| chis101 How do I cheat?
 
 ![]() Reputation: 0 
 Joined: 02 Oct 2019
 Posts: 5
 
 
 | 
			
				|  Posted: Sun Oct 06, 2019 7:17 pm    Post subject: Issues with LoadLibrary getting symbol exports |   |  
				| 
 |  
				| edit: After spending a few hours on this, I seem to have got it to work shortly after posting. See bottom for my fix 
 Hi,
 
 I'm having issues reliably getting LoadLibrary to work. I'm trying to compile a simple DLL, like this:
 
 
  	  | Code: |  	  | #include <windows.h>
 #include <stdio.h>
 #include <stdlib.h>
 
 #define DllExport   __declspec( dllexport )
 
 DllExport void Test()
 {
 MessageBox(0, TEXT("Test Called\n"), TEXT("Test Called"), MB_ICONINFORMATION);
 }
 
 
 BOOL APIENTRY DllMain(HINSTANCE hInst     /* Library instance handle. */,
 DWORD reason        /* Reason this function is being called. */,
 LPVOID reserved     /* Not used. */)
 {
 switch (reason)
 {
 case DLL_PROCESS_ATTACH:
 MessageBox(0, TEXT("DLL Attached\n"), TEXT("DLL Attached"), MB_ICONINFORMATION);
 break;
 
 case DLL_PROCESS_DETACH:
 break;
 
 case DLL_THREAD_ATTACH:
 break;
 
 case DLL_THREAD_DETACH:
 break;
 }
 
 /* Returns TRUE on success, FALSE on failure */
 return TRUE;
 }
 
 
 | 
 
 
 And I have an AA script like this:
 
 
  	  | Code: |  	  | [enable]
 loadLibrary(TestDll.dll)
 
 [disable]
 
 createThread( TestDll.Test)
 
 
 | 
 
 Now, in general this doesn't work. Usually the error is
 
 
 
  	  | Quote: |  	  | "The address in createThread( TestDll.Test ) is not valid" | 
 
 
 It doesn't seem to load the symbol table.  I have the .pdb file sitting next to the DLL in the same directory as the .CT file.  I have also tried putting the DLL and PDB file in the .EXE directory.
 
 
 Now, if I go Tools->Inject DLL,  and manually load the DLL, and it then asks if I want to execute a function it can see the "Test" export. If I run the 'Test' function I get
 
 
  	  | Quote: |  	  | "dllInject failed: Failed executing the function of the dll  Force load module falied:failed finding address of VCRUNTIME140!__C_specific_handler" | 
 
 
 If I now go File->Use Windows Debug Symbols,  and then run Tools->Inject Dll, it works.  I can also now successfully run my auto assembler script as well.  If I look at View->Enumerate DLLs and Symbols,  I see that 'Test.dll' is loaded twice. One has symbols, one does not.
 
 If I restart CE now, I will have to repeat all of the steps for the DLL to load.
 
 Is there something I'm missing to get LoadLibrary to work reliably? It seems that something is going wrong with loading the DLL symbol exports. Do I really need to manually load symbol files before an AA script can use LoadLibrary? Is there a better way to compile my DLL?
 
 I've tried copying VCRUNTIME140.dll and its PDB file into the same directory as my .EXE, but then it just complains about not finding a symbol in another file.
 
 
 Any help would be appreciated!
 
 
 -------
 
 Of course, after working on this for a few hours, I get it working minutes after posting.
 
 I found that Visual Studio was generating partial PDB files.  In Visual Studio I changed
 
 
  	  | Quote: |  	  | Configuration Properties->Linked->Debugging->Generate Full Program Database File | 
 
 to TRUE and it appears to be working better
 |  |