@@ -250,8 +250,12 @@ BuildImportTable(PMEMORYMODULE module)
250250 }
251251 for (; * thunkRef ; thunkRef ++ , funcRef ++ )
252252 {
253- PIMAGE_IMPORT_BY_NAME thunkData = (PIMAGE_IMPORT_BY_NAME )(codeBase + * thunkRef );
254- * funcRef = (DWORD )GetProcAddress (handle , (LPCSTR )& thunkData -> Name );
253+ if IMAGE_SNAP_BY_ORDINAL (* thunkRef )
254+ * funcRef = (DWORD )GetProcAddress (handle , (LPCSTR )IMAGE_ORDINAL (* thunkRef ));
255+ else {
256+ PIMAGE_IMPORT_BY_NAME thunkData = (PIMAGE_IMPORT_BY_NAME )(codeBase + * thunkRef );
257+ * funcRef = (DWORD )GetProcAddress (handle , (LPCSTR )& thunkData -> Name );
258+ }
255259 if (* funcRef == 0 )
256260 {
257261 result = 0 ;
@@ -359,26 +363,29 @@ HMEMORYMODULE MemoryLoadLibrary(const void *data)
359363 FinalizeSections (result );
360364
361365 // get entry point of loaded library
362- DllEntry = (DllEntryProc )(code + result -> headers -> OptionalHeader .AddressOfEntryPoint );
363- if (DllEntry == 0 )
366+ if (result -> headers -> OptionalHeader .AddressOfEntryPoint != 0 )
364367 {
368+ DllEntry = (DllEntryProc )(code + result -> headers -> OptionalHeader .AddressOfEntryPoint );
369+ if (DllEntry == 0 )
370+ {
365371#if DEBUG_OUTPUT
366- OutputDebugString ("Library has no entry point.\n" );
372+ OutputDebugString ("Library has no entry point.\n" );
367373#endif
368- goto error ;
369- }
374+ goto error ;
375+ }
370376
371- // notify library about attaching to process
372- successfull = (* DllEntry )((HINSTANCE )code , DLL_PROCESS_ATTACH , 0 );
373- if (!successfull )
374- {
377+ // notify library about attaching to process
378+ successfull = (* DllEntry )((HINSTANCE )code , DLL_PROCESS_ATTACH , 0 );
379+ if (!successfull )
380+ {
375381#if DEBUG_OUTPUT
376- OutputDebugString ("Can't attach library.\n" );
382+ OutputDebugString ("Can't attach library.\n" );
377383#endif
378- goto error ;
384+ goto error ;
385+ }
386+ result -> initialized = 1 ;
379387 }
380388
381- result -> initialized = 1 ;
382389 return (HMEMORYMODULE )result ;
383390
384391error :
0 commit comments