VOGONS


First post, by Hollowtip

User metadata
Rank Newbie
Rank
Newbie

I've recently started work on a mod for a game (basically injecting new code into it's exe) but ideally, this mod will talk to an external program running under windows.

I plan to implement a custom driver that is loaded before the game starts and then have the driver handle synchronization with the game and the external program. Would this sort of setup even be possible?

Also, the external program will need to read memory from the game. Correct me if I'm wrong, but I assume the memory for the game running will simply be a large, contiguous block of allocated block of memory within the DOSBox process and I shouldn't have any trouble reading it via ReadProcessMemory.

Thanks

Reply 1 of 6, by mr_bigmouth_502

User metadata
Rank Oldbie
Rank
Oldbie

That might be hard (or even impossible) to pull off because as I understand it, DosBox was designed to work as a virtual machine, and as such the degree that it can interact with external programs is quite limited.

Reply 2 of 6, by ripa

User metadata
Rank Oldbie
Rank
Oldbie

I plan to implement a custom driver that is loaded before the game starts and then have the driver handle synchronization with the game and the external program. Would this sort of setup even be possible?

You could register a custom I/O handler in Dosbox and use port I/O from within dosbox to execute the native I/O handler. Just choose some unused I/O location. See keyboard.cpp for example:

static void write_p61(Bitu port,Bitu val,Bitu iolen) {
// Native code here
}
IO_RegisterWriteHandler(0x61,write_p61,IO_MB);

Now when the emulated program does an "out" on port 0x61, write_p61() is executed.

Reply 3 of 6, by Hollowtip

User metadata
Rank Newbie
Rank
Newbie
ripa wrote:

You could register a custom I/O handler in Dosbox and use port I/O from within dosbox to execute the native I/O handler. Just choose some unused I/O location.

Thanks for the info, now I at least know that what I want to do is possible.

Reply 5 of 6, by aqrit

User metadata
Rank Member
Rank
Member

Using WriteProcessMemory on game code doesn't turn out well IF using dynamic core. WriteProcessMemory on data works AFAIK however it can be at different memory locations for every user/session/version, you'll have to search memory for a game string or something and use that as a base address.

IPX and the parallel port are some others ways to talk to things outside of the box. However, dosbox is open source so you can integrate with it directly as needed.

(system shock?)

Reply 6 of 6, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

The emulated memory is a contiguous block so using the recompiler doesn't change that you
can read/write/search the target visible physical memory. Whether or not that's useful is a different story
(setgmented memory, paging etc).