📄 pm.c
字号:
void PMAPI DPMI_int86(int intno, DPMI_regs *regs){ /* Unsed in VDDs */}/****************************************************************************REMARKS:Load the V86 registers in the client state, and save the original statebefore loading the registers.****************************************************************************/static void LoadV86Registers( PCRF saveRegs, RMREGS *in, RMSREGS *sregs){ PCRF pcrf; /* current client register frame */ /* get pointer to registers */ pcrf = (PCRF)VDHQuerySysValue(CURRENT_VDM, VDHLSV_PCRF); /* Note: We could do VDHPushRegs instead but this should be safer as it */ /* doesn't rely on the VDM session having enough free stack space. */ *saveRegs = *pcrf; /* save all registers */ pcrf->crf_eax = in->e.eax; /* load new values */ pcrf->crf_ebx = in->e.ebx; pcrf->crf_ecx = in->e.ecx; pcrf->crf_edx = in->e.edx; pcrf->crf_esi = in->e.esi; pcrf->crf_edi = in->e.edi; pcrf->crf_es = sregs->es; pcrf->crf_ds = sregs->ds;}/****************************************************************************REMARKS:Read the V86 registers from the client state and restore the original state.****************************************************************************/static void ReadV86Registers( PCRF saveRegs, RMREGS *out, RMSREGS *sregs){ PCRF pcrf; /* current client register frame */ /* get pointer to registers */ pcrf = (PCRF)VDHQuerySysValue(CURRENT_VDM, VDHLSV_PCRF); /* read new register values */ out->e.eax = pcrf->crf_eax; out->e.ebx = pcrf->crf_ebx; out->e.ecx = pcrf->crf_ecx; out->e.edx = pcrf->crf_edx; out->e.esi = pcrf->crf_esi; out->e.edi = pcrf->crf_edi; sregs->es = pcrf->crf_es; sregs->ds = pcrf->crf_ds; /* restore original client registers */ *pcrf = *saveRegs;}/****************************************************************************REMARKS: Used for far calls into V86 code****************************************************************************/VOID HOOKENTRY UserReturnHook( PVOID pRefData, PCRF pcrf ){ VDHPostEventSem(hevFarCallRet);}/****************************************************************************REMARKS: Used for calling BIOS interrupts****************************************************************************/VOID HOOKENTRY UserIRetHook( PVOID pRefData, PCRF pcrf ){ VDHPostEventSem(hevIRet);}/****************************************************************************REMARKS:Call a V86 real mode function with the specified register valuesloaded before the call. The call returns with a far ret.Must be called from within a DOS session context!****************************************************************************/void PMAPI PM_callRealMode( uint seg, uint off, RMREGS *regs, RMSREGS *sregs){ CRF saveRegs; FPFN fnAddress; ULONG rc; TRACE("SDDHELP: Entering PM_callRealMode()\n"); LoadV86Registers(SSToDS(&saveRegs),regs,sregs); /* set up return hook for call */ rc = VDHArmReturnHook(hhookUserReturnHook, VDHARH_CSEIP_HOOK); VDHResetEventSem(hevFarCallRet); /* the address is a 16:32 pointer */ OFFSETOF32(fnAddress) = off; SEGMENTOF32(fnAddress) = seg; rc = VDHPushFarCall(fnAddress); VDHYield(0); /* wait until the V86 call returns - our return hook posts the semaphore */ rc = VDHWaitEventSem(hevFarCallRet, SEM_INDEFINITE_WAIT); ReadV86Registers(SSToDS(&saveRegs),regs,sregs); TRACE("SDDHELP: Exiting PM_callRealMode()\n");}/****************************************************************************REMARKS:Issue a V86 real mode interrupt with the specified register valuesloaded before the interrupt.Must be called from within a DOS session context!****************************************************************************/int PMAPI PM_int86( int intno, RMREGS *in, RMREGS *out){ RMSREGS sregs = {0}; CRF saveRegs; ushort oldDisable; ULONG rc; memset(SSToDS(&sregs), 0, sizeof(sregs));#if 0 /* do we need this?? */ /* Disable pass-up to our VDD handler so we directly call BIOS */ TRACE("SDDHELP: Entering PM_int86()\n"); if (disableTSRFlag) { oldDisable = *disableTSRFlag; *disableTSRFlag = 0; }#endif LoadV86Registers(SSToDS(&saveRegs), in, SSToDS(&sregs)); VDHResetEventSem(hevIRet); rc = VDHPushInt(intno); /* set up return hook for interrupt */ rc = VDHArmReturnHook(hhookUserIRetHook, VDHARH_NORMAL_IRET); VDHYield(0); /* wait until the V86 IRETs - our return hook posts the semaphore */ rc = VDHWaitEventSem(hevIRet, 5000); /*SEM_INDEFINITE_WAIT); */ ReadV86Registers(SSToDS(&saveRegs), out, SSToDS(&sregs));#if 0 /* Re-enable pass-up to our VDD handler if previously enabled */ if (disableTSRFlag) *disableTSRFlag = oldDisable;#endif TRACE("SDDHELP: Exiting PM_int86()\n"); return out->x.ax;}/****************************************************************************REMARKS:Issue a V86 real mode interrupt with the specified register valuesloaded before the interrupt.****************************************************************************/int PMAPI PM_int86x( int intno, RMREGS *in, RMREGS *out, RMSREGS *sregs){ CRF saveRegs; ushort oldDisable; ULONG rc;#if 0 /* Disable pass-up to our VxD handler so we directly call BIOS */ TRACE("SDDHELP: Entering PM_int86x()\n"); if (disableTSRFlag) { oldDisable = *disableTSRFlag; *disableTSRFlag = 0; }#endif LoadV86Registers(SSToDS(&saveRegs), in, sregs); VDHResetEventSem(hevIRet); rc = VDHPushInt(intno); /* set up return hook for interrupt */ rc = VDHArmReturnHook(hhookUserIRetHook, VDHARH_NORMAL_IRET); VDHYield(0); /* wait until the V86 IRETs - our return hook posts the semaphore */ rc = VDHWaitEventSem(hevIRet, 5000); /*SEM_INDEFINITE_WAIT); */ ReadV86Registers(SSToDS(&saveRegs), out, sregs);#if 0 /* Re-enable pass-up to our VxD handler if previously enabled */ if (disableTSRFlag) *disableTSRFlag = oldDisable;#endif TRACE("SDDHELP: Exiting PM_int86x()\n"); return out->x.ax;}void PMAPI PM_availableMemory(ulong *physical,ulong *total){ *physical = *total = 0; }/****************************************************************************REMARKS:Allocates a block of locked physical memory.****************************************************************************/void * PMAPI PM_allocLockedMem( uint size, ulong *physAddr, ibool contiguous, ibool below16M){ ULONG flags = VDHAP_SYSTEM; ULONG nPages = (size + 0xFFF) >> 12; flags |= (physAddr != NULL) ? VDHAP_PHYSICAL : VDHAP_FIXED; return VDHAllocPages(physAddr, nPages, VDHAP_SYSTEM | VDHAP_PHYSICAL);}/****************************************************************************REMARKS:Frees a block of locked physical memory.****************************************************************************/void PMAPI PM_freeLockedMem( void *p, uint size, ibool contiguous){ if (p) VDHFreePages((PVOID)p);}/****************************************************************************REMARKS:Lock linear memory so it won't be paged.****************************************************************************/int PMAPI PM_lockDataPages(void *p,uint len,PM_lockHandle *lh){ ULONG lockHandle; /* TODO: the lock handle is essential for the unlock operation!! */ lockHandle = VDHLockMem(p, len, 0, (PVOID)VDHLM_NO_ADDR, NULL); if (lockHandle != NULL) return 0; else return 1;}/****************************************************************************REMARKS:Unlock linear memory so it won't be paged.****************************************************************************/int PMAPI PM_unlockDataPages(void *p,uint len,PM_lockHandle *lh){ /* TODO: implement - use a table of lock handles? */ /* VDHUnlockPages(lockHandle); */ return 0;}/****************************************************************************REMARKS:Lock linear memory so it won't be paged.****************************************************************************/int PMAPI PM_lockCodePages(void (*p)(),uint len,PM_lockHandle *lh){ return PM_lockDataPages((void*)p,len,lh);}/****************************************************************************REMARKS:Unlock linear memory so it won't be paged.****************************************************************************/int PMAPI PM_unlockCodePages(void (*p)(),uint len,PM_lockHandle *lh){ return PM_unlockDataPages((void*)p,len,lh);}/****************************************************************************REMARKS:OS specific shared libraries not supported inside a VDD****************************************************************************/PM_MODULE PMAPI PM_loadLibrary( const char *szDLLName){ (void)szDLLName; return NULL;}/****************************************************************************REMARKS:OS specific shared libraries not supported inside a VDD****************************************************************************/void * PMAPI PM_getProcAddress( PM_MODULE hModule, const char *szProcName){ (void)hModule; (void)szProcName; return NULL;}/****************************************************************************REMARKS:OS specific shared libraries not supported inside a VDD****************************************************************************/void PMAPI PM_freeLibrary( PM_MODULE hModule){ (void)hModule;}/****************************************************************************REMARKS:Function to find the first file matching a search criteria in a directory.****************************************************************************/void *PMAPI PM_findFirstFile( const char *filename, PM_findData *findData){ /* TODO: This function should start a directory enumeration search */ /* given the filename (with wildcards). The data should be */ /* converted and returned in the findData standard form. */ (void)filename; (void)findData; return PM_FILE_INVALID;}/****************************************************************************REMARKS:Function to find the next file matching a search criteria in a directory.****************************************************************************/ibool PMAPI PM_findNextFile( void *handle, PM_findData *findData){ /* TODO: This function should find the next file in directory enumeration */ /* search given the search criteria defined in the call to */ /* PM_findFirstFile. The data should be converted and returned */ /* in the findData standard form. */ (void)handle; (void)findData; return false;}/****************************************************************************REMARKS:Function to close the find process****************************************************************************/void PMAPI PM_findClose( void *handle){ /* TODO: This function should close the find process. This may do */ /* nothing for some OS'es. */ (void)handle;}/****************************************************************************REMARKS:Function to determine if a drive is a valid drive or not. Under Unix thisfunction will return false for anything except a value of 3 (consideredthe root drive, and equivalent to C: for non-Unix systems). The drivenumbering is: 1 - Drive A: 2 - Drive B: 3 - Drive C: etc****************************************************************************/ibool PMAPI PM_driveValid( char drive){ /* Not applicable in a VDD */ (void)drive; return false;}/****************************************************************************REMARKS:Function to get the current working directory for the specififed drive.Under Unix this will always return the current working directory regardlessof what the value of 'drive' is.****************************************************************************/void PMAPI PM_getdcwd( int drive, char *dir, int len){ /* Not applicable in a VDD */ (void)drive; (void)dir; (void)len;}/****************************************************************************PARAMETERS:base - The starting physical base address of the regionsize - The size in bytes of the regiontype - Type to place into the MTRR registerRETURNS:Error code describing the result.REMARKS:Function to enable write combining for the specified region of memory.****************************************************************************/int PMAPI PM_enableWriteCombine( ulong base, ulong size, uint type){ return MTRR_enableWriteCombine(base,size,type);}/****************************************************************************REMARKS:Function to change the file attributes for a specific file.****************************************************************************/void PMAPI PM_setFileAttr( const char *filename, uint attrib){ /* TODO: Implement this ? */ (void)filename; (void)attrib; PM_fatalError("PM_setFileAttr not implemented!");}/****************************************************************************REMARKS:Function to get the file attributes for a specific file.****************************************************************************/uint PMAPI PM_getFileAttr( const char *filename){ /* TODO: Implement this ? */ (void)filename; PM_fatalError("PM_getFileAttr not implemented!"); return 0;}/****************************************************************************REMARKS:Function to create a directory.****************************************************************************/ibool PMAPI PM_mkdir( const char *filename){ /* TODO: Implement this ? */ (void)filename; PM_fatalError("PM_mkdir not implemented!"); return false;}/****************************************************************************REMARKS:Function to remove a directory.****************************************************************************/ibool PMAPI PM_rmdir( const char *filename){ /* TODO: Implement this ? */ (void)filename; PM_fatalError("PM_rmdir not implemented!"); return false;}/****************************************************************************REMARKS:Function to get the file time and date for a specific file.****************************************************************************/ibool PMAPI PM_getFileTime( const char *filename, ibool gmTime, PM_time *time){ /* TODO: Implement this ? */ (void)filename; (void)gmTime; (void)time; PM_fatalError("PM_getFileTime not implemented!"); return false;}/****************************************************************************REMARKS:Function to set the file time and date for a specific file.****************************************************************************/ibool PMAPI PM_setFileTime( const char *filename, ibool gmTime, PM_time *time){ /* TODO: Implement this ? */ (void)filename; (void)gmTime; (void)time; PM_fatalError("PM_setFileTime not implemented!"); return false;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -