1- using System ;
2- using System . Diagnostics ;
3- using System . Reflection ;
4-
5- using FFXCutsceneRemover . ComponentUtil ;
1+ using FFXCutsceneRemover . ComponentUtil ;
62using FFXCutsceneRemover . Logging ;
73using FFXCutsceneRemover . Resources ;
4+ using System ;
5+ using System . ComponentModel ;
6+ using System . Diagnostics ;
7+ using System . Reflection ;
88
99namespace FFXCutsceneRemover ;
1010
@@ -14,6 +14,7 @@ public static class MemoryWatchers
1414 private const string MODULE = "FFX.exe" ;
1515
1616 private static int processBaseAddress ;
17+ private static int getBaseAddressMaxAttempts = 1000 ;
1718
1819 public static Process Process ;
1920 public static MemoryWatcherList Watchers = new MemoryWatcherList ( ) ;
@@ -42,7 +43,7 @@ public static class MemoryWatchers
4243 public static MemoryWatcher < byte > MovementLock ;
4344 public static MemoryWatcher < byte > ActiveMusicId ;
4445 public static MemoryWatcher < byte > MusicId ;
45- public static MemoryWatcher < byte > RoomNumberAlt ;
46+ public static MemoryWatcher < short > RoomNumberAlt ;
4647 public static MemoryWatcher < short > CutsceneAlt ;
4748 public static MemoryWatcher < short > AirshipDestinations ;
4849 public static MemoryWatcher < byte > AuronOverdrives ;
@@ -312,7 +313,21 @@ public static class MemoryWatchers
312313 public static void Initialize ( Process process )
313314 {
314315 Process = process ;
315- processBaseAddress = process . Modules [ 0 ] . BaseAddress . ToInt32 ( ) ;
316+ processBaseAddress = - 1 ;
317+
318+ for ( int i = 0 ; i < getBaseAddressMaxAttempts ; i ++ )
319+ {
320+ try
321+ {
322+ processBaseAddress = process . Modules [ 0 ] . BaseAddress . ToInt32 ( ) ;
323+ break ;
324+ }
325+ catch ( Win32Exception e )
326+ {
327+ DiagnosticLog . Information ( "Exception: " + e . Message ) ;
328+ }
329+ }
330+
316331 DiagnosticLog . Information ( $ "Process base address: { processBaseAddress : X8} ") ;
317332
318333 Language = GetMemoryWatcher < byte > ( MemoryLocations . Language ) ;
@@ -339,7 +354,7 @@ public static void Initialize(Process process)
339354 MovementLock = GetMemoryWatcher < byte > ( MemoryLocations . MovementLock ) ;
340355 ActiveMusicId = GetMemoryWatcher < byte > ( MemoryLocations . ActiveMusicId ) ;
341356 MusicId = GetMemoryWatcher < byte > ( MemoryLocations . MusicId ) ;
342- RoomNumberAlt = GetMemoryWatcher < byte > ( MemoryLocations . RoomNumberAlt ) ;
357+ RoomNumberAlt = GetMemoryWatcher < short > ( MemoryLocations . RoomNumberAlt ) ;
343358 CutsceneAlt = GetMemoryWatcher < short > ( MemoryLocations . CutsceneAlt ) ;
344359 AirshipDestinations = GetMemoryWatcher < short > ( MemoryLocations . AirshipDestinations ) ;
345360 AuronOverdrives = GetMemoryWatcher < byte > ( MemoryLocations . AuronOverdrives ) ;
0 commit comments