Windows


Windows - 4


int 21h ; ISR

pop ds

}

}

 

HANDLE AllocIntReflector(int iVector, FARPROC lpfnCallback)

{

DWORD dwDosMem ;

LPSTR lpLowRMISR ;

DWORD lpfnRMCallback ;

_RMCS FAR *lpSaveRegs ;

 

/* DOS ISR,

* */

 

dwDosMem = GlobalDosAlloc(16 + sizeof (int) + sizeof (_RMCS) ;

 

if (dwDosMem == 0)

return 0;

lpLowRMISR = (LPSTR) MAKELONG(0,LOWORD(dwDosMem)) ;

lpSaveRegs = (_RMCS FAR *) (&lpLowRMISR[16]) ;

 

/* (callback),

* */

 

lpfnRMCallback =

DPMI_AllocateRMCallback((FARPROC)lpfnCallback,

lpSaveRegs)

;

if (HIWORD((DWORD)lpfnRMCallback == 0)

{

GlobalDosFree(LOWORD(dwDosMem)) ;

return 0;

}

/* ( 6 )*/

lpLowRMISR[0] = 0x9A ; /* FAR */

*((DWORD FAR *)&(lpLowRMISR[1])) = lpfnRMCallback ;

lpLowRMISR[5] = 0xCF ; /*IRET */

*((int FAR *)&(lpLowRMISR[6])) = iVector ;

 

/* */

DPMI_SetRMVector(iVector,MAKELONG(0,HIWORD(dwDosMem))) ;

 

return (HANDLE) LOWORD(dwDosMem) ;

/* - */

}

 

void FreeIntReflector(HANDLE hReflector)

{

LPSTR lpLowRMISR ;

DWORD lpfnRMCallback ;

 

/* ISR */

lpLowRMISR = (LPSTR)MAKELONG(0,(WORD)hReflector) ;

 

/* , */

if ((lpLowRMISR[0] != 0x9A) || (lpLowRMISR[5] != 0xCF))

return ; /* , */

 

/* */

lpfnRMCallback = *((DWORD FAR *)&((lpLowRMISR[1])) ;

DPMI_FreeRMCallback(lpfnRMCallback) ;




- -  - -  - -