Jump to content

Debug DLL


Recommended Posts

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.