The following test was failing in Windows Server 2003:
/* Test without privilege */
NtSetSystemInformation(SystemTimeAdjustmentInformation, &SetTimeInfo, sizeof(SetTimeInfo));
The reason is that when the call to the NT function is performed, the process token has the SE_PRIVILEGE_ENABLED already set thanks to the GetPrivilege() previous call.
The Patch attached:
- Implements ResetPrivilege() which resets the SE_PRIVILEGE_ENABLED before performing the call.
- Fixes a token handle leak.