1

每当我关闭我的应用程序时,我都会尝试自己蓝屏死机(强制蓝屏死机)。不幸的是,当我打电话时,Process.EnterDebugMode();我得到了一个例外:Not all privileges or groups referenced are assigned to the caller.

我写了键盘记录器(那部分已经完成),它假设监视将修理我的笔记本电脑的服务人员,这样我就会知道他是否没有做任何有趣的事情。

[DllImport("ntdll.dll", SetLastError = true)]
private static extern int NtSetInformationProcess(IntPtr hProcess, int processInformationClass, ref int processInformation, int processInformationLength);

public static void Main() {
    int isCritical = 1;  // we want this to be a Critical Process
    int BreakOnTermination = 0x1D;  // value for BreakOnTermination (flag)


    Process.EnterDebugMode();  //acquire Debug Privileges

    // setting the BreakOnTermination = 1 for the current process
    NtSetInformationProcess(Process.GetCurrentProcess().Handle, BreakOnTermination, ref isCritical, sizeof(int));
4

1 回答 1

5

您的程序需要以管理员权限运行。如果您这样做,您的程序将按照您的预期运行。

您可以使用 app.manifest 通过 app.manfest 轻松获得程序请求权限 - 在 VS 中右键单击您的项目并添加应用程序清单文件。生成的评论中有说明,但您需要替换

<requestedExecutionLevel level="asInvoker" uiAccess="false" />

<requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />
于 2015-05-06T22:54:46.247 回答