Using Green Adventure Bar and Panels.DLL Crash

fs2crew
Posts: 1
Joined: Thu Nov 03, 2011 12:55 am

Postby fs2crew » Thu Nov 03, 2011 9:31 pm

Hi,



I'm testing FS2Crew's FSX products to see if they work out of the box in Prepar3D...



With my code, which works perfect in FSX, I'm getting a Panels.DLL crash.



I've narrowed down the line of code that causes this crash.



The offending code is associated with displaying information in the Green "Adventure Bar" on the top of the screen.





Here's the relevant code.



The line that triggers the crash is highlighted in Bold in the Case Panel Pre Init Section.



If I comment that line out, no crash.



Code:

PFNC_FSADVBARPROC FS_Show_Text; // Pointer to an exported function from the "WINDOW.DLL" module

// Flight Simulator's AdvBar - Function's Type Definition

typedef void (FSAPI *PFNC_FSADVBARPROC)(char* str, int i1, int i2, int i3); // Flight Simulator's AdvBar - Function's Type Definition






Code:

case PANEL_SERVICE_PRE_INITIALIZE:


{
// IF WE DON'T HAVE THE POINTER
// TO THE EXPORTED FUNCTION! then
if (FS_Show_Text == NULL)
{
// Get a handle to the "WINDOW.DLL" module
HMODULE hWindow = GetModuleHandle("WINDOW.DLL");

// If we got the handle then
if (hWindow != NULL)
{
// Get a pointer to the "WINDOW.DLL" module's exported function
[b]FS_Show_Text = (PFNC_FSADVBARPROC)GetProcAddress(hWindow, (char*)24);[/b]

// If we COULDN'T get the pointer
// to the exported function then
if (FS_Show_Text == NULL)
{
// NOTE: The current Flight Simulator SHOULD BE FS2004!

// Get a pointer to the "WINDOW.DLL" module's exported function (From the module's "Linkage")
FS_Show_Text = (PFNC_FSADVBARPROC)*((unsigned long*)((char*)(GetProcAddress(hWindow, "Linkage")) + 0xC8));

// If we got the pointer to
// the exported function then
if (FS_Show_Text != NULL)
{
// Get the current Flight Simulator's version
FltSim_Version = 1; // FS2004
}
}
else
{
// Get the current Flight Simulator's version
FltSim_Version = 2; // FSX
}
}
}

break;



User avatar
Beau Hollis
Lockheed Martin
Posts: 2116
Joined: Wed Oct 06, 2010 3:25 pm

Postby Beau Hollis » Mon Nov 07, 2011 7:51 am

I would suggest commenting out that code. You could also print the string out via gauge text instead. This add-on is attempting to make a direct function call into window.dll using a raw memory offset rather than using SDK. We have added new functionality to the window module, so the memory addresses and signatures of our functions have changed. There are several approved methods of displaying text in Prepar3D via the SDK that do not require reverse-engineering our binary libraries. Using the SDK will help ensure forward comparability with future releases and avoid possible EULA violations. If you need functionality that is currently not supported via the SDK, please post a feature request here in the forums.

Thanks,

Beau



Beau Hollis
Prepar3D Software Architect


Return to “Software Development Kit (SDK) Questions”

Who is online

Users browsing this forum: No registered users and 7 guests