Results 1 to 10 of 31

Thread: Libcod for windows

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #23
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    I just checked what I did actually different in my version and the only relevant change is in main.cpp:

    PHP Code:
    #include "main.h"
    #include <stdio.h>
    #include "include/functions.h"
    #include "include/cracking.h"
    #include "include/gsc.h"

    DWORD WINAPI MyThread(LPVOID);
    DWORD g_threadID;
    HMODULE g_hModule;

    static 
    int isStarted 0;
    DWORD WINAPI MyThread(LPVOID)
    {
        if (
    isStarted) {
            
    Com_Printf("Already started!\n");
            return 
    NULL;
        }
        
    isStarted 1;
        
    Com_Printf("[PLUGIN LOADED]\n");
        
    #if COD_VERSION == COD2_1_3
            
    cracking_hook_call(0x46E7BF, (int)Scr_GetCustomFunction);
            
    cracking_hook_call(0x46EA03, (int)Scr_GetCustomMethod);
        
    #endif

        
    return 0;
    }

    extern "C" DLL_EXPORT BOOL APIENTRY DllMain(HINSTANCE hinstDLLDWORD fdwReasonLPVOID lpvReserved)
    {
        
    Com_Printf("DllMain()\n");
        switch (
    fdwReason)
        {
            case 
    DLL_PROCESS_ATTACH:
                
    g_hModule hinstDLL;
                
    DisableThreadLibraryCalls(hinstDLL);
               
    CloseHandle(CreateThread(NULL0, &MyThreadNULL0, &g_threadID));
               
    MyThread(NULL);
                break;

            case 
    DLL_THREAD_ATTACH:
                
    // attach to thread
                
    break;

            case 
    DLL_PROCESS_DETACH:
                
    Com_Printf("[PLUGIN UNLOADED]\n");
                
    FreeLibraryAndExitThread(g_hModule0);
                break;

            case 
    DLL_THREAD_DETACH:
                
    Com_Printf("[THREAD DETACH]\n");
                break;
        }
        return 
    TRUE// succesful

    That's were I had all my problems as well: server crashed or just didn't work at all.

    Changes in SmartGit:

    Click image for larger version. 

Name:	main.png 
Views:	231 
Size:	95.2 KB 
ID:	810

    I guess the CloseHandle(CreateThread()) is just not doing anything and could be commented out also. I call MyThread() without threading, since it is just hooking the two functions nonetheless.

    When it still doesn't work, check the Com_Printf() to figure out to what point the code actually did something:

    File: functions.h
    PHP Code:
    #if COD_VERSION == COD2_1_3
        #if 0
        
    static Com_Printf_t Com_Printf = (Com_Printf_t)0x0431EE0;
        
    #else
        
    static FILE *NULL;
        static 
    int Com_Printf(const char *format, ...) {
            if (
    == NULL) {
                
    fopen("libcod.txt""a+");
                
    //fclose(f);
            
    }
            
    fprintf(f"%s"format);
            
    fflush(f);
        }
        
    #endif
    #else
        
    static Com_Printf_t Com_Printf = (Com_Printf_t)NULL;
        
    #warning Com_Printf_t Com_Printf = NULL;
    #endif 
    timescale 0.01

  2. The Following User Says Thank You to kung foo man For This Useful Post:

    serthy (13th December 2014)

Posting Permissions

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