1
0
mirror of synced 2024-11-09 12:59:16 +00:00

Fixed: request global privileges (Vista/Terminal Services compatibility)

This commit is contained in:
Mark van Renswoude 2007-08-24 12:21:41 +00:00
parent b44732c18f
commit d7fe576b00

View File

@ -247,6 +247,33 @@ end;
procedure TX2Instance.Open();
procedure AdjustPrivileges();
var
tokenHandle: THandle;
luid: Int64;
newPrivileges: TTokenPrivileges;
returnLength: Cardinal;
begin
if OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or
TOKEN_QUERY, tokenHandle) then
begin
if LookupPrivilegeValue(nil, SE_CREATE_GLOBAL_NAME, luid) then
begin
FillChar(newPrivileges, SizeOf(TTokenPrivileges), #0);
newPrivileges.PrivilegeCount := 1;
newPrivileges.Privileges[0].Luid := luid;
newPrivileges.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
returnLength := 0;
AdjustTokenPrivileges(tokenHandle, False, newPrivileges,
SizeOf(TTokenPrivileges), nil, returnLength);
end;
end;
end;
const
ScopePrefix: array[Boolean] of String = ('Local\', 'Global\');
@ -259,6 +286,11 @@ begin
FFirstInstance := True;
{ Attempt to get global privileges (required for Terminal Services and
Vista) }
if Global then
AdjustPrivileges;
{ Attempt to create shared memory }
SetLastError(0);
FFileMapping := CreateFileMapping($FFFFFFFF, nil, PAGE_READWRITE, 0,