flat assembler
Message board for the users of flat assembler.

Index > OS Construction > why this code can run win2k8/win7, but not Winxp

Author
Thread Post new topic Reply to topic
pyq881120



Joined: 23 Nov 2011
Posts: 1
pyq881120 29 Nov 2011, 08:33
Hi everyone

I'm copy the MBR to Second sector, then build below code to bin, cover First sector, remain origin MBR Partition table info. this can normal boot win2k8/win7,but not Winxp。

Code:
  org 0h
start:

    xor    ax, ax
       mov    ds, ax
       mov    si, 7C00h
    mov    ax, 0600h
    mov    es, ax
       xor    di, di
       push   100h
 pop    cx

       rep    movsw

    mov eax, [ds:4Ch] ; 
    mov dword [es:int_13h], eax 
    mov word [ds:4Ch], int13_hook 
  mov word [ds:4Eh], es
   pop ds 

 sti
 
    push   es
   mov    ax,next
      push   ax
   retf
next:
   push    dx
  mov     dx, 0
       mov     es, dx
      pop     dx
  mov     cx, 2
       mov     ax, 201h                ; sector 1
  mov     dl, 80h
     mov     bx, 7c00h
   int     13h
 jmp word 0x0000:0x07c00

int13_hook:

       db 0xea
int_13h: dw 0 ; offset
dw  0 ; segment    


[Edit By Loco] Added code tags and moved to OS Construction by public demand (although I don't fully agree with the last action)
Post 29 Nov 2011, 08:33
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 29 Nov 2011, 11:00
Are you trying to run it in pMode ? By the way, I think you posted in a wrong section.
Post 29 Nov 2011, 11:00
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder 29 Nov 2011, 16:09
typedef wrote:
Are you trying to run it in pMode ? By the way, I think you posted in a wrong section.
Looks more like bootloader code, trying to chain to previous bootloader code.

_________________
Image - carpe noctem
Post 29 Nov 2011, 16:09
View user's profile Send private message Visit poster's website Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 29 Nov 2011, 16:32
f0dder wrote:
typedef wrote:
Are you trying to run it in pMode ? By the way, I think you posted in a wrong section.
Looks more like bootloader code, trying to chain to previous bootloader code.


oh yeah. I see the org.

But yeah, wrong section I think
Post 29 Nov 2011, 16:32
View user's profile Send private message Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 517
Location: Munich
shutdownall 29 Nov 2011, 20:22
pyq881120 wrote:
Hi everyone

I'm copy the MBR to Second sector, then build below code to bin, cover First sector, remain origin MBR Partition table info. this can normal boot win2k8/win7,but not Winxp


Are you sure, you let run the same code on all systems ?
Do you test with different PC's or do you have all 3 operating systems on the same PC with partitions ?

The code looks like it's not working at all, when compiling there is an error shown at "jmp word 0x0000:0x07c00". I think the size of int13hook is too small. And you do a POP DS without pushing something.

Did you write the code yourself ? Looks like copied from different sources. Rolling Eyes

Why do you jump after loading the code and why do a retf with the stack ?
By the way, you don't init the stack (SS / SP) which is not a good programming style and can cause side effects.

And what do you want to do ? I think INT13 from BIOS is used for bootloader only. Operating system will use ATAPI interface with in/out or memory mapped i/o and not use BIOS interrupt.

Just my thoughts before spending too much time in a project ...
Post 29 Nov 2011, 20:22
View user's profile Send private message Send e-mail Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 517
Location: Munich
shutdownall 29 Nov 2011, 20:25
And yes, section is wrong.
Should be posted in OS construction ... (for bootloaders).
Post 29 Nov 2011, 20:25
View user's profile Send private message Send e-mail Reply with quote
mbr_tsr



Joined: 03 Apr 2011
Posts: 6424
mbr_tsr 03 Dec 2011, 02:21
ECS:EIP Ha ha i have DQ Double Quad Word Math U when you dq it splits the whole thing in half and flips it then splits each quarter in half and flips it then splits and flips again, dq 0xFFFFFFFFFFFFFFFF i cracked the 64 bit code you try to inc qword [cs:MyDQ] u can't unless you do the butterfly flip formula.
Post 03 Dec 2011, 02:21
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.