ras78 Posted May 10, 2007 Report Posted May 10, 2007 hello guys, I'm trying to create a simple module (DLL) for FS which use Fsuipc for read a couple of offset. Basically I read an offset, get it's value and set another offset. Here's the code: #include "fsmodule.h" #include #include "FSUIPC_User.h" LINKAGE Linkage = { 0x000002d9, module_init, module_deinit, 0, 0, 0x800, { 0 } }; IMPORTTABLE ImportTable = { { 0x00000000, NULL } }; WORD LowVis=0; UINT_PTR FSUIPCTimer, VisibilityTimer; BYTE FSUIPCMemory[400]; VOID CALLBACK Visibility(HWND hwnd, UINT uMsg,UINT_PTR idEvent, DWORD dwTime) { DWORD dwResult; BYTE IsLowVisibility; FSUIPC_Write(0x8001, 12, "IKB3BI67TCHEtest.dll", &dwResult); FSUIPC_Process(&dwResult); FSUIPC_Read(0x238, 3, (BYTE*)&IsLowVisibility, &dwResult); FSUIPC_Process(&dwResult); //visibility is lower than 2 miles //if (IsLowVisibility<=0.02) { FSUIPC_Write(0x0DDE, 1, &LowVis, &dwResult); // FSUIPC_Process(&dwResult); //} } VOID CALLBACK InitFSUIPC(HWND hwnd, UINT uMsg,UINT_PTR idEvent, DWORD dwTime) { DWORD dwResult; if (FSUIPC_Open2(SIM_ANY, &dwResult, (BYTE*)FSUIPCMemory, 500)) { KillTimer(NULL,FSUIPCTimer); VisibilityTimer=SetTimer(NULL,1,2000,Visibility); } } void FSAPI module_deinit () { KillTimer (NULL,VisibilityTimer); FSUIPC_Close (); } void FSAPI module_init () { FSUIPCTimer=SetTimer (NULL,0,2000,InitFSUIPC); } My C compiler succesfully create my DLL but when I put into \modules folder, fs does not load it. I'm a newbie about dll, I dunno how to debug. Any advice? thanks!
Pete Dowson Posted May 10, 2007 Report Posted May 10, 2007 I'm trying to create a simple module (DLL) for FS ... My C compiler succesfully create my DLL but when I put into \modules folder, fs does not load it. Did you export the ImportTable and Linkage names, as in extern __declspec(dllexport) IMPORTTABLE ImportTable; extern __declspec(dllexport) LINKAGE Linkage; If you don't, FS won't think it's a suitable DLL. Regards Pete
ras78 Posted May 10, 2007 Author Report Posted May 10, 2007 SOLVED! A little change applyed: LINKAGE Linkage = { //0x000002d9, 0x00000000, module_init, module_deinit, 0, 0, 0x900, NULL }; Since 0x900 is for fs2004 which I use :D
Pete Dowson Posted May 10, 2007 Report Posted May 10, 2007 Since 0x900 is for fs2004 which I use :D Ah, yes. Sorry. I hadn't noticed that. Though, even if that were wrong, your DLL would still be loaded. It would simply have been terminated again quite quickly (i.e. without the init function being called). Since up until FSX I made DLLs work for all versions of FS since FS98, and even including CFS1 and CFS2, I had to set that parameter dynamically, in the DLLmain function, after working out which version of FS had loaded me. Regards Pete
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now