Hard disk space outside the operating system - Using DOSWindows 9X protection data

zhaozj2021-02-11  161

Use DOS / Windows 9X to protect data

Summary: This article describes how to use the hard disk space that cannot be managed by Windows to achieve special data protection requirements, and how to write MBR programs to complete special system service keywords: main boot record (MBR), boot record (DBR) ), CHS addressing, partition table

First, in the introduction, talk about data protection, you will think of data protection with encryption, disk arrays (data backup system), hard disk protection cards. Nice, these methods are very good, but it is not practical for ordinary personal users. This paper discusses some other feasible system data protection methods. What data needs to be protected? Some data you don't want to be known by others, such as your bank password; some data you don't want to be steamed by others, such as your paper; some data that is easily destroyed, such as the system files in the computer room. Second, DOS / Windows9x cannot be managed hard disk space today, the rapid development of personal microcomputer makes the window operating system everywhere. The development of storage technologies also makes the capacity of the hard disk increasing. However, the window system cannot fully utilize all hard disk space, I don't say that the window system cannot support these large-capacity hard drives, but the window system cannot take advantage of these hard disk space ---- this is the so-called implicit sector. There are several spaces on the hard disk that are not read or written in the window system. It is well known that it is necessary to partition before using the hard disk, the 0 head 0 cylinder 1 sector of the hard disk saves the first partition table (main partition table), the track where the partition table is located (0 head 0 cylinder first track 63 Sector), and the track of the partition table (partition linked list) of other logical drives. Moreover, generally hard drives use LBA mode to manage hard disk space, and the last two cylindrical DOS / WIDOWS systems in the hard disk are not used. For example: 2.1G hard drive uses the LBA mode with 1023 cylindrical, 64 head / cylinders and 63 sectors / tracks, a total of 1023 cylindrical X64 magnetic head / cylindrical X63 sector / track X512 byte / sector, if 2014MB; and the location of the last sector from the partitioning program of the window system (that is, the hard disk space jurisdiction under the operating system) is 255 cylindrical, 253 head, 63 sector (cylindrical and magnetic heads) Data), a total of (254 cylindrical X255 magnetic head / cylinder 1 cylinder X253 magnetic head / cylinder) X63 sector / track X512 byte / sector, if 2000MB. It is clear that there is a 14MB space is useless because some space caused by the conversion of different hard disk addressing mode cannot be used (lost). The system's INT 13H API allows the program to read and write spaces that these window systems cannot manage, which can be used to save some secret information, such as the encrypted data of some software, saved on the hard disk. These additional spaces do not have a concept, cluster, and other concepts, to read these spaces, only through the CHS addressing positioning sector, interrupt sector reading and writing with the 13th interrupt. Of course, this requires certain programming capabilities and has a certain understanding of the hard disk! Third, the most attractive MBR sector in the MBR (Master Boot Record sector is the MBR sector, which is located at the 0 head 0 cylinder 1 sector of the hard disk. The MBR sector is the Self-test when the system is started. The INT 19H first reads 512bytes content to memory 0: 7C00, and then handed control over the MBR sector. Its charm is here, then the operating system has not been loaded, but the operating system also requires the MBR program to boot, so the MBR sector is also called the main guidance sector, and the directive record of the window system is called DBR (DOS Boot Record ). Some of the viruses of the main guiding sector use the characteristics of the MBR sector, and the operating system has not guided the virus code, which is destroyed! This is a double-edged sword, which can use it to provide quality service for everyone. The most common example is the guidance of multi-operating systems. Although the MBR sector is only 512bytes, this is enough for the boot program.

But other sectors of its 0 tracks are not used, the partition table of the window system forms a linked list, how many logical drives will have a partition table, which is not used in the corresponding tracks. Under the window system, these tracks cannot be read directly. Only the partitioned linked list is read with the program to obtain the partition and the address of the tracks, and use INT 13. For example, write an enhanced main boot record (MBR), but the program size exceeds 512bytes, you can divide the binary code of the program into multiple 512bytes, exist on the 0 track, but the first executed code must be placed in the MBR sector, and To retain a good primary partition (total 64bytes) and Magic ID (2Bytes); MBR execution, MBR reads the other parts of the program to the 0 track to the memory. In theory, the main bootstrap is only limited by the implicit track. 31.5kBytes, main boot procedures, and partition tables when a track must be guaranteed (prevent some software from implicitting the track, and destroying the main boot record), so The program must be efficient, refined and short, it is best to write in assembly language. Also, the main boot program must be saved in the hidden sector, which is what the file management subsystem of the window system cannot be done. Therefore, it is necessary to use a installer to put the master's program code and data (MBR) as the installer's data to write MBR to the 0 track 0 sector sector through the write sector of INT 13H. Such actions have certain dangers because the original main boot record and the main partition table will be destroyed, so there is a backup of the original MBR and primary partition table, and completely copy the primary partition table to the new main boot record. Fourth, use the hard disk extra space to mention, use INT 13H to write data to the hidden track of the hard disk. Similarly, the data can also be read out. How can I hide some data that want to hide? In fact, the 13th interruption of the hard disk is in units of sectors, and the sector is in one byte to the smallest unit. In fact, all data can be treated by byte, ignoring its actual data structure, using the INT 13H's 02H read sector sub-function and 03H write sector sub-feature, you can read and write data easily from the hard disk. . As for the use of interruption on No. 13, there are many compilation books. This is not the content discussed herein! There is a problem, how do you know which local operating systems on the hard disk is useless? The front window has been introduced which is the case where the window system does not use the hard disk, and now how to use how the specific location is known. First introduce some knowledge of some hard disk storage structures. When a hard disk is designed, there is a hardware parameter. How many physical heads, physical cylinders, how many sectors have each track, how big Buffer is, must be a three-dimensional stereoscopic structure (CHS - cylinder , HEAD, SECTOR. The hard disk has been formatted in the factory, and each sector indicates that the address is logged, marked the bad sector and gives the actual capacity. At this time, the hard disk is like a small paper, the partitioning program of the operating system divides the hard disk into multiple areas, and then format each area with advanced formatting programs to make file storage in the file system. The front mentioned, the hard disk partition table also saves the implicit track, and the partition table is a linked table structure to know the location of every implicit track. Nowadays, the structure of the partition table is now briefly introduced: Hard Disk Partition Table is data to record the hard disk partition information.

In general, the 0 head 0 cylinder of the hard disk (i.e., the MBR-MASTER BOOT RECORD sector) saves the first partition table (main partition table) of the hard disk, and the partition table is located at the sector displacement 1beh, continuous 40h. One byte. One partition table can accommodate four partition entries, each item occupies 10h bytes, and a partition entry represents the usage of a partition. The data structure of the partition item is suitable for the data format of INT 13H. The structure of the partition entry is such that the 0th byte 80h is the flag of the active partition, the non-active partition is 00h; the first, 2nd, 3 bytes represent the starting position of the partition, the 4th byte is the operating system flag Different operating systems use different tags; the 5th, 6th, 7-bytes indicate the termination position, and the 8th, 9th, 10th, 11 bytes are represented by the current partition relative to the first sector of this partition, and 12th, 13, 14, 15 bytes indicate the total number of sectors in partitioning. The start address and the termination address are in the addressing method of CHS, the address is represented by 3 bytes, the cylindrical and sector data of the partition start (end), and the first byte of the first byte is 6 bits. For the partition start fan value, the maximum 63 (the sector is counted by 1 start counting), the high-character high 2 bits and the low-byte of the 8-bit total 10 bits are the hierarchical start column face value, the maximum value is 1023 ( The three byte is a magnetic head number, a maximum of 255 cylinders and a magnetic head by 0 start counting). The partitioned linked table structure of the window system, the main partition entry is the active partition, the extension partition entry represents the information of the extension partition, and there is a canary partition (logical drive) in the extended partition; the first, 2nd, 3 words of the extended partition entry The section indicates the position of the partition table of the first logical partition; if there is a second logical partition, the first, 2nd, 3 bytes of the second entry of this partition table indicate the position of the next logical partition table, if No this item is 0 value. This forms the structure of the linked list. In the default, the partitioning program of the window system stores each partition table in the first area of ​​the magnetron, but a track has 63 sectors, that is, 62 sectors have a total of 31KB. As for how to take advantage of these spaces. By reading the partition linked list, the operating system is obtained using the hard disk, compares the information detected by the BIOS (Basic Input Output System) (Save in CMOS Data), you can know how many spaces are available in the end of the operating system. (Mainly a partial sector of the last cylinder of the hard disk). You can return the maximum cylinder number of the hard disk by calling the 08H subsystem of INT 13H. In the case of calculating an extra hard disk space, you know that there is a few MB of space in the window system! The bigger the hard disk, the bigger the space! Save some secret sensitive data in the space that is abandoned in these window systems, and others cannot read through the operating system. As for where to put it, in what form, only you and your program know, have certain confidentiality! 5. There are many articles in the demonstration examples to introduce some ideas that use these hard drives. For example, using hard disk additional space encrypts personal confidential file, CMOS data, or personal software encrypted data; write a new one-to-zone protection INT 13H service program saved in implicit track, with a special MBR to put new The INT 13H service program resides in memory to achieve the function of the hard disk soft protection card. Now use a CMOS data self-protection MBR program to be prepared as an example, how specifically, how to save programming in an implicit sector and enhanced primary boot records.

CMOS data has a variety of ways, and some people use VXD technology to write to CMOS data; someone saves CMOS data with files, using programs in the automatic batch file to write data in CMOS data files in CMOS, which is also achieved The effect of protection. The principle of CMOS data protection in this paper is: First, the CMOS data is read out by port 70h and 71h; then, writing CMOS data into an implicit sector with INT 13H, for example: 0 column Face 0 head 29 sector; write the corresponding MBR, write the CMOS data in the hidden sector back to CMOS during each boot. This also achieves the protection of CMOS data! Here, it involves reading and writing methods of CMOS data and programming skills for MBR programs. The BIOS of different companies, their CMOS data formats are different, but they all send the CMOS address (a CMOS address to write a byte data) to send port 70h, and then read the data of this CMOS address with port 71h. Award's BIOS head 10h bytes Some dynamic CMOS data is saved, and then 70h bytes saves some hardware information and user configuration settings, and only the relatively fixed CMOS data of the rear 70h bytes will be saved. MBR - Main boot record, after the system self-test, the data in the MBR sector is read from the data in the MBR sector, that is, the MBR program is read to the memory address 0: 7C00H, and then handed over the control to the MBR. The MBR program of this article completes the CMOS data backcroping and reading operating system boot (DBR) in the following processes, and handles control to DBR for operating system boot. 1. Move the MBR from memory 0: 7C00H to memory 0: 0600h, a total of 512bytes; 2. Skip to the MBR moving code from memory 0: 0600h to 0: 0700h, continue to execute, keep the CMOS data implicit fan Interchange to memory 0: 0800h; 3. Set the address port (70h) of the CMOS (70h) and the reading and writing port (71h), write memory 0: 0800 in CMOS; 4. Read the primary partition table sequentially The content of the four partition items, determine whether it is a bootable partition, if it is 5, otherwise print "invalid partition table" information and enter the dead cycle; if the four partition entries are invalid, enter the ROM Basic; 5 . Save the start sector address of the domain entry, multiple read lead sectors (DBR) to memory 0: 7C00H, if the DBR is successful and the Macic ID (Magic AA55) is judged whether or not the boot record, If it is controlled to 0: 7C00H, the boot of the operating system is proceed, otherwise, "Missing Operating System." Is printed and enters the dead cycle; if the DBR is not successful, print "Error Loading Operating System." And enter the death Cycle; (mentoring the adobe source program and compilation method and program) have MBR, how to write it to the MBR sector? First compile the text into an EXE file, then extract the code and data of the program to a file with Debug (attached to the method program). You can use the program to read this 512bytes file to the memory byte array, and then write the array with INT 13H to the 0 cylinder 0 head 1 sector.

It can also be used to transform the binary data of the MBR file into the data representation you can accept by the programming language you can add to your installer, and write these data to your hard drive. The installer is written in a C language or assembly language, but the MBR program must write with assembly language! An installer (CMBoot.asm) and data conversion program (bintat.c) have been attached thereafter. Similarly, you can also think of more more practical ideas, such as encrypted partition tables, setting password authorization to access the hard disk, with two equality of partition analog backup systems, etc. The simulated backup system is relatively practical in the public recovery system in public room. With the advantages of the currently hard disk, two partitions A, B are separated from the same size, where the operating system and application are installed in the A partition, and write a manager to copy the contents of the A partition to the B partition, and hide B Partition; write a master boot record, you can use hotkey management to select the content recovery (copy) to a partition or normal startup each time you boot. There are a lot of features that MBR can achieve, you can give full play to your imagination to design such MBR! Sixth, the end language seems to be the above text, it seems simple to fully use the space of the hard disk, but this requires a relatively deep understanding of the hard disk, and can use C / C or assembly language. Overall, there is a better skill. Now the high-speed development of storage technology, the capacity and speed of the hard disk are greatly improved, do you want to use the hard disk space as you need to use it? In fact, the answer is whether you have some special needs, and the method described herein can solve your problem! I hope this article can help you. Reference << Hard Drive Protection Technology Handbook >> People's Posts Publishing House March 1996 << Computer Organization and Design: Hardware / Software Interface >> Machinery Industry Press

[Attachment: 1. Main boot record source; ********************************************* ***********************; * CMOSBOOSM HARDDISK CMOS DATA SELF RELOAD BOOT Program *; * === ============================================================================================================================================================================================================= ================ *; * Tasm cmosboot *; * TLINK CMOSBOOT *; * EXE2BIN CMOSBOOT *; * DEBUG CMOSBOOT.EXE *; * -N cmosboot.bin *; * -rcx *; *: 200 *; * -w cs: 0 *; * -q *; * bintodat cmosboot.bin cmosboot.doc *; * bintocat cmosboot.bin cmosboot.cat *; * *; ************************************************************ *******************************

*********************************************************** ************; * Designer: Howard *; * Creat Date: 08/13/2000 *; * Original Place: wuhan *; * Modification Date: 09/13/2000 *; * Now version: 1.0 *; *************************************************** ****************************************

*********************************************************** *************; * mode history *; * ====================== ====================================================== *; * Version 1.0 1.This Program Is A Master Boot Record. *; * 09/13/2000 2.it Can Reload Cmos Data To The CMOS WHEN Boot The *; * The Machine from Hard Disk Every Time *; * 3.the CMOS Data HAVED backuped to the Hard Disk *; * 0 cylinder, 0 head, 29 syctor. *; * 4.before install this mbr to the hard disk, the cmos *; * data must be haved backuped to the hard disk *; * 5 . Ip, it is from cmos *; * data address 10h to 2fh. *; ***************** *************************************************************** PartLoad EQU 600h; TableBegin EQU 7b eh; partition table address in the memoryBootLoc equ 7c00h; dos boot sector loaded to the addressIDAddr equ 7dfeh; dos boot sector ended flag (55aah) .MODEL tiny .CODE org 0Head: start: cli; disable the interrupt (if = 0) xor AX, AX; AX = 0 MOV SS, AX; SS = AX MOV SP, 7C00H; SP = 7C00H MOV Si, SP; Si =

SP Push AX POP ES; ES = 0 Push AX Pop DS; DS = 0 STI; Enable the Interrupt (if = 1) CLD; Disable The Direction (DF = 0) MOV DI, PartLoad; Di = 600H MOV CX, 100H; CX = 100h (512 bytes = 256 Words) Repne Movsw; Move The Master Boot Record from 0: 7C00 To 0: 600 DB 0EAH; 0EAH IS FAR JUMP CODE, THAT IS JMP FAR PTR ContiUne DW Offset Continue 600H, 0000H; JUMP TO 0: Continue 600h; ***************************************************** ****************************; * The Continue Code Is Read The CMOS Backup Data from Hard Disk Sector. *; * And ReWrite THE DATA TO CMOS. *; ************************************************************ ****************************

Continue: MOV AX, 0201H; AH = 02H, Al = 01H MOV BX, 0800H; BX = 800H, CMOS Data Read TO 0: 800H MOV CX, 001DH; CH = 00H, CL = 1DH (The No.29 Sector) MOV DX, 0080H; DH = 00H (Hard Disk) INT 13H MOV AX, 0010H; Al = 10H CMOS Unit Address MOV CX, 0020H; Write 20H Bytes CMOS Data TO CMOS CLD; Disable The Direction DF = 0WriteCmosdata: OUT 70H, Al; Set The CMOS Data Address Push Ax; The Address Backup To Stack Mov Al, [BX]; Al = [BX] OUT 71H, Al; Write a Byte Data The Address Pop Ax Inc Al; The next byte data loop writecmosdata; loop std; enable the direction df = 1 @ next1: Mov Si, TableBegin; Si = Partition Table Begin Address Mov BL, 4 4 sets partition data findboot: CMP BYTE PTR [Si], 80H; Boot Partition? Je SaveRec; if Yes Tan Jump To SaveRec CMP Byte Ptr [Si], 0; = 0? JNE INVALID; Invalid Partition Add Si, 10h THE NEXT Partition Dec BL; BL-1 JNZ Findboot; Continue Findboot Int 18h; Jump To Rom BasicsAverec: MOV DX, [Si] MOV CX, [Si 2]; Let Boot Partition First Sector To CX MOV BP, Si; BP = Si

********************************; * checked the next partition *; ********** ********************** FINDNEXT: Add Si, 10h Dec Bl JZ SetRead; Jump To setRead CMP Byte Ptr [Si], 0 JE FINDNEXTINVALID: MOV Si , OFFSET ERRMSG1 600h; errmsg address to siprintmsg: Call Printstr; Print The Msgdeadlock: JMP Short Deadlock; Dead LocksetRead: MOV DI, 5; SET Reading Dos Boot Sector 5 Times; ************ *********************************************************** * r r 的 的 的 的 的 的 的 的 的 的 的 的 *; ****************************************************** READBOOT: MOV BX, Bootloc; The Dos Boot Sector Read To 0: 7C00 MOV AX, 201H; AH = 02H, Al = 01H Push Di; Di Pushed to Stack (Backup The Reading Times) INT 13H POP DI JNC GOBOOT ife = 00H INT 13H ;RX = 00h int 13h; reset the driver dec Di; Di-1 Jnz Readboot; Continue Read Boot Sector Mov Si, Offset Errmsg2 600h; Get Errmsg2 Address To Si JMP Short PrintMsg; print the msgGoBoot: mov si, offset ErrMsg3 600h; get errmsg3 address to si mov di, IDAddr; di = boot sector last two bytes cmp word ptr [di], 0AA55h; is a boot sector jne PrintMsg; if not boot Si Point To Bootable Partition DB 0EAH, 00H, 7CH, 00H, 00H; Jump To 0: 7C00H

**********************; * Error Message *; ********************* * Errmsg1 DB 'Invalid Partition Table.', 0ERRMSG2 DB 'Error Loading Operating System.', 0ERRMSG3 DB 'MISSING OPERATING SYSTEM.', 0Printstr: Lodsb; Read a Byte from [Si] CMP AL, 0; Al = 0? JE @Exit; if Yes the jump to @Exit Push Si; Push Si to Stack MOV BX, 7; MOV AH, 0EH; Display The Char INT 10H Pop Si JMP Short PrintStr; Print The next char @ EXIT: RETN TAIL:; The next Master Boot Record Tailfillnum EQU 1beh- (Tail-Head); Count The Fill Number DB Fillnum Dup (0)

*********************************************************** ******************; * The parttition table data *; * notise: you must change the next parttition table data to your *; * OWN HARD Disk Parttition Table Data. * *********************************************************** ***************** PartTable DB 80H, 01H, 01H, 00h, 06H, 3FH, 7FH, 96H, 3FH, 00H DB 00H, 00H, 01H, 0AH, 19H, 00h, 00h, 00h, 3FH DB 0ffh, 0fdh, 40h, 0ah, 19h, 00h, 00h, 0e6h, 25h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00hmagicid DW 0AA55H End START 2. Main boot record installer; ********************************************** ****************************; * Program: The cmboot.exe mbristration loader.and read the cmos data *; * And Saved it to the harddisk hidden sector. *; * ========================================================================================================================================== ========================== == *; * TASM cmboot1.asm *; * TLINK CMBOOTLD *; * ================================== ==================================

*; * Designer: Howard *; * Creat Date: 08/29/2000 *; * Original Place: wuhan *; * Modification Date: 08/29/2000 *; * now version: 1.0 *; * ===== ============================================================================================================================================================================================================= ============= *; * mode History *; * ------------------------------ ------------------------------------- *; * Version: 1.0 1.Backup the Old MBR TO A file. *; * 08/29/2000 2.Load The Backup MBR File and Saved It to the mbr *; * Sector (Cylinder: 0, Head: 0, Sector: 1). *; * 3.saved the cmos Data to Hard Disk Hidden Sector. *; * 4.Load The cmoscheckedmbr the mbr sector. *; * 5.reboot the computer. *; * -------------------------------------------------- --------------- *; * 08/30/2000 6.Modify the PSP and _Data segment misteake. *; * -------------- -------------------------------------------------- --- *; * 09/01/2000 7.Modify Some bug, and Optimize Some INSTRUCTIONS. *; * ------------------------- ----------------------------------------- *; * 09/07/2000 8.Modify the parameter error, ignore the space bet- *;

* WEEN THE PROGRAM name and parameter. *; * 9.Modify the file create pROBLEM, ADD ZERO to the *; * end of filename string. *; **************** *********************************************************** **; * problem: 1.The _Data and PSP segment address is stock a problem. *; * 09/01/2000 use a debug information.maybe the buff office address *; * is not Correct, or the data segment is to too Large. *; * i Haved Used Two Mem Unit to Save The PSP and _Data *; * Segment Address.do Not Use The Stack To Save PSP and *; * Data Segment Address. *; * 2.The File "Creat / Open / read / write "Operating is still *; * a problem. *; * --------------------------------- --------------------------------- *; * Bugs: 1.int 13h AH = 02 / 03H ES: BX Point to the buffer, but *; * mo difying program executing, es = psp segment address, it must *; * 09/01/2000 be make it equarl the real buffer segment address *;. * 2.Push and pop operating must be make sure the *; * operands is correct T t er er er *; ************************************************************************************* ************************************************* Dosseg .Model Small .486 .stack 200h .data; Data (Sector)

By compiling cMosboot.asm, you get cmosboot.bin with DEBUG and convert CMOSBOOT.EXE to Sector DB 0FAH, 33H, 0C0H, 7CH, 0D0H, 0BCH, 00H, 7CH, 8BH, 0BCH, 50H, 07H with bintat.exe. DB 50H, 1FH, 0FBH, 0FCH, 0BFH, 00H, 06H, 0B9H, 00h, 01H, 0F2H, 0A5H DB 0EAH, 1DH, 06H, 00H, 0BBH, 00H, 08H, 0B9H DB 1DH , 00h, 0bah, 80h, 00h, 0cdh, 13h, 0b8h, 10h, 00h, 0b9h, 70h db 00h, 0fch, 0e6h, 70h, 50h, 8ah, 07h, 0e6h, 71h, 58h, 0feh, 0C0H DB 43h, 0e2h , 0f3h, 0fdh, 0beh, 0beh, 07h, 0b3h, 04h, 80h, 3ch, 80h DB 74H, 0EH, 80H, 3CH, 00H, 75H, 1CH, 83H, 0C6H, 10H, 0FEH, 0CBH DB 75H, 0EFH, 0CDH , 18h, 8bh, 14h, 8bh, 4ch, 02h, 8bh, 0eeh, 83h db 0c6h, 10h, 0FEH, 3CBH, 74H, 0DH, 80H, 3CH, 00H, 74H, 0F4H, 0BEH DB 0A1H, 06H, 0E8H, 83H , 00h, 0EBH, 0FEH, 0BFH, 05H, 00h, 0BBH, 00h DB 7ch, 0B8H, 01H, 02H, 57H, 0CDH, 13H, 5FH, 73H, 0CH, 33H, 0C0H DB 0CDH, 13H, 4FH, 75H, 0EDH , 0beh, 0bah, 06h, 0e, 0E0H, 0BEH, 0DAH DB 06H, 0BFH, 0FEH, 7DH, 81H, 3DH, 55H, 0AAH, 75H, 0D4H, 8BH, 0F5H DB 0EAH, 00H, 7CH, 00H, 00h, 49h , 6EH, 76H, 61H, 6CH, 69H, 64H DB 20H, 70H, 61H, 72H, 74H, 69H, 74H, 69H, 61H, 62H, 6CH, 65H, 2EH, 00H, 45H , 72H, 72H, 6FH, 72H, 20H DB 6CH, 6FH, 61H, 64H, 69H, 6 EH, 67H, 20H, 6FH, 70H, 65H, 72H DB 61H, 74H, 69H, 6EH, 67H, 20H, 73H, 79H, 73H, 74H, 65H, 6DH DB 2EH, 00H, 4DH, 69H, 73H, 73H, 69H, 6EH, 67H, 20H, 6FH, 70H DB 65H, 72H, 61H, 74H, 69H, 6EH, 67H, 20H, 74H, 79H, 73H, 74H DB 65H, 6DH, 2EH, 00h, 0A, 3CH, 00H, 74h, 0bh, 56h, 0bbh, 07h db 00h, 0B4H, 0EH, 0CDH, 10H, 5EH, 0EBH, 0F0H, 0C3H, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 00h, 00h, 00h, 00h, 00h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h,

00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 00h, 00h, 00h, 00h, 00h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h DB 00h, 00h, 00h, 06H, 3FH, 7FH, 96H, 3FH, 00H DB 00H, 00h, 01H, 0AH, 19H, 00H, 00h, 41H, 97H, 0FH, 3FH DB 0FFH, 0fdh, 40h, 0ah, 19h, 00h, 00h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h DB 00h, 00h, 00h, 00h, 00h, 00h, 00h db 00h, 00h, 00h, 00h, 00H, 55H, 0AAH RES DW 0072H, 0040H DAT DW 0000H, 0FFFH BUFFER DB 512 DUP ( 0) FileName DB 'HDPT.DAT', 0 parameter DB 2 DUP (?) Copyright DB 0DH, 0AH, 'Jiangbifang, I love you!', '$' Helpmsg DB 0DH, 0AH, '1.cmbootld / c' DB 0DH, 0AH, 'Saved the cmos data to hard disk hidden sector.' DB 0DH, 0AH, '2.cmbootld / w' DB 0DH, 0AH , 'Load and saved it to mbr sector.' DB 0DH, 0AH, '3.cmbootld / s' db 0dh, 0ah, 'saved the mbristration to a file.' DB 0DH, 0AH, '4.cmbootld / l' db 0dh, 0ah, 'load the cmoschecked mbristration to hard disk.' DB 0DH, 0AH, '5.cmbootld / R' DB 0DH, 0AH, 'Reboot The Computer.' DB 0DH, 0AH , '6.cmbootld /?' DB 0DH, 0AH, 'Print The Help Message.', '$' Noparamsg DB 0DH, 0AH, 'PLEASE USE CMBOOTLD /? For Help.', '$'; Debug DB 0DH, 0AH , 'Debug Message.', '$' HDBKOKMSG DB 0DH, 0AH,

'Harddisk Mbr Back Ok.', '$' HDReaderrmsg DB 0DH, 0AH, 'Harddisk Reading Error!', '$' HDWRITEERRMSG DB 0DH, 0AH, 'Harddisk Writing Error!', '$' FileCreaterrmsg DB 0DH, 0AH, ' File Creating Error! ',' $ 'FileOpenerrmsg DB 0DH, 0AH,' File Opening Error! ',' $ 'Filewriteerrmsg DB 0DH, 0AH,' File Writing Error! ',' $ 'FileWriteokmsg DB 0DH, 0AH,' File Writing OK! ',' $ 'filereaderrmsg db 0dh, 0ah,' File reading error! ',' $ 'mbrwriteokmsg db 0dh, 0ah,' The cmoschecked mbr loading ok! ',' $ 'cmossavedtohdokmsg db 0dh, 0ah,' The cmos data haved to harddisk. ',' $ 'mbrbkokmsg db 0dh, 0ah,' The old mbr haved backup to the file hdpt.dat. ',' $ 'cmoscheckedmbrldokmsg db 0dh, 0ah,' The cmoscheckedmbr haved installed ok! ',' $ 'WRONGPARAMSG DB 0DH, 0AH,' THE WRONG Parameter: "',' $ '.codestart: Main Proc Far Assume Cs: _Text, DS: _Data, ES: _DATA, S: Stack MOV CS: PSPSEG, DS; PUSH DS XOR AX, AX MOV AX, _Data MOV CS: Dataseg1, AX MOV DS, AX; DS = _Data MOV ES, AX; INT 13H ES: BX Point To Buffer, ES = SEG _DATA LEA DX, COPYRIGHT CALL DISP1; PUSH DS; POP CX; CX = _DATA; POP DS; DS = PSG MOV DS, CS: PSPSEG; DS = PSP CLD MOV SI, 81H LODSB; Push DS; MOV DS, CX; DS = _Data SEG MOV DS, CS: Dataseg1; DS = _Data CMP Al, 0DH JZ Nopara CMP AL,

'' JZ Judgespace; POP DS; DS = PSpContinue: Push Si Dec Si Mov DS, CS: PSPSEG LODSB; Push DS; MOV DS, CX; DS = _Data MoV DS, CS: Dataseg1; DS = _Data Lea BX, Parameter CMP Al, '/' JZ ScanparaloP; Lea BX, Parameter; Push DS JMP Errorscanparaloop: MOV [BX], Al; Pop DS; DS = PSP MOV DS, CS: PSPSEG LODSB; PUSH DS; MOV DS, CX; DS = _Data Mov DS, CS: Dataseg1; DS = _Data CMP AL, 0DH JZ Choise Inc BX JNB Scanparaloop; Instruction Loop Can NOT USE Rigister CX, Judgespace: MOV DS, CS: PSPSEG LODSB; Call Debug; Set Break Point Cmp Al, 0DH JE Nopara Cmp Al, '' Je Judgespace JNE Continue Nopara: Lea DX, Noparamsg JMP Disp; Call Disp; Call Rettodos

Help: Lea DX, Helpmsg JMP DISP; Call Disp; Call Rettodos

Choise :; Push CX; MOV DS, Dataseg1 Lea Si, Parameter Mov Al, [Si 1] CMP AL, 'S' JZ Savembr CMP AL, 'S' JZ Savembr CMP Al, 'W' JZ Writembr CMP Al, ' W 'JZ Writembr CMP AL,' C 'JZ SavedcmosDataToHD CMP Al,' C 'JZ SavedcmosDataToHD CMP Al,' R 'JZ Reboot Cmp Al,' R 'JZ Reboot Cmp Al,' L 'JZ CMOSCHECKEDMBRLD CMP Al,' L ' JZ CMOSCHECKEDMBRLD CMP AL, '?' JZ Help JMP Error

Savembr :; ----- debug instruction ------; MOV DS, CS: Dataseg1; Lea DX, Debug; Call Disp1; Mov Ah, 07h; Int 21h; CLI; ---------- ----------------------; SUB AX, AX; POP DS; DS = _Data; Push DS; Pop Es; ES = _Data MoV AX, 0201H; MOV BX, OFFSET BUFFER LEA BX, BX, ES: BX = _Data: Buffer, ES = SEG _DATA MOV CX, 0001H MOV DX, 0080H INT 13H; Push BX JB Harddiskreaderr; Mov AX, _Data; MOV DS, AX; Push BX XOR BX, BX MOV DX, OFFSET FileName MOV CX, 0 MOV AH, 3CH INT 21H JC Filecreaterr MOV BX, AX MOV DX, OFFSET BUFFER; POP DX MOV CX, 200H MOV AH, 40H INT 21H JC FileWriteerr Mov AH, 3EH INT 21h jmp filewriteok filecreaterr: lea dx, filecreaterrmsg jmp disp; call disp; call rettodosfilewriteerr: lea dx, filewriteerrmsg; call disp; call rettodos jmp dispharddiskreaderr: lea dx, hdreaderrmsg jmp disp; c All Disp; Call RettodosFileWriteok: Lea DX, FileWriteokmsg JMP DISP; CALL DISP; CALL RETTODOS

Writembr :; POP DS; DS = _Data; Push DS; Pop Es; ES = _Data Lea DX, FileName MoV AX, 3D00H MOV CX, 0 INT 21H JC FileOpenerr Mov BX, AX MOV CX, 200H Lea DX, Buffer Push Dx MOV ah, 3fh int 21h jc filereaderr mov ah, 3eh int 21h pop bx mov ax, 0301h mov cx, 0001h mov dx, 0080h int 13h jb hdwriteerr jnb mbrwriteok; jmp rebootfilereaderr: lea dx, filereaderrmsg jmp disp; call disp; call rettodosfileopenerr: lea dx, fileopenerrmsg jmp disp; call disp; call rettodoshdwriteerr: lea dx, hdwriteerrmsg jmp disp; call disp; call rettodoshdreaderr: lea dx, hdreaderrmsg jmp disp; call disp; call rettodosmbrwriteok: lea dx, mbrwriteokmsg call disp1; jmp reboot call rettodossavedcmosdatatohd :; MOV DS, CS: [Dataseg1]; POP DS; DS = _Data Seg; Push DS; Pop Es; ES = _Data MOV BX, Offset Buffer CLD XOR CX, CX Push CX Pop Ax MOV CX, 70H MOV Al, 10h Push Bx; Mistake Goes Here, IT Must Be Push CldcmosDataReadloop: Out 70h, Al Push Ax in Al, 71H MOV DS: [BX], Al Pop Ax Inc BX Inc Al loop CMOSDataReadloop Std Pop Bx; Lea BX, Buffer Mov AX , 0301H; MOV BX, OFFSET BUFFER MOV CX, 1CH; Modify THE NUMBER MOV DX, 0080H INT 13H JB HDWRITEERR; JB CMOSSAVETOHDOKCMOSSAVETOHDOK: LEA DX, CMOSSAVEDTOHDOKMSG JMP DISP; CALL DISP; CALL RETTODOS

cmoscheckedmbrld: mov ax, 0201h mov bx, offset buffer mov cx, 0001h mov dx, 0080h int 13h jb hdreaderr cld mov si, offset buffer 01beh mov di, offset sector 01beh mov cx, 40h repne movsb; std mov ax, 0301h mov bx, offset buffer mov cx, 19 mov dx, 0080h int 13h jb hdwriteerr lea dx, mbrbkokmsg call disp1 mov ax, 0301h mov bx, offset sector mov cx, 0001h mov dx, 0080h int 13h jb hdwriteerr lea dx, cmoscheckedmbrldokmsg call disp1 JMP Reboot JMP Rettodoserror :; Pop DS; DS = _Data Lea DX, WrongParamsg Call Disp1 MOV AX, 0200H; MOV Si, 81H; Inc Si; Pop DS; DS = PSP MOV DS, CS: PSPSEG; MOV Si, 81H POP Si DEC SIPRNWRONGPARETER: etc ^ DL, DS: [Si]; CMP DL, 0DH; JZ RETDOS; MOV AH, 02H; INT 21H; Inc Si; Loop PrnwrongParameter Lodsb CMP AL, 0DH JZ RETDOS MOV DL, Al; MOV AH, 02H INT 21h; Inc Si loop PRNWRONGPARETER; CALL DISPRETDOS: MOV DL, '"' Int 21h MOV DL, '!' Int 21h JMP Rettodosreboot :; Lea BX, Res Mov Word PTR [BX], 1234H Lea BX, Dat Call Dword PTR [bx] DISP: MOV ah, 09h int 21hrettodos: mov ah, 4ch int 21hmain endpdisp1 proc near mov ah, 09h int 21h retdisp1 endp; rettodos proc near; mov ah, 4ch; int 21h; rettodos endp dataseg1 dw pspseg dw end start3 data conversion program??. / * Convert binary file into assembly language data file format * // * bintodat * .bin * .out * /

转载请注明原文地址:https://www.9cbs.com/read-5995.html

New Post(0)