简体   繁体   English

如何获取进程特权(Windows驱动程序)?

[英]How retrive Process Privilege (windows drivers)?

I have an object of IRP and EPROCESS in my driver i want to know how can i retrieve process privilege (like normal or Administrator or SYSTEM ) from these structures ? 我的驱动程序中有一个IRP和EPROCESS对象,我想知道如何从这些结构中检索进程特权(例如normalAdministratorSYSTEM )?

 KPROCESSOR_MODE ProcessRequestorMode = pIrp->RequestorMode;
        UNICODE_STRING PRM;
        if (ProcessRequestorMode == KernelMode)
            status = RtlInitUnicodeStringEx(&PRM, L"Kernel-Mode");
        else
        {
            status = RtlInitUnicodeStringEx(&PRM, L"User-Mode");
            //////////////////////////TODO////////////////////
            //retrieving process previlage
            //////////////////////////////////////////////////
        }
        DBGMSG1("Processor Mode : %wZ   ", PRM);
        if (!NT_SUCCESS(status))
        {
            DBGMSG0("Can not convert RequestorMode to UNICODE_STRING\n");
            ASSERT(FALSE);
            return status;
        }

This information is stored in the process token. 此信息存储在过程令牌中。
You can get that using PsReferencePrimaryToken If the process is impersonating you can use PsReferenceImpersonationToken instead. 您可以使用PsReferencePrimaryToken获得该信息,如果该过程正在模拟,则可以改为使用PsReferenceImpersonationToken。 After that you simply query the token for the TokenUser using ZwQueryInformationToken . 之后,您只需使用ZwQueryInformationToken来查询TokenUser的令牌。

Good luck, 祝好运,
Gabriel 加布里埃尔

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

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