阅读:1183回复:4
各位大哥,为什么不行,帮我看看这段代码吧!!!
这是我写的读物理硬盘的驱动。
#define DEVICE_MAIN #include \"rw.h\" Declare_Virtual_Device(RW) #undef DEVICE_MAIN RwVM::RwVM(VMHANDLE hVM) : VVirtualMachine(hVM) {} RwThread::RwThread(THREADHANDLE hThread) : VThread(hThread) {} DWORD RwDevice::OnW32DeviceIoControl(PIOCTLPARAMS lpDIOCParms) { DWORD dwRetVal=0,retu; VMHANDLE hVM; DAP Dap,*lpDap; CLIENT_STRUCT saveregs; PCLIENT_STRUCT pRegs; DWORD PageNum1,PageNum2; WORD PageOff; DWORD Address,lpOutBuf; DWORD MyPage; WORD seg,offset; BYTE *lpOutBuf; switch(lpDIOCParms->dioc_IOCtlCode) { case DIOC_OPEN: case DIOC_CLOSEHANDLE: return DEVIOCTL_NOERROR; case READ: Save_Client_State(&saveregs); /*lpOutBuf 指向数据存储缓冲区,相当于int 13中的es:bx. lpOutBuf=(char *)lpDIOCParms->dioc_OutBuf; pRegs=lpDIOCParms->dioc_pcrs; hVM=Get_Cur_VM_Handle(); /*是否这里有问题? 我我认为要把PM下的线性地址转换为V86下段:偏移的形式 */ PageNum1=(DWORD)lpOutBuf>>12; PageOff=(DWORD)lpOutBuf&0xfff; if(!LinMapIntoV86(PageNum1,hVM,0x10,1,0,&MyPage))return 3; Address=(MyPage<<12)+PageOff; seg=LOWORD(Address>>4); offset=LOWORD(Address-(seg<<4)); _clientES=seg; _clientBX=offset; _clientAH=0x2; _clientAL=0x1; _clientCX=1; _clientDL=0x80; Begin_Nest_V86_Exec(); Exec_Int(0x13); End_Nest_Exec(); Restore_Client_State(&saveregs); PageNum1=GetNulPageHandle(); if(!MapIntoV86(PageNum1,hVM,0x10,1,0,0))return 3; break; case WRITE: break; default: return ERROR_NOT_SUPPORTED; } return 0; } |
|
沙发#
发布于:2002-08-08 17:34
为了能访问大硬盘,我还写了扩展int 13h的版本,也是死机!!我不明白的地方更多
// RW.cpp - main module for VxD RW #define DEVICE_MAIN #include \"rw.h\" Declare_Virtual_Device(RW) #undef DEVICE_MAIN RwVM::RwVM(VMHANDLE hVM) : VVirtualMachine(hVM) {} RwThread::RwThread(THREADHANDLE hThread) : VThread(hThread) {} DWORD RwDevice::OnW32DeviceIoControl(PIOCTLPARAMS lpDIOCParms) { DWORD dwRetVal=0,retu; VMHANDLE hVM; DAP Dap,*lpDap; CLIENT_STRUCT saveregs; PCLIENT_STRUCT pRegs; DWORD PageNum1,PageNum2; WORD PageOff; DWORD Address; DWORD V86PageNum,MyPage; WORD seg,offset; BYTE *lpOutBuf; switch(lpDIOCParms->dioc_IOCtlCode) { case DIOC_OPEN: case DIOC_CLOSEHANDLE: return DEVIOCTL_NOERROR; case READ: Save_Client_State(&saveregs); lpOutBuf=(char *)lpDIOCParms->dioc_OutBuf; pRegs=lpDIOCParms->dioc_pcrs; Dap.PacketSize=((DAP *)(lpDIOCParms->dioc_InBuf))->PacketSize; Dap.Reserved=((DAP *)(lpDIOCParms->dioc_InBuf))->Reserved; Dap.AbsoluteBlockNumber[0]=((DAP *)(lpDIOCParms->dioc_InBuf))->AbsoluteBlockNumber[0]; Dap.AbsoluteBlockNumber[1]=((DAP *)(lpDIOCParms->dioc_InBuf))->AbsoluteBlockNumber[1]; Dap.TransferBuffer=lpOutBuf; hVM=Get_Cur_VM_Handle(); /*转换地址*/ lpDap=&Dap; PageNum2=((DWORD)lpDap)>>12; PageOff=((DWORD)lpDap)&0xfff; if(!LinMapIntoV86(PageNum2,hVM,0x20,1,0,&MyPage))return 3; Address=(MyPage<<12)+PageOff; seg=LOWORD(Address>>4); offset=LOWORD(Address-(seg<<4)); _clientDS=seg; _clientSI=offset; _clientAH=0x42; _clientDL=0x80; Begin_Nest_V86_Exec(); Exec_Int(0x13); End_Nest_Exec(); Restore_Client_State(&saveregs); PageNum2=GetNulPageHandle(); MapIntoV86PageNum2,hVM,0x20,1,0,0); break; case WRITE: break; default: return ERROR_NOT_SUPPORTED; } return 0; } |
|
板凳#
发布于:2002-08-09 10:04
代码太长了,而且别人也不一定都用过,最明白的其实是你自己哦。
|
|
|
地板#
发布于:2002-08-09 10:17
调试跟踪
看是什么地方出的问题 大家再帮你想办法 |
|
|
地下室#
发布于:2002-08-11 11:58
在扩展INT 13的代码中,每次都是调用中断是,SOFTICE报告一个错误,然后就不能回到应用程序,无法退出SOFTICE
|
|