• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Accessing FS9 memory space

Messages
158
Country
us-northcarolina
This ought to be out there somewhere, but I can't seem to find it.

How do I go about accessing the memory space inside FS9 directly? I know it can be done because FSUIPC does it. Other things do too. Yes, I know it's dangerous but I only want to read one string out of there. Assuming I can find the offset value inside the common area, how do I access it in C?

Another question on advanced topics...is it possible from a DLL running under FS9/FSX to execute (or attach or whatever terminology is correct) a gauge so that the gauge appears to the user without having to be placed in the panel.cfg? And if this can be done, anyone have any pointers on how to properly go about doing it?

I know these ain't easy!
Dutch
 
Okay, here's the basic of how it's done. Or at least, it worked for me. Your mileage may vary. In fact, your mileage may be zero and you may wind up in a cold, muddy ditch somewhere. But at least you get the thrill of doing something you're really not supposed to be doing :)

There's a DLL in FS9 called "GLOBAL.DLL". This is where most, not all, of the basic stuff you might be looking for is kept, somewhat in the same places as documented in the FSUIPC offets. But this is no guarantee! Use FSUIPC if possible, Peter has figured all this out for you. But if, like me, you need to provide some minimal read-only support for people without a registered copy of FSUIPC, you can grab some stuff out of Global.dll directly.

Even more disclaimers: writes to this memory may foul up FS and cause it to crash, or may not do what you think they will, or worse. Only read stuff, don't write it. Also, lots of stuff you may be hankering for isn't in global.dll. Weather, I think, is somewhere in Weather.dll and not at the offsets documented for FSUIPC which are in many cases virtual offsets, just tags for data retrieved from elsewhere. Hunting this stuff down is a black art.

Okay enough with the lawyering...these are the relevant code snippets to read a single byte (unsigned char) from FS memory at 0x0238, which is documented as "Hour of local time in FS (0-23)" in the FSUIPC offsets document.

Code:
HMODULE GLOBALHandle = NULL;     // Handle to the 'Global' DLL
UINT32 MyItemAddr = 0;                // Address of the byte we want
unsigned char LocalHour = 0;          // This is what we'll get

	case PANEL_SERVICE_CONNECT_TO_WINDOW:
		GLOBALHandle = GetModuleHandle("GLOBAL.DLL");
                break;


	case PANEL_SERVICE_PRE_DRAW:
		if (GLOBALHandle != NULL) {
			MyItemAddr = ((UINT32) GetProcAddress(GLOBALHandle, "Linkage")) + 0x0238;   <-- This is the offset, see FSUIPC docs
			if (MyItemAddr != 0) {
				LocalHour = (*(unsigned char *)MyItemAddr);
			}
		}

There may be far better ways to do this but since this magic is known to only a few and they aren't talkin' I had to work this out myself. But what's here works, for me at least.

Dutch
 
Back
Top