Skip to content

Commit

Permalink
Added workaround for configuration issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ccw808 committed Sep 19, 2017
1 parent 8cdb0ec commit a48e21e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
11 changes: 7 additions & 4 deletions Client/loader/MainFunctions.cpp
Expand Up @@ -1094,7 +1094,11 @@ int LaunchGame ( SString strCmdLine )
SString strMtaDir = PathJoin( strMTASAPath, "mta" );

SetDllDirectory( strMtaDir );
CheckService ( CHECK_SERVICE_PRE_CREATE );
if (!CheckService(CHECK_SERVICE_PRE_CREATE) && !IsUserAdmin())
{
RelaunchAsAdmin(strCmdLine, _("Fix configuration issue"));
ExitProcess(EXIT_OK);
}

// Do some D3D things
BeginD3DStuff();
Expand Down Expand Up @@ -1143,9 +1147,8 @@ int LaunchGame ( SString strCmdLine )
if ( dwError == ERROR_ELEVATION_REQUIRED && !bDoneAdmin )
{
// Try to relaunch as admin if not done so already
ReleaseSingleInstanceMutex ();
ShellExecuteNonBlocking( "runas", PathJoin ( strMTASAPath, MTA_EXE_NAME ), strCmdLine + " /done-admin" );
return 5;
RelaunchAsAdmin(strCmdLine + " /done-admin", _("Fix elevation required error"));
ExitProcess(EXIT_OK);
}
else
{
Expand Down
23 changes: 13 additions & 10 deletions Client/loader/Utils.cpp
Expand Up @@ -1250,17 +1250,20 @@ Return Value:
}


static SString HashBuffer ( char* pData, uint uiLength )
//////////////////////////////////////////////////////////
//
// RelaunchAsAdmin
//
// Relaunch as admin if user agrees
//
//////////////////////////////////////////////////////////
void RelaunchAsAdmin(const SString& strCmdLine, const SString& strReason)
{
DWORD dwSum1 = 0;
DWORD dwSum2 = 0x1234;
for ( uint i = 0 ; i < uiLength ; i++ )
{
dwSum1 += pData[i];
dwSum2 += pData[i];
dwSum2 ^= ( dwSum2 << 2 ) + 0x93;
}
return SString ( "%08x%08x%08x", dwSum1, dwSum2, uiLength );
HideSplash();
AddReportLog(7115, SString("Loader - Request to elevate privilages (%s)", *strReason));
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);
ReleaseSingleInstanceMutex();
ShellExecuteNonBlocking("runas", PathJoin(GetMTASAPath(), MTA_EXE_NAME), strCmdLine);
}


Expand Down
1 change: 1 addition & 0 deletions Client/loader/Utils.h
Expand Up @@ -96,6 +96,7 @@ bool IsWindows10OrGreater ( void );
bool IsWindows10Threshold2OrGreater ( void );

BOOL IsUserAdmin ( void );
void RelaunchAsAdmin (const SString& strCmdLine, const SString& strReason);

void UpdateMTAVersionApplicationSetting ( bool bQuiet = false );
bool Is32bitProcess ( DWORD processID );
Expand Down

0 comments on commit a48e21e

Please sign in to comment.