Jump to content
Sign in to follow this  
Xeo

Looking for Module DLL Programming Info

Recommended Posts

Hello there, I'm trying to find info on how to program a plug-in for the MSFS that drops in the Modules folder and show up in the pulldown menus.I looked through the SDK and didn't find information abut this. Can anyone point me to any information ? (like web site, forum, sourse ...)Thanks !Alex.

Share this post


Link to post
Share on other sites
Guest ghrasko

I am interested also. Isn't it the same as gauge programming, only named as dll instead of gau and put it into the modules folder? (well, of course without gauge definitions)Gabor

Share this post


Link to post
Share on other sites
Guest ghrasko

Alex,I think I was right in my previous reply. I searched through the forum and I found Arne Bartels' reply somewhere. Arne I hope you do not bother if I copy it here. It shows, that it is same as in case of gauge programming...--- from Arne's mail --------------My inner core of FS9 modules looks likes this, ...void FSAPI ModuleInit(void){...}void FSAPI ModuleDeinit(void){...}//---------------------------------------------------------BOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOIDlpReserved) { ... } /* This is the module's import table. */ GAUGESIMPORT ImportTable = { { 0x0000000F, (PPANELS)NULL }, { 0x00000000, NULL }}; /* This is the module's export table. */ GAUGESLINKAGE Linkage = { 0x00000001, ModuleInit, ModuleDeinit, 0, 0, FS9LINK_VERSION, NULL};If I recall that right you need 0x00000001 for full access toall functions of the PANELS structure (ImportTable), othernumbers like 0x00000000 limit the functionality and all..._register_c_callback functions are part of the"higher" ImportTable functions. Also ImportTable has to be properly set up with bothentries, to get ImportTable at all which you need for callingany function out of it (most FS functions that are not part ofthe image structure itself, are macros extending theImportTable members).Arne Bartels-----------------------------------

Share this post


Link to post
Share on other sites
Guest ghrasko

And if I am correct with the above assumptions, then is it OK to use the init function as follows (like in gauges)?void FSAPI module_init(void){ chain_insert2(CHAIN_18HZ_SYNC, System_18Hz, NULL, 0); chain_insert2(CHAIN_1HZ_SYNC, System_1Hz, NULL, 0); register_key_event_handler( (GAUGE_KEY_EVENT_HANDLER)KeyHandler, NULL);}Where the first two comands define my callbacks to be called by FS every 1/18th and 1 secons respectively. The third defines my callback function to be called by FS with any events. The callbacks are defined as follows:void FSAPI System_1Hz(DWORD event_id,VOID *buffer_specific,PVOID user_buffer,DWORD user_param){...}void FSAPI System_18Hz(DWORD event_id,VOID *buffer_specific,PVOID user_buffer,DWORD user_param){...}void FSAPI KeyHandler(ID32 event, UINT32 evdata, PVOID userdata){ switch(event) { case KEY_DEC_COWL_FLAPS: ... break; case KEY_INC_COWL_FLAPS: ... break; ... }}

Share this post


Link to post
Share on other sites

Gabor,Realy thank you ...I'll try it later.I found some expamles too :) by Cyril Hruscak and Joel M. DeYoung.Alex.

Share this post


Link to post
Share on other sites

Hi again.Could you please say, where I can get definition of this fuction:>chain_insert2(CHAIN_18HZ_SYNC, System_18Hz, NULL, 0);>chain_insert2(CHAIN_1HZ_SYNC, System_1Hz, NULL, 0);>register_key_event_handler( (GAUGE_KEY_EVENT_HANDLER)KeyHandler, NULL);Where I compile project, I get this message:----------------------------------------------.module.cpp(16) : error C2065: 'CHAIN_18HZ_SYNC' : undeclared identifier.module.cpp(16) : error C2065: 'System_18Hz' : undeclared identifier.module.cpp(16) : error C3861: 'chain_insert2': identifier not found.module.cpp(17) : error C2065: 'CHAIN_1HZ_SYNC' : undeclared identifier.module.cpp(17) : error C2065: 'System_1Hz' : undeclared identifier.module.cpp(17) : error C3861: 'chain_insert2': identifier not found.module.cpp(18) : error C2065: 'KeyHandler' : undeclared identifier----------------------------------------------In Gauge.h I didn't find declaretion of this fuction.Sorry for my English. :)Thanks.Alex.

Share this post


Link to post
Share on other sites
Guest ghrasko

Hi,I send you my "extended" fs9gauges.h file and a small sample if you give me your email address. I developed some codes using this technique. Now I develop a more complex one and I decided that I do not want to rely on these kind of "hacked" access, as I would like to be compatible with FSX also. So I interface FS via FSUIPC (unregistered or registered - depending on whether you would like to read only, or write as well). With this technique I can easily compile my code in two versions: FS Module and Windows EXE - only the main routine should be different. You will see my main code fragment below. Somewhere in the initialization code I start a timer so I will have a routine running every - let's say - 1/10th seconds independent of FS:// Initializes 10Hz timerTimerID = SetTimer( NULL, 0, 100, System_10Hz );... where the 4th param is my timer routine:VOID CALLBACK System_10Hz( HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime )End now let's see the main code. Here you can not see the FSUIPC initialisation and usage, that is a well-documented thing elswhere. This is just a DLL that is used as a module. Very simple and works fine.//--- Global vars -------------------------------------------HINSTANCE hInstance = NULL;TCHAR sModulePath[MAX_PATH] = {0};//-----------------------------------------------------------// FS will call this routine on module initializationvoid __stdcall module_init(void){ Init( sModulePath ); // my init function...}//-----------------------------------------------------------// FS will call this routine on module shut downvoid __stdcall module_deinit(void){ ShutDown(); // my shutdown function...}//---------------------------------------------------------------// The DllMain function is an optional entry point into a // dynamic-link library (DLL). It is called by the system // when processes and threads are initialized and // terminated, or upon calls to the LoadLibrary and // FreeLibrary functions. See more:// http://msdn.microsoft.com/library/default....ase/dllmain.aspBOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved){ hInstance = hDLL; switch( dwReason ) { case DLL_PROCESS_ATTACH: // Retrieves gauge directory. GetModuleFileName( (HMODULE)hInstance, sModulePath, MAX_PATH ); sModulePath[strrchr((char *)sModulePath,'') - (char *)sModulePath + 1] = '0'; break; case DLL_PROCESS_DETACH: break; default: break; } return TRUE;}//-------------------------------------------------------------// This is the module's export table.typedef struct MODULELINKAGE{ int ModuleID; void (__stdcall *ModuleInit)(void); void (__stdcall *ModuleDeinit)(void); unsigned int ModuleFlags; unsigned int ModulePriority; unsigned int ModuleVersion; void *GaugeHdrs;} MODULELINKAGE;;EXTERN_C __declspec(dllexport) MODULELINKAGE Linkage ={ 0x00000000, module_init, module_deinit, 0, 0, 0x0900, NULL};

Share this post


Link to post
Share on other sites

Hi, Thank you for answer !this is my mail: petrochen@gmail.comI'll be glad get any helpful info on my e-mail :) any source code or info. Thank you again.soory for my English :)Alex.

Share this post


Link to post
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
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...