PDA

View Full Version : How to make dll's


mcq
10 Aug 2005, 13:44
Hi there!

I ever want to ask: how can I make myself a nice plugin-dll like FSUIPC, FSPassenger, your ActiGate & Co? Which language these programmers use and where can you get an SDK for these DLL's?

I know, it has only a little bit in common with scenery design, but although I wanted to ask it here, because I know you, arno, made such a plugin-dll (ActiGate)!

Yours,

Marcel

arno
10 Aug 2005, 14:05
Hi Marcel,

They are made in C. I have found a few example DLLs for FS on the internet and I used these as a basis for ActiGate.

But I don't find myself a real expert on this yet. For example I am still trying to let the DLL read the FS memory directly. I lack a bit in C DLL programming experience :).

mcq
10 Aug 2005, 14:16
Thanks....

OK, that's a good answer; even if there seems to be NO SDK... ;)

Marcel

arno
10 Aug 2005, 14:18
No, forgot to mention there. There is absolutely no SDK :D.

mcq
10 Aug 2005, 15:08
But where can I generally find source code of such dll's? (Like you found)?

Btw.: Your ActiGate is a nice and powerfull idea, even if it just works while the user has the dll installed; but I cannot find my Britten Norman Islander ;)

arno
10 Aug 2005, 15:42
Have a look at the names I mentioned in the ActiGate docs. I can't remember them now, but I think if you Google on them you should find something.

About the Islander, well that is not really the type of aircraft you see often on civil airport (and certainly not near gates/docking systems). So therefore I did not add it. But if enough people start asking, it might end up in a future version :).

rhumbaflappy
14 Aug 2005, 14:32
Hi mcq.

This is also posted at AVSIM.

At the avsim library, Cyril Hruscak has some examples of modules. Using his fsmenu.zip as a basis, I come up with this:


#include <windows.h>
#include "gauges.h"

/* This is the module's import table. */ \
GAUGESIMPORT ImportTable = \
{ \
{ 0x00000000, (PPANELS)NULL }, \
{ 0x00000000, NULL } \
}; \
\
\

void FSAPI module_init(void) {}
void FSAPI module_deinit(void) {}

/* This is the module's export table. */ \
GAUGESLINKAGE Linkage = \
{ \
0x00000000, \
module_init, \
module_deinit, \
0, \
0, \
GAUGE_HEADER_VERSION_FS900, {0}
};

// The standard window procedure used by the flight simulator
WNDPROC oldWndProc;

// Flight simulator main window handle
HWND hFSimWindow;

#define MENU_ENTRY "My Mo&dule"
#define ID_MY_MENUITEM 40001

/**
* Main window procedure that is called by the flight simulator to process
* incoming window messages.
*/
LRESULT CALLBACK FSimWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_NCPAINT:
{
HMENU hMenu, hMyMenu;

hMenu = GetMenu(hwnd);
if (hMenu != NULL) {
int i;
// Look for our menu entry in the main menu.
for (i = 0; i < GetMenuItemCount(hMenu); i++) {
char buf[128];
GetMenuString(hMenu, i, buf, 128, MF_BYPOSITION);
if (strcmp(buf, MENU_ENTRY) == 0) {
// It is already here, we do not need to add it again
break;
}
}
if (i < GetMenuItemCount(hMenu)) {
// It is already here, we do not need to add it again
break;
}
/* Create new menu. NOTE: It seems that this will be
* reached more times, so we cannot save the handle, because
* in such case it could be destroyed and we will not have
* any access to it in the simulator.
*/
hMyMenu = CreateMenu();
AppendMenu(hMyMenu, MF_STRING | MF_ENABLED, ID_MY_MENUITEM, "My &First Menu Entry");
// add the created menu to the main menu
AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT_PTR)hMyMenu, MENU_ENTRY);
}
}
break;
case WM_COMMAND:
if (LOWORD(wParam) == ID_MY_MENUITEM) {
// Add your code here
MessageBox(hwnd, "It works!", "HURA", MB_OK | MB_ICONEXCLAMATION);
return 0;
}
break;
}
// Call the original window procedure to handle all other messages
return CallWindowProc(oldWndProc, hwnd, uMsg, wParam, lParam);
}

/**
* Entry point of the DLL.
*/
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
hFSimWindow = FindWindow("FS98MAIN", NULL);
oldWndProc = (WNDPROC)SetWindowLong(hFSimWindow, GWL_WNDPROC, (LONG)FSimWindowProc);
break;
}
return TRUE;
}



This module uses only "windows.h" and the SDK's "gauges.h" for includes. I compiled this as a DLL, with the Visual C++ Express Edition beta, and it works as indicated.

Cyril uses a "modules.h" for his code, but it is not needed in the above example.

I converted this to use "gauges.h" because Module DLLs are basically a gauge, and I wanted to show this. By using gauges.h, many variables would now be available for the module, without needing to use an IPC ( such as FSUIPC ).

============================================

Another source of module info can be found at:

http://www.flightdecksoftware.com/downloads.php

The "cvs" download can get you the code for their FDSConnection.dll... an ipc to the flight simulator. I used that code as a basis to compile a CFS2 version of FDSConnection... without problem.

Dick

arno
15 Aug 2005, 03:08
Thanks Dick, this is interesting. Maybe I can drop the use of FSUIPC now as well. Will take a look at this :).

mcq
15 Aug 2005, 06:38
Yes, that's really interesting!

@arno: ok, islanders need no docking system, but they are NOT general aviation but airline aircrafts! :cool:

mcq
15 Aug 2005, 07:45
HEY MAN! I CAN'T BELIEVE IT! I'VE COMPILED MY VERY VERY FIRST DLL FOR FS!!!!

:rotfl: :rotfl: :rotfl: :rotfl: :rotfl: :rotfl:

BUT (ok, that's normal that there must be a "but" ;) ):

FS says that perhaps there is an uncompatible module instaled; should he load it?!?

So, my first question: How can I say FS, that my module is definitive compatible? (Perhaps anywhere a version number or something like that?)

But, that I must say: it is easier than I thought!!
:teacher:

mcq
15 Aug 2005, 11:07
An additional Question:

I'm mainly interested in improving my scenery via dll's, so my question is:

Does anybody know, how you can place any 3D object (e.g. from an mdl-library) with a dll, e.g. to place an airplane like FSTraffic or a car etc. like in EMMA Field?

Or perhaps anybody know, how I can access to DirectSound to play a *.wav like in FSSoundScape?

Or are these all questions nobody has an answer for? :(

Marcel

rhumbaflappy
15 Aug 2005, 17:50
Hi Marcel.

I think there is a line you can add to FS9.cfg to make "incompatible" gauges work... search the AVSIM forums.

For sound, check out Jose Oliviera's website:

http://www.jcboliveira.flysplash.org

As far as placing objects... who knows? ABACUS is supposed to be releasing a program that will allow adding objects and effects to program interactively, then create a BGL file for future use or distribution. But, it isn't released yet. When it is, it's probably one program I'll actually buy. :)

http://www.abacuspub.com/catalog/s600.htm

They say soon, but they have been saying that since April 9, 2005!

Dick

mcq
15 Aug 2005, 18:36
First of all: Thanks for the intersting sound-link (I mean José's link)!

But I think, you misunderstood me a little bit:

My dream is a module which places DYNAMICALLY 3D objects; just think of this: you've arrived with you aircraft on an airport and are parking anywhere; but the bus "sees" you and drives automatically to your parking position...!

For this case, you need the possibility to place a 3D object instantly to a special point in the coordintates system...

Marcel

arno
16 Aug 2005, 04:25
Hi Marcel,

I have never seen a way to do that. It is possible, because LAGO is also doing it with their Enhancer. But I don't think it is easy. Somehow you need to add the objects to FS at runtime. I guess we would have to know a lot more about the FS structure to be able to do that, but without a nice SDK I expect it is hard to achieve.

rhumbaflappy
16 Aug 2005, 05:48
Hi Marcel.

I recall a trhead at AVSIM's "MSFS Aircraft and Panel Design Forum" that indicates this is possible using DirectX commands from within a gauge. You'll have to search for that. But, I also recall there is no example for it.

Dick

Horst18519
16 Aug 2005, 06:43
Oliver Pabst has done this great job at his EDDW-airport. If I'd be a bit more experienced with C I'd love to try those things too. :o

I think, the biggest problem with this matter is that you won't be able to synchronise AI and other dynamic objects in FS - at least not with FS9. :D

mcq
16 Aug 2005, 06:49
EXACTLY that I meant! Does anybody know how he made his EDDW-scenery?

:scratchch :scratchch :scratchch :scratchch :scratchch :scratchch :scratchch


(I mean the dynamic objects, of course...)

Horst18519
16 Aug 2005, 06:51
I think there's only one who knows. :D ;)

by the way: Your ostfriesland-scenery and the Britten Norman are awesome! :)

arno
16 Aug 2005, 09:46
Hi Marcel,

I don't know exactly how he made the EDDW scenery (he never wanted to really tell that :)), but I am very sure that he is only using the section 15 dynamic scenery. No special DLL or what every is used. Just very smart checks within the dynamic scenery.

mcq
16 Aug 2005, 11:21
I've downloaded his scenery, but I found any dll, too, so I also believe that he just uses bgl's;

Interesting is how he made the trucks coming to your aircraft; with many tiny check areas and many different paths for each possible position you could park?? But then he needs thousand of paths...

:stirthepo

BUT: He has a config-file which includes all aircraft types... the interesting question now is how he loads THIS file within bgl files...???

I cannot understand why there are persons, who like it, that anybody want to know how they made this and that, but they won't tell...

That's like if you're talking to a magician... :wizard: (he won't tell it, too! ;) )

arno
16 Aug 2005, 11:44
BUT: He has a config-file which includes all aircraft types... the interesting question now is how he loads THIS file within bgl files...???

If I remember correct some sort of tool came with the scenery to set the aircraft type etc. I think that tool just changes the hex code fo the BGL file to match the configuration chosen. That wouldn't be too hard to do :).

I cannot understand why there are persons, who like it, that anybody want to know how they made this and that, but they won't tell...

If I remember correct, I once heard that Oliver is now using the technique for commercial sceneries. So I can understand that you don't want to give away your secrets in that case.

mcq
16 Aug 2005, 11:56
I've tested his small program a bit :D :D

After I've saved the editings, the file eddwbase.bgl was brand new... ;)

So it seems that you'll be right, arno, it seems that he "hardcodes" all changes and I believe, there is something like a "for"-loop in his dynamic scenery which opens him the possiblity, that his trucks, etc... will drive to that position he needs them.

But... there MUST be a variable containing the aircraft name; otherwise he couldn't check the type of aircraft...

arno
17 Aug 2005, 05:57
No, as far as I know there is no variable for that (that is why I started with ActiGate in the first place). I don't even think he is checking the aircraft type. The dynamics work with any type you use.

Only the gate has something set for the type. but if I remember correct that is done via the tool again.

mcq
17 Aug 2005, 07:19
Yes, your tool is a very interesting direction of scenery design...

Even if I personally have no use with these variables; although the day of week variable could be very interesting for me; but only for gimmicks like: the café has not opened on sunday :D

mayhem
19 Jan 2007, 13:25
void FSAPI module_init(void){}
void FSAPI module_deinit(void) {}

GAUGESIMPORT ImportTable = {
{ 0x0000000F, (PPANELS)NULL },
{ 0x00000000, NULL }
};
GAUGESLINKAGE Linkage = {
0x00408686,
module_init,
module_deinit,
0,
0,
0x900, // <---- This Is What Needs To Be Corrected
NULL
};

To contact me, use website below
Easy As Web Designs:
http://www.easyasweb.com

lordofwings
15 Jun 2007, 10:30
Would it perhaps be too difficult to mention where you got the sources to make your first DLL and share with the rest? it is supposed to be a place to share knowledge, you know ;-)

HEY MAN! I CAN'T BELIEVE IT! I'VE COMPILED MY VERY VERY FIRST DLL FOR FS!!!!

:rotfl: :rotfl: :rotfl: :rotfl: :rotfl: :rotfl:

BUT (ok, that's normal that there must be a "but" ;) ):

FS says that perhaps there is an uncompatible module instaled; should he load it?!?

So, my first question: How can I say FS, that my module is definitive compatible? (Perhaps anywhere a version number or something like that?)

But, that I must say: it is easier than I thought!!
:teacher:

Horst18519
15 Jun 2007, 10:38
Well, the thumbs-down may not be the best way to motivate him in this, would it? ;)

lordofwings
15 Jun 2007, 12:38
Well, the thumbs-down may not be the best way to motivate him in this, would it? ;)

And why not be more positive and think the other alternative (what really happened): that the icon looks very similar to a question mark. At least to me from the distance of my monitor that looked like a question mark. Now that I look more closely it is indeed a thumbs down.

Anyway, I still have no answer to my question which is why the forums exist ;-)

arno
16 Jun 2007, 04:44
How about actually reading the rest of this thread as well? At least two posts contain samples of the code or where to get them.

http://www.fsdeveloper.com/forum/showpost.php?p=7798&postcount=7
http://www.fsdeveloper.com/forum/showpost.php?p=7798&postcount=12

lordofwings
16 Jun 2007, 08:40
What about granting me some credit? ;-) I tried those examples and can't get the menu to appear on FS9.

How about actually reading the rest of this thread as well? At least two posts contain samples of the code or where to get them.

http://www.fsdeveloper.com/forum/showpost.php?p=7798&postcount=7
http://www.fsdeveloper.com/forum/showpost.php?p=7798&postcount=12

arno
16 Jun 2007, 08:55
Why don't you ask that then? You only mention that the original author does not show the sources he used to compile the example. But nowhere you mention that you are actually looking for a menu entry instead of a simple DLL example.

But I see you asked that in other thread already. So we'd better stop in this one.

rhumbaflappy
16 Jun 2007, 11:05
Here's a menu example for VS Express C++ for FS9:

http://webpages.charter.net/ludowr/fsmenu_2004.zip


http://webpages.charter.net/ludowr/images/ItWorks.jpg


EDITED++++

I did find the trick to eliminate the module warning:

/* This is the module's export table. */ \
GAUGESLINKAGE Linkage = \
{ \
0x00000000, \
module_init, \
module_deinit, \
0, \
0, \
FS9LINK_VERSION, {0}
};

FS9LINK_VERSION is the key

Dick

jcboliveira
16 Jun 2007, 11:48
Or give up on FS9 and go for simconnect, much much easier ;)

José

rhumbaflappy
16 Jun 2007, 13:16
Hi José.

I totally agree. It's time to move on to FSX and beyond.

Dick

lordofwings
17 Jun 2007, 05:40
Here's a menu example for VS Express C++ for FS9:

http://webpages.charter.net/ludowr/fsmenu_2004.zip

Dick

Thanks a million Dick! that is what I call cooperation, providing answers rather attacks.

I don't know what was wrong with the version I had, it compiled without failures or warnings but the Menu never appeared in FS. AFAIK I tried several types of "projects" but never worked. I just replaced my files with these two in the project you provided and now it works.

Doing C/C++ seems like going back to the dark ages LOL. I tried to add a UI form but then it said the project was going to be converted to CLR which I believe (?) would not be good, right? Is there a way to do a form that works within FS rather than displaying a message box? No worries I am not asking for an example, just some pointers if there are. I do my work in C# so this is like a blast from the past for me hehehehe.

lordofwings
17 Jun 2007, 06:04
Hi José.

I totally agree. It's time to move on to FSX and beyond.

Dick

I would and in fact I posess FSX Deluxe but don't use it that much. Main reasons are:

1. It is a resource hug even on my nVidia 256MB, Pentium 3.0GHz, 1GB machine
2. Most of the default jets are just too unreal to fly
3. The IVAO software doesn't work well yet with FSX (had to give up after weeks of trying)
4. The scenery of my home country where I like to fly (Panama) is just HORRIBLE, unreal, an eye sore

So I still fly FS9 :-) For programming I plan to do both FS9 and FSX. I believe many people still hold to FS9 for the same reasons as I do.

rhumbaflappy
17 Jun 2007, 08:59
The VS Express C++ cannot do windows forms... they have to be "hand-programmed".

You might try using Borland C++ Turbo Explorer ( also free ):

http://www.turboexplorer.com/cpp

If you do this, you probably need to update a manifest file to the windowXP winforms, or you'll get a pretty generic-looking form. That would be a subject for a Borland forum or newsgroup.


Dick

Phantoms
26 Sep 2007, 20:35
The VS Express C++ cannot do windows forms... they have to be "hand-programmed".

You might try using Borland C++ Turbo Explorer ( also free ):

http://www.turboexplorer.com/cpp

If you do this, you probably need to update a manifest file to the windowXP winforms, or you'll get a pretty generic-looking form. That would be a subject for a Borland forum or newsgroup.


Dick

Dick,
I've been trying to pick up C++ and been using Code::Blocks with MinGW. Code::Blocks can be found at http://forums.codeblocks.org and I originally used the packages and instructions at http://www.sci.brooklyn.cuny.edu/~goetz/codeblocks/. Would I be better off with the Borland IDE/Compiler?

I have programmed in Basic many ages ago on Vic20 and C64, some very extensive programs at that time. I tried picking up C++ about 10 years back, but gave up on it (used Visual C++ and tried learning from it's documentation). Now I'm trying and picking it up a little better thanks to some easier to follow tutorials (http://www.isotton.com/devel/docs/lcpp/ for example) and a couple good books.

xumepoc
19 Feb 2010, 06:10
Here's a menu example for VS Express C++ for FS9:

http://webpages.charter.net/ludowr/fsmenu_2004.zip


http://webpages.charter.net/ludowr/images/ItWorks.jpg


EDITED++++

I did find the trick to eliminate the module warning:

/* This is the module's export table. */ \
GAUGESLINKAGE Linkage = \
{ \
0x00000000, \
module_init, \
module_deinit, \
0, \
0, \
FS9LINK_VERSION, {0}
};

FS9LINK_VERSION is the key

Dick
Is this zip still around? I get 404 not found

rhumbaflappy
19 Feb 2010, 12:40
Here you go:

fsmenu_2004.zip (http://cid-f3950c5bbd2bcfa1.skydrive.live.com/self.aspx/FS%20Addons/FS9%20files/fsmenu%5E_2004.zip)

Dick

xumepoc
19 Feb 2010, 13:29
Here you go:

fsmenu_2004.zip (http://cid-f3950c5bbd2bcfa1.skydrive.live.com/self.aspx/FS%20Addons/FS9%20files/fsmenu%5E_2004.zip)

Dick

Much appreciated:D:D

ras78
04 Mar 2010, 03:35
I made a experimental DLL in order to fill thre USRVR5 variables with a value when the visibility is lower than a specified value. With this we might be able to condition the lights in case of fog, low vis etc...
I still have some problems with the C code, I'll post here the source.
My plan is to release this tiny DLL for free :)

ras78
10 Mar 2010, 16:02
Here it is, comments are welcome :)