source: trunk/install/inst_x86/install.inc@ 57

Last change on this file since 57 was 57, checked in by Ben Rietbroek, 10 years ago

All source-files lowercased [v1.1.1-testing]

Some standard files like 'COPYING', 'LICENSE', etc. have not been
converted to lower case because they are usually distributed uppercased.

File size: 40.5 KB
Line 
1; AiR-BOOT (c) Copyright 1998-2009 M. Kiewitz
2;
3; This file is part of AiR-BOOT
4;
5; AiR-BOOT is free software: you can redistribute it and/or modify it under
6; the terms of the GNU General Public License as published by the Free
7; Software Foundation, either version 3 of the License, or (at your option)
8; any later version.
9;
10; AiR-BOOT is distributed in the hope that it will be useful, but WITHOUT ANY
11; WARRANTY: without even the implied warranty of MERCHANTABILITY or FITNESS
12; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13; details.
14;
15; You should have received a copy of the GNU General Public License along with
16; AiR-BOOT. If not, see <http://www.gnu.org/licenses/>.
17;
18
19; This file is included by various sources, it expects CS==DS and
20; ES is supposed to point to an area, where it's possible to put track 0
21; of the current harddrive 0 (around 32000 bytes). That way it's possible to
22; reuse this main code in multiple projects.
23
24; Currently used by AiR-BOOT Installer for DOS
25; AiR-BOOT Installer for Floppy (and bootable CD-ROM image)
26
27RunInstaller: ; -------------------------------------------> Verify our image
28 call Init_VerifyImage
29
30 ; -------------------------------------------> Load current MBR
31 call Init_CheckHarddisc
32 jc SkipLoadTrack0
33 mov si, offset TXT_START_LoadMBR
34 call APIShowMessage
35 call APILockVolume
36 call Init_LoadTrackZero
37 mov si, offset TXT_Okay
38 call APIShowMessage
39
40 ; ---------------------------------> Verify Code/Data integrity
41SkipLoadTrack0: mov si, offset TXT_STATUS_Main
42 call APIShowMessage
43
44 call Init_VerifyCode
45 mov al, iStatus_Code
46 mov dx, InstalledVersion_Code
47 call Init_ShowStatus
48
49 mov si, offset TXT_STATUS_Config
50 call APIShowMessage
51 call Init_VerifyConfig
52 mov al, iStatus_Config
53 mov dx, InstalledVersion_Config
54 call Init_ShowStatus
55
56 ; Display language as well, if Code installed
57 mov al, iStatus_Code
58 cmp al, Status_Installed
59 je ShowLanguage
60 cmp al, Status_InstalledMGU
61 jne SkipShowLanguage
62ShowLanguage: mov si, offset TXT_STATUS_Language
63 call APIShowMessage
64 mov al, InstalledLanguageID
65 call Init_ShowLanguage
66 mov si, offset TXT_CR
67 call APIShowMessage
68
69SkipShowLanguage:
70 cmp iStatus_Code, Status_Impossible
71 jne InstPossible
72 call APIExitProgram
73
74 ; ---------------------------------------> Analyse installation
75InstPossible: cmp Option_ForceCode, 1
76 je CodeInstallNeeded
77 cmp iStatus_Code, Status_Installed
78 jne CodeInstallNeeded
79 ; So we got Code installed - is it up-to-date?
80 mov al, InstalledLanguageID
81 cmp al, ImageLanguageID
82 je NoCodeNeeded
83 ; If Language-ID is the same -> No install needed
84CodeInstallNeeded:
85 mov Install_Code, 1 ; Not/Corrupt/Update
86
87NoCodeNeeded: cmp Option_ForceConfig, 1
88 je ConfigInstallNeeded
89 cmp iStatus_Config, Status_Installed
90 je NoConfigNeeded
91ConfigInstallNeeded:
92 mov Install_Config, 1 ; Not/Corrupt
93NoConfigNeeded: mov al, 1
94 cmp iStatus_Code, Status_Corrupt
95 je WonderfulCorrupt
96 cmp iStatus_Config, Status_Corrupt
97 je WonderfulCorrupt
98 xor al, al
99WonderfulCorrupt:
100 mov Install_IsCorrupt, al
101
102 ; --------------------------------------------> Virus detection
103 ; Check-Table:
104 ; --------------
105 ; Code==Not Installed, Config==Not Installed => Check MBR
106 ; Code==Installed, Config==Installed => Check MBR (->Virus?)
107 ; Code==Not Installed, Config==Installed => (->Virus?)
108 ; Code==Installed, Config==Not Installed => Check MBR (->Virus?)
109 cmp iStatus_Code, Status_NotInstalled
110 jne FoundInstall
111 cmp iStatus_Config, Status_NotInstalled
112 jne FoundInstall
113 ; Nothing Found, so Check MBR, if squashed simply stop system
114 call Init_CheckCurrentMBR
115 jnc VirusSkip ; Skip Virus-Stuff Code
116 ; AiR-BOOT 100% not found and Partition Table broken
117 mov si, offset TXT_MBRfail_Argh
118 call APIShowMessage
119 call APIExitProgram
120
121FoundInstall: cmp iStatus_Code, Status_NotInstalled
122 je VirusPossible
123 ; Just check MBR...if squashed show up virus and check for backup
124SimplyCheckMBR: call Init_CheckCurrentMBR
125 jnc VirusSkip
126
127 ; Virus Proposed to have squashed the MBR, perhaps backup is
128 ; available, so check for it.
129VirusPossible: mov si, offset TXT_Virus_Main
130 call APIShowMessage
131 call Init_CheckForStealthVirus
132 jz StealthVirusPossible
133 mov si, offset TXT_Virus_Normal
134 call APIShowMessage
135 jmp VirusWarning
136StealthVirusPossible:
137 mov si, offset TXT_Virus_Severe
138 call APIShowMessage
139
140VirusWarning: mov si, offset TXT_Virus_Always
141 call APIShowMessage
142
143 call Init_CheckCurrentMBR
144 jnc VirusSkip
145 mov si, offset TXT_MBRfail_Normal
146 call APIShowMessage
147 call Init_CheckBackupMBR
148 jc VirusNoBackup
149 mov si, offset TXT_MBRfail_Strike
150 call APIShowMessage
151VirusKeyLoop: call APIReadKeyboard
152 or al, 20h ; Lower-Case Input
153 cmp al, 'y'
154 je VirusRestoreYes
155 cmp al, 'z'
156 je VirusRestoreYes
157 cmp al, 'n'
158 je VirusRestoreNo
159 jmp VirusKeyLoop
160
161VirusRestoreYes:call Init_CopyBackupMBR
162VirusRestoreNo: jmp VirusSkip
163
164VirusNoBackup: mov si, offset TXT_MBRfail_Buuuhh
165 call APIShowMessage
166VirusSkip:
167
168 ; --------------------------------------------------> Main-Menu
169 mov si, offset TXT_MENU_Main
170 call APIShowMessage
171 mov si, offset TXT_MENU_Repair
172 test Install_IsCorrupt, 1
173 jnz MenuShowMessage
174 mov si, offset TXT_MENU_Add
175 cmp iStatus_Code, Status_NotInstalled
176 je MenuShowMessage
177 mov si, offset TXT_MENU_Update
178MenuShowMessage:call APIShowMessage
179
180 mov dx, ImageVersion
181 mov al, dh
182 call ShowNumber
183 mov al, '.'
184 call APIShowChar
185 mov al, dl
186 call ShowNumber2
187 mov al, '/'
188 call APIShowChar
189 mov al, ImageLanguageID
190 call Init_ShowLanguage
191 mov si, offset TXT_MENU_OnCurSystem
192 call APIShowMessage
193
194 mov si, offset TXT_MENU_Delete
195 call APIShowMessage
196 mov si, offset TXT_MENU_Quit
197 call APIShowMessage
198
199 ; Silent operation? Always add AiR-BOOT to system
200 cmp Option_Silent, 1
201 je MenuProcessADD
202
203MenuKeyLoop: call APIReadKeyboard
204 or al, 20h ; Lower-Case Input
205 cmp al, 'a'
206 je MenuProcessADD
207 cmp al, 'r'
208 je MenuProcessADD
209 cmp al, 'u'
210 je MenuProcessADD
211 cmp al, 'd'
212 je MenuProcessDELETE
213 cmp al, 'q'
214 je MenuProcessQUIT
215 jmp MenuKeyLoop
216
217MenuProcessADD: mov si, offset TXT_PROCESS_Split
218 call APIShowMessage
219 call ProcessADD
220 mov si, offset TXT_AfterAdd
221 call APIShowMessage
222 call MenuWaitForEnter
223 call APIAfterAdd
224
225MenuProcessDELETE:
226 mov si, offset TXT_PROCESS_Split
227 call APIShowMessage
228 mov si, offset TXT_DELETE_NotPossible
229 call APIShowMessage
230 mov si, offset TXT_AfterDelete
231 call APIShowMessage
232 call MenuWaitForEnter
233 call APIAfterDelete
234
235MenuProcessQUIT:mov si, offset TXT_AfterQuit
236 call APIShowMessage
237 call MenuWaitForEnter
238 call APIAfterQuit
239
240MenuWaitForEnter Proc Near
241 cmp Option_Silent, 1
242 je MWFE_Skip
243 MWFE_Loop:
244 call APIReadKeyboard
245 cmp al, 0Dh
246 jne MWFE_Loop
247 MWFE_Skip:
248 ret
249MenuWaitForEnter EndP
250
251ProcessADD Proc Near
252 mov si, offset TXT_PROCESS_Add
253 call APIShowMessage
254 xor di, di
255 test Install_Code, 1
256 ; ALLTIME ADD - For Debugging Purposes (Remark next line)
257 IFNDEF DebugVersion
258 jz MPA_NoCode
259 ENDIF
260 mov si, offset TXT_ADD_Code
261 call APIShowMessage
262 call InstallCode
263 mov si, offset TXT_Okay
264 call APIShowMessage
265 inc di
266 MPA_NoCode:
267 test Install_Config, 1
268 jz MPA_NoConfig
269 mov si, offset TXT_ADD_Config
270 call APIShowMessage
271 call InstallConfig
272 mov si, offset TXT_Okay
273 call APIShowMessage
274 inc di
275 MPA_NoConfig:
276 or di, di
277 jz MPA_NothingDone
278 mov si, offset TXT_ADD_SetupOkay
279 call APIShowMessage
280 ret
281
282 MPA_NothingDone:
283 mov si, offset TXT_ADD_NothingToDo
284 call APIShowMessage
285 ret
286ProcessADD EndP
287
288InstallCode Proc Near
289 ; Calculates new code checksum...
290 mov si, offset BootImage+512 ; Sector 2 (Start of Code-Image)
291 xor bx, bx
292 movzx cx, bptr ds:[BootImage+0010h] ; Total sectors used (hard-coded)
293 IC_CalcCodeLoop:
294 call GetCheckOfImageSector
295 loop IC_CalcCodeLoop
296 mov wptr ds:[BootImage+0011h], bx ; set Checksum
297 call InstallCode_MergeMBRs ; Merges BootCodeMBR and actual MBR
298 ; -------------------------------------------------------------------------
299 mov cx, 0001h ; Cylinder 0, Sector 1
300 mov dx, 0080h ; Head 0, Drive 80 (MBR Write)
301 mov si, offset BootImage
302 ; ...writes the new MBR...
303 call SaveImageSector
304
305 ; ...and writes the following sectors...
306 movzx ax, bptr ds:[BootImage+0010h] ; Total sectors used
307 or ax, ax
308 jz IC_NoSectors
309 IC_WriteCodeLoop:
310 call SaveImageSector
311 dec ax
312 jnz IC_WriteCodeLoop
313 IC_NoSectors:
314 ret
315InstallCode EndP
316
317InstallCode_MergeMBRs Proc Near Uses ds si es di
318 ; Exchange DS&ES, DS==HDD, ES==New BootCode
319 push ds
320 push es
321 pop ds
322 pop es
323 xor si, si
324 mov di, offset BootImage
325 add si, 1B8h ; 1B8h - Windoze NT Mickeysoft hdd signature
326 add di, 1B8h ; 1BEh - Real Partition Table start
327 mov cx, 72 ; 66 without Mickeysoft signature
328 rep movsb ; Copies parition table and NT signature
329 ret
330InstallCode_MergeMBRs EndP
331
332InstallConfig Proc Near
333 ; Calculate new Config-CheckSum
334 mov si, offset BootImage+6C00h ; Configuration location
335 mov wptr ds:[si+20], 0 ; delete current CheckSum
336 xor bx, bx
337
338 ;mov cx, 7 ; Rousseau: changed to 7 for v1.0.7+
339
340 ; Rousseau: Changed back to 5 to be compatible with the v1.07 OS/2 and WIN
341 ; installers AIRBOOT2.EXE and AIRBOOTW.EXE dat do a CRC over 5 sectors.
342 mov cx, 5
343
344 IC_CalcConfigLoop:
345 call GetCheckOfImageSector
346 loop IC_CalcConfigLoop
347 mov wptr ds:[BootImage+6C00h+20], bx ; new checksum set
348 ; -------------------------------------------------------------------------
349 mov cx, 0037h ; Cylinder 0, Sektor 55
350 mov dx, 0080h ; Head 0, Drive 80 (CONFIG Write)
351 mov si, offset BootImage+6C00h ; Config-Location
352
353 call SaveImageSector ; Configuration (sec 55)
354
355 ; Rousseau: Added 2 extra SaveImageSector calls for the v1.07+
356 ; 45-partition version.
357 ; Note the MBR backup at sector 62 (LBA 61).
358 call SaveImageSector ; Partition Table part 1 (sec 56)
359 call SaveImageSector ; Partition Table part 2 (sec 57)
360 call SaveImageSector ; Partition Table part 3 (sec 58)
361
362 call SaveImageSector ; Hide-Partition Table part 1 (sec 59)
363 call SaveImageSector ; Hide-Partition Table part 2 (sec 60)
364 call SaveImageSector ; Hide-Partition Table part 3 (sec 61)
365
366 call SaveImageSector ; MBR BackUp (sec 62)
367
368 ret
369InstallConfig EndP
370
371
372
373; Out: Carry Flag SET if Harddisc failed 63-sectors test
374Init_CheckHarddisc Proc Near
375 mov ah, 08h
376 mov dl, 80h
377 int 13h
378 and cl, 111111b
379 cmp cl, 62
380 ja INITCH_Success
381 stc
382 ret
383 INITCH_Success:
384 clc
385 ret
386Init_CheckHarddisc EndP
387
388; In: CH = Cylinder, CL = Sector, ES:BX = Sector Ptr
389; DH = Head, DL = Drive
390LoadHDDSector Proc Near Uses ax es
391 LHDDS_Retry:
392 push bx
393 push cx
394 push dx
395 mov ax, 0201h ; load one sector
396 int 13h
397 jnc LHDDS_Success
398 xor ah, ah
399 xor dl, dl
400 int 13h ; BIOS: READ SECTOR VIA CHS
401 pop dx
402 pop cx
403 pop bx
404 jmp LHDDS_Retry
405 LHDDS_Success:
406 pop dx
407 pop cx
408 pop bx
409 add bx, 512
410 inc cl ; sector fixing must be done manual
411 ret
412LoadHDDSector EndP
413
414; In: CH = Cylinder, CL = Sector, DS:SI = Sector Ptr
415; DH = Head, DL = Drive
416SaveImageSector Proc Near Uses ax bx dx es
417 push ds
418 pop es ; ES==DS -> bootcode image segment
419 mov bx, si ; ES:BX - sector buffer to write
420 SIS_Retry:
421 push bx
422 push cx
423 push dx
424 mov ax, 0301h
425 int 13h ; BIOS: WRITE SECTOR
426 jnc SIS_Success
427 mov ah, 00h ; reset disc
428 mov dl, 00h
429 int 13h
430 pop dx
431 pop cx
432 pop bx
433 jmp SIS_Retry
434 SIS_Success:
435 pop dx
436 pop cx
437 pop bx
438 add si, 512 ; go to next sector
439 inc cl ; add 1 to sector
440 ret
441SaveImageSector EndP
442
443; In: BX - Base Check, ES:SI - Pointer to 512-byte-area to be included
444; Out: BX - Base Check Result
445; Destroyed: SI will get updated (+512)
446GetCheckOfHDDSector Proc Near Uses ds
447 push es
448 pop ds ; DS now points to HDD Track 0
449 call GetCheckOfImageSector
450 ret
451GetCheckOfHDDSector EndP
452
453; In: BX - Base Check, DS:SI - Pointer to 512-byte-area to be included
454; Out: BX - Base Check Result
455; Destroyed: SI will get updated (+512)
456GetCheckOfImageSector Proc Near Uses ax cx
457 mov cx, 256
458 GCOIS_Loop:
459 lodsw
460 xor ax, 0BABEh
461 xor bx, ax
462 loop GCOIS_Loop
463 or bx, bx
464 jnz GCOIS_NoFixUp
465 mov bx, 1 ; dont allow 0, cause 0 means "empty"
466 GCOIS_NoFixUp:
467 ret
468GetCheckOfImageSector EndP
469
470Init_LoadTrackZero Proc Near Uses ES
471 xor bx, bx ; ES:0 - Ptr to load current track-0
472 mov cx, 0001h ; Cylinder 0, Sektor 1
473 mov dx, 0080h ; Head 0, Drive 80
474 INITLTZ_Loop:
475 call LoadHDDSector
476 cmp cl, 63
477 jne INITLTZ_Loop
478 ret
479Init_LoadTrackZero EndP
480
481; al - type to display text
482; dx - version number
483Init_ShowStatus Proc Near Uses si
484 cmp al, Status_Corrupt
485 jb ISSV_NotInstalled
486 je ISSV_Corrupt
487 cmp al, Status_Impossible
488 je ISSV_Impossible
489 ; --- Intact (and possibly Update-able)
490 push ax
491 mov si, offset TXT_STATUS_Intact
492 call APIShowMessage
493 ; Include version number...
494 mov al, dh
495 call ShowNumber
496 mov al, '.'
497 call APIShowChar
498 mov al, dl
499 call ShowNumber2
500 mov al, ')'
501 call APIShowChar
502 pop ax
503 cmp al, Status_InstalledMGU
504 jne ISSV_NoMGU
505 mov si, offset TXT_STATUS_Update
506 call APIShowMessage
507 ISSV_NoMGU:
508 jmp ISSV_End
509
510 ISSV_NotInstalled:
511 mov si, offset TXT_STATUS_ninstall
512 jmp ISSV_EndWithTeletype
513 ISSV_Corrupt:
514 mov si, offset TXT_STATUS_nintact
515 jmp ISSV_EndWithTeletype
516 ISSV_Impossible:
517 mov si, Impossible_Cause
518 ISSV_EndWithTeletype:
519 call APIShowMessage
520 ISSV_End:
521 mov si, offset TXT_CR
522 call APIShowMessage
523 ret
524Init_ShowStatus EndP
525
526; al - Language ID
527Init_ShowLanguage Proc Near Uses si
528 cmp al, 'E'
529 mov si, offset TXT_Language_EN
530 je ISL_Done
531 cmp al, 'N'
532 mov si, offset TXT_Language_NL
533 je ISL_Done
534 cmp al, 'G'
535 mov si, offset TXT_Language_DE
536 je ISL_Done
537 cmp al, 'F'
538 mov si, offset TXT_Language_FR
539 je ISL_Done
540 cmp al, 'I'
541 mov si, offset TXT_Language_IT
542 je ISL_Done
543 cmp al, 'R'
544 mov si, offset TXT_Language_RU
545 je ISL_Done
546 cmp al, 'S'
547 mov si, offset TXT_Language_SW
548 je ISL_Done
549 mov si, offset TXT_Language_Huh ; Unknown to us
550 ISL_Done:
551 call APIShowMessage
552 ret
553Init_ShowLanguage EndP
554
555; In: AL - BCD-number to type to screen
556; Destroyed: *nothing*
557ShowNumber Proc Near Uses ax bx
558 mov ah, al
559 and ah, 0Fh
560 shr al, 4
561 add ax, 3030h
562 cmp al, 30h
563 je SN_SkipDigit
564 call APIShowChar
565 SN_SkipDigit:
566 mov al, ah
567 call APIShowChar
568 ret
569ShowNumber EndP
570
571; In: AL - BCD-number to type to screen (full 2 digits everytime)
572; Destroyed: *nothing*
573ShowNumber2 Proc Near Uses ax bx
574 mov ah, al
575 and ah, 0Fh
576 shr al, 4
577 add ax, 3030h
578 call APIShowChar
579 mov al, ah
580; cmp al,'8'
581; jb ShowNumber2_skip_dot
582 ; Display separation dot
583 push ax
584 mov al,'.'
585 call APIShowChar
586 pop ax
587; ShowNumber2_skip_dot:
588 call APIShowChar
589 ret
590ShowNumber2 EndP
591
592; Verifies our bootcode installation image
593Init_VerifyImage Proc Near
594 ; First we verify the image, this is done by using the same checksum method
595 ; as on real harddrive images. This is mainly for detecting, that we are
596 ; really seeing an AiR-BOOT image and not some other data file.
597
598 ; Identifies image...
599 mov ax, wptr ds:[BootImage+000Dh] ; Version of Image
600 xchg al, ah
601 mov ImageVersion, ax
602 mov al, bptr ds:[BootImage+000Fh] ; Language ID of Image
603 mov ImageLanguageID, al
604 ret
605Init_VerifyImage EndP
606
607; Verifies existing code-image from current HDD...
608Init_VerifyCode Proc Near Uses ds si es di
609 call Init_CheckHarddisc
610 jnc IVC_HarddiscOK
611 mov iStatus_Code, Status_Impossible
612 mov Impossible_Cause, offset TXT_STATUS_Hd2Small
613 ret
614
615 IVC_HarddiscOK:
616 call Init_CheckForEZSETUP
617 jne IVC_NoEZSETUP
618 mov iStatus_Code, Status_Impossible
619 mov Impossible_Cause, offset TXT_STATUS_EZSETUP
620 ret
621
622 IVC_NoEZSETUP:
623 mov si, offset MBR_AiRBOOTCodeSig
624 ; Check Master-Boot-Record Signature
625 cmp wptr es:[01FEh], 0AA55h
626 jne IVC_NotInstalled
627 ; Check AiR-BOOT String...
628 mov di, 2
629 mov cx, MBR_AiRBOOTCodeSigLen
630 repe cmpsb
631 je IVC_IDfound
632 IVC_NotInstalled:
633 ; No AiR-BOOT MBR Image found...
634 mov iStatus_Code, Status_NotInstalled
635 ret
636
637 IVC_IDfound:
638 ; Check actual Code
639 movzx cx, bptr es:[0010h] ; Total-Code-Sectors-Used
640 mov si, 512
641 xor bx, bx
642 IVC_CheckSumLoop:
643 call GetCheckOfHDDSector
644 loop IVC_CheckSumLoop
645 cmp bx, wptr es:[0011h]
646 je IVC_CheckSumOK
647 mov iStatus_Code, Status_Corrupt
648 ret
649
650 IVC_CheckSumOK:
651 mov al, es:[000Fh] ; Current Language ID
652 mov InstalledLanguageID, al
653 mov cx, es:[000Dh] ; Current Version ID
654 mov dx, ImageVersion ; My Image Version ID
655 xchg ch, cl
656 mov InstalledVersion_Code, cx ; remember installed code version
657 cmp cx, dx ; If version number in image is higher
658 jb IVC_MGU_a ; -> Upgradeable
659 mov iStatus_Code, Status_Installed
660 ret
661 IVC_MGU_a:
662 mov iStatus_Code, Status_InstalledMGU
663 ret
664Init_VerifyCode EndP
665
666Init_CheckForEZSETUP Proc Near
667 mov si, offset MBR_EZSETUPCodeSig
668 mov di, 8Fh
669 mov cx, MBR_EZSETUPCodeSigLen
670 repe cmpsb
671 ret
672Init_CheckForEZSETUP EndP
673
674Init_VerifyConfig Proc Near Uses ds si es di
675 ; First check for current Config-Format...
676 mov si, offset MBR_AiRBOOTConfigSig
677 mov di, 6C00h ; Sector 55
678 mov cx, MBR_AiRBOOTConfigSigLen
679 repe cmpsb
680 jne IVC_CheckPrior026
681 mov si, 6C00h ; Sector 55
682 mov dx, wptr es:[si+20] ; DX - Current Checksum
683 mov wptr es:[si+20], 0 ; Kills current Checksum
684 xor bx, bx
685
686 ;mov cx, 7 ; Total of 7 Sectors
687 ; Rousseau: changed above to 7
688 ; Rousseau: Changed back to 5 to be compatible with the v1.07 OS/2 and WIN
689 ; installers AIRBOOT2.EXE and AIRBOOTW.EXE that do a CRC over 5 sectors.
690 mov cx, 5
691
692 IVC_CheckSumLoop2:
693 call GetCheckOfHDDSector
694 loop IVC_CheckSumLoop2
695 cmp bx, dx
696 je IVC_CheckSumOK2
697 mov iStatus_Config, Status_Corrupt
698 ret
699 IVC_CheckSumOK2:
700 ; DS == New BootCode, ES == HDD
701 mov cx, es:[6C0Dh]
702 mov ax, wptr ds:[BootImage+6C0Dh]
703 xchg cl, ch
704 xchg al, ah
705 mov InstalledVersion_Config, cx ; remember installed config version
706 cmp cx, ax
707 jb IVC_UpgradeConfig
708 mov iStatus_Config, Status_Installed
709 jmp IVC_NoUpgradeConfig
710 ; ==========================================================================
711 ; Those Upgrades will copy useful configuration data to the Image Config
712 ; If new configuration data was added, those spaces are not overwritten.
713 ; Sector 60 (MBR-BackUp) *MUST BE* copied, otherwise it's lost.
714 ; ==========================================================================
715 IVC_UpgradeConfig:
716 mov iStatus_Config, Status_InstalledMGU
717 IVC_NoUpgradeConfig:
718 ; We exchange DS and ES, be careful from now on!
719 push ds
720 push es
721 pop ds
722 pop es ; DS = HDD, ES = BootCode
723 cmp cx, 0027h
724 jbe IVC_Upgrade027
725 cmp cx, 0091h
726 jbe IVC_Upgrade091
727 ; If we don't need to "upgrade" the configuration, we simply copy it over.
728 mov si, 6C00h+16 ; Sector 55 (never copy header/version)
729 mov di, si
730 add di, offset BootImage
731 mov cx, (3072-16)/2 ; Copy all 6 sectors w/o modification
732 rep movsw
733 ; DS&ES will get restored here
734 ret
735
736 ; ----------------------------------------- UPGRADE v0.27 and prior versions
737 IVC_Upgrade027:
738 mov si, 6C00h+16 ; Sector 55 (never copy header/version)
739 mov di, si
740 add di, offset BootImage
741 mov cx, (69-16)
742 rep movsb
743 ; Changes: Sector 55 - Offset 69 Length 75 - Linux Command Line
744 ; Offset 144 Length 1 - Linux Kernel Partition
745 ; Offset 145 Length 11 - Default Kernel Name
746 ; Offset 156 Length 1 - Kernel Name Terminator 1
747 ; Offset 157 Length 11 - Last Kernel Name
748 ; Offset 168 Length 1 - Kernel Name Terminator 2
749 ; Offset 169 Length 1 - Ext. Partition M$-Hack Enable
750 ; -> Total-Length 101
751 ; Changes: Sector 55 - Offset 432 Length 34 - New IPT entry (BIOS continued)
752 add si, 101+262+34
753 add di, 101+262+34
754 mov cx, 46/2
755 rep movsw ; Copy remaining of sector 55
756 mov cx, 1924/2
757 rep movsw ; Copy sectors 56-57 & Hide-Config
758 ; Changes: Sector 59 - Offset 388 Length 30 - Logical-Drive-Letter Table
759 add si, 124
760 add di, 124
761 mov cx, 512/2
762 rep movsw ; Copy sector 60 unmodified
763 ; DS&ES will get restored here
764 ret
765
766 ; ----------------------------------------- UPGRADE v0.91 and prior versions
767 IVC_Upgrade091:
768 mov si, 6C00h+16 ; Sector 55 (never copy header/version)
769 mov di, si
770 add di, offset BootImage
771 mov cx, (512-16)/2
772 rep movsw ; Copy sector 55
773 mov cx, 1924/2
774 rep movsw ; Copy sectors 56-57 & Hide-Config
775 ; Changes: Sector 59 - Offset 388 Length 30 - Logical-Drive-Letter Table
776 add si, 124
777 add di, 124
778 mov cx, 512/2
779 rep movsw ; Copy sector 60 unmodified
780 ; DS&ES will get restored here
781 ret
782
783 ; ==========================================================================
784 ; Check for Prior 0.26b format...
785 IVC_CheckPrior026:
786 mov si, offset MBR_AiRBOOTConfigSig
787 mov di, 7000h ; Sector 57
788 mov cx, MBR_AiRBOOTConfigSigLen
789 repe cmpsb
790 je IVC_PriorIDfound
791 ; kein AiR-BOOT MBR Image gefunden
792 mov iStatus_Config, Status_NotInstalled
793 ret
794 IVC_PriorIDfound:
795 mov si, 7000h
796 mov dx, wptr es:[si+20] ; DX - jetzige Checksum
797 mov wptr es:[si+20], 0 ; l”scht jetzige Checksum
798 xor bx, bx
799 mov cx, 3 ; Total of 3 Sectors
800 IVC_PriorCheckSumLoop:
801 call GetCheckOfHDDSector
802 loop IVC_PriorCheckSumLoop
803 cmp bx, dx
804 je IVC_PriorCheckSumOK
805 mov iStatus_Config, Status_Corrupt
806 ret
807 IVC_PriorCheckSumOK:
808 mov iStatus_Config, Status_InstalledMGU
809 ; ==========================================================================
810 ; Now convert Pre-0.26b-configuration layout to new one.
811 ; Sector 57-59 containing Base-Config and IPT are compatible but have to
812 ; get moved to Sector 55-57 and Hide-Configuration has to be taken from
813 ; Image-default-configuration.
814 ; After that a normal version upgrade will be performed additionally.
815 ; ==========================================================================
816 ; Exchange DS and ES, so DS == HDD and ES == New BootCode
817 push ds
818 push es
819 pop ds
820 pop es
821 mov si, 7000h ; Current - Sector 57 (Prior config)
822 mov di, 6C00h ; -> Current - Sector 55 (cur. config)
823 mov cx, 768 ; Total of 3 sectors...
824 rep movsw
825 mov si, 7200h ; Image - Sector 58 (Hide-Config)
826 mov cx, 512 ; Total of 2 sectors...
827 rep movsw
828 ; Exchange DS and ES again, so state is normal...
829 push ds
830 push es
831 pop ds
832 pop es
833 ;jmp IVC_CheckSumOK ; Resume to upgrade config more
834
835 ; Duplicated from Init_VerifyCode to remove jump
836 ; to procedure-local label. JWasm doesn't like that.
837 ; FIXME: Restructure...
838 mov al, es:[000Fh] ; Current Language ID
839 mov InstalledLanguageID, al
840 mov cx, es:[000Dh] ; Current Version ID
841 mov dx, ImageVersion ; My Image Version ID
842 xchg ch, cl
843 mov InstalledVersion_Code, cx ; remember installed code version
844 cmp cx, dx ; If version number in image is higher
845 jb IVC_MGU_b ; -> Upgradeable
846 mov iStatus_Code, Status_Installed
847 ret
848 IVC_MGU_b:
849 mov iStatus_Code, Status_InstalledMGU
850 ret
851
852
853
854
855Init_VerifyConfig EndP
856
857; Carry set, if invalid MBR
858Init_CheckCurrentMBR Proc Near Uses si
859 xor si, si
860 call Init_CheckThisMBR
861 ret
862Init_CheckCurrentMBR EndP
863
864; Carry set, if invalid BackUp
865Init_CheckBackupMBR Proc Near Uses si
866 ; Now 7a00h
867 mov si, 7a00h ; Fixed location of backup
868 call Init_CheckThisMBR
869 ret
870Init_CheckBackupMBR EndP
871
872; Internal
873Init_CheckThisMBR Proc Near
874 cmp wptr es:[si+01FEh], 0AA55h
875 jne ICTM_InvalidMBR
876 xor cx, cx ; No entries checked
877 xor dx, dx ; No entries in MBR
878 add si, 446 ; Auf start Partition table seeken
879 ICTM_PartitionLoop:
880 mov al, es:[si+3] ; Cylinder
881 mov ah, es:[si+2]
882 shr ah, 6 ; oberen Bits von Cylinder
883 shl eax, 16 ; bringt Cylinder nach EAX[16-31]
884 mov ah, es:[si+1] ; Seite nach EAX[8-15]
885 mov al, es:[si+2]
886 and al, 111111b ; Sektor nach EAX[0-7]
887 ; Anfangs-Wert fertig
888 mov bl, es:[si+7] ; Cylinder
889 mov bh, es:[si+6]
890 shr bh, 6 ; oberen Bits von Cylinder
891 shl ebx, 16 ; bringt Cylinder nach EAX[16-31]
892 mov bh, es:[si+5] ; Seite nach EAX[8-15]
893 mov bl, es:[si+6]
894 and bl, 111111b ; Sektor nach EAX[0-7]
895 ; Anfangs-Wert fertig
896 cmp eax, ebx ; vergleichen, falls Begin kleiner
897 ja ICTM_InvalidMBR
898
899 inc cx
900 cmp bptr es:[si+4], 0 ; nur falls was definiert ist
901 je ICTM_ValidButNone
902 cmp wptr es:[si+14], 0 ; Absolute mit 0 vergleichen,
903 jne ICTM_ValidOne ; falls ==0 -> Fehlerhaft
904 cmp wptr es:[si+12], 0
905 je ICTM_InvalidMBR
906 ICTM_ValidOne:
907 inc dx
908 ICTM_ValidButNone:
909 add si, 16
910 cmp cx, 4
911 jne ICTM_PartitionLoop
912 cmp dx, 1
913 jb ICTM_InvalidMBR
914 clc
915 ret
916 ICTM_InvalidMBR:
917 stc
918 ret
919Init_CheckThisMBR EndP
920
921; Copies BackUp MBR into current MBR area, so it will get installed
922Init_CopyBackupMBR Proc Near Uses ds si es di
923 push ds
924 push es
925 pop ds
926 pop es ; Exchange DS&ES so DS==HDD, ES==New BootCode
927 ; Now 7a00h
928 mov si, 7a00h ; Sector 62...
929 mov di, offset BootImage ; -> to Sector 1 of New BootCode
930 mov cx, 256
931 rep movsw ; Copies 1 sector...
932 ret
933Init_CopyBackupMBR EndP
934
935Init_CheckForStealthVirus Proc Near Uses ds si es di
936 xor si, si ; ES:SI - HDD (MBR)
937 xor bx, bx
938 ICFSV_CheckLoop:
939 cmp si, 512
940 ja ICFSV_EndLoop
941 mov al, es:[si]
942 inc si
943 cmp al, 0CDh
944 jne ICFSV_CheckLoop
945 cmp bptr es:[si], 13h
946 jne ICFSV_CheckLoop
947 inc bx
948 jmp ICFSV_CheckLoop
949
950 ICFSV_EndLoop:
951 or bx, bx ; Sets Zero-Flag if no CD 13hs found...
952 ret
953Init_CheckForStealthVirus EndP
954
955TXT_Okay db 'ok'
956TXT_CR db 13, 10, 0
957
958TXT_START_NoPhysicalDrives db ' - No physical drives found on this system. Install impossible.', 13, 10, 0
959TXT_START_LoadMBR db ' - Loading Track-0 from harddisc...', 0
960TXT_STATUS_Main db 13, 10, 13, 10
961 db '-> ...Current Status... <-', 13, 10
962TXT_STATUS_Code db ' - AiR-BOOT is ', 0
963TXT_STATUS_Config db ' - Configuration is ', 0
964TXT_STATUS_Language db ' - Language is ', 0
965TXT_STATUS_Intact db 'intact (v', 0
966TXT_STATUS_nintact db 'not intact', 0
967TXT_STATUS_ninstall db 'not installed', 0
968TXT_STATUS_Update db ', but may be updated', 0
969TXT_STATUS_Hd2Small db 'unable to install', 13, 10
970 db ' Your harddisc does not have at least 63 sectors per track.', 0
971TXT_STATUS_EZSETUP db 'not willing to install', 13, 10
972 db ' Your harddisc contains EZ-SETUP.', 13, 10
973 db ' This program is required, so your computer is able to access the harddisc', 13, 10
974 db ' completly. Installation of AiR-BOOT would overwrite it.', 0
975IFDEF Flat
976 TXT_InstallHalted db 'Installation halted.', 0
977 ELSE
978 TXT_SystemHalted db 'System halted.', 0
979ENDIF
980
981TXT_Language_EN db 'english', 0
982TXT_Language_NL db 'dutch', 0
983TXT_Language_DE db 'german', 0
984TXT_Language_FR db 'french', 0
985TXT_Language_IT db 'italian', 0
986TXT_Language_RU db 'russian', 0
987TXT_Language_SW db 'swedish', 0
988TXT_Language_Huh db 'unknown', 0
989
990TXT_Virus_Main db 13, 10, 13, 10
991 db '-> ...!ATTENTION!... <-', 13, 10, 0
992TXT_Virus_Normal db 'Probably your system was infected by a virus.', 13, 10, 0
993TXT_Virus_Severe db 'Your system GOT infected by a stealth-virus (or your MBR got trashed).', 13, 10, 0
994TXT_Virus_Always db 'Repairing AiR-BOOT will normally squash the virus.', 13, 10
995 db 'But to be sure it''s gone, you should check your harddisc using a virus-scanner.', 13, 10, 0
996
997TXT_MBRfail_Normal db 13, 10
998 db 'AiR-BOOT detected that the virus has broken your partition-table.', 13, 10, 0
999TXT_MBRfail_Strike db 'Good news: AiR-BOOT has found a (hopefully) functional backup.', 13, 10
1000 db 'Shall I use this backup, instead of the current active one ? (Y/N)', 13, 10, 0
1001TXT_MBRfail_Buuuhh db 'Sadly the virus also broke AiR-BOOT''s backup. You will have to help yourself.', 13, 10, 0
1002
1003TXT_MBRfail_Argh db 13, 10, 13, 10
1004 db 'AiR-BOOT detected that the data on your harddisc got damaged.', 13, 10
1005 db 'If you had AiR-BOOT installed before: The corruption killed AiR-BOOT completly!', 13, 10, 0
1006
1007TXT_MENU_Main db 13, 10, 13, 10
1008 db '-> ...Please press... <-', 13, 10, 0
1009TXT_MENU_Add db ' <A> - Add AiR-BOOT ''v', 0
1010TXT_MENU_Repair db ' <R> - Repair AiR-BOOT ''v', 0
1011TXT_MENU_Update db ' <U> - Update/Change AiR-BOOT to ''v', 0
1012TXT_MENU_OnCurSystem db ''' on current system', 13, 10, 0
1013TXT_MENU_Delete db ' <D> - Delete AiR-BOOT from current system', 13, 10, 0
1014TXT_MENU_Quit db ' <Q> - Quit without any change', 13, 10, 0
1015
1016TXT_PROCESS_Split db 13, 10, 13, 10, 13, 10
1017 db '-------------------------------------------------------------------------------', 13, 10, 0
1018TXT_PROCESS_Add db 'Add/Repair/Update AiR-BOOT in progress...', 13, 10, 0
1019
1020TXT_ADD_Code db ' þ Writing AiR-BOOT code...', 0
1021TXT_ADD_Config db ' þ Writing AiR-BOOT configuration...', 0
1022TXT_ADD_NothingToDo db ' þ All components of AiR-BOOT are intact and up-to-date. Nothing to do.', 13, 10, 0
1023TXT_ADD_SetupOkay db 13, 10
1024 db 'Your copy of AiR-BOOT is now fully functional.', 13, 10, 0
1025
1026TXT_DELETE_NotPossible db ' þ Removing AiR-BOOT automatically is not possible here.', 13, 10
1027 db ' Boot your favourite OS and restore/overwrite the MBR manually.', 13, 10
1028 db ' As for DOS/Windows 9x: enter "FDISK /MBR" in commandline.', 13, 10
1029 db ' As for OS/2: enter "FDISK /MBR" or "LVM /NEWMBR:1" in commandline.', 13, 10
1030 db ' For other OSes, please consult the corresponding manual.', 13, 10
1031 db 13, 10, 0
1032
1033MBR_AiRBOOTCodeSig db 'AiRBOOT'
1034MBR_AiRBOOTCodeSigLen equ 7
1035MBR_EZSETUPCodeSig db '528+Mbyte(C)1993,94 Micro House Int',39,'l',0
1036MBR_EZSETUPCodeSigLen equ 38
1037MBR_AiRBOOTConfigSig db 'AiRCFG-TABLE­' ; Contains invisible 0adh character !
1038MBR_AiRBOOTConfigSigLen equ 13
1039
1040; ===============================================================> Variables...
1041iStatus_Code db 0 ; Status of each component
1042iStatus_Config db 0
1043
1044InstalledVersion_Code dw 0 ; Version of each installed component
1045InstalledVersion_Config dw 0
1046InstalledLanguageID db 0 ; Language ID of installed AiR-BOOT
1047
1048ImageVersion dw 0 ; Version of the Image contained
1049ImageLanguageID db 0 ; Language ID of Image contained
1050
1051
1052Option_ForceCode db 0 ; Request to write code anytime
1053Option_ForceConfig db 0 ; Request to write config anytime
1054Option_Silent db 0 ; Request for silent operation
1055
1056Install_Code db 0 ; What Installation has to be done...
1057Install_Config db 0 ; Set to 1, if component not available or defect
1058Install_IsCorrupt db 0 ; Is anything defect ? (Add/Repair-Switch)
1059
1060Impossible_Cause dw 0 ; Offset to text-message, why Impossible Status
1061
1062Status_NotInstalled equ 0 ; No ID found
1063Status_Corrupt equ 1 ; ID found, Checksum failure
1064Status_Installed equ 2 ; ID found, Checksum valid
1065Status_InstalledMGU equ 3 ; ID, Checksum, may get updated
1066Status_Impossible equ 4 ; Unable/Not willing to install
1067
1068; Layout of AiR-BOOT bootcode image
1069; ---------------------------
1070; | 1 | Master Boot Record | Code
1071; | 2 | System-Table | Code
1072; | 3 | Code | Code
1073; | .. | ... | Code
1074; | 55 | Configuration | Config
1075; | 56 | Partitiontable 1 | Config
1076; | 57 | Partitiontable 2 | Config
1077; | 58 | Hide-Partitiontable| Config
1078; | 59 | Hide-Partitiontable| Config
1079; | 60 | Backup of our MBR | Config
1080; ---------------------------
1081
Note: See TracBrowser for help on using the repository browser.