识别命令行参数
可能的重复:
Windows 程序:如何监听命令行参数?
我在 Windows XP 下工作。
我获得了一些第三方软件,这些软件在启动时会生成多个进程。我的任务是编写该软件的替代品,尽管我需要保留其中一个进程(一个“通信服务器”,用于向其他联网计算机上的相同“通信服务器”传递消息/从其他联网计算机上的相同“通信服务器”接收消息)。这个过程的一小部分是学习直接启动“通信服务器”。如果我只是在没有命令行参数的情况下启动它,它会立即死掉。我认为这需要一些论据。所以,我所有的问题都归结为......
对于任何任意过程,是否有可能看到它以什么参数开始?如果是这样,我该怎么做?
我尝试附加 Visual Studio 2010,但没有 .pdb,所以我什么也没得到。不幸的是,我不知道这个“通信服务器”是用什么语言编写的。所以,这确实是一个不太可能的事情。 (我不确定这样做是否能给我一种找到论据的方法,但我认为值得一试。)
谢谢, 戴夫(Dave
)抱歉标签选择不当。这是一个很难分类的问题...
Possible Duplicate:
Windows Program: How to snoop on command line arguments?
I am working under Windows XP.
I've been given some third-party software that spawns several processes when launched. I've been tasked with writing a replacement for this software, though I will need to keep one of its proceeses (a "communication server" that passes / receives messages to / from identical "communication servers" on other networked machines). One small part of this process is learning to start the "communication server" directly. If I just start it with no arguments from the command line, it immediately dies. I'm thinking it needs some arguments. So, all my question boils down to is...
Is it possible, for any arbitrary process, to see what arguments it was started with? If so, how may I do so?
I tried attaching Visual Studio 2010, but there's no .pdb, so I got nothing. Unfortunately, I do not know what language this "communication server" is written in. So, it was really a longshot. (I wasn't sure if doing so would give me a way to find the arguments anyway, but I thought it was worth a try.)
Thanks,
Dave
P.S. Sorry for the poor choice of tags. This is a tough one to categorize...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Process Explorer 显示它们。右键单击列表中的进程,然后单击
Properties...
->图像
->命令行
它不是 100% 可靠,因为进程可以覆盖包含命令行的缓冲区,但通常它可以工作。
Process Explorer displays them. Right click on a process in the list, then
Properties...
->Image
->Command line
It's not 100% reliable since the process can overwrite the buffer containing the command line, but usually it works.
进程资源管理器将允许您查看给定运行的命令行参数过程 :)
Process explorer will allow you to see the command line arguments for a given running process :)
应用程序本身不需要 PDB。 Windows DLL 具有 PDB;在
CreateProcess
和ShellExecute
/CreateProcessAsUser
等变体上放置断点。You don't need the PDB for the app itself. Windows DLLs have PDB's; put a breakpoint on
CreateProcess
and variants likeShellExecute
/CreateProcessAsUser
.