Results 1 to 10 of 31

Thread: Libcod for windows

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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
    Ok, found the error by logging the Com_Printf stuff to a file:


    Code:
    // include/functions.h
    #if COD_VERSION == COD2_1_3
        static FILE *f = NULL;
        //static Com_Printf_t Com_Printf = (Com_Printf_t)0x0431EE0;
        static int Com_Printf(const char *format, ...) {
            if (f == NULL) {
                f = fopen("C:\\libcod.txt", "w+"); // start the Link with +dedicated 1 as Administrator for write permissions
                //fclose(f);
            }
            fprintf(f, "%s", format);
            fflush(f);
        }
    #else
    Output:
    Code:
    DllMain()
    [PLUGIN LOADED]
    DllMain()
    DllMain()
    Already started!
    [THREAD DETACH]
    DllMain()
    [THREAD DETACH]
    DllMain()
    
    Here starts the unloading:
    
    DllMain()
    [THREAD DETACH]
    DllMain()
    [THREAD DETACH]
    DllMain()
    DllMain()
    DllMain()
    [PLUGIN UNLOADED]
    For some reason the DllMain()/DLL_PROCESS_ATTACH is called twice. Fixed it with a simple static variable:

    Code:
    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;
    }
    Now it's working fine, but the manual injecting is a bit annoying (because the dedi server will crash because of missing functions on start). Gotta look for some LD_PRELOAD replacement for Windows.
    timescale 0.01

  2. #2
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Quote Originally Posted by kung foo man View Post
    Gotta look for some LD_PRELOAD replacement for Windows.
    Would it work if you replaced a default dll (like mss32.dll) and loaded that dll (different name) inside your own dll?

Posting Permissions

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