Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!think.com!linus!linus!bistromath.mitre.org!dkb From: dkb@bistromath.mitre.org (Daryl K. Baker) Newsgroups: comp.windows.ms.programmer Subject: Re: GlobalDosAlloc not exported in libs? Message-ID: <1991Mar12.183804.19190@linus.mitre.org> Date: 12 Mar 91 18:38:04 GMT References: <1991Feb13.165724.18629@linus.mitre.org> <1991Mar10.143402.12577@siesoft.co.uk> <1991Mar12.081711.8270@Informatik.TU-Muenchen.DE> Sender: news@linus.mitre.org (News Service) Organization: The MITRE Corporation, Bedford, MA Lines: 138 Nntp-Posting-Host: bistromath.mitre.org I posted the orignal querry and thanks to all who responded with the "correct" answer (no included in windows.h add defintions). Now for the why. I am trying to call a tsr. In article <1991Mar12.081711.8270@Informatik.TU-Muenchen.DE> rommel@Informatik.TU-Muenchen.DE (Kai-Uwe Rommel) writes: >In article <1991Mar10.143402.12577@siesoft.co.uk> mjc@siesoft.co.uk (Mark Carlin) writes: >>I would hazard a guess and suggest that if your intention is to >>communicate with a a DOS program, such as a TSR, then you may have another >>problem to follow; altering segment registers and issuing a software >>interrupt in in enhanced mode will cause a protection violation. >>To overcome this you may have to mess around with DPMI (DOS Protected >>Mode Interface). >You *can* issue software interrupts in 386 enhanced mode, at least to >the most often used vectors, such as 2F, the multiplex interrupt. I use Unfortunately the interupt rouinte already exists and I can't change it. What I did was to write a little routine called dpmi_int86x (); with the same calling parameters as the microsoft routine int86x. This routine calls the dpmi handler to do a "call real mode interupt" (this routine is based on a recent article in PC Magazine) The thing you must make sure of is that all pointers point to dos memory. === dpmi_int86x === #include #include struct DPMI_REGS { WORD di; WORD xdi; WORD si; WORD xsi; WORD bp; WORD xbp; DWORD reserved; WORD bx; WORD xbx; WORD dx; WORD xdx; WORD cx; WORD xcx; WORD ax; WORD xax; WORD flags; WORD es; WORD ds; WORD fs; WORD gs; WORD ip; WORD cs; WORD sp; WORD ss; WORD protdx; WORD protsi; WORD protes; }; int dpmi_int86x ( int int_num, union REGS *inregs, union REGS *outregs, struct SREGS *segregs) { struct DPMI_REGS far * dos_dpmi_regs; struct DPMI_REGS dpmi_regs; WORD regs_seg, regs_off; dos_dpmi_regs = &dpmi_regs; dos_dpmi_regs->ax = inregs->x.ax; dos_dpmi_regs->bx = inregs->x.bx; dos_dpmi_regs->cx = inregs->x.cx; dos_dpmi_regs->dx = inregs->x.dx; dos_dpmi_regs->si = inregs->x.si; dos_dpmi_regs->di = inregs->x.di; dos_dpmi_regs->es = segregs->es; dos_dpmi_regs->ds = segregs->ds; dos_dpmi_regs->protdx = inregs->x.dx; dos_dpmi_regs->protsi = inregs->x.si; dos_dpmi_regs->protes = segregs->es; dos_dpmi_regs->ss = 0; dos_dpmi_regs->sp = 0; /* Uses dpmi server stack */ regs_seg = FP_SEG (dos_dpmi_regs); regs_off = FP_OFF (dos_dpmi_regs); _asm { push es mov ax, regs_seg mov es, ax mov ax, 0300h mov bx, int_num mov bh, 0 mov cx, 0 mov di, regs_off int 31h pop es } outregs->x.ax = dos_dpmi_regs->ax; outregs->x.bx = dos_dpmi_regs->bx; outregs->x.cx = dos_dpmi_regs->cx; outregs->x.dx = dos_dpmi_regs->dx; outregs->x.si = dos_dpmi_regs->si; outregs->x.di = dos_dpmi_regs->di; outregs->x.cflag = dos_dpmi_regs->flags & 1; return outregs->x.ax; } === sample caller === char far * dos_char_ptr; DWORD hDosMemory; HANDLE hProt, hReal; hDosMemory = GlobalDosAlloc ( (long) maxlen ); hProt = LOWORD (hDosMemory); hReal = HIWORD (hDosMemory); dos_char_ptr = GlobalLock ( hProt ); lstrcpy ( dos_char_ptr, name); inregs.h.ah = _nm_res_name; inregs.x.cx = maxlen; inregs.x.dx = FP_OFF(dos_char_ptr); inregs.x.di = FP_OFF(dos_char_ptr); segregs.ds = hReal; segregs.es = hReal; result = dpmi_int86x ( pctcp_int, &inregs, &outregs, &segregs); GlobalUnlock ( hProt); GlobalDosFree (hProt); Daryl Baker dkb@bistromath.mitre.org