论文部分内容阅读
摘要:磁盘读写,历经指明柱面号(Cylinder)+磁头号(Head)+扇区号(Sector)到指明逻辑块地址(LBA)+磁头数+每磁道扇数,再靠扩展13H,指明LBA+磁盘地址包(DAP).98系统,按4K字节/页调配内存,16位asm虚拟86进程,靠bx=3180h(VtoolsD建立的设备名为K4PG_200之动态可装入VxD的ID),ax=1684h,int 2fh,取VxD入口es<<16+di,在Tx过程,做call [SVC],转入VxD之V86_Api_Handler,VxD,靠进入V86_Nest,调用BIOS,Nest要求QS及DAP处于0x10~0x10f有效物理页,此两者共处于逻辑地址空间(中断表及虚拟机管理器VMM占前0x10页)单页,较LinMap映入连续双页,易获成功。关键词:LBA如何对应CHS;后挪QS+DAP再前挪DAP;启用无需CreateFile所涉DLL之静态VxDLDR中图分类号:TP313基本方式之C(0起编号):比特0~7入CH,比特8,9入CL比特6,7,之H(0起编):入DH,之S(1起编):入CL比特0~5,ES:BX矢指QS,AL=读写之扇数,AH=2:读扇区至QS,=3,反方向,DL=80h:指明primary_master硬盘。填完上述入口,就Int 13H动作,返回flag_carry=0/1,述成功/失败。按先S下标增,再H增,再C增,即CHS=0:0:1,..CHS=0:0:3fh,CHS=0:1:1,..CHS=3feh:feh:3fh,能逐一对应LBA之0号..3eh号,3fh号..3ffh*ffh*3fh-1=FAC53Eh号;最终依磁头数+每磁道扇数,换LBA成CHS。13H,扩展变为DS:SI(矢DAP),AH(42h/43h等价前述2/3),DL同前,DAP形如:db16 ;占字节数 db0 sec_tot dw1 ;读写之扇数 QS_off dw0 ;QS偏移 QS_seg dw0 ;段值 LBAL dw0 ;LBA低双字低字 lbah dw0 dd0 ;高双字VXD的ON_SYS_.._INIT,可显模块名:PDDB LE;BYTE MZ[8+1]={0,0,0,0,0,0,0,0,0};LE=Get_DDB(0x3180,NULL);memcpy(MZ,LE->DDB_Name,8);SHELL_SYSMODAL_Message(Get_Cur_VM_Handle(),MB_SYSTEMMODAL,"modular",MZ);Return TRUE;//让VMM装VxD入内存.SVC转入Handler:DWORD due; Handler(VMHANDLE vm,PCLIENT_STRUCT pU){union{DWORD BX;short*pw;}lin;unsigned long OFF,hand,Sense;if(2>pU->CBRS.Client_AL){lin.BX=(DWORD)Map_Flat(CLIENT_ES,CLIENT_BX); OFF=lin.BX&4095; if((512+16)>(pU->CWRS.Client_BP=4096-OFF)) return; due=lin.BX>>12;pU->CWRS.Client_BP=4096; if((256+15)due){ for(hand=16;(256+15+1)!=hand;hand++) if(LinMapIntoV86(due,vm,hand,1,0,&Sense)) break; if((256+15+1)==hand){pU->CBRS.Client_AH=1;return;} due=Sense;pU->CWRS.Client_BP++;}Sense=(due<<12)+OFF;pU->CRS.Client_ES=Sense>>4;pU->CWRS.Client_BX=Sense-(pU->CRS.Client_ES<<4);if(!pU->CBRS.Client_AL){pU->CRS.Client_DS=pU->CRS.Client_ES+32;lin.BX+=512+2+2;*lin.pw=pU->CWRS.Client_SI=pU->CWRS.Client_BX;lin.BX+=2;*lin.pw=pU->CRS.Client_ES;}Begin_Nest_V86_Exec();Exec_Int(19); End_Nest_Exec();pU->CBRS.Client_AH=pU->CRS.Client_EFlags&1;}elseMapIntoV86(GetNulPageHandle(),vm,due,1,0,0);}先测QS+DAP这512+16字节是否整体在V86某页中,跨页则返回指明此整体后挪多少字节而不跨页的bp到asm方call [SVC]下条指令:Map_(..);..return;若QS+DAP虽处于某页due,但非有效范畴,则用LinMap,试映入某有效页:if((256+15)CBRS.Client_AL){..}AH为asm细络而存carry (LBA≤FAC53E盘,写3扇到LBA=FAC53E-2起始3扇,第3扇超LBA,将carry=1)pU->CBRS.Client_AH=pU..;asm交互VxD码:call TxTwo:cmp bp,4096jae VMspush bxmov bx,bp;使QS+DAP囿单页push cxmov cx,(512+16)/2mov si,(512+16)-1*2;整体原字尾mov di,bpadd di,si;新字尾std ;高向低方向rep movswcld pop cxpush bpcall Txmov di,512pop siadd si,dimov cx,16/2rep movswpop bxjmp twoVMs:je bit0push axmov al,dlcall Txpop axbit0:shr ah,1;恢复carry QS尾后挪时至少写DAP首字节(db16),故用mov di,512..复制DAP回原址,因为add LBAL,1adc LBAL[4],0:针对原DAP段偏移而增LBA靠ID=27h之VxDLDR之ax=1/2号服务,装(DX矢文件名)/卸(DX矢模块名)动态VXD:push ax ;压栈1或2.. ;bx=27h获入pop axmov bx,-1;对2号服务call [SVC]作者简介:马文晓(1962-),男,广东人,北京信息科技大学,科研干部,工程师,本科,研究方向:计算机应用。