Проблема с защищенным режимом.

Тема в разделе "WASM.OS.DEVEL", создана пользователем erzik, 10 фев 2007.

  1. rain

    rain New Member

    Публикаций:
    0
    Регистрация:
    22 апр 2006
    Сообщения:
    976
    сорри, задал вопрос, и через минуту нашёл на него ответ :)
     
  2. rain

    rain New Member

    Публикаций:
    0
    Регистрация:
    22 апр 2006
    Сообщения:
    976
    кста вот вопрос, начало бутсектора на winxp:
    Код (Text):
    1. seg000:0000                 xor     ax, ax
    2. seg000:0002
    3. seg000:0002 loc_2:
    4. seg000:0002                 mov     ss, ax
    5. seg000:0004                 mov     sp, 7C00h
    6. seg000:0007                 sti
    7. seg000:0008                 push    ax
    8. seg000:0009                 pop     es
    9. seg000:000A                 push    ax
    10. seg000:000B                 pop     ds
    11. seg000:000C                 cld
    12. seg000:000D                 mov     si, 7C1Bh ; ?
    13. seg000:0010                 mov     di, 61Bh
    14. seg000:0013                 push    ax
    15. seg000:0014                 push    di
    16. seg000:0015                 mov     cx, 1E5h
    17. seg000:0018                 rep movsb
    18. seg000:001A                 retf
    что находится по этому адресу?
     
  3. wasm_test

    wasm_test wasm test user

    Публикаций:
    0
    Регистрация:
    24 ноя 2006
    Сообщения:
    5.582
    Во-первых, поставь базу 7C00
    7c1b указывает сразу за команду последнюю retf (ее адрес 7c1a)
    Все тело программы за RETF'ом релоцируется с адреса 7c1b на адрес 61b


    Сорс MBR под NT4 с комментами (оригинальный). Может, комментарит тебе прояснят ситуацию:
    Код (Text):
    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.  
    18. relocated_org   equ 0600h
    19. buildtime_org   equ 0100h
    20. org_delta       equ (relocated_org - buildtime_org)
    21.  
    22. _data   segment public
    23.         assume  cs:_data,ds:_data
    24.  
    25. ;
    26. ; /tiny programs start at 100h.
    27. ;
    28.  
    29.         org buildtime_org
    30. start:
    31.  
    32.         cli             ;no interrupts for now
    33.         xor ax,ax
    34.         mov ss,ax
    35.         mov sp,7c00h    ;new stack at 0:7c00
    36.         mov si,sp       ;where this boot record starts - 0:7c00
    37.         push ax
    38.         pop es          ;seg regs the same
    39.         push ax
    40.         pop ds
    41.         sti             ;interrupts ok now
    42.         cld
    43.         mov di,relocated_org ;where to relocate this boot record to
    44.         mov cx,100h
    45.         rep movsw       ;relocate to 0:0600
    46. ;       jmp entry2 + org_delta
    47.         db   0eah
    48.         dw   $+4+org_delta,0
    49. entry2:
    50.         mov si,(offset tab) + org_delta  ;partition table
    51.         mov bl,4        ;number of table entries
    52. next:
    53.         cmp byte ptr[si],80h  ;is this a bootable entry?
    54.         je boot         ;yes
    55.         cmp byte ptr[si],0    ;no, is boot indicator zero?
    56.         jne bad         ;no, it must be x"00" or x"80" to be valid
    57.         add si,16       ;yes, go to next entry
    58.         dec bl
    59.         jnz next
    60.         int 18h         ;no bootable entries - go to rom basic
    61. boot:
    62.         mov dx,[si]     ;head and drive to boot from
    63.         mov cx,[si+2]   ;cyl, sector to boot from
    64.         mov bp,si       ;save table entry address to pass to partition boot record
    65. next1:
    66.         add si,16       ;next table entry
    67.         dec bl          ;# entries left
    68.         jz tabok        ;all entries look ok
    69.         cmp byte ptr[si],0    ;all remaining entries should begin with zero
    70.         je next1        ;this one is ok
    71. bad:
    72.         mov si,(offset m1) + org_delta ;oops - found a non-zero entry - the table is bad
    73. msg:
    74.         lodsb           ;get a message character
    75.         cmp al,0
    76.         je  hold
    77.         push si
    78.         mov bx,7
    79.         mov ah,14
    80.         int 10h         ;and display it
    81.         pop si
    82.         jmp msg         ;do the entire message
    83. ;
    84. hold:   jmp hold        ;spin here - nothing more to do
    85. tabok:
    86.         mov di,5        ;retry count
    87. rdboot:
    88.         mov bx,7c00h    ;where to read system boot record
    89.         mov ax,0201h    ;read 1 sector
    90.         push di
    91.         int 13h         ;get the boot record
    92.         pop di
    93.         jnc goboot      ;successful - now give it control
    94.         xor ax,ax       ;had an error, so
    95.         int 13h         ;recalibrate
    96.         dec di          ;reduce retry count
    97.         jnz rdboot      ;if retry count above zero, go retry
    98.         mov si,(offset m2) + org_delta ;all retries done - permanent error - point to message,
    99.         jmp msg          ;go display message and loop
    100. goboot:
    101.         mov si,(offset m3) + org_delta ;prepare for invalid boot record
    102.         mov di,07dfeh
    103.         cmp word ptr [di],0aa55h ;does the boot record have the
    104.                                    ;    required signature?
    105.         jne msg         ;no, display invalid system boot record message
    106.         mov si,bp       ;yes, pass partition table entry address
    107.         db 0eah
    108.         dw 7c00h,0
    109.  
    110. include x86mboot.msg
    111.  
    112.         org 2beh
    113. tab:                    ;partition table
    114.         dw 0,0          ;partition 1 begin
    115.         dw 0,0          ;partition 1 end
    116.         dw 0,0          ;partition 1 relative sector (low, high parts)
    117.         dw 0,0          ;partition 1 # of sectors (low, high parts)
    118.         dw 0,0          ;partition 2 begin
    119.         dw 0,0          ;partition 2 end
    120.         dw 0,0          ;partition 2 relative sector
    121.         dw 0,0          ;partition 2 # of sectors
    122.         dw 0,0          ;partition 3 begin
    123.         dw 0,0          ;partition 3 end
    124.         dw 0,0          ;partition 3 relative sector
    125.         dw 0,0          ;partition 3 # of sectors
    126.         dw 0,0          ;partition 4 begin
    127.         dw 0,0          ;partition 4 end
    128.         dw 0,0          ;partition 4 relative sector
    129.         dw 0,0          ;partition 4 # of sectors
    130. signa   db 55h,0aah     ;signature
    131.  
    132. _data   ends
    133.         end  start
     
  4. rain

    rain New Member

    Публикаций:
    0
    Регистрация:
    22 апр 2006
    Сообщения:
    976
    очень даже прояснил, а можно узанать где сорец взял?
     
  5. wasm_test

    wasm_test wasm test user

    Публикаций:
    0
    Регистрация:
    24 ноя 2006
    Сообщения:
    5.582
    rain
    полные исходники NT4 у меня на винте пылятся)
    В сумме с доступными уже почти каждому сорсами Win2k дает неплохой результат в понимании работы всей линейки NT. Благо разница с XP не такая уж и огромная.
     
  6. St

    St New Member

    Публикаций:
    0
    Регистрация:
    11 авг 2006
    Сообщения:
    72
    Это про ReactOS?
     
  7. wasm_test

    wasm_test wasm test user

    Публикаций:
    0
    Регистрация:
    24 ноя 2006
    Сообщения:
    5.582
    это про полные исходные коды Windows NT4 и частичные коды Windows 2000.

    Про ReactOS я не заикался вообще