<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[command line modifizieren]]></title><description><![CDATA[<p>Hi,</p>
<p>es gibt ja die Funktion GetCommandLine um die Commandline des Prozesses auszulesen. Ich muss die Commandline nun aber modifizieren, SetCommandLine gibts leider nicht, gibt es einen WinAPI weg um dies zu tun oder muss man da mit undokumentiertem kram rumpantschen?!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/222367/command-line-modifizieren</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Apr 2026 16:20:40 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/222367.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 11 Sep 2008 15:48:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to command line modifizieren on Thu, 11 Sep 2008 15:48:15 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>es gibt ja die Funktion GetCommandLine um die Commandline des Prozesses auszulesen. Ich muss die Commandline nun aber modifizieren, SetCommandLine gibts leider nicht, gibt es einen WinAPI weg um dies zu tun oder muss man da mit undokumentiertem kram rumpantschen?!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1580398</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1580398</guid><dc:creator><![CDATA[Erwin20]]></dc:creator><pubDate>Thu, 11 Sep 2008 15:48:15 GMT</pubDate></item><item><title><![CDATA[Reply to command line modifizieren on Thu, 11 Sep 2008 15:56:46 GMT]]></title><description><![CDATA[<p>ich meine ich kann natürlich sowas machen, aber das ist wohl kaum sehr zu empfehlen?!</p>
<pre><code class="language-cpp">CHAR szNewCmdLine[] = &quot;O:\\Path\\To\\Application\\MyApp.exe&quot;;

	strcpy(GetCommandLine(), szNewCmdLine);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1580402</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1580402</guid><dc:creator><![CDATA[Erwin20]]></dc:creator><pubDate>Thu, 11 Sep 2008 15:56:46 GMT</pubDate></item><item><title><![CDATA[Reply to command line modifizieren on Thu, 11 Sep 2008 19:13:46 GMT]]></title><description><![CDATA[<p>Dann erklär doch mal bitte aus welchem Grund Du das möchtest!<br />
Mir fällt keiner ein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1580467</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1580467</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Thu, 11 Sep 2008 19:13:46 GMT</pubDate></item><item><title><![CDATA[Reply to command line modifizieren on Thu, 11 Sep 2008 20:36:57 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>Ich habe eine Funktion wie execv aus POSIX gemacht um das prozess image auszutauschen, es funktioniert auch gut nur würde ich gerne auch die kommandozeilen parameter über execv mitangeben können...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1580497</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1580497</guid><dc:creator><![CDATA[Erwin20]]></dc:creator><pubDate>Thu, 11 Sep 2008 20:36:57 GMT</pubDate></item><item><title><![CDATA[Reply to command line modifizieren on Fri, 12 Sep 2008 11:05:46 GMT]]></title><description><![CDATA[<p>Ich habe jetzt versucht im PEB die Commandline zu ändern, aber GetCommandLine() liefert immer noch die alte Kommandozeile, also muss es sich die noch von woanders holen oder zwischenspeichern. Hast du vielleicht noch einen Tip, Martin?</p>
<p>peb.c</p>
<pre><code class="language-cpp">#include &quot;peb.h&quot;

NTFUNC NtDllCall( LPCSTR lpFunc ) {
	return (NTFUNC)GetProcAddress(LoadLibrary(&quot;NTDLL&quot;),
		lpFunc);
}

BOOL SetCommandLine( LPTSTR lpCmdLine ) {
	PROCESS_BASIC_INFORMATION pbi;

	NtDllCall(&quot;NtQueryInformationProcess&quot;)(GetCurrentProcess(),
		ProcessBasicInformation, &amp;pbi, sizeof(pbi), 0);

	/* test */
	pbi.PebBaseAddress-&gt;ProcessParameters-&gt;CommandLine.Buffer = NULL;
	pbi.PebBaseAddress-&gt;ProcessParameters-&gt;CommandLine.Length = 0;

	NtDllCall(&quot;NtSetInformationProcess&quot;)(GetCurrentProcess(),
		ProcessBasicInformation, &amp;pbi, sizeof(pbi));
	return TRUE;
}

int main(int argc, char *argv[]) {
	SetCommandLine(&quot;O:\\TEST.EXE&quot;);

	printf(&quot;%s\n&quot;, GetCommandLine());
	return 0;
}
</code></pre>
<p>peb.h</p>
<pre><code class="language-cpp">#ifndef _PEB_H_
#define _PEB_H_

#include &lt;Windows.h&gt;
#include &lt;stdio.h&gt;

typedef LPVOID (WINAPI *NTFUNC)();

#define ProcessBasicInformation	0x00

typedef struct _UNICODE_STRING {
	USHORT	Length;
	USHORT	MaximumLength;
	PWSTR	Buffer;
} UNICODE_STRING, *PUNICODE_STRING;

typedef struct _PEB_LDR_DATA {
	BYTE		Reserved1[8];
	PVOID		Reserved2[3];
	LIST_ENTRY	InMemoryOrderModuleList;
} PEB_LDR_DATA, *PPEB_LDR_DATA;

typedef struct _RTL_USER_PROCESS_PARAMETERS {
	BYTE			Reserved1[16];
	PVOID			Reserved2[10];
	UNICODE_STRING	ImagePathName;
	UNICODE_STRING	CommandLine;
} RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS;

typedef struct _PEB {
	BYTE Reserved1[2];
	BYTE BeingDebugged;
	BYTE Reserved2[1];
	PVOID Reserved3[2];
	PPEB_LDR_DATA Ldr;
	PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
	BYTE Reserved4[104];
	PVOID Reserved5[52];
/*	PPS_POST_PROCESS_INIT_ROUTINE PostProcessInitRoutine;*/
	PVOID PostProcessInitRoutine;

	BYTE Reserved6[128];
	PVOID Reserved7[1];
	ULONG SessionId;
} PEB, *PPEB;

typedef struct _PROCESS_BASIC_INFORMATION {
	PVOID	Reserved1;
	PPEB	PebBaseAddress;
	PVOID	Reserved2[2];
	PULONG	UniqueProcessId;
	PVOID	Reserved3;
} PROCESS_BASIC_INFORMATION;

#endif /* _PEB_H_ */
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1580820</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1580820</guid><dc:creator><![CDATA[Erwin20]]></dc:creator><pubDate>Fri, 12 Sep 2008 11:05:46 GMT</pubDate></item><item><title><![CDATA[Reply to command line modifizieren on Fri, 12 Sep 2008 11:13:38 GMT]]></title><description><![CDATA[<p>Ich verstehe nicht, was dies innerhalb ein und des selben Prozesses soll? Was hat das mit execv zu tun?<br />
Zudem findest Du _execv in der CRT von VS!</p>
<p>Für fremde prozesse gibst Du die Infos eben mit, die Du brauchst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1580823</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1580823</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Fri, 12 Sep 2008 11:13:38 GMT</pubDate></item></channel></rss>