forked from ipxe/wimboot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wimboot-patch2.p1
92 lines (84 loc) · 2.56 KB
/
wimboot-patch2.p1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
---
--- wimbootorig/src/vdisk.h 2018-11-02 12:29:14.343297008 +0100
+++ wimboot/src/vdisk.h 2018-11-02 12:28:48.071166732 +0100
@@ -610,11 +610,15 @@
extern struct vdisk_file vdisk_files[VDISK_MAX_FILES];
+
extern void vdisk_read ( uint64_t lba, unsigned int count, void *data );
extern struct vdisk_file *
vdisk_add_file ( const char *name, void *opaque, size_t len,
void ( * read ) ( struct vdisk_file *file, void *data,
size_t offset, size_t len ) );
+
+extern void read_mem_file ( struct vdisk_file *file, void *data, size_t offset, size_t len );
+
extern void
vdisk_patch_file ( struct vdisk_file *file,
void ( * patch ) ( struct vdisk_file *file, void *data,
--- wimbootorig/src/vdisk.c 2018-11-02 12:29:14.343297008 +0100
+++ wimboot/src/vdisk.c 2018-11-02 12:28:48.071166732 +0100
@@ -614,6 +614,19 @@
}
/**
+ * Read from file
+ *
+ * @v file Virtual file
+ * @v data Data buffer
+ * @v offset Offset
+ * @v len Length
+ */
+void read_mem_file ( struct vdisk_file *file, void *data, size_t offset, size_t len ) {
+ memcpy ( data, ( file->opaque + offset ), len );
+}
+
+
+/**
* Add file to virtual disk
*
* @v name Name
--- wimbootorig/src/main.c 2018-11-02 12:29:14.343297008 +0100
+++ wimboot/src/main.c 2018-11-02 12:28:48.071166732 +0100
@@ -197,20 +197,6 @@
}
/**
- * Read from file
- *
- * @v file Virtual file
- * @v data Data buffer
- * @v offset Offset
- * @v len Length
- */
-static void read_file ( struct vdisk_file *file, void *data, size_t offset,
- size_t len ) {
-
- memcpy ( data, ( file->opaque + offset ), len );
-}
-
-/**
* Add embedded bootmgr.exe extracted from bootmgr
*
* @v data File data
@@ -305,8 +291,7 @@
decompress ( compressed, compressed_len, initrd );
/* Add decompressed image */
- return vdisk_add_file ( "bootmgr.exe", initrd,
- decompressed_len, read_file );
+ return vdisk_add_file ( "bootmgr.exe", initrd, decompressed_len, read_mem_file );
}
DBG ( "...no embedded bootmgr.exe found\n" );
@@ -325,7 +310,7 @@
struct vdisk_file *file;
/* Store file */
- file = vdisk_add_file ( name, data, len, read_file );
+ file = vdisk_add_file ( name, data, len, read_mem_file );
/* Check for special-case files */
if ( strcasecmp ( name, "bootmgr.exe" ) == 0 ) {
@@ -378,7 +363,7 @@
/* Read bootmgr.exe into memory */
if ( ! bootmgr )
die ( "FATAL: no bootmgr.exe\n" );
- if ( bootmgr->read == read_file ) {
+ if ( bootmgr->read == read_mem_file ) {
raw_pe = bootmgr->opaque;
} else {
padded_len = ( ( bootmgr->len + PAGE_SIZE - 1 ) &