First post, by Psyraven
Hi all
I noticed that r4481 broke the installer of Pacific Strike in some subtle ways. The installer reads the entirety of a 44 kb file into a buffer and then stores the number of read bytes in memory. Before r4481 all was fine but after that, the number of read bytes are written into a location that is INSIDE the read buffer. So the installer ends up writing a file with 2 corrupted bytes to the hard disk. I noticed that just before it reads the file with INT21 0x3f it resizes a memory block with INT21 0x4a. And when I add (reg_ah != 0x4a) to the list of operations that skip the /* Save registers */ code (which was added by r4481), the installer works correctly again.
I'm pretty sure the file read INT21 op being right after the memory block resize INT21 op is related, I just don't quite understand how the saving of registers and stuff is supposed to work.
Here's the result of some logging I added to the code, first two are in DOS_21Handler for op 0x4a (Resize memory block) and op 0x3f (READ Read from file or device), and last is in the MOV instruction whenever the value 0xAE60 is being written:
- BEFORE r4481:[DOS21] RESIZED MEMORY BLOCK SEGMENT 0x192 FROM 0xD40 BLOCKS (@ 0x1920 ~ 0xED20) TO 0x1840 BLOCKS (@ 0x1920 ~ 0x19D20)[DOS21] FILE READ 0xAE60 BYTES INTO BUFFER 0xEB14 ~ 0x19974[MOV] WRITING 0xAE60 to 0x722C2 <--- Address well outside the file read buffer- AFTER r4481:[DOS21] RESIZED MEMORY BLOCK SEGMENT 0x192 FROM 0xD40 BLOCKS (@ 0x1920 ~ 0xED20) TO 0x1840 BLOCKS (@ 0x1920 ~ 0x19D20)[DOS21] FILE READ 0xAE60 BYTES INTO BUFFER 0xEB14 ~ 0x19974[MOV] WRITING 0xAE60 to 0x11ED2 <--- Address inside the file read buffer
So having the /* Save registers */ code at the top of DOS_21Handler being done for op 0x4a (Resize memory block) seems to cause the installer program to end up writing the number of read bytes to 0x11ED2, which after the memory resize is now inside the read file buffer (0xEB14 ~ 0x19974).