|
|
1.1 root 1: ;
2: ; Copyright (c) 2008 TrueCrypt Foundation. All rights reserved.
3: ;
4: ; Governed by the TrueCrypt License 2.4 the full text of which is contained
5: ; in the file License.txt included in TrueCrypt binary and source code
6: ; distribution packages.
7: ;
8:
9: .MODEL tiny
10: .386
11: _TEXT SEGMENT
12:
13: INCLUDE BootDefs.i
14:
15: ORG 7C00h ; Boot sector offset
16:
17: start:
18: ; BIOS executes boot sector from 0:7C00 or 7C0:0000 (default CD boot loader address).
19: ; Far jump to the next instruction ensures the offset matches the ORG directive.
20: db 0EAh ; jmp 0:main
21: dw main, 0
22:
23: db 'TrueCrypt'
24:
25: main:
1.1.1.2 ! root 26: xor ax, ax
1.1 root 27: mov ds, ax
28:
29: lea si, intro_msg
30: call print
31:
32: mov ax, TC_BOOT_LOADER_SEGMENT
33: mov es, ax ; Default load segment
34:
35: ; Check available memory
1.1.1.2 ! root 36: cmp word ptr [ds:413h], TC_BOOT_LOADER_SEGMENT / 1024 * 16 + TC_BOOT_MEMORY_REQUIRED
1.1 root 37: jge clear_memory
38:
39: ; Insufficient memory
40: mov ax, TC_BOOT_LOADER_LOWMEM_SEGMENT
41: mov es, ax
42:
43: ; Ensure clear BSS section
44: clear_memory:
45: xor al, al
46: mov di, TC_BOOT_LOADER_OFFSET
47: mov cx, TC_BOOT_MEMORY_REQUIRED * 1024 - 1
1.1.1.2 ! root 48: cld
1.1 root 49: rep stosb
50:
51: ; Read boot loader
52: mov bx, TC_BOOT_LOADER_OFFSET
53: mov ch, 0 ; Cylinder
54: mov dh, 0 ; Head
55: mov cl, 2 ; Sector
56: mov al, TC_BOOT_LOADER_AREA_SECTOR_COUNT - 2
57: ; DL = drive number passed from BIOS
58: mov ah, 2
59: int 13h
60: jnc exec_loader
61:
62: lea si, read_error_msg
63: call print
64: jmp $
65:
66: ; Execute boot loader
67: exec_loader:
68:
69: ; DH = boot sector flags
70: mov dh, byte ptr [start + TC_BOOT_SECTOR_CONFIG_OFFSET]
71:
72: mov ax, es
73: mov ds, ax
74: cli
75: mov ss, ax
1.1.1.2 ! root 76: mov sp, TC_BOOT_MEMORY_REQUIRED * 1024 - 4
1.1 root 77: sti
78:
79: mov word ptr [cs:jump_seg], es
80:
81: db 0EAh ; jmp TC_BOOT_LOADER_SEGMENT:TC_BOOT_LOADER_OFFSET
82: dw TC_BOOT_LOADER_OFFSET
83: jump_seg:
84: dw TC_BOOT_LOADER_SEGMENT
85:
86: ; Print string
87: print:
88: xor bx, bx
89: mov ah, 0eh
90:
91: @@: lodsb
92: test al, al
93: jz print_end
94:
95: int 10h
96: jmp @B
97:
98: print_end:
99: ret
100:
101: intro_msg db 13, 10, "TrueCrypt Boot Loader", 13, 10, 0
102: read_error_msg db "Disk read error", 13, 10, 7, 0
103:
104: db 508 - ($ - start) dup (0)
105: dw 0, 0AA55h ; Boot sector signature
106:
107: _TEXT ENDS
108: END start
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.