@@ -104,7 +104,7 @@ public static ref T Read<T>(long address) where T : unmanaged
104104 => ref Read < T > ( ( IntPtr ) address ) ;
105105
106106 public static byte [ ] Assemble ( string source )
107- => MemoryProvider . AssembleInstructions ( source ) ;
107+ => MemoryProvider . AssembleInstructions ( RemoveComments ( source ) ) ;
108108
109109 public static long GetPointer ( long address , params long [ ] offsets )
110110 {
@@ -154,7 +154,7 @@ public static void WriteProtected<T>(long address, params T[] data) where T : un
154154 }
155155
156156 public static void WriteAsmHook ( string instructions , long address , HookBehavior behavior = HookBehavior . After , HookParameter parameter = HookParameter . Jump )
157- => MemoryProvider . WriteASMHook ( instructions , ( IntPtr ) address , ( int ) behavior , ( int ) parameter ) ;
157+ => MemoryProvider . WriteASMHook ( RemoveComments ( instructions ) , ( IntPtr ) address , ( int ) behavior , ( int ) parameter ) ;
158158
159159 public static void WriteAsmHook ( string instructions , long address , HookParameter parameter , HookBehavior behavior )
160160 => WriteAsmHook ( instructions , address , behavior , parameter ) ;
@@ -204,6 +204,24 @@ public static long ScanSignature(params string[] sigs)
204204 return 0 ;
205205 }
206206
207+ public static string RemoveComments ( string instructions )
208+ {
209+ var lines = instructions . Split ( new char [ ] { '\n ' } ) ;
210+ var sb = new StringBuilder ( ) ;
211+ foreach ( var line in lines )
212+ {
213+ string processedLine = line . Trim ( ) ;
214+ if ( string . IsNullOrEmpty ( processedLine ) )
215+ continue ;
216+ var index = processedLine . IndexOf ( ';' ) ;
217+ if ( index != - 1 )
218+ processedLine = processedLine . Substring ( 0 , index ) ;
219+ sb . Append ( processedLine ) ;
220+ sb . Append ( "\r \n " ) ;
221+ }
222+ return sb . ToString ( ) ;
223+ }
224+
207225 public static bool IsKeyDown ( Keys key )
208226 => ( GetAsyncKeyState ( key ) & 1 ) != 0 ;
209227
0 commit comments