VOGONS


First post, by marzsyndrome

User metadata
Rank Newbie
Rank
Newbie

I'm playing round with code in some games atm and wish to be able to know not just when a specific address is modified by another instruction, but also when they're being read (say, for "cmp" purposes) by an instruction.

BPM serves the former well, but it appears there is no means with which to do the latter, which I feel is sorely lacking. I am of course using daum's SVN build (the version dated 2012/02/20 for the time being, since it's the last good build to date to not have serious problems regarding the debugger) as I am not aware of any other debugger-enabled build.

I'm sure someone will point to a patch or make one if it doesn't exist already, but bear in mind I've never built a DOSBox binary before (nor have I, for that matter, compiled much in the way of anything in the past), so preferably a pre-compiled debugger build with said patch applied would be more convenient for a simpleton such as myself.

But still, has such a feature just never been in demand at all? 🙁

Reply 1 of 4, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Because it is not that easy to code if you want to keep it fast.
You'd have to code some sort of overlay memory handler and check for other functions that can change the memory handlers.

Water flows down the stream
How to ask questions the smart way!

Reply 2 of 4, by aqrit

User metadata
Rank Member
Rank
Member

Run DOSBox under an external debugger then use hardware breakpoints

http://www.gamehacking.com/index.php?/topic/9 … ng-ease-of-use/

here is the code that I slapped together for my own use to convert between different addressing schemes

	if (command == "MEM") { // Convert a MEMory address between emulation and host  
if (*found==0) return true;

while (*found==' ') found++; // strip white space

// if a Colon exists then the input is a DOS address
for(int i = 0; i < 5; i++){
if(found[i]==':') goto DosboxToHost;
if(found[i]==0) break;
}

// else input is a Host address
// HostToDosbox:
Bit32u address = 0;
address = GetHexValue(found,found); // 32-bit only! (rewrite if need 64)

if(address < (Bit32u) MemBase) { // error control
DEBUG_ShowMsg("\nDEBUG: Invalid Input! %08X is Less Than MemBase ( %08X )\n\n",
address, MemBase );
return true;
}

DEBUG_ShowMsg("\nDEBUG: ( Host: %08X ) - ( MemBase: %08X ) = ( DosBox: %08X )\n",
address, (Bit32u) MemBase, address - (Bit32u) MemBase);

while (*found==' ') found++; // strip white space

if(*found){
Bit32u TargetSeg = GetHexValue(found,found);
if(TargetSeg != 0){
if ( GetAddress(TargetSeg,0) <= (address - (Bit32u)MemBase) )
DEBUG_ShowMsg(" %04x:%04X\n",TargetSeg, address - (Bit32u)MemBase - GetAddress(TargetSeg,0));
else
DEBUG_ShowMsg(" Error: %04X:0 is Greater Than %08X\n", TargetSeg, address - (Bit32u)MemBase);
}
}

if ( GetAddress(SegValue(cs),0) <= (address - (Bit32u)MemBase) )
DEBUG_ShowMsg(" CS:%04X\n",address - (Bit32u)MemBase - GetAddress(SegValue(cs),0));
if ( GetAddress(SegValue(ds),0) <= (address - (Bit32u)MemBase) )
DEBUG_ShowMsg(" DS:%04X\n",address - (Bit32u)MemBase - GetAddress(SegValue(ds),0));

DEBUG_ShowMsg("\n");
return true;

// displays an emulated game address converted to a host address
DosboxToHost:
Bit16u seg = 0;
Bit32u ofs = 0;
if (*found) {
seg = (Bit16u)GetHexValue(found,found);found++; // found++ == skip ":"
ofs = GetHexValue(found,found);
}
DEBUG_ShowMsg("\nDEBUG: ( DosBox: %08X ) + ( MemBase: %08X ) = ( Host: %08X )\n\n",GetAddress(seg,ofs),MemBase,(GetAddress(seg,ofs) + MemBase));
return true;
}

Reply 3 of 4, by marzsyndrome

User metadata
Rank Newbie
Rank
Newbie

Thanks for the swift response, but man that linked page is making my brain hurt a bit. I may know some basic level of x86 instruction hacking (and their associated hex values) but that's just a whole different level we're talking about. 🙁

Don't suppose you know of any super easy-to-follow tutorial out there involving the use of DOSBox and this OllyDbg thingymajig?

Reply 4 of 4, by aqrit

User metadata
Rank Member
Rank
Member

I'm not the greatest writer in the world 😜

1. Find the Virtual Address of the data you want to watch
( so we can set a hardware breakpoint on it )
2. Find a way to get the DOSBox debugger to break when it encounters a HW BreakPoint exception

Here is some more reading about debugging with DOSBox
but I don't think it covers Read Breakpoints

http://wiki.scummvm.org/index.php/HOWTO-Reverse_Engineering