Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Issues with LoadLibrary getting symbol exports

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
chis101
How do I cheat?
Reputation: 0

Joined: 02 Oct 2019
Posts: 5

PostPosted: Sun Oct 06, 2019 7:17 pm    Post subject: Issues with LoadLibrary getting symbol exports Reply with quote

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
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25807
Location: The netherlands

PostPosted: Mon Oct 07, 2019 1:12 am    Post subject: Reply with quote

Is your dll compiled as a c or c++ dll?

if c++ the exportnames will have some extra characters (e.g @4)

You can either convert if to a c-dll in visual studio, or use a .def file declaring the exports

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites