NT, 2000, XP CDROM boot sector code analysis

xiaoxiao2021-03-06  62

07c0: 0000 facl; disable interruption

07c0: 0001 33C0 XOR AX, AX

07c0: 0003 8ED0 MOV SS, AX; initialization running stack, point SS: SP to run the code

07c0: 0005 BC007C MOV SP, 7C00

07c0: 0008 FB STI; allow interrupt

07c0: 0009 8cc8 MOV AX, CS

07c0: 000B 8ED8 MOV DS, AX; put the DS to the same address as the CS, this operation is more waste, only once

07c0: 000d 52 push dx; boot sector runtime DX save the current boot disk number

The following instructions are used to obtain the load offset address, because the IP is not directly MOV instructions.

Therefore, use a Call instruction to remove IP using the stack.

07c0: 000E E80000 Call 0011; Perform a function call command, thus pressing the address of the next instruction into the stack

07c0: 0011 5E POP Si; take out the address just pressing

07c0: 0012 81EE1100 SUB SI, 0011; Decrease the deflection address to get the actual start offset

07c0: 0016 7412 JE 002A; if the offset is zero jump

Decision is 0000: 7C00 if it is used to use far jumps to translate to 0037

07c0: 0018 81FE007C CMP Si, 7C00; whether the mounting offset is 7C00

07c0: 001c 7575 JNE 0093

07c0: 001e 8cc8 MOV AX, CS; get the load segment address, this sentence is excess, see 0009

07c0: 0020 3D0000 CMP AX, 0000; if the load segment address is 0000

07c0: 0023 757F JNE 00A4

07c0: 0025 EA3700C007 JMP 0037; use far jump instructions to perform address conversion

Decision if the load address is 0000 If it is, it is directly running to 0037

07c0: 002A C606AE0133 MOV BYTE PTR [01AE], 33; Modifying the error code is "3", meaning is the load address error

07c0: 002f 90 NOP

07c0: 0030 8cc8 MOV AX, CS; multiple, same 001e

07c0: 0032 3DC007 CMP AX, 07C0; load segment address is 07c0

07c0: 0035 757E JNE 00B5

The previous section is used to solve the problem of different system loading addresses, the legal address is 0000: 7C00 or 07C0: 0000

If the address is incorrect, the error is handled, and the address is running to 07c0: 0037

07c0: 0037 8cc8 MOV AX, CS; what to take, must be 07c0

07c0: 0039 8ed8 MOV DS, AX; this time is really useful, see 000B

07c0: 003b C606AE0134 MOV BYTE PTR [01AE], 34; Modifying error code is "4", meaning is an illegal guide disk

07c0: 0040 90 NOP

07c0: 0041 80FA80 CMP DL, 80; check if the current boot disk number is less than 80, ie not a hard disk or CDROM

07c0: 0044 726f jb 00b5; if it is the transfer error handling

07c0: 0046 C606AE0135 MOV BYTE PTR [01AE], 35; Modifying the error code is "5", meaning that the sector is illegal or incomplete 07c0: 004B 90 NOP

07c0: 004c BBFE07 MOV BX, 07FE; BX pointing to the guiding sector end sign

07c0: 004F 8B07 MOV AX, [BX]; Take out

07c0: 0051 3D55AA CMP AX, AA55; Whether is AA55

07c0: 0054 755F JNE 00B5; If not, transfer error handling

Load bootfix.bin and run, show "Press any key to boot from CD"

If this file is not skipped

07c0: 0056 5A POP DX; Restore Guidance Disk Number

07c0: 0057 88169904 MOV [0499], DL; save disk number to data area

07c0: 005B 688A04 Push 048a; "Bootfix.bin" file name of the address

07c0: 005e 6A0b push 000b; file name length is 11

07c0: 0060 680020 PUSH 2000; loading start segment address 2000

07c0: 0063 E87603 Call 03DC; call load function

07c0: 0066 0F820F00 jb 0079; if it is not successful, skip directly

07c0: 006A 60 Pusha

07c0: 006b 1e Push DS

07c0: 006c 06 Push ES; save the current run site

07c0: 006D 8A169904 MOV DL, [0499]; Remove the current boot disk number

07c0: 0071 9A00000020 Call 2000: 0000; running the bootfix.bin that has just been loaded

07c0: 0076 07 POP ES

07c0: 0077 1F POP DS

07c0: 0078 61 POPA; Restore run site

Load setupldr.bin and run

07c0: 0079 687E04 PUSH 047E; Address of the "setupldr.bin" file name

07c0: 007c 6A0C PUSH 000c; file name length is 12

07c0: 007e 680020 Push 2000; loading start segment address 2000

07c0: 0081 E85803 CALL 03DC; call load function

07c0: 0084 0F823500 JB 00bd; turn wrong handle if it is not successful

07c0: 0088 8A169904 MOV DL, [0499]; Remove the current boot disk number

07c0: 008c 33c0 xor AX, AX

07c0: 008E 680020 Push 2000

07c0: 0091 50 push ax; manufacturing 2000: 0000 back address in the stack

07c0: 0092 CB RETF; transferred to 2000: 0000 Running the stained setupldr.bin

This is converted by 07c0: 001c

07c0: 0093 56 Push Si

07c0: 0094 8bde MOV BX, Si

07c0: 0096 81C3AE01 ADD BX, 01AE; calculation offset

07C0: 009A C60731 MOV BYTE PTR [BX], 31; Modify the error code is "1", meaning is the boot segment address error

07c0: 009D 81C68A01 Add Si, 018a; "CDBoot: Cannot Boot from CD - CODE:"

07c0: 00a1 EB2A JMP 00cd; display and reboot

07c0: 00A3 90 NOP

Coven this by 07c0: 0023

07c0: 00A4 56 Push Si

07c0: 00A5 8BDE MOV BX, Si

07c0: 00A7 81C3AE01 Add bx, 01ae

07c0: 00Ab C60732 MOV BYTE PTR [BX], 32; Modify the error code is "2", meaning is the boot offset address error

07c0: 00AE 81C68A01 Add Si, 018a; "CDBoot: Cannot Boot from CD - CODE:"

07c0: 00b2 EB19 JMP 00cd; display and reboot

07c0: 00b4 90 NOP

This is converted by 07c0: 0035, 07c0: 0044, 07c0: 0054

07c0: 00b5 6A00 Push 0000

07c0: 00b7 be8a01 MOV SI, 018A; "CDBoot: Cannot Boot from CD - CODE:"

07c0: 00ba EB11 JMP 00cd; display and reboot

07c0: 00bc 90 NOP

Coven this by 07c0: 0084

07c0: 00bd 6a00 push 0000

07c0: 00BF beb201 MOV SI, 01B2; "CDBoot: couldn't Find NTLDR"

07c0: 00c2 EB09 JMP 00cd; display and reboot

07c0: 00c4 90 NOP

Covenant by 07c0: 0367

07c0: 00c5 6A00 push 0000

07c0: 00c7 BED001 MOV SI, 01D0; "CDBoot: Memory Overflow Error"

07c0: 00ca EB01 JMP 00cd; display and reboot

07c0: 00cc 90 NOP

; Display and reboot, the information to be displayed in Si

07c0: 00cd e80400 Call 00d4; display information in Si

07c0: 00d0 5e POP Si; Restore the offset address of the boot sector loaded

07c0: 00d1 EB12 JMP 00E5; start error handling

07c0: 00d3 90 NOP

; Display information functions, entrance:

; Si: information start address, 0 end

07c0: 00d4 ac Lodsb; take a character

07c0: 00d5 0ac0 or Al, Al; whether it ends

07c0: 00D7 0F840900 JE 00E4

07c0: 00db B40E MOV AH, 0E

07C0: 00DD BB0700 MOV BX, 0007

07c0: 00E0 CD10 INT 10; display

07c0: 00E2 EBF0 JMP 00D4

07c0: 00E4 C3 RET

Error handling, this address may vary depending on the loading address, so use Si as the base address for address operation; first delay 0024 times clock interruption, ie 36 * 55 = 1980 ms, about two seconds

07c0: 00E5 C7846B042400 MOV WORD PTR [Si 046B], 0024; Setting the delay counter is 0024

07c0: 00EB FA CLI

07c0: 00ec 06 Push ES

07c0: 00ed 33c0 xor AX, AX

07c0: 00ef 8ec0 MOV ES, AX; ES pointing to the interrupt address table

07c0: 00F1 BB2000 MOV BX, 0020; BX pointing to the offset of interrupt 08

07c0: 00F4 268B07 MOV AX, ES: [BX]

07c0: 00F7 89846704 MOV [Si 0467], AX

07c0: 00fb 268b4702 MOV AX, ES: [BX 02]

07c0: 00ff 89846904 MOV [Si 0469], AX; save the original interrupt 08 address to 0467

07c0: 0103 268937 MOV ES: [BX], Si

07c0: 0106 2681076d01 Add Word PTR ES: [BX], 016D

07c0: 010b 268c4f02 MOV ES: [BX 02], CS; interrupt 08 point 07c0: 016b

07c0: 010f 07 POP ES

07c0: 0110 FB STI

07c0: 0111 83BC6B0400 CMP Word PTR [Si 046B], 0000; Viewing the counter end

07c0: 0116 75F9 JNE 0111

07c0: 0118 Fa CLI

07c0: 0119 06 Push ES

07c0: 011a 33c0 xor AX, AX

07c0: 011c 8ec0 MOV ES, AX

07c0: 011e BB2000 MOV BX, 0020

07c0: 0121 8B846704 MOV AX, [Si 0467]

07c0: 0125 268907 MOV ES: [BX], AX

07c0: 0128 8B846904 MOV AX, [Si 0469]

07c0: 012c 26894702 MOV ES: [BX 02], AX; Restore the address of the interrupt 08 that has just been saved

07c0: 0130 07 POP ES

07c0: 0131 FB STI

Will the boot sector code to 2000: 0000 for loading new guiding sectors at 07c0: 0000

07c0: 0132 1e Push DS

07c0: 0133 06 Push ES

07c0: 0134 B80020 MOV AX, 2000

07c0: 0137 8ec0 MOV ES, AX

07c0: 0139 8cc8 MOV AX, CS

07c0: 013b 8ed8 MOV DS, AX

07c0: 013d 33FF XOR DI, DI

07c0: 013f B90008 MOV CX, 0800

07c0: 0142 F3 REPZ

07c0: 0143 A4 MOVSB

07c0: 0144 07 POP ES

07c0: 0145 1F POP DS

07c0: 0146 EA4B010020 JMP 2000: 014B; transfer to

; In the 07c0: 0000 Loading Hard Disk This segment is executed when the code is executed, it has been moved to 2000: 014B

07c0: 014b 06 Push ES

07c0: 014C B8C007 MOV AX, 07C0

07c0: 014F 8EC0 MOV ES, AX

07c0: 0151 BB0000 MOV BX, 0000

07c0: 0154 B80102 MOV AX, 0201

07c0: 0157 B90100 MOV CX, 0001

07c0: 015A ba8000 MOV DX, 0080

07c0: 015D CD13 INT 13

07c0: 015F 0F830200 JNB 0165

07c0: 0163 EBFE JMP 0163; If the load failed, the dead cycle

07c0: 0165 07 POP ES

07c0: 0166 B280 MOV DL, 80

07c0: 0168 EA007C0000 JMP 0000: 7C00; transfer to hard disk boot sector processing

; New interrupt 08 handler, each interrupt generation will reduce the counter to zero

07c0: 016D 9C Pushf

07c0: 016e facli

07c0: 016f 2E83BC6B0400 CMP Word PTR CS: [Si 046B], 0000; Whether the counter is zero

07c0: 0175 0F840500 JE 017E

07c0: 0179 2EFF8C6B04 DEC WORD PTR CS: [Si 046B]; less than zero

07c0: 017e 9D POPF

07c0: 017f 2effb46904 Push Word PTR CS: [Si 0469]

07c0: 0184 2Effb46704 Push Word PTR CS: [Si 0467]; press the original interrupt address into the stack

07c0: 0189 CB RETF; transfer to the system interrupt handler continues to process

Error prompt information

07c0: 018a db "CDBoot: Cannot Boot from CD - CODE:"

07c0: 01AE DB "0", 0D, 0A, 00; Error code

07c0: 01B2 DB "CDBoot: couldn't Find NTLDR", 0D, 0A, 00

07c0: 01d0 DB "CDBoot: Memory Overflow Error", 0D, 0A, 00

; The following is a function used in the previous code.

; Search for specified strings from the directory just read

The role of this is to find the specified file in the entire directory.

; Consider the minimization offset of far nodes when looking up

And considering the problem of cross-section

; Pure algorithm, there is no logic, so it is more cumbersome, but also boring

If you want to know, you can check the contents of the relevant directory items in ISO9660 to go to a line.

07c0: 01f0 C606B10400 MOV BYTE PTR [04B1], 00;

07c0: 01f5 90 NOP

07c0: 01f6 8B0E9E04 MOV CX, [049E]; Remove the number of characters read

07c0: 01fa FC CLD

07c0: 01fb 33dB xor bx, bx; es: bx point to directory start

07c0: 01fd 33d2 xor DX, DX

07C0: 01FF 8B36AD04 MOV SI, [04AD]; address to search for the address of the string

07c0: 0203 268A17 MOV DL, ES: [BX]; Take the length of the directory

07c0: 0206 80fa00 CMP DL, 00; If the length is zero, skip this item

07c0: 0209 0F843B00 JE 0248

07c0: 020D 8BC3 MOV AX, BX07C0: 020F 052100 Add Ax, 0021; Plus 21H Point to Directory Name

07c0: 0212 8BF8 MOV DI, AX

07c0: 0214 51 PUSH CX

07c0: 0215 33C9 XOR CX, CX

07c0: 0217 8A0EAF04 MOV CL, [04AF]; CX is the string length

07c0: 021b F3 REPZ

07c0: 021c A6 CMPSB; comparison string

07c0: 021D 59 POP CX

07c0: 021e 0f846f00 je 0291; if the same

07c0: 0222 3BD1 CMP DX, CX; Compare Catalog Item Length and Total Length

07c0: 0224 0F833700 JNB 025F; Total length high if not enough

07c0: 0228 2BCA SUB CX, DX; minus the current directory item length from the low length low

07c0: 022A 803EB10401 CMP BYTE PTR [04B1], 01

07c0: 022F 0F841A00 JE 024D

07c0: 0233 03d3 add dx, bx; offset address plus this directory key points to the next directory item

07c0: 0235 8BDA MOV BX, DX

07c0: 0237 83e30f and bx, 000f

07c0: 023A 51 PUSH CX

07c0: 023b B104 MOV CL, 04

07c0: 023D D3EA SHR DX, CL

07c0: 023F 59 POP CX

07c0: 0240 8cc0 MOV AX, ES

07c0: 0242 03C2 Add Ax, DX

07c0: 0244 8ec0 MOV ES, AX; minimize far pointer offset

07c0: 0246 EBB7 JMP 01FF

07c0: 0248 BA0100 MOV DX, 0001; Set length is one, directly enter the next comparison

07c0: 024b EBD5 JMP 0222

07c0: 024D 41 Inc CX

07C0: 024E C606B10400 MOV BYTE PTR [04B1], 00

07c0: 0253 90 NOP

07c0: 0254 EBDD JMP 0233

07c0: 0256 C606B10401 MOV BYTE PTR [04B1], 01

07c0: 025B 90 NOP

07c0: 025c EB29 JMP 0287

07c0: 025e 90 NOP

07c0: 025F 833EA00400 CMP Word PTR [04A0], 0000; Higher Length Higher Length is zero

07c0: 0264 0F850200 JNE 026A; Continue processing if not zero

07c0: 0268 F9 STC; did not find

07c0: 0269 C3 RET

07c0: 026A 832EA00401 SUB WORD PTR [04A0], 0001; High level minus one

07c0: 026F 03DA Add BX, DX; Offset address plus this directory key points to the next directory item

07c0: 0271 53 Push BX

07c0: 0272 51 PUSH CX

07c0: 0273 B104 MOV CL, 04

07c0: 0275 D3EB SHR BX, CL

07c0: 0277 59 POP CX

07c0: 0278 8cc0 MOV AX, ES

07c0: 027A 03C3 Add Ax, BX07C0: 027C 8EC0 MOV ES, AX; Minimize Far Tier Off

07c0: 027e 5B POP BX

07c0: 027f 83e30f and bx, 000f

07c0: 0282 2BD1 SUB DX, CX

07c0: 0284 74D0 JE 0256

07c0: 0286 4A DEC DX

07c0: 0287 B8FFF MOV AX, FFFF

07c0: 028A 2BC2 SUB AX, DX

07c0: 028C 8BC8 MOV CX, AX; get the status of the new total length

07c0: 028e E96EFF JMP 01FF; Continue Find

07c0: 0291 803EB00401 CMP BYTE PTR [04B0], 01; Search is a subdirectory

07c0: 0296 0F840A00 JE 02A4; if it is a subdirectory, rotor directory property check

07c0: 029a 26f6471902 Test Byte PTR ES: [BX 19], 02; View whether the directory property is file

07c0: 029f 7581 JNE 0222; If it is not to look up

07c0: 02A1 EB0A JMP 02AD

07c0: 02A3 90 NOP

07C0: 02A4 26F6471902 TEST BYTE PTR ES: [BX 19], 02; View whether the directory property is a child directory

07c0: 02A9 0F8475FF JE 0222; Continue to find if not

07c0: 02ad A0AF04 MOV Al, [04AF]

07c0: 02B0 26384720 CMP ES: [BX 20], Al; Compare file name length

07c0: 02B4 0F856AFF JNE 0222; Continue to compare

07c0: 02b8 F8 Clc; Clear tag, find success

07c0: 02b9 C3 RET

The following functions use the parameter transmission method of class C

So everyone saw familiar PUSH BP / MOV BP, SP Directive

But obviously the author is not familiar with the senior language function stack organization.

The MOV Sp, BP, which ends the function ends, also caught it.

This instruction is a high-level language to release automatic local variables.

And several functions here, do not use local variables at all

In fact, if you use local variables, the few functions here will look better.

I refer to it seems to be comparable to the disassembly code of C.

;Ha ha

Read the specified sector to memory, read and write using expanded disk

In view of the limitations of 64K data segments under DOS, the read operation is performed.

07c0: 02ba 55 push bp

07c0: 02bb 8bec MOV BP, SP

07c0: 02BD 53 Push BX

07c0: 02Be 56 Push Si

07c0: 02BF 52 Push DX

07c0: 02c0 50 push ax; save register

07c0: 02C1 BB6D04 MOV BX, 046D; BX pointing to extended disk reading structure

07c0: 02c4 C60710 MOV BYTE PTR [BX], 10

07c0: 02c7 C6470100 MOV BYTE PTR [BX 01], 00

07c0: 02cb C6470300 MOV BYTE PTR [BX 03], 00

07c0: 02cf C747040000 MOV Word PTR [BX 04], 0000

07c0: 02d4 C7470C0000 MOV WORD PTR [BX 0C], 0000

07c0: 02d9 C7470E0000 MOV WORD PTR [BX 0e], 0000; all clear; copy the call parameters to the temporary data area

07c0: 02de 8b460c MOV AX, [BP 0C]

07c0: 02e1 A3A204 MOV [04A2], AX

07c0: 02E4 8B460A MOV AX, [BP 0A]

07c0: 02E7 A3A404 MOV [04A4], AX; the number of readings, 32 bits, divided into two processing

07c0: 02EA 8B4608 MOV AX, [BP 08]

07c0: 02ed A3A604 MOV [04A6], AX; segment address of the data area

07c0: 02F0 8B4606 MOV AX, [BP 06]

07c0: 02f3 A3A804 MOV [04A8], AX

07c0: 02F6 8B4604 MOV AX, [BP 04]

07c0: 02f9 A3AA04 MOV [04AA], AX; start logic sector number, 32-bit

The parameters that will be transferred during the call are saved in the data area for use.

In fact, it is not necessary, since the parameter passing of class C,

Then you can use these real parameters directly.

07c0: 02FC 813EA4040000 CMP Word PTR [04A4], 0000

07c0: 0302 0F851900 JNE 031F

07c0: 0306 813EA2042000 CMP Word PTR [04A2], 0020

07c0: 030C 0F8F0F00 JG 031F; the total number of sectors is less than 20

Ensure that the amount of data per read is not more than 64K.

If the total number of sectors is less than 20h, that is, 20H * 800h = 10000h, it is exactly the size of 64K a data segment.

Attention, the sector of the CDROM is treated here, so the sector size is 800h, 2048 bytes.

07c0: 0310 C6067D0400 MOV BYTE PTR [047D], 00; Clear tag indicates no segment processing

07c0: 0315 90 NOP

07c0: 0316 A1A204 MOV AX, Word PTR [04A2]

07c0: 0319 A2AC04 MOV BYTE PTR [04ac], Al; Direct reading total sector number

07c0: 031c EB0D JMP 032B

07c0: 031e 90 NOP

07c0: 031F C6067D0401 MOV BYTE PTR [047D], 01; Set marker mark requirements segment processing

07c0: 0324 90 NOP

07c0: 0325 C606AC0420 MOV BYTE PTR [04ac], 20; 20 sectors of each fixed reading, 64K data

07c0: 032A 90 NOP

07c0: 032b A0AC04 MOV Al, [04ac]

07c0: 032e 884702 MOV [BX 02], Al; sector number

07c0: 0331 A1A604 MOV AX, [04A6]

07c0: 0334 894706 MOV [BX 06], AX; segment address of the data area

07c0: 0337 A1A804 MOV AX, [04A8]

07c0: 033A 894708 MOV [BX 08], AX

07c0: 033D A1AA04 MOV AX, [04AA]

07c0: 0340 89470A MOV [BX 0A], AX; start logic fan code

07c0: 0343 BE6D04 MOV SI, 046D

07c0: 0346 B442 MOV AH, 42

07c0: 0348 8A169904 MOV DL, [0499]; Remove the guide disk number 07c0: 034C CD13 INT 13; operation

07c0: 034e 803E7D0401 CMP BYTE PTR [047D], 01; Do you need to read?

07c0: 0353 0F852200 JNE 0379

07c0: 0357 832EA20420 Sub Word PTR [04A2], 0020

07c0: 035c 831EA40400 SBB Word PTR [04A4], 0000; total sector number is reduced 20

07c0: 0361 8106A6040010 Add Word PTR [04A6], 1000; Data segment address is minus 1000, pointing to the next 64K.

07c0: 0367 0F825AFD JB 00c5; if overflows turn wrong

07c0: 036B 8106A8042000 Add Word PTR [04A8], 0020

07c0: 0371 8116AA040000 ADC Word PTR [04AA], 0000; Start Logic Sector Code plus 20

07c0: 0377 EB83 JMP 02FC; start next cycle reading

07c0: 0379 58 POP AX; Restore Register

07c0: 037A 5A POP DX

07c0: 037B 5E Pop Si

07c0: 037C 5B POP BX

07c0: 037D 8BE5 MOV SP, BP

07c0: 037F 5D POP BP

07c0: 0380 C3 RET

; Start reading the specified byte number to memory from the specified sector

; Call 02BA to complete the reading

07c0: 0381 55 Push BP

07c0: 0382 8bec MOV BP, SP

07c0: 0384 51 PUSH CX

07c0: 0385 53 Push BX

07c0: 0386 50 Push AX

; Convert the number of bytes to the number of logical sectors, less than one sector calculates according to one sector

07c0: 0387 B10B MOV CL, 0B

07c0: 0389 8B1EA004 MOV BX, [04a0]

07c0: 038D A19E04 MOV AX, [049E]

07c0: 0390 0FADD8 SHRD AX, BX, CL

07c0: 0393 D3EB SHR BX, CL; shifts BX: AX to right, 1148

07c0: 0395 F7069E04FF07 TEST WORD PTR [049E], 07FF; Whether the low position is zero

07c0: 039b 7406 JE 03A3

07c0: 039d 050100 Add Ax, 0001

07c0: 03A0 83D300 ADC BX, 0000; not add one

07c0: 03A3 50 Push AX

07c0: 03a4 53 push bx; total sector number

07c0: 03A5 FF7604 PUSH WORD PTR [BP 04]; Segment Address

07c0: 03A8 FF369A04 Push Word PTR [049A]

07c0: 03ac FF369C04 Push Word PTR [049C]; Start Logic Sector Number

07c0: 03B0 E807FF Call 02ba; reading sector

07c0: 03B3 83C40A Add SP, 000A

07c0: 03B6 58 POP AX; recovery register

07c0: 03B7 5B POP BX

07C0: 03B8 59 POP CX07C0: 03B9 8BE5 MOV SP, BP

07c0: 03bb 5D POP BP

07c0: 03bc C3 RET

Remove the start sector and bytes of the directory item

07c0: 03bd 50 Push AX

07c0: 03Be 268B4702 MOV AX, ES: [BX 02]

07c0: 03c2 A39A04 MOV [049A], AX

07c0: 03c5 268B4704 MOV AX, ES: [BX 04]

07c0: 03c9 A39C04 MOV [049C], AX; Start Logic Sector Code

07c0: 03cc 268B470A MOV AX, ES: [BX 0A]

07c0: 03d0 A39E04 MOV [049E], AX

07c0: 03d3 268B470C MOV AX, ES: [BX 0C]

07c0: 03d7 A3A004 MOV [04A0], AX; bytes

07c0: 03Da 58 POP AX

07c0: 03dB C3 RET

Load functions, entrances: File name address, file name length, load segment address

07c0: 03DC 55 Push BP

07c0: 03DD 8BEC MOV BP, SP

Read CDROM Guidance Information

07c0: 03DF 6A01 Push 0001

07c0: 03e1 6A00 PUSH 0000; total sector number 00000001

07c0: 03e3 680010 Push 1000; Segment Address 1000

07c0: 03e6 6a10 push 0010

07c0: 03e8 6A00 PUSH 0000; Start Logic Sector No. 00000010

07c0: 03EA E8CDFE CALL 02BA; reading sector

07c0: 03ed 83c40a Add SP, 000A

Remove the root directory information

07c0: 03F0 B80010 MOV AX, 1000

07c0: 03f3 8ec0 MOV ES, AX

07c0: 03F5 26A19E00 MOV AX, ES: [009E]

07c0: 03F9 A39A04 MOV [049A], AX

07c0: 03FC 26A1A000 MOV AX, ES: [00A0]

07c0: 0400 A39C04 MOV [049c], AX; start logic fan code number

07c0: 0403 26A1A600 MOV AX, ES: [00A6]

07c0: 0407 A39E04 MOV [049E], AX

07c0: 040A 26A1A800 MOV AX, ES: [00A8]

07c0: 040e A3A004 MOV [04A0], AX; reading byte

07c0: 0411 680010 Push 1000; Segment Address 1000

07c0: 0414 E86AFF CALL 0381; read data

07c0: 0417 83C402 Add SP, 0002

Search "i386" in the root directory

07c0: 041a C706AD049504 MOV Word PTR [04AD], 0495; "I386" address

07c0: 0420 C606AF0404 MOV BYTE PTR [04AF], 04; Length 4

07c0: 0425 90 NOP

07c0: 0426 C606B00401 MOV BYTE PTR [04B0], 01; Place the item mark, check if it is a child directory

07C0: 042B 90 NOP07C0: 042C E8C1FD Call 01f0; start search

07c0: 042f 7234 JB 0465; if not found

; Read the "i386" directory found

07c0: 0431 E889FF Call 03BD; Remove the starting sector and bytes

07c0: 0434 680010 Push 1000

07c0: 0437 E847FF CALL 0381; Reading Demo

07c0: 043A 83C402 Add SP, 0002

The specified file when the call function is searched in I386.

07c0: 043d B80010 MOV AX, 1000

07c0: 0440 8ec0 MOV ES, AX

07c0: 0442 8B4608 MOV AX, [BP 08]

07c0: 0445 A3AD04 MOV [04AD], AX; file name address

07c0: 0448 8A4606 MOV Al, [BP 06]

07c0: 044b A2AF04 MOV BYTE PTR [04AF], AL; file name length

07c0: 044e C606B00400 MOV BYTE PTR [04B0], 00; Place the catalog item mark, check if it is a file

07c0: 0453 90 NOP

07c0: 0454 E899FD Call 01f0; start search

07c0: 0457 720c jb 0465; if not found

; Read the specified file found

07c0: 0459 E861FF CALL 03BD; Remove the starting sector and bytes

07c0: 045c FF7604 Push Word PTR [BP 04]

07c0: 045f E81FFF CALL 0381; Reading Demo

07c0: 0462 83C402 Add SP, 0002

07c0: 0465 5D POP BP

07c0: 0466 C3 RET

; End of the code, start the data area

07c0: 0467 DW 0000, 00000; Save the original address of the interrupt 08

07c0: 046b DW 0000; Delay counter

Where the disk extension reading structure is stored here

07c0: 046d db 00; structure size

07c0: 046e db 00;

07c0: 046f db 00; number of sectors to be read

07c0: 0470 db 00;

07c0: 0471 DW 0000, 0000; read data target address

07c0: 0475 DD 00; Start logic sector

07c0: 047a dw 0000; reserved

07c0: 047d dw 0000; section processing mark, zero no need to process

07c0: 047E DB "setupldr.bin"

07c0: 048a db "bootfix.bin"

07c0: 0495 DB "i386"

07c0: 0499 dB 0000; disk number

07c0: 049a dw 0000

07c0: 049c dw 0000; start logic fan area number

07c0: 049e dw 0000

07c0: 04A0 DW 0000; read the number of bytes; the temporary data of the read disk operation is stored here

07c0: 04A2 DW 0000, 0000; total sector number

07c0: 04A6 DW 0000; section address of the data area

07c0: 04A8 DW 0000, 0000; start logical sector number

07c0: 04ac dw 0000; number of sectors

07c0: 04ad DW 0000; Search String Address

07c0: 04AF DW 0000; length

07c0: 04b0 db 00; Directory Items, 1 represented the lookup subdirectory

07c0: 04b1 db 00

07c0: 07fe DB 55, AA

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

New Post(0)