Showing results 1 to 4 of 4

Thread: My dll isn't working?

  1. #1

    Default My dll isn't working?

    Hey guys. I've been coding in C++ for a while, but i've never made a dll before. I'm trying to make a dll that will alter some values when injected, but i'm having a problem with simply getting the code to execute upon injection. I've commented out a lot of the code and just added a messagebox until i can get that to work. I've been banned from 2 channels on irc programming channels when asking this question (due to unethical programming i guess) so i'm hoping i'll be able to get some help here.

    Here's the code:

    main.h:
    Code:
    #ifdef BUILD_DLL
        #define DLL_EXPORT __declspec(dllexport)
    #else
        #define DLL_EXPORT __declspec(dllimport)
    #endif
    Code:
    #include "main.h"
    #include <windows.h>
    #include "detours.h"
    #include <sstream>
    #include <string>
    
    //float** addr = (float**)0x682246f0 + 0x0180;
    
    DWORD WINAPI MyThread(LPVOID);
    DWORD g_threadID;
    HMODULE g_hModule;
    std::string ret;
    
    BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
    {
        switch (fdwReason)
        {
            case DLL_PROCESS_ATTACH:
                {
                    //float* add = *addr;
                    //float locx = *add;
    
                    //std::stringstream out;
                    //out << locx;
                   // ret = out.str();
    
                    MessageBox(0, "hi", "test", MB_OK);
    
                    //g_hModule = hinstDLL;
                   // DisableThreadLibraryCalls(hinstDLL);
                    //Create a thread
                    //CreateThread(NULL, NULL, &MyThread, NULL, NULL, &g_threadID);
    
    
                }
                break;
    
            case DLL_PROCESS_DETACH:
                // detach from process
                break;
    
            case DLL_THREAD_ATTACH:
                // attach to thread
                break;
    
            case DLL_THREAD_DETACH:
                // detach from thread
                break;
        }
        return TRUE; // succesful
    }
    
    DWORD WINAPI MyThread(LPVOID)
    {
        MessageBox(0, ret.c_str(), "Message", MB_OK);
    
    }

  2. #2
    =) Senior Member
    Developer

    Supreme Being
    K? Pŕo?ćtiόnŹ's Avatar
    Join Date
    Oct 2004
    Posts
    11,794

    Default

    Probably something in your build parameters.
    Quote Originally Posted by Voice Of Korhal View Post
    Let us hope so, if that Reverse Engineering crap actually works, I'll be amazed.

  3. #3

    Default

    I did some more googling after i posted, and found out that code::blocks and gcc mangle the dllmain function, to fix it you have to prepend 'extern "C"' to the dllmain function. Everything is working great now ^_^

    Thanks for taking the time ;)

  4. #4
    =) Senior Member
    Developer

    Supreme Being
    K? Pŕo?ćtiόnŹ's Avatar
    Join Date
    Oct 2004
    Posts
    11,794

    Default

    Well thats stupid.
    Quote Originally Posted by Voice Of Korhal View Post
    Let us hope so, if that Reverse Engineering crap actually works, I'll be amazed.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. PSU Not working well
    By FedeArg in forum Hardware and Software
    Replies: 2
    Last Post: 03-18-2010, 06:20 PM
  2. A working...
    By HoaX in forum Starcraft/Brood War
    Replies: 3
    Last Post: 07-06-2006, 09:17 PM
  3. Ban still not working
    By 3D.CD_Yet_Ban_aint_workin in forum Starcraft/Brood War
    Replies: 11
    Last Post: 09-06-2005, 07:45 PM
  4. Ban not working
    By 3D.CD_i_am_back in forum Starcraft/Brood War
    Replies: 17
    Last Post: 08-17-2005, 10:56 AM
  5. can someone pm me a working cd key
    By anarki in forum Gaming
    Replies: 1
    Last Post: 07-06-2005, 10:55 PM

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •