How to detect if executable requires UAC elevation (C# pref)

℡╲_俬逩灬. 提交于 2019-11-29 05:20:50

Try using the CheckElevation function exported by kernel32.dll. This is a completely undocumented function, but here's what I've been able to reverse-engineer:

ULONG CheckElevation(
    __in PWSTR FileName,
    __inout PULONG Flags, // Have a ULONG set to 0, and pass a pointer to it
    __in_opt HANDLE TokenHandle, // Use NULL
    __out_opt PULONG Output1, // On output, is 2 or less.
    __out_opt PULONG Output2
    );

You'll have to do some experimentation to find out how to call the function properly. What I've been able to work out so far is that if Output1 is not 0, elevation is required.

Why would you want to use picture recognition if it can be checked programmatically? You can use P/invoke to call CreateProcess with desired parameters.

The best way is to parse its PE format and then know whether its manifest file requires UAC.

http://weblogs.asp.net/kennykerr/archive/2007/07/10/manifest-view-1-0.aspx?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+KennyKerr+(Kenny+Kerr)

Not sure how Kenny wrote the code, but it shows the possibility.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!