where command line arguments are stored?

前端 未结 4 1888
逝去的感伤
逝去的感伤 2021-01-13 16:29

I have a doubt @ the storage of command line arguments.

myprog.exe -cfgfile myconfig.cfg

commandline args are passed when process gets created so are they

4条回答
  •  北荒
    北荒 (楼主)
    2021-01-13 16:33

    For WIndows, the command line arguments are kept in the process environment block (PEB), which is allocated in the user process address space when the process is created.

    You can read Windows Internals for a lot more details. Here's a snippet from Chapter 5 - Processes, Threads, and Jobs.

    I would assume that it's the same for the Unix flavors. This data needs to be in the process memory, so that it can be accessed by the process itself.

提交回复
热议问题