Creating bootable image for VirtualBox

huangapple go评论60阅读模式
英文:

Creating bootable image for VirtualBox

问题

I need just welcome message printed.

There are some hints on this forum, however it's hard to put all up together.

So I've created a mininmal .asm similar to this one

[ORG 0x7c00] 
BITS 16

main:
mov ax, 0x07C0
mov ds, ax
mov es, ax

mov bp, message
mov bh, 0
mov bl, 00001111b

mov cx, 13
mov al, 1

mov ah, 0x13
mov dx, 0
int 0x10

cli
hlt

jmp $

message db "Hello, World!"
length db (length - message)

times 510-($-$$) db 0
dw 0xaa55

Build:

nasm -f bin sboot.asm -o sboot.bin
dd if=sboot.bin of=sboot.img bs=512 count=1 conv=notrunc

And convert IMG file to ISO with program CDBurnerXP. I am using 'Boot options...' and select:

  • Emulation type = Diskette 1.44MB (boot image 95/98/ME)
  • Load segment = 7c0
  • Sectors: 1
  • Platform: x86-64
    I also add dummy txt file, so that the ISO is not empty and save everything as ISO file.

Then I try to run it in Virtual Box with minimum options (disabled: audio, network, USB) and it crashes. Container goes into status 'Aborted'

Log from VirtualBox says nothing particular:

00:00:06.813147 PDMLdr: pdmR3LoadR0U: pszName="VMMR0.r0" rc=VERR_LDR_GENERAL_FAILURE szErr="SUP_IOCTL_LDR_OPEN failed"
00:00:06.813197 VMSetError: F:\tinderbox\win-rel\src\VBox\VMM\VMMR3\PDMLdr.cpp(750) int __cdecl pdmR3LoadR0U(struct UVM *,const char *,const char *,const char *); rc=VERR_LDR_GENERAL_FAILURE
00:00:06.813199 VMSetError: Failed to load R0 module C:\Program Files\Oracle\VirtualBox/VMMR0.r0: SUP_IOCTL_LDR_OPEN failed
00:00:06.813209 VMSetError: F:\tinderbox\win-rel\src\VBox\VMM\VMMR3\VM.cpp(585) int __cdecl vmR3CreateU(struct UVM *,unsigned int,int (__cdecl *)(struct UVM *,struct VM *,const struct VMMR3VTABLE *,void *) noexcept,void *); rc=VERR_LDR_GENERAL_FAILURE
00:00:06.813212 VMSetError: Failed to load VMMR0.r0
00:00:06.813425 ERROR [COM]: aRC=E_FAIL (0x80004005) aIID={6ac83d89-6ee7-4e33-8ae6-b257b2e81be8} aComponent={ConsoleWrap} aText={Failed to load R0 module C:\Program Files\Oracle\VirtualBox/VMMR0.r0: SUP_IOCTL_LDR_OPEN failed (VERR_LDR_GENERAL_FAILURE).
00:00:06.813445 Failed to load VMMR0.r0 (VERR_LDR_GENERAL_FAILURE)}, preserve=false aResultDetail=-618
00:00:06.813679 Console: Machine state changed to 'PoweredOff'
00:00:06.980955 Power up failed (vrc=VERR_LDR_GENERAL_FAILURE, rc=E_FAIL (0X80004005))
00:00:06.984607 GUI: UIMachineViewNormal::resendSizeHint: Restoring guest size-hint for screen 0 to 800x600

Any idea what went wrong?

英文:

I need just welcome message printed.

There are some hints on this forum, however it's hard to put all up together.

So I've created a mininmal .asm similar to this one

[ORG 0x7c00]   
BITS 16

main:
                mov ax, 0x07C0                                  
                mov ds, ax         
                mov es, ax         

                mov bp, message    
                mov bh, 0          
                mov bl, 00001111b  
                                   
                mov cx, 13         
                mov al, 1          
                                   
                mov ah, 0x13       
                mov dx, 0          
                int 0x10           

				cli
				hlt
				
                jmp $

message     db      "Hello, World!"
length      db      (length - message)
                             
times   510-($-$$) db 0
dw      0xaa55           

Build:

nasm -f bin sboot.asm -o sboot.bin
dd if=sboot.bin of=sboot.img bs=512 count=1 conv=notrunc

And convert IMG file to ISO with program CDBurnerXP. I am using 'Boot options...' and select:

  • Emulation type = Diskette 1.44MB (boot image 95/98/ME)
  • Load segment = 7c0
  • Sectors: 1
  • Platform: x86-64
    I also add dummy txt file, so that the ISO is not empty and save everything as ISO file.

Then I try to run it in Virtual Box with minimum options (disabled: audio, network, USB) and it crashes. Container goes into status 'Aborted'

Log from VirtualBox says nothing particular:

00:00:06.813147 PDMLdr: pdmR3LoadR0U: pszName="VMMR0.r0" rc=VERR_LDR_GENERAL_FAILURE szErr="SUP_IOCTL_LDR_OPEN failed"
00:00:06.813197 VMSetError: F:\tinderbox\win-rel\src\VBox\VMM\VMMR3\PDMLdr.cpp(750) int __cdecl pdmR3LoadR0U(struct UVM *,const char *,const char *,const char *); rc=VERR_LDR_GENERAL_FAILURE
00:00:06.813199 VMSetError: Failed to load R0 module C:\Program Files\Oracle\VirtualBox/VMMR0.r0: SUP_IOCTL_LDR_OPEN failed
00:00:06.813209 VMSetError: F:\tinderbox\win-rel\src\VBox\VMM\VMMR3\VM.cpp(585) int __cdecl vmR3CreateU(struct UVM *,unsigned int,int (__cdecl *)(struct UVM *,struct VM *,const struct VMMR3VTABLE *,void *) noexcept,void *); rc=VERR_LDR_GENERAL_FAILURE
00:00:06.813212 VMSetError: Failed to load VMMR0.r0
00:00:06.813425 ERROR [COM]: aRC=E_FAIL (0x80004005) aIID={6ac83d89-6ee7-4e33-8ae6-b257b2e81be8} aComponent={ConsoleWrap} aText={Failed to load R0 module C:\Program Files\Oracle\VirtualBox/VMMR0.r0: SUP_IOCTL_LDR_OPEN failed (VERR_LDR_GENERAL_FAILURE).
00:00:06.813445 Failed to load VMMR0.r0 (VERR_LDR_GENERAL_FAILURE)}, preserve=false aResultDetail=-618
00:00:06.813679 Console: Machine state changed to 'PoweredOff'
00:00:06.980955 Power up failed (vrc=VERR_LDR_GENERAL_FAILURE, rc=E_FAIL (0X80004005))
00:00:06.984607 GUI: UIMachineViewNormal::resendSizeHint: Restoring guest size-hint for screen 0 to 800x600

Any idea what went wrong?

答案1

得分: 3

Your setup for DS and ES does not match the ORG setting!

If you use [ORG 0x7c00], then you have to set DS=0 and ES=0.
Since you only use the BIOS function 13h that depends on ES:BP, setting up ES would be enough:

xor ax, ax
mov es, ax
英文:

> [ORG 0x7c00]
> BITS 16
>
> main:
> mov ax, 0x07C0
> mov ds, ax
> mov es, ax

Your setup for DS and ES does not match the ORG settting!

If you use [ORG 0x7c00], then you have to set DS=0 and ES=0.
Since you only use the BIOS function 13h that depends on ES:BP, setting up ES would be enough:

xor  ax, ax
mov  es, ax

huangapple
  • 本文由 发表于 2023年5月7日 20:22:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76193895.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定