[英]Opening command line program with elevated rights
I am currently writing a DLL injection program (C++) which adds specified certificate to certmgr.exe
.我目前正在编写一个 DLL 注入程序(C++),它将指定的证书添加到
certmgr.exe
。
I wrote the whole thing connected with injection ( OpenProcess
, etc.).我写了与注入有关的整个事情(
OpenProcess
等)。 When I am executing it - attached to svchost
- my DLL is not loading since it seems that it doesn't have such rights as svchost
has.当我执行它时 - 附加到
svchost
- 我的 DLL 没有加载,因为它似乎没有svchost
那样的权限。
How can I pass rights?我如何传递权利?
In my DLL file, I am using system("certmgr.exe -add ....")
and I think this might be the problem because the command line opens as a separate program (as if I opened it via start
).在我的 DLL 文件中,我使用的是
system("certmgr.exe -add ....")
我认为这可能是问题所在,因为命令行作为单独的程序打开(就像我通过start
打开它一样)。
Use ShellExecute() using the "runas" argument, which will make it try to run as administrator使用“runas”参数使用ShellExecute() ,这将使其尝试以管理员身份运行
ShellExecuteA( NULL,
"runas",
"c:\\windows\\certmgr.exe",
"-add ....",
NULL,
SW_SHOWNORMAL
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.