Skip to content

Commit a48e21e

Browse files
committed
Added workaround for configuration issues
1 parent 8cdb0ec commit a48e21e

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

Client/loader/MainFunctions.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,11 @@ int LaunchGame ( SString strCmdLine )
10941094
SString strMtaDir = PathJoin( strMTASAPath, "mta" );
10951095

10961096
SetDllDirectory( strMtaDir );
1097-
CheckService ( CHECK_SERVICE_PRE_CREATE );
1097+
if (!CheckService(CHECK_SERVICE_PRE_CREATE) && !IsUserAdmin())
1098+
{
1099+
RelaunchAsAdmin(strCmdLine, _("Fix configuration issue"));
1100+
ExitProcess(EXIT_OK);
1101+
}
10981102

10991103
// Do some D3D things
11001104
BeginD3DStuff();
@@ -1143,9 +1147,8 @@ int LaunchGame ( SString strCmdLine )
11431147
if ( dwError == ERROR_ELEVATION_REQUIRED && !bDoneAdmin )
11441148
{
11451149
// Try to relaunch as admin if not done so already
1146-
ReleaseSingleInstanceMutex ();
1147-
ShellExecuteNonBlocking( "runas", PathJoin ( strMTASAPath, MTA_EXE_NAME ), strCmdLine + " /done-admin" );
1148-
return 5;
1150+
RelaunchAsAdmin(strCmdLine + " /done-admin", _("Fix elevation required error"));
1151+
ExitProcess(EXIT_OK);
11491152
}
11501153
else
11511154
{

Client/loader/Utils.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,17 +1250,20 @@ Return Value:
12501250
}
12511251

12521252

1253-
static SString HashBuffer ( char* pData, uint uiLength )
1253+
//////////////////////////////////////////////////////////
1254+
//
1255+
// RelaunchAsAdmin
1256+
//
1257+
// Relaunch as admin if user agrees
1258+
//
1259+
//////////////////////////////////////////////////////////
1260+
void RelaunchAsAdmin(const SString& strCmdLine, const SString& strReason)
12541261
{
1255-
DWORD dwSum1 = 0;
1256-
DWORD dwSum2 = 0x1234;
1257-
for ( uint i = 0 ; i < uiLength ; i++ )
1258-
{
1259-
dwSum1 += pData[i];
1260-
dwSum2 += pData[i];
1261-
dwSum2 ^= ( dwSum2 << 2 ) + 0x93;
1262-
}
1263-
return SString ( "%08x%08x%08x", dwSum1, dwSum2, uiLength );
1262+
HideSplash();
1263+
AddReportLog(7115, SString("Loader - Request to elevate privilages (%s)", *strReason));
1264+
MessageBoxUTF8(NULL, SString ( _("MTA:SA needs Administrator access for the following task:\n\n '%s'\n\nPlease confirm in the next window."), *strReason), "Multi Theft Auto: San Andreas", MB_OK | MB_ICONINFORMATION | MB_TOPMOST);
1265+
ReleaseSingleInstanceMutex();
1266+
ShellExecuteNonBlocking("runas", PathJoin(GetMTASAPath(), MTA_EXE_NAME), strCmdLine);
12641267
}
12651268

12661269

Client/loader/Utils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ bool IsWindows10OrGreater ( void );
9696
bool IsWindows10Threshold2OrGreater ( void );
9797

9898
BOOL IsUserAdmin ( void );
99+
void RelaunchAsAdmin (const SString& strCmdLine, const SString& strReason);
99100

100101
void UpdateMTAVersionApplicationSetting ( bool bQuiet = false );
101102
bool Is32bitProcess ( DWORD processID );

0 commit comments

Comments
 (0)