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 02:41
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » Disk sector reading and writing, partition information management tool Dsptw (updated on 2008.11.29) View 112,531 Replies 565
Floor 361 Posted 2008-05-07 22:21 ·  中国 北京 电信
高级用户
★★
流落街头
Credits 570
Posts 272
Joined 2005-10-17 10:51
20-year member
UID 43609
Gender Male
From 北京
Status Offline
to gmy:
http://upload.cn-dos.net/img/363.rar
The version you wanted. I just came online and saw the requirements about m and n. I haven't implemented it yet. The recovery of MBR through the file has been implemented.

dsptw 0 /mbr /noback /File:mymbr.bin /y

The file size must not be less than 432 bytes.

This tool might be useful to you:
http://upload.cn-dos.net/img/339.rar

[ Last edited by 19951001 on 2008-5-7 at 10:55 PM ]
Floor 362 Posted 2008-05-07 22:37 ·  中国 山东 青岛 阿里云
版主
★★★
操作系统爱好者
Credits 1,113
Posts 392
Joined 2002-11-11 00:00
23-year member
UID 228
Gender Male
Status Offline
/file: The parameter has been tested successfully, I forgot. If there is time, add this function to the DOS version of dspt.

Looked at the str tool, it is really useful, but it can only do file to file, not file to disk, so it returns to the issue of /m /n function expansion. I imitate the parameters of str and suggest the building to add the following parameter:

Suggest adding /R1: Restore Bytes ("Byte Restore", which is a powerful supplement to /R "Sector Restore", and /m /n do not need to be developed because it has been included)

DSPTW

Start1: Offset to Process data in DstDisk. (Starting position of data to be processed on the target disk, supporting both decimal and hexadecimal)
Start2: Offset to Process data in SrcFile. (Starting position of data to be processed in the source file, supporting both decimal and hexadecimal)
Bytes: Total Bytes to be Processed (Total bytes to be processed in the source file, supporting both decimal and hexadecimal)

Example 1:
Restore hard disk partition table from a distance: Only restore the HPT (hard disk partition table) of machine A to the end flag to the corresponding position of machine B, excluding information such as MBR (Master Boot Record) and Microsoft digital signature.
Machine A: dsptw 0 0 1 /s a.bin /y
Machine B: dsptw 0 1 /r1 0x1BE /from a.bin 0x1BE 66 /y

Example 2:
Backup hard disk partition table locally: Only backup the 0-sector HPT (hard disk partition table) to the end flag to the corresponding position of the 1-sector, excluding information such as MBR (Master Boot Record) and Microsoft digital signature.
dsptw 0 0 1 /s a.bin /y
dsptw 0 1 /r1 0x1BE /from a.bin 0x1BE 66 /y

Example 3:
Restore hard disk partition table locally: Only restore the 1-sector HPT (hard disk partition table) to the end flag to the corresponding position of the 0-sector, excluding information such as MBR (Master Boot Record) and Microsoft digital signature.
dsptw 0 1 1 /s a.bin /y
dsptw 0 0 /r1 0x1BE /from a.bin 0x1BE 66 /y

When the above content was written, I suddenly realized: dsptw and str can cooperate to realize the above 3 examples, so stupid. The basic idea is:
Disk to file: dsptw /s
File to file: str
File to disk: dsptw /r

[ Last edited by gmy on 2008-5-8 at 11:01 AM ]
DOS之家 http://doshome.com 站长 葛明阳
Floor 363 Posted 2008-06-29 10:10 ·  中国 江西 吉安 电信
新手上路
Credits 2
Posts 1
Joined 2008-06-20 15:56
18-year member
UID 120637
Gender Male
Status Offline
Learn and benefit, thank you LZ for providing!
Floor 364 Posted 2008-06-30 21:15 ·  中国 江苏 苏州 电信
新手上路
Credits 11
Posts 5
Joined 2008-06-30 20:01
17-year member
UID 120960
Gender Male
Status Offline
Good post,
Thanks a lot for the LZ's sharing!
Floor 365 Posted 2008-07-14 18:09 ·  中国 广东 肇庆 电信
初级用户
Credits 112
Posts 49
Joined 2006-10-19 11:04
19-year member
UID 66890
Status Offline
Here is the translation:

Below is a batch script I wrote for operating the hard disk MBR. Is this correct? (Especially whether the return codes for each item are correct):

@echo off
cls
echo.
echo Hard disk MBR operation options:
echo.
echo 1. Backup 2. Restore 3. Rebuild
echo.
echo 4. View 5. Clear 6. Exit
echo.
choice /c:123456 /n What do I want to do:
if errorlevel 6 goto Exit
if errorlevel 5 goto dspt5
if errorlevel 4 goto dspt4
if errorlevel 3 goto dspt3
if errorlevel 2 goto dspt2
if errorlevel 1 goto dspt1

:dspt1
cls
dspt 0 0 1 /s %ramdrive%\mbr.bak /y >nul
if errorlevel 1 echo Failed to read the MBR of cylinder 0, sector 1!
if errorlevel 1 goto Exit
dspt 0 35 1 /r %ramdrive%\mbr.bak /y >nul
if errorlevel 1 echo Failed to backup the MBR to cylinder 0, sector 35!
if errorlevel 0 echo Congratulations, the operation was successful!!!
goto Exit

:dspt2
cls
dspt 0 35 1 /s %ramdrive%\mbr.res /y >nul
if errorlevel 1 echo Failed to read the MBR of cylinder 0, sector 35!
if errorlevel 1 goto Exit
dspt 0 0 1 /r %ramdrive%\mbr.res /y >nul
if errorlevel 1 echo Failed to restore the hard disk MBR!
if errorlevel 0 echo Congratulations, the operation was successful!!!
goto Exit

:dspt3
cls
dspt 0 /mbr /noback /y >nul
if errorlevel 1 echo Failed to rebuild the hard disk MBR!
if errorlevel 0 echo Congratulations, the operation was successful!!!
goto Exit

:dspt4
cls
dspt 0 0 1 /e /y >nul
if errorlevel 1 echo Failed to clear the hard disk MBR!
if errorlevel 0 echo Congratulations, the operation was successful!!!
goto Exit

:dspt5
cls
dspt 0 35 1 /L /p /a
if errorlevel 1 echo You haven't backed up the MBR!
if errorlevel 0 echo Congratulations, the operation was successful!!!
goto Exit

:Exit
Floor 366 Posted 2008-07-14 22:04 ·  中国 北京 电信
高级用户
★★
流落街头
Credits 570
Posts 272
Joined 2005-10-17 10:51
20-year member
UID 43609
Gender Male
From 北京
Status Offline
Originally posted by ljb603 at 2008-7-14 18:09:
The following is a batch script I wrote for operating the hard disk MBR. Is it correct? (Especially whether the return codes of each item are correct):
@echo off
cls
echo.
echo Hard disk MBR operation options:
echo.
echo ...


Operation is successful returns 0, and unsuccessful returns a value greater than 0, see the first floor.
In your batch script, if it fails, it will display a failure message, and if it succeeds, it will display a success message.

@echo off
cls
echo.
echo Hard disk MBR operation options:
echo.
echo 1. Backup 2. Restore 3. Rebuild
echo.
echo 4. View 5. Clear 6. Exit
echo.
choice /c:123456 /n I want:
if errorlevel 6 goto Exit
if errorlevel 5 goto dspt5
if errorlevel 4 goto dspt4
if errorlevel 3 goto dspt3
if errorlevel 2 goto dspt2
if errorlevel 1 goto dspt1

:dspt1
cls
dspt 0 0 1 /s %ramdrive%\mbr.bak /y >nul
if errorlevel 1 echo Failed to read MBR of cylinder 0, sector 1!
if errorlevel 1 goto Exit
dspt 0 35 1 /r %ramdrive%\mbr.bak /y >nul
if errorlevel 1 echo Failed to backup MBR to cylinder 0, sector 35!
if errorlevel 0 echo Congratulations, operation succeeded!!!
goto Exit

:dspt2
cls
dspt 0 35 1 /s %ramdrive%\mbr.res /y >nul
if errorlevel 1 echo Failed to read MBR of cylinder 0, sector 35!
if errorlevel 1 goto Exit
dspt 0 0 1 /r %ramdrive%\mbr.res /y >nul
if errorlevel 1 echo Failed to restore hard disk MBR!
if errorlevel 0 echo Congratulations, operation succeeded!!!
goto Exit
=========================
If there is no backup of MBR, then the MBR will be cleared! This will cause you great losses
=========================

:dspt3
cls
dspt 0 /mbr /noback /y >nul
if errorlevel 1 echo Failed to rebuild hard disk MBR!
if errorlevel 0 echo Congratulations, operation succeeded!!!
goto Exit

:dspt4
cls
dspt 0 0 1 /e /y >nul
if errorlevel 1 echo Failed to clear hard disk MBR!
if errorlevel 0 echo Congratulations, operation succeeded!!!
goto Exit
=============================
From the initial display, it seems it should be View, not Clear. If someone selects 4, then the MBR will be cleared. Originally intended to just view, but it might lose hard disk data. Should be careful
=================================

:dspt5
cls
dspt 0 35 1 /L /p /a
if errorlevel 1 echo You have not backed up MBR!
if errorlevel 0 echo Congratulations, operation succeeded!!!
goto Exit
======================================
If 5 is selected, it should be Clear, but the display won't cause damage at that time

If you want to display the first hard disk MBR, use dspt 0 0 1 /l /p /a
If you want to backup, use your this code
======================================
:Exit

[ Last edited by 19951001 on 2008-7-14 at 10:06 PM ]
Floor 367 Posted 2008-07-15 15:24 ·  中国 广东 肇庆 电信
初级用户
Credits 112
Posts 49
Joined 2006-10-19 11:04
19-year member
UID 66890
Status Offline
Thanks to the reminder from the previous post, I had mixed up the contents of :dspt4 and :dspt5. Now it is corrected as follows:
……
:dspt4
cls
dspt 0 35 1 /L /p /a
if errorlevel 1 echo You don't have a backup of the MBR!
if errorlevel 0 echo Congratulations, the operation was successful!!!
goto Exit

:dspt5
cls
dspt 0 0 1 /e /y >nul
if errorlevel 1 echo Hard disk MBR zeroing failed!
if errorlevel 0 echo Congratulations, the operation was successful!!!
goto Exit

:Exit
Floor 368 Posted 2008-07-16 18:12 ·  中国 北京 电信
高级用户
★★
流落街头
Credits 570
Posts 272
Joined 2005-10-17 10:51
20-year member
UID 43609
Gender Male
From 北京
Status Offline
Originally posted by ljb603 at 2008-7-15 15:24:
if errorlevel 1 echo You haven't backed up the MBR!
if errorlevel 0 echo Congratulations...


If it fails, you'll have both Echoes displayed like this.

[ Last edited by 19951001 on 2008-7-16 at 06:18 PM ]
Floor 369 Posted 2008-07-24 21:11 ·  中国 广东 广州 联通
初级用户
★★
Credits 167
Posts 80
Joined 2005-11-07 05:08
20-year member
UID 44725
Gender Male
Status Offline
Originally posted by 19951001 at 2008-5-7 22:21:
to gmy:
http://upload.cn-dos.net/img/363.rar
The version you want. I just came up and saw the requirements about m and n. It hasn't been implemented for the time being. The restoration of the MBR through the file has been implemented

ds ...


The file of 447 bytes seems unable to be restored.
Floor 370 Posted 2008-07-26 17:37 ·  中国 北京 电信
高级用户
★★
流落街头
Credits 570
Posts 272
Joined 2005-10-17 10:51
20-year member
UID 43609
Gender Male
From 北京
Status Offline
Originally posted by xypcmac at 2008-7-24 21:11:


A file of 447 bytes seems to be unrecoverable.



To recover the MBR through a file, as long as the file is larger than 432 bytes, when recovering, only the first 432 bytes are taken, and it has no relation to the content after 432 bytes
Floor 371 Posted 2008-07-26 18:02 ·  中国 广东 广州 联通
初级用户
★★
Credits 167
Posts 80
Joined 2005-11-07 05:08
20-year member
UID 44725
Gender Male
Status Offline
Why is there 447 bytes? That's because on the premise of 446 bytes (MBR), 1 byte of the first partition activation is added, that is, 80
Floor 372 Posted 2008-07-26 19:58 ·  中国 北京 电信
高级用户
★★
流落街头
Credits 570
Posts 272
Joined 2005-10-17 10:51
20-year member
UID 43609
Gender Male
From 北京
Status Offline
Originally posted by xypcmac at 2008-7-26 18:02:
Why is there 447 bytes? That's because on the premise of 446 bytes (MBR), 1 byte of the first partition activation is added. That is 80


Recover MBR information through file recovery, excluding partition table information. Currently, the Microsoft standard master boot record is 432 bytes, so the program only takes the content of 432 bytes for recovery. Your idea can be solved by using dspt(w) combined with str for sector recovery. Take a look at gmy's previous post.
Floor 373 Posted 2008-07-27 15:47 ·  中国 广东 广州 联通
初级用户
★★
Credits 167
Posts 80
Joined 2005-11-07 05:08
20-year member
UID 44725
Gender Male
Status Offline
DSPT

It seems that this command cannot restore irregular 447-byte files.

Of course, I can restore the 446-byte MBR and then use dsptw DISK /ACT:1 to complete it. But in this way, I will definitely have to write some batch processing code.
Floor 374 Posted 2008-09-03 18:03 ·  中国 北京 教育网
新手上路
Credits 2
Posts 1
Joined 2008-09-03 15:23
17-year member
UID 124682
Gender Male
Status Offline
Floor 375 Posted 2008-09-03 21:26 ·  中国 上海 浦东新区 电信
初级用户
Credits 83
Posts 38
Joined 2007-01-17 04:38
19-year member
UID 76759
Gender Male
Status Offline
It's really a good thing. Thanks to the landlord for sharing.
‹ Prev 1 23 24 25 26 27 38 Next ›
Forum Jump: