Skip to content
This repository has been archived by the owner on Jun 28, 2023. It is now read-only.

Wimboot.mod in UEFI mode loads only first image in wim file when index is not 1. #99

Closed
rradjab opened this issue Mar 14, 2023 · 4 comments

Comments

@rradjab
Copy link

rradjab commented Mar 14, 2023

Wimboot.mod in UEFI mode loads only first image in wim file when index is not equals to 1. wimboot.xz used from grub2fm :)
Example code:

loopback -d loop
loopback loop (hd0,1)/winpe10.iso
wimboot --index=2 --testmode=no
@:bootmgfw.efi:(memdisk)/bootmgfw.efi
@:boot.wim:"(loop)/sources/boot.wim";
boot

1

please help.

@a1ive
Copy link
Owner

a1ive commented Mar 15, 2023

It‘s a bug introduced in wimboot v2.7.5.
See: ipxe/wimboot#40
Applying this patch and compiling, the problem should be fixed:
wimboot.patch

diff --git a/grub-core/map/lib/wim.c b/grub-core/map/lib/wim.c
index b61be90..ead6f91 100644
--- a/grub-core/map/lib/wim.c
+++ b/grub-core/map/lib/wim.c
@@ -296,7 +296,8 @@ int wim_count ( struct vfat_file *file, struct wim_header *header,
   int rc;
 
   /* Count metadata entries */
-  for ( offset = 0 ; ( offset + sizeof ( entry ) ) <= header->lookup.len ;
+  for ( offset = 0, *count = 0 ;
+        ( offset + sizeof ( entry ) ) <= header->lookup.len ;
         offset += sizeof ( entry ) ) {
 
     /* Read entry */
diff --git a/grub-core/map/lib/wimpatch.c b/grub-core/map/lib/wimpatch.c
index eb64840..cfd9528 100644
--- a/grub-core/map/lib/wimpatch.c
+++ b/grub-core/map/lib/wimpatch.c
@@ -688,6 +688,10 @@ static int wim_construct_patch ( struct vfat_file *file,
            &patch->boot ) ) != 0 )
     return rc;
 
+  /* Update boot image metadata in patched header, if applicable */
+  if ( boot_index )
+    memcpy ( boot, &patch->boot, sizeof ( *boot ) );
+
   /* Record original boot index */
   patch->boot_index = patch->header.boot_index;
 

As I am no longer maintaining this project, I will not update it to fix this bug.

@rradjab
Copy link
Author

rradjab commented Mar 15, 2023

thank you for quick answer and help!
can you please help to get wimboot.mod for UEFI for x86_64-efi and i386-efi please?

@a1ive
Copy link
Owner

a1ive commented Mar 15, 2023

thank you for quick answer and help! can you please help to get wimboot.mod for UEFI for x86_64-efi and i386-efi please?

https://github.com/a1ive/grub/releases/tag/latest

@rradjab
Copy link
Author

rradjab commented Mar 15, 2023

thank you very much, you are genius!
i've tested and it already working!!!

@rradjab rradjab closed this as completed Mar 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants