Hi! Dnia czwartek, 15 listopada 2007, Mike McCarty napisał: > Without actually seeing the defective code from DOS and your > attempted workaround, it's impossible to tell. I am an old hand > at MSDOS and assembler, though not much with the undocumented > I/Fs. However, if you want you can shoot me some code and I'll > have a look. Perhaps we can work this out via e-mail. > > A TSR may not be able to do what you want, unless it is rather > "smart". CX may be clobbered so far up that there's no way > for you to fix it, except in a DOS version specific manner, > if at all. One possibility is to patch DOS at install. IOW, > find the defective code, and patch over it, possibly jumping > out into your own code in a couple of places. It may not be > possible to fix this w/o clobbering something else that DOS needs, > so the patches might be significant. IOW, you might need to > trap multiple interrupt vectors and save information for more > than one level of DOS, along with flags indicating what was > taking place at the time CX got clobbered, and restore the > values the various levels of DOS need. This is fragment of dosemu code called after int2f AX=112E (just before quitting): if (LOW(state->eax) == MULTIPURPOSE_OPEN /* 2E */) { u_char *stack_ch, *stack_cl; // original CX value when int21 ah=6c00 is called u_short in2e_fileattr = sda_ext_attr(sda); // normally this should be enought SETWORD(&(state->ecx), out2e_result); // but I try to modify pushed CX on stack stack_ch = (u_char *) (Addr(state, ss, esp) - (784 + 6)); stack_cl = (u_char *) (Addr(state, ss, esp) - (784 + 7)); if ( ((in2e_fileattr & 0x00ff) != *stack_cl) && ((in2e_fileattr & 0xff00) != *stack_ch) ) { // sanity check error("Wrong stack offset for MULTIPURPOSE_OPEN!" "Expected value: 0x%04x. Value on stack 0x%02x%02x\n", in2e_fileattr, *stack_ch, *stack_cl); leavedos(1); } *stack_ch = (out2e_result & 0xFF00) >> 16; *stack_cl = out2e_result & 0x00FF; } I use this program to test if CX was set correctly: #include <stdio.h> #include <io.h> #include <dos.h> #include <conio.h> #include <errno.h> #define u_short unsigned int #define u_char unsigned char int open2e(u_short openmode, u_short fileattr, u_short fci, char *filename, int *respond) { int __fd = -1, res; asm { mov ax, 0x6c00 mov bx, openmode mov cx, fileattr mov dx, fci mov si, filename int 0x21 jc blad } asm mov res, cx; asm mov __fd, ax; *respond = res; return __fd; blad: asm mov errno, ax; return -1; } int main(void) { int fd, res; char *filename = "F:\\TEST.TXT"; clrscr(); fd = open2e(0x0042, 0x002a, 0x0001, filename, &res); if (fd == -1) { perror("open2e"); } else { printf("2e respond: 0x%04x\n", res); printf("fd == %d\n", fd); write(fd, "write test", 11); close(fd); } getch(); return 0; } If you need more do not hesitate to ask. Best regards, -- Rafał Cygnarowski rafi@xxxxxxx
Attachment:
signature.asc
Description: This is a digitally signed message part.