Do I need to copy command line arguments in assembly

Viewed 80

I work with fasm but maybe this question doesn't rely on assembly language version. Where is command line arguments string stored? Do I need to copy this string at program start or it is guaranteed to persist indefinitely? Can buffer overflows etc from my program overwrite original?

1 Answers

Command line arguments are part of the process environment block (PEB) and do not change after the process starts. You can access the command line via GetCommandLineW, and you can parse the arguments yourself. There also exists CommandLineToArgvW which does some parsing for you.

The string data is in writable memory, so yes if you have buggy / insecure code that modifies one arg, an overflow in it could modify another one.

Related