File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -323,16 +323,18 @@ HMEMORYMODULE MemoryLoadLibrary(const void *data)
323323 }
324324
325325 // reserve memory for image of library
326+ // XXX: is it correct to commit the complete memory region at once?
327+ // calling DllEntry raises an exception if we don't...
326328 code = (unsigned char * )VirtualAlloc ((LPVOID )(old_header -> OptionalHeader .ImageBase ),
327329 old_header -> OptionalHeader .SizeOfImage ,
328- MEM_RESERVE ,
330+ MEM_RESERVE | MEM_COMMIT ,
329331 PAGE_READWRITE );
330332
331333 if (code == NULL ) {
332334 // try to allocate memory at arbitrary position
333335 code = (unsigned char * )VirtualAlloc (NULL ,
334336 old_header -> OptionalHeader .SizeOfImage ,
335- MEM_RESERVE ,
337+ MEM_RESERVE | MEM_COMMIT ,
336338 PAGE_READWRITE );
337339 if (code == NULL ) {
338340#if DEBUG_OUTPUT
@@ -348,13 +350,6 @@ HMEMORYMODULE MemoryLoadLibrary(const void *data)
348350 result -> modules = NULL ;
349351 result -> initialized = 0 ;
350352
351- // XXX: is it correct to commit the complete memory region at once?
352- // calling DllEntry raises an exception if we don't...
353- VirtualAlloc (code ,
354- old_header -> OptionalHeader .SizeOfImage ,
355- MEM_COMMIT ,
356- PAGE_READWRITE );
357-
358353 // commit memory for headers
359354 headers = (unsigned char * )VirtualAlloc (code ,
360355 old_header -> OptionalHeader .SizeOfHeaders ,
You can’t perform that action at this time.
0 commit comments