source: trunk/AIR-BOOT/SOURCE/REGULAR/PARTSCAN.ASM@ 16

Last change on this file since 16 was 8, checked in by kiewitz, 23 years ago

Added AiR-BOOT Images and support for other languages.
Note: This comment was created after rebuilding the repo. [2011-07]

File size: 24.7 KB
Line 
1
2; Disclaimer:
3;=============
4; The sourcecode is released via www.netlabs.org CVS *ONLY*.
5; You MUST NOT upload it to other servers nor republish it in any way.
6; The sourcecode is still COPYRIGHTED and NOT YET RELEASED UNDER GPL.
7; It's (c) Copyright 1998-2002 by Martin Kiewitz.
8; You may recompile the source and do *PRIVATE* modifications, but please keep
9; in mind that modifying this code needs at least *some* assembly skill. If
10; you mess up your system, because you needed to hack your way through, don't
11; blame me. Releasing a customized version of AiR-BOOT, selling it in any form
12; or reusing parts of this source is *PROHIBITED*. Ask me, if you have some
13; idea about new functionality *before* developing the code, otherwise I will
14; definitely reject it. Also please accept, that I have some basic design
15; rules on AiR-BOOT and I will maintain them at all costs, so this won't get
16; another GRUB.
17
18;---------------------------------------------------------------------------
19; AiR-BOOT / PARTiTiON SCANNING
20;---------------------------------------------------------------------------
21
22; Note: This is complex code. Also some of this functions have DS != CS, so
23; make sure that you know what you are doing in here.
24
25PARTSCAN_ScanForPartitions Proc Near Uses
26 ; Reset X-Reference
27 call PARTSCAN_ResetXref
28
29 push ds si
30 push 0040h
31 pop ds
32 mov si, 0075h
33 mov dh, ds:[si] ; 40:75 -> POST: Total Harddiscs == DL
34 pop si ds
35 mov TotalHarddiscs, dh
36 xor al, al
37 mov NewPartitions, al
38
39 mov dl, 80h ; is first harddisc
40 PSSFP_HarddiscLoop:
41 push dx
42 call PARTSCAN_ScanDriveForPartitions
43 pop dx
44 inc dl
45 dec dh
46 jnz PSSFP_HarddiscLoop
47
48 ; Use X-Reference to sync NewPartitionTable with Hide-Config
49 call PARTSCAN_SyncHideConfigWithXref
50
51 ; Now we copy the new IPT over the old one...
52 mov si, offset NewPartTable
53 mov di, offset PartitionTable
54 movzx ax, NewPartitions
55 mov CFG_Partitions, al
56 mov bl, LocIPT_LenOfIPT
57 mul bl
58 mov cx, ax
59 rep movsb
60
61 ; and the New Logical Drive Letter table as well...
62 mov si, offset NewDriveLetters
63 mov di, offset DriveLetters
64 mov cx, LocIPT_MaxPartitions/2
65 rep movsw
66
67 ; Search for any Linux partition and remember, if it got found...
68 mov si, offset PartitionTable
69 movzx cx, CFG_Partitions
70 xor dl, dl ; DL - Is Linux here ?
71 or cx, cx
72 jz PSSFP_NoPartitions
73 PSSFP_LinuxLoop:
74 cmp bptr [si+LocIPT_SystemID], 083h ; Hard-Coded
75 jne PSSFP_NoLinux
76 mov dl, 1 ; Linux found...
77 PSSFP_NoLinux:
78 add si, LocIPT_LenOfIPT
79 loop PSSFP_LinuxLoop
80 PSSFP_NoPartitions:
81 mov GotLinux, dl ; Set Flag
82
83 ; ...and finally check, if we need to set a Drive-Letter
84 mov dl, AutoDrvLetter
85 or dl, dl
86 jz PSSFP_NoAutoDriveLetter
87 movzx cx, CFG_Partitions
88 or cx, cx
89 jz PSSFP_NoAutoDriveLetter
90 mov si, offset PartitionTable
91 mov di, offset DriveLetters
92 mov ax, wptr [AutoDrvLetterSerial]
93 mov bx, wptr [AutoDrvLetterSerial+2]
94 PSSFP_AutoDrvLetterLoop:
95 cmp ax, [si+LocIPT_Serial]
96 jne PSSFP_AutoDrvLetterNoMatch
97 cmp bx, [si+LocIPT_Serial+2]
98 jne PSSFP_AutoDrvLetterNoMatch
99 ; We got a match, so set Drive-Letter in DL
100 or bptr [si+LocIPT_Flags], Flags_DriveLetter
101 mov [di], dl
102 PSSFP_AutoDrvLetterNoMatch:
103 add si, LocIPT_LenOfIPT
104 inc di
105 loop PSSFP_AutoDrvLetterLoop
106 mov AutoDrvLetter, 0 ; Disable after processing...
107 PSSFP_NoAutoDriveLetter:
108 ret
109PARTSCAN_ScanForPartitions EndP
110
111; Scannt die Festplatte auf jegliche Partitionstabellen...
112; Falls eine fehlerhafte Partition gefunden wird, wird abgebrochen.
113; falls eine Extended Partition (DOS) gefunden wird, wird erneut gescannt.
114PARTSCAN_ScanDriveForPartitions Proc Near Uses
115 xor ax, ax
116 xor bx, bx ; Location Absoluter Sektor 0
117 mov cx, 0001h
118 xor dh, dh ; Location Zylinder 0, Side 0, Sektor 1 MBR
119 mov [ExtendedAbsPosSet], al
120 mov wptr [ExtendedAbsPos+0], ax
121 mov wptr [ExtendedAbsPos+2], ax
122 PSSDFP_LoadThisPartition:
123 call DriveIO_LoadPartition
124 jc PSSDFP_InvalidPartition
125 call PARTSCAN_ScanPartition
126 IFDEF ReleaseCode
127 call DriveIO_SavePartition
128 ENDIF
129 call PARTSCAN_ScanPartitionForExtended
130 jc PSSDFP_LoadThisPartition
131 PSSDFP_InvalidPartition:
132 ret
133PARTSCAN_ScanDriveForPartitions EndP
134
135; The following routines have NOT *DS* set to CS, so we must address via ES
136PARTSCAN_ScanPartition Proc Near Uses ax ds si
137 push ExecBaseSeg
138 pop ds
139 mov si, ExecBasePtr
140 add si, 446 ; DS:SI - First Partition-Entry
141 PSSP_ScanLoop:
142 mov al, bptr ds:[si+LocBRPT_SystemID]
143 cmp al, 5 ; Is Partition EXTENDED ?
144 je PSSP_IgnorePartition
145 cmp al, 0Fh ; Is Partition EXTENDED (M$-DOS7) ?
146 je PSSP_IgnorePartition
147 cmp al, 0 ; Is Partition EMPTY ?
148 je PSSP_IgnorePartition
149 ; Ignore this Partitions, because there are no real Partitions
150 call PARTSCAN_CheckThisPartition
151 PSSP_IgnorePartition:
152 ; L”scht das Boot-Able Flag...
153 and byte ptr ds:[si+LocBRPT_Flags], 7Fh ; Reset the Active-Flag
154 add si, LocBRPT_LenOfEntry ; 16 Bytes per partition entry
155 cmp si, 500+ExecBasePtr
156 jb PSSP_ScanLoop
157 ; If we are on first HDD and in primary partition table -> mark primary
158 cmp bptr es:[CurPartition_Location+4], 80h ; Drive
159 jne PSSP_NoMarkPrimary
160 cmp wptr es:[CurPartition_Location+0], 0
161 jne PSSP_NoMarkPrimary
162 cmp wptr es:[CurPartition_Location+2], 0 ; Absolute Location
163 jne PSSP_NoMarkPrimary
164 call PART_MarkFirstGoodPrimary
165 PSSP_NoMarkPrimary:
166 ret
167PARTSCAN_ScanPartition EndP
168
169MBR_NoName_Patched db 15 dup (0)
170
171; Will insert this partition into NewPartTable and compare it to our "old"
172; LocIPT-table. If the same partition is found there, Flags&CRC are taken from
173; the old table, otherwise they are generated freshly.
174; Will also fill out PartitionXref to sync HideConfig later
175; In: DS:SI - Partition-Entry (16-Bytes)
176; ES - is CS
177; (DS is *NOT* CS here)
178PARTSCAN_CheckThisPartition Proc Near Uses di ds si
179 local PartSystemID:byte, PartTypeFlags:byte
180 local PartCRC:word, PartPtr:dword
181
182 mov ax, ds
183 mov wptr [PartPtr+2], ax ; ...
184 mov wptr [PartPtr+0], si ; Save Pointer to PartitionEntry
185
186 mov al, bptr ds:[si+LocBRPT_SystemID]
187 mov PartSystemID, al
188
189 mov cx, wptr ds:[si+LocBRPT_BeginSector] ; Cylinder/Sector
190 mov dh, bptr ds:[si+LocBRPT_BeginHead] ; Head
191 mov dl, bptr es:[CurPartition_Location+4] ; Drive
192 mov ax, wptr ds:[si+LocBRPT_RelativeBegin] ; Absolute Sector
193 mov bx, wptr ds:[si+LocBRPT_RelativeBegin+2]
194 add ax, wptr es:[CurPartition_Location+0] ; +Partition-Absolute
195 adc bx, wptr es:[CurPartition_Location+2] ; sectors
196 call DriveIO_LoadTmpSector ; Loads Boot record
197 ; Sets up DS:SI - TmpSector
198
199 push si
200 mov bx, 4B4Dh ; Magic 'MK' :)
201 call MBR_GetCheckOfSector
202 mov PartCRC, bx ; Save Partition's-CRC
203
204 ; ------------------------------ Gets internal infos of partition type
205 mov al, PartSystemID
206 call PART_SearchFileSysName
207 ; Replies AH - FileSysFlags, AL - UnhiddenID, SI - FileSystemNamePtr
208 mov di, si
209 mov PartTypeFlags, ah
210 mov PartSystemID, al ; Use Unhidden-ID
211 pop si
212
213 ;================================
214 ; AL - File System ID (Unhidden)
215 ; AH - File System Flags
216 ; SI - Boot-Record of Partition
217 ; DI - File System Name
218 ; DS==CS here
219 ;================================
220
221 test ah, FileSysFlags_NoName ; No-Name-Flag ? -> No Partition Name
222 jnz PCCTP_ThereIsNoName ; available
223 test ah, FileSysFlags_FAT32 ; FAT32 specific name getting ?
224 jz PCCTP_ResumeNormal
225 add si, 1Ch ; Fix for FAT 32, shiat
226 PCCTP_ResumeNormal:
227 add si, 2Bh ; DS:SI - Partition-Name
228 mov cx, 11 ; 11 bytes length
229 call PART_CheckForValidPartName
230 jnc PCCTP_SetNameToNoName
231 sub si, 4 ; DS:SI -> Serial&Name (15-Bytes)
232 xor ah, ah ; no Flags_NoPartName
233 jmp PCCTP_NameSearchInIPT
234
235 PCCTP_SetNameToNoName:
236 cmp PartSystemID, 07h ; We got HPFS that failed ?
237 jne PCCTP_NotHPFS ; -> is NTFS (internal type 08h)
238 inc PartSystemID ; All that fails is Microsoft <bg>
239 PCCTP_NotHPFS:
240 jmp PCCTP_ThereIsNoName
241
242 ;=======================================================
243 ; NAME SEARCH in IPT-Table
244 ; DS:SI - Serial&Name of Current Partition (15-Bytes)
245 ; AH - NoPartName-Flag (!MUST! be merged with Flags)
246 ;=======================================================
247 PCCTP_NameSearchInIPT:
248 xor ah, ah ; no Flags_NoPartName cause PartName valid
249 mov di, offset PartitionTable ; ES:DI - IPT-Start
250 mov dl, es:CFG_Partitions
251 or dl, dl
252 jz PCCTP_NameCompFailed
253 PCCTP_SerialNameCompLoop:
254 mov al, es:[di+LocIPT_Flags]
255 test al, Flags_NowFound
256 jnz PCCTP_SerialNameAlreadyFound
257 ; Now compare IPT with current Partition
258 mov cx, 15 ; Serial&Name (15-Bytes)
259 push si di
260 repz cmpsb
261 pop di si
262 je PCCTP_Match
263 PCCTP_SerialNameAlreadyFound:
264 add di, LocIPT_LenOfIPT
265 dec dl
266 jnz PCCTP_SerialNameCompLoop
267
268 ; if we didn't find Serial&Name, let's try Name-only without Serial
269 mov di, offset PartitionTable ; ES:DI - IPT-Start
270 mov dl, CFG_Partitions
271 PCCTP_NameCompLoop:
272 mov al, es:[di+LocIPT_Flags]
273 test al, Flags_NowFound
274 jnz PCCTP_NameAlreadyFound
275 ; Now compare IPT with current Partition
276 mov cx, 11 ; Name only (11-Bytes)
277 push si di
278 add si, 4
279 add di, 4 ; Skip over Serial-Field
280 repz cmpsb
281 pop di si
282 jne PCCTP_NameNoMatch
283 mov cx, ds:[si+0] ; Get Serial
284 mov es:[di+0], cx
285 mov cx, ds:[si+2]
286 mov es:[di+2], cx ; ...and put it into IPT
287 jmp PCCTP_Match
288 PCCTP_NameNoMatch:
289 PCCTP_NameAlreadyFound:
290 add di, LocIPT_LenOfIPT
291 dec dl
292 jnz PCCTP_NameCompLoop
293 PCCTP_NameCompFailed:
294 jmp PCCTP_CompareFailed
295
296 PCCTP_ThereIsNoName:
297 ; First, try to find this partition by comparing location and PartitionID
298 ; aka LocIPT_AbsoluteBegin:dword and LocIPT_SystemID
299 ; If found, simply go to the normal match-routine, otherwise use the
300 ; File-System-Name to build the Volume-Label for the New IPT Entry.
301 mov dh, PartSystemID
302 push ds
303 lds si, dptr PartPtr ; DS:SI - Cur Partition Entry
304 ; Relative Sector to MBR/EPR
305 mov cx, wptr ds:[si+LocBRPT_RelativeBegin]
306 mov bx, wptr ds:[si+LocBRPT_RelativeBegin+2]
307 add cx, cs:[CurPartition_Location+0]
308 add bx, cs:[CurPartition_Location+2]
309 ; BX:CX - Absolute First Sector of Partition on HDD
310 pop ds
311 ; Build a standard-Volume Label from FileSystemNamePtr
312 ; We have to call SearchFileSysName again because of NTFS
313 push ax cx
314 mov al, dh
315 call PART_SearchFileSysName ; We want SI here <- FileSystemNamePtr
316 mov di, offset MBR_NoName_Patched
317 add di, 4 ; Skip Serial-Field
318 mov cx, 8
319 rep movsb ; Copy FileSystemName to Temp Space
320 mov si, offset MBR_NoName_Patched
321 pop cx ax
322 ;=======================================================
323 ; LOCATION SEARCH in IPT-Table
324 ; DH - PartitionID of Current Partition
325 ; BX:CX - AbsoluteBegin of Current Partition
326 ; AH - NoPartName-Flag (!MUST! be merged with Flags)
327 ; DS:SI - Serial&Name of Current Partition (15-Bytes)
328 ;=======================================================
329 PCCTP_LocSearchInIPT:
330 mov ah, Flags_NoPartName ;set Flags_NoPartName, PartName invalid
331 mov di, offset PartitionTable ; ES:DI - IPT-Start
332 mov dl, es:CFG_Partitions
333 or dl, dl
334 jz PCCTP_LocCompFailed
335 PCCTP_LocCompLoop:
336 mov al, es:[di+LocIPT_Flags]
337 test al, Flags_NowFound
338 jnz PCCTP_LocAlreadyFound
339 ; Now compare IPT with current Partition
340 cmp dh, es:[di+LocIPT_SystemID]
341 jne PCCTP_LocMismatch
342 cmp cx, es:[di+LocIPT_AbsoluteBegin]
343 jne PCCTP_LocMismatch
344 cmp bx, es:[di+LocIPT_AbsoluteBegin+2]
345 jne PCCTP_LocMismatch
346 jmp PCCTP_Match
347 PCCTP_LocMismatch:
348 PCCTP_LocAlreadyFound:
349 add di, LocIPT_LenOfIPT
350 dec dl
351 jnz PCCTP_LocCompLoop
352 PCCTP_LocCompFailed:
353 jmp PCCTP_CompareFailed
354
355 ; ==================================
356 ; =MATCH=, found partition in IPT...
357 ; AH - NoPartName-Flag (!MUST! be merged with Flags)
358 ; DL - IPT Partition Number from Loop (inverted)
359 ; ES:DI - LocIPT-Pointer to found IPT-entry
360 ; ==================================
361 PCCTP_Match:
362 mov ch, ah
363 ; Save the new location of this partition in the Xref-Table
364 ; for converting HideConfig.
365 mov dh, dl
366 mov dl, es:CFG_Partitions
367 sub dl, dh
368 mov dh, NewPartitions ; is actually a counter
369 call PARTSCAN_DefXref ; DL-IPT-Partition, DH-NewPartition
370
371 ; Get Saved-Flags...
372 mov cl, byte ptr es:[di+LocIPT_Flags] ; Use saved Flags
373
374 ; ...and Saved-CRC if available...
375 mov ax, wptr es:[di+LocIPT_BootRecordCRC]
376 or ax, ax
377 jz PCCTP_UseNewComputedCRC
378 mov PartCRC, ax ; Use saved IPT-CRC
379 PCCTP_UseNewComputedCRC:
380 ; ...and mark partition in IPT as already found
381 or byte ptr es:[di+LocIPT_Flags], Flags_NowFound
382 ; ...get Serial&Name from IPT-table...
383 mov si, di
384 add si, LocIPT_Serial ; DS:SI - LocIPT-Serial&Name
385 jmp PCCTP_AddToNew
386
387 ; =================================
388 ; =FAILED= search, not found in IPT
389 ; AH - NoPartName-Flag (!MUST! be merged with Flags)
390 ; DS:SI - Serial&Name of Current Partition (15-Bytes)
391 ; =================================
392 PCCTP_CompareFailed:
393 mov ch, ah
394 ; Default Flags hinzufgen...
395 mov cl, LocIPT_DefaultFlags
396
397 mov al, PartTypeFlags
398 ; May I auto-add partitions ?
399 test es:CFG_PartitionsDetect, 1
400 jz PCCTP_MayNotAddAny ; add, but non-bootable
401 test al, FileSysFlags_BootAble ; AH kam von SearchFileSysName
402 jnz PCCTP_PerhapsBootAble
403 PCCTP_MayNotAddAny:
404 mov cl, LocIPT_DefaultNonBootFlags
405 PCCTP_PerhapsBootAble:
406
407 ; On FAT32-partitions, default to P-Flag (which means using M$-hack)
408 ; Anyway, this hack has to be globaly activated by the user manually...
409 cmp PartSystemID, 09h ; Hardcoded: FAT32
410 je PCCTP_NeedsExtMShack
411 cmp PartSystemID, 0Bh
412 je PCCTP_NeedsExtMShack
413 cmp PartSystemID, 0Ch
414 je PCCTP_NeedsExtMShack
415 cmp PartSystemID, 0Eh ; FAT16 above 8 GB
416 jne PCCTP_NoExtMShack
417 ; We only get here, when the SystemID seems to be an M$ "invention"...
418 PCCTP_NeedsExtMShack:
419 or cl, Flags_ExtPartMShack
420 PCCTP_NoExtMShack:
421
422 ;================================================
423 ; CL - IPT-Partition-Flags, CH - NoPartName-Flag
424 ; DS:SI - PartSerial&Name (15-Bytes)
425 ;================================================
426 PCCTP_AddToNew:
427 mov al, Flags_NoPartName ; Unset NoPartName
428 not al
429 and cl, al
430 or cl, ch ; CL = Both CL and CH merged
431
432 ; Calculate Pointer to IPT
433 mov di, offset NewPartTable ; ES:DI - NewPartTable
434 movzx ax, es:NewPartitions
435 mov bl, LocIPT_LenOfIPT
436 mul bl
437 add di, ax ; ES:DI - Last+1 Entry of NewPartTable
438
439 ; Now finally write this partition to our IPT
440 ;=============================================
441 push cx
442 mov cx, 15 ; Copy Serial&Name...
443 rep movsb
444 pop cx
445
446 lds si, dptr PartPtr ; DS:SI - Cur Partition Entry
447 mov al, bptr es:[CurPartition_Location+4] ; Drive
448 stosb
449 mov al, PartSystemID ; Unhidden SystemID
450 stosb
451 mov al, cl ; Partition-Flags from register...
452 stosb
453 mov ax, PartCRC ; BootRecordCRC...
454 stosw
455 mov al, bptr ds:[si+LocBRPT_BeginHead]
456 stosb
457 mov ax, wptr ds:[si+LocBRPT_BeginSector] ; Cylinder/Sector
458 stosw
459 mov al, bptr es:[CurPartition_Location+5] ; Head of Part-Table
460 stosb
461 mov ax, wptr es:[CurPartition_Location+6] ; Cylinder/Sector
462 stosw
463 mov ax, wptr ds:[si+LocBRPT_RelativeBegin]
464 mov bx, wptr ds:[si+LocBRPT_RelativeBegin+2]
465 mov cx, wptr es:[CurPartition_Location+0] ; +Partition-Absolute
466 mov dx, wptr es:[CurPartition_Location+2] ; sectors
467 add ax, cx
468 adc bx, dx
469 stosw
470 mov ax, bx
471 stosw
472 mov ax, cx ; Absolute sector of partition table
473 stosw
474 mov ax, dx
475 stosw
476 inc es:NewPartitions ; NEW IPT Entry DONE
477
478 cmp es:NewPartitions, LocIPT_MaxPartitions
479 jbe PCCTP_NotTooManyPartitions
480 mov ax, cs
481 mov ds, ax
482 mov si, offset TXT_TooManyPartitions
483 call MBR_Teletype
484 jmp MBR_HaltSystem
485
486 PCCTP_NotTooManyPartitions:
487 ; UNHIDE PARTITION, if it was hidden previously
488 mov al, PartSystemID
489 cmp al, 08h ; internally NTFS ?
490 jne PCCTP_NoInternalNTFS
491 dec al
492 PCCTP_NoInternalNTFS:
493 mov bptr ds:[si+LocBRPT_SystemID], al
494
495 ; Calculate Size of this partition...
496 movzx ax, es:NewPartitions
497 dec ax
498 mov bx, ax
499 shl ax, 1
500 shl bx, 2
501 add ax, bx ; My way [tm] of multiplying with 6
502 mov di, offset PartitionSizeTable
503 add di, ax ; DI - Partition Size-Element
504 mov ax, wptr ds:[si+LocBRPT_AbsoluteLength] ; Sector-Size
505 mov bx, wptr ds:[si+LocBRPT_AbsoluteLength+2]
506 call PART_FillOutSizeElement
507 ret
508PARTSCAN_CheckThisPartition EndP
509
510; Scans Current Partition for Extended Partitions, if found, AX,BX,CX,DX will
511; be set to this location and Carry will be set
512PARTSCAN_ScanPartitionForExtended Proc Near Uses ds si
513 mov ax, ExecBaseSeg
514 mov ds, ax
515 mov si, ExecBasePtr
516 add si, 446 ; DS:SI - First Partition Entry
517 xor ax, ax
518 PSSPFE_ScanLoop:
519 mov al, ds:[si+LocBRPT_SystemID]
520 cmp al, 5 ; Is Partition EXTENDED ?
521 je PSSPFE_ExtendedPartition
522 cmp al, 0Fh ; Is Partition EXTENDED (M$) ?
523 je PSSPFE_ExtendedPartition
524 jmp PSSPFE_IgnorePartition
525 PSSPFE_ExtendedPartition:
526 mov ax, wptr ds:[si+LocBRPT_RelativeBegin]
527 mov bx, wptr ds:[si+LocBRPT_RelativeBegin+2]
528 add ax, wptr es:[ExtendedAbsPos+0] ; Adjust...
529 adc bx, wptr es:[ExtendedAbsPos+2] ; (Shit Design!)
530 test es:[ExtendedAbsPosSet], 1
531 jnz PSSPFE_ExtendedMainKnown
532 mov wptr es:[ExtendedAbsPos+0], ax
533 mov wptr es:[ExtendedAbsPos+2], bx
534 mov cs:[ExtendedAbsPosSet], 1
535 PSSPFE_ExtendedMainKnown:
536 mov cx, wptr ds:[si+LocBRPT_BeginSector] ; Cylinder/Sector
537 mov dh, bptr ds:[si+LocBRPT_BeginHead] ; Head
538 mov dl, bptr es:[CurPartition_Location+4] ; Drive
539 stc
540 jmp PSSPFE_EndOfSearch
541 PSSPFE_IgnorePartition:
542 add si, LocBRPT_LenOfEntry
543 cmp si, 500+ExecBasePtr
544 jb PSSPFE_ScanLoop
545 clc
546 PSSPFE_EndOfSearch:
547 ret
548PARTSCAN_ScanPartitionForExtended EndP
549
550; ===================
551; X-REFERENCE STUFF -> PartitionXref
552; ===================
553
554; The following routines have DS==CS again
555
556; Reset X-Reference
557PARTSCAN_ResetXref Proc Near Uses ax cx es di
558 push cs
559 pop es
560 mov di, offset PartitionXref ; X-Reference for later syncing
561 mov cx, LocIPT_MaxPartitions
562 mov ax, 0FFFFh ; Fill up with FFh
563 rep stosb
564 mov di, offset NewHidePartTable ; Temporary Hide-Config Table
565 mov cx, 450 ; Size is 900
566 rep stosw ; Fill up with FFFFh
567 mov di, offset NewDriveLetters
568 mov cx, 15 ; Temporary Logical-Drive Letter Table
569 xor ax, ax ; Size is 30
570 rep stosw ; Fill up with 0000h
571 ret
572PARTSCAN_ResetXref EndP
573
574; In: DL - Partition Number in IPT
575; DH - Partition Number in NewPartitionTable
576; Destroyed: None
577PARTSCAN_DefXref Proc Near Uses ax bx cx dx si di
578 movzx bx, dl
579 mov bptr [PartitionXref+bx], dh ; X-Reference
580 ; Copy Hide-Config of IPT partition to new location in new table
581 mov si, offset HidePartitionTable
582 mov di, offset NewHidePartTable
583 mov bl, LocIPT_MaxPartitions
584 mov al, dl
585 mul bl
586 add si, ax
587 mov al, dh
588 mul bl
589 add di, ax
590 mov cx, LocIPT_MaxPartitions
591 rep movsb ; Copy Hide-Config to NewHideTable
592 ; Process Logical-Drive-Letter table as well...
593 movzx bx, dl
594 mov al, bptr [DriveLetters+bx] ; Get Drv-Letter from org. pos
595 movzx bx, dh
596 mov bptr [NewDriveLetters+bx], al ; Put Drv-Letter to new pos
597 ret
598PARTSCAN_DefXref EndP
599
600; In: DL - Partition Number in previous IPT
601; Out: DH - Partition Number in NewPartitionTable
602; Destroyed: None
603PARTSCAN_GetXref Proc Near Uses bx
604 movzx bx, dl
605 mov dh, bptr [PartitionXref+bx] ; X-Reference
606 ret
607PARTSCAN_GetXref EndP
608
609; This here updates the contents of the Hide-Configuration to the current IPT
610; table.
611PARTSCAN_SyncHideConfigWithXref Proc Near Uses ax bx cx dx si di
612 mov si, offset NewHidePartTable
613 mov di, offset HidePartitionTable
614 mov ch, LocIPT_MaxPartitions
615 PSSHCWX_SyncPartLoop:
616 mov cl, LocIPT_MaxPartitions
617 xor dl, dl ; Partition Lost Counter
618 PSSHCWX_SyncLoop:
619 lodsb ; Get Part-Pointer from Hide-Cfg
620 cmp al, 0FFh
621 je PSSHCWX_SyncEmpty
622 movzx bx, al
623 mov al, [PartitionXref+bx] ; Translate it
624 cmp al, 0FFh
625 je PSSHCWX_PartLost
626 PSSHCWX_SyncEmpty:
627 stosb ; Put translated pointer to new table
628 dec cl
629 jnz PSSHCWX_SyncLoop
630 jmp PSSHCWX_SyncLoopEnd
631 PSSHCWX_PartLost:
632 inc dl ; One partition got lost...
633 dec cl
634 jnz PSSHCWX_SyncLoop
635
636 PSSHCWX_SyncLoopEnd:
637 or dl, dl
638 jz PSSHCWX_NothingLost
639 mov al, 0FFh
640 PSSHCWX_LostFillLoop:
641 stosb
642 dec cl
643 jnz PSSHCWX_LostFillLoop
644 PSSHCWX_NothingLost:
645 dec ch
646 jnz PSSHCWX_SyncPartLoop
647 ret
648PARTSCAN_SyncHideConfigWithXref EndP
Note: See TracBrowser for help on using the repository browser.