主题:怎样用QB读取硬盘分区表
用了很多时间也搜索了不少资料也没有理出个头绪来,所用的程序只能正确读出一个扇区的数据,但我想读出6个扇区的数据应该怎样修改程序,能读取一个扇区数据的源程序为:
SUB Xint13 (M%, HdNum%, StartNum AS DOUBLE, BlockNum%, buff$)
ax% = 0: bx% = 1: cx% = 2: dx% = 3: bp% = 4
si% = 5: di% = 6: flags% = 7: ds% = 8: es% = 9
'IF LEN(Buff$) < 512 THEN Buff$ = SPACE$(512)
DIM reg%(9)
SELECT CASE M%
CASE 2
dat$ = STRING$(BlockNum% * 512, 0)
reg%(ax%) = &H4200
CASE 3
dat$ = buff$
reg%(ax%) = &H4300
CASE 8
reg%(ax%) = &H4800
reg%(ds%) = SSEG(buff$)
reg%(si%) = SADD(buff$)
reg%(dx%) = HdNum%
CALL INT86XOLD(&H13, reg%(), reg%())
EXIT SUB
END SELECT
DatSegment% = SSEG(dat$)
DatOffset% = SADD(dat$)
dap$ = CHR$(&H10) + CHR$(0) + MKI$(BlockNum%) + MKI$(DatOffset%) + MKI$(DatSegment%) + MKL$(StartNum) + MKL$(0)
reg%(ds%) = SSEG(dap$)
reg%(si%) = SADD(dap$)
reg%(dx%) = HdNum%
CALL INT86XOLD(&H13, reg%(), reg%())
buff$ = dat$
END SUB
另一个程序为(功能一样):
'$INCLUDE: 'qb.bi'
DIM SHARED ax, bx, cx, dx, es
buff$ = SPACE$(512) '设置磁盘缓冲区
bx = SADD(buff$) '获得缓冲区的偏移地址
es = VARSEG(buff$) '获得缓冲区的段址
OPEN "savehd.dat" FOR BINARY AS #1
ax = &H201
cx = 1
dx = &H80
int13 ' 调用13号中断
PUT #1, , buff$
CLOSE #1
PRINT "硬盘主引导区已被成功的保存到SAVEHD.DAT文件中!"
END
SUB int13
DIM InRegs AS RegTypeX
DIM OutRegs AS RegTypeX
InRegs.ax = ax
InRegs.bx = bx
InRegs.cx = cx
InRegs.dx = dx
InRegs.es = es
INTERRUPTX &H13, InRegs, OutRegs
ax = OutRegs.ax
bx = OutRegs.bx
cx = OutRegs.cx
dx = OutRegs.dx
es = OutRegs.es
END SUB
请高手指正,如何能正确读出前6个扇区的数据,跟指定扇区的数据。
SUB Xint13 (M%, HdNum%, StartNum AS DOUBLE, BlockNum%, buff$)
ax% = 0: bx% = 1: cx% = 2: dx% = 3: bp% = 4
si% = 5: di% = 6: flags% = 7: ds% = 8: es% = 9
'IF LEN(Buff$) < 512 THEN Buff$ = SPACE$(512)
DIM reg%(9)
SELECT CASE M%
CASE 2
dat$ = STRING$(BlockNum% * 512, 0)
reg%(ax%) = &H4200
CASE 3
dat$ = buff$
reg%(ax%) = &H4300
CASE 8
reg%(ax%) = &H4800
reg%(ds%) = SSEG(buff$)
reg%(si%) = SADD(buff$)
reg%(dx%) = HdNum%
CALL INT86XOLD(&H13, reg%(), reg%())
EXIT SUB
END SELECT
DatSegment% = SSEG(dat$)
DatOffset% = SADD(dat$)
dap$ = CHR$(&H10) + CHR$(0) + MKI$(BlockNum%) + MKI$(DatOffset%) + MKI$(DatSegment%) + MKL$(StartNum) + MKL$(0)
reg%(ds%) = SSEG(dap$)
reg%(si%) = SADD(dap$)
reg%(dx%) = HdNum%
CALL INT86XOLD(&H13, reg%(), reg%())
buff$ = dat$
END SUB
另一个程序为(功能一样):
'$INCLUDE: 'qb.bi'
DIM SHARED ax, bx, cx, dx, es
buff$ = SPACE$(512) '设置磁盘缓冲区
bx = SADD(buff$) '获得缓冲区的偏移地址
es = VARSEG(buff$) '获得缓冲区的段址
OPEN "savehd.dat" FOR BINARY AS #1
ax = &H201
cx = 1
dx = &H80
int13 ' 调用13号中断
PUT #1, , buff$
CLOSE #1
PRINT "硬盘主引导区已被成功的保存到SAVEHD.DAT文件中!"
END
SUB int13
DIM InRegs AS RegTypeX
DIM OutRegs AS RegTypeX
InRegs.ax = ax
InRegs.bx = bx
InRegs.cx = cx
InRegs.dx = dx
InRegs.es = es
INTERRUPTX &H13, InRegs, OutRegs
ax = OutRegs.ax
bx = OutRegs.bx
cx = OutRegs.cx
dx = OutRegs.dx
es = OutRegs.es
END SUB
请高手指正,如何能正确读出前6个扇区的数据,跟指定扇区的数据。