[ros-kernel] ReactOS is not loading auto-start drivers anymore

Filip Navara xnavara at volny.cz
Sun Apr 11 19:06:15 CEST 2004


Jason Filby wrote:

>It looks like its a problem with privileges. I just committed an
>updated 
>ntoskrnl/io/driver.c, which when you commented out NDEBUG, shows a 
>message on failure:
>(io/driver.c:1519) Privilege not held
>
>In NtLoadDriver, the first call (to SeSinglePrivilegeCheck), fails.
>But 
>I'm not yet sure why.
>  
>
You're right Jason. The "services" application doesn't acquire the Load 
Driver privilage.
Here is the code, add it to "subsys/system/services/services.c" above 
WinMain and then call it somewhere there :

VOID FASTCALL
AcquireLoadDriverPrivilage(VOID)
{
    HANDLE hProcess;
    HANDLE hToken;
    TOKEN_PRIVILEGES tkp;

    /* Change our priority class to HIGH */
    hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, 
GetCurrentProcessId());
    SetPriorityClass(hProcess, HIGH_PRIORITY_CLASS);
    CloseHandle(hProcess);

    /* Get a token for this process.  */
    if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | 
TOKEN_QUERY, &hToken)) {
        /* Get the LUID for the debug privilege.  */
        LookupPrivilegeValue(NULL, SE_LOAD_DRIVER_NAME, 
&tkp.Privileges[0].Luid);

        tkp.PrivilegeCount = 1;  /* one privilege to set */
        tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

        /* Get the debug privilege for this process. */
        AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, 
(PTOKEN_PRIVILEGES)NULL, 0);
    }
}


- Filip


More information about the Ros-kernel mailing list