@@ -75,15 +75,15 @@ public static IntPtr LoadLibrary(
7575 loadLibrary = loadLibrary ?? MemoryDefaultLoadLibraryDelegate ;
7676 getProcAddress = getProcAddress ?? MemoryDefaultGetProcAddressDelegate ;
7777 freeLibrary = freeLibrary ?? MemoryDefaultFreeLibraryDelegate ;
78-
78+
7979 var handle = MemoryLoadLibraryEx (
80- dataPtr ,
80+ dataPtr ,
8181 ( ulong ) length ,
82- allocMemory ,
83- freeMemory ,
84- loadLibrary ,
85- getProcAddress ,
86- freeLibrary ,
82+ allocMemory ,
83+ freeMemory ,
84+ loadLibrary ,
85+ getProcAddress ,
86+ freeLibrary ,
8787 null
8888 ) ;
8989 if ( handle == null )
@@ -188,6 +188,7 @@ internal static bool MemoryDefaultFreeLibrary(void* module, void* userdata)
188188
189189 private static readonly uint HostMachine = ( ( Func < uint > ) ( ( ) =>
190190 {
191+ #if NET || NETSTANDARD || NET471_OR_GREATER
191192 switch ( RuntimeInformation . ProcessArchitecture )
192193 {
193194 case Architecture . X86 :
@@ -201,6 +202,9 @@ internal static bool MemoryDefaultFreeLibrary(void* module, void* userdata)
201202 default :
202203 throw new PlatformNotSupportedException ( ) ;
203204 }
205+ #else
206+ return ( uint ) ( Environment . Is64BitProcess ? Image . FileMachineAMD64 : Image . FileMachinei386 ) ;
207+ #endif
204208 } ) ) ( ) ;
205209
206210 // Protection flags for memory pages (Executable, Readable, Writeable)
@@ -224,13 +228,13 @@ internal static bool MemoryDefaultFreeLibrary(void* module, void* userdata)
224228 private static void * MemoryLoadLibrary ( void * data , ulong size )
225229 {
226230 return MemoryLoadLibraryEx (
227- data ,
231+ data ,
228232 size ,
229233 MemoryDefaultAllocDelegate ,
230234 MemoryDefaultFreeDelegate ,
231235 MemoryDefaultLoadLibraryDelegate ,
232236 MemoryDefaultGetProcAddressDelegate ,
233- MemoryDefaultFreeLibraryDelegate ,
237+ MemoryDefaultFreeLibraryDelegate ,
234238 null ) ;
235239 }
236240
@@ -618,8 +622,8 @@ private static bool MemoryFreeLibrary(_MEMORYMODULE* mod)
618622 {
619623 Dictionary < string , uint > nameExports = null ;
620624
621- // So I actually removed all of Thomas Heller's Binary search
622- // implementation of MemoryGetProcAddress, and replace it with my
625+ // So I actually removed all of Thomas Heller's Binary search
626+ // implementation of MemoryGetProcAddress, and replace it with my
623627 // own managed Dictionary implementation.
624628
625629 // Lazily build name table and sort it by names
@@ -1470,7 +1474,7 @@ struct _IMAGE_NT_HEADERS
14701474 public _IMAGE_FILE_HEADER FileHeader ;
14711475 public _IMAGE_OPTIONAL_HEADER OptionalHeader ;
14721476 }
1473-
1477+
14741478 [ StructLayout ( LayoutKind . Sequential , Pack = 1 ) ]
14751479 struct _IMAGE_OPTIONAL_HEADER
14761480 {
@@ -1508,8 +1512,8 @@ public uint BaseOfData
15081512 }
15091513 public UIntPtr ImageBase
15101514 {
1511- get => Environment . Is64BitProcess ?
1512- ( UIntPtr ) _architectureSpecificValue1 . ImageBase64 :
1515+ get => Environment . Is64BitProcess ?
1516+ ( UIntPtr ) _architectureSpecificValue1 . ImageBase64 :
15131517 ( UIntPtr ) _architectureSpecificValue1 . ImageBase32 ;
15141518 set
15151519 {
0 commit comments