/******************************************** * RedirectDevice - redirect a device to a remote resource * ON ENTRY: * deviceStr has a string with the device name: * either disk or printer (ex. 'D:' or 'LPT1') * resourceStr has a string with the server and name of resource * (ex. 'TIM\TOOLS') * deviceType indicates the type of device being redirected * 3 = printer, 4 = disk * deviceParameter is a value to be saved with this redirection * which will be returned on GetRedirectionList * ON EXIT: * returns CC_SUCCESS if the operation was successful, * otherwise returns the DOS error code * NOTES: * deviceParameter is used in DOSEMU to return the drive attribute * It is not actually saved and returned as specified by the redirector * specification. This type of usage is common among commercial redirectors. ********************************************/ static uint16 RedirectDevice(char *deviceStr, char *resourceStr, uint8 deviceType, uint16 deviceParameter) { char slashedResourceStr[MAX_RESOURCE_PATH_LENGTH]; struct REGPACK preg = REGPACK_INIT; char *dStr, *sStr; /* prepend the resource string with slashes */ strcpy(slashedResourceStr, "\\\\"); strcat(slashedResourceStr, resourceStr); /* should verify strings before sending them down ??? */ dStr = com_strdup(deviceStr); preg.r_ds = FP_SEG(dStr); preg.r_si = FP_OFF(dStr); sStr = com_strdup(slashedResourceStr); preg.r_es = FP_SEG(sStr); preg.r_di = FP_OFF(sStr); preg.r_cx = deviceParameter; preg.r_bx = deviceType; preg.r_ax = DOS_REDIRECT_DEVICE; intr(0x21, &preg); com_strfree(dStr); com_strfree(sStr); if (preg.r_flags & CARRY_FLAG) { return (preg.r_ax); } else { return (CC_SUCCESS); } }
int com_dossetcurrentdir(char *path) { /*struct com_starter_seg *ctcb = owntcb->params;*/ char *s = com_strdup(path); com_errno = 8; if (!s) return -1; pre_msdos(); HI(ax) = 0x3b; SREG(ds) = DOSEMU_LMHEAP_SEG; LWORD(edx) = DOSEMU_LMHEAP_OFFS_OF(s); call_msdos(); /* call MSDOS */ com_strfree(s); if (LWORD(eflags) & CF) { post_msdos(); return -1; } post_msdos(); return 0; }
static int load_and_run_DOS_program(char *command, char *cmdline, int quit) { BMEM(pa4) = (struct param4a *)lowmem_alloc(sizeof(struct param4a)); if (!BMEM(pa4)) return -1; BMEM(allocated) = 1; BMEM(quit) = quit; BMEM(cmd) = com_strdup(command); if (!BMEM(cmd)) { com_errno = 8; return -1; } BMEM(cmdl) = lowmem_alloc(256); if (!BMEM(cmdl)) { com_strfree(BMEM(cmd)); com_errno = 8; return -1; } if (!cmdline) cmdline = ""; snprintf(BMEM(cmdl), 256, "%c %s\r", (char)(strlen(cmdline)+1), cmdline); /* prepare param block */ BMEM(pa4)->envframe = 0; // ctcb->envir_frame; BMEM(pa4)->cmdline = MK_FARt(DOSEMU_LMHEAP_SEG, DOSEMU_LMHEAP_OFFS_OF(BMEM(cmdl))); BMEM(pa4)->fcb1 = MK_FARt(COM_PSP_SEG, offsetof(struct PSP, FCB1)); BMEM(pa4)->fcb2 = MK_FARt(COM_PSP_SEG, offsetof(struct PSP, FCB2)); SREG(es) = DOSEMU_LMHEAP_SEG; LWORD(ebx) = DOSEMU_LMHEAP_OFFS_OF(BMEM(pa4)); /* path of programm to load */ SREG(ds) = DOSEMU_LMHEAP_SEG; LWORD(edx) = DOSEMU_LMHEAP_OFFS_OF(BMEM(cmd)); fake_call_to(BIOSSEG, GET_RETCODE_HELPER); LWORD(eax) = 0x4b00; real_run_int(0x21); return 0; }
int commands_plugin_inte6_done(void) { if (!pool_used) return 0; LWORD(ebx) = BMEM(retcode); if (BMEM(allocated)) { com_strfree(BMEM(cmd)); lowmem_free((void *)BMEM(pa4), sizeof(struct param4a)); lowmem_free(BMEM(cmdl), 256); if (BMEM(quit)) coopth_add_post_handler(do_exit, NULL); } pool_used--; if (!pool_used) { int leaked = smdestroy(&mp); if (leaked) error("inte6_plugin: leaked %i bytes, builtin=%s\n", leaked, builtin_name); lowmem_heap_free(lowmem_pool); } return 1; }