@@ -349,9 +349,6 @@ WString devicePathToWin32Path ( const WString& strDevicePath )
349
349
}
350
350
351
351
352
- typedef WINBASEAPI BOOL (WINAPI *LPFN_QueryFullProcessImageNameW)(__in HANDLE hProcess, __in DWORD dwFlags, __out_ecount_part(*lpdwSize, *lpdwSize) LPWSTR lpExeName, __inout PDWORD lpdwSize);
353
-
354
-
355
352
// /////////////////////////////////////////////////////////////////////////
356
353
//
357
354
// GetProcessPathFilename
@@ -361,17 +358,7 @@ typedef WINBASEAPI BOOL (WINAPI *LPFN_QueryFullProcessImageNameW)(__in HANDLE hP
361
358
// /////////////////////////////////////////////////////////////////////////
362
359
SString GetProcessPathFilename ( DWORD processID )
363
360
{
364
- static LPFN_QueryFullProcessImageNameW fnQueryFullProcessImageNameW = NULL ;
365
- static bool bDoneGetProcAddress = false ;
366
- if ( !bDoneGetProcAddress )
367
- {
368
- // Find 'QueryFullProcessImageNameA'
369
- bDoneGetProcAddress = true ;
370
- HMODULE hModule = GetModuleHandle ( " Kernel32.dll" );
371
- fnQueryFullProcessImageNameW = static_cast < LPFN_QueryFullProcessImageNameW > ( static_cast < PVOID > ( GetProcAddress ( hModule, " QueryFullProcessImageNameW" ) ) );
372
- }
373
-
374
- if ( fnQueryFullProcessImageNameW )
361
+ if ( _QueryFullProcessImageNameW )
375
362
{
376
363
for ( int i = 0 ; i < 2 ; i++ )
377
364
{
@@ -380,7 +367,7 @@ SString GetProcessPathFilename ( DWORD processID )
380
367
{
381
368
WCHAR szProcessName[MAX_PATH] = L" " ;
382
369
DWORD dwSize = NUMELMS (szProcessName);
383
- DWORD bOk = fnQueryFullProcessImageNameW ( hProcess, 0 , szProcessName, &dwSize );
370
+ DWORD bOk = _QueryFullProcessImageNameW ( hProcess, 0 , szProcessName, &dwSize );
384
371
CloseHandle ( hProcess );
385
372
if ( bOk )
386
373
{
@@ -433,6 +420,23 @@ SString GetProcessPathFilename ( DWORD processID )
433
420
}
434
421
}
435
422
423
+ if ( _NtQuerySystemInformation )
424
+ {
425
+ SYSTEM_PROCESS_IMAGE_NAME_INFORMATION info;
426
+ WCHAR szProcessName[MAX_PATH] = L" " ;
427
+ info.ProcessId = (HANDLE)processID;
428
+ info.ImageName .Length = 0 ;
429
+ info.ImageName .MaximumLength = sizeof (szProcessName);
430
+ info.ImageName .Buffer = szProcessName;
431
+
432
+ NTSTATUS status = _NtQuerySystemInformation (SystemProcessImageNameInformation, &info, sizeof (info), NULL );
433
+ if (NT_SUCCESS (status))
434
+ {
435
+ WString strProcessName = WStringX (info.ImageName .Buffer , info.ImageName .Length / 2 );
436
+ return ToUTF8 (devicePathToWin32Path (strProcessName));
437
+ }
438
+ }
439
+
436
440
return " " ;
437
441
}
438
442
@@ -1260,7 +1264,7 @@ Return Value:
1260
1264
void RelaunchAsAdmin (const SString& strCmdLine, const SString& strReason)
1261
1265
{
1262
1266
HideSplash ();
1263
- AddReportLog (7115 , SString (" Loader - Request to elevate privilages (%s)" , *strReason));
1267
+ AddReportLog (7115 , SString (" Loader - Request to elevate privileges (%s)" , *strReason));
1264
1268
MessageBoxUTF8 (NULL , SString ( _ (" MTA:SA needs Administrator access for the following task:\n\n '%s'\n\n Please confirm in the next window." ), *strReason), " Multi Theft Auto: San Andreas" , MB_OK | MB_ICONINFORMATION | MB_TOPMOST);
1265
1269
ReleaseSingleInstanceMutex ();
1266
1270
ShellExecuteNonBlocking (" runas" , PathJoin (GetMTASAPath (), MTA_EXE_NAME), strCmdLine);
0 commit comments