简体   繁体   English

有人可以解释RtlAdjustPrivilege

[英]Can someone explain RtlAdjustPrivilege

I have knowledge of java and python ,but any language containing C in its name is so hard to understand and learn. 我具有Java和python的知识,但是任何以C命名的语言都很难理解和学习。 Recently i was trying to create BSOD in windows using NtRaiseHardError and after few (unsuccessful) tries in c++ I turned to c#. 最近,我试图使用NtRaiseHardError在Windows中创建BSOD,在c ++中尝试了几次(不成功)之后,我转向了c#。

Using code from here i was able to make a program and cause bsod. 这里使用代码,我能够制作一个程序并导致bsod。 Later i tried to fully understand the code but i can not understand what RtlAdjustPrivilege is doing. 后来我试图完全理解代码,但我不明白RtlAdjustPrivilege在做什么。

I see that it is some kind of privilege changing but while program is running i see no administrator password prompts despite the fact that i am using user account so i believe that it is not escalating to admin privileges. 我看到这是一种特权更改,但是在程序运行时,尽管我使用的是用户帐户,但我看不到任何管理员密码提示,因此我认为它不会升级为管理员特权。 If someone know what exactly this function does or how it works please explain it. 如果有人知道此功能的确切功能或工作方式,请对其进行解释。 This is how it is implemented: 它是这样实现的:

To import it: 要导入它:

[DllImport("ntdll.dll")]
private static extern uint RtlAdjustPrivilege
(
    int Privilege,
    bool bEnablePrivilege,
    bool IsThreadPrivilege,
    out bool PreviousValue
);

And later use it: 然后使用它:

RtlAdjustPrivilege(19, true, false, out bool previousValue);

19 is SE_SHUTDOWN_PRIVILEGE - declared in wdm.h . 19是SE_SHUTDOWN_PRIVILEGEwdm.h中声明。

RtlAdjustPrivilege open current process (if IsThreadPrivilege := false ) or current thread (if IsThreadPrivilege := true )token, then call ZwAdjustPrivilegeToken ( AdjustTokenPrivileges is thin shell over this api) and finally close open token. RtlAdjustPrivilege打开当前进程(如果IsThreadPrivilege:= false )或当前线程(如果IsThreadPrivilege:= true )令牌,则调用ZwAdjustPrivilegeTokenAdjustTokenPrivileges是此API的薄壳),最后关闭打开的令牌。

The ZwAdjustPrivilegeToken ( AdjustTokenPrivileges ) function enables or disables privileges in the specified access token. ZwAdjustPrivilegeTokenAdjustTokenPrivileges )函数启用或禁用指定访问令牌中的特权。 but privilege must be already in token 但是特权必须已经在令牌中

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

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