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-30 03:57
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » Disk sector reading and writing, partition information management tool Dsptw (updated on 2008.11.29) View 112,536 Replies 565
Original Poster Posted 2006-11-02 01:17 ·  中国 北京 中移铁通
高级用户
★★
流落街头
Credits 570
Posts 272
Joined 2005-10-17 10:51
20-year member
UID 43609
Gender Male
From 北京
Status Offline
Disk Sector Reading and Writing, Partition Information Management Tool Usage Instructions


=============================
Diskrw.com is a disk sector reading and writing program
Dpit.com is a partition information management tool
Dspt.com is a combined version of the above two
=============================



Syntax:
DSPT
Disk: 0-First Hard Disk, 1-Second Hard Disk, ...(0 is the first hard disk, 1 is the second hard disk)
A:, B, C:, D: ....:
Start: Disk Absolute Sector Number (Sector number, should be an integer greater than or equal to 0, disk sectors are numbered starting from 0)
:n Partition Number (:n n is the partition number, which can be obtained through the command: dspt 0 /l)
Sectors: Total Sectors to be Processed (Number of sectors to be processed, value range 1-4194303, i.e., 0x0-0x3FFFFF)
/S: Save Disk Sector Info to File (Save disk sectors to file)
/R: Restore Disk Sector Info from File (Restore file information to disk, requiring the file size to be equal to the number of sectors to be restored multiplied by 512)
/C: Compare Disk Sector Info with File (Compare file information with disk sector information, requiring the file size to be equal to the number of sectors to be compared multiplied by 512)
FileName: Disk Sector Info File (File name)
/Y: Assume Yes on all Queries (Assume yes for all confirmation requests and do not display copyright information)

Examples:
dspt 0 0 1 /s mbr0.bin Save the information of one sector starting from sector 0 of the first hard disk to the file mbr0.bin. This position is the master boot record of the disk.
dspt 1 100 1000 /s sectors.bin Save the information of 1000 sectors starting from the 100th sector of the second hard disk to sectors.bin. The file size after saving should be 512000 bytes.
dspt 0 0 1 /c mbr0.bin Compare the file information with the information of one sector starting from sector 0 of the first hard disk. The file size is required to be 512 bytes.
dspt 0 0 1 /r mbr0.bin Restore the file information to one sector starting from sector 0 of the first hard disk. The file size is required to be 512 bytes.

DSPT
/L: List Disk Sector Info on Screen (List disk information on the screen)
/P: Pause echo Screen (Pause when full screen)
/A: Show ASC Value (Show ASC code)
DSPT
/E: Clear Disk Sector Info (Clear sector information)
Examples:
dspt 0 0 100 /L /p /a Display the information of 100 sectors starting from sector 0 of the first hard disk on the screen, pause when full screen and display ASC code.
dspt 1 100 1000 /e Clear the information of 1000 sectors starting from the 100th sector of the second hard disk.


DSPT
SrcDisk/DstDisk: 0-First Hard Disk, 1-Second Hard Disk, ...
A:, B:, C:, D: ....
Start: Disk Absolute Sector Number
Sectors: Total Sectors to be Processed
/D: Copy Disk Sector Info from SrcDisk to DstDisk (Copy disk information)
Offset: Disk Absolute Sector Number (Sector number, should be an integer greater than or equal to 0, disk sectors are numbered starting from 0)
/Y: Assume Yes on all Queries
Examples:
dspt 0 0 1000 /d 0 100 Copy the information of 1000 sectors starting from sector 0 of the first hard disk to 1000 sectors starting from sector 100 of the first hard disk.

DSPT
Disk: 0-First Hard disk, 1-Second Hard Disk, ...
/S: Save Disk Partition Info to File (Save disk partition information)
/R: Restore Disk Partiton Info from File (Restore disk partition information from file)
/C: Compare Disk Partiton Info with File (Compare disk partition information with file information)
FileName: Disk Partition Info File
/Y: Assume Yes on all Queries
Examples:
dspt 1 /s dsk1part.bin Save the partition information of the second hard disk to the file dsk1part.bin

DSPT
Save Partition Boot Record to File
Examples:
dspt 0 /s dbr0.bin /dbr Save the boot information of each partition of the first hard disk to the file dbr0.bin

Explanation about file size: The size of the saved partition information file and DBR information file should be (516 × number of sectors saved + 1)

DSPT
/L: List Disk Partition Info on Screen (List disk partition information on the screen)
/NOEXT: Don't Display Big Extended Partition (Don't display total extended partition information)
Examples:
dspt 0 /l Display the partition information of the first hard disk on the screen.

DSPT
Active Disk Partition n
Examples:
dspt 0 /ACT:2 Activate the second partition of the first hard disk. Only primary partitions can be activated.

DSPT
Find Disk Partition (Find partition)
type: Can be FAT16/FAT32/FAT/NTFS/LINUX/ALL
Examples:
dspt 0 /Find:all Find all partitions of the first hard disk, and the display format is 0:1 0:2 ....

DSPT
ReBuild Disk Main Boot Record
/NOBACK: Don't Backup old MBR
Examples:
dspt 0 /mbr Rebuild the main boot record of the first hard disk. By default, the original main boot record is backed up to dsk?mbr.bin, which has the same function as Fdisk/mbr.

DSPT
Hide/Unhide Disk Partition n (Hide/Unhide partition n, n can be obtained through dspt 0 /l)
Examples:
dspt 0 /hide:3 Hide the third partition of the first hard disk.
dspt 0 /unhide:3 Unhide the third partition of the first hard disk.

DSPT
Disk: 0-First Hard disk, 1-Second Hard Disk, ...
/DPS: Save Disk Partition Info to Last Cluster (Save partition information to the last cluster of the hard disk)
/DPR: Restore Disk Partiton Info from Last Cluster (Restore disk partition information from the last cluster of the hard disk, provided that partition information has been saved)
/DPC: Compare Disk Partiton Info with Last Cluster (Compare partition information with the information of the last cluster of the hard disk)
/Y: Assume Yes on all Queries
Note: Use this command with caution. If your BIOS does not support large hard disks, the last cluster obtained through BIOS may not be the real last cluster. At this time, reading and writing to this cluster may cause data loss.


2007.1.15
dpit 1.15 test version, added support for FAT32, NTFS volume labels, and can display the DOS drive letter of FAT32 partitions.

I don't have a test environment for FAT16, please help test whether the volume label and drive letter are correct.

2007.2.15
Release diskrw 2007.1.31 DOS official version.
Support DOS native drive letters, currently do not support IFS and NTFS4DOS generated drive letters.

2007.2.26
Release dspt and dpit DOS official versions

2007.5.29
Add a small tool

There is a modified DSPT DOS version on floor 262

2007.7.12
1 Add disk comparison function

DISKRW
Disk: 0-First Hard Disk, 1-Second Hard Disk, ...
A:, B:, C:, D: ...
Start: Disk Absolute Sector Number
Sectors: Total Sectors to be Processed
/O: Compare Disk Sector Info with DstDisk
DstDisk: 0-First Hard Disk, 1-Second Hard Disk, ...
A:, B:, C:, D: ...
Offset: Disk Absolute Sector Number

Examples:
diskrw c: 20 10 /O d: 5 Compare 10 sectors starting from sector 20 of drive C: with 10 sectors starting from sector 5 of drive D:
diskrw 0 10 10 /O c: 0 Compare 10 sectors starting from sector 10 of the first physical disk with 10 sectors starting from sector 0 of drive C:

2 Add the function to directly modify disk sectors
DISKRW /M /Hex:Value
Disk: 0-First Hard Disk, 1-Second Hard Disk, ...
A:, B:, C:, D: ...
SectorNo: Disk Absolute Secotor Number
Offset: Offset in Specified Sector (0..511)
/M: Modify Disk Sector Info
/Hex: Hexadecimal Stytle
Value: Hexadecimal Digital String (No more than 32 characters)

Examples:
diskrw c: 20 0 /M /Hex:ABCDEF Modify the three bytes at offset position 0 of sector 20 of drive C: to 0xAB, 0xCD, 0xEF

Note: Each modification of a sector is up to 16 bytes (32 characters) at most

2007.7.17 Update
dsptw 〔disk〕 /l /a
Add parameter /a to accurately get the total number of sectors of the disk in Win32 environment

2007.8.8
DOS version Diskrw update
1. Fix the bug in the disk editing function when the disk is a DOS drive letter.

Win32 version update Dsptw and diskrw

2007.8.15
diskrw update on the first floor
dspt update on floor 290

dspt error code:

#define SUCCESS 0
#define READ_DISK_ERROR 1
#define WRITE_DISK_ERROR 2
#define OPEN_FILE_ERROR 3
#define CREATE_FILE_ERROR 4
#define READ_FILE_ERROR 5
#define WRITE_FILE_ERROR 6
#define FILE_SIZE_ERROR 7
#define TOO_MANY_PARTITIONS 8
#define PARTITION_NUMBER_ERROR 9
#define PARTITION_CANNOT_BE_HIDDEN 10
#define PARTITION_CANNOT_BE_UNHIDDEN 11
#define ONLY_PRIMARY_PARTITION_CAN_BE_ACTIVE 12
#define UNSURPPORT_PARTITION 13
#define DISK_ERROR 14
#define NOT_ENOUGH_MEMORY 15
#define PARAMETER_ERROR 16
#define USER_CANCEL 17
#define LIST_OK 100
#define OS_ERROR 201
#define NAME_ERROR 202
#define COMPARE_MISMATCH 203
#define PRG_SIZE_ERROR 204
#define SECTORS_ERROR 205
#define PARAMETERS_TOO_FEW 207
#define UNKOWN_ERROR 1000


2008.9.27
Win32 version diskrw update
http://upload.cn-dos.net/img/798.rar



Content of this modification:
1 Command adjustment, the original /E command (delete sector content) is changed to /F command (sector content filling)
The original /E command fills the specified sector with 0
The current /F command can specify any value to fill the sector. If no Value value is entered, it performs the same function as the original version's /E command

DISKRW
/F: Fill Disk Sector Info with Value
Value: an Integer (0..255), default is 0

2 Command adjustment, change the command to modify the sector from the original /M (Modify) to /E (Edit) for more intuitive
DISKRW
SectorNo: Absolute/Relative Sector No. of Disk
Offset: The Offset in Specified Sector (0..511)
/E: Edit Disk Sector Info
/HEX: Hex Style
Value: Hex Digital String (No more than 32 characters)

3 Function addition, add the function to move sectors, the used command is /M
DISKRW
/M: Move Disk Sector DATA form Disk to DstDisk
DstDisk: 0-First hard Disk, 1-Second Hard Disk, ...
A:, B:, C:, D: ...
Offset: Absolute/Relative Sector No. of Disk

4 Fix the Bug of the case of using hexadecimal numbers
DOS version has no this problem

2008.11.1
Diskrw for DOS

Different from the original version

1. Add parameter Offset
This parameter is used to specify the offset position inside the file, the default value is 0 (start of the file)
If the Offset value is given but the file does not exist, the given Offset value is ignored.
Examples:
Diskrw C: 0 10 /S sector.bin 10
Write 10 sectors from the starting position of drive C: to the file sector.bin. If the file does not exist, the size of sector.bin is 5120 bytes. If the file exists, such as the file size is less than 10 bytes, the program will give an error message. If the file size is greater than or equal to 10 bytes, the program will write the sector content to the offset position 10 of the file starting from 5120 bytes, and the original information in the file will be overwritten (if the file length is less than 5130 bytes, the file length will increase).


DISKRW
Disk: 0-First Hard Disk, 1-Second Hard Disk, ...
A:, B:, C:, D: ...
Start: Disk Absolute Sector Number
Sectors: Total Sectors to be Processed
/S: Save Disk Sector Info to File
/R: Restore Disk Sector Info from File
/C: Compare Disk Sector Info with File
FileName: Disk Sector Info File
/Offset: The Offset In FileName

2. Add function /M
This function has long been implemented in the win32 version, move the sector content of Sectors from position Start in disk Disk to position Offset in disk DstDisk. After moving, the corresponding position sector information in Disk will be cleared. If the moved sector and the moved-in sector positions overlap, the program will intelligently select the part of the sector to be cleared.

DISKRW
/D: Duplicate Disk Sector Info from Disk to DstDisk
/O: cOmpare Disk Sector Info with DstDisk
/M: Move Disk Sector Info from Disk to DstDisk
DstDisk: 0-First Hard Disk, 1-Second Hard Disk, ...
A:, B:, C:, D: ...
Offset: Disk Absolute Sector Number

3. Add parameter /Asc
Edit the disk can directly use ASCII code, the length is not more than 16 characters.

DISKRW :
SectorNo: Disk Absolute Secotor Number
Offset: Offset in Specified Sector (0..511)
/E: Edit Disk Sector Info
/Hex: Hex Style
/Asc: ASCII Style
Value: Hex_Digital/ASCII String (32/16 Characters Maximum)

4. Sector internal processing command (only process a single sector)
If Bytes is input as 0 or the input data is large (exceeds the sector boundary), the program processes the number of bytes from Offset to the end of the sector

Examples:
Diskrw 0 0 446 /b 64 mbr.dat Backup 64 bytes starting from offset position 446 in the first sector (sector 0) of the first hard disk (disk 0) to the file mbr.dat. (Here, the partition table information in the disk MBR is backed up)


DISKRW
/B: Backup Disk Sector Info to File
/V: Vertify Disk Sector Info with File
/U: Update Disk Sector Info from File
Bytes: Bytes to Process (0..512)

diskrw for Win32
1. Fix the bug in the function of displaying disk sectors. When the number of sectors is a multiple of 16, there is a problem when displaying the last screen. Rewrite the sector display function.

2. Fix the error that the return value is SUCCESS when disk reading and writing fails.

http://www.cn-dos.net/forum/attachment.php?aid=4373&checkid=65c57&download=1

2008.11.13 diskrw for DOS final version floor 389
http://www.cn-dos.net/forum/attachment.php?aid=4378&checkid=8ef93&download=1

2008.11.15
diskrw amphibious version
http://www.cn-dos.net/forum/attachment.php?aid=4386&checkid=090a9&download=1


2008.11.29 dsptw update
Add a switch /GetID that can display the partition ID value (applicable to /L and /find commands)
Usage method:
dsptw 0 /l /getid
dsptw 0 /find:all /getid

http://www.cn-dos.net/forum/attachment.php?aid=4418&checkid=8664f&download=1
Recent Ratings for This Post ( 2 in total) Click for details
RaterScoreTime
+1 2009-08-27 08:34
szl1123 +2 2010-03-24 22:30
Attachments
DsptDpit0208.rar (34.37 KiB, Credits to download 1 pts, Downloads: 604)
dsptw20070808.rar (32.3 KiB, Downloads: 649)
Floor 2 Posted 2006-11-02 02:08 ·  中国 福建 泉州 电信
银牌会员
★★★
Credits 1,276
Posts 469
Joined 2002-12-23 13:00
23-year member
UID 586
Gender Male
From 福建泉州
Status Offline
Download and test. Unexpectedly, the combined file is so much smaller.
QQ:366840202
http://chenall.net
Floor 3 Posted 2006-11-02 04:26 ·  中国 江苏 南京 电信
高级用户
★★
Credits 525
Posts 222
Joined 2006-08-28 21:07
19-year member
UID 61476
Status Offline
Originally posted by 19951001 at 2006-11-2 01:17:
This program was made at the request of the netizen cchessbd.
Combine my two small tools, diskrw and dpit, into one.

The program performs different functions according to the file name,
When the program name is diskrw, it executes...


Thanks. My boot disk has been updated many times because of this, heh heh.
But the bat inside is not very necessary, it's just that there is a dpit.com,
The cab compressed package can be reduced by 10k at a time.

[ Last edited by cchessbd on 2006-11-2 at 04:52 AM ]
Floor 4 Posted 2006-11-02 05:02 ·  中国 江苏 南京 电信
高级用户
★★
Credits 525
Posts 222
Joined 2006-08-28 21:07
19-year member
UID 61476
Status Offline
Yes, I just tested it. The recovery had an error.
Re-downloaded it. The test was fine. Thanks a lot!

[ Last edited by cchessbd on 2006-11-2 at 05:09 AM ]
Floor 5 Posted 2006-11-02 23:33 ·  中国 北京 中移铁通
高级用户
★★
流落街头
Credits 570
Posts 272
Joined 2005-10-17 10:51
20-year member
UID 43609
Gender Male
From 北京
Status Offline
2006.11.2 update
1 When using the diskrw function, when disk is A: or B:, the :N parameter is restricted.
2 Rewrite the /p and /a parameters of the display function of diskrw.
3 Some corrections in display aspects.

For the newly added parameter :N of diskrw, please refer to readme.txt in the compressed package.

[ Last edited by 19951001 on 2006-11-3 at 02:30 AM ]
Floor 6 Posted 2006-11-15 04:55 ·  中国 福建 泉州 石狮市 电信
银牌会员
★★★
Credits 1,276
Posts 469
Joined 2002-12-23 13:00
23-year member
UID 586
Gender Male
From 福建泉州
Status Offline
Downloaded the new version, and will support it again.
QQ:366840202
http://chenall.net
Floor 7 Posted 2006-11-15 08:54 ·  中国 浙江 宁波 电信
中级用户
★★
Credits 300
Posts 137
Joined 2005-11-04 02:00
20-year member
UID 44559
Gender Male
Status Offline
Not used before, what is it for?
Floor 8 Posted 2006-11-15 22:49 ·  中国 北京 中移铁通
高级用户
★★
流落街头
Credits 570
Posts 272
Joined 2005-10-17 10:51
20-year member
UID 43609
Gender Male
From 北京
Status Offline
Floor 9 Posted 2006-11-16 22:38 ·  中国 北京 中移铁通
高级用户
★★
流落街头
Credits 570
Posts 272
Joined 2005-10-17 10:51
20-year member
UID 43609
Gender Male
From 北京
Status Offline
2006.11.16
A BUG was found in the program, reported by netizen weilong888, and it has been fixed now.
Please download again.
Floor 10 Posted 2006-11-19 11:05 ·  中国 浙江 衢州 电信
银牌会员
★★★
Credits 1,270
Posts 548
Joined 2004-05-31 00:00
22-year member
UID 25754
Gender Male
Status Offline
I downloaded and tried it. The command `dpit 0 /c dsk0pt.bin` has already shown "done". But when using `dpit 0 /s dsk0dbr.bin /dbr`, it shows "disk read error". I took a look and there is an additional 1548B file named `dsk0dbr.bin`.
Floor 11 Posted 2006-11-20 04:56 ·  中国 北京 华北计算技术研究所
高级用户
★★
流落街头
Credits 570
Posts 272
Joined 2005-10-17 10:51
20-year member
UID 43609
Gender Male
From 北京
Status Offline
Originally posted by weilong888 at 2006-11-19 11:05:
I downloaded and tried. The command "dpit 0 /c dsk0pt.bin" has already shown "done". But the command "dpit 0 /s dsk0dbr.bin /dbr" shows "disk read error". I noticed that there is an additional 1548B file "dsk0dbr.bin".


I haven't found the problem here for the time being. You can try the Windows version to see if the same problem occurs, because the two versions have the same processing method. I will find the bug as soon as possible.

Can you upload your disk mbr? Use the command
diskrw 0 0 1 /s mbr0.bin
Save the file to mbr0.bin and then upload the file.

[ Last edited by 19951001 on 2006-11-20 at 05:04 AM ]
Floor 12 Posted 2006-11-20 13:50 ·  中国 浙江 衢州 电信
银牌会员
★★★
Credits 1,270
Posts 548
Joined 2004-05-31 00:00
22-year member
UID 25754
Gender Male
Status Offline
Now I'm uploading the mbr0.bin file from my diskrw 0 0 1 /s mbr0.bin. Let the楼主 see where this bug might be.

[ Last edited by weilong888 on 2006-11-21 at 08:56 AM ]
Floor 13 Posted 2006-11-20 22:26 ·  中国 北京 华北计算技术研究所
高级用户
★★
流落街头
Credits 570
Posts 272
Joined 2005-10-17 10:51
20-year member
UID 43609
Gender Male
From 北京
Status Offline
Originally posted by weilong888 at 2006-11-20 13:50:
Now I will upload the mbr0.bin file in my diskrw 0 0 1 /s mbr0.bin. The landlord, please take a look. Where could this bug be.


Try this version, I changed the search order.

[ Last edited by 19951001 on 2006-12-1 at 03:48 AM ]
Floor 14 Posted 2006-11-21 00:01 ·  中国 山东 青岛 阿里云
版主
★★★
操作系统爱好者
Credits 1,113
Posts 392
Joined 2002-11-11 00:00
23-year member
UID 228
Gender Male
Status Offline
Received, next version update.
DOS之家 http://doshome.com 站长 葛明阳
Floor 15 Posted 2006-11-21 03:39 ·  中国 北京 华北计算技术研究所
高级用户
★★
流落街头
Credits 570
Posts 272
Joined 2005-10-17 10:51
20-year member
UID 43609
Gender Male
From 北京
Status Offline
to weilong888:
I divided the disk into 3 primary partitions and one extended partition (with 6 partitions inside) on a machine by referring to your MBR method. There were no problems with the operation. I uploaded two versions on November 17. If the version you downloaded is the one uploaded in the morning, there might be an issue. Please re - download and test it again. I also provide another version here that can display primary partitions or logical partitions as requested by netizen chenall. Please test it as well.

[ Last edited by 19951001 on 2006 - 12 - 1 at 03:49 AM ]
1 2 3 38 Next ›
Forum Jump: