I have been trying to load and execute a .COM file using int 21h DOS interrups (EXEC), but it seems there is a problem with the Parameter Block passed to BX. This script executes .COM file but no send parameters properly. Can you help me?
Reference I have used:Code:#include <stdio.h> #include <dos.h> #include <stdlib.h> #include <sys\types.h> int main(int argc, char near *argv[ ]) { int len, i, j, retorna; union REGS regs; struct param { int segmento; int cmd_ptr_offset; int cmd_ptr_segment; int fcb1_ptr_offset; int fcb1_ptr_segment; int fcb2_ptr_offset; int fcb2_ptr_segment; } par; char* cmd; struct SREGS sregs; // argv[3] contain the parameters to the .com eg. C:\myprogram -e comfilename parameters cmd[0] = (char) strlen(argv[3]); strcpy(&cmd[1],argv[3]); strcat(&cmd[1],"\r"); segread(&sregs); memset(par, 0, sizeof(par)); par.cmd_ptr_offset = (int) cmd; par.cmd_ptr_segment = sregs.ds; par.fcb1_ptr_offset = 0x5c; par.fcb1_ptr_segment = _psp; par.fcb2_ptr_offset = 0x6c; par.fcb2_ptr_segment = _psp; par.segmento = *((int far *)(((long)_psp<<16) | 0x2c)); printf("cmd:%s\n",cmd); regs.h.ah = 0x4b; regs.h.al = 0x00; regs.x.dx = (int) argv[2]; regs.x.bx =(int) ∥ sregs.es = sregs.ds; retorna = intdos(®s,®s); if (!(regs.x.cflag ? retorna : 0)) { printf("CARRY FLAG IS CLEAR.\n"); }; printf("Program has been executed: %s", argv[2]); return 0; }
http://www.delorie.com/djgpp/doc/rbinter/id/51/29.html
Thanks.



LinkBack URL
About LinkBacks


