Windows NT 4.0 source code leak
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 lines
4.5 KiB

4 years ago
  1. ;/*
  2. ; * Microsoft Confidential
  3. ; * Copyright (C) Microsoft Corporation 1983 - 1991
  4. ; * All Rights Reserved.
  5. ; */
  6. ; BOOT - IBM hard disk boot record 6/8/82
  7. ;
  8. ;
  9. ; This is the standard boot record that will be shipped on all hard disks. It contains:
  10. ;
  11. ; 1. Code to load (and give control to) the boot record for 1 of 4 possible
  12. ; operating systems.
  13. ;
  14. ; 2. A partition table at the end of the boot record, followed by the required signature.
  15. ;
  16. ;
  17. relocated_org equ 0600h
  18. buildtime_org equ 0100h
  19. org_delta equ (relocated_org - buildtime_org)
  20. _data segment public
  21. assume cs:_data,ds:_data
  22. ;
  23. ; /tiny programs start at 100h.
  24. ;
  25. org buildtime_org
  26. start:
  27. cli ;no interrupts for now
  28. xor ax,ax
  29. mov ss,ax
  30. mov sp,7c00h ;new stack at 0:7c00
  31. mov si,sp ;where this boot record starts - 0:7c00
  32. push ax
  33. pop es ;seg regs the same
  34. push ax
  35. pop ds
  36. sti ;interrupts ok now
  37. cld
  38. mov di,relocated_org ;where to relocate this boot record to
  39. mov cx,100h
  40. rep movsw ;relocate to 0:0600
  41. ; jmp entry2 + org_delta
  42. db 0eah
  43. dw $+4+org_delta,0
  44. entry2:
  45. mov si,(offset tab) + org_delta ;partition table
  46. mov bl,4 ;number of table entries
  47. next:
  48. cmp byte ptr[si],80h ;is this a bootable entry?
  49. je boot ;yes
  50. cmp byte ptr[si],0 ;no, is boot indicator zero?
  51. jne bad ;no, it must be x"00" or x"80" to be valid
  52. add si,16 ;yes, go to next entry
  53. dec bl
  54. jnz next
  55. int 18h ;no bootable entries - go to rom basic
  56. boot:
  57. mov dx,[si] ;head and drive to boot from
  58. mov cx,[si+2] ;cyl, sector to boot from
  59. mov bp,si ;save table entry address to pass to partition boot record
  60. next1:
  61. add si,16 ;next table entry
  62. dec bl ;# entries left
  63. jz tabok ;all entries look ok
  64. cmp byte ptr[si],0 ;all remaining entries should begin with zero
  65. je next1 ;this one is ok
  66. bad:
  67. mov si,(offset m1) + org_delta ;oops - found a non-zero entry - the table is bad
  68. msg:
  69. lodsb ;get a message character
  70. cmp al,0
  71. je hold
  72. push si
  73. mov bx,7
  74. mov ah,14
  75. int 10h ;and display it
  76. pop si
  77. jmp msg ;do the entire message
  78. ;
  79. hold: jmp hold ;spin here - nothing more to do
  80. tabok:
  81. mov di,5 ;retry count
  82. rdboot:
  83. mov bx,7c00h ;where to read system boot record
  84. mov ax,0201h ;read 1 sector
  85. push di
  86. int 13h ;get the boot record
  87. pop di
  88. jnc goboot ;successful - now give it control
  89. xor ax,ax ;had an error, so
  90. int 13h ;recalibrate
  91. dec di ;reduce retry count
  92. jnz rdboot ;if retry count above zero, go retry
  93. mov si,(offset m2) + org_delta ;all retries done - permanent error - point to message,
  94. jmp msg ;go display message and loop
  95. goboot:
  96. mov si,(offset m3) + org_delta ;prepare for invalid boot record
  97. mov di,07dfeh
  98. cmp word ptr [di],0aa55h ;does the boot record have the
  99. ; required signature?
  100. jne msg ;no, display invalid system boot record message
  101. mov si,bp ;yes, pass partition table entry address
  102. db 0eah
  103. dw 7c00h,0
  104. include x86mboot.msg
  105. org 2beh
  106. tab: ;partition table
  107. dw 0,0 ;partition 1 begin
  108. dw 0,0 ;partition 1 end
  109. dw 0,0 ;partition 1 relative sector (low, high parts)
  110. dw 0,0 ;partition 1 # of sectors (low, high parts)
  111. dw 0,0 ;partition 2 begin
  112. dw 0,0 ;partition 2 end
  113. dw 0,0 ;partition 2 relative sector
  114. dw 0,0 ;partition 2 # of sectors
  115. dw 0,0 ;partition 3 begin
  116. dw 0,0 ;partition 3 end
  117. dw 0,0 ;partition 3 relative sector
  118. dw 0,0 ;partition 3 # of sectors
  119. dw 0,0 ;partition 4 begin
  120. dw 0,0 ;partition 4 end
  121. dw 0,0 ;partition 4 relative sector
  122. dw 0,0 ;partition 4 # of sectors
  123. signa db 55h,0aah ;signature
  124. _data ends
  125. end start