@@ -116,7 +116,11 @@ public static unsafe class NativeMemory
116116 static NativeMemory ( )
117117 {
118118 byte * address ;
119- }
119+
120+ /*address = FindPattern("\x40\x53\x48\x83\xEC\x20\x33\xDB\x38\x1D\x00\x00\x00\x00\x74\x1C", "xxxxxxxxxx????xx");
121+ GetPlayerAddressFunc = GetDelegateForFunctionPointer<GetHandleAddressFuncDelegate>(
122+ new IntPtr(*(int*)(address + 3) + address + 7));*/
123+ }
120124
121125 /// <summary>
122126 /// Reads a single 8-bit value from the specified <paramref name="address"/>.
@@ -315,43 +319,36 @@ public static string PtrToStringUTF8(IntPtr ptr)
315319
316320 return PtrToStringUTF8 ( ptr , len ) ;
317321 }
318- public static string PtrToStringUTF8 ( IntPtr ptr , int len )
322+ public static string PtrToStringUTF8 ( IntPtr nativeUtf8 , int len )
319323 {
320- if ( len < 0 )
321- throw new ArgumentException ( null , nameof ( len ) ) ;
322-
323- if ( ptr == IntPtr . Zero )
324- return null ;
325- if ( len == 0 )
326- return string . Empty ;
327-
328- return Encoding . UTF8 . GetString ( ( byte * ) ptr . ToPointer ( ) , len ) ;
329- }
324+ while ( Marshal . ReadByte ( nativeUtf8 , len ) != 0 ) ++ len ;
325+ byte [ ] buffer = new byte [ len ] ;
326+ Marshal . Copy ( nativeUtf8 , buffer , 0 , buffer . Length ) ;
327+ return Encoding . UTF8 . GetString ( buffer ) ;
328+ }
330329
331330
332331 public static IntPtr StringToCoTaskMemUTF8 ( string managedString )
333332 {
334333 int len = Encoding . UTF8 . GetByteCount ( managedString ) ;
335-
336334 byte [ ] buffer = new byte [ len + 1 ] ;
337-
338335 Encoding . UTF8 . GetBytes ( managedString , 0 , managedString . Length , buffer , 0 ) ;
339-
340336 IntPtr nativeUtf8 = Marshal . AllocHGlobal ( buffer . Length ) ;
341-
342337 Marshal . Copy ( buffer , 0 , nativeUtf8 , buffer . Length ) ;
343-
344338 return nativeUtf8 ;
345339 }
346-
347340
348- #region -- Cameras --
341+ //delegate ulong GetHandleAddressFuncDelegate(int handle);
342+ //static GetHandleAddressFuncDelegate GetPlayerAddressFunc;
349343
350- #endregion
344+ /*public static IntPtr GetPlayerAddress(int handle)
345+ {
346+ return new IntPtr((long)GetPlayerAddressFunc(handle));
347+ }*/
351348
352- #region -- Game Data --
349+ #region -- Game Data --
353350
354- delegate uint GetHashKeyDelegate ( IntPtr stringPtr , uint initialHash ) ;
351+ delegate uint GetHashKeyDelegate ( IntPtr stringPtr , uint initialHash ) ;
355352 static GetHashKeyDelegate GetHashKeyFunc ;
356353
357354 public static uint GetHashKey ( string key )
@@ -368,21 +365,6 @@ public static uint GetHashKey(string key)
368365
369366 #endregion
370367
371- #region -- Vehicle Offsets --
372-
373- public static int GearOffset { get ; }
374- public static int HighGearOffset { get ; }
375-
376- public static int CurrentRPMOffset { get ; }
377- public static int AccelerationOffset { get ; }
378-
379- public static int FuelLevelOffset { get ; }
380- public static int WheelSpeedOffset { get ; }
381-
382- public static int SteeringAngleOffset { get ; }
383- public static int SteeringScaleOffset { get ; }
384-
385- #endregion
386368
387369
388370
0 commit comments