I am writing a 16-bit (PM16) version of PDOS-generic using an OS/2 1.x executable as a pseudo-BIOS and running under Windows 2000 (also tried HX dpmild16 under Freedos).
I got a protection violation and thought that I needed the equivalent of mprotect to overcome that. DosQueryMem and DosSetMem seem to do such a thing in OS/2 2.0, but don't seem to exist in OS/2 1.x.
Then I realized that there was no choice - code uses cs while data uses ds and you never execute code using ds, so you always need two separate selectors for a single block of memory if you wish to both execute and read/write. Nor can you even theoretically do a cs override to access data using cs, because you can't alter cs because it is permanently in use for the current code.
So my question is - how do you map an OS/2 1.x data selector to a code selector?
I tried this (as a guess):
x -= (__incr / 2) * 65536UL;
D:\devel\pdos\generic>bios pcomm.exe
bios starting
p is FCC7:0004
first byte of code is CB
incr is 8
entry_point is FCC7:0004
about to execute program
genstart is FCC3:0004
D:\devel\pdos\generic>
but still got a protection violation.
I tried doing an add - same result.
Any ideas?
Note that if I get it working, I will then take action to address the offset of 4 (which should be 0 when I try to execute more substantial code - currently it's just zapped to be a retf).
Thanks. Paul.
I got a protection violation and thought that I needed the equivalent of mprotect to overcome that. DosQueryMem and DosSetMem seem to do such a thing in OS/2 2.0, but don't seem to exist in OS/2 1.x.
Then I realized that there was no choice - code uses cs while data uses ds and you never execute code using ds, so you always need two separate selectors for a single block of memory if you wish to both execute and read/write. Nor can you even theoretically do a cs override to access data using cs, because you can't alter cs because it is permanently in use for the current code.
So my question is - how do you map an OS/2 1.x data selector to a code selector?
I tried this (as a guess):
x -= (__incr / 2) * 65536UL;
D:\devel\pdos\generic>bios pcomm.exe
bios starting
p is FCC7:0004
first byte of code is CB
incr is 8
entry_point is FCC7:0004
about to execute program
genstart is FCC3:0004
D:\devel\pdos\generic>
but still got a protection violation.
I tried doing an add - same result.
Any ideas?
Note that if I get it working, I will then take action to address the offset of 4 (which should be 0 when I try to execute more substantial code - currently it's just zapped to be a retf).
Thanks. Paul.