Results 1 to 7 of 7
  1. #1
    T0P-CENT's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Posts
    88
    Reputation
    14
    Thanks
    17
    My Mood
    Stressed

    How Can I Set An Entrypoint For DLLs ? [Solved]

    First i thought entry point in dlls was DLLMain but then when i try to import it in C# i get an error that entrypoint wasn't found

    here is my code
    Code:
    #include <Windows.h>
    
    int Test(int x,int y)
    {
    return x+y;
    }
    
    BOOL APIENTRY DllMain( HMODULE hModule,
                           DWORD  ul_reason_for_call,
                           LPVOID lpReserved
    					 )
    {
    	switch (ul_reason_for_call)
    	{
    	case DLL_PROCESS_ATTACH:
    		MessageBox(0,L"Test",L"From unmanaged dll",0);
    	case DLL_THREAD_ATTACH:
    	case DLL_THREAD_DETACH:
    	case DLL_PROCESS_DETACH:
    		break;
    	}
    	return TRUE;
    }
    And if you dont mind can you give me little explanation about entry point ?
    Like do i have to set import the same dllagain and changing the entry point so i can use other functions? thanks in advance

  2. #2
    Nico's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    Germany :D
    Posts
    15,918
    Reputation
    1121
    Thanks
    8,617
    Youre exporting DLLMain?

  3. #3
    T0P-CENT's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Posts
    88
    Reputation
    14
    Thanks
    17
    My Mood
    Stressed
    Quote Originally Posted by Nico View Post
    Youre exporting DLLMain?
    Nope , but i got my problem solved thanks
    solution : before any function/void
    Code:
    extern "C" __declspec(dllexport)

  4. #4
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    Naice.

    A nigga mad. Opened again.
    @Jason: Soothe your pain now.
    Last edited by Hassan; 10-04-2011 at 10:48 PM.

  5. #5
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Just to clarify, even when exporting with the

    extern "C" __declspec(dllexport) keyword, name mangling can still occur. There is, however, an easy way to find out what name your exported function was given when it was exported. All exported functions are added to the PE image file's "export table". So using any PE explorer you can simply go to the export table and see what functions your dll exports, and what names they have.

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  6. #6
    freedompeace's Avatar
    Join Date
    Jul 2010
    Gender
    female
    Posts
    3,033
    Reputation
    340
    Thanks
    2,792
    My Mood
    Sad
    Quote Originally Posted by Jason View Post
    Just to clarify, even when exporting with the

    extern "C" __declspec(dllexport) keyword, name mangling can still occur. There is, however, an easy way to find out what name your exported function was given when it was exported. All exported functions are added to the PE image file's "export table". So using any PE explorer you can simply go to the export table and see what functions your dll exports, and what names they have.
    Linking using C linkage (extern C) disables name mangling for the specified declaration -- C doesn't mangle names; C++ does. :)

    It also happens to be that C and C++ (as in extern "C" and extern "C++") are the only supported string literals for the extern keyword in MSVC.
    Last edited by freedompeace; 10-05-2011 at 06:27 AM. Reason: added little footnote-like thing at the end of the post.

  7. #7
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Quote Originally Posted by freedompeace View Post


    Linking using C linkage (extern C) disables name mangling for the specified declaration -- C doesn't mangle names; C++ does.

    It also happens to be that C and C++ (as in extern "C" and extern "C++") are the only supported string literals for the extern keyword in MSVC.
    Weird, exported my function with the extern "C" specifier and looky here, it was exported as _function@14

    Maybe this was just a one off

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

Similar Threads

  1. [Help] How can i get the program for the use hacks
    By gal1994 in forum Combat Arms EU Hack Coding/Source Code
    Replies: 1
    Last Post: 12-15-2010, 02:14 AM
  2. how can i set: if semtex is stuck to u, self thread BLALL();
    By idiot2010 in forum Call of Duty Modern Warfare 2 GSC Modding Help/Discussion
    Replies: 6
    Last Post: 12-11-2010, 10:37 AM
  3. how can i get this code!! ZackthOP7D3Dv2.dll
    By onyok0 in forum Soldier Front General
    Replies: 2
    Last Post: 12-23-2009, 07:37 AM
  4. How can i set up vents for my clan?
    By _-Blazin-_ in forum General
    Replies: 4
    Last Post: 06-06-2009, 07:04 AM
  5. How can i make a hack for WarRock?
    By tomva in forum General Game Hacking
    Replies: 4
    Last Post: 06-09-2007, 03:13 PM