开发者

How does Windows pass arguments to a program? (And is there a SetCommandLine function?)

How does the entry开发者_开发知识库 point receive arguments from the command line? I looked through a disassembly of one and found it calls __getmainargs to obtain the arguments. Is there a way to "__setmainargs"? I know that CreateProcess does this already but I want to see how CreateProcess does this


AFAIK the arguments are passed as a single string in memory, so in truth there is just ONE argument - the splitting into several is done by your program. The Kernel receives the argument from the CreateProcess() call and places it in a predefined memory location when setting up the new process.

But that is just my half-educated guess.


At a Win32 level, the application will call GetCommandLine() at some point to retrieve the command line that was given to the CreateProcess() call. There is no corresponding SetCommandLine call, so after a new process is launched there is no way to "change" its command line arguments.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜