| 1 | ; AiR-BOOT (c) Copyright 1998-2008 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 | ;                         AiR-BOOT SETUP / GENERIC & GENERAL SETUP ROUTINES | 
|---|
| 20 | ;--------------------------------------------------------------------------- | 
|---|
| 21 | ; | 
|---|
| 22 | ; First define processor so when a model is specified | 
|---|
| 23 | ; the correct default segments are created. | 
|---|
| 24 | ; | 
|---|
| 25 | .286 | 
|---|
| 26 |  | 
|---|
| 27 | ; Tasm needs a memory model for USES on PROC to work. | 
|---|
| 28 | IFDEF   TASM | 
|---|
| 29 | ;~ .model large, basic | 
|---|
| 30 | .model  tiny,c | 
|---|
| 31 | ENDIF | 
|---|
| 32 |  | 
|---|
| 33 | ;_TEXT           SEGMENT     USE16   PUBLIC  'CODE' | 
|---|
| 34 | ;_TEXT           ENDS | 
|---|
| 35 |  | 
|---|
| 36 | MBRPROT         GROUP       CODE_SEG | 
|---|
| 37 | ;DGROUP          GROUP       CODE_SEG | 
|---|
| 38 |  | 
|---|
| 39 | CODE_SEG        SEGMENT     USE16   PUBLIC  'CODE' | 
|---|
| 40 |  | 
|---|
| 41 | ;assume cs:MBRPROT, ds:MBRPROT, es:nothing, ss:nothing | 
|---|
| 42 | assume cs:MBRPROT, ds:MBRPROT, es:nothing, ss:nothing | 
|---|
| 43 |  | 
|---|
| 44 | org 0000h | 
|---|
| 45 | ;.386p | 
|---|
| 46 | ;.286 | 
|---|
| 47 |  | 
|---|
| 48 | ; | 
|---|
| 49 | ; Storage for old interrupt vectors. | 
|---|
| 50 | ; | 
|---|
| 51 | OldInterrupt10  dd      0 | 
|---|
| 52 | OldInterrupt13  dd      0 | 
|---|
| 53 |  | 
|---|
| 54 | MBR_IgnoreWrite db      0 | 
|---|
| 55 |  | 
|---|
| 56 | MBRP_Routine: | 
|---|
| 57 | cmp     ah, 03h | 
|---|
| 58 | je      MBRP_NormalWriteTest | 
|---|
| 59 | cmp     ah, 0Bh | 
|---|
| 60 | je      MBRP_NormalWriteTest | 
|---|
| 61 | cmp     ah, 43h | 
|---|
| 62 | je      MBRP_ExtendedWriteTest | 
|---|
| 63 | MBRP_ResumeCall: | 
|---|
| 64 | jmp     dword ptr cs:[OldInterrupt13] | 
|---|
| 65 |  | 
|---|
| 66 | MBRP_NormalWriteTest: | 
|---|
| 67 | cmp     ch, 0 | 
|---|
| 68 | jne     MBRP_ResumeCall | 
|---|
| 69 | cmp     dh, 0 | 
|---|
| 70 | jne     MBRP_ResumeCall | 
|---|
| 71 | ; We don't mind which sector, AiR-BOOT is everywhere ;-) | 
|---|
| 72 | test    dl, 80h | 
|---|
| 73 | jz      MBRP_ResumeCall | 
|---|
| 74 | jmp     MBRP_FakeOkay | 
|---|
| 75 |  | 
|---|
| 76 | MBRP_ExtendedWriteTest: | 
|---|
| 77 | cmp     word ptr ds:[si+0Eh], 0 | 
|---|
| 78 | jne     MBRP_ResumeCall | 
|---|
| 79 | cmp     word ptr ds:[si+0Ch], 0 | 
|---|
| 80 | jne     MBRP_ResumeCall | 
|---|
| 81 | cmp     word ptr ds:[si+0Ah], 0 | 
|---|
| 82 | jne     MBRP_ResumeCall | 
|---|
| 83 | cmp     word ptr ds:[si+08h], 63  ; If Logical Block-Number =>63 | 
|---|
| 84 | jae     MBRP_ResumeCall | 
|---|
| 85 | jmp     MBRP_FakeOkay | 
|---|
| 86 |  | 
|---|
| 87 | MBRP_FakeOkay: | 
|---|
| 88 | test    cs:[MBR_IgnoreWrite], 1 | 
|---|
| 89 | jz      MBRP_CrunchSession | 
|---|
| 90 | xor     ah, ah | 
|---|
| 91 | clc | 
|---|
| 92 | retf 2 | 
|---|
| 93 |  | 
|---|
| 94 | MBRP_CrunchSession: | 
|---|
| 95 | ; We are ruining registers here, but we won't get back to caller... | 
|---|
| 96 | mov     ax, 03h                        ; Graphic: Set Mode 3 | 
|---|
| 97 | pushf | 
|---|
| 98 | call    dword ptr cs:[OldInterrupt10] | 
|---|
| 99 |  | 
|---|
| 100 | mov     ax, cs | 
|---|
| 101 | mov     ds, ax | 
|---|
| 102 | mov     ax, 0B800h | 
|---|
| 103 | mov     es, ax | 
|---|
| 104 | xor     di, di | 
|---|
| 105 | mov     ax, 4F20h | 
|---|
| 106 | mov     cx, 2000h                       ; Clears whole screen (using RED) | 
|---|
| 107 | rep     stosw | 
|---|
| 108 |  | 
|---|
| 109 | mov     si, offset MBRP_Line1 | 
|---|
| 110 | mov     di, 1120 | 
|---|
| 111 | call    MBRProt_WriteBorderLine | 
|---|
| 112 | mov     cx, 4 | 
|---|
| 113 | call    MBRProt_WriteLine | 
|---|
| 114 | mov     si, offset MBRP_EmptyLine | 
|---|
| 115 | mov     cx, 1 | 
|---|
| 116 | call    MBRProt_WriteLine | 
|---|
| 117 | mov     si, offset MBRP_Line2 | 
|---|
| 118 | mov     cx, 3 | 
|---|
| 119 | call    MBRProt_WriteLine | 
|---|
| 120 | mov     si, offset MBRP_EmptyLine | 
|---|
| 121 | mov     cx, 1 | 
|---|
| 122 | call    MBRProt_WriteLine | 
|---|
| 123 | mov     si, offset MBRP_Line3 | 
|---|
| 124 | call    MBRProt_WriteBorderLine | 
|---|
| 125 |  | 
|---|
| 126 | mov     ax, 8600h | 
|---|
| 127 | xor     cx, cx | 
|---|
| 128 | mov     dx, 500 | 
|---|
| 129 | int     15h                             ; Wait for display... | 
|---|
| 130 | WindowsProcessing: | 
|---|
| 131 | cli | 
|---|
| 132 | jmp     WindowsProcessing | 
|---|
| 133 |  | 
|---|
| 134 | MBRProt_WriteLine              Proc Near    Uses ax bx cx dx | 
|---|
| 135 | add     di, 26 | 
|---|
| 136 | mov     ah, 4Ch                      ; red/brightred | 
|---|
| 137 | lodsb | 
|---|
| 138 | stosw | 
|---|
| 139 | mov     ah, 4Fh                      ; red/brightwhite | 
|---|
| 140 | mov     dx, 53 | 
|---|
| 141 | MBRP_WriteChar: | 
|---|
| 142 | lodsb | 
|---|
| 143 | stosw | 
|---|
| 144 | dec     dx | 
|---|
| 145 | jnz     MBRP_WriteChar | 
|---|
| 146 | mov     ah, 4Ch                      ; red/brightred | 
|---|
| 147 | lodsb | 
|---|
| 148 | stosw | 
|---|
| 149 | add     di, 24 | 
|---|
| 150 | dec     cx | 
|---|
| 151 | jnz     MBRProt_WriteLine | 
|---|
| 152 | ret | 
|---|
| 153 | MBRProt_WriteLine              EndP | 
|---|
| 154 |  | 
|---|
| 155 | MBRProt_WriteBorderLine        Proc Near | 
|---|
| 156 | add     di, 26 | 
|---|
| 157 | mov     ah, 4Ch | 
|---|
| 158 | mov     dx, 55 | 
|---|
| 159 | MBRP_WriteBorderChar: | 
|---|
| 160 | lodsb | 
|---|
| 161 | stosw | 
|---|
| 162 | dec     dx | 
|---|
| 163 | jnz     MBRP_WriteBorderChar | 
|---|
| 164 | add     di, 24 | 
|---|
| 165 | ret | 
|---|
| 166 | MBRProt_WriteBorderLine        EndP | 
|---|
| 167 |  | 
|---|
| 168 | MBRP_Line1      db      'ÕÍÍŽ!ATTENTION! -> A V1RU5 WAS FOUND <- !ATTENTION!ÃÍÍž' | 
|---|
| 169 | MBRP_EmptyLine  db      '³                                                     ³' | 
|---|
| 170 | db      '³ A program tried to write to your Master Boot Record ³' | 
|---|
| 171 | db      '³     AiR-BOOT supposes this as a viral act, so it    ³' | 
|---|
| 172 | db      '³        intercepted it and crashed the system.       ³' | 
|---|
| 173 | MBRP_Line2      db      '³ If you tried to install a OS or something like that ³' | 
|---|
| 174 | db      '³  you have to deactivate MBR PROTECTION in AiR-BOOT  ³' | 
|---|
| 175 | db      '³             or contact your supervisor.             ³' | 
|---|
| 176 | ;MBRP_Line3      db      'ÔÍÍÍŽAiR-BOOT (c) Copyright by M. Kiewitz 1999-2009ÃÍÍŸ' | 
|---|
| 177 | MBRP_Line3      db      'ÔÍÍÍŽAiR-BOOT (c) Copyright by M. Kiewitz 1999-2012ÃÍÍŸ' | 
|---|
| 178 |  | 
|---|
| 179 | xxx: | 
|---|
| 180 |  | 
|---|
| 181 | ;~ org             1019 | 
|---|
| 182 | org             763 | 
|---|
| 183 |  | 
|---|
| 184 | ; | 
|---|
| 185 | ; MBR-PROT signature at end. | 
|---|
| 186 | ; | 
|---|
| 187 | db  'MBRPI' | 
|---|
| 188 |  | 
|---|
| 189 | CODE_SEG        ENDS | 
|---|
| 190 | end | 
|---|