Jump to content
Sign in to follow this  
marcom

Creating a custom module

Recommended Posts

Hi folks,I want to create a simple DLL that gets automatically loaded when FS9 starts and released when FS9 exits. The DLL won't communicate with FS9 directly so I hope I don't have to use the SDK (I have just taken a look at it and I'm not impressed :-) ). Which functions have to be exported by a DLL? I've taken a look at the existing DLL's (with DependencyWalker) and they all seem to export at least two functions, ImportTable and Linkage. The SDK doesn't explain these functions so I guess some type of macro creates those functions for you?Can someone maybe explain how these functions are called and what the prototype is so I can create my DLL?Thanks!Mark


Mark Foti

Author of aviaworx - https://www.aviaworx.com

logo_avsim.png

Share this post


Link to post
Share on other sites

Here is the basic block of code:#include "fs9gauges.h"#include "some_local_header_file.h"#include #include void FSAPI module_init(void){} void FSAPI module_deinit(void){} /* This is the module's import table. */ GAUGESIMPORT ImportTable = { { 0x0000000F, (PPANELS)NULL }, { 0x00000000, NULL } }; /* This is the module's export table. */ GAUGESLINKAGE Linkage = { 0x000002d9, module_init, module_deinit, 0, 0, FS9LINK_VERSION, {0} };The first element in the declaration of Linkage (0x2d9) can be pretty much any number you want.By including the reference to the gauges.h file, you will be able to use FS variables and key events - something that will make your life much easier.Doug

Share this post


Link to post
Share on other sites

Hi Doug,thanks for the info! That's pretty much exactly what I needed! Although I can't honestly say I truly understand how the constructs work...How come the FS SDK is so "unfriendly"? Does it have to do with FS's ancient programming history (I hear many parts of the core have been carried over from version 4 written in assembler)?I'll give the dll a try tomorrow - thank goodness I can communicate with FS through FSUIPC!Do you also use these constructs or did someone create a more user-friendly wrapper?Kind regards,Mark


Mark Foti

Author of aviaworx - https://www.aviaworx.com

logo_avsim.png

Share this post


Link to post
Share on other sites

And one more follow-up question:how can I add a menu entry to say the Modules menu?


Mark Foti

Author of aviaworx - https://www.aviaworx.com

logo_avsim.png

Share this post


Link to post
Share on other sites

And to everyone who might want to add something to the FS menu, consider using "SetWindowLongPtr" instead of "SetWindowLong" as its safer (considering the jump to 64 bit pointers)Regards,Mark


Mark Foti

Author of aviaworx - https://www.aviaworx.com

logo_avsim.png

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...