|
@@ -49,7 +49,9 @@ type
|
|
|
|
|
|
function CheckForMutexes(const Mutexes: String): Boolean;
|
|
function CheckForMutexes(const Mutexes: String): Boolean;
|
|
procedure CreateMutexes(const Mutexes: String);
|
|
procedure CreateMutexes(const Mutexes: String);
|
|
-function CreateTempDir(const LimitCurrentUserSidAccess: Boolean): String;
|
|
|
|
|
|
+function CreateTempDir(const LimitCurrentUserSidAccess: Boolean;
|
|
|
|
+ var Protected: Boolean): String; overload;
|
|
|
|
+function CreateTempDir(const LimitCurrentUserSidAccess: Boolean): String; overload;
|
|
function DecrementSharedCount(const RegView: TRegView; const Filename: String): Boolean;
|
|
function DecrementSharedCount(const RegView: TRegView; const Filename: String): Boolean;
|
|
procedure DelayDeleteFile(const DisableFsRedir: Boolean; const Filename: String;
|
|
procedure DelayDeleteFile(const DisableFsRedir: Boolean; const Filename: String;
|
|
const MaxTries, FirstRetryDelayMS, SubsequentRetryDelayMS: Integer);
|
|
const MaxTries, FirstRetryDelayMS, SubsequentRetryDelayMS: Integer);
|
|
@@ -175,7 +177,7 @@ function ConvertStringSecurityDescriptorToSecurityDescriptorW(
|
|
dummy: Pointer): BOOL; stdcall; external advapi32;
|
|
dummy: Pointer): BOOL; stdcall; external advapi32;
|
|
|
|
|
|
function CreateSafeDirectory(const LimitCurrentUserSidAccess: Boolean; Path: String;
|
|
function CreateSafeDirectory(const LimitCurrentUserSidAccess: Boolean; Path: String;
|
|
- var ErrorCode: DWORD): Boolean;
|
|
|
|
|
|
+ var ErrorCode: DWORD; var Protected: Boolean): Boolean; overload;
|
|
{ Creates a protected directory if
|
|
{ Creates a protected directory if
|
|
-it's a subdirectory of c:\WINDOWS\TEMP, or
|
|
-it's a subdirectory of c:\WINDOWS\TEMP, or
|
|
-it's on a local drive and LimitCurrentUserSidAccess is True (latter is true atm if elevated and not debugging)
|
|
-it's on a local drive and LimitCurrentUserSidAccess is True (latter is true atm if elevated and not debugging)
|
|
@@ -192,7 +194,9 @@ begin
|
|
not PathCharIsSlash(Drive[1]) and
|
|
not PathCharIsSlash(Drive[1]) and
|
|
(GetDriveType(PChar(AddBackslash(Drive))) <> DRIVE_REMOTE);
|
|
(GetDriveType(PChar(AddBackslash(Drive))) <> DRIVE_REMOTE);
|
|
|
|
|
|
- if IsUnderWindowsTemp or IsLocalTempToProtect then begin
|
|
|
|
|
|
+ Protected := IsUnderWindowsTemp or IsLocalTempToProtect;
|
|
|
|
+
|
|
|
|
+ if Protected then begin
|
|
var StringSecurityDescriptor :=
|
|
var StringSecurityDescriptor :=
|
|
// D: adds a Discretionary ACL ("DACL", i.e. access control via SIDs)
|
|
// D: adds a Discretionary ACL ("DACL", i.e. access control via SIDs)
|
|
// P: prevents DACL from being modified by inheritable ACEs
|
|
// P: prevents DACL from being modified by inheritable ACEs
|
|
@@ -245,6 +249,13 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function CreateSafeDirectory(const LimitCurrentUserSidAccess: Boolean; Path: String;
|
|
|
|
+ var ErrorCode: DWORD): Boolean; overload;
|
|
|
|
+begin
|
|
|
|
+ var Protected: Boolean;
|
|
|
|
+ Result := CreateSafeDirectory(LimitCurrentUserSidAccess, Path, ErrorCode, Protected);
|
|
|
|
+end;
|
|
|
|
+
|
|
function IntToBase32(Number: Longint): String;
|
|
function IntToBase32(Number: Longint): String;
|
|
const
|
|
const
|
|
Table: array[0..31] of Char = '0123456789ABCDEFGHIJKLMNOPQRSTUV';
|
|
Table: array[0..31] of Char = '0123456789ABCDEFGHIJKLMNOPQRSTUV';
|
|
@@ -319,7 +330,8 @@ begin
|
|
until False; // continue until a new directory was created
|
|
until False; // continue until a new directory was created
|
|
end;
|
|
end;
|
|
|
|
|
|
-function CreateTempDir(const LimitCurrentUserSidAccess: Boolean): String;
|
|
|
|
|
|
+function CreateTempDir(const LimitCurrentUserSidAccess: Boolean;
|
|
|
|
+ var Protected: Boolean): String;
|
|
{ This is called by SetupLdr, Setup, and Uninstall. }
|
|
{ This is called by SetupLdr, Setup, and Uninstall. }
|
|
var
|
|
var
|
|
Dir: String;
|
|
Dir: String;
|
|
@@ -327,7 +339,7 @@ var
|
|
begin
|
|
begin
|
|
while True do begin
|
|
while True do begin
|
|
Dir := GenerateUniqueName(False, GetTempDir, '.tmp');
|
|
Dir := GenerateUniqueName(False, GetTempDir, '.tmp');
|
|
- if CreateSafeDirectory(LimitCurrentUserSidAccess, Dir, ErrorCode) then
|
|
|
|
|
|
+ if CreateSafeDirectory(LimitCurrentUserSidAccess, Dir, ErrorCode, Protected) then
|
|
Break;
|
|
Break;
|
|
if ErrorCode <> ERROR_ALREADY_EXISTS then
|
|
if ErrorCode <> ERROR_ALREADY_EXISTS then
|
|
raise Exception.Create(FmtSetupMessage(msgLastErrorMessage,
|
|
raise Exception.Create(FmtSetupMessage(msgLastErrorMessage,
|
|
@@ -337,6 +349,12 @@ begin
|
|
Result := Dir;
|
|
Result := Dir;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function CreateTempDir(const LimitCurrentUserSidAccess: Boolean): String;
|
|
|
|
+begin
|
|
|
|
+ var Protected: Boolean;
|
|
|
|
+ Result := CreateTempDir(LimitCurrentUserSidAccess, Protected);
|
|
|
|
+end;
|
|
|
|
+
|
|
function ReplaceSystemDirWithSysWow64(const Path: String): String;
|
|
function ReplaceSystemDirWithSysWow64(const Path: String): String;
|
|
{ If the user is running 64-bit Windows and Path begins with
|
|
{ If the user is running 64-bit Windows and Path begins with
|
|
'x:\windows\system32' it replaces it with 'x:\windows\syswow64', like the
|
|
'x:\windows\system32' it replaces it with 'x:\windows\syswow64', like the
|