ORE Shared Memory

After last nights post about implementing ORE, I tried a few more experiments in the hope that I’d be able to achieve my goal of having a BDS compiled EXE load an FPC compiled DLL and share objects between the two.

The biggest obstacle to implementing my goal is being able to allocate memory that is fully accessible on both sides of the application/DLL boundary. This is key to being able to share objects across the boundary.

Inspired by some sample code from Technomage, I hooked the EXE’s memory manager into the DLL’s memory manager. Due to the differences in implementation, this required some intermediate functions, but, the DLL loaded and the EXE appeared to be able to allocate (and to a certain extent use) memory using the DLL’s memory manager… so things were looking up.

Unfortunately, as the initialisation phase was nearing completion, *BOOM* EInvalidPointer exceptions. The strange thing about this is that by that stage, it had already requested a number of blocks of memory that in many cases had actually had data written to them.

Try as I might, I couldn’t find the cause. But as soon as I compiled the DLL with BDS the problem went away and I had memory shared between the EXE and the DLL and I was able to pass objects across the app/DLL boundary with no problems at all.

I guess somethings just aren’t meant to be.

Still, there are other options for compiling the DLL, including the free Turbo Explorer, so I think I’m going to plod on and get the system working entirely with BDS and then worry about the finer points of implementation at a later stage. One option could be to actually have both the app and the DLL hook their memory managers into a memory manager in another DLL.

But, one good thing has come out of all this… many of the concerns and questions I had about the design of ORE are now cleared up as I’m going to make the assumption that I can share objects across the application/DLL boundary. This frees up the design quite considerably since I don’t have to worry about a whole bunch of pointer transfer mechanisms… I can just pass an object.

And on the design front, I’ve made some progress with the statemachines in the play engine.

Main play engine statemachine:-

Play Engine - Main Statemachine

Initialisation statemachine:-

Play Engine - Initialisation Statemachine

Thats about it for now, overall progress has been a little slow over the last week or so, mainly due to trying to figure out all my convoluted data transfer mechanisms to get around the app/DLL boundary issues, but now I’ve got that side of things straight in my mind, I’m hoping things will speed up a little (they better do as I’m looking forward to making The Outer Reaches – Rise of The Raiders with the new engine :-) )

Leave a Reply


Bad Behavior has blocked 195 access attempts in the last 7 days.