简体   繁体   English

我是否需要在程序集中复制命令行 arguments

[英]Do I need to copy command line arguments in assembly

I work with fasm but maybe this question doesn't rely on assembly language version.我与 fasm 合作,但也许这个问题不依赖于汇编语言版本。 Where is command line arguments string stored?命令行 arguments 字符串存储在哪里? 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?我的程序中的缓冲区溢出等可以覆盖原始文件吗?

Command line arguments are part of the process environment block (PEB) and do not change after the process starts.命令行 arguments 是进程环境块 (PEB)的一部分,在进程启动后不会更改。 You can access the command line via GetCommandLineW , and you can parse the arguments yourself.您可以通过GetCommandLineW访问命令行,也可以自己解析 arguments。 There also exists CommandLineToArgvW which does some parsing for you.还存在CommandLineToArgvW可以为您进行一些解析。

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.字符串数据在可写的 memory 中,所以是的,如果您有修改一个 arg 的错误/不安全代码,其中的溢出可能会修改另一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM