Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 31

Thread: Libcod for windows

  1. #21
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,010
    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)

  3. #22
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Quote Originally Posted by serthy View Post
    Thank you!
    Unfortunately this DLL does not work on my machine either
    (when injecting the dll the CoD2 server console throws this unknown function script compile error for not finding a libcod-function)
    It might be because it is linked against the mysql library.
    Try to copy libmysql.dll (in lib/) with the libcod dll.

  4. The Following 2 Users Say Thank You to Mitch For This Useful Post:

    kung foo man (14th December 2014),serthy (14th December 2014)

  5. #23
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    Quote Originally Posted by Mitch View Post
    It might be because it is linked against the mysql library.
    Try to copy libmysql.dll (in lib/) with the libcod dll.
    Thanks, this did the trick!
    I also had to use the -m32 flag in compiler and linker settings to build a 32bit dll (when using TDM-GCC64), now its working

  6. The Following User Says Thank You to serthy For This Useful Post:

    Mitch (14th December 2014)

  7. #24
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    I added basic support for 1.0. But i haven't tested all the functions. So it might be that some functions don't work yet. Probably the entity and vector return value.

    https://github.com/M-itch/libcod_win...d9436e4e13b717

    I also included kung's injector loop (with a dll check).

    Edit: status 1.0

    Working
    - All param functions are working (string, int, float, vector)
    - string, int and float return functions are working
    - ip/ping are working

    Not working/untested
    - Vector, entity and array return functions haven't been tested yet
    - All player functions haven't been tested yet (except ip/ping)

    Edit 2: https://github.com/M-itch/libcod_win...2b230f5cd3985f (Added player functions to 1.0, build 2)
    Edit 3: https://github.com/M-itch/libcod_win...01c2f823c9490a (fix vector stack push, build 3)
    Edit 3: https://github.com/M-itch/libcod_win...f943c86cfa6651 (IWD download check, build4)
    Attached Files Attached Files
    Last edited by Mitch; 20th January 2015 at 20:58. Reason: added fixed vector push

  8. The Following 2 Users Say Thank You to Mitch For This Useful Post:

    kung foo man (4th January 2015),serthy (5th January 2015)

  9. #25
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    When i use this, must I still preload it?

    EDIT:

    Click image for larger version. 

Name:	inject_loop.jpg 
Views:	201 
Size:	18.4 KB 
ID:	827
    Last edited by kung foo man; 13th January 2015 at 20:12. Reason: img as attach

  10. #26
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,010
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    That's basically "runtime loading", with a possible delay of a second. I think you didn't called your server-binary "sd.exe" (or didn't start yet ^^), otherwise it should be found by the loop and some inject message shoud appear.
    timescale 0.01

  11. #27
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    Well when I run the InjectDLL.exe and write
    Code:
    InjectDLL sd.exe libcod2_1_0.dll
    and press enter it dissappears immediatly. Even if the server is started.
    So I modified InjectLibcod.bat with notepad and changed it to the correct files. Then I get that window that doesn't go away. I tried it with server on and off. No result so far. It's a home-server btw

    EDIT: Nevermind! Works like a charm. It was the wrong process name
    Last edited by Ni3ls; 13th January 2015 at 20:38.

  12. #28
    Corporal guiismiti's Avatar
    Join Date
    Dec 2013
    Location
    Brazil
    Posts
    244
    Thanks
    121
    Thanked 42 Times in 31 Posts
    Not sure if anybody is still having trouble using it on windows 7 x64, but I just did it successfully.
    I'm using the .dll files from Mitch's repository and the Inject .exe and .bat from Kung.

    <3 libcod
    set logfile 2

  13. #29
    Corporal guiismiti's Avatar
    Join Date
    Dec 2013
    Location
    Brazil
    Posts
    244
    Thanks
    121
    Thanked 42 Times in 31 Posts
    Which compiler do you use?
    I'm trying to add missing functions.
    set logfile 2

  14. #30
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,010
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    https://killtube.org/showthread.php?...ll=1#post10962

    Quote Originally Posted by Mitch View Post
    No idea. I just build my source with CodeBlocks 13.12 using GCC 4.7.1 (mingw32-g++.exe) on Windows 8.1.
    But investing a bit work, it should work nicely with Visual Studio aswell
    timescale 0.01

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

    guiismiti (6th April 2017)

Posting Permissions

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