PDA

View Full Version : Dll Import with entry point



Mito0602
4th November 2014, 12:23
Heyy,

i know that using google.de helps with many problems. Unfortunately i am not able to get this one solved:

I have a .dll and a C# source File, nothing else.

My problem is that i can't transform the C# code in an executable :mad: :mad:

Following is the C# Code:


[DllImport("SomeonesApi.dll", EntryPoint="RegisterUser")]
public static extern uint RegisterMe(
byte hUsernumber, // Requested Usernumber (in hex)
string Username); // Name of the user


The solution i've seen is via QLibrary.



QLibrary lib("C:/Windows/system32/SomeonesApi.dll");
lib.load();
bool successfully_loaded =lib.isLoaded();
typedef unsigned int (*RegisterMe) (unsigned char,std::string);
RegisterMe newUser = new RegisterMe(0x01,"User1");
RegisterMe returnvalue = (newUser )lib.resolve("RegisterUser");


Can someone tell me what i've done wrong? Is there another (better) way to get this c# function transformed?

Thanks in advance :)

Added after 1 16 minutes:

I think i got it working ... :


QLibrary lib("C:/Windows/system32/SomeonesApi.dll");
lib.load();
bool successfully_loaded =lib.isLoaded();
typedef unsigned int (*RegisterMe) (unsigned char,std::string);
//RegisterMe newUser = new RegisterMe(0x01,"User1"); this line was the wrong one
RegisterMe newUser = (RegisterMe )lib.resolve("RegisterUser");
if (newUser)
{
newUser(0x01,"User1");
return 0;
}
else return -1;


If anyone else has a better solution:

Feel free to write :)