Jump to content











Photo
- - - - -

Chaining to ReactOS


  • Please log in to reply
12 replies to this topic

#1 Sha0

Sha0

    WinVBlock Dev

  • Developer
  • 1682 posts
  • Location:reboot.pro Forums
  • Interests:Booting
  •  
    Canada

Posted 01 May 2011 - 06:30 PM

I have added an option to chain-load ReactOS' FreeLdr from Syslinux using the chain.c32 COMBOOT32 module. Until it has been committed to the main Syslinux branch, I have attached the modified chain.c32 to this post.

You can use it by including the following in your syslinux.cfg or pxelinux.cfg/default config-file:

LABEL freeldr

  COM32 chain.c32

  APPEND freeldr=freeldr.sys keeppxe

With very special thanks to Hervé Poussineau for recently adding PXE as a FreeLdr filesystem type, you can use net(0) in the ARC path in your FreeLdr.ini file:

...

[ReactOS]

BootType=Windows2003

SystemPath=ramdisk(0)\reactos

Options=/DEBUGPORT=COM1 /SOS /MININT /RDPATH=net(0)\ReactOS-LiveCD.iso


Unfortunately, there is currently a RAM disk regression in ReactOS, but it is good to be able to chain FreeLdr anyway.

Attached Files



#2 roytam1

roytam1

    Member

  • Developer
  • 99 posts
  •  
    Hong Kong

Posted 02 May 2011 - 09:01 AM

no source code available?

#3 Sha0

Sha0

    WinVBlock Dev

  • Developer
  • 1682 posts
  • Location:reboot.pro Forums
  • Interests:Booting
  •  
    Canada

Posted 02 May 2011 - 01:13 PM

no source code available?

It's been added to Syslinux proper now, courtesy of H. Peter Anvin. Source code here.

Now as a matter of fact, he has added the ability to choose segment, offset, and entry point for arbitrary binaries (see the seg= option). :dubbio: Please use with extreme caution.

#4 ireneuszp

ireneuszp

    Frequent Member

  • Advanced user
  • 191 posts
  •  
    Poland

Posted 04 May 2011 - 10:28 PM

why I can't chaining to ReactOS from grub4dos


title ReactOS (freeldr.sys)\n Uruchamia FreeLoader from ReactOS (freeldr.sys)...

	find --set-root /freeldr.sys

	uuid ()

	kernel /freeldr.sys


I have only black screen :buehehe:

#5 Sha0

Sha0

    WinVBlock Dev

  • Developer
  • 1682 posts
  • Location:reboot.pro Forums
  • Interests:Booting
  •  
    Canada

Posted 04 May 2011 - 10:36 PM

why I can't chaining to ReactOS from grub4dos

Oops. Wrong forum for that. :buehehe:

#6 roytam1

roytam1

    Member

  • Developer
  • 99 posts
  •  
    Hong Kong

Posted 05 May 2011 - 12:10 PM

@ireneuszp:
You may try the following:
chainloader --force --load-offset=0x8000 --boot-ip=0x9000 /freeldr.sys
but the --boot-ip value may change in the future.

@Sha0:
You may look for ROS's boot sector for better loading freeldr:
FoundFreeLoader:

		; We found freeldr.sys on the disk

		; so we need to load the first 512

		; bytes of it to 0000:8000

        ; ES:DI has dir entry (ES:DI == 07E0:XXXX)

        mov  ax,WORD [es:di+1ah]				; Get start cluster

		push ax									; Save start cluster

		push WORD 800h							; Put 800h on the stack and load it

		pop  es									; Into ES so that we load the cluster at 0000:8000

		call ReadCluster						; Read the cluster

		pop  ax									; Restore start cluster of FreeLoader



		; Save the addresses of needed functions so

		; the helper code will know where to call them.

		mov  WORD [BYTE bp-ReadSectorsOffset],ReadSectors		; Save the address of ReadSectors

		mov  WORD [BYTE bp-ReadClusterOffset],ReadCluster		; Save the address of ReadCluster

		mov  WORD [BYTE bp-PutCharsOffset],PutChars				; Save the address of PutChars



		; Now AX has start cluster of FreeLoader and we

		; have loaded the helper code in the first 512 bytes

		; of FreeLoader to 0000:8000. Now transfer control

		; to the helper code. Skip the first three bytes

		; because they contain a jump instruction to skip

		; over the helper code in the FreeLoader image.

		;jmp  0000:9003h

		push 0						; push segment (0x0000)

		mov bx, [0x8000 + 0xA8]		; load the RVA of the EntryPoint into eax

		add bx, 0x8003				; RVA -> VA and skip 3 bytes (jump to fathelper code)

		push bx						; push offset

		retf						; Transfer control to FreeLoader



#7 roytam1

roytam1

    Member

  • Developer
  • 99 posts
  •  
    Hong Kong

Posted 05 May 2011 - 02:07 PM

The above code is for FAT16.
for others:
LoadFileDone:

        mov  dl,[BYTE bp+BootDrive]		; Load boot drive into DL

		mov  dh,[BootPartition]			; Load boot partition into DH



		push 0						; push segment (0x0000)

		mov eax, [0x8000 + 0xA8]	; load the RVA of the EntryPoint into eax

		add eax, 0x8000				; RVA -> VA

		push ax						; push offset

		retf						; Transfer control to FreeLoader



#8 roytam1

roytam1

    Member

  • Developer
  • 99 posts
  •  
    Hong Kong

Posted 05 May 2011 - 02:11 PM

@ireneuszp: a new grub4dos patch is uploaded to google code. http://code.google.c...es/detail?id=24

#9 roytam1

roytam1

    Member

  • Developer
  • 99 posts
  •  
    Hong Kong

Posted 06 May 2011 - 07:20 AM

@ireneuszp: a new grub4dos patch is uploaded to google code. http://code.google.c...es/detail?id=24

And was applied.
http://code.google.c...-06.7z&can=2&q=

#10 Max_Real Qnx

Max_Real Qnx

    Gold Member

  • Patrician
  • 1382 posts
  • Location:Istanbul
  • Interests:To be or not to be that is the question.
  •  
    Turkey

Posted 15 May 2011 - 11:59 AM

And was applied.
http://code.google.c...-06.7z&can=2&q=


Hi roytam1 :cheers:

Thank you very much for your excellent work and tips. Best regards :thumbsup:

#11 Sha0

Sha0

    WinVBlock Dev

  • Developer
  • 1682 posts
  • Location:reboot.pro Forums
  • Interests:Booting
  •  
    Canada

Posted 15 May 2011 - 12:44 PM

@ireneuszp:
You may try the following:

chainloader --force --load-offset=0x8000 --boot-ip=0x9000 /freeldr.sys
but the --boot-ip value may change in the future.

That's nice, but... It's off-topic. The topic is Syslinux. :ranting2:

@Sha0:
You may look for ROS's boot sector for better loading freeldr:

What do you mean by "better"? That's nice of you to share the ReactOS source code, but... The chain.c32 code was inspired by ReactOS source code, so I don't understand your suggestion. :)

#12 roytam1

roytam1

    Member

  • Developer
  • 99 posts
  •  
    Hong Kong

Posted 15 May 2011 - 12:49 PM

That's nice, but... It's off-topic. The topic is Syslinux. :ranting2:


What do you mean by "better"? That's nice of you to share the ReactOS source code, but... The chain.c32 code was inspired by ReactOS source code, so I don't understand your suggestion. :)

to fix a TODO in the code:
+ /* TODO: Properly parse the PE. Right now, this is hard-coded */

#13 Icecube

Icecube

    Gold Member

  • Team Reboot
  • 1063 posts
  •  
    Belgium

Posted 26 July 2011 - 07:21 AM

freeldr.sys and setupldr.sys of ReactOS are now multiboot compliant (in the last test versions).

Syslinux:
LABEL reactos

MENU LABEL Boot ReactOS

COM32 mboot.c32

APPEND /freeldr.sys



LABEL reactos_install

MENU LABEL Install ReactOS

COM32 mboot.c32

APPEND /loader/setupldr.sys
Grub4dos:
title Boot ReactOS

kernel /freeldr.sys



title Install ReactOS

kernel /loader/setupldr.sys
So the need for ugly hacks is gone.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users