阅读:1068回复:1
请教扩展int13的使用方法
请问如何使用扩展int13实现对硬盘的物理控制,即可以访问到任意指定的扇区,命令我知道,但不会用,希望各位高手举个例子,小弟不胜感激,谢谢
|
|
沙发#
发布于:2003-11-03 19:13
在9x下VXD可以进入V86模式调用Int13中断,我正在用,但是出现了一些问题,你也可以尝试一把,附源码:
void ReadSectors(CLIENT_STRUCT *pRegs) { Debug_Printf_Service(\"Entering: ReadSectors pRegs=0x%X\\n\",pRegs); //return; DWORD dwRetVal = 0xFF; VMHANDLE hVM; MEMHANDLE hMem; CLIENT_STRUCT saveregs; DWORD PageNum,Address,MyPage; WORD PageOff,seg,offset; DWORD AddrData = (DWORD)gSectors; //gSectors是我定义的一个全局数组,大小8192bytes DWORD vmpnum = 0x10; PageNum = AddrData>>12; PageOff = AddrData&0xfff; hVM = Get_Cur_VM_Handle(); //保存当前虚拟机的寄存器状态 Save_Client_State(&saveregs); vmpnum = GetFirstV86Page(); 这句我执行时总会产生错误,98死机。。。如果你解决了千万要告诉我一声,我在驱动开发网上发贴了,但是好像高手都很保守,不肯指点我这个新新手!:( if(!LinMapIntoV86(PageNum,hVM,vmpnum,2,0,&MyPage)) { Debug_Printf_Service(\"LinMapIntoV86: Failed\\n\"); Restore_Client_State(&saveregs); return; } Address=(MyPage<<12)+PageOff; //计算新的线性地址 seg=LOWORD(Address>>4); //把线性地址转化成传统的段:偏 offset=LOWORD(Address-(seg<<4)); //移量的形式 //输入的参数,具体怎么用看INT13的说明吧 pRegs->CWRS.Client_AX = 0x0210; //读16个扇区 pRegs->CWRS.Client_DX = 0x0080; //第一个硬盘 pRegs->CWRS.Client_CX = 0x0001; //开始扇区号; pRegs->CRS.Client_Alt_ES = seg; pRegs->CWRS.Client_BX = offset; Begin_Nest_V86_Exec(); //这一句使得系统转入虚拟86方式 Exec_Int(0x13); //执行13h中断 dwRetVal = pRegs->CBRS.Client_BH; //保存返回值 End_Nest_Exec(); //退出虚拟86方式 //这一段取消原来的映射 hMem = GetNulPageHandle(); MapIntoV86(hMem,hVM,vmpnum,2,0,0); Restore_Client_State(&saveregs); //Read OK if (dwRetVal == 0) { PIGD_DATA pIgdData = (PIGD_DATA)gSectors; Debug_Printf_Service(\"ReadOK: coremark=0x%X, m_card=%X, m_selva=%X\\n\", pIgdData->sect08.code.coremark,pIgdData->sect02.code.m_card,pIgdData->sect02.code.m_selva); if(pIgdData->sect08.code.coremark == 0x4D4F4C01 //Core Installed && pIgdData->sect02.code.m_card == 1) //Card Installed { if(pIgdData->sect02.code.m_selva&0x01) //Pub Partion is Read Only { //Wait_Semaphore( SetMutex, BLOCK_SVC_INTS ); gIsReadOnly = TRUE; //Signal_Semaphore( SetMutex ); } } gReadOk = TRUE; } else { Debug_Printf_Service(\"ReadFailed!!!\\n\"); } return; } |
|
|