Hey,
i'm trying to add some selfmade c++-natives to rtc for my personal use. I use the template of the jApi-Tutorial to create an extra .dll-file which i put into the bin-folder of rtc and I load this dll additionally within the ongameload.lua-file. I also added my native to the rtc-common.j.
Here's the source of my dll (Compiler is Visual Studio 2008 Express)
The japi-log says it loads the dll properly and i also can pop up a Windows - MessageBox, but it crashes at the " jAddNative(UMETestFunction, "UMETestFunction", "(S)S");" - line.
Hope anyone can help
i'm trying to add some selfmade c++-natives to rtc for my personal use. I use the template of the jApi-Tutorial to create an extra .dll-file which i put into the bin-folder of rtc and I load this dll additionally within the ongameload.lua-file. I also added my native to the rtc-common.j.
Here's the source of my dll (Compiler is Visual Studio 2008 Express)
Code:
#include <windows.h>
#include <stdio.h>
#define jNATIVE __stdcall
#define jAPI __fastcall
#define FloatAsInt(f) (*(long*)&f)
#define IntAsFloat(i) (*(float*)&i)
typedef long jString;
typedef long jInt;
typedef long jReal;
typedef void (jAPI *jpAddNative)(void *routine, char *name, char *prototype);
typedef jString (jAPI *jpStrMap) (char *str);
typedef char * (jAPI *jpStrGet) (jString strid);
jpAddNative jAddNative;
jpStrMap jStrMap;
jpStrGet jStrGet;
#pragma warning ( disable : 4996 )
jString jNATIVE UMETestFunction(jString js)
{
char* s = jStrGet(js);
strcat(s, "FooBar!!!");
return jStrMap(s);
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
{
DisableThreadLibraryCalls(hModule);
HMODULE hjApi = GetModuleHandle("japi.dll");
jAddNative = (jpAddNative)GetProcAddress(hjApi, "jAddNative");
jStrMap = (jpStrMap)GetProcAddress(hjApi, "jStrMap");
jStrGet = (jpStrGet)GetProcAddress(hjApi, "jStrGet");
jAddNative(UMETestFunction, "UMETestFunction", "(S)S");
}
return TRUE;
}
The japi-log says it loads the dll properly and i also can pop up a Windows - MessageBox, but it crashes at the " jAddNative(UMETestFunction, "UMETestFunction", "(S)S");" - line.
Hope anyone can help
Last edited: