@@ -75,15 +75,15 @@ public static IntPtr LoadLibrary(
75
75
loadLibrary = loadLibrary ?? MemoryDefaultLoadLibraryDelegate ;
76
76
getProcAddress = getProcAddress ?? MemoryDefaultGetProcAddressDelegate ;
77
77
freeLibrary = freeLibrary ?? MemoryDefaultFreeLibraryDelegate ;
78
-
78
+
79
79
var handle = MemoryLoadLibraryEx (
80
- dataPtr ,
80
+ dataPtr ,
81
81
( ulong ) length ,
82
- allocMemory ,
83
- freeMemory ,
84
- loadLibrary ,
85
- getProcAddress ,
86
- freeLibrary ,
82
+ allocMemory ,
83
+ freeMemory ,
84
+ loadLibrary ,
85
+ getProcAddress ,
86
+ freeLibrary ,
87
87
null
88
88
) ;
89
89
if ( handle == null )
@@ -188,6 +188,7 @@ internal static bool MemoryDefaultFreeLibrary(void* module, void* userdata)
188
188
189
189
private static readonly uint HostMachine = ( ( Func < uint > ) ( ( ) =>
190
190
{
191
+ #if NET || NETSTANDARD || NET471_OR_GREATER
191
192
switch ( RuntimeInformation . ProcessArchitecture )
192
193
{
193
194
case Architecture . X86 :
@@ -201,6 +202,9 @@ internal static bool MemoryDefaultFreeLibrary(void* module, void* userdata)
201
202
default :
202
203
throw new PlatformNotSupportedException ( ) ;
203
204
}
205
+ #else
206
+ return ( uint ) ( Environment . Is64BitProcess ? Image . FileMachineAMD64 : Image . FileMachinei386 ) ;
207
+ #endif
204
208
} ) ) ( ) ;
205
209
206
210
// Protection flags for memory pages (Executable, Readable, Writeable)
@@ -224,13 +228,13 @@ internal static bool MemoryDefaultFreeLibrary(void* module, void* userdata)
224
228
private static void * MemoryLoadLibrary ( void * data , ulong size )
225
229
{
226
230
return MemoryLoadLibraryEx (
227
- data ,
231
+ data ,
228
232
size ,
229
233
MemoryDefaultAllocDelegate ,
230
234
MemoryDefaultFreeDelegate ,
231
235
MemoryDefaultLoadLibraryDelegate ,
232
236
MemoryDefaultGetProcAddressDelegate ,
233
- MemoryDefaultFreeLibraryDelegate ,
237
+ MemoryDefaultFreeLibraryDelegate ,
234
238
null ) ;
235
239
}
236
240
@@ -618,8 +622,8 @@ private static bool MemoryFreeLibrary(_MEMORYMODULE* mod)
618
622
{
619
623
Dictionary < string , uint > nameExports = null ;
620
624
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
623
627
// own managed Dictionary implementation.
624
628
625
629
// Lazily build name table and sort it by names
@@ -1470,7 +1474,7 @@ struct _IMAGE_NT_HEADERS
1470
1474
public _IMAGE_FILE_HEADER FileHeader ;
1471
1475
public _IMAGE_OPTIONAL_HEADER OptionalHeader ;
1472
1476
}
1473
-
1477
+
1474
1478
[ StructLayout ( LayoutKind . Sequential , Pack = 1 ) ]
1475
1479
struct _IMAGE_OPTIONAL_HEADER
1476
1480
{
@@ -1508,8 +1512,8 @@ public uint BaseOfData
1508
1512
}
1509
1513
public UIntPtr ImageBase
1510
1514
{
1511
- get => Environment . Is64BitProcess ?
1512
- ( UIntPtr ) _architectureSpecificValue1 . ImageBase64 :
1515
+ get => Environment . Is64BitProcess ?
1516
+ ( UIntPtr ) _architectureSpecificValue1 . ImageBase64 :
1513
1517
( UIntPtr ) _architectureSpecificValue1 . ImageBase32 ;
1514
1518
set
1515
1519
{
0 commit comments