kung foo man (14th December 2014),serthy (14th December 2014)
Mitch (14th December 2014)
I just checked what I did actually different in my version and the only relevant change is in main.cpp:
That's were I had all my problems as well: server crashed or just didn't work at all.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 hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
Com_Printf("DllMain()\n");
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
g_hModule = hinstDLL;
DisableThreadLibraryCalls(hinstDLL);
CloseHandle(CreateThread(NULL, 0, &MyThread, NULL, 0, &g_threadID));
MyThread(NULL);
break;
case DLL_THREAD_ATTACH:
// attach to thread
break;
case DLL_PROCESS_DETACH:
Com_Printf("[PLUGIN UNLOADED]\n");
FreeLibraryAndExitThread(g_hModule, 0);
break;
case DLL_THREAD_DETACH:
Com_Printf("[THREAD DETACH]\n");
break;
}
return TRUE; // succesful
}
Changes in SmartGit:
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 *f = NULL;
static int Com_Printf(const char *format, ...) {
if (f == NULL) {
f = 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
serthy (13th December 2014)
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)
kung foo man (4th January 2015),serthy (5th January 2015)
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
Well when I run the InjectDLL.exe and write
and press enter it dissappears immediatly. Even if the server is started.Code:InjectDLL sd.exe libcod2_1_0.dll
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 19:38.
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
Which compiler do you use?
I'm trying to add missing functions.
set logfile 2
https://killtube.org/showthread.php?...ll=1#post10962
But investing a bit work, it should work nicely with Visual Studio aswell
timescale 0.01
guiismiti (6th April 2017)