China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-23 10:02
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » Source code for reading the hard disk master boot sector View 926 Replies 4
Original Poster Posted 2003-09-20 00:00 ·  中国 湖北 宜昌 电信
高级用户
★★
Credits 677
Posts 194
Joined 2003-09-13 00:00
22-year member
UID 9778
Gender Male
Status Offline
'$INCLUDE: 'qb.bi'
DIM SHARED ax, bx, cx, dx, es
buff$ = SPACE$(512) 'set the disk buffer
bx = SADD(buff$) 'get the buffer offset address
es = VARSEG(buff$) 'get the segment address of the buffer
OPEN "savehd.dat" FOR BINARY AS #1
ax = &H201
cx = 1
dx = &H80
int13 ' call interrupt 13
PUT #1, , buff$
CLOSE #1
PRINT "The hard disk master boot sector has been successfully saved to the file SAVEHD.DAT!"
END

SUB int13
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

This program was written in qb4.5 and tested OK!
Hope everyone will give it lots of support!
Floor 2 Posted 2003-09-30 00:00 ·  中国 湖北 宜昌 电信
高级用户
★★
Credits 677
Posts 194
Joined 2003-09-13 00:00
22-year member
UID 9778
Gender Male
Status Offline
Explanation: INT 13 interrupt AH=2 read AL = number of sectors to read BX=buffer address CL=starting sector number
DL=the drive to operate on.
Using DEBUG is very simple
A
MOV AX,201
MOV BX,200
MOV CX,1
MOV DX,80
INT 13
INT 3
G ‘at this time the contents of the hard disk master boot sector have already been read out
N HDBOOT。DAT ’the filename to save
RCX 200 ‘the file size
W 200 ’start writing from address 200

I'm new here, please reply with a few posts everybody! I'd be happy even if you criticize me! Don't make me feel this place is so empty!
Floor 3 Posted 2003-10-03 00:00 ·  中国 湖北 武汉 联通
银牌会员
★★★
Credits 1,681
Posts 512
Joined 2003-08-02 00:00
22-year member
UID 7953
Gender Male
Status Offline
I found a small problem: RegType does not include es, RegTypeX should be used instead (I'm using QBX 7.1), and it should also be stated that /l should be added when compiling.

This program is really good, and the prompt under Win2000 is really cool: this program is trying to directly access the hard disk...
Somehow somewhere I've got to choose.
No matter if it is win or lose.
Floor 4 Posted 2003-10-03 00:00 ·  中国 福建 福州 电信
元老会员
★★★
农民
Credits 2,903
Posts 991
Joined 2003-07-23 00:00
22-year member
UID 7391
Gender Male
From 福建省
Status Offline
IceBoy, well done!
艰难奋长戟,万古用一夫

中国DOS联盟 http://www.cn-dos.net 欢迎大家来共同学习
我的MSN&E-Mail cn_archer@hotmail.com QQ 56049418
Floor 5 Posted 2003-10-04 00:00 ·  中国 陕西 西安 教育网
高级用户
★★
OS/2女孩
Credits 639
Posts 183
Joined 2003-06-14 00:00
23-year member
UID 5148
Gender Female
Status Offline
Hehe, actually under FREEDOS it can also easily damage the boot record, luckily it only reads.
QB45 may always use BATCH to launch QB4.5,
so he forgot to write the /L parameter, ???
REM 喜欢DOS,因为它的简单
REM 喜欢OS/2,因为它不再矫饰
REM 喜欢BASIC,因为它并不幼稚
REM 喜欢GNU,因为它杂乱无章
Forum Jump: