@@ -299,12 +299,31 @@ EPatchResult UpdatePatchStatusTimestamp( const SString& strGTAEXEPath, EPatchMod
299
299
// ////////////////////////////////////////////////////////
300
300
EPatchResult UpdatePatchStatusLargeMem ( const SString& strGTAEXEPath, EPatchMode mode )
301
301
{
302
+ // Get file position of IMAGE_FILE_HEADER->Characteristics
303
+ uint uiFilePosition = 0 ;
304
+ FILE* fh = fopen ( strGTAEXEPath, " rb" );
305
+ if ( fh )
306
+ {
307
+ // 60 is offset of IMAGE_DOS_HEADER->e_lfanew
308
+ if ( !fseek ( fh, 60 , SEEK_SET ) )
309
+ {
310
+ long e_lfanew;
311
+ if ( fread ( &e_lfanew, sizeof ( e_lfanew ), 1 , fh ) == 1 )
312
+ {
313
+ // 4 is offset of IMAGE_NT_HEADERS->FileHeader
314
+ // 18 is offset of IMAGE_FILE_HEADER->Characteristics
315
+ uiFilePosition = e_lfanew + 4 + 18 ;
316
+ }
317
+ }
318
+ fclose ( fh );
319
+ }
320
+
302
321
// Get the value from the header
303
322
ushort usCharacteristics = 0 ;
304
- FILE* fh = fopen ( strGTAEXEPath, " rb" );
323
+ fh = fopen ( strGTAEXEPath, " rb" );
305
324
if ( fh )
306
325
{
307
- if ( !fseek ( fh, 0x96 , SEEK_SET ) )
326
+ if ( !fseek ( fh, uiFilePosition , SEEK_SET ) )
308
327
{
309
328
if ( fread ( &usCharacteristics, sizeof ( usCharacteristics ), 1 , fh ) != 1 )
310
329
{
@@ -341,13 +360,17 @@ EPatchResult UpdatePatchStatusLargeMem( const SString& strGTAEXEPath, EPatchMode
341
360
{
342
361
return PATCH_SET_RESULT_REQ_ADMIN;
343
362
}
344
- if ( !fseek ( fh, 0x96 , SEEK_SET ) )
363
+ if ( !fseek ( fh, uiFilePosition , SEEK_SET ) )
345
364
{
346
365
fwrite ( &usCharacteristicsRequired, sizeof ( usCharacteristicsRequired ), 1 , fh );
347
366
}
348
367
fclose ( fh );
349
368
}
350
369
}
370
+ else
371
+ {
372
+ WriteDebugEventAndReport ( 9805 , SString ( " Unable to set LARGE_ADDRESS_AWARE [FilePosition=0x%x Characteristics=0x%x]" , uiFilePosition, usCharacteristics ) );
373
+ }
351
374
return PATCH_SET_RESULT_OK;
352
375
}
353
376
0 commit comments