mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-09-18 18:01:14 +00:00
Compare commits
50 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
537f0eaa7e | ||
|
c8cf9b7ce2 | ||
|
4c71d7c190 | ||
|
47f9f2c42c | ||
|
fc3a5fae36 | ||
|
b3982d4930 | ||
|
c280baae27 | ||
|
425d640480 | ||
|
07d4140cf4 | ||
|
90ae07d227 | ||
|
e3e21eb6e6 | ||
|
c8ce2ae85a | ||
|
c02a6955c3 | ||
|
6b78603dd3 | ||
|
07a386c963 | ||
|
eb048c0075 | ||
|
37ac3f312f | ||
|
092cff8429 | ||
|
b347c1b5da | ||
|
da746c608f | ||
|
81aa56955a | ||
|
d1679871a6 | ||
|
f383052013 | ||
|
667f5bcc1b | ||
|
af69cb7f44 | ||
|
7bb13fc18a | ||
|
7fce7e0aba | ||
|
2a435084c2 | ||
|
c0c454a436 | ||
|
63924fa8bd | ||
|
3e47f5e8de | ||
|
b5eb347244 | ||
|
9225c940a6 | ||
|
a8edb99d28 | ||
|
ac3ab97686 | ||
|
c42a8c6d93 | ||
|
4b1dd4d3af | ||
|
f342be1d6c | ||
|
f4774ee0e4 | ||
|
d3cfa73631 | ||
|
331080fb95 | ||
|
99fbd14f08 | ||
|
1c5aeb35dc | ||
|
f7b3bd1729 | ||
|
672632a0c2 | ||
|
d07aa6ce07 | ||
|
93996cf7e2 | ||
|
ca62128f9b | ||
|
265b70f1c7 | ||
|
491f0bea8a |
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
blank_issues_enabled: false
|
85
.github/ISSUE_TEMPLATE/issue_template.yml
vendored
Normal file
85
.github/ISSUE_TEMPLATE/issue_template.yml
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
name: Issue Report
|
||||
description: File an issue report
|
||||
title: "[issue]: "
|
||||
assignees:
|
||||
- octocat
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to fill out this issue report!
|
||||
- type: checkboxes
|
||||
id: faq
|
||||
attributes:
|
||||
label: Official FAQ
|
||||
description: Have you checked the official FAQ at [https://www.ventoy.net/en/faq.html](https://www.ventoy.net/en/faq.html) ?
|
||||
options:
|
||||
- label: I have checked the official FAQ.
|
||||
required: true
|
||||
- type: input
|
||||
id: version
|
||||
attributes:
|
||||
label: Ventoy Version
|
||||
description: What version of ventoy are you running?
|
||||
placeholder: 1.0.46
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: latestrelease
|
||||
attributes:
|
||||
label: What about latest release
|
||||
description: Have you tried with the latest release of Ventoy?
|
||||
options:
|
||||
- Yes. I have tried the latest release, but the bug still exist.
|
||||
- No. I didn't try the latest release.
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: bios
|
||||
attributes:
|
||||
label: BIOS Mode
|
||||
description: In which BIOS mode did you find the bug?
|
||||
options:
|
||||
- Legacy BIOS Mode
|
||||
- UEFI Mode
|
||||
- Both
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: partstyle
|
||||
attributes:
|
||||
label: Partition Style
|
||||
description: Which partition style did you select when you install Ventoy?
|
||||
options:
|
||||
- MBR
|
||||
- GPT
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: capacity
|
||||
attributes:
|
||||
label: Disk Capacity
|
||||
description: What is the capacity of the disk installed with Ventoy?
|
||||
placeholder: 32GB
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: checksum
|
||||
attributes:
|
||||
label: Image file checksum (if applicable)
|
||||
description: Have you checked the image file in Ventoy's menu as [https://www.ventoy.net/en/faq.html#faq_boot_checksum](https://www.ventoy.net/en/faq.html#faq_boot_checksum) ?
|
||||
options:
|
||||
- Yes.
|
||||
- No.
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: what-happened
|
||||
attributes:
|
||||
label: What happened?
|
||||
description: Tell me what happened. It's highly recommended to include some photo or video about the bug.
|
||||
placeholder: Tell us what you see!
|
||||
value: "A bug happened!"
|
||||
validations:
|
||||
required: true
|
||||
|
@@ -148,7 +148,7 @@ STATIC EFI_STATUS EFIAPI ventoy_read_iso_sector
|
||||
ventoy_override_chunk *pOverride = g_override_chunk;
|
||||
EFI_BLOCK_IO_PROTOCOL *pRawBlockIo = gBlockData.pRawBlockIo;
|
||||
|
||||
debug("read iso sector %lu count %u", Sector, Count);
|
||||
debug("read iso sector %lu count %u Buffer:%p Align:%u", Sector, Count, Buffer, pRawBlockIo->Media->IoAlign);
|
||||
|
||||
ReadStart = Sector * 2048;
|
||||
ReadEnd = (Sector + Count) * 2048;
|
||||
@@ -173,7 +173,6 @@ STATIC EFI_STATUS EFIAPI ventoy_read_iso_sector
|
||||
{
|
||||
MapLba = ((Sector - pchunk->img_start_sector) >> 1) + pchunk->disk_start_sector;
|
||||
}
|
||||
|
||||
|
||||
secLeft = pchunk->img_end_sector + 1 - Sector;
|
||||
secRead = (Count < secLeft) ? Count : secLeft;
|
||||
@@ -182,7 +181,7 @@ STATIC EFI_STATUS EFIAPI ventoy_read_iso_sector
|
||||
MapLba, secRead * 2048, pCurBuf);
|
||||
if (EFI_ERROR(Status))
|
||||
{
|
||||
debug("Raw disk read block failed %r LBA:%lu Count:%u", Status, MapLba, secRead);
|
||||
debug("Raw disk read block failed %r LBA:%lu Count:%u %p", Status, MapLba, secRead, pCurBuf);
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -425,7 +424,7 @@ end:
|
||||
return Lba;
|
||||
}
|
||||
|
||||
EFI_STATUS EFIAPI ventoy_block_io_read
|
||||
EFI_STATUS EFIAPI ventoy_block_io_read_real
|
||||
(
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
||||
IN UINT32 MediaId,
|
||||
@@ -447,7 +446,7 @@ EFI_STATUS EFIAPI ventoy_block_io_read
|
||||
ventoy_sector_flag *cur_flag;
|
||||
ventoy_virt_chunk *node;
|
||||
|
||||
//debug("### ventoy_block_io_read sector:%u count:%u", (UINT32)Lba, (UINT32)BufferSize / 2048);
|
||||
debug("### block_io_read_real sector:%u count:%u Buffer:%p", (UINT32)Lba, (UINT32)BufferSize / 2048, Buffer);
|
||||
|
||||
secNum = BufferSize / 2048;
|
||||
|
||||
@@ -484,6 +483,8 @@ EFI_STATUS EFIAPI ventoy_block_io_read
|
||||
secNum = VirtSec - Lba;
|
||||
}
|
||||
|
||||
debug("XXX block_io_read_real sector:%u count:%u Buffer:%p", (UINT32)Lba, (UINT32)BufferSize / 2048, Buffer);
|
||||
|
||||
if (secNum > g_sector_flag_num)
|
||||
{
|
||||
cur_flag = AllocatePool(secNum * sizeof(ventoy_sector_flag));
|
||||
@@ -551,6 +552,42 @@ EFI_STATUS EFIAPI ventoy_block_io_read
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
EFI_STATUS EFIAPI ventoy_block_io_read
|
||||
(
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
||||
IN UINT32 MediaId,
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN BufferSize,
|
||||
OUT VOID *Buffer
|
||||
)
|
||||
{
|
||||
UINT32 IoAlign = 0;
|
||||
VOID *NewBuf = NULL;
|
||||
EFI_STATUS Status = EFI_OUT_OF_RESOURCES;
|
||||
|
||||
if (gBlockData.pRawBlockIo && gBlockData.pRawBlockIo->Media)
|
||||
{
|
||||
IoAlign = gBlockData.pRawBlockIo->Media->IoAlign;
|
||||
}
|
||||
|
||||
if ((IoAlign == 0) || (((UINTN) Buffer & (IoAlign - 1)) == 0))
|
||||
{
|
||||
Status = ventoy_block_io_read_real(This, MediaId, Lba, BufferSize, Buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
NewBuf = AllocatePages(EFI_SIZE_TO_PAGES(BufferSize + IoAlign));
|
||||
if (NewBuf)
|
||||
{
|
||||
Status = ventoy_block_io_read_real(This, MediaId, Lba, BufferSize, NewBuf);
|
||||
CopyMem(Buffer, NewBuf, BufferSize);
|
||||
FreePages(NewBuf, EFI_SIZE_TO_PAGES(BufferSize + IoAlign));
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
EFI_STATUS EFIAPI ventoy_block_io_write
|
||||
(
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
||||
@@ -720,7 +757,7 @@ EFI_STATUS EFIAPI ventoy_block_io_read_512
|
||||
UINT8 *CurBuf = NULL;
|
||||
EFI_STATUS Status = EFI_SUCCESS;
|
||||
|
||||
debug("ventoy_block_io_read_512 %lu %lu\n", Lba, BufferSize / 512);
|
||||
debug("ventoy_block_io_read_512 %lu %lu Buffer:%p\n", Lba, BufferSize / 512, Buffer);
|
||||
|
||||
CurBuf = (UINT8 *)Buffer;
|
||||
|
||||
|
343
GRUB2/MOD_SRC/grub-2.04/grub-core/commands/hashsum.c
Normal file
343
GRUB2/MOD_SRC/grub-2.04/grub-core/commands/hashsum.c
Normal file
@@ -0,0 +1,343 @@
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/dl.h>
|
||||
#include <grub/extcmd.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/crypto.h>
|
||||
#include <grub/normal.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
static const struct grub_arg_option options[] = {
|
||||
{"hash", 'h', 0, N_("Specify hash to use."), N_("HASH"), ARG_TYPE_STRING},
|
||||
{"check", 'c', 0, N_("Check hashes of files with hash list FILE."),
|
||||
N_("FILE"), ARG_TYPE_STRING},
|
||||
{"prefix", 'p', 0, N_("Base directory for hash list."), N_("DIR"),
|
||||
ARG_TYPE_STRING},
|
||||
{"keep-going", 'k', 0, N_("Don't stop after first error."), 0, 0},
|
||||
{"uncompress", 'u', 0, N_("Uncompress file before checksumming."), 0, 0},
|
||||
{0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
static struct { const char *name; const char *hashname; } aliases[] =
|
||||
{
|
||||
{"sha256sum", "sha256"},
|
||||
{"sha512sum", "sha512"},
|
||||
{"sha1sum", "sha1"},
|
||||
{"md5sum", "md5"},
|
||||
{"crc", "crc32"},
|
||||
};
|
||||
|
||||
static inline int
|
||||
hextoval (char c)
|
||||
{
|
||||
if (c >= '0' && c <= '9')
|
||||
return c - '0';
|
||||
if (c >= 'a' && c <= 'f')
|
||||
return c - 'a' + 10;
|
||||
if (c >= 'A' && c <= 'F')
|
||||
return c - 'A' + 10;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
hash_file (grub_file_t file, const gcry_md_spec_t *hash, void *result)
|
||||
{
|
||||
int progress = 0;
|
||||
grub_uint64_t ro = 0;
|
||||
grub_uint64_t div = 0;
|
||||
grub_uint64_t total = 0;
|
||||
void *context;
|
||||
grub_uint8_t *readbuf;
|
||||
#define BUF_SIZE 1024 * 1024
|
||||
readbuf = grub_malloc (BUF_SIZE);
|
||||
if (!readbuf)
|
||||
return grub_errno;
|
||||
context = grub_zalloc (hash->contextsize);
|
||||
if (!readbuf || !context)
|
||||
goto fail;
|
||||
|
||||
if (file->size > 16 * 1024 * 1024)
|
||||
progress = 1;
|
||||
|
||||
hash->init (context);
|
||||
while (1)
|
||||
{
|
||||
grub_ssize_t r;
|
||||
r = grub_file_read (file, readbuf, BUF_SIZE);
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
if (r == 0)
|
||||
break;
|
||||
hash->write (context, readbuf, r);
|
||||
if (progress)
|
||||
{
|
||||
total += r;
|
||||
div = grub_divmod64(total * 100, (grub_uint64_t)file->size, &ro);
|
||||
grub_printf("\rCalculating %d%% ", (int)div);
|
||||
grub_refresh();
|
||||
}
|
||||
}
|
||||
hash->final (context);
|
||||
grub_memcpy (result, hash->read (context), hash->mdlen);
|
||||
|
||||
grub_free (readbuf);
|
||||
grub_free (context);
|
||||
if (progress)
|
||||
{
|
||||
grub_printf("\rCalculating 100%% \n\r\n");
|
||||
grub_refresh();
|
||||
}
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
fail:
|
||||
grub_free (readbuf);
|
||||
grub_free (context);
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
check_list (const gcry_md_spec_t *hash, const char *hashfilename,
|
||||
const char *prefix, int keep, int uncompress)
|
||||
{
|
||||
grub_file_t hashlist, file;
|
||||
char *buf = NULL;
|
||||
grub_uint8_t expected[GRUB_CRYPTO_MAX_MDLEN];
|
||||
grub_uint8_t actual[GRUB_CRYPTO_MAX_MDLEN];
|
||||
grub_err_t err;
|
||||
unsigned i;
|
||||
unsigned unread = 0, mismatch = 0;
|
||||
|
||||
if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN)
|
||||
return grub_error (GRUB_ERR_BUG, "mdlen is too long");
|
||||
|
||||
hashlist = grub_file_open (hashfilename, GRUB_FILE_TYPE_HASHLIST);
|
||||
if (!hashlist)
|
||||
return grub_errno;
|
||||
|
||||
while (grub_free (buf), (buf = grub_file_getline (hashlist)))
|
||||
{
|
||||
const char *p = buf;
|
||||
while (grub_isspace (p[0]))
|
||||
p++;
|
||||
for (i = 0; i < hash->mdlen; i++)
|
||||
{
|
||||
int high, low;
|
||||
high = hextoval (*p++);
|
||||
low = hextoval (*p++);
|
||||
if (high < 0 || low < 0)
|
||||
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "invalid hash list");
|
||||
expected[i] = (high << 4) | low;
|
||||
}
|
||||
if ((p[0] != ' ' && p[0] != '\t') || (p[1] != ' ' && p[1] != '\t'))
|
||||
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "invalid hash list");
|
||||
p += 2;
|
||||
if (prefix)
|
||||
{
|
||||
char *filename;
|
||||
|
||||
filename = grub_xasprintf ("%s/%s", prefix, p);
|
||||
if (!filename)
|
||||
return grub_errno;
|
||||
file = grub_file_open (filename, GRUB_FILE_TYPE_TO_HASH
|
||||
| (!uncompress ? GRUB_FILE_TYPE_NO_DECOMPRESS
|
||||
: GRUB_FILE_TYPE_NONE));
|
||||
grub_free (filename);
|
||||
}
|
||||
else
|
||||
file = grub_file_open (p, GRUB_FILE_TYPE_TO_HASH
|
||||
| (!uncompress ? GRUB_FILE_TYPE_NO_DECOMPRESS
|
||||
: GRUB_FILE_TYPE_NONE));
|
||||
if (!file)
|
||||
{
|
||||
grub_file_close (hashlist);
|
||||
grub_free (buf);
|
||||
return grub_errno;
|
||||
}
|
||||
err = hash_file (file, hash, actual);
|
||||
grub_file_close (file);
|
||||
if (err)
|
||||
{
|
||||
grub_printf_ (N_("%s: READ ERROR\n"), p);
|
||||
if (!keep)
|
||||
{
|
||||
grub_file_close (hashlist);
|
||||
grub_free (buf);
|
||||
return err;
|
||||
}
|
||||
grub_print_error ();
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
unread++;
|
||||
continue;
|
||||
}
|
||||
if (grub_crypto_memcmp (expected, actual, hash->mdlen) != 0)
|
||||
{
|
||||
grub_printf_ (N_("%s: HASH MISMATCH\n"), p);
|
||||
if (!keep)
|
||||
{
|
||||
grub_file_close (hashlist);
|
||||
grub_free (buf);
|
||||
return grub_error (GRUB_ERR_TEST_FAILURE,
|
||||
"hash of '%s' mismatches", p);
|
||||
}
|
||||
mismatch++;
|
||||
continue;
|
||||
}
|
||||
grub_printf_ (N_("%s: OK\n"), p);
|
||||
}
|
||||
if (mismatch || unread)
|
||||
return grub_error (GRUB_ERR_TEST_FAILURE,
|
||||
"%d files couldn't be read and hash "
|
||||
"of %d files mismatches", unread, mismatch);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
|
||||
int argc, char **args)
|
||||
{
|
||||
struct grub_arg_list *state = ctxt->state;
|
||||
const char *hashname = NULL;
|
||||
const char *prefix = NULL;
|
||||
const gcry_md_spec_t *hash;
|
||||
unsigned i;
|
||||
int keep = state[3].set;
|
||||
int uncompress = state[4].set;
|
||||
unsigned unread = 0;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE (aliases); i++)
|
||||
if (grub_strcmp (ctxt->extcmd->cmd->name, aliases[i].name) == 0)
|
||||
hashname = aliases[i].hashname;
|
||||
if (state[0].set)
|
||||
hashname = state[0].arg;
|
||||
|
||||
if (!hashname)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no hash specified");
|
||||
|
||||
hash = grub_crypto_lookup_md_by_name (hashname);
|
||||
if (!hash)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "unknown hash");
|
||||
|
||||
if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN)
|
||||
return grub_error (GRUB_ERR_BUG, "mdlen is too long");
|
||||
|
||||
if (state[2].set)
|
||||
prefix = state[2].arg;
|
||||
|
||||
if (state[1].set)
|
||||
{
|
||||
if (argc != 0)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"--check is incompatible with file list");
|
||||
return check_list (hash, state[1].arg, prefix, keep, uncompress);
|
||||
}
|
||||
|
||||
for (i = 0; i < (unsigned) argc; i++)
|
||||
{
|
||||
GRUB_PROPERLY_ALIGNED_ARRAY (result, GRUB_CRYPTO_MAX_MDLEN);
|
||||
grub_file_t file;
|
||||
grub_err_t err;
|
||||
unsigned j;
|
||||
file = grub_file_open (args[i], GRUB_FILE_TYPE_TO_HASH
|
||||
| (!uncompress ? GRUB_FILE_TYPE_NO_DECOMPRESS
|
||||
: GRUB_FILE_TYPE_NONE));
|
||||
if (!file)
|
||||
{
|
||||
if (!keep)
|
||||
return grub_errno;
|
||||
grub_print_error ();
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
unread++;
|
||||
continue;
|
||||
}
|
||||
err = hash_file (file, hash, result);
|
||||
grub_file_close (file);
|
||||
if (err)
|
||||
{
|
||||
if (!keep)
|
||||
return err;
|
||||
grub_print_error ();
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
unread++;
|
||||
continue;
|
||||
}
|
||||
for (j = 0; j < hash->mdlen; j++)
|
||||
grub_printf ("%02x", ((grub_uint8_t *) result)[j]);
|
||||
grub_printf (" %s\n", args[i]);
|
||||
}
|
||||
|
||||
if (unread)
|
||||
return grub_error (GRUB_ERR_TEST_FAILURE, "%d files couldn't be read",
|
||||
unread);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_extcmd_t cmd, cmd_md5, cmd_sha1, cmd_sha256, cmd_sha512, cmd_crc;
|
||||
|
||||
GRUB_MOD_INIT(hashsum)
|
||||
{
|
||||
cmd = grub_register_extcmd ("hashsum", grub_cmd_hashsum, 0,
|
||||
N_("-h HASH [-c FILE [-p PREFIX]] "
|
||||
"[FILE1 [FILE2 ...]]"),
|
||||
/* TRANSLATORS: "hash checksum" is just to
|
||||
be a bit more precise, you can treat it as
|
||||
just "hash". */
|
||||
N_("Compute or check hash checksum."),
|
||||
options);
|
||||
cmd_md5 = grub_register_extcmd ("md5sum", grub_cmd_hashsum, 0,
|
||||
N_("[-c FILE [-p PREFIX]] "
|
||||
"[FILE1 [FILE2 ...]]"),
|
||||
N_("Compute or check hash checksum."),
|
||||
options);
|
||||
cmd_sha1 = grub_register_extcmd ("sha1sum", grub_cmd_hashsum, 0,
|
||||
N_("[-c FILE [-p PREFIX]] "
|
||||
"[FILE1 [FILE2 ...]]"),
|
||||
N_("Compute or check hash checksum."),
|
||||
options);
|
||||
cmd_sha256 = grub_register_extcmd ("sha256sum", grub_cmd_hashsum, 0,
|
||||
N_("[-c FILE [-p PREFIX]] "
|
||||
"[FILE1 [FILE2 ...]]"),
|
||||
N_("Compute or check hash checksum."),
|
||||
options);
|
||||
cmd_sha512 = grub_register_extcmd ("sha512sum", grub_cmd_hashsum, 0,
|
||||
N_("[-c FILE [-p PREFIX]] "
|
||||
"[FILE1 [FILE2 ...]]"),
|
||||
N_("Compute or check hash checksum."),
|
||||
options);
|
||||
|
||||
cmd_crc = grub_register_extcmd ("crc", grub_cmd_hashsum, 0,
|
||||
N_("[-c FILE [-p PREFIX]] "
|
||||
"[FILE1 [FILE2 ...]]"),
|
||||
N_("Compute or check hash checksum."),
|
||||
options);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(hashsum)
|
||||
{
|
||||
grub_unregister_extcmd (cmd);
|
||||
grub_unregister_extcmd (cmd_md5);
|
||||
grub_unregister_extcmd (cmd_sha1);
|
||||
grub_unregister_extcmd (cmd_sha256);
|
||||
grub_unregister_extcmd (cmd_sha512);
|
||||
grub_unregister_extcmd (cmd_crc);
|
||||
}
|
@@ -29,6 +29,7 @@
|
||||
extern int g_ventoy_memdisk_mode;
|
||||
extern int g_ventoy_iso_raw;
|
||||
extern int g_ventoy_grub2_mode;
|
||||
extern int g_ventoy_wimboot_mode;
|
||||
extern int g_ventoy_iso_uefi_drv;
|
||||
|
||||
static const char *align_options[] =
|
||||
@@ -209,6 +210,9 @@ label_set_property (void *vself, const char *name, const char *value)
|
||||
else if (grub_strcmp (value, "@VTOY_GRUB2_MODE@") == 0) {
|
||||
value = g_ventoy_grub2_mode ? grub_env_get("VTOY_GRUB2_MODE_STR") : " ";
|
||||
}
|
||||
else if (grub_strcmp (value, "@VTOY_WIMBOOT_MODE@") == 0) {
|
||||
value = g_ventoy_wimboot_mode ? grub_env_get("VTOY_WIMBOOT_MODE_STR") : " ";
|
||||
}
|
||||
else if (grub_strcmp (value, "@VTOY_ISO_UEFI_DRV@") == 0) {
|
||||
value = g_ventoy_iso_uefi_drv ? grub_env_get("VTOY_ISO_UEFI_DRV_STR") : " ";
|
||||
}
|
||||
|
@@ -964,3 +964,20 @@ void * grub_efi_allocate_iso_buf(grub_uint64_t size)
|
||||
|
||||
return (void *)(unsigned long)address;
|
||||
}
|
||||
|
||||
void * grub_efi_allocate_chain_buf(grub_uint64_t size)
|
||||
{
|
||||
grub_efi_boot_services_t *b;
|
||||
grub_efi_status_t status;
|
||||
grub_efi_physical_address_t address = 0;
|
||||
grub_efi_uintn_t pages = GRUB_EFI_BYTES_TO_PAGES(size);
|
||||
|
||||
b = grub_efi_system_table->boot_services;
|
||||
status = efi_call_4 (b->allocate_pages, GRUB_EFI_ALLOCATE_ANY_PAGES, GRUB_EFI_LOADER_DATA, pages, &address);
|
||||
if (status != GRUB_EFI_SUCCESS)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (void *)(unsigned long)address;
|
||||
}
|
||||
|
316
GRUB2/MOD_SRC/grub-2.04/grub-core/loader/linux.c
Normal file
316
GRUB2/MOD_SRC/grub-2.04/grub-core/loader/linux.c
Normal file
@@ -0,0 +1,316 @@
|
||||
#include <grub/types.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/linux.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/term.h>
|
||||
|
||||
struct newc_head
|
||||
{
|
||||
char magic[6];
|
||||
char ino[8];
|
||||
char mode[8];
|
||||
char uid[8];
|
||||
char gid[8];
|
||||
char nlink[8];
|
||||
char mtime[8];
|
||||
char filesize[8];
|
||||
char devmajor[8];
|
||||
char devminor[8];
|
||||
char rdevmajor[8];
|
||||
char rdevminor[8];
|
||||
char namesize[8];
|
||||
char check[8];
|
||||
} GRUB_PACKED;
|
||||
|
||||
struct grub_linux_initrd_component
|
||||
{
|
||||
grub_file_t file;
|
||||
char *newc_name;
|
||||
grub_off_t size;
|
||||
};
|
||||
|
||||
struct dir
|
||||
{
|
||||
char *name;
|
||||
struct dir *next;
|
||||
struct dir *child;
|
||||
};
|
||||
|
||||
static char
|
||||
hex (grub_uint8_t val)
|
||||
{
|
||||
if (val < 10)
|
||||
return '0' + val;
|
||||
return 'a' + val - 10;
|
||||
}
|
||||
|
||||
static void
|
||||
set_field (char *var, grub_uint32_t val)
|
||||
{
|
||||
int i;
|
||||
char *ptr = var;
|
||||
for (i = 28; i >= 0; i -= 4)
|
||||
*ptr++ = hex((val >> i) & 0xf);
|
||||
}
|
||||
|
||||
static grub_uint8_t *
|
||||
make_header (grub_uint8_t *ptr,
|
||||
const char *name, grub_size_t len,
|
||||
grub_uint32_t mode,
|
||||
grub_off_t fsize)
|
||||
{
|
||||
struct newc_head *head = (struct newc_head *) ptr;
|
||||
grub_uint8_t *optr;
|
||||
grub_size_t oh = 0;
|
||||
grub_memcpy (head->magic, "070701", 6);
|
||||
set_field (head->ino, 0);
|
||||
set_field (head->mode, mode);
|
||||
set_field (head->uid, 0);
|
||||
set_field (head->gid, 0);
|
||||
set_field (head->nlink, 1);
|
||||
set_field (head->mtime, 0);
|
||||
set_field (head->filesize, fsize);
|
||||
set_field (head->devmajor, 0);
|
||||
set_field (head->devminor, 0);
|
||||
set_field (head->rdevmajor, 0);
|
||||
set_field (head->rdevminor, 0);
|
||||
set_field (head->namesize, len);
|
||||
set_field (head->check, 0);
|
||||
optr = ptr;
|
||||
ptr += sizeof (struct newc_head);
|
||||
grub_memcpy (ptr, name, len);
|
||||
ptr += len;
|
||||
oh = ALIGN_UP_OVERHEAD (ptr - optr, 4);
|
||||
grub_memset (ptr, 0, oh);
|
||||
ptr += oh;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
static void
|
||||
free_dir (struct dir *root)
|
||||
{
|
||||
if (!root)
|
||||
return;
|
||||
free_dir (root->next);
|
||||
free_dir (root->child);
|
||||
grub_free (root->name);
|
||||
grub_free (root);
|
||||
}
|
||||
|
||||
static grub_size_t
|
||||
insert_dir (const char *name, struct dir **root,
|
||||
grub_uint8_t *ptr)
|
||||
{
|
||||
struct dir *cur, **head = root;
|
||||
const char *cb, *ce = name;
|
||||
grub_size_t size = 0;
|
||||
while (1)
|
||||
{
|
||||
for (cb = ce; *cb == '/'; cb++);
|
||||
for (ce = cb; *ce && *ce != '/'; ce++);
|
||||
if (!*ce)
|
||||
break;
|
||||
|
||||
for (cur = *root; cur; cur = cur->next)
|
||||
if (grub_memcmp (cur->name, cb, ce - cb)
|
||||
&& cur->name[ce - cb] == 0)
|
||||
break;
|
||||
if (!cur)
|
||||
{
|
||||
struct dir *n;
|
||||
n = grub_zalloc (sizeof (*n));
|
||||
if (!n)
|
||||
return 0;
|
||||
n->next = *head;
|
||||
n->name = grub_strndup (cb, ce - cb);
|
||||
if (ptr)
|
||||
{
|
||||
grub_dprintf ("linux", "Creating directory %s, %s\n", name, ce);
|
||||
ptr = make_header (ptr, name, ce - name,
|
||||
040777, 0);
|
||||
}
|
||||
size += ALIGN_UP ((ce - (char *) name)
|
||||
+ sizeof (struct newc_head), 4);
|
||||
*head = n;
|
||||
cur = n;
|
||||
}
|
||||
root = &cur->next;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_initrd_init (int argc, char *argv[],
|
||||
struct grub_linux_initrd_context *initrd_ctx)
|
||||
{
|
||||
int i;
|
||||
int newc = 0;
|
||||
struct dir *root = 0;
|
||||
|
||||
initrd_ctx->nfiles = 0;
|
||||
initrd_ctx->components = 0;
|
||||
|
||||
initrd_ctx->components = grub_zalloc (argc
|
||||
* sizeof (initrd_ctx->components[0]));
|
||||
if (!initrd_ctx->components)
|
||||
return grub_errno;
|
||||
|
||||
initrd_ctx->size = 0;
|
||||
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
const char *fname = argv[i];
|
||||
|
||||
initrd_ctx->size = ALIGN_UP (initrd_ctx->size, 4);
|
||||
|
||||
if (grub_memcmp (argv[i], "newc:", 5) == 0)
|
||||
{
|
||||
const char *ptr, *eptr;
|
||||
ptr = argv[i] + 5;
|
||||
while (*ptr == '/')
|
||||
ptr++;
|
||||
eptr = grub_strchr (ptr, ':');
|
||||
if (eptr)
|
||||
{
|
||||
initrd_ctx->components[i].newc_name = grub_strndup (ptr, eptr - ptr);
|
||||
if (!initrd_ctx->components[i].newc_name)
|
||||
{
|
||||
grub_initrd_close (initrd_ctx);
|
||||
return grub_errno;
|
||||
}
|
||||
initrd_ctx->size
|
||||
+= ALIGN_UP (sizeof (struct newc_head)
|
||||
+ grub_strlen (initrd_ctx->components[i].newc_name),
|
||||
4);
|
||||
initrd_ctx->size += insert_dir (initrd_ctx->components[i].newc_name,
|
||||
&root, 0);
|
||||
newc = 1;
|
||||
fname = eptr + 1;
|
||||
}
|
||||
}
|
||||
else if (newc)
|
||||
{
|
||||
initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head)
|
||||
+ sizeof ("TRAILER!!!") - 1, 4);
|
||||
free_dir (root);
|
||||
root = 0;
|
||||
newc = 0;
|
||||
}
|
||||
initrd_ctx->components[i].file = grub_file_open (fname,
|
||||
GRUB_FILE_TYPE_LINUX_INITRD
|
||||
| GRUB_FILE_TYPE_NO_DECOMPRESS);
|
||||
if (!initrd_ctx->components[i].file)
|
||||
{
|
||||
grub_initrd_close (initrd_ctx);
|
||||
return grub_errno;
|
||||
}
|
||||
initrd_ctx->nfiles++;
|
||||
initrd_ctx->components[i].size
|
||||
= grub_file_size (initrd_ctx->components[i].file);
|
||||
initrd_ctx->size += initrd_ctx->components[i].size;
|
||||
}
|
||||
|
||||
if (newc)
|
||||
{
|
||||
initrd_ctx->size = ALIGN_UP (initrd_ctx->size, 4);
|
||||
initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head)
|
||||
+ sizeof ("TRAILER!!!") - 1, 4);
|
||||
free_dir (root);
|
||||
root = 0;
|
||||
}
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
grub_size_t
|
||||
grub_get_initrd_size (struct grub_linux_initrd_context *initrd_ctx)
|
||||
{
|
||||
return initrd_ctx->size;
|
||||
}
|
||||
|
||||
void
|
||||
grub_initrd_close (struct grub_linux_initrd_context *initrd_ctx)
|
||||
{
|
||||
int i;
|
||||
if (!initrd_ctx->components)
|
||||
return;
|
||||
for (i = 0; i < initrd_ctx->nfiles; i++)
|
||||
{
|
||||
grub_free (initrd_ctx->components[i].newc_name);
|
||||
grub_file_close (initrd_ctx->components[i].file);
|
||||
}
|
||||
grub_free (initrd_ctx->components);
|
||||
initrd_ctx->components = 0;
|
||||
}
|
||||
|
||||
extern int ventoy_need_prompt_load_file(void);
|
||||
extern grub_ssize_t ventoy_load_file_with_prompt(grub_file_t file, void *buf, grub_ssize_t size);
|
||||
grub_err_t
|
||||
grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx,
|
||||
char *argv[], void *target)
|
||||
{
|
||||
grub_uint8_t *ptr = target;
|
||||
int i;
|
||||
int newc = 0;
|
||||
struct dir *root = 0;
|
||||
grub_ssize_t cursize = 0;
|
||||
grub_ssize_t readsize = 0;
|
||||
|
||||
for (i = 0; i < initrd_ctx->nfiles; i++)
|
||||
{
|
||||
grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4));
|
||||
ptr += ALIGN_UP_OVERHEAD (cursize, 4);
|
||||
|
||||
if (initrd_ctx->components[i].newc_name)
|
||||
{
|
||||
ptr += insert_dir (initrd_ctx->components[i].newc_name,
|
||||
&root, ptr);
|
||||
ptr = make_header (ptr, initrd_ctx->components[i].newc_name,
|
||||
grub_strlen (initrd_ctx->components[i].newc_name),
|
||||
0100777,
|
||||
initrd_ctx->components[i].size);
|
||||
newc = 1;
|
||||
}
|
||||
else if (newc)
|
||||
{
|
||||
ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!") - 1,
|
||||
0, 0);
|
||||
free_dir (root);
|
||||
root = 0;
|
||||
newc = 0;
|
||||
}
|
||||
|
||||
cursize = initrd_ctx->components[i].size;
|
||||
if (ventoy_need_prompt_load_file() && initrd_ctx->components[i].newc_name &&
|
||||
grub_strcmp(initrd_ctx->components[i].newc_name, "boot.wim") == 0)
|
||||
{
|
||||
readsize = ventoy_load_file_with_prompt(initrd_ctx->components[i].file, ptr, cursize);
|
||||
}
|
||||
else
|
||||
{
|
||||
readsize = grub_file_read (initrd_ctx->components[i].file, ptr, cursize);
|
||||
}
|
||||
|
||||
if (readsize != cursize)
|
||||
{
|
||||
if (!grub_errno)
|
||||
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
|
||||
argv[i]);
|
||||
grub_initrd_close (initrd_ctx);
|
||||
return grub_errno;
|
||||
}
|
||||
ptr += cursize;
|
||||
}
|
||||
if (newc)
|
||||
{
|
||||
grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4));
|
||||
ptr += ALIGN_UP_OVERHEAD (cursize, 4);
|
||||
ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!") - 1, 0, 0);
|
||||
}
|
||||
free_dir (root);
|
||||
root = 0;
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
@@ -38,6 +38,7 @@ int g_ventoy_menu_refresh = 0;
|
||||
int g_ventoy_memdisk_mode = 0;
|
||||
int g_ventoy_iso_raw = 0;
|
||||
int g_ventoy_grub2_mode = 0;
|
||||
int g_ventoy_wimboot_mode = 0;
|
||||
int g_ventoy_iso_uefi_drv = 0;
|
||||
int g_ventoy_last_entry = -1;
|
||||
int g_ventoy_suppress_esc = 0;
|
||||
@@ -904,6 +905,12 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
|
||||
g_ventoy_menu_refresh = 1;
|
||||
goto refresh;
|
||||
|
||||
case (GRUB_TERM_CTRL | 'w'):
|
||||
menu_fini ();
|
||||
g_ventoy_wimboot_mode = 1 - g_ventoy_wimboot_mode;
|
||||
g_ventoy_menu_refresh = 1;
|
||||
goto refresh;
|
||||
|
||||
case (GRUB_TERM_CTRL | 'u'):
|
||||
menu_fini ();
|
||||
g_ventoy_iso_uefi_drv = 1 - g_ventoy_iso_uefi_drv;
|
||||
|
@@ -462,6 +462,8 @@ static int lzx_uncompressed ( struct lzx *lzx ) {
|
||||
if ( len % 2 )
|
||||
lzx->input.offset++;
|
||||
|
||||
lzx->output.offset += len;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -614,7 +616,7 @@ ssize_t lzx_decompress ( const void *data, size_t len, void *buf ) {
|
||||
/* Sanity check */
|
||||
if ( len % 2 ) {
|
||||
DBG ( "LZX cannot handle odd-length input data\n" );
|
||||
return -1;
|
||||
//return -1;
|
||||
}
|
||||
|
||||
/* Initialise global state, if required */
|
||||
|
@@ -127,16 +127,21 @@ static grub_uint64_t g_enumerate_start_time_ms;
|
||||
static grub_uint64_t g_enumerate_finish_time_ms;
|
||||
static int g_vtoy_file_flt[VTOY_FILE_FLT_BUTT] = {0};
|
||||
|
||||
static const char *g_vtoy_winpeshl_ini = "[LaunchApps]\r\nvtoyjump.exe";
|
||||
|
||||
static const char *g_menu_class[] =
|
||||
{
|
||||
"vtoyiso", "vtoywim", "vtoyefi", "vtoyimg", "vtoyvhd", "vtoyvtoy"
|
||||
};
|
||||
|
||||
static const char *g_menu_prefix[] =
|
||||
const char *g_menu_prefix[img_type_max] =
|
||||
{
|
||||
"iso", "wim", "efi", "img", "vhd", "vtoy"
|
||||
};
|
||||
|
||||
static int g_vtoy_load_prompt = 0;
|
||||
static char g_vtoy_prompt_msg[64];
|
||||
|
||||
static int ventoy_get_fs_type(const char *fs)
|
||||
{
|
||||
if (NULL == fs)
|
||||
@@ -1020,7 +1025,7 @@ static grub_err_t ventoy_cmd_concat_efi_iso(grub_extcmd_context_t ctxt, int argc
|
||||
data = (char *)grub_efi_allocate_iso_buf(totlen);
|
||||
#else
|
||||
data = (char *)grub_malloc(totlen);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
ventoy_fill_os_param(file, (ventoy_os_param *)data);
|
||||
|
||||
@@ -1041,6 +1046,61 @@ static grub_err_t ventoy_cmd_concat_efi_iso(grub_extcmd_context_t ctxt, int argc
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_set_wim_prompt(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
(void)args;
|
||||
|
||||
g_vtoy_load_prompt = 0;
|
||||
grub_memset(g_vtoy_prompt_msg, 0, sizeof(g_vtoy_prompt_msg));
|
||||
|
||||
if (argc == 2 && args[0][0] == '1')
|
||||
{
|
||||
g_vtoy_load_prompt = 1;
|
||||
grub_snprintf(g_vtoy_prompt_msg, sizeof(g_vtoy_prompt_msg), "%s", args[1]);
|
||||
}
|
||||
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
int ventoy_need_prompt_load_file(void)
|
||||
{
|
||||
return g_vtoy_load_prompt;
|
||||
}
|
||||
|
||||
grub_ssize_t ventoy_load_file_with_prompt(grub_file_t file, void *buf, grub_ssize_t size)
|
||||
{
|
||||
grub_uint64_t ro = 0;
|
||||
grub_uint64_t div = 0;
|
||||
grub_ssize_t left = size;
|
||||
char *cur = (char *)buf;
|
||||
|
||||
grub_printf("\r%s 1%% ", g_vtoy_prompt_msg);
|
||||
grub_refresh();
|
||||
|
||||
while (left >= VTOY_SIZE_2MB)
|
||||
{
|
||||
grub_file_read(file, cur, VTOY_SIZE_2MB);
|
||||
cur += VTOY_SIZE_2MB;
|
||||
left -= VTOY_SIZE_2MB;
|
||||
|
||||
div = grub_divmod64((grub_uint64_t)((size - left) * 100), (grub_uint64_t)size, &ro);
|
||||
grub_printf("\r%s %d%% ", g_vtoy_prompt_msg, (int)div);
|
||||
grub_refresh();
|
||||
}
|
||||
|
||||
if (left > 0)
|
||||
{
|
||||
grub_file_read(file, cur, left);
|
||||
}
|
||||
|
||||
grub_printf("\r%s 100%% \n", g_vtoy_prompt_msg);
|
||||
grub_refresh();
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_load_file_to_mem(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int rc = 1;
|
||||
@@ -1048,36 +1108,59 @@ static grub_err_t ventoy_cmd_load_file_to_mem(grub_extcmd_context_t ctxt, int ar
|
||||
char value[32];
|
||||
char *buf = NULL;
|
||||
grub_file_t file;
|
||||
enum grub_file_type type;
|
||||
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
(void)args;
|
||||
|
||||
if (argc != 2)
|
||||
if (argc != 3)
|
||||
{
|
||||
return rc;
|
||||
}
|
||||
|
||||
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", args[0]);
|
||||
if (grub_strcmp(args[0], "nodecompress") == 0)
|
||||
{
|
||||
type = VENTOY_FILE_TYPE;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = GRUB_FILE_TYPE_LINUX_INITRD;
|
||||
}
|
||||
|
||||
file = ventoy_grub_file_open(type, "%s", args[1]);
|
||||
if (file == NULL)
|
||||
{
|
||||
debug("failed to open file <%s>\n", args[0]);
|
||||
debug("failed to open file <%s>\n", args[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef GRUB_MACHINE_EFI
|
||||
buf = (char *)grub_efi_allocate_iso_buf(file->size);
|
||||
buf = (char *)grub_efi_allocate_chain_buf(file->size);
|
||||
#else
|
||||
buf = (char *)grub_malloc(file->size);
|
||||
#endif
|
||||
|
||||
grub_file_read(file, buf, file->size);
|
||||
if (!buf)
|
||||
{
|
||||
grub_file_close(file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
grub_snprintf(name, sizeof(name), "%s_addr", args[1]);
|
||||
if (g_vtoy_load_prompt)
|
||||
{
|
||||
ventoy_load_file_with_prompt(file, buf, file->size);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_file_read(file, buf, file->size);
|
||||
}
|
||||
|
||||
grub_snprintf(name, sizeof(name), "%s_addr", args[2]);
|
||||
grub_snprintf(value, sizeof(value), "0x%llx", (unsigned long long)(unsigned long)buf);
|
||||
grub_env_set(name, value);
|
||||
|
||||
grub_snprintf(name, sizeof(name), "%s_size", args[1]);
|
||||
grub_snprintf(name, sizeof(name), "%s_size", args[2]);
|
||||
grub_snprintf(value, sizeof(value), "%llu", (unsigned long long)file->size);
|
||||
grub_env_set(name, value);
|
||||
|
||||
@@ -3163,6 +3246,10 @@ static grub_err_t ventoy_cmd_check_mode(grub_extcmd_context_t ctxt, int argc, ch
|
||||
{
|
||||
return g_ventoy_grub2_mode ? 0 : 1;
|
||||
}
|
||||
else if (args[0][0] == '4')
|
||||
{
|
||||
return g_ventoy_wimboot_mode ? 0 : 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -4117,8 +4204,18 @@ static int ventoy_fs_enum_1st_file(const char *filename, const struct grub_dirho
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_fs_enum_1st_dir(const char *filename, const struct grub_dirhook_info *info, void *data)
|
||||
{
|
||||
if (info->dir && filename && filename[0] != '.')
|
||||
{
|
||||
grub_snprintf((char *)data, 256, "%s", filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_fs_enum_1st_file(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_fs_enum_1st_child(int argc, char **args, grub_fs_dir_hook_t hook)
|
||||
{
|
||||
int rc = 1;
|
||||
char *device_name = NULL;
|
||||
@@ -4126,11 +4223,9 @@ static grub_err_t ventoy_cmd_fs_enum_1st_file(grub_extcmd_context_t ctxt, int ar
|
||||
grub_fs_t fs = NULL;
|
||||
char name[256] ={0};
|
||||
|
||||
(void)ctxt;
|
||||
|
||||
if (argc != 3)
|
||||
{
|
||||
debug("ventoy_cmd_fs_enum_1st_file, invalid param num %d\n", argc);
|
||||
debug("ventoy_fs_enum_1st_child, invalid param num %d\n", argc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -4155,7 +4250,7 @@ static grub_err_t ventoy_cmd_fs_enum_1st_file(grub_extcmd_context_t ctxt, int ar
|
||||
goto end;
|
||||
}
|
||||
|
||||
fs->fs_dir(dev, args[1], ventoy_fs_enum_1st_file, name);
|
||||
fs->fs_dir(dev, args[1], hook, name);
|
||||
if (name[0])
|
||||
{
|
||||
ventoy_set_env(args[2], name);
|
||||
@@ -4171,6 +4266,18 @@ end:
|
||||
return rc;
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_fs_enum_1st_file(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
(void)ctxt;
|
||||
return ventoy_fs_enum_1st_child(argc, args, ventoy_fs_enum_1st_file);
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_fs_enum_1st_dir(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
(void)ctxt;
|
||||
return ventoy_fs_enum_1st_child(argc, args, ventoy_fs_enum_1st_dir);
|
||||
}
|
||||
|
||||
static grub_err_t ventoy_cmd_basename(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
char c;
|
||||
@@ -4345,6 +4452,23 @@ int ventoy_env_init(void)
|
||||
grub_env_export("ventoy_env_param");
|
||||
}
|
||||
|
||||
grub_snprintf(buf, sizeof(buf), "0x%lx", (ulong)g_vtoy_winpeshl_ini);
|
||||
grub_env_set("vtoy_winpeshl_ini_addr", buf);
|
||||
|
||||
grub_snprintf(buf, sizeof(buf), "%d", (int)grub_strlen(g_vtoy_winpeshl_ini));
|
||||
grub_env_set("vtoy_winpeshl_ini_size", buf);
|
||||
|
||||
grub_env_export("vtoy_winpeshl_ini_addr");
|
||||
grub_env_export("vtoy_winpeshl_ini_size");
|
||||
|
||||
grub_snprintf(buf, sizeof(buf), "0x%lx", (ulong)ventoy_chain_file_size);
|
||||
grub_env_set("vtoy_chain_file_size", buf);
|
||||
grub_env_export("vtoy_chain_file_size");
|
||||
|
||||
grub_snprintf(buf, sizeof(buf), "0x%lx", (ulong)ventoy_chain_file_read);
|
||||
grub_env_set("vtoy_chain_file_read", buf);
|
||||
grub_env_export("vtoy_chain_file_read");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -4387,6 +4511,7 @@ static cmd_para ventoy_cmds[] =
|
||||
{ "vt_check_part_exist", ventoy_cmd_part_exist, 0, NULL, "", "", NULL },
|
||||
{ "vt_get_fs_label", ventoy_cmd_get_fs_label, 0, NULL, "", "", NULL },
|
||||
{ "vt_fs_enum_1st_file", ventoy_cmd_fs_enum_1st_file, 0, NULL, "", "", NULL },
|
||||
{ "vt_fs_enum_1st_dir", ventoy_cmd_fs_enum_1st_dir, 0, NULL, "", "", NULL },
|
||||
{ "vt_file_basename", ventoy_cmd_basename, 0, NULL, "", "", NULL },
|
||||
{ "vt_file_basefile", ventoy_cmd_basefile, 0, NULL, "", "", NULL },
|
||||
{ "vt_enum_video_mode", ventoy_cmd_enum_video_mode, 0, NULL, "", "", NULL },
|
||||
@@ -4426,6 +4551,7 @@ static cmd_para ventoy_cmds[] =
|
||||
|
||||
{ "vt_windows_reset", ventoy_cmd_wimdows_reset, 0, NULL, "", "", NULL },
|
||||
{ "vt_windows_chain_data", ventoy_cmd_windows_chain_data, 0, NULL, "", "", NULL },
|
||||
{ "vt_windows_wimboot_data", ventoy_cmd_windows_wimboot_data, 0, NULL, "", "", NULL },
|
||||
{ "vt_windows_collect_wim_patch", ventoy_cmd_collect_wim_patch, 0, NULL, "", "", NULL },
|
||||
{ "vt_windows_locate_wim_patch", ventoy_cmd_locate_wim_patch, 0, NULL, "", "", NULL },
|
||||
{ "vt_windows_count_wim_patch", ventoy_cmd_wim_patch_count, 0, NULL, "", "", NULL },
|
||||
@@ -4465,6 +4591,10 @@ static cmd_para ventoy_cmds[] =
|
||||
{ "vt_check_secureboot_var", ventoy_cmd_check_secureboot_var, 0, NULL, "", "", NULL },
|
||||
{ "vt_clear_key", ventoy_cmd_clear_key, 0, NULL, "", "", NULL },
|
||||
{ "vt_img_check_range", ventoy_cmd_img_check_range, 0, NULL, "", "", NULL },
|
||||
{ "vt_is_pe64", ventoy_cmd_is_pe64, 0, NULL, "", "", NULL },
|
||||
{ "vt_sel_wimboot", ventoy_cmd_sel_wimboot, 0, NULL, "", "", NULL },
|
||||
{ "vt_set_wim_load_prompt", ventoy_cmd_set_wim_prompt, 0, NULL, "", "", NULL },
|
||||
{ "vt_set_theme", ventoy_cmd_set_theme, 0, NULL, "", "", NULL },
|
||||
|
||||
};
|
||||
|
||||
@@ -4479,6 +4609,7 @@ int ventoy_register_all_cmd(void)
|
||||
cur->cmd = grub_register_extcmd(cur->name, cur->func, cur->flags,
|
||||
cur->summary, cur->description, cur->parser);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -29,6 +29,8 @@
|
||||
|
||||
#define VTOY_SIZE_1GB 1073741824
|
||||
#define VTOY_SIZE_1MB (1024 * 1024)
|
||||
#define VTOY_SIZE_2MB (2 * 1024 * 1024)
|
||||
#define VTOY_SIZE_4MB (4 * 1024 * 1024)
|
||||
#define VTOY_SIZE_512KB (512 * 1024)
|
||||
#define VTOY_SIZE_1KB 1024
|
||||
|
||||
@@ -194,12 +196,14 @@ typedef struct ventoy_iso9660_vd
|
||||
|
||||
#pragma pack()
|
||||
|
||||
#define img_type_iso 0
|
||||
#define img_type_wim 1
|
||||
#define img_type_efi 2
|
||||
#define img_type_img 3
|
||||
#define img_type_vhd 4
|
||||
#define img_type_vtoy 5
|
||||
#define img_type_start 0
|
||||
#define img_type_iso 0
|
||||
#define img_type_wim 1
|
||||
#define img_type_efi 2
|
||||
#define img_type_img 3
|
||||
#define img_type_vhd 4
|
||||
#define img_type_vtoy 5
|
||||
#define img_type_max 6
|
||||
|
||||
typedef struct img_info
|
||||
{
|
||||
@@ -282,6 +286,7 @@ extern ventoy_img_chunk_list g_img_chunk_list;
|
||||
extern ventoy_img_chunk_list g_wimiso_chunk_list;
|
||||
extern char *g_wimiso_path;
|
||||
extern char g_arch_mode_suffix[64];
|
||||
extern const char *g_menu_prefix[img_type_max];
|
||||
|
||||
extern int g_ventoy_debug;
|
||||
void ventoy_debug(const char *fmt, ...);
|
||||
@@ -554,10 +559,16 @@ int ventoy_is_dir_exist(const char *fmt, ...);
|
||||
int ventoy_fill_data(grub_uint32_t buflen, char *buffer);
|
||||
grub_err_t ventoy_cmd_load_plugin(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_wimdows_reset(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_is_pe64(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_windows_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_windows_wimboot_data(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_wim_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_wim_check_bootable(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_dump_wim_patch(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_sel_wimboot(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_set_wim_prompt(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_ssize_t ventoy_load_file_with_prompt(grub_file_t file, void *buf, grub_ssize_t size);
|
||||
int ventoy_need_prompt_load_file(void);
|
||||
|
||||
VTOY_JSON *vtoy_json_find_item
|
||||
(
|
||||
@@ -767,8 +778,17 @@ typedef struct file_fullpath
|
||||
char path[256];
|
||||
}file_fullpath;
|
||||
|
||||
typedef struct theme_list
|
||||
{
|
||||
file_fullpath theme;
|
||||
struct theme_list *next;
|
||||
}theme_list;
|
||||
|
||||
#define auto_install_type_file 0
|
||||
#define auto_install_type_parent 1
|
||||
typedef struct install_template
|
||||
{
|
||||
int type;
|
||||
int pathlen;
|
||||
char isopath[256];
|
||||
|
||||
@@ -862,8 +882,11 @@ typedef struct conf_replace
|
||||
struct conf_replace *next;
|
||||
}conf_replace;
|
||||
|
||||
#define injection_type_file 0
|
||||
#define injection_type_parent 1
|
||||
typedef struct injection_config
|
||||
{
|
||||
int type;
|
||||
int pathlen;
|
||||
char isopath[256];
|
||||
char archive[256];
|
||||
@@ -900,8 +923,12 @@ typedef struct vtoy_password
|
||||
grub_uint8_t md5[16];
|
||||
}vtoy_password;
|
||||
|
||||
#define vtoy_menu_pwd_file 0
|
||||
#define vtoy_menu_pwd_parent 1
|
||||
|
||||
typedef struct menu_password
|
||||
{
|
||||
int type;
|
||||
int pathlen;
|
||||
char isopath[256];
|
||||
|
||||
@@ -916,6 +943,7 @@ extern int g_ventoy_last_entry;
|
||||
extern int g_ventoy_memdisk_mode;
|
||||
extern int g_ventoy_iso_raw;
|
||||
extern int g_ventoy_grub2_mode;
|
||||
extern int g_ventoy_wimboot_mode;
|
||||
extern int g_ventoy_iso_uefi_drv;
|
||||
extern int g_ventoy_case_insensitive;
|
||||
extern grub_uint8_t g_ventoy_chain_type;
|
||||
@@ -977,6 +1005,7 @@ int ventoy_plugin_load_dud(dud *node, const char *isopart);
|
||||
int ventoy_get_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start);
|
||||
int ventoy_check_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start);
|
||||
void ventoy_plugin_dump_persistence(void);
|
||||
grub_err_t ventoy_cmd_set_theme(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_plugin_check_json(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_check_password(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
grub_err_t ventoy_cmd_linux_get_main_initrd_index(grub_extcmd_context_t ctxt, int argc, char **args);
|
||||
@@ -1009,8 +1038,20 @@ int ventoy_load_part_table(const char *diskname);
|
||||
int ventoy_env_init(void);
|
||||
int ventoy_register_all_cmd(void);
|
||||
int ventoy_unregister_all_cmd(void);
|
||||
int ventoy_chain_file_size(const char *path);
|
||||
int ventoy_chain_file_read(const char *path, int offset, int len, void *buf);
|
||||
|
||||
#define VTOY_CMD_CHECK(a) if (33554432 != g_ventoy_disk_part_size[a]) ventoy_syscall0(exit)
|
||||
|
||||
#define vtoy_theme_random_boot_second 0
|
||||
#define vtoy_theme_random_boot_day 1
|
||||
#define vtoy_theme_random_boot_month 2
|
||||
|
||||
#define ventoy_env_export(env, name) \
|
||||
{\
|
||||
grub_env_set((env), (name));\
|
||||
grub_env_export(env);\
|
||||
}
|
||||
|
||||
#endif /* __VENTOY_DEF_H__ */
|
||||
|
||||
|
@@ -43,6 +43,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
|
||||
char g_arch_mode_suffix[64];
|
||||
static char g_iso_disk_name[128];
|
||||
static vtoy_password g_boot_pwd;
|
||||
static vtoy_password g_file_type_pwd[img_type_max];
|
||||
static install_template *g_install_template_head = NULL;
|
||||
static dud *g_dud_head = NULL;
|
||||
static menu_password *g_pwd_head = NULL;
|
||||
@@ -55,6 +56,32 @@ static auto_memdisk *g_auto_memdisk_head = NULL;
|
||||
static image_list *g_image_list_head = NULL;
|
||||
static conf_replace *g_conf_replace_head = NULL;
|
||||
|
||||
static int g_theme_num = 0;
|
||||
static theme_list *g_theme_head = NULL;
|
||||
static int g_theme_random = vtoy_theme_random_boot_second;
|
||||
static char g_theme_single_file[256];
|
||||
|
||||
static int ventoy_plugin_is_parent(const char *pat, int patlen, const char *isopath)
|
||||
{
|
||||
if (patlen > 1)
|
||||
{
|
||||
if (isopath[patlen] == '/' && ventoy_strncmp(pat, isopath, patlen) == 0 &&
|
||||
grub_strchr(isopath + patlen + 1, '/') == NULL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pat[0] == '/' && grub_strchr(isopath + 1, '/') == NULL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_plugin_control_check(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int rc = 0;
|
||||
@@ -155,6 +182,38 @@ static int ventoy_plugin_theme_check(VTOY_JSON *json, const char *isodisk)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
node = vtoy_json_find_item(json->pstChild, JSON_TYPE_ARRAY, "file");
|
||||
if (node)
|
||||
{
|
||||
for (node = node->pstChild; node; node = node->pstNext)
|
||||
{
|
||||
value = node->unData.pcStrVal;
|
||||
grub_printf("file: %s\n", value);
|
||||
if (value[0] == '/')
|
||||
{
|
||||
exist = ventoy_is_file_exist("%s%s", isodisk, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
exist = ventoy_is_file_exist("%s/ventoy/%s", isodisk, value);
|
||||
}
|
||||
|
||||
if (exist == 0)
|
||||
{
|
||||
grub_printf("Theme file %s does NOT exist\n", value);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
value = vtoy_json_get_string_ex(json->pstChild, "random");
|
||||
if (value)
|
||||
{
|
||||
grub_printf("random: %s\n", value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
value = vtoy_json_get_string_ex(json->pstChild, "gfxmode");
|
||||
if (value)
|
||||
@@ -222,8 +281,10 @@ static int ventoy_plugin_theme_entry(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
const char *value;
|
||||
char filepath[256];
|
||||
VTOY_JSON *node;
|
||||
|
||||
VTOY_JSON *node = NULL;
|
||||
theme_list *tail = NULL;
|
||||
theme_list *themenode = NULL;
|
||||
|
||||
value = vtoy_json_get_string_ex(json->pstChild, "file");
|
||||
if (value)
|
||||
{
|
||||
@@ -236,53 +297,112 @@ static int ventoy_plugin_theme_entry(VTOY_JSON *json, const char *isodisk)
|
||||
grub_snprintf(filepath, sizeof(filepath), "%s/ventoy/%s", isodisk, value);
|
||||
}
|
||||
|
||||
if (ventoy_is_file_exist(filepath) == 0)
|
||||
if (ventoy_check_file_exist(filepath) == 0)
|
||||
{
|
||||
debug("Theme file %s does not exist\n", filepath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
debug("vtoy_theme %s\n", filepath);
|
||||
grub_env_set("vtoy_theme", filepath);
|
||||
ventoy_env_export("vtoy_theme", filepath);
|
||||
grub_snprintf(g_theme_single_file, sizeof(g_theme_single_file), "%s", filepath);
|
||||
}
|
||||
else
|
||||
{
|
||||
node = vtoy_json_find_item(json->pstChild, JSON_TYPE_ARRAY, "file");
|
||||
if (node)
|
||||
{
|
||||
for (node = node->pstChild; node; node = node->pstNext)
|
||||
{
|
||||
value = node->unData.pcStrVal;
|
||||
if (value[0] == '/')
|
||||
{
|
||||
grub_snprintf(filepath, sizeof(filepath), "%s%s", isodisk, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_snprintf(filepath, sizeof(filepath), "%s/ventoy/%s", isodisk, value);
|
||||
}
|
||||
|
||||
if (ventoy_check_file_exist(filepath) == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
themenode = grub_zalloc(sizeof(theme_list));
|
||||
if (themenode)
|
||||
{
|
||||
grub_snprintf(themenode->theme.path, sizeof(themenode->theme.path), "%s", filepath);
|
||||
if (g_theme_head)
|
||||
{
|
||||
tail->next = themenode;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_theme_head = themenode;
|
||||
}
|
||||
tail = themenode;
|
||||
g_theme_num++;
|
||||
}
|
||||
}
|
||||
|
||||
ventoy_env_export("vtoy_theme", "random");
|
||||
value = vtoy_json_get_string_ex(json->pstChild, "random");
|
||||
if (value)
|
||||
{
|
||||
if (grub_strcmp(value, "boot_second") == 0)
|
||||
{
|
||||
g_theme_random = vtoy_theme_random_boot_second;
|
||||
}
|
||||
else if (grub_strcmp(value, "boot_day") == 0)
|
||||
{
|
||||
g_theme_random = vtoy_theme_random_boot_day;
|
||||
}
|
||||
else if (grub_strcmp(value, "boot_month") == 0)
|
||||
{
|
||||
g_theme_random = vtoy_theme_random_boot_month;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
value = vtoy_json_get_string_ex(json->pstChild, "gfxmode");
|
||||
if (value)
|
||||
{
|
||||
debug("vtoy_gfxmode %s\n", value);
|
||||
grub_env_set("vtoy_gfxmode", value);
|
||||
ventoy_env_export("vtoy_gfxmode", value);
|
||||
}
|
||||
|
||||
value = vtoy_json_get_string_ex(json->pstChild, "display_mode");
|
||||
if (value)
|
||||
{
|
||||
debug("display_mode %s\n", value);
|
||||
grub_env_set("vtoy_display_mode", value);
|
||||
ventoy_env_export("vtoy_display_mode", value);
|
||||
}
|
||||
|
||||
value = vtoy_json_get_string_ex(json->pstChild, "serial_param");
|
||||
if (value)
|
||||
{
|
||||
debug("serial_param %s\n", value);
|
||||
grub_env_set("vtoy_serial_param", value);
|
||||
ventoy_env_export("vtoy_serial_param", value);
|
||||
}
|
||||
|
||||
value = vtoy_json_get_string_ex(json->pstChild, "ventoy_left");
|
||||
if (value)
|
||||
{
|
||||
grub_env_set("VTLE_LFT", value);
|
||||
ventoy_env_export("VTLE_LFT", value);
|
||||
}
|
||||
|
||||
value = vtoy_json_get_string_ex(json->pstChild, "ventoy_top");
|
||||
if (value)
|
||||
{
|
||||
grub_env_set("VTLE_TOP", value);
|
||||
ventoy_env_export("VTLE_TOP", value);
|
||||
}
|
||||
|
||||
value = vtoy_json_get_string_ex(json->pstChild, "ventoy_color");
|
||||
if (value)
|
||||
{
|
||||
grub_env_set("VTLE_CLR", value);
|
||||
ventoy_env_export("VTLE_CLR", value);
|
||||
}
|
||||
|
||||
node = vtoy_json_find_item(json->pstChild, JSON_TYPE_ARRAY, "fonts");
|
||||
@@ -498,8 +618,7 @@ static int ventoy_plugin_auto_install_check(VTOY_JSON *json, const char *isodisk
|
||||
grub_printf("NOT object type\n");
|
||||
}
|
||||
|
||||
iso = vtoy_json_get_string_ex(pNode->pstChild, "image");
|
||||
if (iso)
|
||||
if ((iso = vtoy_json_get_string_ex(pNode->pstChild, "image")) != NULL)
|
||||
{
|
||||
pos = grub_strchr(iso, '*');
|
||||
if (pos || 0 == ventoy_plugin_check_path(isodisk, iso))
|
||||
@@ -524,6 +643,30 @@ static int ventoy_plugin_auto_install_check(VTOY_JSON *json, const char *isodisk
|
||||
grub_printf("image: %s [FAIL]\n", iso);
|
||||
}
|
||||
}
|
||||
else if ((iso = vtoy_json_get_string_ex(pNode->pstChild, "parent")) != NULL)
|
||||
{
|
||||
if (ventoy_is_dir_exist("%s%s", isodisk, iso))
|
||||
{
|
||||
grub_printf("parent: %s [OK]\n", iso);
|
||||
ventoy_plugin_check_fullpath(pNode->pstChild, isodisk, "template", &pathnum);
|
||||
|
||||
if (JSON_SUCCESS == vtoy_json_get_int(pNode->pstChild, "autosel", &autosel))
|
||||
{
|
||||
if (autosel >= 0 && autosel <= pathnum)
|
||||
{
|
||||
grub_printf("autosel: %d [OK]\n", autosel);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("autosel: %d [FAIL]\n", autosel);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("parent: %s [FAIL]\n", iso);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("image not found\n");
|
||||
@@ -535,6 +678,7 @@ static int ventoy_plugin_auto_install_check(VTOY_JSON *json, const char *isodisk
|
||||
|
||||
static int ventoy_plugin_auto_install_entry(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int type = 0;
|
||||
int pathnum = 0;
|
||||
int autosel = 0;
|
||||
const char *iso = NULL;
|
||||
@@ -563,7 +707,14 @@ static int ventoy_plugin_auto_install_entry(VTOY_JSON *json, const char *isodisk
|
||||
|
||||
for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
|
||||
{
|
||||
type = auto_install_type_file;
|
||||
iso = vtoy_json_get_string_ex(pNode->pstChild, "image");
|
||||
if (!iso)
|
||||
{
|
||||
type = auto_install_type_parent;
|
||||
iso = vtoy_json_get_string_ex(pNode->pstChild, "parent");
|
||||
}
|
||||
|
||||
if (iso && iso[0] == '/')
|
||||
{
|
||||
if (0 == ventoy_plugin_parse_fullpath(pNode->pstChild, isodisk, "template", &templatepath, &pathnum))
|
||||
@@ -571,6 +722,7 @@ static int ventoy_plugin_auto_install_entry(VTOY_JSON *json, const char *isodisk
|
||||
node = grub_zalloc(sizeof(install_template));
|
||||
if (node)
|
||||
{
|
||||
node->type = type;
|
||||
node->pathlen = grub_snprintf(node->isopath, sizeof(node->isopath), "%s", iso);
|
||||
node->templatepath = templatepath;
|
||||
node->templatenum = pathnum;
|
||||
@@ -809,8 +961,26 @@ static int ventoy_plugin_parse_pwdstr(char *pwdstr, vtoy_password *pwd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ventoy_plugin_get_pwd_type(const char *pwd)
|
||||
{
|
||||
int i;
|
||||
char pwdtype[64];
|
||||
|
||||
for (i = 0; pwd && i < (int)ARRAY_SIZE(g_menu_prefix); i++)
|
||||
{
|
||||
grub_snprintf(pwdtype, sizeof(pwdtype), "%spwd", g_menu_prefix[i]);
|
||||
if (grub_strcmp(pwdtype, pwd) == 0)
|
||||
{
|
||||
return img_type_start + i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int ventoy_plugin_pwd_entry(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int type = -1;
|
||||
const char *iso = NULL;
|
||||
const char *pwd = NULL;
|
||||
VTOY_JSON *pNode = NULL;
|
||||
@@ -844,6 +1014,10 @@ static int ventoy_plugin_pwd_entry(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
ventoy_plugin_parse_pwdstr(pNode->unData.pcStrVal, &g_boot_pwd);
|
||||
}
|
||||
else if ((type = ventoy_plugin_get_pwd_type(pNode->pcName)) >= 0)
|
||||
{
|
||||
ventoy_plugin_parse_pwdstr(pNode->unData.pcStrVal, g_file_type_pwd + type);
|
||||
}
|
||||
else if (pNode->pcName && grub_strcmp("menupwd", pNode->pcName) == 0)
|
||||
{
|
||||
for (pCNode = pNode->pstChild; pCNode; pCNode = pCNode->pstNext)
|
||||
@@ -853,13 +1027,21 @@ static int ventoy_plugin_pwd_entry(VTOY_JSON *json, const char *isodisk)
|
||||
continue;
|
||||
}
|
||||
|
||||
type = vtoy_menu_pwd_file;
|
||||
iso = vtoy_json_get_string_ex(pCNode->pstChild, "file");
|
||||
if (!iso)
|
||||
{
|
||||
type = vtoy_menu_pwd_parent;
|
||||
iso = vtoy_json_get_string_ex(pCNode->pstChild, "parent");
|
||||
}
|
||||
|
||||
pwd = vtoy_json_get_string_ex(pCNode->pstChild, "pwd");
|
||||
if (iso && pwd && iso[0] == '/')
|
||||
{
|
||||
node = grub_zalloc(sizeof(menu_password));
|
||||
if (node)
|
||||
{
|
||||
node->type = type;
|
||||
node->pathlen = grub_snprintf(node->isopath, sizeof(node->isopath), "%s", iso);
|
||||
|
||||
if (ventoy_plugin_parse_pwdstr((char *)pwd, &(node->password)))
|
||||
@@ -888,6 +1070,7 @@ static int ventoy_plugin_pwd_entry(VTOY_JSON *json, const char *isodisk)
|
||||
|
||||
static int ventoy_plugin_pwd_check(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int type = -1;
|
||||
char *pos = NULL;
|
||||
const char *iso = NULL;
|
||||
const char *pwd = NULL;
|
||||
@@ -913,6 +1096,17 @@ static int ventoy_plugin_pwd_check(VTOY_JSON *json, const char *isodisk)
|
||||
grub_printf("Invalid bootpwd.\n");
|
||||
}
|
||||
}
|
||||
else if ((type = ventoy_plugin_get_pwd_type(pNode->pcName)) >= 0)
|
||||
{
|
||||
if (0 == ventoy_plugin_parse_pwdstr(pNode->unData.pcStrVal, NULL))
|
||||
{
|
||||
grub_printf("%s:<%s>\n", pNode->pcName, pNode->unData.pcStrVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("Invalid pwd <%s>\n", pNode->unData.pcStrVal);
|
||||
}
|
||||
}
|
||||
else if (pNode->pcName && grub_strcmp("menupwd", pNode->pcName) == 0)
|
||||
{
|
||||
grub_printf("\n");
|
||||
@@ -924,8 +1118,7 @@ static int ventoy_plugin_pwd_check(VTOY_JSON *json, const char *isodisk)
|
||||
continue;
|
||||
}
|
||||
|
||||
iso = vtoy_json_get_string_ex(pCNode->pstChild, "file");
|
||||
if (iso)
|
||||
if ((iso = vtoy_json_get_string_ex(pCNode->pstChild, "file")) != NULL)
|
||||
{
|
||||
pos = grub_strchr(iso, '*');
|
||||
if (pos || 0 == ventoy_plugin_check_path(isodisk, iso))
|
||||
@@ -947,6 +1140,26 @@ static int ventoy_plugin_pwd_check(VTOY_JSON *json, const char *isodisk)
|
||||
grub_printf("<%s%s> not found\n", isodisk, iso);
|
||||
}
|
||||
}
|
||||
else if ((iso = vtoy_json_get_string_ex(pCNode->pstChild, "parent")) != NULL)
|
||||
{
|
||||
if (ventoy_is_dir_exist("%s%s", isodisk, iso))
|
||||
{
|
||||
pwd = vtoy_json_get_string_ex(pCNode->pstChild, "pwd");
|
||||
if (0 == ventoy_plugin_parse_pwdstr((char *)pwd, NULL))
|
||||
{
|
||||
grub_printf("dir:<%s> [%s]\n", iso, (pos ? "*" : "OK"));
|
||||
grub_printf("pwd:<%s>\n\n", pwd);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("Invalid password for <%s>\n", iso);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("<%s%s> not found\n", isodisk, iso);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("No file item found in json.\n");
|
||||
@@ -1207,6 +1420,7 @@ static int ventoy_plugin_menualias_entry(VTOY_JSON *json, const char *isodisk)
|
||||
|
||||
static int ventoy_plugin_injection_check(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int type = 0;
|
||||
const char *path = NULL;
|
||||
const char *archive = NULL;
|
||||
VTOY_JSON *pNode = NULL;
|
||||
@@ -1221,11 +1435,17 @@ static int ventoy_plugin_injection_check(VTOY_JSON *json, const char *isodisk)
|
||||
|
||||
for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
|
||||
{
|
||||
type = injection_type_file;
|
||||
path = vtoy_json_get_string_ex(pNode->pstChild, "image");
|
||||
if (!path)
|
||||
{
|
||||
grub_printf("image not found\n");
|
||||
continue;
|
||||
type = injection_type_parent;
|
||||
path = vtoy_json_get_string_ex(pNode->pstChild, "parent");
|
||||
if (!path)
|
||||
{
|
||||
grub_printf("image/parent not found\n");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
archive = vtoy_json_get_string_ex(pNode->pstChild, "archive");
|
||||
@@ -1235,13 +1455,21 @@ static int ventoy_plugin_injection_check(VTOY_JSON *json, const char *isodisk)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (grub_strchr(path, '*'))
|
||||
if (type == injection_type_file)
|
||||
{
|
||||
grub_printf("image: <%s> [*]\n", path);
|
||||
if (grub_strchr(path, '*'))
|
||||
{
|
||||
grub_printf("image: <%s> [*]\n", path);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("image: <%s> [%s]\n", path, ventoy_check_file_exist("%s%s", isodisk, path) ? "OK" : "NOT EXIST");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_printf("image: <%s> [%s]\n", path, ventoy_check_file_exist("%s%s", isodisk, path) ? "OK" : "NOT EXIST");
|
||||
grub_printf("parent: <%s> [%s]\n", path,
|
||||
ventoy_is_dir_exist("%s%s", isodisk, path) ? "OK" : "NOT EXIST");
|
||||
}
|
||||
|
||||
grub_printf("archive: <%s> [%s]\n\n", archive, ventoy_check_file_exist("%s%s", isodisk, archive) ? "OK" : "NOT EXIST");
|
||||
@@ -1252,6 +1480,7 @@ static int ventoy_plugin_injection_check(VTOY_JSON *json, const char *isodisk)
|
||||
|
||||
static int ventoy_plugin_injection_entry(VTOY_JSON *json, const char *isodisk)
|
||||
{
|
||||
int type = 0;
|
||||
const char *path = NULL;
|
||||
const char *archive = NULL;
|
||||
VTOY_JSON *pNode = NULL;
|
||||
@@ -1279,13 +1508,21 @@ static int ventoy_plugin_injection_entry(VTOY_JSON *json, const char *isodisk)
|
||||
|
||||
for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
|
||||
{
|
||||
type = injection_type_file;
|
||||
path = vtoy_json_get_string_ex(pNode->pstChild, "image");
|
||||
if (!path)
|
||||
{
|
||||
type = injection_type_parent;
|
||||
path = vtoy_json_get_string_ex(pNode->pstChild, "parent");
|
||||
}
|
||||
|
||||
archive = vtoy_json_get_string_ex(pNode->pstChild, "archive");
|
||||
if (path && path[0] == '/' && archive && archive[0] == '/')
|
||||
{
|
||||
node = grub_zalloc(sizeof(injection_config));
|
||||
if (node)
|
||||
{
|
||||
node->type = type;
|
||||
node->pathlen = grub_snprintf(node->isopath, sizeof(node->isopath), "%s", path);
|
||||
grub_snprintf(node->archive, sizeof(node->archive), "%s", archive);
|
||||
|
||||
@@ -1977,7 +2214,7 @@ void ventoy_plugin_dump_injection(void)
|
||||
|
||||
for (node = g_injection_head; node; node = node->next)
|
||||
{
|
||||
grub_printf("\nIMAGE:<%s>\n", node->isopath);
|
||||
grub_printf("\n%s:<%s>\n", (node->type == injection_type_file) ? "IMAGE" : "PARENT", node->isopath);
|
||||
grub_printf("ARCHIVE:<%s>\n", node->archive);
|
||||
}
|
||||
|
||||
@@ -1992,7 +2229,9 @@ void ventoy_plugin_dump_auto_install(void)
|
||||
|
||||
for (node = g_install_template_head; node; node = node->next)
|
||||
{
|
||||
grub_printf("\nIMAGE:<%s> <%d>\n", node->isopath, node->templatenum);
|
||||
grub_printf("\n%s:<%s> <%d>\n",
|
||||
(node->type == auto_install_type_file) ? "IMAGE" : "PARENT",
|
||||
node->isopath, node->templatenum);
|
||||
for (i = 0; i < node->templatenum; i++)
|
||||
{
|
||||
grub_printf("SCRIPT %d:<%s>\n", i, node->templatepath[i].path);
|
||||
@@ -2045,9 +2284,23 @@ install_template * ventoy_plugin_find_install_template(const char *isopath)
|
||||
len = (int)grub_strlen(isopath);
|
||||
for (node = g_install_template_head; node; node = node->next)
|
||||
{
|
||||
if (node->pathlen == len && ventoy_strcmp(node->isopath, isopath) == 0)
|
||||
if (node->type == auto_install_type_file)
|
||||
{
|
||||
return node;
|
||||
if (node->pathlen == len && ventoy_strcmp(node->isopath, isopath) == 0)
|
||||
{
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (node = g_install_template_head; node; node = node->next)
|
||||
{
|
||||
if (node->type == auto_install_type_parent)
|
||||
{
|
||||
if (node->pathlen < len && ventoy_plugin_is_parent(node->isopath, node->pathlen, isopath))
|
||||
{
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2166,9 +2419,23 @@ const char * ventoy_plugin_get_injection(const char *isopath)
|
||||
len = (int)grub_strlen(isopath);
|
||||
for (node = g_injection_head; node; node = node->next)
|
||||
{
|
||||
if (node->pathlen == len && ventoy_strcmp(node->isopath, isopath) == 0)
|
||||
if (node->type == injection_type_file)
|
||||
{
|
||||
return node->archive;
|
||||
if (node->pathlen == len && ventoy_strcmp(node->isopath, isopath) == 0)
|
||||
{
|
||||
return node->archive;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (node = g_injection_head; node; node = node->next)
|
||||
{
|
||||
if (node->type == injection_type_parent)
|
||||
{
|
||||
if (node->pathlen < len && ventoy_plugin_is_parent(node->isopath, node->pathlen, isopath))
|
||||
{
|
||||
return node->archive;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2200,7 +2467,8 @@ const char * ventoy_plugin_get_menu_alias(int type, const char *isopath)
|
||||
|
||||
const char * ventoy_plugin_get_menu_class(int type, const char *name, const char *path)
|
||||
{
|
||||
int len;
|
||||
int namelen;
|
||||
int pathlen;
|
||||
menu_class *node = NULL;
|
||||
|
||||
if (!g_menu_class_head)
|
||||
@@ -2208,6 +2476,9 @@ const char * ventoy_plugin_get_menu_class(int type, const char *name, const char
|
||||
return NULL;
|
||||
}
|
||||
|
||||
namelen = (int)grub_strlen(name);
|
||||
pathlen = (int)grub_strlen(path);
|
||||
|
||||
if (vtoy_class_image_file == type)
|
||||
{
|
||||
for (node = g_menu_class_head; node; node = node->next)
|
||||
@@ -2217,19 +2488,25 @@ const char * ventoy_plugin_get_menu_class(int type, const char *name, const char
|
||||
continue;
|
||||
}
|
||||
|
||||
if (node->parent)
|
||||
if (node->parent == 0)
|
||||
{
|
||||
len = (int)grub_strlen(path);
|
||||
if ((node->patlen < len) && (path[node->patlen] == '/') &&
|
||||
(grub_strncmp(path, node->pattern, node->patlen) == 0))
|
||||
if ((node->patlen < namelen) && grub_strstr(name, node->pattern))
|
||||
{
|
||||
return node->class;
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
for (node = g_menu_class_head; node; node = node->next)
|
||||
{
|
||||
if (node->type != type)
|
||||
{
|
||||
len = (int)grub_strlen(name);
|
||||
if ((node->patlen < len) && grub_strstr(name, node->pattern))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (node->parent)
|
||||
{
|
||||
if ((node->patlen < pathlen) && ventoy_plugin_is_parent(node->pattern, node->patlen, path))
|
||||
{
|
||||
return node->class;
|
||||
}
|
||||
@@ -2238,10 +2515,9 @@ const char * ventoy_plugin_get_menu_class(int type, const char *name, const char
|
||||
}
|
||||
else
|
||||
{
|
||||
len = (int)grub_strlen(name);
|
||||
for (node = g_menu_class_head; node; node = node->next)
|
||||
{
|
||||
if (node->type == type && node->patlen == len && grub_strncmp(name, node->pattern, len) == 0)
|
||||
if (node->type == type && node->patlen == namelen && grub_strncmp(name, node->pattern, namelen) == 0)
|
||||
{
|
||||
return node->class;
|
||||
}
|
||||
@@ -2475,20 +2751,59 @@ int ventoy_plugin_load_dud(dud *node, const char *isopart)
|
||||
|
||||
static const vtoy_password * ventoy_plugin_get_password(const char *isopath)
|
||||
{
|
||||
int i;
|
||||
int len;
|
||||
const char *pos = NULL;
|
||||
menu_password *node = NULL;
|
||||
|
||||
if ((!g_pwd_head) || (!isopath))
|
||||
if (!isopath)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
len = (int)grub_strlen(isopath);
|
||||
for (node = g_pwd_head; node; node = node->next)
|
||||
if (g_pwd_head)
|
||||
{
|
||||
if (node->pathlen == len && ventoy_strncmp(node->isopath, isopath, len) == 0)
|
||||
len = (int)grub_strlen(isopath);
|
||||
for (node = g_pwd_head; node; node = node->next)
|
||||
{
|
||||
return &(node->password);
|
||||
if (node->type == vtoy_menu_pwd_file)
|
||||
{
|
||||
if (node->pathlen == len && ventoy_strncmp(node->isopath, isopath, len) == 0)
|
||||
{
|
||||
return &(node->password);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (node = g_pwd_head; node; node = node->next)
|
||||
{
|
||||
if (node->type == vtoy_menu_pwd_parent)
|
||||
{
|
||||
if (node->pathlen < len && ventoy_plugin_is_parent(node->isopath, node->pathlen, isopath))
|
||||
{
|
||||
return &(node->password);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (*isopath)
|
||||
{
|
||||
if (*isopath == '.')
|
||||
{
|
||||
pos = isopath;
|
||||
}
|
||||
isopath++;
|
||||
}
|
||||
|
||||
if (pos)
|
||||
{
|
||||
for (i = 0; i < (int)ARRAY_SIZE(g_menu_prefix); i++)
|
||||
{
|
||||
if (g_file_type_pwd[i].type && 0 == grub_strcasecmp(pos + 1, g_menu_prefix[i]))
|
||||
{
|
||||
return g_file_type_pwd + i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2608,3 +2923,62 @@ end:
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_set_theme(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
grub_uint32_t i = 0;
|
||||
grub_uint32_t mod = 0;
|
||||
theme_list *node = g_theme_head;
|
||||
struct grub_datetime datetime;
|
||||
|
||||
(void)argc;
|
||||
(void)args;
|
||||
(void)ctxt;
|
||||
|
||||
if (g_theme_single_file[0])
|
||||
{
|
||||
debug("single theme %s\n", g_theme_single_file);
|
||||
grub_env_set("theme", g_theme_single_file);
|
||||
goto end;
|
||||
}
|
||||
|
||||
debug("g_theme_num = %d\n", g_theme_num);
|
||||
|
||||
if (g_theme_num == 0)
|
||||
{
|
||||
goto end;
|
||||
}
|
||||
|
||||
grub_memset(&datetime, 0, sizeof(datetime));
|
||||
grub_get_datetime(&datetime);
|
||||
|
||||
if (g_theme_random == vtoy_theme_random_boot_second)
|
||||
{
|
||||
grub_divmod32((grub_uint32_t)datetime.second, (grub_uint32_t)g_theme_num, &mod);
|
||||
}
|
||||
else if (g_theme_random == vtoy_theme_random_boot_day)
|
||||
{
|
||||
grub_divmod32((grub_uint32_t)datetime.day, (grub_uint32_t)g_theme_num, &mod);
|
||||
}
|
||||
else if (g_theme_random == vtoy_theme_random_boot_month)
|
||||
{
|
||||
grub_divmod32((grub_uint32_t)datetime.month, (grub_uint32_t)g_theme_num, &mod);
|
||||
}
|
||||
|
||||
debug("%04d/%02d/%02d %02d:%02d:%02d radom:%d mod:%d\n",
|
||||
datetime.year, datetime.month, datetime.day,
|
||||
datetime.hour, datetime.minute, datetime.second,
|
||||
g_theme_random, mod);
|
||||
|
||||
for (i = 0; i < mod && node; i++)
|
||||
{
|
||||
node = node->next;
|
||||
}
|
||||
|
||||
debug("random theme %s\n", node->theme.path);
|
||||
grub_env_set("theme", node->theme.path);
|
||||
|
||||
end:
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -543,7 +543,7 @@ grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char *
|
||||
}
|
||||
|
||||
grub_env_set(args[1], type);
|
||||
debug("<%s> vtoy type: <%s> ", args[0], type);
|
||||
debug("<%s> vtoy type: <%s> offset:%d\n", args[0], type, offset);
|
||||
|
||||
if (offset >= 0)
|
||||
{
|
||||
@@ -598,6 +598,14 @@ grub_err_t ventoy_cmd_get_vtoy_type(grub_extcmd_context_t ctxt, int argc, char *
|
||||
altboot = 1;
|
||||
grub_env_set(args[3], "1");
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("offset data=0x%x\n", data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("BootCode: 0x%x\n", gpt->MBR.BootCode[92]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -314,6 +314,90 @@ static int ventoy_is_pe64(grub_uint8_t *buffer)
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_is_pe64(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int ret = 1;
|
||||
grub_file_t file;
|
||||
grub_uint8_t buf[512];
|
||||
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
|
||||
file = grub_file_open(args[0], VENTOY_FILE_TYPE);
|
||||
if (!file)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
grub_memset(buf, 0, 512);
|
||||
grub_file_read(file, buf, 512);
|
||||
if (ventoy_is_pe64(buf))
|
||||
{
|
||||
debug("%s is PE64\n", args[0]);
|
||||
ret = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("%s is PE32\n", args[0]);
|
||||
}
|
||||
grub_file_close(file);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_sel_wimboot(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int size;
|
||||
char *buf = NULL;
|
||||
char configfile[128];
|
||||
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
(void)args;
|
||||
|
||||
debug("select wimboot argc:%d\n", argc);
|
||||
|
||||
buf = (char *)grub_malloc(8192);
|
||||
if (!buf)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
size = (int)grub_snprintf(buf, 8192,
|
||||
"menuentry \"Windows Setup (32-bit)\" {\n"
|
||||
" set vtoy_wimboot_sel=32\n"
|
||||
"}\n"
|
||||
"menuentry \"Windows Setup (64-bit)\" {\n"
|
||||
" set vtoy_wimboot_sel=64\n"
|
||||
"}\n"
|
||||
);
|
||||
buf[size] = 0;
|
||||
|
||||
g_ventoy_menu_esc = 1;
|
||||
g_ventoy_suppress_esc = 1;
|
||||
|
||||
grub_snprintf(configfile, sizeof(configfile), "configfile mem:0x%llx:size:%d", (ulonglong)(ulong)buf, size);
|
||||
grub_script_execute_sourcecode(configfile);
|
||||
|
||||
g_ventoy_menu_esc = 0;
|
||||
g_ventoy_suppress_esc = 0;
|
||||
|
||||
grub_free(buf);
|
||||
|
||||
if (g_ventoy_last_entry == 0)
|
||||
{
|
||||
debug("last entry=%d %s=32\n", g_ventoy_last_entry, args[0]);
|
||||
grub_env_set(args[0], "32");
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("last entry=%d %s=64\n", g_ventoy_last_entry, args[0]);
|
||||
grub_env_set(args[0], "64");
|
||||
}
|
||||
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_wimdows_reset(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
wim_patch *next = NULL;
|
||||
@@ -464,6 +548,8 @@ static int ventoy_read_resource(grub_file_t fp, wim_header *wimhdr, wim_resource
|
||||
chunk_num = (head->raw_size + WIM_CHUNK_LEN - 1) / WIM_CHUNK_LEN;
|
||||
cur_offset = (chunk_num - 1) * 4;
|
||||
chunk_offset = (grub_uint32_t *)buffer_compress;
|
||||
|
||||
//debug("%llu %llu chunk_num=%lu", (ulonglong)head->size_in_wim, (ulonglong)head->raw_size, chunk_num);
|
||||
|
||||
cur_dst = buffer_decompress;
|
||||
|
||||
@@ -516,9 +602,11 @@ static int ventoy_read_resource(grub_file_t fp, wim_header *wimhdr, wim_resource
|
||||
decompress_len = (int)lzx_decompress(buffer_compress + cur_offset, head->size_in_wim - cur_offset, cur_dst);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cur_dst += decompress_len;
|
||||
total_decompress += decompress_len;
|
||||
|
||||
//debug("last chunk_size:%u decompresslen:%d tot:%d\n", last_chunk_size, decompress_len, total_decompress);
|
||||
|
||||
if (cur_dst != buffer_decompress + head->raw_size)
|
||||
{
|
||||
@@ -572,25 +660,31 @@ static wim_directory_entry * search_full_wim_dirent
|
||||
|
||||
static wim_directory_entry * search_replace_wim_dirent(void *meta_data, wim_directory_entry *dir)
|
||||
{
|
||||
wim_directory_entry *wim_dirent = NULL;
|
||||
wim_directory_entry *wim_dirent1 = NULL;
|
||||
wim_directory_entry *wim_dirent2 = NULL;
|
||||
const char *pecmd_path[] = { "Windows", "System32", "pecmd.exe", NULL };
|
||||
const char *wpeinit_path[] = { "Windows", "System32", "wpeinit.exe", NULL };
|
||||
const char *winpeshl_path[] = { "Windows", "System32", "winpeshl.exe", NULL };
|
||||
//const char *native_path[] = { "Windows", "System32", "native.exe", NULL };
|
||||
|
||||
wim_dirent = search_full_wim_dirent(meta_data, dir, winpeshl_path);
|
||||
debug("search winpeshl.exe %p\n", wim_dirent);
|
||||
if (wim_dirent)
|
||||
wim_dirent1 = search_full_wim_dirent(meta_data, dir, pecmd_path);
|
||||
debug("search pecmd.exe %p\n", wim_dirent1);
|
||||
if (wim_dirent1)
|
||||
{
|
||||
return wim_dirent;
|
||||
wim_dirent2 = search_full_wim_dirent(meta_data, dir, wpeinit_path);
|
||||
debug("search wpeinit.exe %p\n", wim_dirent1);
|
||||
if (wim_dirent2)
|
||||
{
|
||||
return wim_dirent2;
|
||||
}
|
||||
return wim_dirent1;
|
||||
}
|
||||
|
||||
#if 0
|
||||
wim_dirent = search_full_wim_dirent(meta_data, dir, native_path);
|
||||
debug("search native.exe %p\n", wim_dirent);
|
||||
if (wim_dirent)
|
||||
wim_dirent1 = search_full_wim_dirent(meta_data, dir, winpeshl_path);
|
||||
debug("search winpeshl.exe %p\n", wim_dirent1);
|
||||
if (wim_dirent1)
|
||||
{
|
||||
return wim_dirent;
|
||||
return wim_dirent1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -798,7 +892,14 @@ static int ventoy_update_before_chain(ventoy_os_param *param, char *isopath)
|
||||
grub_crypto_hash(GRUB_MD_SHA1, wim_data->bin_hash.sha1, wim_data->jump_bin_data, wim_data->bin_raw_len);
|
||||
|
||||
security = (wim_security_header *)wim_data->new_meta_data;
|
||||
rootdir = (wim_directory_entry *)(wim_data->new_meta_data + ((security->len + 7) & 0xFFFFFFF8U));
|
||||
if (security->len > 0)
|
||||
{
|
||||
rootdir = (wim_directory_entry *)(wim_data->new_meta_data + ((security->len + 7) & 0xFFFFFFF8U));
|
||||
}
|
||||
else
|
||||
{
|
||||
rootdir = (wim_directory_entry *)(wim_data->new_meta_data + 8);
|
||||
}
|
||||
|
||||
/* update all winpeshl.exe dirent entry's hash */
|
||||
ventoy_update_all_hash(node, wim_data->new_meta_data, rootdir);
|
||||
@@ -1083,7 +1184,48 @@ static void ventoy_windows_fill_override_data_iso9660( grub_uint64_t isosize,
|
||||
return;
|
||||
}
|
||||
|
||||
static void ventoy_windows_fill_override_data_udf( grub_uint64_t isosize, void *override)
|
||||
static int ventoy_windows_fill_udf_short_ad(grub_file_t isofile, grub_uint32_t curpos,
|
||||
wim_tail *wim_data, grub_uint32_t new_wim_size)
|
||||
{
|
||||
int i;
|
||||
grub_uint32_t total = 0;
|
||||
grub_uint32_t left_size = 0;
|
||||
ventoy_udf_override *udf = NULL;
|
||||
ventoy_udf_override tmp[4];
|
||||
|
||||
grub_memset(tmp, 0, sizeof(tmp));
|
||||
grub_file_seek(isofile, wim_data->override_offset);
|
||||
grub_file_read(isofile, tmp, sizeof(tmp));
|
||||
|
||||
left_size = new_wim_size;
|
||||
udf = (ventoy_udf_override *)wim_data->override_data;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
total += tmp[i].length;
|
||||
if (total >= wim_data->wim_raw_size)
|
||||
{
|
||||
udf->length = left_size;
|
||||
udf->position = curpos;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
udf->length = tmp[i].length;
|
||||
udf->position = curpos;
|
||||
}
|
||||
|
||||
left_size -= tmp[i].length;
|
||||
curpos += udf->length / 2048;
|
||||
udf++;
|
||||
wim_data->override_len += sizeof(ventoy_udf_override);
|
||||
}
|
||||
|
||||
debug("######## Too many udf ad ######\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void ventoy_windows_fill_override_data_udf(grub_file_t isofile, void *override)
|
||||
{
|
||||
grub_uint32_t data32;
|
||||
grub_uint64_t data64;
|
||||
@@ -1094,9 +1236,8 @@ static void ventoy_windows_fill_override_data_udf( grub_uint64_t isosize, voi
|
||||
ventoy_override_chunk *cur;
|
||||
wim_patch *node = NULL;
|
||||
wim_tail *wim_data = NULL;
|
||||
ventoy_udf_override *udf = NULL;
|
||||
|
||||
sector = (isosize + 2047) / 2048;
|
||||
sector = (isofile->size + 2047) / 2048;
|
||||
|
||||
cur = (ventoy_override_chunk *)override;
|
||||
|
||||
@@ -1106,7 +1247,7 @@ static void ventoy_windows_fill_override_data_udf( grub_uint64_t isosize, voi
|
||||
cur++;
|
||||
}
|
||||
|
||||
debug("ventoy_windows_fill_override_data_udf %lu\n", (ulong)isosize);
|
||||
debug("ventoy_windows_fill_override_data_udf %lu\n", (ulong)isofile->size);
|
||||
|
||||
for (node = g_wim_patch_head; node; node = node->next)
|
||||
{
|
||||
@@ -1147,13 +1288,11 @@ static void ventoy_windows_fill_override_data_udf( grub_uint64_t isosize, voi
|
||||
data64 = new_wim_size;
|
||||
grub_memcpy(cur->override_data, &(data64), 8);
|
||||
|
||||
udf = (ventoy_udf_override *)wim_data->override_data;
|
||||
udf->length = new_wim_size;
|
||||
udf->position = (grub_uint32_t)sector - udf_start_block;
|
||||
/* override 3: position and length in extend data */
|
||||
ventoy_windows_fill_udf_short_ad(isofile, (grub_uint32_t)sector - udf_start_block, wim_data, new_wim_size);
|
||||
|
||||
sector += (new_wim_size / 2048);
|
||||
|
||||
/* override 3: position and length in extend data */
|
||||
|
||||
cur++;
|
||||
cur->img_offset = wim_data->override_offset;
|
||||
cur->override_size = wim_data->override_len;
|
||||
@@ -1330,6 +1469,54 @@ end:
|
||||
return rc;
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_windows_wimboot_data(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
grub_uint32_t size = 0;
|
||||
const char *addr = NULL;
|
||||
ventoy_chain_head *chain = NULL;
|
||||
ventoy_os_param *param = NULL;
|
||||
char envbuf[64];
|
||||
|
||||
(void)ctxt;
|
||||
(void)argc;
|
||||
(void)args;
|
||||
|
||||
addr = grub_env_get("vtoy_chain_mem_addr");
|
||||
if (!addr)
|
||||
{
|
||||
debug("Failed to find vtoy_chain_mem_addr\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
chain = (ventoy_chain_head *)(void *)grub_strtoul(addr, NULL, 16);
|
||||
|
||||
if (grub_memcmp(&g_ventoy_guid, &chain->os_param.guid, 16) != 0)
|
||||
{
|
||||
debug("os_param.guid not match\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
size = sizeof(ventoy_os_param) + sizeof(ventoy_windows_data);
|
||||
param = (ventoy_os_param *)grub_zalloc(size);
|
||||
if (!param)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
grub_memcpy(param, &chain->os_param, sizeof(ventoy_os_param));
|
||||
ventoy_fill_windows_rtdata(param + 1, param->vtoy_img_path);
|
||||
|
||||
grub_snprintf(envbuf, sizeof(envbuf), "0x%lx", (unsigned long)param);
|
||||
grub_env_set("vtoy_wimboot_mem_addr", envbuf);
|
||||
debug("vtoy_wimboot_mem_addr: %s\n", envbuf);
|
||||
|
||||
grub_snprintf(envbuf, sizeof(envbuf), "%u", size);
|
||||
grub_env_set("vtoy_wimboot_mem_size", envbuf);
|
||||
debug("vtoy_wimboot_mem_size: %s\n", envbuf);
|
||||
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
grub_err_t ventoy_cmd_windows_chain_data(grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int unknown_image = 0;
|
||||
@@ -1499,7 +1686,7 @@ grub_err_t ventoy_cmd_windows_chain_data(grub_extcmd_context_t ctxt, int argc, c
|
||||
}
|
||||
else
|
||||
{
|
||||
ventoy_windows_fill_override_data_udf(isosize, (char *)chain + chain->override_chunk_offset);
|
||||
ventoy_windows_fill_override_data_udf(file, (char *)chain + chain->override_chunk_offset);
|
||||
}
|
||||
|
||||
/* part 5: virt chunk */
|
||||
@@ -1762,3 +1949,29 @@ grub_err_t ventoy_cmd_wim_chain_data(grub_extcmd_context_t ctxt, int argc, char
|
||||
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
|
||||
}
|
||||
|
||||
int ventoy_chain_file_size(const char *path)
|
||||
{
|
||||
int size;
|
||||
grub_file_t file;
|
||||
|
||||
file = grub_file_open(path, VENTOY_FILE_TYPE);
|
||||
size = (int)(file->size);
|
||||
|
||||
grub_file_close(file);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
int ventoy_chain_file_read(const char *path, int offset, int len, void *buf)
|
||||
{
|
||||
int size;
|
||||
grub_file_t file;
|
||||
|
||||
file = grub_file_open(path, VENTOY_FILE_TYPE);
|
||||
grub_file_seek(file, offset);
|
||||
size = grub_file_read(file, buf, len);
|
||||
grub_file_close(file);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
|
@@ -87,6 +87,7 @@ EXPORT_FUNC (grub_efi_compare_device_paths) (const grub_efi_device_path_t *dp1,
|
||||
const grub_efi_device_path_t *dp2);
|
||||
|
||||
void * EXPORT_FUNC (grub_efi_allocate_iso_buf) (grub_uint64_t size);
|
||||
void * EXPORT_FUNC (grub_efi_allocate_chain_buf) (grub_uint64_t size);
|
||||
|
||||
|
||||
extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd,
|
||||
|
878
GRUB2/MOD_SRC/grub-2.04/util/setup.c
Normal file
878
GRUB2/MOD_SRC/grub-2.04/util/setup.c
Normal file
@@ -0,0 +1,878 @@
|
||||
/* grub-setup.c - make GRUB usable */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/emu/misc.h>
|
||||
#include <grub/util/misc.h>
|
||||
#include <grub/device.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/fs.h>
|
||||
#include <grub/partition.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/emu/hostdisk.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
#ifdef GRUB_SETUP_SPARC64
|
||||
#include <grub/util/ofpath.h>
|
||||
#include <grub/sparc64/ieee1275/boot.h>
|
||||
#include <grub/sparc64/ieee1275/kernel.h>
|
||||
#else
|
||||
#include <grub/i386/pc/boot.h>
|
||||
#include <grub/i386/pc/kernel.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include <assert.h>
|
||||
#include <grub/emu/getroot.h>
|
||||
#include "progname.h"
|
||||
#include <grub/reed_solomon.h>
|
||||
#include <grub/msdos_partition.h>
|
||||
#include <grub/crypto.h>
|
||||
#include <grub/util/install.h>
|
||||
#include <grub/emu/hostfile.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
/* On SPARC this program fills in various fields inside of the 'boot' and 'core'
|
||||
* image files.
|
||||
*
|
||||
* The 'boot' image needs to know the OBP path name of the root
|
||||
* device. It also needs to know the initial block number of
|
||||
* 'core' (which is 'diskboot' concatenated with 'kernel' and
|
||||
* all the modules, this is created by grub-mkimage). This resulting
|
||||
* 'boot' image is 512 bytes in size and is placed in the second block
|
||||
* of a partition.
|
||||
*
|
||||
* The initial 'diskboot' block acts as a loader for the actual GRUB
|
||||
* kernel. It contains the loading code and then a block list.
|
||||
*
|
||||
* The block list of 'core' starts at the end of the 'diskboot' image
|
||||
* and works it's way backwards towards the end of the code of 'diskboot'.
|
||||
*
|
||||
* We patch up the images with the necessary values and write out the
|
||||
* result.
|
||||
*/
|
||||
|
||||
#ifdef GRUB_SETUP_SPARC64
|
||||
#define grub_target_to_host16(x) grub_be_to_cpu16(x)
|
||||
#define grub_target_to_host32(x) grub_be_to_cpu32(x)
|
||||
#define grub_target_to_host64(x) grub_be_to_cpu64(x)
|
||||
#define grub_host_to_target16(x) grub_cpu_to_be16(x)
|
||||
#define grub_host_to_target32(x) grub_cpu_to_be32(x)
|
||||
#define grub_host_to_target64(x) grub_cpu_to_be64(x)
|
||||
#elif defined (GRUB_SETUP_BIOS)
|
||||
#define grub_target_to_host16(x) grub_le_to_cpu16(x)
|
||||
#define grub_target_to_host32(x) grub_le_to_cpu32(x)
|
||||
#define grub_target_to_host64(x) grub_le_to_cpu64(x)
|
||||
#define grub_host_to_target16(x) grub_cpu_to_le16(x)
|
||||
#define grub_host_to_target32(x) grub_cpu_to_le32(x)
|
||||
#define grub_host_to_target64(x) grub_cpu_to_le64(x)
|
||||
#else
|
||||
#error Complete this
|
||||
#endif
|
||||
|
||||
static void
|
||||
write_rootdev (grub_device_t root_dev,
|
||||
char *boot_img, grub_uint64_t first_sector)
|
||||
{
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
{
|
||||
grub_uint8_t *boot_drive;
|
||||
void *kernel_sector;
|
||||
boot_drive = (grub_uint8_t *) (boot_img + GRUB_BOOT_MACHINE_BOOT_DRIVE);
|
||||
kernel_sector = (boot_img + GRUB_BOOT_MACHINE_KERNEL_SECTOR);
|
||||
|
||||
/* FIXME: can this be skipped? */
|
||||
*boot_drive = 0xFF;
|
||||
|
||||
grub_set_unaligned64 (kernel_sector, grub_cpu_to_le64 (first_sector));
|
||||
}
|
||||
#endif
|
||||
#ifdef GRUB_SETUP_SPARC64
|
||||
{
|
||||
void *kernel_byte;
|
||||
kernel_byte = (boot_img + GRUB_BOOT_AOUT_HEADER_SIZE
|
||||
+ GRUB_BOOT_MACHINE_KERNEL_BYTE);
|
||||
grub_set_unaligned64 (kernel_byte,
|
||||
grub_cpu_to_be64 (first_sector << GRUB_DISK_SECTOR_BITS));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef GRUB_SETUP_SPARC64
|
||||
#define BOOT_SECTOR 1
|
||||
#else
|
||||
#define BOOT_SECTOR 0
|
||||
#endif
|
||||
|
||||
/* Helper for setup. */
|
||||
|
||||
struct blocklists
|
||||
{
|
||||
struct grub_boot_blocklist *first_block, *block;
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
grub_uint16_t current_segment;
|
||||
#endif
|
||||
#ifdef GRUB_SETUP_SPARC64
|
||||
grub_uint64_t gpt_offset;
|
||||
#endif
|
||||
grub_uint16_t last_length;
|
||||
grub_disk_addr_t first_sector;
|
||||
};
|
||||
|
||||
/* Helper for setup. */
|
||||
static void
|
||||
save_blocklists (grub_disk_addr_t sector, unsigned offset, unsigned length,
|
||||
void *data)
|
||||
{
|
||||
struct blocklists *bl = data;
|
||||
struct grub_boot_blocklist *prev = bl->block + 1;
|
||||
grub_uint64_t seclen;
|
||||
|
||||
#ifdef GRUB_SETUP_SPARC64
|
||||
sector -= bl->gpt_offset;
|
||||
#endif
|
||||
|
||||
grub_util_info ("saving <%" GRUB_HOST_PRIuLONG_LONG ",%u,%u>",
|
||||
(unsigned long long) sector, offset, length);
|
||||
|
||||
if (bl->first_sector == (grub_disk_addr_t) -1)
|
||||
{
|
||||
if (offset != 0 || length < GRUB_DISK_SECTOR_SIZE)
|
||||
grub_util_error ("%s", _("the first sector of the core file is not sector-aligned"));
|
||||
|
||||
bl->first_sector = sector;
|
||||
sector++;
|
||||
length -= GRUB_DISK_SECTOR_SIZE;
|
||||
if (!length)
|
||||
return;
|
||||
}
|
||||
|
||||
if (offset != 0 || bl->last_length != 0)
|
||||
grub_util_error ("%s", _("non-sector-aligned data is found in the core file"));
|
||||
|
||||
seclen = (length + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS;
|
||||
|
||||
if (bl->block != bl->first_block
|
||||
&& (grub_target_to_host64 (prev->start)
|
||||
+ grub_target_to_host16 (prev->len)) == sector)
|
||||
{
|
||||
grub_uint16_t t = grub_target_to_host16 (prev->len);
|
||||
t += seclen;
|
||||
prev->len = grub_host_to_target16 (t);
|
||||
}
|
||||
else
|
||||
{
|
||||
bl->block->start = grub_host_to_target64 (sector);
|
||||
bl->block->len = grub_host_to_target16 (seclen);
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
bl->block->segment = grub_host_to_target16 (bl->current_segment);
|
||||
#endif
|
||||
|
||||
bl->block--;
|
||||
if (bl->block->len)
|
||||
grub_util_error ("%s", _("the sectors of the core file are too fragmented"));
|
||||
}
|
||||
|
||||
bl->last_length = length & (GRUB_DISK_SECTOR_SIZE - 1);
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
bl->current_segment += seclen << (GRUB_DISK_SECTOR_BITS - 4);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Context for setup/identify_partmap. */
|
||||
struct identify_partmap_ctx
|
||||
{
|
||||
grub_partition_map_t dest_partmap;
|
||||
grub_partition_t container;
|
||||
int multiple_partmaps;
|
||||
};
|
||||
|
||||
/* Helper for setup.
|
||||
Unlike root_dev, with dest_dev we're interested in the partition map even
|
||||
if dest_dev itself is a whole disk. */
|
||||
static int
|
||||
identify_partmap (grub_disk_t disk __attribute__ ((unused)),
|
||||
const grub_partition_t p, void *data)
|
||||
{
|
||||
struct identify_partmap_ctx *ctx = data;
|
||||
|
||||
if (p->parent != ctx->container)
|
||||
return 0;
|
||||
/* NetBSD and OpenBSD subpartitions have metadata inside a partition,
|
||||
so they are safe to ignore.
|
||||
*/
|
||||
if (grub_strcmp (p->partmap->name, "netbsd") == 0
|
||||
|| grub_strcmp (p->partmap->name, "openbsd") == 0)
|
||||
return 0;
|
||||
if (ctx->dest_partmap == NULL)
|
||||
{
|
||||
ctx->dest_partmap = p->partmap;
|
||||
return 0;
|
||||
}
|
||||
if (ctx->dest_partmap == p->partmap)
|
||||
return 0;
|
||||
ctx->multiple_partmaps = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
#define SETUP grub_util_bios_setup
|
||||
#elif GRUB_SETUP_SPARC64
|
||||
#define SETUP grub_util_sparc_setup
|
||||
#else
|
||||
#error "Shouldn't happen"
|
||||
#endif
|
||||
|
||||
void
|
||||
SETUP (const char *dir,
|
||||
const char *boot_file, const char *core_file,
|
||||
const char *dest, int force,
|
||||
int fs_probe, int allow_floppy,
|
||||
int add_rs_codes __attribute__ ((unused))) /* unused on sparc64 */
|
||||
{
|
||||
char *core_path;
|
||||
char *boot_img, *core_img, *boot_path;
|
||||
char *root = 0;
|
||||
size_t boot_size, core_size;
|
||||
grub_uint16_t core_sectors;
|
||||
grub_device_t root_dev = 0, dest_dev, core_dev;
|
||||
grub_util_fd_t fp;
|
||||
struct blocklists bl;
|
||||
|
||||
bl.first_sector = (grub_disk_addr_t) -1;
|
||||
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
bl.current_segment =
|
||||
GRUB_BOOT_I386_PC_KERNEL_SEG + (GRUB_DISK_SECTOR_SIZE >> 4);
|
||||
#endif
|
||||
bl.last_length = 0;
|
||||
|
||||
/* Read the boot image by the OS service. */
|
||||
boot_path = grub_util_get_path (dir, boot_file);
|
||||
boot_size = grub_util_get_image_size (boot_path);
|
||||
if (boot_size != GRUB_DISK_SECTOR_SIZE)
|
||||
grub_util_error (_("the size of `%s' is not %u"),
|
||||
boot_path, GRUB_DISK_SECTOR_SIZE);
|
||||
boot_img = grub_util_read_image (boot_path);
|
||||
free (boot_path);
|
||||
|
||||
core_path = grub_util_get_path (dir, core_file);
|
||||
core_size = grub_util_get_image_size (core_path);
|
||||
core_sectors = ((core_size + GRUB_DISK_SECTOR_SIZE - 1)
|
||||
>> GRUB_DISK_SECTOR_BITS);
|
||||
if (core_size < GRUB_DISK_SECTOR_SIZE)
|
||||
grub_util_error (_("the size of `%s' is too small"), core_path);
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
if (core_size > 0xFFFF * GRUB_DISK_SECTOR_SIZE)
|
||||
grub_util_error (_("the size of `%s' is too large"), core_path);
|
||||
#endif
|
||||
|
||||
core_img = grub_util_read_image (core_path);
|
||||
|
||||
/* Have FIRST_BLOCK to point to the first blocklist. */
|
||||
bl.first_block = (struct grub_boot_blocklist *) (core_img
|
||||
+ GRUB_DISK_SECTOR_SIZE
|
||||
- sizeof (*bl.block));
|
||||
|
||||
grub_util_info ("Opening dest `%s'", dest);
|
||||
dest_dev = grub_device_open (dest);
|
||||
if (! dest_dev)
|
||||
grub_util_error ("%s", grub_errmsg);
|
||||
|
||||
core_dev = dest_dev;
|
||||
|
||||
{
|
||||
char **root_devices = grub_guess_root_devices (dir);
|
||||
char **cur;
|
||||
int found = 0;
|
||||
|
||||
if (!root_devices)
|
||||
grub_util_error (_("cannot find a device for %s (is /dev mounted?)"), dir);
|
||||
|
||||
for (cur = root_devices; *cur; cur++)
|
||||
{
|
||||
char *drive;
|
||||
grub_device_t try_dev;
|
||||
|
||||
drive = grub_util_get_grub_dev (*cur);
|
||||
if (!drive)
|
||||
continue;
|
||||
try_dev = grub_device_open (drive);
|
||||
if (! try_dev)
|
||||
{
|
||||
free (drive);
|
||||
continue;
|
||||
}
|
||||
if (!found && try_dev->disk->id == dest_dev->disk->id
|
||||
&& try_dev->disk->dev->id == dest_dev->disk->dev->id)
|
||||
{
|
||||
if (root_dev)
|
||||
grub_device_close (root_dev);
|
||||
free (root);
|
||||
root_dev = try_dev;
|
||||
root = drive;
|
||||
found = 1;
|
||||
continue;
|
||||
}
|
||||
if (!root_dev)
|
||||
{
|
||||
root_dev = try_dev;
|
||||
root = drive;
|
||||
continue;
|
||||
}
|
||||
grub_device_close (try_dev);
|
||||
free (drive);
|
||||
}
|
||||
if (!root_dev)
|
||||
{
|
||||
root = grub_util_get_grub_dev ("/dev/sda");
|
||||
root_dev = grub_device_open (root);
|
||||
if (root_dev)
|
||||
grub_util_info ("guessing the root device failed, because of `%s'", grub_errmsg);
|
||||
else
|
||||
grub_util_error ("guessing the root device failed, because of `%s'", grub_errmsg);
|
||||
}
|
||||
grub_util_info ("guessed root_dev `%s' from "
|
||||
"dir `%s'", root_dev->disk->name, dir);
|
||||
|
||||
for (cur = root_devices; *cur; cur++)
|
||||
free (*cur);
|
||||
free (root_devices);
|
||||
}
|
||||
|
||||
grub_util_info ("setting the root device to `%s'", root);
|
||||
if (grub_env_set ("root", root) != GRUB_ERR_NONE)
|
||||
grub_util_error ("%s", grub_errmsg);
|
||||
|
||||
{
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
char *tmp_img;
|
||||
grub_uint8_t *boot_drive_check;
|
||||
|
||||
/* Read the original sector from the disk. */
|
||||
tmp_img = xmalloc (GRUB_DISK_SECTOR_SIZE);
|
||||
if (grub_disk_read (dest_dev->disk, 0, 0, GRUB_DISK_SECTOR_SIZE, tmp_img))
|
||||
grub_util_error ("%s", grub_errmsg);
|
||||
|
||||
boot_drive_check = (grub_uint8_t *) (boot_img
|
||||
+ GRUB_BOOT_MACHINE_DRIVE_CHECK);
|
||||
/* Copy the possible DOS BPB. */
|
||||
memcpy (boot_img + GRUB_BOOT_MACHINE_BPB_START,
|
||||
tmp_img + GRUB_BOOT_MACHINE_BPB_START,
|
||||
GRUB_BOOT_MACHINE_BPB_END - GRUB_BOOT_MACHINE_BPB_START);
|
||||
|
||||
/* If DEST_DRIVE is a hard disk, enable the workaround, which is
|
||||
for buggy BIOSes which don't pass boot drive correctly. Instead,
|
||||
they pass 0x00 or 0x01 even when booted from 0x80. */
|
||||
if (!allow_floppy && !grub_util_biosdisk_is_floppy (dest_dev->disk))
|
||||
{
|
||||
/* Replace the jmp (2 bytes) with double nop's. */
|
||||
boot_drive_check[0] = 0x90;
|
||||
boot_drive_check[1] = 0x90;
|
||||
}
|
||||
#endif
|
||||
|
||||
struct identify_partmap_ctx ctx = {
|
||||
.dest_partmap = NULL,
|
||||
.container = dest_dev->disk->partition,
|
||||
.multiple_partmaps = 0
|
||||
};
|
||||
int is_ldm;
|
||||
grub_err_t err;
|
||||
grub_disk_addr_t *sectors;
|
||||
int i;
|
||||
grub_fs_t fs;
|
||||
unsigned int nsec, maxsec;
|
||||
|
||||
grub_partition_iterate (dest_dev->disk, identify_partmap, &ctx);
|
||||
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
/* Copy the partition table. */
|
||||
if (ctx.dest_partmap ||
|
||||
(!allow_floppy && !grub_util_biosdisk_is_floppy (dest_dev->disk)))
|
||||
memcpy (boot_img + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC,
|
||||
tmp_img + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC,
|
||||
GRUB_BOOT_MACHINE_PART_END - GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC);
|
||||
|
||||
free (tmp_img);
|
||||
#endif
|
||||
|
||||
if (ctx.container
|
||||
&& grub_strcmp (ctx.container->partmap->name, "msdos") == 0
|
||||
&& ctx.dest_partmap
|
||||
&& (ctx.container->msdostype == GRUB_PC_PARTITION_TYPE_NETBSD
|
||||
|| ctx.container->msdostype == GRUB_PC_PARTITION_TYPE_OPENBSD))
|
||||
{
|
||||
grub_util_warn ("%s", _("Attempting to install GRUB to a disk with multiple partition labels or both partition label and filesystem. This is not supported yet."));
|
||||
goto unable_to_embed;
|
||||
}
|
||||
|
||||
fs = grub_fs_probe (dest_dev);
|
||||
if (!fs)
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
is_ldm = grub_util_is_ldm (dest_dev->disk);
|
||||
|
||||
if (fs_probe)
|
||||
{
|
||||
if (!fs && !ctx.dest_partmap)
|
||||
grub_util_error (_("unable to identify a filesystem in %s; safety check can't be performed"),
|
||||
dest_dev->disk->name);
|
||||
if (fs && !fs->reserved_first_sector)
|
||||
/* TRANSLATORS: Filesystem may reserve the space just GRUB isn't sure about it. */
|
||||
grub_util_error (_("%s appears to contain a %s filesystem which isn't known to "
|
||||
"reserve space for DOS-style boot. Installing GRUB there could "
|
||||
"result in FILESYSTEM DESTRUCTION if valuable data is overwritten "
|
||||
"by grub-setup (--skip-fs-probe disables this "
|
||||
"check, use at your own risk)"), dest_dev->disk->name, fs->name);
|
||||
|
||||
if (ctx.dest_partmap && strcmp (ctx.dest_partmap->name, "msdos") != 0
|
||||
&& strcmp (ctx.dest_partmap->name, "gpt") != 0
|
||||
&& strcmp (ctx.dest_partmap->name, "bsd") != 0
|
||||
&& strcmp (ctx.dest_partmap->name, "netbsd") != 0
|
||||
&& strcmp (ctx.dest_partmap->name, "openbsd") != 0
|
||||
&& strcmp (ctx.dest_partmap->name, "sunpc") != 0)
|
||||
/* TRANSLATORS: Partition map may reserve the space just GRUB isn't sure about it. */
|
||||
grub_util_error (_("%s appears to contain a %s partition map which isn't known to "
|
||||
"reserve space for DOS-style boot. Installing GRUB there could "
|
||||
"result in FILESYSTEM DESTRUCTION if valuable data is overwritten "
|
||||
"by grub-setup (--skip-fs-probe disables this "
|
||||
"check, use at your own risk)"), dest_dev->disk->name, ctx.dest_partmap->name);
|
||||
if (is_ldm && ctx.dest_partmap && strcmp (ctx.dest_partmap->name, "msdos") != 0
|
||||
&& strcmp (ctx.dest_partmap->name, "gpt") != 0)
|
||||
grub_util_error (_("%s appears to contain a %s partition map and "
|
||||
"LDM which isn't known to be a safe combination."
|
||||
" Installing GRUB there could "
|
||||
"result in FILESYSTEM DESTRUCTION if valuable data"
|
||||
" is overwritten "
|
||||
"by grub-setup (--skip-fs-probe disables this "
|
||||
"check, use at your own risk)"),
|
||||
dest_dev->disk->name, ctx.dest_partmap->name);
|
||||
|
||||
}
|
||||
|
||||
if (! ctx.dest_partmap && ! fs && !is_ldm)
|
||||
{
|
||||
grub_util_warn ("%s", _("Attempting to install GRUB to a partitionless disk or to a partition. This is a BAD idea."));
|
||||
goto unable_to_embed;
|
||||
}
|
||||
if (ctx.multiple_partmaps || (ctx.dest_partmap && fs) || (is_ldm && fs))
|
||||
{
|
||||
grub_util_warn ("%s", _("Attempting to install GRUB to a disk with multiple partition labels. This is not supported yet."));
|
||||
goto unable_to_embed;
|
||||
}
|
||||
|
||||
if (ctx.dest_partmap && !ctx.dest_partmap->embed)
|
||||
{
|
||||
grub_util_warn (_("Partition style `%s' doesn't support embedding"),
|
||||
ctx.dest_partmap->name);
|
||||
goto unable_to_embed;
|
||||
}
|
||||
|
||||
if (fs && !fs->fs_embed)
|
||||
{
|
||||
grub_util_warn (_("File system `%s' doesn't support embedding"),
|
||||
fs->name);
|
||||
goto unable_to_embed;
|
||||
}
|
||||
|
||||
nsec = core_sectors;
|
||||
|
||||
if (add_rs_codes)
|
||||
maxsec = 2 * core_sectors;
|
||||
else
|
||||
maxsec = core_sectors;
|
||||
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
if (maxsec > ((0x78000 - GRUB_KERNEL_I386_PC_LINK_ADDR)
|
||||
>> GRUB_DISK_SECTOR_BITS))
|
||||
maxsec = ((0x78000 - GRUB_KERNEL_I386_PC_LINK_ADDR)
|
||||
>> GRUB_DISK_SECTOR_BITS);
|
||||
#endif
|
||||
|
||||
#ifdef GRUB_SETUP_SPARC64
|
||||
/*
|
||||
* On SPARC we need two extra. One is because we are combining the
|
||||
* core.img with the boot.img. The other is because the boot sector
|
||||
* starts at 1.
|
||||
*/
|
||||
nsec += 2;
|
||||
maxsec += 2;
|
||||
#endif
|
||||
|
||||
if (is_ldm)
|
||||
err = grub_util_ldm_embed (dest_dev->disk, &nsec, maxsec,
|
||||
GRUB_EMBED_PCBIOS, §ors);
|
||||
else if (ctx.dest_partmap)
|
||||
err = ctx.dest_partmap->embed (dest_dev->disk, &nsec, maxsec,
|
||||
GRUB_EMBED_PCBIOS, §ors);
|
||||
else
|
||||
err = fs->fs_embed (dest_dev, &nsec, maxsec,
|
||||
GRUB_EMBED_PCBIOS, §ors);
|
||||
if (!err && nsec < core_sectors)
|
||||
{
|
||||
err = grub_error (GRUB_ERR_OUT_OF_RANGE,
|
||||
N_("Your embedding area is unusually small. "
|
||||
"core.img won't fit in it."));
|
||||
}
|
||||
|
||||
if (err)
|
||||
{
|
||||
grub_util_warn ("%s", grub_errmsg);
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
goto unable_to_embed;
|
||||
}
|
||||
|
||||
assert (nsec <= maxsec);
|
||||
|
||||
/* Clean out the blocklists. */
|
||||
bl.block = bl.first_block;
|
||||
while (bl.block->len)
|
||||
{
|
||||
grub_memset (bl.block, 0, sizeof (*bl.block));
|
||||
|
||||
bl.block--;
|
||||
|
||||
if ((char *) bl.block <= core_img)
|
||||
grub_util_error ("%s", _("no terminator in the core image"));
|
||||
}
|
||||
|
||||
bl.block = bl.first_block;
|
||||
for (i = 0; i < nsec; i++)
|
||||
save_blocklists (sectors[i] + grub_partition_get_start (ctx.container),
|
||||
0, GRUB_DISK_SECTOR_SIZE, &bl);
|
||||
|
||||
/* Make sure that the last blocklist is a terminator. */
|
||||
if (bl.block == bl.first_block)
|
||||
bl.block--;
|
||||
bl.block->start = 0;
|
||||
bl.block->len = 0;
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
bl.block->segment = 0;
|
||||
#endif
|
||||
|
||||
#ifdef GRUB_SETUP_SPARC64
|
||||
{
|
||||
/*
|
||||
* On SPARC, the block-list entries need to be based off the beginning
|
||||
* of the parition, not the beginning of the disk.
|
||||
*/
|
||||
struct grub_boot_blocklist *block;
|
||||
block = bl.first_block;
|
||||
|
||||
while (block->len)
|
||||
{
|
||||
block->start -= bl.first_sector;
|
||||
block--;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Reserve space for the boot block since it can not be in the
|
||||
* Parition table on SPARC.
|
||||
*/
|
||||
assert (bl.first_block->len > 2);
|
||||
bl.first_block->start += 2;
|
||||
bl.first_block->len -= 2;
|
||||
write_rootdev (root_dev, boot_img, sectors[BOOT_SECTOR + 1] - bl.first_sector);
|
||||
#endif
|
||||
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
write_rootdev (root_dev, boot_img, bl.first_sector);
|
||||
#endif
|
||||
|
||||
/* Round up to the nearest sector boundary, and zero the extra memory */
|
||||
core_img = xrealloc (core_img, nsec * GRUB_DISK_SECTOR_SIZE);
|
||||
assert (core_img && (nsec * GRUB_DISK_SECTOR_SIZE >= core_size));
|
||||
memset (core_img + core_size, 0, nsec * GRUB_DISK_SECTOR_SIZE - core_size);
|
||||
|
||||
bl.first_block = (struct grub_boot_blocklist *) (core_img
|
||||
+ GRUB_DISK_SECTOR_SIZE
|
||||
- sizeof (*bl.block));
|
||||
#if GRUB_SETUP_BIOS
|
||||
grub_size_t no_rs_length;
|
||||
no_rs_length = grub_target_to_host16
|
||||
(grub_get_unaligned16 (core_img
|
||||
+ GRUB_DISK_SECTOR_SIZE
|
||||
+ GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_LENGTH));
|
||||
|
||||
if (no_rs_length == 0xffff)
|
||||
grub_util_error ("%s", _("core.img version mismatch"));
|
||||
|
||||
if (add_rs_codes)
|
||||
{
|
||||
grub_set_unaligned32 ((core_img + GRUB_DISK_SECTOR_SIZE
|
||||
+ GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY),
|
||||
grub_host_to_target32 (nsec * GRUB_DISK_SECTOR_SIZE - core_size));
|
||||
|
||||
void *tmp = xmalloc (core_size);
|
||||
grub_memcpy (tmp, core_img, core_size);
|
||||
grub_reed_solomon_add_redundancy (core_img + no_rs_length + GRUB_DISK_SECTOR_SIZE,
|
||||
core_size - no_rs_length - GRUB_DISK_SECTOR_SIZE,
|
||||
nsec * GRUB_DISK_SECTOR_SIZE
|
||||
- core_size);
|
||||
assert (grub_memcmp (tmp, core_img, core_size) == 0);
|
||||
free (tmp);
|
||||
}
|
||||
|
||||
/* Write the core image onto the disk. */
|
||||
for (i = 0; i < nsec; i++)
|
||||
grub_disk_write (dest_dev->disk, sectors[i], 0,
|
||||
GRUB_DISK_SECTOR_SIZE,
|
||||
core_img + i * GRUB_DISK_SECTOR_SIZE);
|
||||
#endif
|
||||
|
||||
#ifdef GRUB_SETUP_SPARC64
|
||||
{
|
||||
int isec = BOOT_SECTOR;
|
||||
|
||||
/* Write the boot image onto the disk. */
|
||||
if (grub_disk_write (dest_dev->disk, sectors[isec++], 0,
|
||||
GRUB_DISK_SECTOR_SIZE, boot_img))
|
||||
grub_util_error ("%s", grub_errmsg);
|
||||
|
||||
/* Write the core image onto the disk. */
|
||||
for (i = 0 ; isec < nsec; i++, isec++)
|
||||
{
|
||||
if (grub_disk_write (dest_dev->disk, sectors[isec], 0,
|
||||
GRUB_DISK_SECTOR_SIZE,
|
||||
core_img + i * GRUB_DISK_SECTOR_SIZE))
|
||||
grub_util_error ("%s", grub_errmsg);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
grub_free (sectors);
|
||||
|
||||
goto finish;
|
||||
}
|
||||
|
||||
unable_to_embed:
|
||||
|
||||
if (dest_dev->disk->dev->id != root_dev->disk->dev->id)
|
||||
grub_util_error ("%s", _("embedding is not possible, but this is required for "
|
||||
"RAID and LVM install"));
|
||||
|
||||
{
|
||||
grub_fs_t fs;
|
||||
fs = grub_fs_probe (root_dev);
|
||||
if (!fs)
|
||||
grub_util_error (_("can't determine filesystem on %s"), root);
|
||||
|
||||
if (!fs->blocklist_install)
|
||||
grub_util_error (_("filesystem `%s' doesn't support blocklists"),
|
||||
fs->name);
|
||||
}
|
||||
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
if (dest_dev->disk->id != root_dev->disk->id
|
||||
|| dest_dev->disk->dev->id != root_dev->disk->dev->id)
|
||||
/* TRANSLATORS: cross-disk refers to /boot being on one disk
|
||||
but MBR on another. */
|
||||
grub_util_error ("%s", _("embedding is not possible, but this is required for "
|
||||
"cross-disk install"));
|
||||
#else
|
||||
core_dev = root_dev;
|
||||
#endif
|
||||
|
||||
grub_util_warn ("%s", _("Embedding is not possible. GRUB can only be installed in this "
|
||||
"setup by using blocklists. However, blocklists are UNRELIABLE and "
|
||||
"their use is discouraged."));
|
||||
if (! force)
|
||||
/* TRANSLATORS: Here GRUB refuses to continue with blocklist install. */
|
||||
grub_util_error ("%s", _("will not proceed with blocklists"));
|
||||
|
||||
/* The core image must be put on a filesystem unfortunately. */
|
||||
grub_util_info ("will leave the core image on the filesystem");
|
||||
|
||||
grub_util_biosdisk_flush (root_dev->disk);
|
||||
|
||||
/* Clean out the blocklists. */
|
||||
bl.block = bl.first_block;
|
||||
while (bl.block->len)
|
||||
{
|
||||
bl.block->start = 0;
|
||||
bl.block->len = 0;
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
bl.block->segment = 0;
|
||||
#endif
|
||||
|
||||
bl.block--;
|
||||
|
||||
if ((char *) bl.block <= core_img)
|
||||
grub_util_error ("%s", _("no terminator in the core image"));
|
||||
}
|
||||
|
||||
bl.block = bl.first_block;
|
||||
|
||||
#ifdef GRUB_SETUP_SPARC64
|
||||
{
|
||||
grub_partition_t container = root_dev->disk->partition;
|
||||
bl.gpt_offset = 0;
|
||||
|
||||
if (grub_strstr (container->partmap->name, "gpt"))
|
||||
bl.gpt_offset = grub_partition_get_start (container);
|
||||
}
|
||||
#endif
|
||||
|
||||
grub_install_get_blocklist (root_dev, core_path, core_img, core_size,
|
||||
save_blocklists, &bl);
|
||||
|
||||
if (bl.first_sector == (grub_disk_addr_t)-1)
|
||||
grub_util_error ("%s", _("can't retrieve blocklists"));
|
||||
|
||||
#ifdef GRUB_SETUP_SPARC64
|
||||
{
|
||||
char *boot_devpath;
|
||||
boot_devpath = (char *) (boot_img
|
||||
+ GRUB_BOOT_AOUT_HEADER_SIZE
|
||||
+ GRUB_BOOT_MACHINE_BOOT_DEVPATH);
|
||||
if (dest_dev->disk->id != root_dev->disk->id
|
||||
|| dest_dev->disk->dev->id != root_dev->disk->dev->id)
|
||||
{
|
||||
char *dest_ofpath;
|
||||
dest_ofpath
|
||||
= grub_util_devname_to_ofpath (grub_util_biosdisk_get_osdev (root_dev->disk));
|
||||
/* FIXME handle NULL result */
|
||||
grub_util_info ("dest_ofpath is `%s'", dest_ofpath);
|
||||
strncpy (boot_devpath, dest_ofpath,
|
||||
GRUB_BOOT_MACHINE_BOOT_DEVPATH_END
|
||||
- GRUB_BOOT_MACHINE_BOOT_DEVPATH - 1);
|
||||
boot_devpath[GRUB_BOOT_MACHINE_BOOT_DEVPATH_END
|
||||
- GRUB_BOOT_MACHINE_BOOT_DEVPATH - 1] = 0;
|
||||
free (dest_ofpath);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_util_info ("non cross-disk install");
|
||||
memset (boot_devpath, 0, GRUB_BOOT_MACHINE_BOOT_DEVPATH_END
|
||||
- GRUB_BOOT_MACHINE_BOOT_DEVPATH);
|
||||
}
|
||||
grub_util_info ("boot device path %s", boot_devpath);
|
||||
}
|
||||
#endif
|
||||
|
||||
write_rootdev (root_dev, boot_img, bl.first_sector);
|
||||
|
||||
/* Write the first two sectors of the core image onto the disk. */
|
||||
grub_util_info ("opening the core image `%s'", core_path);
|
||||
fp = grub_util_fd_open (core_path, GRUB_UTIL_FD_O_WRONLY);
|
||||
if (! GRUB_UTIL_FD_IS_VALID (fp))
|
||||
grub_util_error (_("cannot open `%s': %s"), core_path,
|
||||
grub_util_fd_strerror ());
|
||||
|
||||
if (grub_util_fd_write (fp, core_img, GRUB_DISK_SECTOR_SIZE * 2)
|
||||
!= GRUB_DISK_SECTOR_SIZE * 2)
|
||||
grub_util_error (_("cannot write to `%s': %s"),
|
||||
core_path, strerror (errno));
|
||||
if (grub_util_fd_sync (fp) < 0)
|
||||
grub_util_error (_("cannot sync `%s': %s"), core_path, strerror (errno));
|
||||
if (grub_util_fd_close (fp) < 0)
|
||||
grub_util_error (_("cannot close `%s': %s"), core_path, strerror (errno));
|
||||
grub_util_biosdisk_flush (root_dev->disk);
|
||||
|
||||
grub_disk_cache_invalidate_all ();
|
||||
|
||||
{
|
||||
char *buf, *ptr = core_img;
|
||||
size_t len = core_size;
|
||||
grub_uint64_t blk, offset = 0;
|
||||
grub_partition_t container = core_dev->disk->partition;
|
||||
grub_err_t err;
|
||||
|
||||
core_dev->disk->partition = 0;
|
||||
#ifdef GRUB_SETUP_SPARC64
|
||||
offset = bl.gpt_offset;
|
||||
#endif
|
||||
|
||||
buf = xmalloc (core_size);
|
||||
blk = bl.first_sector;
|
||||
err = grub_disk_read (core_dev->disk, blk + offset, 0, GRUB_DISK_SECTOR_SIZE, buf);
|
||||
if (err)
|
||||
grub_util_error (_("cannot read `%s': %s"), core_dev->disk->name,
|
||||
grub_errmsg);
|
||||
if (grub_memcmp (buf, ptr, GRUB_DISK_SECTOR_SIZE) != 0)
|
||||
grub_util_error ("%s", _("blocklists are invalid"));
|
||||
|
||||
ptr += GRUB_DISK_SECTOR_SIZE;
|
||||
len -= GRUB_DISK_SECTOR_SIZE;
|
||||
|
||||
bl.block = bl.first_block;
|
||||
while (bl.block->len)
|
||||
{
|
||||
size_t cur = grub_target_to_host16 (bl.block->len) << GRUB_DISK_SECTOR_BITS;
|
||||
blk = grub_target_to_host64 (bl.block->start);
|
||||
|
||||
if (cur > len)
|
||||
cur = len;
|
||||
|
||||
err = grub_disk_read (core_dev->disk, blk + offset, 0, cur, buf);
|
||||
if (err)
|
||||
grub_util_error (_("cannot read `%s': %s"), core_dev->disk->name,
|
||||
grub_errmsg);
|
||||
|
||||
if (grub_memcmp (buf, ptr, cur) != 0)
|
||||
grub_util_error ("%s", _("blocklists are invalid"));
|
||||
|
||||
ptr += cur;
|
||||
len -= cur;
|
||||
bl.block--;
|
||||
|
||||
if ((char *) bl.block <= core_img)
|
||||
grub_util_error ("%s", _("no terminator in the core image"));
|
||||
}
|
||||
if (len)
|
||||
grub_util_error ("%s", _("blocklists are incomplete"));
|
||||
core_dev->disk->partition = container;
|
||||
free (buf);
|
||||
}
|
||||
|
||||
#ifdef GRUB_SETUP_BIOS
|
||||
finish:
|
||||
#endif
|
||||
|
||||
/* Write the boot image onto the disk. */
|
||||
if (grub_disk_write (dest_dev->disk, BOOT_SECTOR,
|
||||
0, GRUB_DISK_SECTOR_SIZE, boot_img))
|
||||
grub_util_error ("%s", grub_errmsg);
|
||||
|
||||
#ifdef GRUB_SETUP_SPARC64
|
||||
finish:
|
||||
#endif
|
||||
|
||||
grub_util_biosdisk_flush (root_dev->disk);
|
||||
grub_util_biosdisk_flush (dest_dev->disk);
|
||||
|
||||
free (core_path);
|
||||
free (core_img);
|
||||
free (boot_img);
|
||||
grub_device_close (dest_dev);
|
||||
grub_device_close (root_dev);
|
||||
}
|
||||
|
@@ -36,6 +36,10 @@ done
|
||||
$BUSYBOX_PATH/umount /vtmnt && $BUSYBOX_PATH/rm -rf /vtmnt
|
||||
$BUSYBOX_PATH/cp -a /ventoy /ventoy_rdroot
|
||||
|
||||
if [ -f /etc/default/cdlinux ]; then
|
||||
echo "CDL_WAIT=60" >> /etc/default/cdlinux
|
||||
fi
|
||||
|
||||
echo 'echo "CDL_DEV=/dev/mapper/ventoy" >>"$VAR_FILE"' >> /ventoy_rdroot/etc/rc.d/rc.var
|
||||
|
||||
ventoy_set_rule_dir_prefix /ventoy_rdroot
|
||||
|
@@ -31,10 +31,11 @@ done
|
||||
|
||||
ventoy_extract_vtloopex ${vtdiskname}2 crux
|
||||
|
||||
|
||||
vtKver=$(uname -r)
|
||||
vtLoopExDir=$VTOY_PATH/vtloopex/crux/vtloopex
|
||||
$BUSYBOX_PATH/xz -d $vtLoopExDir/dm-mod/$(uname -r)/64/dax.ko.xz
|
||||
$BUSYBOX_PATH/xz -d $vtLoopExDir/dm-mod/$(uname -r)/64/dm-mod.ko.xz
|
||||
$BUSYBOX_PATH/insmod $vtLoopExDir/dm-mod/$(uname -r)/64/dax.ko
|
||||
$BUSYBOX_PATH/insmod $vtLoopExDir/dm-mod/$(uname -r)/64/dm-mod.ko
|
||||
|
||||
ventoy_check_install_module_xz $vtLoopExDir/dm-mod/$vtKver/64/dax.ko
|
||||
ventoy_check_install_module_xz $vtLoopExDir/dm-mod/$vtKver/64/dm-mod.ko
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
|
||||
|
47
IMG/cpio/ventoy/hook/debian/mocaccino-disk.sh
Normal file
47
IMG/cpio/ventoy/hook/debian/mocaccino-disk.sh
Normal file
@@ -0,0 +1,47 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
. /ventoy/hook/ventoy-hook-lib.sh
|
||||
|
||||
if is_ventoy_hook_finished; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
vtlog "####### $0 $* ########"
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
wait_for_usb_disk_ready
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
vtlog "ventoy disk not found"
|
||||
PATH=$VTPATH_OLD
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
|
||||
|
||||
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
|
||||
vtDM=$(ventoy_find_dm_id ${blkdev_num})
|
||||
vtlog "/dev/$vtDM"
|
||||
|
||||
PATH=$VTPATH_OLD
|
||||
|
||||
set_ventoy_hook_finish
|
20
IMG/cpio/ventoy/hook/debian/mocaccino-hook.sh
Normal file
20
IMG/cpio/ventoy/hook/debian/mocaccino-hook.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/ventoy/busybox/sh
|
||||
#************************************************************************************
|
||||
# Copyright (c) 2020, longpanda <admin@ventoy.net>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#************************************************************************************
|
||||
|
||||
$SED "/mount_system *$/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/mocaccino-disk.sh" -i /loader
|
@@ -90,6 +90,9 @@ ventoy_get_debian_distro() {
|
||||
echo 'kerio'; return
|
||||
fi
|
||||
|
||||
if $GREP -q 'mocaccino' /proc/version; then
|
||||
echo 'mocaccino'; return
|
||||
fi
|
||||
|
||||
echo 'default'
|
||||
}
|
||||
|
@@ -96,6 +96,12 @@ if $GREP -q el8 /proc/version; then
|
||||
vtNeedRepo="yes"
|
||||
fi
|
||||
|
||||
if $GREP -i -q Fedora /proc/version; then
|
||||
if $GREP -q 'Server Edition' /etc/os-release; then
|
||||
vtNeedRepo="yes"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$vtNeedRepo" = "yes" ]; then
|
||||
$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel7/ventoy-repo.sh /lib/dracut/hooks/pre-pivot/99-ventoy-repo.sh
|
||||
fi
|
||||
|
@@ -57,14 +57,14 @@ vterr() {
|
||||
|
||||
|
||||
is_ventoy_hook_finished() {
|
||||
[ -e $VTOY_PATH/hook_finish ]
|
||||
[ -e $VTOY_PATH/hook_finish ]
|
||||
}
|
||||
|
||||
set_ventoy_hook_finish() {
|
||||
echo 'Y' > $VTOY_PATH/hook_finish
|
||||
echo 'Y' > $VTOY_PATH/hook_finish
|
||||
}
|
||||
|
||||
get_ventoy_disk_name() {
|
||||
get_ventoy_disk_name() {
|
||||
line=$($VTOY_PATH/tool/vtoydump -f /ventoy/ventoy_os_param)
|
||||
if [ $? -eq 0 ]; then
|
||||
echo ${line%%#*}
|
||||
@@ -74,7 +74,7 @@ get_ventoy_disk_name() {
|
||||
}
|
||||
|
||||
get_ventoy_iso_name() {
|
||||
line=$($VTOY_PATH/tool/vtoydump -f /ventoy/ventoy_os_param)
|
||||
line=$($VTOY_PATH/tool/vtoydump -f /ventoy/ventoy_os_param)
|
||||
if [ $? -eq 0 ]; then
|
||||
echo ${line##*#}
|
||||
else
|
||||
@@ -83,8 +83,9 @@ get_ventoy_iso_name() {
|
||||
}
|
||||
|
||||
wait_for_usb_disk_ready() {
|
||||
while [ -n "Y" ]; do
|
||||
usb_disk=$(get_ventoy_disk_name)
|
||||
vtloop=0
|
||||
while [ -n "Y" ]; do
|
||||
usb_disk=$(get_ventoy_disk_name)
|
||||
vtlog "wait_for_usb_disk_ready $usb_disk ..."
|
||||
|
||||
if echo $usb_disk | $EGREP -q "nvme|mmc|nbd"; then
|
||||
@@ -95,13 +96,20 @@ wait_for_usb_disk_ready() {
|
||||
|
||||
if [ -e "${vtpart2}" ]; then
|
||||
vtlog "wait_for_usb_disk_ready $usb_disk finish"
|
||||
break
|
||||
else
|
||||
$SLEEP 0.3
|
||||
fi
|
||||
done
|
||||
break
|
||||
else
|
||||
let vtloop=vtloop+1
|
||||
if [ $vtloop -gt 2 ]; then
|
||||
if [ "$VTLOG" != "$VTOY_PATH/log" ]; then
|
||||
$VTOY_PATH/tool/vtoydump -f /ventoy/ventoy_os_param -v > $VTLOG
|
||||
fi
|
||||
fi
|
||||
$SLEEP 0.3
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
check_usb_disk_ready() {
|
||||
if echo $1 | $EGREP -q "nvme|mmc|nbd"; then
|
||||
vtpart2=${1}p2
|
||||
@@ -610,3 +618,10 @@ ventoy_extract_vtloopex() {
|
||||
|
||||
cd $vtCurPwd
|
||||
}
|
||||
|
||||
ventoy_check_install_module_xz() {
|
||||
if [ -f "${1}.xz" ]; then
|
||||
$BUSYBOX_PATH/xz -d "${1}.xz"
|
||||
$BUSYBOX_PATH/insmod "$1"
|
||||
fi
|
||||
}
|
||||
|
@@ -34,9 +34,19 @@ else
|
||||
vtBit=32
|
||||
fi
|
||||
|
||||
xz -d $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dm-mod.ko.xz
|
||||
insmod $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dm-mod.ko
|
||||
if grep -q "device-mapper" /proc/devices; then
|
||||
vtlog "device-mapper enabled by system"
|
||||
else
|
||||
if [ -f $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dax.ko.xz ]; then
|
||||
xz -d $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dax.ko.xz
|
||||
insmod $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dax.ko
|
||||
fi
|
||||
|
||||
if [ -f $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dm-mod.ko.xz ]; then
|
||||
xz -d $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dm-mod.ko.xz
|
||||
insmod $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dm-mod.ko
|
||||
fi
|
||||
fi
|
||||
|
||||
wait_for_usb_disk_ready
|
||||
|
||||
|
@@ -27,7 +27,83 @@ vtlog "####### $0 $* ########"
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
wait_for_usb_disk_ready
|
||||
check_mkdev_node() {
|
||||
for i in $(ls /sys/class/block/); do
|
||||
if ! [ -e /dev/$i ]; then
|
||||
blkdev_num=$(sed 's/:/ /g' /sys/class/block/$i/dev)
|
||||
vtlog "mknod -m 0666 /dev/$i b $blkdev_num"
|
||||
mknod -m 0666 /dev/$i b $blkdev_num
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
check_insmod() {
|
||||
if [ -f "$1" ]; then
|
||||
vtlog "insmod $1"
|
||||
insmod "$1" >> $VTOY_PATH/log 2>&1
|
||||
else
|
||||
vtlog "$1 not exist"
|
||||
fi
|
||||
}
|
||||
|
||||
wrt_insmod() {
|
||||
kbit=$1
|
||||
kv=$(uname -r)
|
||||
|
||||
vtlog "insmod $kv $kbit"
|
||||
|
||||
check_insmod /ventoy_openwrt/$kv/$kbit/dax.ko
|
||||
check_insmod /ventoy_openwrt/$kv/$kbit/dm-mod.ko
|
||||
}
|
||||
|
||||
insmod_dm_mod() {
|
||||
if grep -q "device-mapper" /proc/devices; then
|
||||
vtlog "device-mapper enabled by system 0"
|
||||
return
|
||||
fi
|
||||
|
||||
check_insmod /ventoy/modules/dax.ko
|
||||
check_insmod /ventoy/modules/dm-mod.ko
|
||||
|
||||
if grep -q "device-mapper" /proc/devices; then
|
||||
vtlog "device-mapper enabled by system 1"
|
||||
return
|
||||
fi
|
||||
|
||||
if [ -f /ventoy_openwrt.xz ]; then
|
||||
tar xf /ventoy_openwrt.xz -C /
|
||||
rm -f /ventoy_openwrt.xz
|
||||
fi
|
||||
|
||||
if uname -m | egrep -q "amd64|x86_64"; then
|
||||
wrt_insmod 64
|
||||
else
|
||||
wrt_insmod generic
|
||||
if lsmod | grep -q 'dm-mod'; then
|
||||
vterr "insmod generic failed"
|
||||
else
|
||||
wrt_insmod legacy
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
insmod_dm_mod
|
||||
|
||||
check_mkdev_node
|
||||
sleep 1
|
||||
|
||||
while [ -n "Y" ]; do
|
||||
vtusb_disk=$(get_ventoy_disk_name)
|
||||
if check_usb_disk_ready "$vtusb_disk"; then
|
||||
vtlog "get_ventoy_disk_name $vtusb_disk ready"
|
||||
break;
|
||||
else
|
||||
vtlog "get_ventoy_disk_name $vtusb_disk not ready"
|
||||
sleep 2
|
||||
check_mkdev_node
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
vtdiskname=$(get_ventoy_disk_name)
|
||||
if [ "$vtdiskname" = "unknown" ]; then
|
||||
@@ -44,6 +120,8 @@ echo -n $vtDM > /ventoy/vtDM
|
||||
|
||||
ventoy_create_dev_ventoy_part
|
||||
mdev -s
|
||||
check_mkdev_node
|
||||
|
||||
|
||||
mkdir /ventoy_rdroot
|
||||
mount /dev/ventoy2 /ventoy_rdroot
|
||||
|
@@ -21,37 +21,8 @@
|
||||
|
||||
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
|
||||
|
||||
wrt_insmod() {
|
||||
kbit=$1
|
||||
kv=$(uname -r)
|
||||
|
||||
echo "insmod $kv $kbit" >> $VTOY_PATH/log
|
||||
|
||||
[ -f /ventoy_openwrt/$kv/$kbit/dax.ko ] && insmod /ventoy_openwrt/$kv/$kbit/dax.ko > /dev/null 2>&1
|
||||
[ -f /ventoy_openwrt/$kv/$kbit/dm-mod.ko ] && insmod /ventoy_openwrt/$kv/$kbit/dm-mod.ko > /dev/null 2>&1
|
||||
}
|
||||
|
||||
|
||||
mkdir /sys
|
||||
mount -t sysfs sys /sys
|
||||
mdev -s
|
||||
|
||||
|
||||
if [ -f /ventoy_openwrt.xz ]; then
|
||||
tar xf /ventoy_openwrt.xz -C /
|
||||
rm -f /ventoy_openwrt.xz
|
||||
fi
|
||||
|
||||
|
||||
if uname -m | egrep -q "amd64|x86_64"; then
|
||||
wrt_insmod 64
|
||||
else
|
||||
wrt_insmod generic
|
||||
if lsmod | grep -q 'dm-mod'; then
|
||||
echo "insmod generic failed" >> $VTOY_PATH/log
|
||||
else
|
||||
wrt_insmod legacy
|
||||
fi
|
||||
fi
|
||||
|
||||
sh $VTOY_PATH/loop/openwrt/ventoy-disk.sh
|
||||
|
BIN
IMG/vtloopex/lakka/vtloopex/dm-mod/5.10.35/64/dax.ko.xz
Normal file
BIN
IMG/vtloopex/lakka/vtloopex/dm-mod/5.10.35/64/dax.ko.xz
Normal file
Binary file not shown.
BIN
IMG/vtloopex/lakka/vtloopex/dm-mod/5.10.35/64/dm-mod.ko.xz
Normal file
BIN
IMG/vtloopex/lakka/vtloopex/dm-mod/5.10.35/64/dm-mod.ko.xz
Normal file
Binary file not shown.
@@ -4,6 +4,7 @@ size=1024
|
||||
fstype=ext4
|
||||
label=casper-rw
|
||||
config=''
|
||||
outputfile=persistence.dat
|
||||
|
||||
print_usage() {
|
||||
echo 'Usage: CreatePersistentImg.sh [ -s size ] [ -t fstype ] [ -l LABEL ] [ -c CFG ]'
|
||||
@@ -12,6 +13,7 @@ print_usage() {
|
||||
echo ' -t filesystem type, default is ext4 ext2/ext3/ext4/xfs are supported now'
|
||||
echo ' -l label, default is casper-rw'
|
||||
echo ' -c configfile name inside the persistence file. File content is "/ union"'
|
||||
echo ' -o outputfile name, default is persistence.dat'
|
||||
echo ''
|
||||
}
|
||||
|
||||
@@ -28,6 +30,9 @@ while [ -n "$1" ]; do
|
||||
elif [ "$1" = "-c" ]; then
|
||||
shift
|
||||
config=$1
|
||||
elif [ "$1" = "-o" ]; then
|
||||
shift
|
||||
outputfile=$1
|
||||
elif [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
||||
print_usage
|
||||
exit 0
|
||||
@@ -69,13 +74,17 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$outputdir" != "persistence.dat" ]; then
|
||||
mkdir -p "$(dirname "$outputfile")"
|
||||
fi
|
||||
|
||||
# 00->ff avoid sparse file
|
||||
dd if=/dev/zero bs=1M count=$size | tr '\000' '\377' > persistence.dat
|
||||
dd if=/dev/zero bs=1M count=$size | tr '\000' '\377' > "$outputfile"
|
||||
sync
|
||||
|
||||
freeloop=$(losetup -f)
|
||||
|
||||
losetup $freeloop persistence.dat
|
||||
losetup $freeloop "$outputfile"
|
||||
|
||||
mkfs -t $fstype $fsopt -L $label $freeloop
|
||||
|
||||
|
97
INSTALL/ExtendPersistentImg.sh
Normal file
97
INSTALL/ExtendPersistentImg.sh
Normal file
@@ -0,0 +1,97 @@
|
||||
#!/bin/sh
|
||||
|
||||
print_usage() {
|
||||
echo 'Usage: ExtendPersistentImg.sh file size'
|
||||
echo ' file persistent dat file'
|
||||
echo ' size extend size in MB'
|
||||
echo 'Example:'
|
||||
echo ' sh ExtendPersistentImg.sh ubuntu.dat 2048'
|
||||
echo ''
|
||||
}
|
||||
|
||||
if [ -z "$1" -o "$1" = "-h" ]; then
|
||||
print_usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$2" ]; then
|
||||
print_usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
file=$1
|
||||
size=$2
|
||||
|
||||
if [ ! -f "$file" ]; then
|
||||
echo "$file not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if echo $size | grep -q "[^0-9]"; then
|
||||
print_usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fsize=$(stat -c '%s' $file)
|
||||
|
||||
fsmod=$(expr $fsize % 1024)
|
||||
if [ $fsmod -ne 0 ]; then
|
||||
echo "File size of $file is not aligned by 1MB, please check."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
fsMB=$(expr $fsize / 1024 / 1024)
|
||||
total=$(expr $fsMB + $size)
|
||||
|
||||
magic=$(hexdump -n3 -e '3/1 "%02X"' $file)
|
||||
if [ "$magic" = "584653" ]; then
|
||||
if which xfs_growfs >/dev/null 2>&1; then
|
||||
cmd=xfs_growfs
|
||||
else
|
||||
echo 'xfs_growfs not found, please install xfsprogs first'
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
if which resize2fs >/dev/null 2>&1; then
|
||||
cmd=resize2fs
|
||||
else
|
||||
echo 'resize2fs not found, please install e2fsprogs first'
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
echo "Extend dat file... (current is ${fsMB}MB, append ${size}MB, total ${total}MB)"
|
||||
dd if=/dev/zero bs=1M count=$size status=none >> "$file"
|
||||
sync
|
||||
|
||||
freeloop=$(losetup -f)
|
||||
losetup $freeloop "$file"
|
||||
|
||||
if [ "$cmd" = "resize2fs" ]; then
|
||||
echo "Extend ext filesystem by resize2fs ..."
|
||||
echo "resize2fs $freeloop ${total}M"
|
||||
e2fsck -f $freeloop
|
||||
resize2fs $freeloop ${total}M
|
||||
ret=$?
|
||||
else
|
||||
echo "Extend xfs filesystem by xfs_growfs ..."
|
||||
|
||||
tmpdir=$(mktemp -d)
|
||||
mount $freeloop $tmpdir
|
||||
xfs_growfs $freeloop
|
||||
ret=$?
|
||||
umount $tmpdir && rm -rf $tmpdir
|
||||
fi
|
||||
|
||||
losetup -d $freeloop
|
||||
|
||||
echo ""
|
||||
if [ $ret -eq 0 ]; then
|
||||
echo "======= SUCCESS ========="
|
||||
else
|
||||
echo "======= FAILED ========="
|
||||
fi
|
||||
echo ""
|
||||
|
@@ -38,5 +38,12 @@ Please refer https://www.ventoy.net/en/plugin_persistence.html for details.
|
||||
|
||||
|
||||
|
||||
========== ExtendPersistentImg.sh ===============
|
||||
sudo sh ExtendPersistentImg.sh file size
|
||||
For example:
|
||||
sh ExtendPersistentImg.sh persistence.dat 2048 ----> Extend persistence.dat by 2048MB
|
||||
That is to say, persistence.dat file will grow to 3GB size (assume that it is 1GB size before extend)
|
||||
|
||||
Please refer https://www.ventoy.net/en/plugin_persistence.html for details.
|
||||
|
||||
|
||||
|
Binary file not shown.
@@ -23,7 +23,7 @@ sfs: fshelp
|
||||
reiserfs: fshelp
|
||||
part_sunpc:
|
||||
zstd:
|
||||
gfxmenu: video_colors trig bitmap_scale gfxterm font normal bitmap video
|
||||
gfxmenu: trig video_colors bitmap_scale gfxterm font normal bitmap video
|
||||
jfs:
|
||||
help: extcmd normal
|
||||
configfile: normal
|
||||
@@ -68,7 +68,7 @@ gfxterm_background: video_colors bitmap_scale gfxterm extcmd video bitmap
|
||||
search_fs_uuid:
|
||||
gcry_dsa: pgp mpi
|
||||
keystatus: extcmd
|
||||
linux: verifiers boot fdt
|
||||
linux: ventoy verifiers boot fdt
|
||||
geli: cryptodisk crypto gcry_sha512 pbkdf2 gcry_sha256
|
||||
cmdline_cat_test: font functional_test normal procfs video_fb
|
||||
part_sun:
|
||||
@@ -93,7 +93,7 @@ terminal:
|
||||
div:
|
||||
crypto:
|
||||
part_bsd: part_msdos
|
||||
ventoy: elf fshelp ext2 btrfs font crypto gcry_md5 exfat udf extcmd normal video gcry_sha1 iso9660
|
||||
ventoy: elf fshelp ext2 btrfs font crypto gcry_md5 exfat udf extcmd datetime div normal video gcry_sha1 iso9660
|
||||
gcry_sha512: crypto
|
||||
password: crypto normal
|
||||
fshelp:
|
||||
|
@@ -130,9 +130,7 @@ function get_os_type {
|
||||
|
||||
function vt_check_compatible_pe {
|
||||
#Check for PE without external tools
|
||||
if [ -f "$1/HBCD_PE.ini" ]; then
|
||||
set ventoy_compatible=YES
|
||||
fi
|
||||
return
|
||||
}
|
||||
|
||||
function locate_initrd {
|
||||
@@ -535,6 +533,10 @@ function uefi_windows_menu_func {
|
||||
vt_windows_chain_data "${1}${chosen_path}"
|
||||
ventoy_debug_pause
|
||||
|
||||
if vt_check_mode 4; then
|
||||
vtoy_windows_wimboot_func
|
||||
fi
|
||||
|
||||
if [ -n "$vtoy_chain_mem_addr" ]; then
|
||||
ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
|
||||
ventoy_cli_console
|
||||
@@ -634,6 +636,8 @@ function uefi_linux_menu_func {
|
||||
vt_add_replace_file 0 "EFI\\hyperiso\\hyperiso.img"
|
||||
fi
|
||||
elif [ -d (loop)/EFI/BOOT/entries ]; then
|
||||
vt_linux_get_main_initrd_index vtindex
|
||||
|
||||
if [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
|
||||
vt_add_replace_file 0 "EFI\\parabolaiso\\parabolaiso.img"
|
||||
elif [ -f (loop)/parabola/boot/x86_64/initramfs-linux-libre.img ]; then
|
||||
@@ -805,6 +809,86 @@ function uefi_iso_memdisk {
|
||||
}
|
||||
|
||||
|
||||
function vtoy_windows_wimboot_func {
|
||||
if [ -f (loop)/x86/sources/boot.wim -a -f (loop)/x64/sources/boot.wim ]; then
|
||||
vt_sel_wimboot vtoy_wimboot_bit
|
||||
if [ "$vtoy_wimboot_bit" = "32" ]; then
|
||||
set vtoy_wimboot_prefix=(loop)/x86
|
||||
else
|
||||
set vtoy_wimboot_prefix=(loop)/x64
|
||||
fi
|
||||
else
|
||||
set vtoy_wimboot_prefix=(loop)
|
||||
if vt_is_pe64 $vtoy_wimboot_prefix/setup.exe; then
|
||||
set vtoy_wimboot_bit=64
|
||||
else
|
||||
set vtoy_wimboot_bit=32
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "${vtdebug_flag}" ]; then
|
||||
echo vtoy_wimboot_prefix=$vtoy_wimboot_prefix vtoy_wimboot_bit=$vtoy_wimboot_bit
|
||||
fi
|
||||
|
||||
for wmfile in sources/boot.wim boot/bcd boot/boot.sdi; do
|
||||
if [ ! -f $vtoy_wimboot_prefix/$wmfile ]; then
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -f $vtoy_wimboot_prefix/sources/install.wim -o -f $vtoy_wimboot_prefix/sources/install.esd ]; then
|
||||
vt_windows_wimboot_data
|
||||
else
|
||||
return
|
||||
fi
|
||||
|
||||
if [ "$grub_platform" = "pc" ]; then
|
||||
set vt_wimkernel=wimboot.x86_64.xz
|
||||
|
||||
linux16 "$vtoy_path/$vt_wimkernel" quiet
|
||||
ventoy_debug_pause
|
||||
|
||||
vt_set_wim_load_prompt 1 "Loading files......"
|
||||
initrd16 newc:vtoyjump.exe:$vtoy_path/vtoyjump${vtoy_wimboot_bit}.exe \
|
||||
newc:wimboot.data:mem:${vtoy_wimboot_mem_addr}:size:${vtoy_wimboot_mem_size} \
|
||||
newc:winpeshl.ini:mem:${vtoy_winpeshl_ini_addr}:size:${vtoy_winpeshl_ini_size} \
|
||||
newc:bcd:$vtoy_wimboot_prefix/boot/bcd \
|
||||
newc:boot.sdi:$vtoy_wimboot_prefix/boot/boot.sdi \
|
||||
newc:boot.wim:$vtoy_wimboot_prefix/sources/boot.wim
|
||||
vt_set_wim_load_prompt 0
|
||||
boot
|
||||
else
|
||||
if [ "$grub_cpu" = "i386" ]; then
|
||||
set vt_wimkernel=wimboot.i386.efi.xz
|
||||
else
|
||||
set vt_wimkernel=wimboot.x86_64.xz
|
||||
fi
|
||||
|
||||
vt_set_wim_load_prompt 1 "Loading files......"
|
||||
vt_load_file_to_mem "nodecompress" $vtoy_wimboot_prefix/sources/boot.wim vtoy_wimfile_mem
|
||||
vt_set_wim_load_prompt 0
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
set vtoy_wimfile_path=mem:${vtoy_wimfile_mem_addr}:size:${vtoy_wimfile_mem_size}
|
||||
else
|
||||
set vtoy_wimfile_path=$vtoy_wimboot_prefix/sources/boot.wim
|
||||
fi
|
||||
|
||||
ventoy_cli_console
|
||||
chainloader "$vtoy_path/$vt_wimkernel" quiet \
|
||||
"vf=wimboot.data:mem:${vtoy_wimboot_mem_addr}:size:${vtoy_wimboot_mem_size}" \
|
||||
"vf=winpeshl.ini:mem:${vtoy_winpeshl_ini_addr}:size:${vtoy_winpeshl_ini_size}" \
|
||||
"vf=vtoyjump.exe:$vtoy_path/vtoyjump${vtoy_wimboot_bit}.exe" \
|
||||
"vf=bcd:$vtoy_wimboot_prefix/boot/bcd" \
|
||||
"vf=boot.sdi:$vtoy_wimboot_prefix/boot/boot.sdi" \
|
||||
"vf=boot.wim:$vtoy_wimfile_path" \
|
||||
pfsize=$vtoy_chain_file_size \
|
||||
pfread=$vtoy_chain_file_read
|
||||
boot
|
||||
ventoy_gui_console
|
||||
fi
|
||||
}
|
||||
|
||||
function legacy_windows_menu_func {
|
||||
vt_windows_reset
|
||||
|
||||
@@ -833,7 +917,11 @@ function legacy_windows_menu_func {
|
||||
|
||||
vt_windows_chain_data "${1}${chosen_path}"
|
||||
ventoy_debug_pause
|
||||
|
||||
|
||||
if vt_check_mode 4; then
|
||||
vtoy_windows_wimboot_func
|
||||
fi
|
||||
|
||||
if [ -n "$vtoy_chain_mem_addr" ]; then
|
||||
ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
|
||||
linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} ibft mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
|
||||
@@ -1311,7 +1399,7 @@ function vtoyboot_common_func {
|
||||
ventoy_pause
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
vt_img_sector "${1}"
|
||||
vt_raw_chain_data "${1}"
|
||||
|
||||
@@ -1538,14 +1626,25 @@ function ventoy_img_openwrt {
|
||||
set ventoy_busybox_ver=64
|
||||
fi
|
||||
|
||||
if [ ! -f ${vtoy_iso_part}/ventoy/ventoy_openwrt.xz ]; then
|
||||
ventoy_gui_console
|
||||
echo -e "\n ventoy_openwrt.xz not found. Please refer https://www.ventoy.net/en/doc_openwrt.html.\n"
|
||||
echo -e " 未找到 ventoy_openwrt.xz 文件。请参考 https://www.ventoy.net/cn/doc_openwrt.html\n"
|
||||
echo -e "\n press ENTER to exit (请按 回车 键返回) ..."
|
||||
read vtInputKey
|
||||
ventoy_cli_console
|
||||
return
|
||||
vt_fs_enum_1st_dir (vtimghd,2) /lib/modules/ vt_dir_name
|
||||
|
||||
if [ -f (vtimghd,2)/lib/modules/$vt_dir_name/dm-mod.ko ]; then
|
||||
set openwrt_plugin_need=0
|
||||
vt_img_extra_initrd_append (vtimghd,2)/lib/modules/$vt_dir_name/dm-mod.ko
|
||||
if [ -f (vtimghd,2)/lib/modules/$vt_dir_name/dax.ko ]; then
|
||||
vt_img_extra_initrd_append (vtimghd,2)/lib/modules/$vt_dir_name/dax.ko
|
||||
fi
|
||||
else
|
||||
set openwrt_plugin_need=1
|
||||
if [ ! -f ${vtoy_iso_part}/ventoy/ventoy_openwrt.xz ]; then
|
||||
ventoy_gui_console
|
||||
echo -e "\n ventoy_openwrt.xz not found. Please refer https://www.ventoy.net/en/doc_openwrt.html.\n"
|
||||
echo -e " 未找到 ventoy_openwrt.xz 文件。请参考 https://www.ventoy.net/cn/doc_openwrt.html\n"
|
||||
echo -e "\n press ENTER to exit (请按 回车 键返回) ..."
|
||||
read vtInputKey
|
||||
ventoy_cli_console
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
if vt_img_check_range "${vtoy_iso_part}${vt_chosen_path}"; then
|
||||
@@ -1560,12 +1659,14 @@ function ventoy_img_openwrt {
|
||||
return
|
||||
fi
|
||||
|
||||
|
||||
vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
|
||||
vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
|
||||
|
||||
vt_img_extra_initrd_append ${vtoy_iso_part}/ventoy/ventoy_openwrt.xz
|
||||
|
||||
if [ $openwrt_plugin_need -eq 1 ]; then
|
||||
if [ -f ${vtoy_iso_part}/ventoy/ventoy_openwrt.xz ]; then
|
||||
vt_img_extra_initrd_append ${vtoy_iso_part}/ventoy/ventoy_openwrt.xz
|
||||
fi
|
||||
fi
|
||||
|
||||
#boot image file
|
||||
vt_set_boot_opt rdinit=/vtoy/vtoy ventoyos=openwrt
|
||||
@@ -1607,6 +1708,15 @@ function img_unsupport_tip {
|
||||
read vtInputKey
|
||||
}
|
||||
|
||||
function legacy_img_memdisk {
|
||||
linux16 $vtoy_path/memdisk
|
||||
echo "Loading img file to memory ..."
|
||||
initrd16 "${1}${2}"
|
||||
|
||||
ventoy_cli_console
|
||||
boot
|
||||
}
|
||||
|
||||
function img_common_menuentry {
|
||||
set ventoy_compatible=YES
|
||||
set ventoy_busybox_ver=32
|
||||
@@ -1621,8 +1731,11 @@ function img_common_menuentry {
|
||||
return
|
||||
fi
|
||||
|
||||
if [ -d (vtimghd)/ ]; then
|
||||
loopback -d vtimghd
|
||||
if [ "$grub_platform" = "pc" ]; then
|
||||
if vt_check_mode 0; then
|
||||
legacy_img_memdisk $vtoy_iso_part "$vt_chosen_path"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
loopback vtimghd "${vtoy_iso_part}${vt_chosen_path}"
|
||||
@@ -1689,6 +1802,8 @@ function img_common_menuentry {
|
||||
fi
|
||||
fi
|
||||
|
||||
loopback -d vtimghd
|
||||
|
||||
set root=$vtback_root
|
||||
vt_pop_last_entry
|
||||
set theme=$vtback_theme
|
||||
@@ -1708,7 +1823,7 @@ function img_unsupport_menuentry {
|
||||
#############################################################
|
||||
#############################################################
|
||||
|
||||
set VENTOY_VERSION="1.0.43"
|
||||
set VENTOY_VERSION="1.0.47"
|
||||
|
||||
#ACPI not compatible with Window7/8, so disable by default
|
||||
set VTOY_PARAM_NO_ACPI=1
|
||||
@@ -1721,6 +1836,7 @@ set VTOY_DEFAULT_MENU_MODE=0
|
||||
set VTOY_MEM_DISK_STR="[Memdisk]"
|
||||
set VTOY_ISO_RAW_STR="Compatible Mode"
|
||||
set VTOY_GRUB2_MODE_STR="GRUB2 Mode"
|
||||
set VTOY_WIMBOOT_MODE_STR="WIMBOOT Mode"
|
||||
set VTOY_ISO_UEFI_DRV_STR="UEFI FS"
|
||||
|
||||
set VTOY_F2_CMD="ventoy_power"
|
||||
@@ -1843,7 +1959,7 @@ elif [ "$vtoy_display_mode" = "serial_console" ]; then
|
||||
terminal_output serial console
|
||||
else
|
||||
if [ -n "$vtoy_theme" ]; then
|
||||
set theme=$vtoy_theme
|
||||
vt_set_theme
|
||||
else
|
||||
set theme=$prefix/themes/ventoy/theme.txt
|
||||
fi
|
||||
@@ -1888,6 +2004,12 @@ export vtoy_efi_part
|
||||
export VENTOY_VERSION
|
||||
export VTOY_CUR_VIDEO_MODE
|
||||
export VTOY_EFI_ARCH
|
||||
export VTOY_MEM_DISK_STR
|
||||
export VTOY_ISO_RAW_STR
|
||||
export VTOY_GRUB2_MODE_STR
|
||||
export VTOY_WIMBOOT_MODE_STR
|
||||
export VTOY_ISO_UEFI_DRV_STR
|
||||
|
||||
|
||||
#special VTOY_DEFAULT_IMAGE process
|
||||
if [ -n "$VTOY_DEFAULT_IMAGE" ]; then
|
||||
|
@@ -26,7 +26,7 @@ sfs: fshelp
|
||||
reiserfs: fshelp
|
||||
part_sunpc:
|
||||
zstd:
|
||||
gfxmenu: video_colors trig bitmap_scale gfxterm font normal bitmap video
|
||||
gfxmenu: trig video_colors bitmap_scale gfxterm font normal bitmap video
|
||||
backtrace:
|
||||
jfs:
|
||||
help: extcmd normal
|
||||
@@ -82,7 +82,7 @@ gfxterm_background: video_colors bitmap_scale gfxterm extcmd video bitmap
|
||||
search_fs_uuid:
|
||||
gcry_dsa: pgp mpi
|
||||
keystatus: extcmd
|
||||
linux: verifiers video boot relocator mmap
|
||||
linux: ventoy verifiers video boot relocator mmap
|
||||
geli: cryptodisk crypto gcry_sha512 pbkdf2 gcry_sha256
|
||||
cmdline_cat_test: font functional_test normal procfs video_fb
|
||||
rdmsr: extcmd
|
||||
@@ -120,7 +120,7 @@ ehci: cs5536 usb boot
|
||||
crypto:
|
||||
part_bsd: part_msdos
|
||||
cs5536:
|
||||
ventoy: elf fshelp ext2 btrfs font crypto gcry_md5 exfat udf extcmd normal video gcry_sha1 iso9660
|
||||
ventoy: elf fshelp ext2 btrfs font crypto gcry_md5 exfat udf extcmd datetime div normal video gcry_sha1 iso9660
|
||||
gcry_sha512: crypto
|
||||
password: crypto normal
|
||||
fshelp:
|
||||
|
@@ -26,7 +26,7 @@ sfs: fshelp
|
||||
reiserfs: fshelp
|
||||
part_sunpc:
|
||||
zstd:
|
||||
gfxmenu: video_colors trig bitmap_scale gfxterm font normal bitmap video
|
||||
gfxmenu: trig video_colors bitmap_scale gfxterm font normal bitmap video
|
||||
backtrace:
|
||||
jfs:
|
||||
help: extcmd normal
|
||||
@@ -82,7 +82,7 @@ gfxterm_background: video_colors bitmap_scale gfxterm extcmd video bitmap
|
||||
search_fs_uuid:
|
||||
gcry_dsa: pgp mpi
|
||||
keystatus: extcmd
|
||||
linux: verifiers normal vbe video boot relocator mmap
|
||||
linux: ventoy verifiers normal vbe video boot relocator mmap
|
||||
geli: cryptodisk crypto gcry_sha512 pbkdf2 gcry_sha256
|
||||
cmdline_cat_test: font functional_test normal procfs video_fb
|
||||
rdmsr: extcmd
|
||||
@@ -123,7 +123,7 @@ crypto:
|
||||
part_bsd: part_msdos
|
||||
cs5536: pci
|
||||
biosdisk:
|
||||
ventoy: elf fshelp ext2 btrfs font crypto gcry_md5 exfat udf extcmd normal video gcry_sha1 iso9660 acpi
|
||||
ventoy: elf fshelp ext2 btrfs font crypto gcry_md5 exfat udf datetime div extcmd normal video gcry_sha1 iso9660 acpi
|
||||
lsapm:
|
||||
gcry_sha512: crypto
|
||||
password: crypto normal
|
||||
|
Binary file not shown.
@@ -78,6 +78,14 @@ terminal-box: "terminal_box_*.png"
|
||||
+ label {text = "@VTOY_GRUB2_MODE@" color = "red" align = "left"}
|
||||
}
|
||||
|
||||
+ hbox{
|
||||
left = 30%+200
|
||||
top = 95%-25
|
||||
width = 10%
|
||||
height = 25
|
||||
+ label {text = "@VTOY_WIMBOOT_MODE@" color = "red" align = "left"}
|
||||
}
|
||||
|
||||
+ hbox{
|
||||
left = 90%
|
||||
top = 55
|
||||
|
@@ -26,7 +26,7 @@ sfs: fshelp
|
||||
reiserfs: fshelp
|
||||
part_sunpc:
|
||||
zstd:
|
||||
gfxmenu: video_colors trig bitmap_scale gfxterm font normal bitmap video
|
||||
gfxmenu: trig video_colors bitmap_scale gfxterm font normal bitmap video
|
||||
backtrace:
|
||||
jfs:
|
||||
help: extcmd normal
|
||||
@@ -81,7 +81,7 @@ gfxterm_background: video_colors bitmap_scale gfxterm extcmd video bitmap
|
||||
search_fs_uuid:
|
||||
gcry_dsa: pgp mpi
|
||||
keystatus: extcmd
|
||||
linux: verifiers video boot relocator mmap
|
||||
linux: ventoy verifiers video boot relocator mmap
|
||||
geli: cryptodisk crypto gcry_sha512 pbkdf2 gcry_sha256
|
||||
cmdline_cat_test: font functional_test normal procfs video_fb
|
||||
rdmsr: extcmd
|
||||
@@ -120,7 +120,7 @@ ehci: cs5536 usb boot
|
||||
crypto:
|
||||
part_bsd: part_msdos
|
||||
cs5536:
|
||||
ventoy: elf fshelp ext2 btrfs font crypto gcry_md5 exfat udf extcmd normal video gcry_sha1 iso9660
|
||||
ventoy: elf fshelp ext2 btrfs font crypto gcry_md5 exfat udf extcmd datetime div normal video gcry_sha1 iso9660
|
||||
gcry_sha512: crypto
|
||||
password: crypto normal
|
||||
fshelp:
|
||||
|
@@ -70,6 +70,22 @@ terminal-box: "terminal_box_*.png"
|
||||
}
|
||||
|
||||
|
||||
+ hbox{
|
||||
left = 30%+200
|
||||
top = 95%-50
|
||||
width = 10%
|
||||
height = 25
|
||||
+ label {text = "@VTOY_GRUB2_MODE@" color = "red" align = "left"}
|
||||
}
|
||||
|
||||
+ hbox{
|
||||
left = 30%+200
|
||||
top = 95%-25
|
||||
width = 10%
|
||||
height = 25
|
||||
+ label {text = "@VTOY_WIMBOOT_MODE@" color = "red" align = "left"}
|
||||
}
|
||||
|
||||
+ hbox{
|
||||
left = 90%
|
||||
top = 55
|
||||
|
@@ -3,6 +3,18 @@
|
||||
LOGFILE=log.txt
|
||||
VUSER=$(get_user)
|
||||
|
||||
if which browser >/dev/null 2>&1; then
|
||||
:
|
||||
else
|
||||
if [ "$LANG" = "zh_CN.UTF-8" ]; then
|
||||
echo " Built-in browser not found in the system, please use VentoyWeb.sh ..."
|
||||
else
|
||||
echo " 未找到系统内置的 browser (卸载了?)请使用 VentoyWeb.sh ..."
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
if [ -e $LOGFILE ]; then
|
||||
chown $VUSER $LOGFILE
|
||||
else
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
INSTALL/ventoy/wimboot.i386.efi.xz
Normal file
BIN
INSTALL/ventoy/wimboot.i386.efi.xz
Normal file
Binary file not shown.
BIN
INSTALL/ventoy/wimboot.x86_64.xz
Normal file
BIN
INSTALL/ventoy/wimboot.x86_64.xz
Normal file
Binary file not shown.
@@ -106,11 +106,13 @@ cp $OPT VentoyWebDeepin.sh $tmpdir/
|
||||
cp $OPT README $tmpdir/
|
||||
cp $OPT plugin $tmpdir/
|
||||
cp $OPT CreatePersistentImg.sh $tmpdir/
|
||||
cp $OPT ExtendPersistentImg.sh $tmpdir/
|
||||
dos2unix -q $tmpdir/Ventoy2Disk.sh
|
||||
dos2unix -q $tmpdir/VentoyWeb.sh
|
||||
dos2unix -q $tmpdir/VentoyWebDeepin.sh
|
||||
#dos2unix -q $tmpdir/Ventoy.desktop
|
||||
dos2unix -q $tmpdir/CreatePersistentImg.sh
|
||||
dos2unix -q $tmpdir/ExtendPersistentImg.sh
|
||||
|
||||
cp $OPT ../LinuxGUI/WebUI $tmpdir/
|
||||
sed 's/.*SCRIPT_DEL_THIS \(.*\)/\1/g' -i $tmpdir/WebUI/index.html
|
||||
@@ -144,6 +146,7 @@ chmod +x $tmpdir/VentoyWeb.sh
|
||||
chmod +x $tmpdir/VentoyWebDeepin.sh
|
||||
#chmod +x $tmpdir/Ventoy.desktop
|
||||
chmod +x $tmpdir/CreatePersistentImg.sh
|
||||
chmod +x $tmpdir/ExtendPersistentImg.sh
|
||||
|
||||
tar -czvf ventoy-${curver}-linux.tar.gz $tmpdir
|
||||
|
||||
|
@@ -1354,6 +1354,15 @@ static int int13_load_eltorito ( unsigned int drive, struct segoff *address ) {
|
||||
DBG ( "INT13 drive %02x El Torito boot image loads at %04x:%04x\n",
|
||||
drive, address->segment, address->offset );
|
||||
|
||||
if (catalog.boot.length > 256)
|
||||
{
|
||||
if (g_debug)
|
||||
{
|
||||
printf("trim length from %d to 4\n", catalog.boot.length);
|
||||
}
|
||||
catalog.boot.length = 4;
|
||||
}
|
||||
|
||||
/* Use INT 13, 42 to read the boot image */
|
||||
eltorito_address.bufsize =
|
||||
offsetof ( typeof ( eltorito_address ), buffer_phys );
|
||||
|
@@ -44,6 +44,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"خطأ في الاتصال: الخدمة غير متوفرة",
|
||||
"STR_WEB_TOKEN_MISMATCH":"تم تحديث حالة البرنامج الخفي ، يرجى إعادة المحاولة لاحقًا.",
|
||||
"STR_WEB_SERVICE_BUSY":"الخدمة مشغولة ، يرجى إعادة المحاولة لاحقًا.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -91,6 +95,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"통신 오류: 서비스를 사용할 수 없음",
|
||||
"STR_WEB_TOKEN_MISMATCH":"데몬 상태가 업데이트되었습니다. 나중에 다시 시도하십시오.",
|
||||
"STR_WEB_SERVICE_BUSY":"서비스가 사용 중입니다. 나중에 다시 시도하십시오.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -138,6 +146,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"通信失败:服务不可用",
|
||||
"STR_WEB_TOKEN_MISMATCH":"后台服务状态更新,请稍后重试",
|
||||
"STR_WEB_SERVICE_BUSY":"后台服务正忙,请稍后重试",
|
||||
"STR_MENU_VTSI_CREATE":"创建 VTSI 文件",
|
||||
"STR_VTSI_CREATE_TIP":"本操作不会向设备中写入数据,而只会生成一个 VTSI 文件#@是否继续?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI 文件创建成功,你可以使用Rufus(3.15+)将其写入对应设备,从而完成Ventoy的安装",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI 文件创建失败",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -185,6 +197,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Communication error: Service Unavailable",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Daemon status updated, please retry later.",
|
||||
"STR_WEB_SERVICE_BUSY":"Service is busy, please retry later.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -232,6 +248,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"خطای ارتباطی: سرویس موجود نیست",
|
||||
"STR_WEB_TOKEN_MISMATCH":"وضعیت Daemon به روز شد ، لطفاً بعداً دوباره امتحان کنید.",
|
||||
"STR_WEB_SERVICE_BUSY":"سرویس شلوغ است ، لطفاً بعداً دوباره امتحان کنید.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -279,6 +299,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Błąd komunikacji: usługa niedostępna",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Stan daemona został zaktualizowany, spróbuj ponownie później.",
|
||||
"STR_WEB_SERVICE_BUSY":"Usługa jest zajęta, spróbuj ponownie później.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -326,6 +350,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Erro de comunicação: Serviço indisponível",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Status daemon atualizado, por favor, tente novamente mais tarde.",
|
||||
"STR_WEB_SERVICE_BUSY":"O serviço está ocupado, por favor, tente novamente mais tarde.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -373,6 +401,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Iletişim hatası: Uzaktan web erişim hizmeti erişilemez durumda",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Daemon durumu güncellendi,lütfen daha sonra tekrar deneyiniz.",
|
||||
"STR_WEB_SERVICE_BUSY":"Hizmet meşgul, lütfen daha sonra tekrar deneyin.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -420,6 +452,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Kommunikationsfehler: Dienst nicht verfügbar",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Daemon-Status aktualisiert, bitte später erneut versuchen.",
|
||||
"STR_WEB_SERVICE_BUSY":"Dienst ist ausgelastet, bitte später erneut versuchen.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -467,53 +503,61 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Error de comunicacion : servici pas disponible",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Estat del Daemon actualizat, tornatz ensajar mai tard.",
|
||||
"STR_WEB_SERVICE_BUSY":"Lo servici es ocupat, tornatz ensajar mai tard.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
"name":"French (Français)",
|
||||
"FontFamily":"Courier New",
|
||||
"FontSize":16,
|
||||
"Author":"vboucard",
|
||||
"Author":"vboucard, Silejonu",
|
||||
|
||||
"STR_ERROR":"Erreur",
|
||||
"STR_WARNING":"Avertissement",
|
||||
"STR_INFO":"Info",
|
||||
"STR_INCORRECT_DIR":"Ce programme doit s'exécuter dans le bon répertoire !",
|
||||
"STR_INCORRECT_DIR":"Ce programme doit s'exécuter dans le bon répertoire !",
|
||||
"STR_INCORRECT_TREE_DIR":"Ne me lancez pas d'ici, veuillez télécharger le programme d'installation et relancez-le.",
|
||||
"STR_DEVICE":"Périphérique",
|
||||
"STR_LOCAL_VER":"Ventoy en local",
|
||||
"STR_DISK_VER":"Ventoy sur le périphérique",
|
||||
"STR_STATUS":"Etat - prêt",
|
||||
"STR_STATUS":"État - prêt",
|
||||
"STR_INSTALL":"Installation",
|
||||
"STR_UPDATE":"Mise à jour",
|
||||
"STR_UPDATE_TIP":"La mise à jour est sûre, les fichiers ISO ne seront pas modifiés.#@Continuer?",
|
||||
"STR_INSTALL_TIP":"Le disque va être formaté et toutes ses données seront perdues.#@Continuer?",
|
||||
"STR_INSTALL_TIP2":"Le disque va être formaté et toutes ses données seront perdues.#@Continuer? (confirmation)",
|
||||
"STR_INSTALL_SUCCESS":"Félicitations !#@Ventoy a été correctement installé sur le périphérique.",
|
||||
"STR_INSTALL_FAILED":"Une erreur est survenue durant l'installation. Vous pouvez rebrancher le périphérique USB et réessayer. Vérifiez le fichier log.txt pour plus de détails.",
|
||||
"STR_UPDATE_SUCCESS":"Félicitations !#@Ventoy a été correctement mis à jour sur le périphérique.",
|
||||
"STR_UPDATE_FAILED":"Une erreur est survenue durant la mise à jour. Vous pouvez rebrancher le périphérique USB et réessayer. Vérifiez le fichier log.txt pour plus de détails.",
|
||||
"STR_UPDATE_TIP":"La mise à jour est sûre, les fichiers ISO ne seront pas modifiés.#@Continuer ?",
|
||||
"STR_INSTALL_TIP":"Le disque va être formaté et toutes ses données seront perdues.#@Continuer ?",
|
||||
"STR_INSTALL_TIP2":"Le disque va être formaté et toutes ses données seront perdues.#@Continuer ? (Confirmation)",
|
||||
"STR_INSTALL_SUCCESS":"Félicitations !#@Ventoy a été correctement installé sur le périphérique.",
|
||||
"STR_INSTALL_FAILED":"Une erreur est survenue durant l'installation. Vous pouvez rebrancher le périphérique et réessayer. Consultez le fichier log.txt pour plus de détails.",
|
||||
"STR_UPDATE_SUCCESS":"Félicitations !#@Ventoy a été correctement mis à jour sur le périphérique.",
|
||||
"STR_UPDATE_FAILED":"Une erreur est survenue durant la mise à jour. Vous pouvez rebrancher le périphérique et réessayer. Consultez le fichier log.txt pour plus de détails.",
|
||||
"STR_WAIT_PROCESS":"Une opération est en cours, veuillez patienter...",
|
||||
"STR_MENU_OPTION":"Option",
|
||||
"STR_MENU_SECURE_BOOT":"Secure Boot",
|
||||
"STR_MENU_PART_CFG":"Configuration de partition",
|
||||
"STR_BTN_OK":"D'accord",
|
||||
"STR_MENU_PART_CFG":"Configuration des partitions",
|
||||
"STR_BTN_OK":"Valider",
|
||||
"STR_BTN_CANCEL":"Annuler",
|
||||
"STR_PRESERVE_SPACE":"Préservez de l'espace au bas du disque",
|
||||
"STR_SPACE_VAL_INVALID":"Valeur non valide pour l'espace réservé",
|
||||
"STR_PRESERVE_SPACE":"Réservez de l'espace à la fin du disque",
|
||||
"STR_SPACE_VAL_INVALID":"Valeur de l'espace réservé invalide",
|
||||
"STR_MENU_CLEAR":"Effacer Ventoy",
|
||||
"STR_CLEAR_SUCCESS":"Ventoy a été enlevé du périphérique avec succès.",
|
||||
"STR_CLEAR_FAILED":"Une erreur est survenue pendant la suppression de Ventoy. Vous pouvez rebrancher le périphérique USB. Vérifiez le fichier log.txt pour plus de détails.",
|
||||
"STR_CLEAR_SUCCESS":"Ventoy a été retiré du périphérique avec succès.",
|
||||
"STR_CLEAR_FAILED":"Une erreur est survenue pendant la suppression de Ventoy. Vous pouvez rebrancher le périphérique et réessayer. Consultez le fichier log.txt pour plus de détails.",
|
||||
"STR_MENU_PART_STYLE":"Type de partition",
|
||||
"STR_DISK_2TB_MBR_ERROR":"Sélectionnez le type GPT pour les disques de plus de 2TO",
|
||||
"STR_SHOW_ALL_DEV":"Afficher tous les appareils",
|
||||
"STR_PART_ALIGN_4KB":"Alignez les partitions avec 4 KO",
|
||||
"STR_WEB_COMMUNICATION_ERR":"Communication error:",
|
||||
"STR_WEB_REMOTE_ABNORMAL":"Communication error: remote abnormal",
|
||||
"STR_WEB_REQUEST_TIMEOUT":"Communication error: Request timed out",
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Communication error: Service Unavailable",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Daemon status updated, please retry later.",
|
||||
"STR_WEB_SERVICE_BUSY":"Service is busy, please retry later.",
|
||||
"STR_DISK_2TB_MBR_ERROR":"Sélectionnez le type GPT pour les disques de plus de 2 To",
|
||||
"STR_SHOW_ALL_DEV":"Afficher tous les périphériques",
|
||||
"STR_PART_ALIGN_4KB":"Alignez les partitions sur 4 ko",
|
||||
"STR_WEB_COMMUNICATION_ERR":"Erreur de communication :",
|
||||
"STR_WEB_REMOTE_ABNORMAL":"Erreur de communication : anomalie sur le serveur",
|
||||
"STR_WEB_REQUEST_TIMEOUT":"Erreur de communication : délai d'attente dépassé",
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Erreur de communication : service inaccessible",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Statut du démon mis à jour, veuillez réessayer plus tard.",
|
||||
"STR_WEB_SERVICE_BUSY":"Service surchargé, veuillez réessayer plus tard.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -561,6 +605,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Communication error: Service Unavailable",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Daemon status updated, please retry later.",
|
||||
"STR_WEB_SERVICE_BUSY":"Service is busy, please retry later.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -573,7 +621,7 @@
|
||||
"STR_WARNING":"Advertencia",
|
||||
"STR_INFO":"Información",
|
||||
"STR_INCORRECT_DIR":"¡Por favor, ejecuta bajo el directorio correcto!",
|
||||
"STR_INCORRECT_TREE_DIR":"No me ejecute aquí, por favor descarga el paquete de instalacion lanzado, y ejecutalo allí.",
|
||||
"STR_INCORRECT_TREE_DIR":"No me ejecute aquí, por favor descarga el paquete de instalación lanzado, y ejecútalo allí.",
|
||||
"STR_DEVICE":"Dispositivo",
|
||||
"STR_LOCAL_VER":"Ventoy En Paquete",
|
||||
"STR_DISK_VER":"Ventoy En Dispositivo",
|
||||
@@ -584,30 +632,34 @@
|
||||
"STR_INSTALL_TIP":"El dispositivo será formateado y todos los datos se perderán.#@¿Continuar?",
|
||||
"STR_INSTALL_TIP2":"El dispositivo será formateado y todos los datos se perderán.#@¿Continuar? (Doble Comprobación)",
|
||||
"STR_INSTALL_SUCCESS":"¡Felicitaciones!#@Ventoy ha sido instalado exitosamente en el dispositivo.",
|
||||
"STR_INSTALL_FAILED":"Ocurrío un error durante la instalación. Puedes reconectar el USB e intentar de nuevo. Comprueba log.txt para detalles.",
|
||||
"STR_INSTALL_FAILED":"Ocurrió un error durante la instalación. Puedes reconectar el USB e intentar de nuevo. Comprueba log.txt para detalle.",
|
||||
"STR_UPDATE_SUCCESS":"¡Felicitaciones!#@Ventoy ha sido actualizado exitosamente en el dispositivo.",
|
||||
"STR_UPDATE_FAILED":"Ocurrío un error durante la actualización. Puedes reconectar el USB e intentar de nuevo. Comprueba log.txt para detalles.",
|
||||
"STR_WAIT_PROCESS":"Un hilo está ejecutandose, por favor espera...",
|
||||
"STR_UPDATE_FAILED":"Ocurrió un error durante la actualización. Puedes reconectar el USB e intentar de nuevo. Comprueba log.txt para detalle.",
|
||||
"STR_WAIT_PROCESS":"Un hilo está ejecutándose, por favor espera...",
|
||||
"STR_MENU_OPTION":"Opción",
|
||||
"STR_MENU_SECURE_BOOT":"Soporte de Arranque Seguro",
|
||||
"STR_MENU_PART_CFG":"Confirguración de Partición",
|
||||
"STR_MENU_SECURE_BOOT":"Soporte De Arranque Seguro",
|
||||
"STR_MENU_PART_CFG":"Configuración De Partición",
|
||||
"STR_BTN_OK":"ACEPTAR",
|
||||
"STR_BTN_CANCEL":"Cancelar",
|
||||
"STR_PRESERVE_SPACE":"Preservar algo de espacio en la parte inferior del dispositivo",
|
||||
"STR_SPACE_VAL_INVALID":"Valor inválido para espacio preservado",
|
||||
"STR_PRESERVE_SPACE":"Preservar algo de espacio al final del dispositivo",
|
||||
"STR_SPACE_VAL_INVALID":"Valor inválido para espacio reservado",
|
||||
"STR_MENU_CLEAR":"Limpiar Ventoy",
|
||||
"STR_CLEAR_SUCCESS":"Ventoy ha sido removido exotosamente desde el dispositivo.",
|
||||
"STR_CLEAR_FAILED":"Ocurrío un error al limpiar Ventoy desde el dispositivo. Puedes reconectar el USB e intentar de nuevo. Comprueba log.txt para detalle.",
|
||||
"STR_MENU_PART_STYLE":"Estilo de Partición",
|
||||
"STR_CLEAR_SUCCESS":"Ventoy ha sido removido exitosamente desde el dispositivo.",
|
||||
"STR_CLEAR_FAILED":"Ocurrió un error al limpiar Ventoy desde el dispositivo. Puedes reconectar el USB e intentar de nuevo. Comprueba log.txt para detalle.",
|
||||
"STR_MENU_PART_STYLE":"Estilo De Partición",
|
||||
"STR_DISK_2TB_MBR_ERROR":"Por favor selecciona GPT para dispositivos sobre 2TB",
|
||||
"STR_SHOW_ALL_DEV":"Mostrar todos los dispositivos",
|
||||
"STR_SHOW_ALL_DEV":"Mostrar Todos Los Dispositivos",
|
||||
"STR_PART_ALIGN_4KB":"Alinear particiones con 4KB",
|
||||
"STR_WEB_COMMUNICATION_ERR":"Communication error:",
|
||||
"STR_WEB_REMOTE_ABNORMAL":"Communication error: remote abnormal",
|
||||
"STR_WEB_REQUEST_TIMEOUT":"Communication error: Request timed out",
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Communication error: Service Unavailable",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Daemon status updated, please retry later.",
|
||||
"STR_WEB_SERVICE_BUSY":"Service is busy, please retry later.",
|
||||
"STR_WEB_COMMUNICATION_ERR":"Error de comunicación:",
|
||||
"STR_WEB_REMOTE_ABNORMAL":"Error de comunicación: anormal remoto",
|
||||
"STR_WEB_REQUEST_TIMEOUT":"Error de comunicación: Tiempo de espera agotado",
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Error de comunicación: Servicio No Disponible",
|
||||
"STR_WEB_TOKEN_MISMATCH":" Estado del daemon actualizado, por favor reintenta más tarde.",
|
||||
"STR_WEB_SERVICE_BUSY":" El servicio está ocupado, por favor reintenta más tarde.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -655,6 +707,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Ошибка связи: Служба недоступна",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Статус демона обновлен. Повторите попытку позже.",
|
||||
"STR_WEB_SERVICE_BUSY":"Служба занята, повторите попытку позже.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -702,6 +758,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Communication error: Service Unavailable",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Daemon status updated, please retry later.",
|
||||
"STR_WEB_SERVICE_BUSY":"Service is busy, please retry later.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -749,6 +809,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Communication error: Service Unavailable",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Daemon status updated, please retry later.",
|
||||
"STR_WEB_SERVICE_BUSY":"Service is busy, please retry later.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -796,6 +860,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Communicatiefout: service niet beschikbaar",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Daemon-status bijgewerkt, probeer het later opnieuw.",
|
||||
"STR_WEB_SERVICE_BUSY":"Service is bezet, probeer het later opnieuw.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -843,6 +911,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Communication error: Service Unavailable",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Daemon status updated, please retry later.",
|
||||
"STR_WEB_SERVICE_BUSY":"Service is busy, please retry later.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -890,6 +962,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Communication error: Service Unavailable",
|
||||
"STR_WEB_TOKEN_MISMATCH":"デーモンのステータスが更新されました。しばらくしてから再試行してください。",
|
||||
"STR_WEB_SERVICE_BUSY":"サービスがビジーです。後で再試行してください。",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -937,6 +1013,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Communication error: Service Unavailable",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Daemon status updated, please retry later.",
|
||||
"STR_WEB_SERVICE_BUSY":"Service is busy, please retry later.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -984,6 +1064,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Communication error: Service Unavailable",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Daemon status updated, please retry later.",
|
||||
"STR_WEB_SERVICE_BUSY":"Service is busy, please retry later.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -1031,6 +1115,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Communication error: Service Unavailable",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Daemon status updated, please retry later.",
|
||||
"STR_WEB_SERVICE_BUSY":"Service is busy, please retry later.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -1078,6 +1166,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"通信錯誤: 服務不可用",
|
||||
"STR_WEB_TOKEN_MISMATCH":"服務狀態已更新",
|
||||
"STR_WEB_SERVICE_BUSY":"服務正忙,請稍後重試",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -1125,6 +1217,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Greška u komunikaciji: Servis nije dostupan",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Status demona ažuriran, pokušajte ponovo kasnije.",
|
||||
"STR_WEB_SERVICE_BUSY":"Servis je zauzet, pokušajte ponovo kasnije.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -1172,6 +1268,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Комуникациона грешка: Сервис је недоступан",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Статус демона ажуриран, покушајте поново касније.",
|
||||
"STR_WEB_SERVICE_BUSY":"Севис је заузет, покушајте поново касније.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -1219,6 +1319,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Communication error: Service Unavailable",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Daemon status updated, please retry later.",
|
||||
"STR_WEB_SERVICE_BUSY":"Service is busy, please retry later.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -1266,6 +1370,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Kommunikasjonsfeil: Tjeneste utilgjengelig",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Daemon status er oppdatert, vennligst prøv igjen senere.",
|
||||
"STR_WEB_SERVICE_BUSY":"Tjenesten er opptatt, vennligst prøv igjen senere.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -1313,6 +1421,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Lỗi giao tiếp: Dịch vụ không sẵn có",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Đã cập nhật trạng thái Daemon, vui lòng thử lại sau.",
|
||||
"STR_WEB_SERVICE_BUSY":"Dịch vụ bận, vui lòng thử lại sau.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -1360,6 +1472,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Communication error: Service Unavailable",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Daemon status updated, please retry later.",
|
||||
"STR_WEB_SERVICE_BUSY":"Service is busy, please retry later.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -1371,21 +1487,21 @@
|
||||
"STR_ERROR":"Грешка",
|
||||
"STR_WARNING":"Предупредување",
|
||||
"STR_INFO":"Инфо",
|
||||
"STR_INCORRECT_DIR":"Ве молам покренете ме коректниот фолдер!",
|
||||
"STR_INCORRECT_DIR":"Ве молам покренете ме коректната папка!",
|
||||
"STR_INCORRECT_TREE_DIR":"Не покренувајте ме овде, ве молам превземете ја последната верзија и покренете ме таму.",
|
||||
"STR_DEVICE":"Уред",
|
||||
"STR_LOCAL_VER":"Ventoy Во Пакетот",
|
||||
"STR_DISK_VER":"Ventoy Во Уредот",
|
||||
"STR_LOCAL_VER":"Ventoy во пакетот",
|
||||
"STR_DISK_VER":"Ventoy на уредот",
|
||||
"STR_STATUS":"Статус - Спремен",
|
||||
"STR_INSTALL":"Инсталирај",
|
||||
"STR_UPDATE":"Ажурирај",
|
||||
"STR_UPDATE_TIP":"Операцијата ажурирање е безбедна, ISO датотеките нема да бидат променети.#@Продолжи?",
|
||||
"STR_INSTALL_TIP":"УСБ дискот ќе биде форматиран и сите податоци ќе бидат уништени.#@Продолжи?",
|
||||
"STR_INSTALL_TIP2":"УСБ дискот ќе биде форматиран и сите податоци ќе бидат уништени.#@Продолжи? (Двојна проверка)",
|
||||
"STR_INSTALL_TIP":"УСБ уредот ќе биде форматиран и сите податоци ќе бидат уништени.#@Продолжи?",
|
||||
"STR_INSTALL_TIP2":"УСБ уредот ќе биде форматиран и сите податоци ќе бидат уништени.#@Продолжи? (Двојна проверка)",
|
||||
"STR_INSTALL_SUCCESS":"Честитки!#@Ventoy е успешно инсталиран на уредот.",
|
||||
"STR_INSTALL_FAILED":"Се појави грешка при инсталацијата. Отстранете го УСБ драјвот и пробајте повторно. Проверете го log.txt за детали.",
|
||||
"STR_INSTALL_FAILED":"Се појави грешка при инсталацијата. Отстранете го УСБ уредот и пробајте повторно. Проверете го log.txt за детали.",
|
||||
"STR_UPDATE_SUCCESS":"Честитки!#@Ventoy е успешно ажуриран на уредот.",
|
||||
"STR_UPDATE_FAILED":"Се појави грешка при ажурирањето. Отстранете го УСБ драјвот и пробајте повторно. Проверете го log.txt за детали.",
|
||||
"STR_UPDATE_FAILED":"Се појави грешка при ажурирањето. Отстранете го УСБ уредот и пробајте повторно. Проверете го log.txt за детали.",
|
||||
"STR_WAIT_PROCESS":"Процесот е вклучен, ве молиме почекајте...",
|
||||
"STR_MENU_OPTION":"Опции",
|
||||
"STR_MENU_SECURE_BOOT":"Secure Boot Поддршка",
|
||||
@@ -1396,17 +1512,21 @@
|
||||
"STR_SPACE_VAL_INVALID":"Невалидна вредност за резервираното место",
|
||||
"STR_MENU_CLEAR":"Отстрани го Ventoy",
|
||||
"STR_CLEAR_SUCCESS":"Ventoy е успешно отстранет од уредот.",
|
||||
"STR_CLEAR_FAILED":"Се појави грешка при отстранувањето на Ventoy од уредот. Отстранете го УСБ драјвот и пробајте повторно. Проверете го log.txt за детали.",
|
||||
"STR_CLEAR_FAILED":"Се појави грешка при отстранувањето на Ventoy од уредот. Отстранете го УСБ уредот и пробајте повторно. Проверете го log.txt за детали.",
|
||||
"STR_MENU_PART_STYLE":"Тип на партиција",
|
||||
"STR_DISK_2TB_MBR_ERROR":"Ве молиме изберете GPT за дискови поголеми од 2TB",
|
||||
"STR_SHOW_ALL_DEV":"Show All Devices",
|
||||
"STR_PART_ALIGN_4KB":"Align partitions with 4KB",
|
||||
"STR_WEB_COMMUNICATION_ERR":"Communication error:",
|
||||
"STR_WEB_REMOTE_ABNORMAL":"Communication error: remote abnormal",
|
||||
"STR_WEB_REQUEST_TIMEOUT":"Communication error: Request timed out",
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Communication error: Service Unavailable",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Daemon status updated, please retry later.",
|
||||
"STR_WEB_SERVICE_BUSY":"Service is busy, please retry later.",
|
||||
"STR_DISK_2TB_MBR_ERROR":"Ве молиме изберете GPT за уредот поголеми од 2TB",
|
||||
"STR_SHOW_ALL_DEV":"Прикажи ги сите уреди",
|
||||
"STR_PART_ALIGN_4KB":"Порамнете ги партициите со 4KB",
|
||||
"STR_WEB_COMMUNICATION_ERR":"Комуникациска грешка:",
|
||||
"STR_WEB_REMOTE_ABNORMAL":"Комуникациска грешка: Абнормално далечинско управување",
|
||||
"STR_WEB_REQUEST_TIMEOUT":"Комуникациска грешка: Барањето е истечено",
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Комуникациска грешка: Недостапен сервис",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Ажуриран статус на даемонот, молиме обидете се подоцна.",
|
||||
"STR_WEB_SERVICE_BUSY":"Сервисот е зафатен, молиме обидете се подоцна.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -1454,6 +1574,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Communication error: Service Unavailable",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Daemon status updated, please retry later.",
|
||||
"STR_WEB_SERVICE_BUSY":"Service is busy, please retry later.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -1501,6 +1625,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Communication error: Service Unavailable",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Daemon status updated, please retry later.",
|
||||
"STR_WEB_SERVICE_BUSY":"Service is busy, please retry later.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -1548,6 +1676,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Communication error: Service Unavailable",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Daemon status updated, please retry later.",
|
||||
"STR_WEB_SERVICE_BUSY":"Service is busy, please retry later.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -1595,6 +1727,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Помилка зв'язку: Служба недоступна",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Статус демона оновлено. Повторіть спробу пізніше.",
|
||||
"STR_WEB_SERVICE_BUSY":"Служба зайнята, повторіть спробу пізніше.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -1642,6 +1778,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Σφάλμα επικοινωνίας: υπηρεσία μη διαθέσιμη",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Η κατάσταση του δαίμονα επικαιροποιήθηκε. Παρακαλώ δοκιμάστε αργότερα.",
|
||||
"STR_WEB_SERVICE_BUSY":"Η υπηρεσία είναι απασχολημένη. Παρακαλώ δοκιμάστε αργότερα.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -1689,6 +1829,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Kommunikationsfel: Tjänsten är inte tillgänglig",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Daemon-status uppdaterad. Försök igen senare.",
|
||||
"STR_WEB_SERVICE_BUSY":"Tjänster är upptagen. Försök igen senare.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
},
|
||||
{
|
||||
@@ -1736,6 +1880,10 @@
|
||||
"STR_WEB_SERVICE_UNAVAILABLE":"Napaka v komunikaciji: storitev ni na voljo",
|
||||
"STR_WEB_TOKEN_MISMATCH":"Zahteva storitve je potekla, prosim poskusite kasneje.",
|
||||
"STR_WEB_SERVICE_BUSY":"Storitev je zasedena, prosim poskusite kasneje.",
|
||||
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
|
||||
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?",
|
||||
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15+) to write it to the device so as to complete the installation of Ventoy.",
|
||||
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
|
||||
"STRXXX":""
|
||||
}
|
||||
]
|
@@ -1,5 +1,4 @@
|
||||
wimboot follows GPLv2+ license (see gpl-2.0.txt)
|
||||
|
||||
Ventoy use the lzx decompress file from wimboot. These code follow the same license as wimboot.
|
||||
|
||||
Ventoy modified the code and follow the same license as wimboot.
|
||||
|
||||
|
@@ -412,7 +412,7 @@ int ventoy_fill_gpt(uint64_t size, uint64_t reserve, int align4k, VTOY_GPT_INFO
|
||||
ventoy_gen_preudo_uuid(&(Table[1].PartGuid));
|
||||
Table[1].StartLBA = Table[0].LastLBA + 1;
|
||||
Table[1].LastLBA = Table[1].StartLBA + VTOYEFI_PART_BYTES / 512 - 1;
|
||||
Table[1].Attr = 0x8000000000000001ULL;
|
||||
Table[1].Attr = 0xC000000000000001ULL;
|
||||
ventoy_fill_gpt_partname(Table[1].Name, "VTOYEFI");
|
||||
|
||||
#if 0
|
||||
|
@@ -16,7 +16,8 @@ You can copy many image files at a time and ventoy will give you a boot menu to
|
||||
x86 Legacy BIOS, IA32 UEFI, x86_64 UEFI, ARM64 UEFI and MIPS64EL UEFI are supported in the same way.<br/>
|
||||
Both MBR and GPT partition style are supported in the same way.<br/>
|
||||
Most type of OS supported(Windows/WinPE/Linux/Unix/Vmware/Xen...) <br/>
|
||||
700+ ISO files are tested. 90%+ distros in distrowatch.com supported. <br/>
|
||||
700+ ISO files are tested (<a href="https://www.ventoy.net/en/isolist.html">List</a>). 90%+ distros in <a href="https://distrowatch.com/">distrowatch.com</a> supported. <br/>
|
||||
<br/>Official Website: <a href=https://www.ventoy.net>https://www.ventoy.net</a>
|
||||
</h4>
|
||||
|
||||
# Features
|
||||
|
@@ -72,6 +72,11 @@ typedef enum STR_ID
|
||||
STR_WEB_TOKEN_MISMATCH, //37
|
||||
STR_WEB_SERVICE_BUSY, //38
|
||||
|
||||
STR_MENU_VTSI_CREATE, //39
|
||||
STR_VTSI_CREATE_TIP, //40
|
||||
STR_VTSI_CREATE_SUCCESS, //41
|
||||
STR_VTSI_CREATE_FAILED, //42
|
||||
|
||||
STR_ID_MAX
|
||||
}STR_ID;
|
||||
|
||||
@@ -83,7 +88,8 @@ extern BOOL g_SecureBoot;
|
||||
#define VTOY_MENU_PART_STYLE 0xA003
|
||||
#define VTOY_MENU_PART_MBR 0xA004
|
||||
#define VTOY_MENU_PART_GPT 0xA005
|
||||
#define VTOY_MENU_ALL_DEV 0xA006
|
||||
#define VTOY_MENU_ALL_DEV 0xA006
|
||||
#define VTOY_MENU_VTSI 0xA007
|
||||
|
||||
|
||||
typedef enum OPT_SUBMENU
|
||||
@@ -93,6 +99,7 @@ typedef enum OPT_SUBMENU
|
||||
OPT_SUBMENU_PART_CFG,
|
||||
OPT_SUBMENU_CLEAR,
|
||||
OPT_SUBMENU_ALL_DEV,
|
||||
OPT_SUBMENU_VTSI,
|
||||
|
||||
OPT_SUBMENU_MAX
|
||||
}OPT_SUBMENU;
|
||||
|
Binary file not shown.
@@ -1268,7 +1268,6 @@ static int FormatPart1exFAT(UINT64 DiskSizeBytes)
|
||||
{
|
||||
MKFS_PARM Option;
|
||||
FRESULT Ret;
|
||||
FATFS fs;
|
||||
|
||||
Option.fmt = FM_EXFAT;
|
||||
Option.n_fat = 1;
|
||||
@@ -1289,28 +1288,10 @@ static int FormatPart1exFAT(UINT64 DiskSizeBytes)
|
||||
Log("Formatting Part1 exFAT ...");
|
||||
|
||||
Ret = f_mkfs(TEXT("0:"), &Option, 0, 8 * 1024 * 1024);
|
||||
|
||||
if (FR_OK == Ret)
|
||||
{
|
||||
Log("Formatting Part1 exFAT success");
|
||||
|
||||
Ret = f_mount(&fs, TEXT("0:"), 1);
|
||||
Log("mount part %d", Ret);
|
||||
|
||||
if (FR_OK == Ret)
|
||||
{
|
||||
Ret = f_setlabel(TEXT("Ventoy"));
|
||||
Log("f_setlabel %d", Ret);
|
||||
|
||||
Ret = f_mount(0, TEXT("0:"), 1);
|
||||
Log("umount part %d", Ret);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("mount exfat failed %d", Ret);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1556,6 +1537,225 @@ End:
|
||||
return rc;
|
||||
}
|
||||
|
||||
int InstallVentoy2FileImage(PHY_DRIVE_INFO *pPhyDrive, int PartStyle)
|
||||
{
|
||||
int i;
|
||||
int rc = 1;
|
||||
int Len = 0;
|
||||
int dataLen = 0;
|
||||
UINT size = 0;
|
||||
UINT segnum = 0;
|
||||
UINT32 chksum = 0;
|
||||
UINT64 data_offset = 0;
|
||||
UINT64 Part2StartSector = 0;
|
||||
UINT64 Part1StartSector = 0;
|
||||
UINT64 Part1SectorCount = 0;
|
||||
UINT8 *pData = NULL;
|
||||
UINT8 *pBkGptPartTbl = NULL;
|
||||
BYTE *ImgBuf = NULL;
|
||||
MBR_HEAD *pMBR = NULL;
|
||||
VTSI_FOOTER *pImgFooter = NULL;
|
||||
VTSI_SEGMENT *pSegment = NULL;
|
||||
VTOY_GPT_INFO *pGptInfo = NULL;
|
||||
VTOY_GPT_HDR *pBkGptHdr = NULL;
|
||||
FILE *fp = NULL;
|
||||
|
||||
Log("InstallVentoy2FileImage %s PhyDrive%d <<%s %s %dGB>>",
|
||||
PartStyle ? "GPT" : "MBR", pPhyDrive->PhyDrive, pPhyDrive->VendorId, pPhyDrive->ProductId,
|
||||
GetHumanReadableGBSize(pPhyDrive->SizeInBytes));
|
||||
|
||||
PROGRESS_BAR_SET_POS(PT_LOCK_FOR_CLEAN);
|
||||
|
||||
size = SIZE_1MB + VENTOY_EFI_PART_SIZE + 33 * 512 + VTSI_IMG_MAX_SEG * sizeof(VTSI_SEGMENT) + sizeof(VTSI_FOOTER);
|
||||
|
||||
pData = (UINT8 *)malloc(size);
|
||||
if (!pData)
|
||||
{
|
||||
Log("malloc image buffer failed %d.", size);
|
||||
goto End;
|
||||
}
|
||||
|
||||
pImgFooter = (VTSI_FOOTER *)(pData + size - sizeof(VTSI_FOOTER));
|
||||
pSegment = (VTSI_SEGMENT *)((UINT8 *)pImgFooter - VTSI_IMG_MAX_SEG * sizeof(VTSI_SEGMENT));
|
||||
memset(pImgFooter, 0, sizeof(VTSI_FOOTER));
|
||||
memset(pSegment, 0, VTSI_IMG_MAX_SEG * sizeof(VTSI_SEGMENT));
|
||||
|
||||
PROGRESS_BAR_SET_POS(PT_WRITE_VENTOY_START);
|
||||
|
||||
Log("Writing Boot Image ............................. ");
|
||||
if (ReadWholeFileToBuf(VENTOY_FILE_STG1_IMG, 0, (void **)&ImgBuf, &Len))
|
||||
{
|
||||
Log("Failed to read stage1 img");
|
||||
goto End;
|
||||
}
|
||||
|
||||
unxz(ImgBuf, Len, NULL, NULL, pData, &dataLen, unxz_error);
|
||||
SAFE_FREE(ImgBuf);
|
||||
|
||||
if (PartStyle)
|
||||
{
|
||||
pGptInfo = (VTOY_GPT_INFO *)pData;
|
||||
memset(pGptInfo, 0, sizeof(VTOY_GPT_INFO));
|
||||
VentoyFillGpt(pPhyDrive->SizeInBytes, pGptInfo);
|
||||
|
||||
pBkGptPartTbl = pData + SIZE_1MB + VENTOY_EFI_PART_SIZE;
|
||||
memset(pBkGptPartTbl, 0, 33 * 512);
|
||||
|
||||
memcpy(pBkGptPartTbl, pGptInfo->PartTbl, 32 * 512);
|
||||
pBkGptHdr = (VTOY_GPT_HDR *)(pBkGptPartTbl + 32 * 512);
|
||||
VentoyFillBackupGptHead(pGptInfo, pBkGptHdr);
|
||||
|
||||
Part1StartSector = pGptInfo->PartTbl[0].StartLBA;
|
||||
Part1SectorCount = pGptInfo->PartTbl[0].LastLBA - Part1StartSector + 1;
|
||||
Part2StartSector = pGptInfo->PartTbl[1].StartLBA;
|
||||
|
||||
Log("Write GPT Info OK ...");
|
||||
}
|
||||
else
|
||||
{
|
||||
pMBR = (MBR_HEAD *)pData;
|
||||
VentoyFillMBR(pPhyDrive->SizeInBytes, pMBR, PartStyle);
|
||||
Part1StartSector = pMBR->PartTbl[0].StartSectorId;
|
||||
Part1SectorCount = pMBR->PartTbl[0].SectorCount;
|
||||
Part2StartSector = pMBR->PartTbl[1].StartSectorId;
|
||||
|
||||
Log("Write MBR OK ...");
|
||||
}
|
||||
|
||||
Log("Writing EFI part Image ............................. ");
|
||||
rc = ReadWholeFileToBuf(VENTOY_FILE_DISK_IMG, 0, (void **)&ImgBuf, &Len);
|
||||
if (rc)
|
||||
{
|
||||
Log("Failed to read img file %p %u", ImgBuf, Len);
|
||||
goto End;
|
||||
}
|
||||
|
||||
PROGRESS_BAR_SET_POS(PT_WRITE_VENTOY_START + 28);
|
||||
memset(g_part_img_buf, 0, sizeof(g_part_img_buf));
|
||||
unxz(ImgBuf, Len, NULL, NULL, pData + SIZE_1MB, &dataLen, unxz_error);
|
||||
if (dataLen == Len)
|
||||
{
|
||||
Log("decompress finished success");
|
||||
g_part_img_buf[0] = pData + SIZE_1MB;
|
||||
|
||||
VentoyProcSecureBoot(g_SecureBoot);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("decompress finished failed");
|
||||
goto End;
|
||||
}
|
||||
|
||||
fopen_s(&fp, "VentoySparseImg.vtsi", "wb+");
|
||||
if (!fp)
|
||||
{
|
||||
Log("Failed to create Ventoy img file");
|
||||
goto End;
|
||||
}
|
||||
|
||||
Log("Writing stage1 data ............................. ");
|
||||
fwrite(pData, 1, SIZE_1MB, fp);
|
||||
pSegment[0].disk_start_sector = 0;
|
||||
pSegment[0].sector_num = SIZE_1MB / 512;
|
||||
pSegment[0].data_offset = data_offset;
|
||||
data_offset += pSegment[0].sector_num * 512;
|
||||
|
||||
disk_io_set_param(INVALID_HANDLE_VALUE, Part1StartSector + Part1SectorCount);// include the 2048 sector gap
|
||||
disk_io_set_imghook(fp, pSegment + 1, VTSI_IMG_MAX_SEG - 1, data_offset);
|
||||
|
||||
Log("Formatting part1 exFAT ...");
|
||||
if (0 != FormatPart1exFAT(pPhyDrive->SizeInBytes))
|
||||
{
|
||||
Log("FormatPart1exFAT failed.");
|
||||
disk_io_reset_imghook(&segnum, &data_offset);
|
||||
goto End;
|
||||
}
|
||||
|
||||
disk_io_reset_imghook(&segnum, &data_offset);
|
||||
segnum++;
|
||||
|
||||
Log("current segment number:%d dataoff:%ld", segnum, (long)data_offset);
|
||||
|
||||
//write data
|
||||
Log("Writing part2 data ............................. ");
|
||||
fwrite(pData + SIZE_1MB, 1, VENTOY_EFI_PART_SIZE, fp);
|
||||
pSegment[segnum].disk_start_sector = Part2StartSector;
|
||||
pSegment[segnum].sector_num = VENTOY_EFI_PART_SIZE / 512;
|
||||
pSegment[segnum].data_offset = data_offset;
|
||||
data_offset += pSegment[segnum].sector_num * 512;
|
||||
segnum++;
|
||||
|
||||
if (PartStyle)
|
||||
{
|
||||
Log("Writing backup gpt table ............................. ");
|
||||
fwrite(pBkGptPartTbl, 1, 33 * 512, fp);
|
||||
pSegment[segnum].disk_start_sector = pPhyDrive->SizeInBytes / 512 - 33;
|
||||
pSegment[segnum].sector_num = 33;
|
||||
pSegment[segnum].data_offset = data_offset;
|
||||
data_offset += pSegment[segnum].sector_num * 512;
|
||||
segnum++;
|
||||
}
|
||||
|
||||
Log("Writing segment metadata ............................. ");
|
||||
|
||||
for (i = 0; i < (int)segnum; i++)
|
||||
{
|
||||
Log("SEG[%d]: PhySector:%llu SectorNum:%llu DataOffset:%llu(sector:%llu)", i, pSegment[i].disk_start_sector, pSegment[i].sector_num,
|
||||
pSegment[i].data_offset, pSegment[i].data_offset / 512);
|
||||
}
|
||||
|
||||
dataLen = segnum * sizeof(VTSI_SEGMENT);
|
||||
fwrite(pSegment, 1, dataLen, fp);
|
||||
|
||||
if (dataLen % 512)
|
||||
{
|
||||
//pData + SIZE_1MB - 8192 is a temp data buffer with zero
|
||||
fwrite(pData + SIZE_1MB - 8192, 1, 512 - (dataLen % 512), fp);
|
||||
}
|
||||
|
||||
//Fill footer
|
||||
pImgFooter->magic = VTSI_IMG_MAGIC;
|
||||
pImgFooter->version = 1;
|
||||
pImgFooter->disk_size = pPhyDrive->SizeInBytes;
|
||||
memcpy(&pImgFooter->disk_signature, pPhyDrive->MBR.BootCode + 0x1b8, 4);
|
||||
pImgFooter->segment_num = segnum;
|
||||
pImgFooter->segment_offset = data_offset;
|
||||
|
||||
for (i = 0, chksum = 0; i < (int)(segnum * sizeof(VTSI_SEGMENT)); i++)
|
||||
{
|
||||
chksum += *((UINT8 *)pSegment + i);
|
||||
}
|
||||
pImgFooter->segment_chksum = ~chksum;
|
||||
|
||||
for (i = 0, chksum = 0; i < sizeof(VTSI_FOOTER); i++)
|
||||
{
|
||||
chksum += *((UINT8 *)pImgFooter + i);
|
||||
}
|
||||
pImgFooter->foot_chksum = ~chksum;
|
||||
|
||||
Log("Writing footer segnum(%u) segoffset(%llu) ......................", segnum, data_offset);
|
||||
Log("disk_size=%llu disk_signature=%lx segment_offset=%llu", pImgFooter->disk_size, pImgFooter->disk_signature, pImgFooter->segment_offset);
|
||||
|
||||
fwrite(pImgFooter, 1, sizeof(VTSI_FOOTER), fp);
|
||||
fclose(fp);
|
||||
|
||||
Log("Writing Ventoy image file finished, the file size should be %llu .", data_offset + 512 + ((dataLen + 511) / 512 * 512));
|
||||
|
||||
rc = 0;
|
||||
|
||||
End:
|
||||
|
||||
PROGRESS_BAR_SET_POS(PT_MOUNT_VOLUME);
|
||||
|
||||
Log("retcode:%d\n", rc);
|
||||
|
||||
SAFE_FREE(pData);
|
||||
SAFE_FREE(ImgBuf);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle)
|
||||
{
|
||||
int i;
|
||||
@@ -1573,7 +1773,6 @@ int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle)
|
||||
UINT64 Part1SectorCount = 0;
|
||||
UINT64 Part2StartSector = 0;
|
||||
|
||||
|
||||
Log("InstallVentoy2PhyDrive %s PhyDrive%d <<%s %s %dGB>>",
|
||||
PartStyle ? "GPT" : "MBR", pPhyDrive->PhyDrive, pPhyDrive->VendorId, pPhyDrive->ProductId,
|
||||
GetHumanReadableGBSize(pPhyDrive->SizeInBytes));
|
||||
@@ -1680,8 +1879,6 @@ int InstallVentoy2PhyDrive(PHY_DRIVE_INFO *pPhyDrive, int PartStyle)
|
||||
goto End;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PROGRESS_BAR_SET_POS(PT_FORMAT_PART2);
|
||||
Log("Writing part2 FAT img ...");
|
||||
|
||||
|
@@ -659,7 +659,7 @@ int VentoyFillGpt(UINT64 DiskSizeBytes, VTOY_GPT_INFO *pInfo)
|
||||
CoCreateGuid(&(Table[1].PartGuid));
|
||||
Table[1].StartLBA = Table[0].LastLBA + 1;
|
||||
Table[1].LastLBA = Table[1].StartLBA + VENTOY_EFI_PART_SIZE / 512 - 1;
|
||||
Table[1].Attr = 0x8000000000000001ULL;
|
||||
Table[1].Attr = 0xC000000000000001ULL;
|
||||
memcpy(Table[1].Name, L"VTOYEFI", 7 * 2);
|
||||
|
||||
#if 0
|
||||
|
@@ -28,6 +28,7 @@ DWORD g_PhyDriveCount = 0;
|
||||
static int g_FilterRemovable = 0;
|
||||
int g_FilterUSB = 1;
|
||||
int g_ForceOperation = 1;
|
||||
int g_WriteImage = 0;
|
||||
|
||||
int ParseCmdLineOption(LPSTR lpCmdLine)
|
||||
{
|
||||
|
@@ -233,4 +233,65 @@ UINT32 VentoyCrc32(void *Buffer, UINT32 Length);
|
||||
|
||||
#define SECURE_ICON_STRING _UICON(UNICODE_LOCK)
|
||||
|
||||
extern int g_WriteImage;
|
||||
|
||||
#define VTSI_IMG_MAGIC 0x0000594F544E4556ULL // "VENTOY\0\0"
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
/*
|
||||
+---------------------------------
|
||||
+ sector 0 ~ sector N-1
|
||||
+ data area
|
||||
+---------------------------------
|
||||
+ sector N ~
|
||||
+ segment[0]
|
||||
+ segment[1]
|
||||
+ segment[2]
|
||||
+ ......
|
||||
+ segment[M-1]
|
||||
+ align data (aligned with 512)
|
||||
+---------------------------------
|
||||
+ footer
|
||||
+---------------------------------
|
||||
*
|
||||
* All the integers are in little endian
|
||||
* The sector size is fixed 512 for ventoy image file.
|
||||
*
|
||||
*/
|
||||
|
||||
#define VTSI_IMG_MAX_SEG 128
|
||||
|
||||
typedef struct {
|
||||
UINT64 disk_start_sector;
|
||||
UINT64 sector_num;
|
||||
UINT64 data_offset;
|
||||
}VTSI_SEGMENT;
|
||||
|
||||
typedef struct {
|
||||
UINT64 magic;
|
||||
UINT32 version;
|
||||
UINT64 disk_size;
|
||||
UINT32 disk_signature;
|
||||
UINT32 foot_chksum;
|
||||
|
||||
UINT32 segment_num;
|
||||
UINT32 segment_chksum;
|
||||
UINT64 segment_offset;
|
||||
|
||||
UINT8 reserved[512 - 44];
|
||||
}VTSI_FOOTER;
|
||||
#pragma pack()
|
||||
extern int __static_assert__[sizeof(VTSI_FOOTER) == 512 ? 1 : -1];
|
||||
|
||||
|
||||
#define SAFE_FREE(ptr) if (ptr) { free(ptr); (ptr) = NULL; }
|
||||
int InstallVentoy2FileImage(PHY_DRIVE_INFO *pPhyDrive, int PartStyle);
|
||||
void disk_io_set_imghook(FILE *fp, VTSI_SEGMENT *segment, int maxseg, UINT64 data_offset);
|
||||
void disk_io_reset_imghook(int *psegnum, UINT64 *pDataOffset);
|
||||
|
||||
|
||||
#define VTSI_SUPPORT 0
|
||||
|
||||
|
||||
#endif
|
||||
|
Binary file not shown.
@@ -11,6 +11,8 @@
|
||||
|
||||
#include "ff.h" /* Obtains integer types */
|
||||
#include "diskio.h" /* Declarations of disk functions */
|
||||
#include "../Ventoy2Disk.h"
|
||||
|
||||
|
||||
/* Definitions of physical drive number for each drive */
|
||||
#define DEV_RAM 0 /* Example: Map Ramdisk to physical drive 0 */
|
||||
@@ -23,12 +25,41 @@ static UINT8 g_MbrSector[512];
|
||||
HANDLE g_hPhyDrive;
|
||||
UINT64 g_SectorCount;
|
||||
|
||||
FILE *g_VentoyImgFp = NULL;
|
||||
VTSI_SEGMENT *g_VentoySegment = NULL;
|
||||
int g_VentoyMaxSeg = 0;
|
||||
int g_VentoyCurSeg = -1;
|
||||
UINT64 g_VentoyDataOffset = 0;
|
||||
|
||||
void disk_io_set_param(HANDLE Handle, UINT64 SectorCount)
|
||||
{
|
||||
g_hPhyDrive = Handle;
|
||||
g_SectorCount = SectorCount;
|
||||
}
|
||||
|
||||
void disk_io_set_imghook(FILE *fp, VTSI_SEGMENT *segment, int maxseg, UINT64 data_offset)
|
||||
{
|
||||
g_VentoyImgFp = fp;
|
||||
g_VentoySegment = segment;
|
||||
g_VentoyMaxSeg = maxseg;
|
||||
|
||||
memset(segment, 0, maxseg * sizeof(VTSI_SEGMENT));
|
||||
g_VentoyCurSeg = -1;
|
||||
g_VentoyDataOffset = data_offset;
|
||||
}
|
||||
|
||||
void disk_io_reset_imghook(int *psegnum, UINT64 *pDataOffset)
|
||||
{
|
||||
*psegnum = g_VentoyCurSeg + 1;
|
||||
*pDataOffset = g_VentoyDataOffset;
|
||||
|
||||
g_VentoyImgFp = NULL;
|
||||
g_VentoySegment = NULL;
|
||||
g_VentoyMaxSeg = 0;
|
||||
g_VentoyCurSeg = -1;
|
||||
g_VentoyDataOffset = 0;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Get Drive Status */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
@@ -126,6 +157,13 @@ DRESULT disk_read (
|
||||
BOOL bRet;
|
||||
LARGE_INTEGER liCurrentPosition;
|
||||
|
||||
//Log("xxx disk_read: sector:%ld count:%ld", (long)sector, (long)count);
|
||||
|
||||
if (g_VentoyImgFp)
|
||||
{
|
||||
return RES_OK;
|
||||
}
|
||||
|
||||
liCurrentPosition.QuadPart = sector * 512;
|
||||
SetFilePointerEx(g_hPhyDrive, liCurrentPosition, &liCurrentPosition, FILE_BEGIN);
|
||||
|
||||
@@ -162,6 +200,9 @@ DRESULT disk_write (
|
||||
DWORD dwSize;
|
||||
BOOL bRet;
|
||||
LARGE_INTEGER liCurrentPosition;
|
||||
VTSI_SEGMENT *CurSeg = NULL;
|
||||
|
||||
Log("==== disk_write: sector:%ld count:%ld", (long)sector, (long)count);
|
||||
|
||||
// skip MBR
|
||||
if (sector == 0)
|
||||
@@ -177,6 +218,31 @@ DRESULT disk_write (
|
||||
count--;
|
||||
}
|
||||
|
||||
if (g_VentoyImgFp)
|
||||
{
|
||||
CurSeg = g_VentoySegment + g_VentoyCurSeg;
|
||||
|
||||
if (g_VentoyCurSeg >= 0 && CurSeg->sector_num > 0 && sector == CurSeg->disk_start_sector + CurSeg->sector_num)
|
||||
{
|
||||
CurSeg->sector_num += count; //merge
|
||||
}
|
||||
else
|
||||
{
|
||||
g_VentoyCurSeg++;
|
||||
CurSeg++;
|
||||
|
||||
CurSeg->disk_start_sector = sector;
|
||||
CurSeg->data_offset = g_VentoyDataOffset;
|
||||
CurSeg->sector_num = count;
|
||||
}
|
||||
|
||||
g_VentoyDataOffset += count * 512;
|
||||
|
||||
fwrite(buff, 1, count * 512, g_VentoyImgFp);
|
||||
return RES_OK;
|
||||
}
|
||||
|
||||
|
||||
liCurrentPosition.QuadPart = sector * 512;
|
||||
SetFilePointerEx(g_hPhyDrive, liCurrentPosition, &liCurrentPosition, FILE_BEGIN);
|
||||
|
||||
|
@@ -6067,6 +6067,11 @@ FRESULT f_mkfs (
|
||||
/* Initialize the root directory */
|
||||
mem_set(buf, 0, sz_buf * ss);
|
||||
buf[SZDIRE * 0 + 0] = ET_VLABEL; /* Volume label entry (no label) */
|
||||
|
||||
//default label: Ventoy (unicode)
|
||||
buf[1] = 6; //label length
|
||||
memcpy(buf + 2, L"Ventoy", 2 * buf[1]);
|
||||
|
||||
buf[SZDIRE * 1 + 0] = ET_BITMAP; /* Bitmap entry */
|
||||
st_dword(buf + SZDIRE * 1 + 20, 2); /* cluster */
|
||||
st_dword(buf + SZDIRE * 1 + 24, szb_bit); /* size */
|
||||
|
@@ -244,7 +244,7 @@ int DumpGptInfo(VTOY_GPT_INFO *pGptInfo)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define VENTOY_EFI_PART_ATTR 0x8000000000000001ULL
|
||||
#define VENTOY_EFI_PART_ATTR 0xC000000000000001ULL
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
|
@@ -309,11 +309,44 @@ static int Utf8ToUtf16(const char* src, WCHAR * dst)
|
||||
return MultiByteToWideChar(CP_UTF8, 0, src, -1, dst, size + 1);
|
||||
}
|
||||
|
||||
static BOOL IsPathExist(BOOL Dir, const char *Fmt, ...)
|
||||
static BOOL IsDirExist(const char *Fmt, ...)
|
||||
{
|
||||
va_list Arg;
|
||||
DWORD Attr;
|
||||
int UTF8 = 0;
|
||||
CHAR FilePathA[MAX_PATH];
|
||||
WCHAR FilePathW[MAX_PATH];
|
||||
|
||||
va_start(Arg, Fmt);
|
||||
vsnprintf_s(FilePathA, sizeof(FilePathA), sizeof(FilePathA), Fmt, Arg);
|
||||
va_end(Arg);
|
||||
|
||||
UTF8 = IsUTF8Encode(FilePathA);
|
||||
|
||||
if (UTF8)
|
||||
{
|
||||
Utf8ToUtf16(FilePathA, FilePathW);
|
||||
Attr = GetFileAttributesW(FilePathW);
|
||||
}
|
||||
else
|
||||
{
|
||||
Attr = GetFileAttributesA(FilePathA);
|
||||
}
|
||||
|
||||
if (Attr != INVALID_FILE_ATTRIBUTES && (Attr & FILE_ATTRIBUTE_DIRECTORY))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static BOOL IsFileExist(const char *Fmt, ...)
|
||||
{
|
||||
va_list Arg;
|
||||
HANDLE hFile;
|
||||
DWORD Attr;
|
||||
BOOL bRet = FALSE;
|
||||
int UTF8 = 0;
|
||||
CHAR FilePathA[MAX_PATH];
|
||||
WCHAR FilePathW[MAX_PATH];
|
||||
@@ -335,7 +368,7 @@ static BOOL IsPathExist(BOOL Dir, const char *Fmt, ...)
|
||||
}
|
||||
if (INVALID_HANDLE_VALUE == hFile)
|
||||
{
|
||||
return FALSE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
CloseHandle(hFile);
|
||||
@@ -349,22 +382,16 @@ static BOOL IsPathExist(BOOL Dir, const char *Fmt, ...)
|
||||
Attr = GetFileAttributesA(FilePathA);
|
||||
}
|
||||
|
||||
if (Dir)
|
||||
{
|
||||
if ((Attr & FILE_ATTRIBUTE_DIRECTORY) == 0)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Attr & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
if (Attr & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
bRet = TRUE;
|
||||
|
||||
out:
|
||||
Log("File <%s> %s", FilePathA, (bRet ? "exist" : "NOT exist"));
|
||||
return bRet;
|
||||
}
|
||||
|
||||
static int GetPhyDiskUUID(const char LogicalDrive, UINT8 *UUID, DISK_EXTENT *DiskExtent)
|
||||
@@ -425,6 +452,121 @@ static int GetPhyDiskUUID(const char LogicalDrive, UINT8 *UUID, DISK_EXTENT *Dis
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int VentoyMountAnywhere(HANDLE Handle)
|
||||
{
|
||||
DWORD Status;
|
||||
ATTACH_VIRTUAL_DISK_PARAMETERS AttachParameters;
|
||||
|
||||
Log("VentoyMountAnywhere");
|
||||
|
||||
memset(&AttachParameters, 0, sizeof(AttachParameters));
|
||||
AttachParameters.Version = ATTACH_VIRTUAL_DISK_VERSION_1;
|
||||
|
||||
Status = AttachVirtualDisk(Handle, NULL, ATTACH_VIRTUAL_DISK_FLAG_READ_ONLY | ATTACH_VIRTUAL_DISK_FLAG_PERMANENT_LIFETIME, 0, &AttachParameters, NULL);
|
||||
if (Status != ERROR_SUCCESS)
|
||||
{
|
||||
Log("Failed to attach virtual disk ErrorCode:%u", Status);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VentoyMountY(HANDLE Handle)
|
||||
{
|
||||
int i;
|
||||
BOOL bRet = FALSE;
|
||||
DWORD Status;
|
||||
DWORD physicalDriveNameSize;
|
||||
CHAR *Pos = NULL;
|
||||
WCHAR physicalDriveName[MAX_PATH];
|
||||
CHAR physicalDriveNameA[MAX_PATH];
|
||||
CHAR cdromDriveName[MAX_PATH];
|
||||
ATTACH_VIRTUAL_DISK_PARAMETERS AttachParameters;
|
||||
|
||||
Log("VentoyMountY");
|
||||
|
||||
memset(&AttachParameters, 0, sizeof(AttachParameters));
|
||||
AttachParameters.Version = ATTACH_VIRTUAL_DISK_VERSION_1;
|
||||
|
||||
Status = AttachVirtualDisk(Handle, NULL, ATTACH_VIRTUAL_DISK_FLAG_READ_ONLY | ATTACH_VIRTUAL_DISK_FLAG_NO_DRIVE_LETTER | ATTACH_VIRTUAL_DISK_FLAG_PERMANENT_LIFETIME, 0, &AttachParameters, NULL);
|
||||
if (Status != ERROR_SUCCESS)
|
||||
{
|
||||
Log("Failed to attach virtual disk ErrorCode:%u", Status);
|
||||
return 1;
|
||||
}
|
||||
|
||||
memset(physicalDriveName, 0, sizeof(physicalDriveName));
|
||||
memset(physicalDriveNameA, 0, sizeof(physicalDriveNameA));
|
||||
|
||||
physicalDriveNameSize = MAX_PATH;
|
||||
Status = GetVirtualDiskPhysicalPath(Handle, &physicalDriveNameSize, physicalDriveName);
|
||||
if (Status != ERROR_SUCCESS)
|
||||
{
|
||||
Log("Failed GetVirtualDiskPhysicalPath ErrorCode:%u", Status);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (i = 0; physicalDriveName[i]; i++)
|
||||
{
|
||||
physicalDriveNameA[i] = toupper((CHAR)(physicalDriveName[i]));
|
||||
}
|
||||
|
||||
Log("physicalDriveNameA=<%s>", physicalDriveNameA);
|
||||
|
||||
Pos = strstr(physicalDriveNameA, "CDROM");
|
||||
if (!Pos)
|
||||
{
|
||||
Log("Not cdrom phy drive");
|
||||
return 1;
|
||||
}
|
||||
|
||||
sprintf_s(cdromDriveName, sizeof(cdromDriveName), "\\Device\\%s", Pos);
|
||||
Log("cdromDriveName=<%s>", cdromDriveName);
|
||||
|
||||
for (i = 0; i < 3 && (bRet == FALSE); i++)
|
||||
{
|
||||
Sleep(1000);
|
||||
bRet = DefineDosDeviceA(DDD_RAW_TARGET_PATH, "Y:", cdromDriveName);
|
||||
Log("DefineDosDeviceA %s", bRet ? "success" : "failed");
|
||||
}
|
||||
|
||||
return bRet ? 0 : 1;
|
||||
}
|
||||
|
||||
static BOOL VentoyNeedMountY(const char *IsoPath)
|
||||
{
|
||||
/* TBD */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int VentoyAttachVirtualDisk(HANDLE Handle, const char *IsoPath)
|
||||
{
|
||||
int DriveYFree;
|
||||
DWORD Drives;
|
||||
|
||||
Drives = GetLogicalDrives();
|
||||
if ((1 << 24) & Drives)
|
||||
{
|
||||
Log("Y: is occupied");
|
||||
DriveYFree = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("Y: is free now");
|
||||
DriveYFree = 1;
|
||||
}
|
||||
|
||||
if (DriveYFree && VentoyNeedMountY(IsoPath))
|
||||
{
|
||||
return VentoyMountY(Handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
return VentoyMountAnywhere(Handle);
|
||||
}
|
||||
}
|
||||
|
||||
int VentoyMountISOByAPI(const char *IsoPath)
|
||||
{
|
||||
HANDLE Handle;
|
||||
@@ -432,7 +574,6 @@ int VentoyMountISOByAPI(const char *IsoPath)
|
||||
WCHAR wFilePath[512] = { 0 };
|
||||
VIRTUAL_STORAGE_TYPE StorageType;
|
||||
OPEN_VIRTUAL_DISK_PARAMETERS OpenParameters;
|
||||
ATTACH_VIRTUAL_DISK_PARAMETERS AttachParameters;
|
||||
|
||||
Log("VentoyMountISOByAPI <%s>", IsoPath);
|
||||
|
||||
@@ -447,10 +588,8 @@ int VentoyMountISOByAPI(const char *IsoPath)
|
||||
|
||||
memset(&StorageType, 0, sizeof(StorageType));
|
||||
memset(&OpenParameters, 0, sizeof(OpenParameters));
|
||||
memset(&AttachParameters, 0, sizeof(AttachParameters));
|
||||
|
||||
|
||||
OpenParameters.Version = OPEN_VIRTUAL_DISK_VERSION_1;
|
||||
AttachParameters.Version = ATTACH_VIRTUAL_DISK_VERSION_1;
|
||||
|
||||
Status = OpenVirtualDisk(&StorageType, wFilePath, VIRTUAL_DISK_ACCESS_READ, 0, &OpenParameters, &Handle);
|
||||
if (Status != ERROR_SUCCESS)
|
||||
@@ -468,7 +607,7 @@ int VentoyMountISOByAPI(const char *IsoPath)
|
||||
|
||||
Log("OpenVirtualDisk success");
|
||||
|
||||
Status = AttachVirtualDisk(Handle, NULL, ATTACH_VIRTUAL_DISK_FLAG_READ_ONLY | ATTACH_VIRTUAL_DISK_FLAG_PERMANENT_LIFETIME, 0, &AttachParameters, NULL);
|
||||
Status = VentoyAttachVirtualDisk(Handle, IsoPath);
|
||||
if (Status != ERROR_SUCCESS)
|
||||
{
|
||||
Log("Failed to attach virtual disk ErrorCode:%u", Status);
|
||||
@@ -476,6 +615,8 @@ int VentoyMountISOByAPI(const char *IsoPath)
|
||||
return 1;
|
||||
}
|
||||
|
||||
Log("VentoyAttachVirtualDisk success");
|
||||
|
||||
CloseHandle(Handle);
|
||||
return 0;
|
||||
}
|
||||
@@ -789,7 +930,7 @@ static int DeleteVentoyPart2MountPoint(DWORD PhyDrive)
|
||||
Drives = GetLogicalDrives();
|
||||
while (Drives)
|
||||
{
|
||||
if ((Drives & 0x01) && IsPathExist(FALSE, "%C:\\ventoy\\ventoy.cpio", Letter))
|
||||
if ((Drives & 0x01) && IsFileExist("%C:\\ventoy\\ventoy.cpio", Letter))
|
||||
{
|
||||
Log("File %C:\\ventoy\\ventoy.cpio exist", Letter);
|
||||
|
||||
@@ -1010,7 +1151,7 @@ static int VentoyHook(ventoy_os_param *param)
|
||||
if (Drives & 0x01)
|
||||
{
|
||||
sprintf_s(IsoPath, sizeof(IsoPath), "%C:\\%s", Letter, param->vtoy_img_path);
|
||||
if (IsPathExist(FALSE, "%s", IsoPath))
|
||||
if (IsFileExist("%s", IsoPath))
|
||||
{
|
||||
Log("File exist under %C:", Letter);
|
||||
if (GetPhyDiskUUID(Letter, UUID, &DiskExtent) == 0)
|
||||
@@ -1050,7 +1191,7 @@ static int VentoyHook(ventoy_os_param *param)
|
||||
if (g_windows_data.auto_install_script[0])
|
||||
{
|
||||
sprintf_s(IsoPath, sizeof(IsoPath), "%C:%s", Letter, g_windows_data.auto_install_script);
|
||||
if (IsPathExist(FALSE, "%s", IsoPath))
|
||||
if (IsFileExist("%s", IsoPath))
|
||||
{
|
||||
Log("use auto install script %s...", IsoPath);
|
||||
ProcessUnattendedInstallation(IsoPath);
|
||||
@@ -1068,7 +1209,7 @@ static int VentoyHook(ventoy_os_param *param)
|
||||
if (g_windows_data.injection_archive[0])
|
||||
{
|
||||
sprintf_s(IsoPath, sizeof(IsoPath), "%C:%s", Letter, g_windows_data.injection_archive);
|
||||
if (IsPathExist(FALSE, "%s", IsoPath))
|
||||
if (IsFileExist("%s", IsoPath))
|
||||
{
|
||||
Log("decompress injection archive %s...", IsoPath);
|
||||
DecompressInjectionArchive(IsoPath, DiskExtent.DiskNumber);
|
||||
@@ -1105,6 +1246,64 @@ const char * GetFileNameInPath(const char *fullpath)
|
||||
return fullpath;
|
||||
}
|
||||
|
||||
int VentoyJumpWimboot(INT argc, CHAR **argv, CHAR *LunchFile)
|
||||
{
|
||||
int rc = 1;
|
||||
char *buf = NULL;
|
||||
DWORD size = 0;
|
||||
DWORD Pos;
|
||||
|
||||
#ifdef VTOY_32
|
||||
g_64bit_system = FALSE;
|
||||
#else
|
||||
g_64bit_system = TRUE;
|
||||
#endif
|
||||
|
||||
Log("VentoyJumpWimboot %dbit", g_64bit_system ? 64 : 32);
|
||||
|
||||
sprintf_s(LunchFile, MAX_PATH, "X:\\setup.exe");
|
||||
|
||||
ReadWholeFile2Buf("wimboot.data", &buf, &size);
|
||||
Log("wimboot.data size:%d", size);
|
||||
|
||||
memcpy(&g_os_param, buf, sizeof(ventoy_os_param));
|
||||
memcpy(&g_windows_data, buf + sizeof(ventoy_os_param), sizeof(ventoy_windows_data));
|
||||
memcpy(g_os_param_reserved, g_os_param.vtoy_reserved, sizeof(g_os_param_reserved));
|
||||
|
||||
if (g_os_param_reserved[0] == 1)
|
||||
{
|
||||
Log("break here for debug .....");
|
||||
goto End;
|
||||
}
|
||||
|
||||
// convert / to \\
|
||||
for (Pos = 0; Pos < sizeof(g_os_param.vtoy_img_path) && g_os_param.vtoy_img_path[Pos]; Pos++)
|
||||
{
|
||||
if (g_os_param.vtoy_img_path[Pos] == '/')
|
||||
{
|
||||
g_os_param.vtoy_img_path[Pos] = '\\';
|
||||
}
|
||||
}
|
||||
|
||||
if (g_os_param_reserved[0] == 2)
|
||||
{
|
||||
Log("skip hook for debug .....");
|
||||
rc = 0;
|
||||
goto End;
|
||||
}
|
||||
|
||||
rc = VentoyHook(&g_os_param);
|
||||
|
||||
End:
|
||||
|
||||
if (buf)
|
||||
{
|
||||
free(buf);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int VentoyJump(INT argc, CHAR **argv, CHAR *LunchFile)
|
||||
{
|
||||
int rc = 1;
|
||||
@@ -1115,12 +1314,12 @@ int VentoyJump(INT argc, CHAR **argv, CHAR *LunchFile)
|
||||
CHAR ExeFileName[MAX_PATH];
|
||||
|
||||
sprintf_s(ExeFileName, sizeof(ExeFileName), "%s", argv[0]);
|
||||
if (!IsPathExist(FALSE, "%s", ExeFileName))
|
||||
if (!IsFileExist("%s", ExeFileName))
|
||||
{
|
||||
Log("File %s NOT exist, now try %s.exe", ExeFileName, ExeFileName);
|
||||
sprintf_s(ExeFileName, sizeof(ExeFileName), "%s.exe", argv[0]);
|
||||
|
||||
Log("File %s exist ? %s", ExeFileName, IsPathExist(FALSE, "%s", ExeFileName) ? "YES" : "NO");
|
||||
Log("File %s exist ? %s", ExeFileName, IsFileExist("%s", ExeFileName) ? "YES" : "NO");
|
||||
}
|
||||
|
||||
if (ReadWholeFile2Buf(ExeFileName, (void **)&Buffer, &FileSize))
|
||||
@@ -1129,9 +1328,15 @@ int VentoyJump(INT argc, CHAR **argv, CHAR *LunchFile)
|
||||
}
|
||||
|
||||
g_64bit_system = IsPe64(Buffer);
|
||||
Log("VentoyJump %dbit", g_64bit_system ? 64 : 32);
|
||||
|
||||
if (!IsPathExist(TRUE, "ventoy"))
|
||||
if (IsDirExist("ventoy"))
|
||||
{
|
||||
Log("ventoy directory already exist");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("ventoy directory not exist, now create it.");
|
||||
if (!CreateDirectoryA("ventoy", NULL))
|
||||
{
|
||||
Log("Failed to create ventoy directory err:%u", GetLastError());
|
||||
@@ -1167,6 +1372,14 @@ int VentoyJump(INT argc, CHAR **argv, CHAR *LunchFile)
|
||||
|
||||
PeStart += sizeof(ventoy_os_param) + sizeof(ventoy_windows_data);
|
||||
sprintf_s(LunchFile, MAX_PATH, "ventoy\\%s", GetFileNameInPath(ExeFileName));
|
||||
|
||||
if (IsFileExist("%s", LunchFile))
|
||||
{
|
||||
Log("vtoyjump multiple call...");
|
||||
rc = 0;
|
||||
goto End;
|
||||
}
|
||||
|
||||
SaveBuffer2File(LunchFile, Buffer + PeStart, FileSize - PeStart);
|
||||
break;
|
||||
}
|
||||
@@ -1197,6 +1410,120 @@ End:
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int GetPecmdParam(const char *argv, char *CallParamBuf, DWORD BufLen)
|
||||
{
|
||||
HKEY hKey;
|
||||
LSTATUS Ret;
|
||||
DWORD dw;
|
||||
DWORD Type;
|
||||
CHAR *Pos = NULL;
|
||||
CHAR CallParam[256] = { 0 };
|
||||
CHAR FileName[MAX_PATH];
|
||||
|
||||
Log("GetPecmdParam <%s>", argv);
|
||||
|
||||
*CallParamBuf = 0;
|
||||
|
||||
strcpy_s(FileName, sizeof(FileName), argv);
|
||||
for (dw = 0, Pos = FileName; *Pos; Pos++)
|
||||
{
|
||||
dw++;
|
||||
*Pos = toupper(*Pos);
|
||||
}
|
||||
|
||||
Log("dw=%lu argv=<%s>", dw, FileName);
|
||||
|
||||
if (dw >= 9 && strcmp(FileName + dw - 9, "PECMD.EXE") == 0)
|
||||
{
|
||||
Log("Get parameters for pecmd.exe");
|
||||
Ret = RegCreateKeyEx(HKEY_LOCAL_MACHINE, "System\\Setup", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dw);
|
||||
if (ERROR_SUCCESS == Ret)
|
||||
{
|
||||
memset(FileName, 0, sizeof(FileName));
|
||||
dw = sizeof(FileName);
|
||||
Ret = RegQueryValueEx(hKey, "CmdLine", NULL, &Type, FileName, &dw);
|
||||
if (ERROR_SUCCESS == Ret && Type == REG_SZ)
|
||||
{
|
||||
strcpy_s(CallParam, sizeof(CallParam), FileName);
|
||||
Log("CmdLine:<%s>", CallParam);
|
||||
|
||||
if (_strnicmp(CallParam, "PECMD.EXE", 9) == 0)
|
||||
{
|
||||
Pos = CallParam + 9;
|
||||
if (*Pos == ' ' || *Pos == '\t')
|
||||
{
|
||||
Pos++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Pos = CallParam;
|
||||
}
|
||||
|
||||
Log("CmdLine2:<%s>", Pos);
|
||||
sprintf_s(CallParamBuf, BufLen, " %s", Pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("Failed to RegQueryValueEx %lu %lu", Ret, Type);
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("Failed to create reg key %lu", Ret);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("This is NOT pecmd.exe");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int GetWpeInitParam(char **argv, int argc, char *CallParamBuf, DWORD BufLen)
|
||||
{
|
||||
int i;
|
||||
DWORD dw;
|
||||
CHAR *Pos = NULL;
|
||||
CHAR FileName[MAX_PATH];
|
||||
|
||||
Log("GetWpeInitParam argc=%d", argc);
|
||||
|
||||
*CallParamBuf = 0;
|
||||
|
||||
strcpy_s(FileName, sizeof(FileName), argv[0]);
|
||||
for (dw = 0, Pos = FileName; *Pos; Pos++)
|
||||
{
|
||||
dw++;
|
||||
*Pos = toupper(*Pos);
|
||||
}
|
||||
|
||||
Log("dw=%lu argv=<%s>", dw, FileName);
|
||||
|
||||
if (dw >= 11 && strcmp(FileName + dw - 11, "WPEINIT.EXE") == 0)
|
||||
{
|
||||
Log("Get parameters for WPEINIT.EXE");
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
strcat_s(CallParamBuf, BufLen, " ");
|
||||
strcat_s(CallParamBuf, BufLen, argv[i]);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("This is NOT wpeinit.exe");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i = 0;
|
||||
@@ -1204,6 +1531,7 @@ int main(int argc, char **argv)
|
||||
CHAR *Pos = NULL;
|
||||
CHAR CurDir[MAX_PATH];
|
||||
CHAR LunchFile[MAX_PATH];
|
||||
CHAR CallParam[1024] = { 0 };
|
||||
STARTUPINFOA Si;
|
||||
PROCESS_INFORMATION Pi;
|
||||
|
||||
@@ -1238,10 +1566,25 @@ int main(int argc, char **argv)
|
||||
Log("Current directory = <%s>", CurDir);
|
||||
}
|
||||
|
||||
if (0 == GetWpeInitParam(argv, argc, CallParam, sizeof(CallParam)))
|
||||
{
|
||||
GetPecmdParam(argv[0], CallParam, sizeof(CallParam));
|
||||
}
|
||||
|
||||
GetStartupInfoA(&Si);
|
||||
|
||||
memset(LunchFile, 0, sizeof(LunchFile));
|
||||
rc = VentoyJump(argc, argv, LunchFile);
|
||||
|
||||
if (strstr(argv[0], "vtoyjump.exe"))
|
||||
{
|
||||
rc = VentoyJumpWimboot(argc, argv, LunchFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = VentoyJump(argc, argv, LunchFile);
|
||||
}
|
||||
|
||||
Log("LunchFile=<%s> CallParam=<%s>", LunchFile, CallParam);
|
||||
|
||||
if (g_os_param_reserved[0] == 3)
|
||||
{
|
||||
@@ -1250,22 +1593,35 @@ int main(int argc, char **argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
Si.dwFlags |= STARTF_USESHOWWINDOW;
|
||||
Si.wShowWindow = SW_HIDE;
|
||||
if (CallParam[0])
|
||||
{
|
||||
strcat_s(LunchFile, sizeof(LunchFile), CallParam);
|
||||
}
|
||||
else if (NULL == strstr(LunchFile, "setup.exe"))
|
||||
{
|
||||
Log("Not setup.exe, hide windows.");
|
||||
Si.dwFlags |= STARTF_USESHOWWINDOW;
|
||||
Si.wShowWindow = SW_HIDE;
|
||||
}
|
||||
|
||||
Log("Ventoy jump %s ...", rc == 0 ? "success" : "failed");
|
||||
}
|
||||
|
||||
Log("Now launch <%s> ...", LunchFile);
|
||||
|
||||
CreateProcessA(NULL, LunchFile, NULL, NULL, FALSE, 0, NULL, NULL, &Si, &Pi);
|
||||
//sprintf_s(LunchFile, sizeof(LunchFile), "%s", "cmd.exe");
|
||||
CreateProcessA(NULL, LunchFile, NULL, NULL, FALSE, 0, NULL, NULL, &Si, &Pi);
|
||||
|
||||
while (rc)
|
||||
for (i = 0; rc && i < 10; i++)
|
||||
{
|
||||
Log("Ventoy hook failed, now wait and retry ...");
|
||||
Sleep(1000);
|
||||
|
||||
rc = VentoyHook(&g_os_param);
|
||||
}
|
||||
|
||||
WaitForSingleObject(Pi.hProcess, INFINITE);
|
||||
Log("Wait process...");
|
||||
WaitForSingleObject(Pi.hProcess, INFINITE);
|
||||
|
||||
Log("vtoyjump finished");
|
||||
return 0;
|
||||
}
|
||||
|
@@ -92,7 +92,7 @@
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>FATFS_INC_FORMAT_SUPPORT=0;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>VTOY_32;FATFS_INC_FORMAT_SUPPORT=0;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
@@ -108,7 +108,7 @@
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>FATFS_INC_FORMAT_SUPPORT=0;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>VTOY_64;FATFS_INC_FORMAT_SUPPORT=0;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
@@ -126,7 +126,7 @@
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>FATFS_INC_FORMAT_SUPPORT=0;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>VTOY_32;FATFS_INC_FORMAT_SUPPORT=0;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
@@ -146,7 +146,7 @@
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>FATFS_INC_FORMAT_SUPPORT=0;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>VTOY_64;FATFS_INC_FORMAT_SUPPORT=0;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
|
20
wimboot/build.sh
Normal file
20
wimboot/build.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
VTOY_PATH=$PWD/../
|
||||
|
||||
cd wimboot-2.7.3/src
|
||||
|
||||
make clean
|
||||
make -j 16
|
||||
|
||||
rm -f *.xz
|
||||
xz wimboot.x86_64
|
||||
xz wimboot.i386.efi
|
||||
|
||||
rm -f $VTOY_PATH/INSTALL/ventoy/wimboot.x86_64.xz
|
||||
rm -f $VTOY_PATH/INSTALL/ventoy/wimboot.i386.efi.xz
|
||||
cp -a wimboot.x86_64.xz $VTOY_PATH/INSTALL/ventoy/
|
||||
cp -a wimboot.i386.efi.xz $VTOY_PATH/INSTALL/ventoy/
|
||||
|
||||
make clean
|
||||
cd ../../
|
10
wimboot/wimboot-2.7.3/src/.gitignore
vendored
Normal file
10
wimboot/wimboot-2.7.3/src/.gitignore
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
wimboot
|
||||
*.s
|
||||
*.o
|
||||
*.a
|
||||
*.elf
|
||||
*.map
|
||||
*.unsigned
|
||||
*.efi
|
||||
*.cab
|
||||
efireloc
|
187
wimboot/wimboot-2.7.3/src/Makefile
Normal file
187
wimboot/wimboot-2.7.3/src/Makefile
Normal file
@@ -0,0 +1,187 @@
|
||||
VERSION := v2.7.3
|
||||
|
||||
OBJECTS := prefix.o startup.o callback.o main.o vsprintf.o string.o peloader.o
|
||||
OBJECTS += int13.o vdisk.o cpio.o stdio.o lznt1.o xca.o die.o efi.o efimain.o
|
||||
OBJECTS += efiguid.o efifile.o efipath.o efiboot.o efiblock.o cmdline.o
|
||||
OBJECTS += wimpatch.o huffman.o lzx.o wim.o wimfile.o pause.o sha1.o cookie.o
|
||||
OBJECTS += paging.o memmap.o
|
||||
|
||||
OBJECTS_i386 := $(patsubst %.o,%.i386.o,$(OBJECTS))
|
||||
OBJECTS_x86_64 := $(patsubst %.o,%.x86_64.o,$(OBJECTS))
|
||||
OBJECTS_i386_x86_64 := $(patsubst %.o,%.i386.x86_64.o,$(OBJECTS))
|
||||
|
||||
HEADERS := $(wildcard *.h)
|
||||
|
||||
HOST_CC := $(CC)
|
||||
AS := $(AS)
|
||||
ECHO := echo
|
||||
OBJCOPY := objcopy
|
||||
AR := ar
|
||||
RANLIB := ranlib
|
||||
CP := cp
|
||||
RM := rm
|
||||
GCAB := gcab
|
||||
PESIGN := pesign
|
||||
DIFF := diff
|
||||
CUT := cut
|
||||
BINUTILS_DIR := /usr
|
||||
BFD_DIR := $(BINUTILS_DIR)
|
||||
ZLIB_DIR := /usr
|
||||
|
||||
HOST_CFLAGS += -Wall -W -Werror
|
||||
|
||||
CFLAGS += -Os -ffreestanding -Wall -W -Werror -nostdinc -I. -fshort-wchar
|
||||
CFLAGS += -DVERSION="\"$(VERSION)\""
|
||||
|
||||
CFLAGS_i386 += -m32 -march=i386 -malign-double -fno-pic
|
||||
CFLAGS_x86_64 += -m64 -mno-red-zone -fpie
|
||||
|
||||
# Enable stack protection if available
|
||||
#
|
||||
SPG_TEST = $(CC) -fstack-protector-strong -mstack-protector-guard=global \
|
||||
-x c -c /dev/null -o /dev/null >/dev/null 2>&1
|
||||
SPG_FLAGS := $(shell $(SPG_TEST) && $(ECHO) '-fstack-protector-strong ' \
|
||||
'-mstack-protector-guard=global')
|
||||
CFLAGS += $(SPG_FLAGS)
|
||||
|
||||
# Inhibit unwanted debugging information
|
||||
CFI_TEST = $(CC) -fno-dwarf2-cfi-asm -fno-exceptions -fno-unwind-tables \
|
||||
-fno-asynchronous-unwind-tables -x c -c /dev/null \
|
||||
-o /dev/null >/dev/null 2>&1
|
||||
CFI_FLAGS := $(shell $(CFI_TEST) && \
|
||||
$(ECHO) '-fno-dwarf2-cfi-asm -fno-exceptions ' \
|
||||
'-fno-unwind-tables -fno-asynchronous-unwind-tables')
|
||||
WORKAROUND_CFLAGS += $(CFI_FLAGS)
|
||||
|
||||
# Add -maccumulate-outgoing-args if required by this version of gcc
|
||||
MS_ABI_TEST_CODE := extern void __attribute__ (( ms_abi )) ms_abi(); \
|
||||
void sysv_abi ( void ) { ms_abi(); }
|
||||
MS_ABI_TEST = $(ECHO) '$(MS_ABI_TEST_CODE)' | \
|
||||
$(CC) -m64 -mno-accumulate-outgoing-args -x c -c - -o /dev/null \
|
||||
>/dev/null 2>&1
|
||||
MS_ABI_FLAGS := $(shell $(MS_ABI_TEST) || $(ECHO) '-maccumulate-outgoing-args')
|
||||
WORKAROUND_CFLAGS += $(MS_ABI_FLAGS)
|
||||
|
||||
# Inhibit warnings from taking address of packed struct members
|
||||
WNAPM_TEST = $(CC) -Wno-address-of-packed-member -x c -c /dev/null \
|
||||
-o /dev/null >/dev/null 2>&1
|
||||
WNAPM_FLAGS := $(shell $(WNAPM_TEST) && \
|
||||
$(ECHO) '-Wno-address-of-packed-member')
|
||||
WORKAROUND_CFLAGS += $(WNAPM_FLAGS)
|
||||
|
||||
# Inhibit LTO
|
||||
LTO_TEST = $(CC) -fno-lto -x c -c /dev/null -o /dev/null >/dev/null 2>&1
|
||||
LTO_FLAGS := $(shell $(LTO_TEST) && $(ECHO) '-fno-lto')
|
||||
WORKAROUND_CFLAGS += $(LTO_FLAGS)
|
||||
|
||||
CFLAGS += $(WORKAROUND_CFLAGS)
|
||||
CFLAGS += $(EXTRA_CFLAGS)
|
||||
|
||||
ifneq ($(DEBUG),)
|
||||
CFLAGS += -DDEBUG=$(DEBUG)
|
||||
endif
|
||||
|
||||
CFLAGS += -include compiler.h
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Final targets
|
||||
|
||||
all : wimboot wimboot.i386 wimboot.x86_64 wimboot.cab
|
||||
|
||||
wimboot : wimboot.x86_64 Makefile
|
||||
$(CP) $< $@
|
||||
$(CP) $@ ../$@
|
||||
|
||||
wimboot.%.elf : prefix.%.o lib.%.a script.lds Makefile
|
||||
$(LD) -m elf_$* -T script.lds -o $@ -q -Map wimboot.$*.map \
|
||||
prefix.$*.o lib.$*.a
|
||||
|
||||
wimboot.%.unsigned : wimboot.%.elf efireloc Makefile
|
||||
$(OBJCOPY) -Obinary $< $@
|
||||
./efireloc $< $@
|
||||
|
||||
wimboot.%.unsigned.hash : wimboot.%.unsigned Makefile
|
||||
$(PESIGN) -h -i $< | $(CUT) -d" " -f2- > $@
|
||||
|
||||
wimboot.%.efi : wimboot.%.unsigned Makefile
|
||||
$(CP) $< $@
|
||||
|
||||
wimboot.%.efi.hash : wimboot.%.efi Makefile
|
||||
$(PESIGN) -h -i $< | $(CUT) -d" " -f2- > $@
|
||||
|
||||
wimboot.% : wimboot.%.efi wimboot.%.efi.hash wimboot.%.unsigned.hash Makefile
|
||||
$(DIFF) wimboot.$*.efi.hash wimboot.$*.unsigned.hash
|
||||
$(CP) $< $@
|
||||
|
||||
wimboot.cab : wimboot.i386.efi wimboot.x86_64.efi Makefile
|
||||
$(GCAB) -n -c $@ wimboot.i386.efi wimboot.x86_64.efi
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# i386 objects
|
||||
|
||||
%.i386.s : %.S $(HEADERS) Makefile
|
||||
$(CC) $(CFLAGS) $(CFLAGS_i386) -DASSEMBLY -Ui386 -E $< -o $@
|
||||
|
||||
%.i386.s : %.c $(HEADERS) Makefile
|
||||
$(CC) $(CFLAGS) $(CFLAGS_i386) -S $< -o $@
|
||||
|
||||
%.i386.o : %.i386.s i386.i Makefile
|
||||
$(AS) --32 i386.i $< -o $@
|
||||
|
||||
lib.i386.a : $(OBJECTS_i386) Makefile
|
||||
$(RM) -f $@
|
||||
$(AR) r $@ $(OBJECTS_i386)
|
||||
$(RANLIB) $@
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# i386 objects to be linked into an x86_64 binary
|
||||
|
||||
%.i386.x86_64.raw.o : %.i386.s i386.i Makefile
|
||||
$(AS) --64 i386.i $< -o $@
|
||||
|
||||
%.i386.x86_64.o : %.i386.x86_64.raw.o Makefile
|
||||
$(OBJCOPY) --prefix-symbols=__i386_ $< $@
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# x86_64 objects
|
||||
|
||||
%.x86_64.s : %.S $(HEADERS) Makefile
|
||||
$(CC) $(CFLAGS) $(CFLAGS_x86_64) -DASSEMBLY -Ui386 -E $< -o $@
|
||||
|
||||
%.x86_64.s : %.c $(HEADERS) Makefile
|
||||
$(CC) $(CFLAGS) $(CFLAGS_x86_64) -S $< -o $@
|
||||
|
||||
%.x86_64.o : %.x86_64.s x86_64.i Makefile
|
||||
$(AS) --64 x86_64.i $< -o $@
|
||||
|
||||
lib.x86_64.a : $(OBJECTS_x86_64) $(OBJECTS_i386_x86_64) Makefile
|
||||
$(RM) -f $@
|
||||
$(AR) r $@ $(OBJECTS_x86_64) $(OBJECTS_i386_x86_64)
|
||||
$(RANLIB) $@
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# EFI relocator
|
||||
|
||||
EFIRELOC_CFLAGS := -I$(BINUTILS_DIR)/include -I$(BFD_DIR)/include \
|
||||
-I$(ZLIB_DIR)/include -idirafter .
|
||||
EFIRELOC_LDFLAGS := -L$(BINUTILS_DIR)/lib -L$(BFD_DIR)/lib -L$(ZLIB_DIR)/lib \
|
||||
-lbfd -ldl -liberty -lz -Wl,--no-warn-search-mismatch
|
||||
|
||||
efireloc : efireloc.c Makefile
|
||||
$(CC) $(HOST_CFLAGS) $(EFIRELOC_CFLAGS) $< $(EFIRELOC_LDFLAGS) -o $@
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Cleanup
|
||||
|
||||
clean :
|
||||
$(RM) -f *.s *.o *.a *.elf *.map
|
||||
$(RM) -f efireloc
|
||||
$(RM) -f wimboot wimboot.i386 wimboot.x86_64 ../wimboot
|
||||
$(RM) -f wimboot.i386.unsigned wimboot.x86_64.unsigned
|
||||
$(RM) -f wimboot.i386.efi wimboot.x86_64.efi wimboot.cab
|
39
wimboot/wimboot-2.7.3/src/assert.h
Normal file
39
wimboot/wimboot-2.7.3/src/assert.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef _ASSERT_H
|
||||
#define _ASSERT_H
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Assertions
|
||||
*
|
||||
*/
|
||||
|
||||
#include "wimboot.h"
|
||||
|
||||
#define assert(x) do { \
|
||||
if ( DEBUG && ! (x) ) { \
|
||||
die ( "Assertion failed at %s line %d: %s\n", \
|
||||
__FILE__, __LINE__, #x ); \
|
||||
} \
|
||||
} while ( 0 )
|
||||
|
||||
#endif /* _ASSERT_H */
|
318
wimboot/wimboot-2.7.3/src/bootapp.h
Normal file
318
wimboot/wimboot-2.7.3/src/bootapp.h
Normal file
@@ -0,0 +1,318 @@
|
||||
#ifndef _BOOTAPP_H
|
||||
#define _BOOTAPP_H
|
||||
|
||||
/*
|
||||
* Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Boot application data structures
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/** A segment:offset address */
|
||||
struct segoff {
|
||||
/** Offset */
|
||||
uint16_t offset;
|
||||
/** Segment */
|
||||
uint16_t segment;
|
||||
} __attribute__ (( packed ));
|
||||
|
||||
/** A GUID */
|
||||
struct guid {
|
||||
/** 8 hex digits, big-endian */
|
||||
uint32_t a;
|
||||
/** 2 hex digits, big-endian */
|
||||
uint16_t b;
|
||||
/** 2 hex digits, big-endian */
|
||||
uint16_t c;
|
||||
/** 2 hex digits, big-endian */
|
||||
uint16_t d;
|
||||
/** 12 hex digits, big-endian */
|
||||
uint8_t e[6];
|
||||
} __attribute__ (( packed ));
|
||||
|
||||
/** Real-mode callback parameters */
|
||||
struct bootapp_callback_params {
|
||||
/** Vector */
|
||||
union {
|
||||
/** Interrupt number */
|
||||
uint32_t interrupt;
|
||||
/** Segment:offset address of real-mode function */
|
||||
struct segoff function;
|
||||
} vector;
|
||||
/** %eax value */
|
||||
union {
|
||||
struct {
|
||||
uint8_t al;
|
||||
uint8_t ah;
|
||||
} __attribute__ (( packed ));
|
||||
uint16_t ax;
|
||||
uint32_t eax;
|
||||
};
|
||||
/** %ebx value */
|
||||
union {
|
||||
struct {
|
||||
uint8_t bl;
|
||||
uint8_t bh;
|
||||
} __attribute__ (( packed ));
|
||||
uint16_t bx;
|
||||
uint32_t ebx;
|
||||
};
|
||||
/** %ecx value */
|
||||
union {
|
||||
struct {
|
||||
uint8_t cl;
|
||||
uint8_t ch;
|
||||
} __attribute__ (( packed ));
|
||||
uint16_t cx;
|
||||
uint32_t ecx;
|
||||
};
|
||||
/** %edx value */
|
||||
union {
|
||||
struct {
|
||||
uint8_t dl;
|
||||
uint8_t dh;
|
||||
} __attribute__ (( packed ));
|
||||
uint16_t dx;
|
||||
uint32_t edx;
|
||||
};
|
||||
/** Placeholder (for %esp?) */
|
||||
uint32_t unused_esp;
|
||||
/** Placeholder (for %ebp?) */
|
||||
uint32_t unused_ebp;
|
||||
/** %esi value */
|
||||
union {
|
||||
uint16_t si;
|
||||
uint32_t esi;
|
||||
};
|
||||
/** %edi value */
|
||||
union {
|
||||
uint16_t di;
|
||||
uint32_t edi;
|
||||
};
|
||||
/** Placeholder (for %cs?) */
|
||||
uint32_t unused_cs;
|
||||
/** %ds value */
|
||||
uint32_t ds;
|
||||
/** Placeholder (for %ss?) */
|
||||
uint32_t unused_ss;
|
||||
/** %es value */
|
||||
uint32_t es;
|
||||
/** %fs value */
|
||||
uint32_t fs;
|
||||
/** %gs value */
|
||||
uint32_t gs;
|
||||
/** eflags value */
|
||||
uint32_t eflags;
|
||||
} __attribute__ (( packed ));
|
||||
|
||||
/** eflags bits */
|
||||
enum eflags {
|
||||
CF = ( 1 << 0 ),
|
||||
PF = ( 1 << 2 ),
|
||||
AF = ( 1 << 4 ),
|
||||
ZF = ( 1 << 6 ),
|
||||
SF = ( 1 << 7 ),
|
||||
OF = ( 1 << 11 ),
|
||||
};
|
||||
|
||||
/** Real-mode callback function table */
|
||||
struct bootapp_callback_functions {
|
||||
/**
|
||||
* Call an arbitrary real-mode interrupt
|
||||
*
|
||||
* @v params Parameters
|
||||
*/
|
||||
void ( * call_interrupt ) ( struct bootapp_callback_params *params );
|
||||
/**
|
||||
* Call an arbitrary real-mode function
|
||||
*
|
||||
* @v params Parameters
|
||||
*/
|
||||
void ( * call_real ) ( struct bootapp_callback_params *params );
|
||||
} __attribute__ (( packed ));
|
||||
|
||||
/** Real-mode callbacks */
|
||||
struct bootapp_callback {
|
||||
/** Real-mode callback function table */
|
||||
struct bootapp_callback_functions *fns;
|
||||
/** Drive number for INT13 calls */
|
||||
uint32_t drive;
|
||||
} __attribute__ (( packed ));
|
||||
|
||||
/** Boot application descriptor */
|
||||
struct bootapp_descriptor {
|
||||
/** Signature */
|
||||
char signature[8];
|
||||
/** Version */
|
||||
uint32_t version;
|
||||
/** Total length */
|
||||
uint32_t len;
|
||||
/** COFF machine type */
|
||||
uint32_t arch;
|
||||
/** Reserved */
|
||||
uint32_t reserved_0x14;
|
||||
/** Loaded PE image base address */
|
||||
void *pe_base;
|
||||
/** Reserved */
|
||||
uint32_t reserved_0x1c;
|
||||
/** Length of loaded PE image */
|
||||
uint32_t pe_len;
|
||||
/** Offset to memory descriptor */
|
||||
uint32_t memory;
|
||||
/** Offset to boot application entry descriptor */
|
||||
uint32_t entry;
|
||||
/** Offset to ??? */
|
||||
uint32_t xxx;
|
||||
/** Offset to callback descriptor */
|
||||
uint32_t callback;
|
||||
/** Offset to pointless descriptor */
|
||||
uint32_t pointless;
|
||||
/** Reserved */
|
||||
uint32_t reserved_0x38;
|
||||
} __attribute__ (( packed ));
|
||||
|
||||
/** "BOOT APP" magic signature */
|
||||
#define BOOTAPP_SIGNATURE "BOOT APP"
|
||||
|
||||
/** Boot application descriptor version */
|
||||
#define BOOTAPP_VERSION 2
|
||||
|
||||
/** i386 architecture */
|
||||
#define BOOTAPP_ARCH_I386 0x014c
|
||||
|
||||
/** Memory region descriptor */
|
||||
struct bootapp_memory_region {
|
||||
/** Reserved (for struct list_head?) */
|
||||
uint8_t reserved[8];
|
||||
/** Start page address */
|
||||
uint64_t start_page;
|
||||
/** Reserved */
|
||||
uint8_t reserved_0x10[8];
|
||||
/** Number of pages */
|
||||
uint64_t num_pages;
|
||||
/** Reserved */
|
||||
uint8_t reserved_0x20[4];
|
||||
/** Flags */
|
||||
uint32_t flags;
|
||||
} __attribute__ (( packed ));
|
||||
|
||||
/** Memory descriptor */
|
||||
struct bootapp_memory_descriptor {
|
||||
/** Version */
|
||||
uint32_t version;
|
||||
/** Length of descriptor (excluding region descriptors) */
|
||||
uint32_t len;
|
||||
/** Number of regions */
|
||||
uint32_t num_regions;
|
||||
/** Length of each region descriptor */
|
||||
uint32_t region_len;
|
||||
/** Length of reserved area at start of each region descriptor */
|
||||
uint32_t reserved_len;
|
||||
} __attribute__ (( packed ));
|
||||
|
||||
/** Boot application memory descriptor version */
|
||||
#define BOOTAPP_MEMORY_VERSION 1
|
||||
|
||||
/** Boot application entry descriptor */
|
||||
struct bootapp_entry_descriptor {
|
||||
/** Signature */
|
||||
char signature[8];
|
||||
/** Flags */
|
||||
uint32_t flags;
|
||||
/** GUID */
|
||||
struct guid guid;
|
||||
/** Reserved */
|
||||
uint8_t reserved[16];
|
||||
} __attribute__ (( packed ));
|
||||
|
||||
/** ??? */
|
||||
struct bootapp_entry_wtf1_descriptor {
|
||||
/** Flags */
|
||||
uint32_t flags;
|
||||
/** Length of descriptor */
|
||||
uint32_t len;
|
||||
/** Total length of following descriptors within BTAPENT */
|
||||
uint32_t extra_len;
|
||||
/** Reserved */
|
||||
uint8_t reserved[12];
|
||||
} __attribute__ (( packed ));
|
||||
|
||||
/** ??? */
|
||||
struct bootapp_entry_wtf2_descriptor {
|
||||
/** GUID */
|
||||
struct guid guid;
|
||||
} __attribute__ (( packed ));
|
||||
|
||||
/** ??? */
|
||||
struct bootapp_entry_wtf3_descriptor {
|
||||
/** Flags */
|
||||
uint32_t flags;
|
||||
/** Reserved */
|
||||
uint32_t reserved_0x04;
|
||||
/** Length of descriptor */
|
||||
uint32_t len;
|
||||
/** Reserved */
|
||||
uint32_t reserved_0x0c;
|
||||
/** Boot partition offset (in bytes) */
|
||||
uint32_t boot_partition_offset;
|
||||
/** Reserved */
|
||||
uint8_t reserved_0x14[16];
|
||||
/** MBR signature present? */
|
||||
uint32_t xxx;
|
||||
/** MBR signature */
|
||||
uint32_t mbr_signature;
|
||||
/** Reserved */
|
||||
uint8_t reserved_0x2c[26];
|
||||
} __attribute__ (( packed ));
|
||||
|
||||
/** "BTAPENT" magic signature */
|
||||
#define BOOTAPP_ENTRY_SIGNATURE "BTAPENT\0"
|
||||
|
||||
/** Boot application entry flags
|
||||
*
|
||||
* pxeboot, etftboot, and fatboot all use a value of 0x21; I have no
|
||||
* idea what it means.
|
||||
*/
|
||||
#define BOOTAPP_ENTRY_FLAGS 0x21
|
||||
|
||||
/** Boot application callback descriptor */
|
||||
struct bootapp_callback_descriptor {
|
||||
/** Real-mode callbacks */
|
||||
struct bootapp_callback *callback;
|
||||
/** Reserved */
|
||||
uint32_t reserved;
|
||||
} __attribute__ (( packed ));
|
||||
|
||||
/** Boot application pointless descriptor */
|
||||
struct bootapp_pointless_descriptor {
|
||||
/** Version */
|
||||
uint32_t version;
|
||||
/** Reserved */
|
||||
uint8_t reserved[24];
|
||||
} __attribute__ (( packed ));
|
||||
|
||||
/** Boot application pointless descriptor version */
|
||||
#define BOOTAPP_POINTLESS_VERSION 1
|
||||
|
||||
#endif /* _BOOTAPP_H */
|
183
wimboot/wimboot-2.7.3/src/byteswap.h
Normal file
183
wimboot/wimboot-2.7.3/src/byteswap.h
Normal file
@@ -0,0 +1,183 @@
|
||||
#ifndef _BITS_BYTESWAP_H
|
||||
#define _BITS_BYTESWAP_H
|
||||
|
||||
/** @file
|
||||
*
|
||||
* Byte-order swapping functions
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
static inline __attribute__ (( always_inline, const )) uint16_t
|
||||
__bswap_variable_16 ( uint16_t x ) {
|
||||
__asm__ ( "xchgb %b0,%h0" : "=Q" ( x ) : "0" ( x ) );
|
||||
return x;
|
||||
}
|
||||
|
||||
static inline __attribute__ (( always_inline )) void
|
||||
__bswap_16s ( uint16_t *x ) {
|
||||
__asm__ ( "rorw $8, %0" : "+m" ( *x ) );
|
||||
}
|
||||
|
||||
static inline __attribute__ (( always_inline, const )) uint32_t
|
||||
__bswap_variable_32 ( uint32_t x ) {
|
||||
__asm__ ( "bswapl %k0" : "=r" ( x ) : "0" ( x ) );
|
||||
return x;
|
||||
}
|
||||
|
||||
static inline __attribute__ (( always_inline )) void
|
||||
__bswap_32s ( uint32_t *x ) {
|
||||
__asm__ ( "bswapl %k0" : "=r" ( *x ) : "0" ( *x ) );
|
||||
}
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
static inline __attribute__ (( always_inline, const )) uint64_t
|
||||
__bswap_variable_64 ( uint64_t x ) {
|
||||
__asm__ ( "bswapq %q0" : "=r" ( x ) : "0" ( x ) );
|
||||
return x;
|
||||
}
|
||||
|
||||
#else /* __x86_64__ */
|
||||
|
||||
static inline __attribute__ (( always_inline, const )) uint64_t
|
||||
__bswap_variable_64 ( uint64_t x ) {
|
||||
uint32_t in_high = ( x >> 32 );
|
||||
uint32_t in_low = ( x & 0xffffffffUL );
|
||||
uint32_t out_high;
|
||||
uint32_t out_low;
|
||||
|
||||
__asm__ ( "bswapl %0\n\t"
|
||||
"bswapl %1\n\t"
|
||||
"xchgl %0,%1\n\t"
|
||||
: "=r" ( out_high ), "=r" ( out_low )
|
||||
: "0" ( in_high ), "1" ( in_low ) );
|
||||
|
||||
return ( ( ( ( uint64_t ) out_high ) << 32 ) |
|
||||
( ( uint64_t ) out_low ) );
|
||||
}
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
|
||||
static inline __attribute__ (( always_inline )) void
|
||||
__bswap_64s ( uint64_t *x ) {
|
||||
*x = __bswap_variable_64 ( *x );
|
||||
}
|
||||
|
||||
/**
|
||||
* Byte-swap a 16-bit constant
|
||||
*
|
||||
* @v value Constant value
|
||||
* @ret swapped Byte-swapped value
|
||||
*/
|
||||
#define __bswap_constant_16( value ) \
|
||||
( ( ( (value) & 0x00ff ) << 8 ) | \
|
||||
( ( (value) & 0xff00 ) >> 8 ) )
|
||||
|
||||
/**
|
||||
* Byte-swap a 32-bit constant
|
||||
*
|
||||
* @v value Constant value
|
||||
* @ret swapped Byte-swapped value
|
||||
*/
|
||||
#define __bswap_constant_32( value ) \
|
||||
( ( ( (value) & 0x000000ffUL ) << 24 ) | \
|
||||
( ( (value) & 0x0000ff00UL ) << 8 ) | \
|
||||
( ( (value) & 0x00ff0000UL ) >> 8 ) | \
|
||||
( ( (value) & 0xff000000UL ) >> 24 ) )
|
||||
|
||||
/**
|
||||
* Byte-swap a 64-bit constant
|
||||
*
|
||||
* @v value Constant value
|
||||
* @ret swapped Byte-swapped value
|
||||
*/
|
||||
#define __bswap_constant_64( value ) \
|
||||
( ( ( (value) & 0x00000000000000ffULL ) << 56 ) | \
|
||||
( ( (value) & 0x000000000000ff00ULL ) << 40 ) | \
|
||||
( ( (value) & 0x0000000000ff0000ULL ) << 24 ) | \
|
||||
( ( (value) & 0x00000000ff000000ULL ) << 8 ) | \
|
||||
( ( (value) & 0x000000ff00000000ULL ) >> 8 ) | \
|
||||
( ( (value) & 0x0000ff0000000000ULL ) >> 24 ) | \
|
||||
( ( (value) & 0x00ff000000000000ULL ) >> 40 ) | \
|
||||
( ( (value) & 0xff00000000000000ULL ) >> 56 ) )
|
||||
|
||||
/**
|
||||
* Byte-swap a 16-bit value
|
||||
*
|
||||
* @v value Value
|
||||
* @ret swapped Byte-swapped value
|
||||
*/
|
||||
#define __bswap_16( value ) \
|
||||
( __builtin_constant_p (value) ? \
|
||||
( ( uint16_t ) __bswap_constant_16 ( ( uint16_t ) (value) ) ) \
|
||||
: __bswap_variable_16 (value) )
|
||||
#define bswap_16( value ) __bswap_16 (value)
|
||||
|
||||
/**
|
||||
* Byte-swap a 32-bit value
|
||||
*
|
||||
* @v value Value
|
||||
* @ret swapped Byte-swapped value
|
||||
*/
|
||||
#define __bswap_32( value ) \
|
||||
( __builtin_constant_p (value) ? \
|
||||
( ( uint32_t ) __bswap_constant_32 ( ( uint32_t ) (value) ) ) \
|
||||
: __bswap_variable_32 (value) )
|
||||
#define bswap_32( value ) __bswap_32 (value)
|
||||
|
||||
/**
|
||||
* Byte-swap a 64-bit value
|
||||
*
|
||||
* @v value Value
|
||||
* @ret swapped Byte-swapped value
|
||||
*/
|
||||
#define __bswap_64( value ) \
|
||||
( __builtin_constant_p (value) ? \
|
||||
( ( uint64_t ) __bswap_constant_64 ( ( uint64_t ) (value) ) ) \
|
||||
: __bswap_variable_64 (value) )
|
||||
#define bswap_64( value ) __bswap_64 (value)
|
||||
|
||||
#define __cpu_to_leNN( bits, value ) (value)
|
||||
#define __cpu_to_beNN( bits, value ) __bswap_ ## bits (value)
|
||||
#define __leNN_to_cpu( bits, value ) (value)
|
||||
#define __beNN_to_cpu( bits, value ) __bswap_ ## bits (value)
|
||||
#define __cpu_to_leNNs( bits, ptr ) do { } while ( 0 )
|
||||
#define __cpu_to_beNNs( bits, ptr ) __bswap_ ## bits ## s (ptr)
|
||||
#define __leNN_to_cpus( bits, ptr ) do { } while ( 0 )
|
||||
#define __beNN_to_cpus( bits, ptr ) __bswap_ ## bits ## s (ptr)
|
||||
|
||||
#define cpu_to_le16( value ) __cpu_to_leNN ( 16, value )
|
||||
#define cpu_to_le32( value ) __cpu_to_leNN ( 32, value )
|
||||
#define cpu_to_le64( value ) __cpu_to_leNN ( 64, value )
|
||||
#define cpu_to_be16( value ) __cpu_to_beNN ( 16, value )
|
||||
#define cpu_to_be32( value ) __cpu_to_beNN ( 32, value )
|
||||
#define cpu_to_be64( value ) __cpu_to_beNN ( 64, value )
|
||||
#define le16_to_cpu( value ) __leNN_to_cpu ( 16, value )
|
||||
#define le32_to_cpu( value ) __leNN_to_cpu ( 32, value )
|
||||
#define le64_to_cpu( value ) __leNN_to_cpu ( 64, value )
|
||||
#define be16_to_cpu( value ) __beNN_to_cpu ( 16, value )
|
||||
#define be32_to_cpu( value ) __beNN_to_cpu ( 32, value )
|
||||
#define be64_to_cpu( value ) __beNN_to_cpu ( 64, value )
|
||||
#define cpu_to_le16s( ptr ) __cpu_to_leNNs ( 16, ptr )
|
||||
#define cpu_to_le32s( ptr ) __cpu_to_leNNs ( 32, ptr )
|
||||
#define cpu_to_le64s( ptr ) __cpu_to_leNNs ( 64, ptr )
|
||||
#define cpu_to_be16s( ptr ) __cpu_to_beNNs ( 16, ptr )
|
||||
#define cpu_to_be32s( ptr ) __cpu_to_beNNs ( 32, ptr )
|
||||
#define cpu_to_be64s( ptr ) __cpu_to_beNNs ( 64, ptr )
|
||||
#define le16_to_cpus( ptr ) __leNN_to_cpus ( 16, ptr )
|
||||
#define le32_to_cpus( ptr ) __leNN_to_cpus ( 32, ptr )
|
||||
#define le64_to_cpus( ptr ) __leNN_to_cpus ( 64, ptr )
|
||||
#define be16_to_cpus( ptr ) __beNN_to_cpus ( 16, ptr )
|
||||
#define be32_to_cpus( ptr ) __beNN_to_cpus ( 32, ptr )
|
||||
#define be64_to_cpus( ptr ) __beNN_to_cpus ( 64, ptr )
|
||||
|
||||
#define htonll( value ) cpu_to_be64 (value)
|
||||
#define ntohll( value ) be64_to_cpu (value)
|
||||
#define htonl( value ) cpu_to_be32 (value)
|
||||
#define ntohl( value ) be32_to_cpu (value)
|
||||
#define htons( value ) cpu_to_be16 (value)
|
||||
#define ntohs( value ) be16_to_cpu (value)
|
||||
|
||||
#endif /* _BITS_BYTESWAP_H */
|
151
wimboot/wimboot-2.7.3/src/cmdline.c
Normal file
151
wimboot/wimboot-2.7.3/src/cmdline.c
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Command line
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "wimboot.h"
|
||||
#include "cmdline.h"
|
||||
|
||||
/** Use raw (unpatched) BCD files */
|
||||
int cmdline_rawbcd;
|
||||
|
||||
/** Use raw (unpatched) WIM files */
|
||||
int cmdline_rawwim;
|
||||
|
||||
/** Inhibit debugging output */
|
||||
int cmdline_quiet;
|
||||
|
||||
/** Allow graphical output from bootmgr/bootmgfw */
|
||||
int cmdline_gui;
|
||||
|
||||
/** Pause before booting OS */
|
||||
int cmdline_pause;
|
||||
|
||||
/** Pause without displaying any prompt */
|
||||
int cmdline_pause_quiet;
|
||||
|
||||
/** Use linear (unpaged) memory model */
|
||||
int cmdline_linear;
|
||||
|
||||
/** WIM boot index */
|
||||
unsigned int cmdline_index;
|
||||
|
||||
int cmdline_vf_num;
|
||||
char cmdline_vf_path[MAX_VF][64];
|
||||
|
||||
file_size_pf pfventoy_file_size;
|
||||
file_read_pf pfventoy_file_read;
|
||||
|
||||
/**
|
||||
* Process command line
|
||||
*
|
||||
* @v cmdline Command line
|
||||
*/
|
||||
void process_cmdline ( char *cmdline ) {
|
||||
char *tmp = cmdline;
|
||||
char *key;
|
||||
char *value;
|
||||
char *endp;
|
||||
|
||||
/* Do nothing if we have no command line */
|
||||
if ( ( cmdline == NULL ) || ( cmdline[0] == '\0' ) )
|
||||
return;
|
||||
|
||||
/* Parse command line */
|
||||
while ( *tmp ) {
|
||||
|
||||
/* Skip whitespace */
|
||||
while ( isspace ( *tmp ) )
|
||||
tmp++;
|
||||
|
||||
/* Find value (if any) and end of this argument */
|
||||
key = tmp;
|
||||
value = NULL;
|
||||
while ( *tmp ) {
|
||||
if ( isspace ( *tmp ) ) {
|
||||
*(tmp++) = '\0';
|
||||
break;
|
||||
} else if ( *tmp == '=' ) {
|
||||
*(tmp++) = '\0';
|
||||
value = tmp;
|
||||
} else {
|
||||
tmp++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Process this argument */
|
||||
if ( strcmp ( key, "rawbcd" ) == 0 ) {
|
||||
cmdline_rawbcd = 1;
|
||||
} else if ( strcmp ( key, "rawwim" ) == 0 ) {
|
||||
cmdline_rawwim = 1;
|
||||
} else if ( strcmp ( key, "gui" ) == 0 ) {
|
||||
cmdline_gui = 1;
|
||||
}
|
||||
|
||||
else if ((key[0] == 'v') && (key[1] == 'f') ) {
|
||||
if (cmdline_vf_num >= MAX_VF)
|
||||
die("Too many vf\n");
|
||||
snprintf(cmdline_vf_path[cmdline_vf_num], 64, "%s", value);
|
||||
cmdline_vf_num++;
|
||||
}else if ( strcmp ( key, "pfsize" ) == 0 ) {
|
||||
pfventoy_file_size = (file_size_pf)strtoul(value, &endp, 0);
|
||||
} else if ( strcmp ( key, "pfread" ) == 0 ) {
|
||||
pfventoy_file_read = (file_read_pf)strtoul(value, &endp, 0 );
|
||||
}
|
||||
|
||||
else if ( strcmp ( key, "linear" ) == 0 ) {
|
||||
cmdline_linear = 1;
|
||||
} else if ( strcmp ( key, "quiet" ) == 0 ) {
|
||||
cmdline_quiet = 1;
|
||||
} else if ( strcmp ( key, "pause" ) == 0 ) {
|
||||
cmdline_pause = 1;
|
||||
if ( value && ( strcmp ( value, "quiet" ) == 0 ) )
|
||||
cmdline_pause_quiet = 1;
|
||||
} else if ( strcmp ( key, "index" ) == 0 ) {
|
||||
if ( ( ! value ) || ( ! value[0] ) )
|
||||
die ( "Argument \"index\" needs a value\n" );
|
||||
cmdline_index = strtoul ( value, &endp, 0 );
|
||||
if ( *endp )
|
||||
die ( "Invalid index \"%s\"\n", value );
|
||||
} else if ( strcmp ( key, "initrdfile" ) == 0 ) {
|
||||
/* Ignore this keyword to allow for use with syslinux */
|
||||
} else if ( key == cmdline ) {
|
||||
/* Ignore unknown initial arguments, which may
|
||||
* be the program name.
|
||||
*/
|
||||
} else {
|
||||
die ( "Unrecognised argument \"%s%s%s\"\n", key,
|
||||
( value ? "=" : "" ), ( value ? value : "" ) );
|
||||
}
|
||||
}
|
||||
|
||||
/* Show command line (after parsing "quiet" option) */
|
||||
DBG ( "Command line: \"%s\" vf=%d pfsize=%p pfread=%p\n",
|
||||
cmdline, cmdline_vf_num, pfventoy_file_size, pfventoy_file_read);
|
||||
}
|
48
wimboot/wimboot-2.7.3/src/cmdline.h
Normal file
48
wimboot/wimboot-2.7.3/src/cmdline.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef _CMDLINE_H
|
||||
#define _CMDLINE_H
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Command line
|
||||
*
|
||||
*/
|
||||
|
||||
extern int cmdline_rawbcd;
|
||||
extern int cmdline_rawwim;
|
||||
extern int cmdline_quiet;
|
||||
extern int cmdline_gui;
|
||||
extern int cmdline_pause;
|
||||
extern int cmdline_pause_quiet;
|
||||
extern int cmdline_linear;
|
||||
extern unsigned int cmdline_index;
|
||||
extern void process_cmdline ( char *cmdline );
|
||||
|
||||
typedef int (*file_size_pf)(const char *path);
|
||||
typedef int (*file_read_pf)(const char *path, int offset, int len, void *buf);
|
||||
extern file_size_pf pfventoy_file_size;
|
||||
extern file_read_pf pfventoy_file_read;
|
||||
#define MAX_VF 16
|
||||
extern char cmdline_vf_path[MAX_VF][64];
|
||||
extern int cmdline_vf_num;
|
||||
|
||||
#endif /* _CMDLINE_H */
|
43
wimboot/wimboot-2.7.3/src/compiler.h
Normal file
43
wimboot/wimboot-2.7.3/src/compiler.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef _COMPILER_H
|
||||
#define _COMPILER_H
|
||||
|
||||
/*
|
||||
* Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Global compiler definitions
|
||||
*
|
||||
*/
|
||||
|
||||
/* Force visibility of all symbols to "hidden", i.e. inform gcc that
|
||||
* all symbol references resolve strictly within our final binary.
|
||||
* This avoids unnecessary PLT/GOT entries on x86_64.
|
||||
*
|
||||
* This is a stronger claim than specifying "-fvisibility=hidden",
|
||||
* since it also affects symbols marked with "extern".
|
||||
*/
|
||||
#ifndef ASSEMBLY
|
||||
#if __GNUC__ >= 4
|
||||
#pragma GCC visibility push(hidden)
|
||||
#endif
|
||||
#endif /* ASSEMBLY */
|
||||
|
||||
#endif /* _COMPILER_H */
|
92
wimboot/wimboot-2.7.3/src/cookie.c
Normal file
92
wimboot/wimboot-2.7.3/src/cookie.c
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Stack cookie
|
||||
*
|
||||
*/
|
||||
|
||||
#include "wimboot.h"
|
||||
|
||||
/** Stack cookie */
|
||||
unsigned long __stack_chk_guard;
|
||||
|
||||
/**
|
||||
* Construct stack cookie value
|
||||
*
|
||||
*/
|
||||
static __attribute__ (( noinline )) unsigned long make_cookie ( void ) {
|
||||
union {
|
||||
struct {
|
||||
uint32_t eax;
|
||||
uint32_t edx;
|
||||
} __attribute__ (( packed ));
|
||||
unsigned long tsc;
|
||||
} u;
|
||||
unsigned long cookie;
|
||||
|
||||
/* We have no viable source of entropy. Use the CPU timestamp
|
||||
* counter, which will have at least some minimal randomness
|
||||
* in the low bits by the time we are invoked.
|
||||
*/
|
||||
__asm__ ( "rdtsc" : "=a" ( u.eax ), "=d" ( u.edx ) );
|
||||
cookie = u.tsc;
|
||||
|
||||
/* Ensure that the value contains a NUL byte, to act as a
|
||||
* runaway string terminator. Construct the NUL using a shift
|
||||
* rather than a mask, to avoid losing valuable entropy in the
|
||||
* lower-order bits.
|
||||
*/
|
||||
cookie <<= 8;
|
||||
|
||||
return cookie;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise stack cookie
|
||||
*
|
||||
* This function must not itself use stack guard
|
||||
*/
|
||||
void init_cookie ( void ) {
|
||||
|
||||
/* Set stack cookie value
|
||||
*
|
||||
* This function must not itself use stack protection, since
|
||||
* the change in the stack guard value would trigger a false
|
||||
* positive.
|
||||
*
|
||||
* There is unfortunately no way to annotate a function to
|
||||
* exclude the use of stack protection. We must therefore
|
||||
* rely on correctly anticipating the compiler's decision on
|
||||
* the use of stack protection.
|
||||
*/
|
||||
__stack_chk_guard = make_cookie();
|
||||
}
|
||||
|
||||
/**
|
||||
* Abort on stack check failure
|
||||
*
|
||||
*/
|
||||
void __stack_chk_fail ( void ) {
|
||||
|
||||
/* Abort program */
|
||||
die ( "Stack check failed\n" );
|
||||
}
|
15
wimboot/wimboot-2.7.3/src/coverity-model.c
Normal file
15
wimboot/wimboot-2.7.3/src/coverity-model.c
Normal file
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Coverity modelling file
|
||||
*
|
||||
*/
|
||||
|
||||
typedef unsigned short wchar_t;
|
||||
typedef void mbstate_t;
|
||||
|
||||
/* Inhibit use of built-in models for functions where Coverity's
|
||||
* assumptions about the modelled function are incorrect for wimboot.
|
||||
*/
|
||||
int getchar ( void ) {
|
||||
}
|
||||
size_t wcrtomb ( char *buf, wchar_t wc, mbstate_t *ps ) {
|
||||
}
|
134
wimboot/wimboot-2.7.3/src/cpio.c
Normal file
134
wimboot/wimboot-2.7.3/src/cpio.c
Normal file
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* CPIO archives
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "wimboot.h"
|
||||
#include "cpio.h"
|
||||
|
||||
/**
|
||||
* Align CPIO length to nearest dword
|
||||
*
|
||||
* @v len Length
|
||||
* @ret len Aligned length
|
||||
*/
|
||||
static size_t cpio_align ( size_t len ) {
|
||||
return ( ( len + 0x03 ) & ~0x03 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse CPIO field value
|
||||
*
|
||||
* @v field ASCII field
|
||||
* @ret value Field value
|
||||
*/
|
||||
static unsigned long cpio_value ( const char *field ) {
|
||||
char buf[9];
|
||||
|
||||
memcpy ( buf, field, ( sizeof ( buf ) - 1 ) );
|
||||
buf[ sizeof ( buf ) - 1 ] = '\0';
|
||||
return strtoul ( buf, NULL, 16 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract files from CPIO archive
|
||||
*
|
||||
* @v data CPIO archive
|
||||
* @v len Maximum length of CPIO archive
|
||||
* @v file File handler
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int cpio_extract ( void *data, size_t len,
|
||||
int ( * file ) ( const char *name, void *data,
|
||||
size_t len ) ) {
|
||||
const struct cpio_header *cpio;
|
||||
const uint32_t *pad;
|
||||
const char *file_name;
|
||||
void *file_data;
|
||||
size_t file_name_len;
|
||||
size_t file_len;
|
||||
size_t cpio_len;
|
||||
int rc;
|
||||
|
||||
while ( 1 ) {
|
||||
|
||||
/* Skip over any padding */
|
||||
while ( len >= sizeof ( *pad ) ) {
|
||||
pad = data;
|
||||
if ( *pad )
|
||||
break;
|
||||
data += sizeof ( *pad );
|
||||
len -= sizeof ( *pad );
|
||||
}
|
||||
|
||||
/* Stop if we have reached the end of the archive */
|
||||
if ( ! len )
|
||||
return 0;
|
||||
|
||||
/* Sanity check */
|
||||
if ( len < sizeof ( *cpio ) ) {
|
||||
DBG ( "Truncated CPIO header\n" );
|
||||
return -1;
|
||||
}
|
||||
cpio = data;
|
||||
|
||||
/* Check magic */
|
||||
if ( memcmp ( cpio->c_magic, CPIO_MAGIC,
|
||||
sizeof ( cpio->c_magic ) ) != 0 ) {
|
||||
DBG ( "Bad CPIO magic\n" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Extract file parameters */
|
||||
file_name = ( ( void * ) ( cpio + 1 ) );
|
||||
file_name_len = cpio_value ( cpio->c_namesize );
|
||||
file_data = ( data + cpio_align ( sizeof ( *cpio ) +
|
||||
file_name_len ) );
|
||||
file_len = cpio_value ( cpio->c_filesize );
|
||||
cpio_len = ( file_data + file_len - data );
|
||||
if ( cpio_len < len )
|
||||
cpio_len = cpio_align ( cpio_len );
|
||||
if ( cpio_len > len ) {
|
||||
DBG ( "Truncated CPIO file\n" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* If we reach the trailer, we're done */
|
||||
if ( strcmp ( file_name, CPIO_TRAILER ) == 0 )
|
||||
return 0;
|
||||
|
||||
/* Process file */
|
||||
if ( ( rc = file ( file_name, file_data, file_len ) ) != 0 )
|
||||
return rc;
|
||||
|
||||
/* Move to next file */
|
||||
data += cpio_len;
|
||||
len -= cpio_len;
|
||||
}
|
||||
}
|
78
wimboot/wimboot-2.7.3/src/cpio.h
Normal file
78
wimboot/wimboot-2.7.3/src/cpio.h
Normal file
@@ -0,0 +1,78 @@
|
||||
#ifndef _CPIO_H
|
||||
#define _CPIO_H
|
||||
|
||||
/*
|
||||
* Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* CPIO archives
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/** A CPIO archive header
|
||||
*
|
||||
* All field are hexadecimal ASCII numbers padded with '0' on the
|
||||
* left to the full width of the field.
|
||||
*/
|
||||
struct cpio_header {
|
||||
/** The string "070701" or "070702" */
|
||||
char c_magic[6];
|
||||
/** File inode number */
|
||||
char c_ino[8];
|
||||
/** File mode and permissions */
|
||||
char c_mode[8];
|
||||
/** File uid */
|
||||
char c_uid[8];
|
||||
/** File gid */
|
||||
char c_gid[8];
|
||||
/** Number of links */
|
||||
char c_nlink[8];
|
||||
/** Modification time */
|
||||
char c_mtime[8];
|
||||
/** Size of data field */
|
||||
char c_filesize[8];
|
||||
/** Major part of file device number */
|
||||
char c_maj[8];
|
||||
/** Minor part of file device number */
|
||||
char c_min[8];
|
||||
/** Major part of device node reference */
|
||||
char c_rmaj[8];
|
||||
/** Minor part of device node reference */
|
||||
char c_rmin[8];
|
||||
/** Length of filename, including final NUL */
|
||||
char c_namesize[8];
|
||||
/** Checksum of data field if c_magic is 070702, othersize zero */
|
||||
char c_chksum[8];
|
||||
} __attribute__ (( packed ));
|
||||
|
||||
/** CPIO magic */
|
||||
#define CPIO_MAGIC "070701"
|
||||
|
||||
/** CPIO trailer */
|
||||
#define CPIO_TRAILER "TRAILER!!!"
|
||||
|
||||
extern int cpio_extract ( void *data, size_t len,
|
||||
int ( * file ) ( const char *name, void *data,
|
||||
size_t len ) );
|
||||
|
||||
#endif /* _CPIO_H */
|
47
wimboot/wimboot-2.7.3/src/ctype.h
Normal file
47
wimboot/wimboot-2.7.3/src/ctype.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef _CTYPE_H
|
||||
#define _CTYPE_H
|
||||
|
||||
/*
|
||||
* Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Character types
|
||||
*
|
||||
*/
|
||||
|
||||
static inline int islower ( int c ) {
|
||||
return ( ( c >= 'a' ) && ( c <= 'z' ) );
|
||||
}
|
||||
|
||||
static inline int isupper ( int c ) {
|
||||
return ( ( c >= 'A' ) && ( c <= 'Z' ) );
|
||||
}
|
||||
|
||||
static inline int toupper ( int c ) {
|
||||
|
||||
if ( islower ( c ) )
|
||||
c -= ( 'a' - 'A' );
|
||||
return c;
|
||||
}
|
||||
|
||||
extern int isspace ( int c );
|
||||
|
||||
#endif /* _CTYPE_H */
|
72
wimboot/wimboot-2.7.3/src/die.c
Normal file
72
wimboot/wimboot-2.7.3/src/die.c
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Fatal errors
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include "wimboot.h"
|
||||
#include "efi.h"
|
||||
|
||||
/**
|
||||
* Handle fatal errors
|
||||
*
|
||||
* @v fmt Error message format string
|
||||
* @v ... Arguments
|
||||
*/
|
||||
void die ( const char *fmt, ... ) {
|
||||
EFI_BOOT_SERVICES *bs;
|
||||
EFI_RUNTIME_SERVICES *rs;
|
||||
va_list args;
|
||||
|
||||
/* Print message */
|
||||
va_start ( args, fmt );
|
||||
vprintf ( fmt, args );
|
||||
va_end ( args );
|
||||
|
||||
/* Reboot or exit as applicable */
|
||||
if ( efi_systab ) {
|
||||
|
||||
/* Exit */
|
||||
bs = efi_systab->BootServices;
|
||||
bs->Exit ( efi_image_handle, EFI_LOAD_ERROR, 0, NULL );
|
||||
printf ( "Failed to exit\n" );
|
||||
rs = efi_systab->RuntimeServices;
|
||||
rs->ResetSystem ( EfiResetWarm, 0, 0, NULL );
|
||||
printf ( "Failed to reboot\n" );
|
||||
|
||||
} else {
|
||||
|
||||
/* Wait for keypress */
|
||||
printf ( "Press a key to reboot..." );
|
||||
getchar();
|
||||
printf ( "\n" );
|
||||
|
||||
/* Reboot system */
|
||||
reboot();
|
||||
}
|
||||
|
||||
/* Should be impossible to reach this */
|
||||
__builtin_unreachable();
|
||||
}
|
34
wimboot/wimboot-2.7.3/src/efi.c
Normal file
34
wimboot/wimboot-2.7.3/src/efi.c
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* EFI interface
|
||||
*
|
||||
*/
|
||||
|
||||
#include "wimboot.h"
|
||||
#include "efi.h"
|
||||
|
||||
/** EFI system table */
|
||||
EFI_SYSTEM_TABLE *efi_systab;
|
||||
|
||||
/** EFI image handle */
|
||||
EFI_HANDLE efi_image_handle;
|
52
wimboot/wimboot-2.7.3/src/efi.h
Normal file
52
wimboot/wimboot-2.7.3/src/efi.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#ifndef _EFI_H
|
||||
#define _EFI_H
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* EFI definitions
|
||||
*
|
||||
*/
|
||||
|
||||
/* EFIAPI definition */
|
||||
#if __x86_64__
|
||||
#define EFIAPI __attribute__ (( ms_abi ))
|
||||
#else
|
||||
#define EFIAPI
|
||||
#endif
|
||||
|
||||
/* EFI headers rudely redefine NULL */
|
||||
#undef NULL
|
||||
|
||||
#include "efi/Uefi.h"
|
||||
#include "efi/Protocol/LoadedImage.h"
|
||||
|
||||
extern EFI_SYSTEM_TABLE *efi_systab;
|
||||
extern EFI_HANDLE efi_image_handle;
|
||||
|
||||
extern EFI_GUID efi_block_io_protocol_guid;
|
||||
extern EFI_GUID efi_device_path_protocol_guid;
|
||||
extern EFI_GUID efi_graphics_output_protocol_guid;
|
||||
extern EFI_GUID efi_loaded_image_protocol_guid;
|
||||
extern EFI_GUID efi_simple_file_system_protocol_guid;
|
||||
|
||||
#endif /* _EFI_H */
|
1021
wimboot/wimboot-2.7.3/src/efi/Base.h
Normal file
1021
wimboot/wimboot-2.7.3/src/efi/Base.h
Normal file
File diff suppressed because it is too large
Load Diff
71
wimboot/wimboot-2.7.3/src/efi/Guid/FileInfo.h
Normal file
71
wimboot/wimboot-2.7.3/src/efi/Guid/FileInfo.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/** @file
|
||||
Provides a GUID and a data structure that can be used with EFI_FILE_PROTOCOL.SetInfo()
|
||||
and EFI_FILE_PROTOCOL.GetInfo() to set or get generic file information.
|
||||
This GUID is defined in UEFI specification.
|
||||
|
||||
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials are licensed and made available under
|
||||
the terms and conditions of the BSD License that accompanies this distribution.
|
||||
The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php.
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __FILE_INFO_H__
|
||||
#define __FILE_INFO_H__
|
||||
|
||||
#define EFI_FILE_INFO_ID \
|
||||
{ \
|
||||
0x9576e92, 0x6d3f, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
///
|
||||
/// The size of the EFI_FILE_INFO structure, including the Null-terminated FileName string.
|
||||
///
|
||||
UINT64 Size;
|
||||
///
|
||||
/// The size of the file in bytes.
|
||||
///
|
||||
UINT64 FileSize;
|
||||
///
|
||||
/// PhysicalSize The amount of physical space the file consumes on the file system volume.
|
||||
///
|
||||
UINT64 PhysicalSize;
|
||||
///
|
||||
/// The time the file was created.
|
||||
///
|
||||
EFI_TIME CreateTime;
|
||||
///
|
||||
/// The time when the file was last accessed.
|
||||
///
|
||||
EFI_TIME LastAccessTime;
|
||||
///
|
||||
/// The time when the file's contents were last modified.
|
||||
///
|
||||
EFI_TIME ModificationTime;
|
||||
///
|
||||
/// The attribute bits for the file.
|
||||
///
|
||||
UINT64 Attribute;
|
||||
///
|
||||
/// The Null-terminated name of the file.
|
||||
///
|
||||
CHAR16 FileName[1];
|
||||
} EFI_FILE_INFO;
|
||||
|
||||
///
|
||||
/// The FileName field of the EFI_FILE_INFO data structure is variable length.
|
||||
/// Whenever code needs to know the size of the EFI_FILE_INFO data structure, it needs to
|
||||
/// be the size of the data structure without the FileName field. The following macro
|
||||
/// computes this size correctly no matter how big the FileName array is declared.
|
||||
/// This is required to make the EFI_FILE_INFO data structure ANSI compilant.
|
||||
///
|
||||
#define SIZE_OF_EFI_FILE_INFO OFFSET_OF (EFI_FILE_INFO, FileName)
|
||||
|
||||
extern EFI_GUID gEfiFileInfoGuid;
|
||||
|
||||
#endif
|
25
wimboot/wimboot-2.7.3/src/efi/Guid/HiiFormMapMethodGuid.h
Normal file
25
wimboot/wimboot-2.7.3/src/efi/Guid/HiiFormMapMethodGuid.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/** @file
|
||||
Guid used to identify HII FormMap configuration method.
|
||||
|
||||
Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
@par Revision Reference:
|
||||
GUID defined in UEFI 2.2 spec.
|
||||
**/
|
||||
|
||||
#ifndef __EFI_HII_FORMMAP_GUID_H__
|
||||
#define __EFI_HII_FORMMAP_GUID_H__
|
||||
|
||||
#define EFI_HII_STANDARD_FORM_GUID \
|
||||
{ 0x3bd2f4ec, 0xe524, 0x46e4, { 0xa9, 0xd8, 0x51, 0x1, 0x17, 0x42, 0x55, 0x62 } }
|
||||
|
||||
extern EFI_GUID gEfiHiiStandardFormGuid;
|
||||
|
||||
#endif
|
58
wimboot/wimboot-2.7.3/src/efi/Guid/PcAnsi.h
Normal file
58
wimboot/wimboot-2.7.3/src/efi/Guid/PcAnsi.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/** @file
|
||||
Terminal Device Path Vendor Guid.
|
||||
|
||||
Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
@par Revision Reference:
|
||||
GUIDs defined in UEFI 2.0 spec.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __PC_ANSI_H__
|
||||
#define __PC_ANSI_H__
|
||||
|
||||
#define EFI_PC_ANSI_GUID \
|
||||
{ \
|
||||
0xe0c14753, 0xf9be, 0x11d2, {0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
|
||||
}
|
||||
|
||||
#define EFI_VT_100_GUID \
|
||||
{ \
|
||||
0xdfa66065, 0xb419, 0x11d3, {0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
|
||||
}
|
||||
|
||||
#define EFI_VT_100_PLUS_GUID \
|
||||
{ \
|
||||
0x7baec70b, 0x57e0, 0x4c76, {0x8e, 0x87, 0x2f, 0x9e, 0x28, 0x08, 0x83, 0x43 } \
|
||||
}
|
||||
|
||||
#define EFI_VT_UTF8_GUID \
|
||||
{ \
|
||||
0xad15a0d6, 0x8bec, 0x4acf, {0xa0, 0x73, 0xd0, 0x1d, 0xe7, 0x7e, 0x2d, 0x88 } \
|
||||
}
|
||||
|
||||
#define DEVICE_PATH_MESSAGING_UART_FLOW_CONTROL \
|
||||
{ \
|
||||
0x37499a9d, 0x542f, 0x4c89, {0xa0, 0x26, 0x35, 0xda, 0x14, 0x20, 0x94, 0xe4 } \
|
||||
}
|
||||
|
||||
#define EFI_SAS_DEVICE_PATH_GUID \
|
||||
{ \
|
||||
0xd487ddb4, 0x008b, 0x11d9, {0xaf, 0xdc, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d } \
|
||||
}
|
||||
|
||||
extern EFI_GUID gEfiPcAnsiGuid;
|
||||
extern EFI_GUID gEfiVT100Guid;
|
||||
extern EFI_GUID gEfiVT100PlusGuid;
|
||||
extern EFI_GUID gEfiVTUTF8Guid;
|
||||
extern EFI_GUID gEfiUartDevicePathGuid;
|
||||
extern EFI_GUID gEfiSasDevicePathGuid;
|
||||
|
||||
#endif
|
128
wimboot/wimboot-2.7.3/src/efi/Guid/WinCertificate.h
Normal file
128
wimboot/wimboot-2.7.3/src/efi/Guid/WinCertificate.h
Normal file
@@ -0,0 +1,128 @@
|
||||
/** @file
|
||||
GUID for UEFI WIN_CERTIFICATE structure.
|
||||
|
||||
Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
@par Revision Reference:
|
||||
GUID defined in UEFI 2.0 spec.
|
||||
**/
|
||||
|
||||
#ifndef __EFI_WIN_CERTIFICATE_H__
|
||||
#define __EFI_WIN_CERTIFICATE_H__
|
||||
|
||||
//
|
||||
// _WIN_CERTIFICATE.wCertificateType
|
||||
//
|
||||
#define WIN_CERT_TYPE_PKCS_SIGNED_DATA 0x0002
|
||||
#define WIN_CERT_TYPE_EFI_PKCS115 0x0EF0
|
||||
#define WIN_CERT_TYPE_EFI_GUID 0x0EF1
|
||||
|
||||
///
|
||||
/// The WIN_CERTIFICATE structure is part of the PE/COFF specification.
|
||||
///
|
||||
typedef struct {
|
||||
///
|
||||
/// The length of the entire certificate,
|
||||
/// including the length of the header, in bytes.
|
||||
///
|
||||
UINT32 dwLength;
|
||||
///
|
||||
/// The revision level of the WIN_CERTIFICATE
|
||||
/// structure. The current revision level is 0x0200.
|
||||
///
|
||||
UINT16 wRevision;
|
||||
///
|
||||
/// The certificate type. See WIN_CERT_TYPE_xxx for the UEFI
|
||||
/// certificate types. The UEFI specification reserves the range of
|
||||
/// certificate type values from 0x0EF0 to 0x0EFF.
|
||||
///
|
||||
UINT16 wCertificateType;
|
||||
///
|
||||
/// The following is the actual certificate. The format of
|
||||
/// the certificate depends on wCertificateType.
|
||||
///
|
||||
/// UINT8 bCertificate[ANYSIZE_ARRAY];
|
||||
///
|
||||
} WIN_CERTIFICATE;
|
||||
|
||||
///
|
||||
/// WIN_CERTIFICATE_UEFI_GUID.CertType
|
||||
///
|
||||
#define EFI_CERT_TYPE_RSA2048_SHA256_GUID \
|
||||
{0xa7717414, 0xc616, 0x4977, {0x94, 0x20, 0x84, 0x47, 0x12, 0xa7, 0x35, 0xbf } }
|
||||
|
||||
///
|
||||
/// WIN_CERTIFICATE_UEFI_GUID.CertData
|
||||
///
|
||||
typedef struct {
|
||||
EFI_GUID HashType;
|
||||
UINT8 PublicKey[256];
|
||||
UINT8 Signature[256];
|
||||
} EFI_CERT_BLOCK_RSA_2048_SHA256;
|
||||
|
||||
|
||||
///
|
||||
/// Certificate which encapsulates a GUID-specific digital signature
|
||||
///
|
||||
typedef struct {
|
||||
///
|
||||
/// This is the standard WIN_CERTIFICATE header, where
|
||||
/// wCertificateType is set to WIN_CERT_TYPE_EFI_GUID.
|
||||
///
|
||||
WIN_CERTIFICATE Hdr;
|
||||
///
|
||||
/// This is the unique id which determines the
|
||||
/// format of the CertData. .
|
||||
///
|
||||
EFI_GUID CertType;
|
||||
///
|
||||
/// The following is the certificate data. The format of
|
||||
/// the data is determined by the CertType.
|
||||
/// If CertType is EFI_CERT_TYPE_RSA2048_SHA256_GUID,
|
||||
/// the CertData will be EFI_CERT_BLOCK_RSA_2048_SHA256 structure.
|
||||
///
|
||||
UINT8 CertData[1];
|
||||
} WIN_CERTIFICATE_UEFI_GUID;
|
||||
|
||||
|
||||
///
|
||||
/// Certificate which encapsulates the RSASSA_PKCS1-v1_5 digital signature.
|
||||
///
|
||||
/// The WIN_CERTIFICATE_UEFI_PKCS1_15 structure is derived from
|
||||
/// WIN_CERTIFICATE and encapsulate the information needed to
|
||||
/// implement the RSASSA-PKCS1-v1_5 digital signature algorithm as
|
||||
/// specified in RFC2437.
|
||||
///
|
||||
typedef struct {
|
||||
///
|
||||
/// This is the standard WIN_CERTIFICATE header, where
|
||||
/// wCertificateType is set to WIN_CERT_TYPE_UEFI_PKCS1_15.
|
||||
///
|
||||
WIN_CERTIFICATE Hdr;
|
||||
///
|
||||
/// This is the hashing algorithm which was performed on the
|
||||
/// UEFI executable when creating the digital signature.
|
||||
///
|
||||
EFI_GUID HashAlgorithm;
|
||||
///
|
||||
/// The following is the actual digital signature. The
|
||||
/// size of the signature is the same size as the key
|
||||
/// (1024-bit key is 128 bytes) and can be determined by
|
||||
/// subtracting the length of the other parts of this header
|
||||
/// from the total length of the certificate as found in
|
||||
/// Hdr.dwLength.
|
||||
///
|
||||
/// UINT8 Signature[];
|
||||
///
|
||||
} WIN_CERTIFICATE_EFI_PKCS1_15;
|
||||
|
||||
extern EFI_GUID gEfiCertTypeRsa2048Sha256Guid;
|
||||
|
||||
#endif
|
288
wimboot/wimboot-2.7.3/src/efi/Ia32/ProcessorBind.h
Normal file
288
wimboot/wimboot-2.7.3/src/efi/Ia32/ProcessorBind.h
Normal file
@@ -0,0 +1,288 @@
|
||||
/** @file
|
||||
Processor or Compiler specific defines and types for IA-32 architecture.
|
||||
|
||||
Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials are licensed and made available under
|
||||
the terms and conditions of the BSD License that accompanies this distribution.
|
||||
The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php.
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __PROCESSOR_BIND_H__
|
||||
#define __PROCESSOR_BIND_H__
|
||||
|
||||
///
|
||||
/// Define the processor type so other code can make processor based choices.
|
||||
///
|
||||
#define MDE_CPU_IA32
|
||||
|
||||
//
|
||||
// Make sure we are using the correct packing rules per EFI specification
|
||||
//
|
||||
#if !defined(__GNUC__)
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
#if defined(__INTEL_COMPILER)
|
||||
//
|
||||
// Disable ICC's remark #869: "Parameter" was never referenced warning.
|
||||
// This is legal ANSI C code so we disable the remark that is turned on with -Wall
|
||||
//
|
||||
#pragma warning ( disable : 869 )
|
||||
|
||||
//
|
||||
// Disable ICC's remark #1418: external function definition with no prior declaration.
|
||||
// This is legal ANSI C code so we disable the remark that is turned on with /W4
|
||||
//
|
||||
#pragma warning ( disable : 1418 )
|
||||
|
||||
//
|
||||
// Disable ICC's remark #1419: external declaration in primary source file
|
||||
// This is legal ANSI C code so we disable the remark that is turned on with /W4
|
||||
//
|
||||
#pragma warning ( disable : 1419 )
|
||||
|
||||
//
|
||||
// Disable ICC's remark #593: "Variable" was set but never used.
|
||||
// This is legal ANSI C code so we disable the remark that is turned on with /W4
|
||||
//
|
||||
#pragma warning ( disable : 593 )
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(_MSC_EXTENSIONS)
|
||||
|
||||
//
|
||||
// Disable warning that make it impossible to compile at /W4
|
||||
// This only works for Microsoft* tools
|
||||
//
|
||||
|
||||
//
|
||||
// Disabling bitfield type checking warnings.
|
||||
//
|
||||
#pragma warning ( disable : 4214 )
|
||||
|
||||
//
|
||||
// Disabling the unreferenced formal parameter warnings.
|
||||
//
|
||||
#pragma warning ( disable : 4100 )
|
||||
|
||||
//
|
||||
// Disable slightly different base types warning as CHAR8 * can not be set
|
||||
// to a constant string.
|
||||
//
|
||||
#pragma warning ( disable : 4057 )
|
||||
|
||||
//
|
||||
// ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning
|
||||
//
|
||||
#pragma warning ( disable : 4127 )
|
||||
|
||||
//
|
||||
// This warning is caused by functions defined but not used. For precompiled header only.
|
||||
//
|
||||
#pragma warning ( disable : 4505 )
|
||||
|
||||
//
|
||||
// This warning is caused by empty (after preprocessing) source file. For precompiled header only.
|
||||
//
|
||||
#pragma warning ( disable : 4206 )
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(_MSC_EXTENSIONS)
|
||||
|
||||
//
|
||||
// use Microsoft C complier dependent integer width types
|
||||
//
|
||||
|
||||
///
|
||||
/// 8-byte unsigned value.
|
||||
///
|
||||
typedef unsigned __int64 UINT64;
|
||||
///
|
||||
/// 8-byte signed value.
|
||||
///
|
||||
typedef __int64 INT64;
|
||||
///
|
||||
/// 4-byte unsigned value.
|
||||
///
|
||||
typedef unsigned __int32 UINT32;
|
||||
///
|
||||
/// 4-byte signed value.
|
||||
///
|
||||
typedef __int32 INT32;
|
||||
///
|
||||
/// 2-byte unsigned value.
|
||||
///
|
||||
typedef unsigned short UINT16;
|
||||
///
|
||||
/// 2-byte Character. Unless otherwise specified all strings are stored in the
|
||||
/// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
|
||||
///
|
||||
typedef unsigned short CHAR16;
|
||||
///
|
||||
/// 2-byte signed value.
|
||||
///
|
||||
typedef short INT16;
|
||||
///
|
||||
/// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other
|
||||
/// values are undefined.
|
||||
///
|
||||
typedef unsigned char BOOLEAN;
|
||||
///
|
||||
/// 1-byte unsigned value.
|
||||
///
|
||||
typedef unsigned char UINT8;
|
||||
///
|
||||
/// 1-byte Character.
|
||||
///
|
||||
typedef char CHAR8;
|
||||
///
|
||||
/// 1-byte signed value.
|
||||
///
|
||||
typedef signed char INT8;
|
||||
#else
|
||||
///
|
||||
/// 8-byte unsigned value.
|
||||
///
|
||||
typedef unsigned long long UINT64;
|
||||
///
|
||||
/// 8-byte signed value.
|
||||
///
|
||||
typedef long long INT64;
|
||||
///
|
||||
/// 4-byte unsigned value.
|
||||
///
|
||||
typedef unsigned int UINT32;
|
||||
///
|
||||
/// 4-byte signed value.
|
||||
///
|
||||
typedef int INT32;
|
||||
///
|
||||
/// 2-byte unsigned value.
|
||||
///
|
||||
typedef unsigned short UINT16;
|
||||
///
|
||||
/// 2-byte Character. Unless otherwise specified all strings are stored in the
|
||||
/// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
|
||||
///
|
||||
typedef unsigned short CHAR16;
|
||||
///
|
||||
/// 2-byte signed value.
|
||||
///
|
||||
typedef short INT16;
|
||||
///
|
||||
/// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other
|
||||
/// values are undefined.
|
||||
///
|
||||
typedef unsigned char BOOLEAN;
|
||||
///
|
||||
/// 1-byte unsigned value.
|
||||
///
|
||||
typedef unsigned char UINT8;
|
||||
///
|
||||
/// 1-byte Character
|
||||
///
|
||||
typedef char CHAR8;
|
||||
///
|
||||
/// 1-byte signed value
|
||||
///
|
||||
typedef signed char INT8;
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions;
|
||||
/// 8 bytes on supported 64-bit processor instructions.)
|
||||
///
|
||||
typedef UINT32 UINTN;
|
||||
///
|
||||
/// Signed value of native width. (4 bytes on supported 32-bit processor instructions;
|
||||
/// 8 bytes on supported 64-bit processor instructions.)
|
||||
///
|
||||
typedef INT32 INTN;
|
||||
|
||||
//
|
||||
// Processor specific defines
|
||||
//
|
||||
|
||||
///
|
||||
/// A value of native width with the highest bit set.
|
||||
///
|
||||
#define MAX_BIT 0x80000000
|
||||
///
|
||||
/// A value of native width with the two highest bits set.
|
||||
///
|
||||
#define MAX_2_BITS 0xC0000000
|
||||
|
||||
///
|
||||
/// Maximum legal IA-32 address.
|
||||
///
|
||||
#define MAX_ADDRESS 0xFFFFFFFF
|
||||
|
||||
///
|
||||
/// Maximum legal IA-32 INTN and UINTN values.
|
||||
///
|
||||
#define MAX_INTN ((INTN)0x7FFFFFFF)
|
||||
#define MAX_UINTN ((UINTN)0xFFFFFFFF)
|
||||
|
||||
///
|
||||
/// The stack alignment required for IA-32.
|
||||
///
|
||||
#define CPU_STACK_ALIGNMENT sizeof(UINTN)
|
||||
|
||||
//
|
||||
// Modifier to ensure that all protocol member functions and EFI intrinsics
|
||||
// use the correct C calling convention. All protocol member functions and
|
||||
// EFI intrinsics are required to modify their member functions with EFIAPI.
|
||||
//
|
||||
#ifdef EFIAPI
|
||||
///
|
||||
/// If EFIAPI is already defined, then we use that definition.
|
||||
///
|
||||
#elif defined(_MSC_EXTENSIONS)
|
||||
///
|
||||
/// Microsoft* compiler specific method for EFIAPI calling convention.
|
||||
///
|
||||
#define EFIAPI __cdecl
|
||||
#elif defined(__GNUC__)
|
||||
///
|
||||
/// GCC specific method for EFIAPI calling convention.
|
||||
///
|
||||
#define EFIAPI __attribute__((cdecl))
|
||||
#else
|
||||
///
|
||||
/// The default for a non Microsoft* or GCC compiler is to assume the EFI ABI
|
||||
/// is the standard.
|
||||
///
|
||||
#define EFIAPI
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
///
|
||||
/// For GNU assembly code, .global or .globl can declare global symbols.
|
||||
/// Define this macro to unify the usage.
|
||||
///
|
||||
#define ASM_GLOBAL .globl
|
||||
#endif
|
||||
|
||||
/**
|
||||
Return the pointer to the first instruction of a function given a function pointer.
|
||||
On IA-32 CPU architectures, these two pointer values are the same,
|
||||
so the implementation of this macro is very simple.
|
||||
|
||||
@param FunctionPointer A pointer to a function.
|
||||
|
||||
@return The pointer to the first instruction of a function given a function pointer.
|
||||
|
||||
**/
|
||||
#define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)
|
||||
|
||||
#endif
|
||||
|
756
wimboot/wimboot-2.7.3/src/efi/IndustryStandard/PeImage.h
Normal file
756
wimboot/wimboot-2.7.3/src/efi/IndustryStandard/PeImage.h
Normal file
@@ -0,0 +1,756 @@
|
||||
/** @file
|
||||
EFI image format for PE32, PE32+ and TE. Please note some data structures are
|
||||
different for PE32 and PE32+. EFI_IMAGE_NT_HEADERS32 is for PE32 and
|
||||
EFI_IMAGE_NT_HEADERS64 is for PE32+.
|
||||
|
||||
This file is coded to the Visual Studio, Microsoft Portable Executable and
|
||||
Common Object File Format Specification, Revision 8.3 - February 6, 2013.
|
||||
This file also includes some definitions in PI Specification, Revision 1.0.
|
||||
|
||||
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php.
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __PE_IMAGE_H__
|
||||
#define __PE_IMAGE_H__
|
||||
|
||||
//
|
||||
// PE32+ Subsystem type for EFI images
|
||||
//
|
||||
#define EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION 10
|
||||
#define EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
|
||||
#define EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
|
||||
#define EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER 13 ///< defined PI Specification, 1.0
|
||||
|
||||
|
||||
//
|
||||
// PE32+ Machine type for EFI images
|
||||
//
|
||||
#define IMAGE_FILE_MACHINE_I386 0x014c
|
||||
#define IMAGE_FILE_MACHINE_IA64 0x0200
|
||||
#define IMAGE_FILE_MACHINE_EBC 0x0EBC
|
||||
#define IMAGE_FILE_MACHINE_X64 0x8664
|
||||
#define IMAGE_FILE_MACHINE_ARMTHUMB_MIXED 0x01c2
|
||||
#define IMAGE_FILE_MACHINE_ARM64 0xAA64
|
||||
|
||||
//
|
||||
// EXE file formats
|
||||
//
|
||||
#define EFI_IMAGE_DOS_SIGNATURE SIGNATURE_16('M', 'Z')
|
||||
#define EFI_IMAGE_OS2_SIGNATURE SIGNATURE_16('N', 'E')
|
||||
#define EFI_IMAGE_OS2_SIGNATURE_LE SIGNATURE_16('L', 'E')
|
||||
#define EFI_IMAGE_NT_SIGNATURE SIGNATURE_32('P', 'E', '\0', '\0')
|
||||
|
||||
///
|
||||
/// PE images can start with an optional DOS header, so if an image is run
|
||||
/// under DOS it can print an error message.
|
||||
///
|
||||
typedef struct {
|
||||
UINT16 e_magic; ///< Magic number.
|
||||
UINT16 e_cblp; ///< Bytes on last page of file.
|
||||
UINT16 e_cp; ///< Pages in file.
|
||||
UINT16 e_crlc; ///< Relocations.
|
||||
UINT16 e_cparhdr; ///< Size of header in paragraphs.
|
||||
UINT16 e_minalloc; ///< Minimum extra paragraphs needed.
|
||||
UINT16 e_maxalloc; ///< Maximum extra paragraphs needed.
|
||||
UINT16 e_ss; ///< Initial (relative) SS value.
|
||||
UINT16 e_sp; ///< Initial SP value.
|
||||
UINT16 e_csum; ///< Checksum.
|
||||
UINT16 e_ip; ///< Initial IP value.
|
||||
UINT16 e_cs; ///< Initial (relative) CS value.
|
||||
UINT16 e_lfarlc; ///< File address of relocation table.
|
||||
UINT16 e_ovno; ///< Overlay number.
|
||||
UINT16 e_res[4]; ///< Reserved words.
|
||||
UINT16 e_oemid; ///< OEM identifier (for e_oeminfo).
|
||||
UINT16 e_oeminfo; ///< OEM information; e_oemid specific.
|
||||
UINT16 e_res2[10]; ///< Reserved words.
|
||||
UINT32 e_lfanew; ///< File address of new exe header.
|
||||
} EFI_IMAGE_DOS_HEADER;
|
||||
|
||||
///
|
||||
/// COFF File Header (Object and Image).
|
||||
///
|
||||
typedef struct {
|
||||
UINT16 Machine;
|
||||
UINT16 NumberOfSections;
|
||||
UINT32 TimeDateStamp;
|
||||
UINT32 PointerToSymbolTable;
|
||||
UINT32 NumberOfSymbols;
|
||||
UINT16 SizeOfOptionalHeader;
|
||||
UINT16 Characteristics;
|
||||
} EFI_IMAGE_FILE_HEADER;
|
||||
|
||||
///
|
||||
/// Size of EFI_IMAGE_FILE_HEADER.
|
||||
///
|
||||
#define EFI_IMAGE_SIZEOF_FILE_HEADER 20
|
||||
|
||||
//
|
||||
// Characteristics
|
||||
//
|
||||
#define EFI_IMAGE_FILE_RELOCS_STRIPPED BIT0 ///< 0x0001 Relocation info stripped from file.
|
||||
#define EFI_IMAGE_FILE_EXECUTABLE_IMAGE BIT1 ///< 0x0002 File is executable (i.e. no unresolved externel references).
|
||||
#define EFI_IMAGE_FILE_LINE_NUMS_STRIPPED BIT2 ///< 0x0004 Line nunbers stripped from file.
|
||||
#define EFI_IMAGE_FILE_LOCAL_SYMS_STRIPPED BIT3 ///< 0x0008 Local symbols stripped from file.
|
||||
#define EFI_IMAGE_FILE_BYTES_REVERSED_LO BIT7 ///< 0x0080 Bytes of machine word are reversed.
|
||||
#define EFI_IMAGE_FILE_32BIT_MACHINE BIT8 ///< 0x0100 32 bit word machine.
|
||||
#define EFI_IMAGE_FILE_DEBUG_STRIPPED BIT9 ///< 0x0200 Debugging info stripped from file in .DBG file.
|
||||
#define EFI_IMAGE_FILE_SYSTEM BIT12 ///< 0x1000 System File.
|
||||
#define EFI_IMAGE_FILE_DLL BIT13 ///< 0x2000 File is a DLL.
|
||||
#define EFI_IMAGE_FILE_BYTES_REVERSED_HI BIT15 ///< 0x8000 Bytes of machine word are reversed.
|
||||
|
||||
///
|
||||
/// Header Data Directories.
|
||||
///
|
||||
typedef struct {
|
||||
UINT32 VirtualAddress;
|
||||
UINT32 Size;
|
||||
} EFI_IMAGE_DATA_DIRECTORY;
|
||||
|
||||
//
|
||||
// Directory Entries
|
||||
//
|
||||
#define EFI_IMAGE_DIRECTORY_ENTRY_EXPORT 0
|
||||
#define EFI_IMAGE_DIRECTORY_ENTRY_IMPORT 1
|
||||
#define EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE 2
|
||||
#define EFI_IMAGE_DIRECTORY_ENTRY_EXCEPTION 3
|
||||
#define EFI_IMAGE_DIRECTORY_ENTRY_SECURITY 4
|
||||
#define EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC 5
|
||||
#define EFI_IMAGE_DIRECTORY_ENTRY_DEBUG 6
|
||||
#define EFI_IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7
|
||||
#define EFI_IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8
|
||||
#define EFI_IMAGE_DIRECTORY_ENTRY_TLS 9
|
||||
#define EFI_IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10
|
||||
|
||||
#define EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES 16
|
||||
|
||||
///
|
||||
/// @attention
|
||||
/// EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC means PE32 and
|
||||
/// EFI_IMAGE_OPTIONAL_HEADER32 must be used. The data structures only vary
|
||||
/// after NT additional fields.
|
||||
///
|
||||
#define EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b
|
||||
|
||||
///
|
||||
/// Optional Header Standard Fields for PE32.
|
||||
///
|
||||
typedef struct {
|
||||
///
|
||||
/// Standard fields.
|
||||
///
|
||||
UINT16 Magic;
|
||||
UINT8 MajorLinkerVersion;
|
||||
UINT8 MinorLinkerVersion;
|
||||
UINT32 SizeOfCode;
|
||||
UINT32 SizeOfInitializedData;
|
||||
UINT32 SizeOfUninitializedData;
|
||||
UINT32 AddressOfEntryPoint;
|
||||
UINT32 BaseOfCode;
|
||||
UINT32 BaseOfData; ///< PE32 contains this additional field, which is absent in PE32+.
|
||||
///
|
||||
/// Optional Header Windows-Specific Fields.
|
||||
///
|
||||
UINT32 ImageBase;
|
||||
UINT32 SectionAlignment;
|
||||
UINT32 FileAlignment;
|
||||
UINT16 MajorOperatingSystemVersion;
|
||||
UINT16 MinorOperatingSystemVersion;
|
||||
UINT16 MajorImageVersion;
|
||||
UINT16 MinorImageVersion;
|
||||
UINT16 MajorSubsystemVersion;
|
||||
UINT16 MinorSubsystemVersion;
|
||||
UINT32 Win32VersionValue;
|
||||
UINT32 SizeOfImage;
|
||||
UINT32 SizeOfHeaders;
|
||||
UINT32 CheckSum;
|
||||
UINT16 Subsystem;
|
||||
UINT16 DllCharacteristics;
|
||||
UINT32 SizeOfStackReserve;
|
||||
UINT32 SizeOfStackCommit;
|
||||
UINT32 SizeOfHeapReserve;
|
||||
UINT32 SizeOfHeapCommit;
|
||||
UINT32 LoaderFlags;
|
||||
UINT32 NumberOfRvaAndSizes;
|
||||
EFI_IMAGE_DATA_DIRECTORY DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES];
|
||||
} EFI_IMAGE_OPTIONAL_HEADER32;
|
||||
|
||||
///
|
||||
/// @attention
|
||||
/// EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC means PE32+ and
|
||||
/// EFI_IMAGE_OPTIONAL_HEADER64 must be used. The data structures only vary
|
||||
/// after NT additional fields.
|
||||
///
|
||||
#define EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b
|
||||
|
||||
///
|
||||
/// Optional Header Standard Fields for PE32+.
|
||||
///
|
||||
typedef struct {
|
||||
///
|
||||
/// Standard fields.
|
||||
///
|
||||
UINT16 Magic;
|
||||
UINT8 MajorLinkerVersion;
|
||||
UINT8 MinorLinkerVersion;
|
||||
UINT32 SizeOfCode;
|
||||
UINT32 SizeOfInitializedData;
|
||||
UINT32 SizeOfUninitializedData;
|
||||
UINT32 AddressOfEntryPoint;
|
||||
UINT32 BaseOfCode;
|
||||
///
|
||||
/// Optional Header Windows-Specific Fields.
|
||||
///
|
||||
UINT64 ImageBase;
|
||||
UINT32 SectionAlignment;
|
||||
UINT32 FileAlignment;
|
||||
UINT16 MajorOperatingSystemVersion;
|
||||
UINT16 MinorOperatingSystemVersion;
|
||||
UINT16 MajorImageVersion;
|
||||
UINT16 MinorImageVersion;
|
||||
UINT16 MajorSubsystemVersion;
|
||||
UINT16 MinorSubsystemVersion;
|
||||
UINT32 Win32VersionValue;
|
||||
UINT32 SizeOfImage;
|
||||
UINT32 SizeOfHeaders;
|
||||
UINT32 CheckSum;
|
||||
UINT16 Subsystem;
|
||||
UINT16 DllCharacteristics;
|
||||
UINT64 SizeOfStackReserve;
|
||||
UINT64 SizeOfStackCommit;
|
||||
UINT64 SizeOfHeapReserve;
|
||||
UINT64 SizeOfHeapCommit;
|
||||
UINT32 LoaderFlags;
|
||||
UINT32 NumberOfRvaAndSizes;
|
||||
EFI_IMAGE_DATA_DIRECTORY DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES];
|
||||
} EFI_IMAGE_OPTIONAL_HEADER64;
|
||||
|
||||
|
||||
///
|
||||
/// @attention
|
||||
/// EFI_IMAGE_NT_HEADERS32 is for use ONLY by tools.
|
||||
///
|
||||
typedef struct {
|
||||
UINT32 Signature;
|
||||
EFI_IMAGE_FILE_HEADER FileHeader;
|
||||
EFI_IMAGE_OPTIONAL_HEADER32 OptionalHeader;
|
||||
} EFI_IMAGE_NT_HEADERS32;
|
||||
|
||||
#define EFI_IMAGE_SIZEOF_NT_OPTIONAL32_HEADER sizeof (EFI_IMAGE_NT_HEADERS32)
|
||||
|
||||
///
|
||||
/// @attention
|
||||
/// EFI_IMAGE_HEADERS64 is for use ONLY by tools.
|
||||
///
|
||||
typedef struct {
|
||||
UINT32 Signature;
|
||||
EFI_IMAGE_FILE_HEADER FileHeader;
|
||||
EFI_IMAGE_OPTIONAL_HEADER64 OptionalHeader;
|
||||
} EFI_IMAGE_NT_HEADERS64;
|
||||
|
||||
#define EFI_IMAGE_SIZEOF_NT_OPTIONAL64_HEADER sizeof (EFI_IMAGE_NT_HEADERS64)
|
||||
|
||||
//
|
||||
// Other Windows Subsystem Values
|
||||
//
|
||||
#define EFI_IMAGE_SUBSYSTEM_UNKNOWN 0
|
||||
#define EFI_IMAGE_SUBSYSTEM_NATIVE 1
|
||||
#define EFI_IMAGE_SUBSYSTEM_WINDOWS_GUI 2
|
||||
#define EFI_IMAGE_SUBSYSTEM_WINDOWS_CUI 3
|
||||
#define EFI_IMAGE_SUBSYSTEM_OS2_CUI 5
|
||||
#define EFI_IMAGE_SUBSYSTEM_POSIX_CUI 7
|
||||
|
||||
///
|
||||
/// Length of ShortName.
|
||||
///
|
||||
#define EFI_IMAGE_SIZEOF_SHORT_NAME 8
|
||||
|
||||
///
|
||||
/// Section Table. This table immediately follows the optional header.
|
||||
///
|
||||
typedef struct {
|
||||
UINT8 Name[EFI_IMAGE_SIZEOF_SHORT_NAME];
|
||||
union {
|
||||
UINT32 PhysicalAddress;
|
||||
UINT32 VirtualSize;
|
||||
} Misc;
|
||||
UINT32 VirtualAddress;
|
||||
UINT32 SizeOfRawData;
|
||||
UINT32 PointerToRawData;
|
||||
UINT32 PointerToRelocations;
|
||||
UINT32 PointerToLinenumbers;
|
||||
UINT16 NumberOfRelocations;
|
||||
UINT16 NumberOfLinenumbers;
|
||||
UINT32 Characteristics;
|
||||
} EFI_IMAGE_SECTION_HEADER;
|
||||
|
||||
///
|
||||
/// Size of EFI_IMAGE_SECTION_HEADER.
|
||||
///
|
||||
#define EFI_IMAGE_SIZEOF_SECTION_HEADER 40
|
||||
|
||||
//
|
||||
// Section Flags Values
|
||||
//
|
||||
#define EFI_IMAGE_SCN_TYPE_NO_PAD BIT3 ///< 0x00000008 ///< Reserved.
|
||||
#define EFI_IMAGE_SCN_CNT_CODE BIT5 ///< 0x00000020
|
||||
#define EFI_IMAGE_SCN_CNT_INITIALIZED_DATA BIT6 ///< 0x00000040
|
||||
#define EFI_IMAGE_SCN_CNT_UNINITIALIZED_DATA BIT7 ///< 0x00000080
|
||||
|
||||
#define EFI_IMAGE_SCN_LNK_OTHER BIT8 ///< 0x00000100 ///< Reserved.
|
||||
#define EFI_IMAGE_SCN_LNK_INFO BIT9 ///< 0x00000200 ///< Section contains comments or some other type of information.
|
||||
#define EFI_IMAGE_SCN_LNK_REMOVE BIT11 ///< 0x00000800 ///< Section contents will not become part of image.
|
||||
#define EFI_IMAGE_SCN_LNK_COMDAT BIT12 ///< 0x00001000
|
||||
|
||||
#define EFI_IMAGE_SCN_ALIGN_1BYTES BIT20 ///< 0x00100000
|
||||
#define EFI_IMAGE_SCN_ALIGN_2BYTES BIT21 ///< 0x00200000
|
||||
#define EFI_IMAGE_SCN_ALIGN_4BYTES (BIT20|BIT21) ///< 0x00300000
|
||||
#define EFI_IMAGE_SCN_ALIGN_8BYTES BIT22 ///< 0x00400000
|
||||
#define EFI_IMAGE_SCN_ALIGN_16BYTES (BIT20|BIT22) ///< 0x00500000
|
||||
#define EFI_IMAGE_SCN_ALIGN_32BYTES (BIT21|BIT22) ///< 0x00600000
|
||||
#define EFI_IMAGE_SCN_ALIGN_64BYTES (BIT20|BIT21|BIT22) ///< 0x00700000
|
||||
|
||||
#define EFI_IMAGE_SCN_MEM_DISCARDABLE BIT25 ///< 0x02000000
|
||||
#define EFI_IMAGE_SCN_MEM_NOT_CACHED BIT26 ///< 0x04000000
|
||||
#define EFI_IMAGE_SCN_MEM_NOT_PAGED BIT27 ///< 0x08000000
|
||||
#define EFI_IMAGE_SCN_MEM_SHARED BIT28 ///< 0x10000000
|
||||
#define EFI_IMAGE_SCN_MEM_EXECUTE BIT29 ///< 0x20000000
|
||||
#define EFI_IMAGE_SCN_MEM_READ BIT30 ///< 0x40000000
|
||||
#define EFI_IMAGE_SCN_MEM_WRITE BIT31 ///< 0x80000000
|
||||
|
||||
///
|
||||
/// Size of a Symbol Table Record.
|
||||
///
|
||||
#define EFI_IMAGE_SIZEOF_SYMBOL 18
|
||||
|
||||
//
|
||||
// Symbols have a section number of the section in which they are
|
||||
// defined. Otherwise, section numbers have the following meanings:
|
||||
//
|
||||
#define EFI_IMAGE_SYM_UNDEFINED (UINT16) 0 ///< Symbol is undefined or is common.
|
||||
#define EFI_IMAGE_SYM_ABSOLUTE (UINT16) -1 ///< Symbol is an absolute value.
|
||||
#define EFI_IMAGE_SYM_DEBUG (UINT16) -2 ///< Symbol is a special debug item.
|
||||
|
||||
//
|
||||
// Symbol Type (fundamental) values.
|
||||
//
|
||||
#define EFI_IMAGE_SYM_TYPE_NULL 0 ///< no type.
|
||||
#define EFI_IMAGE_SYM_TYPE_VOID 1 ///< no valid type.
|
||||
#define EFI_IMAGE_SYM_TYPE_CHAR 2 ///< type character.
|
||||
#define EFI_IMAGE_SYM_TYPE_SHORT 3 ///< type short integer.
|
||||
#define EFI_IMAGE_SYM_TYPE_INT 4
|
||||
#define EFI_IMAGE_SYM_TYPE_LONG 5
|
||||
#define EFI_IMAGE_SYM_TYPE_FLOAT 6
|
||||
#define EFI_IMAGE_SYM_TYPE_DOUBLE 7
|
||||
#define EFI_IMAGE_SYM_TYPE_STRUCT 8
|
||||
#define EFI_IMAGE_SYM_TYPE_UNION 9
|
||||
#define EFI_IMAGE_SYM_TYPE_ENUM 10 ///< enumeration.
|
||||
#define EFI_IMAGE_SYM_TYPE_MOE 11 ///< member of enumeration.
|
||||
#define EFI_IMAGE_SYM_TYPE_BYTE 12
|
||||
#define EFI_IMAGE_SYM_TYPE_WORD 13
|
||||
#define EFI_IMAGE_SYM_TYPE_UINT 14
|
||||
#define EFI_IMAGE_SYM_TYPE_DWORD 15
|
||||
|
||||
//
|
||||
// Symbol Type (derived) values.
|
||||
//
|
||||
#define EFI_IMAGE_SYM_DTYPE_NULL 0 ///< no derived type.
|
||||
#define EFI_IMAGE_SYM_DTYPE_POINTER 1
|
||||
#define EFI_IMAGE_SYM_DTYPE_FUNCTION 2
|
||||
#define EFI_IMAGE_SYM_DTYPE_ARRAY 3
|
||||
|
||||
//
|
||||
// Storage classes.
|
||||
//
|
||||
#define EFI_IMAGE_SYM_CLASS_END_OF_FUNCTION ((UINT8) -1)
|
||||
#define EFI_IMAGE_SYM_CLASS_NULL 0
|
||||
#define EFI_IMAGE_SYM_CLASS_AUTOMATIC 1
|
||||
#define EFI_IMAGE_SYM_CLASS_EXTERNAL 2
|
||||
#define EFI_IMAGE_SYM_CLASS_STATIC 3
|
||||
#define EFI_IMAGE_SYM_CLASS_REGISTER 4
|
||||
#define EFI_IMAGE_SYM_CLASS_EXTERNAL_DEF 5
|
||||
#define EFI_IMAGE_SYM_CLASS_LABEL 6
|
||||
#define EFI_IMAGE_SYM_CLASS_UNDEFINED_LABEL 7
|
||||
#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 8
|
||||
#define EFI_IMAGE_SYM_CLASS_ARGUMENT 9
|
||||
#define EFI_IMAGE_SYM_CLASS_STRUCT_TAG 10
|
||||
#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_UNION 11
|
||||
#define EFI_IMAGE_SYM_CLASS_UNION_TAG 12
|
||||
#define EFI_IMAGE_SYM_CLASS_TYPE_DEFINITION 13
|
||||
#define EFI_IMAGE_SYM_CLASS_UNDEFINED_STATIC 14
|
||||
#define EFI_IMAGE_SYM_CLASS_ENUM_TAG 15
|
||||
#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_ENUM 16
|
||||
#define EFI_IMAGE_SYM_CLASS_REGISTER_PARAM 17
|
||||
#define EFI_IMAGE_SYM_CLASS_BIT_FIELD 18
|
||||
#define EFI_IMAGE_SYM_CLASS_BLOCK 100
|
||||
#define EFI_IMAGE_SYM_CLASS_FUNCTION 101
|
||||
#define EFI_IMAGE_SYM_CLASS_END_OF_STRUCT 102
|
||||
#define EFI_IMAGE_SYM_CLASS_FILE 103
|
||||
#define EFI_IMAGE_SYM_CLASS_SECTION 104
|
||||
#define EFI_IMAGE_SYM_CLASS_WEAK_EXTERNAL 105
|
||||
|
||||
//
|
||||
// type packing constants
|
||||
//
|
||||
#define EFI_IMAGE_N_BTMASK 017
|
||||
#define EFI_IMAGE_N_TMASK 060
|
||||
#define EFI_IMAGE_N_TMASK1 0300
|
||||
#define EFI_IMAGE_N_TMASK2 0360
|
||||
#define EFI_IMAGE_N_BTSHFT 4
|
||||
#define EFI_IMAGE_N_TSHIFT 2
|
||||
|
||||
//
|
||||
// Communal selection types.
|
||||
//
|
||||
#define EFI_IMAGE_COMDAT_SELECT_NODUPLICATES 1
|
||||
#define EFI_IMAGE_COMDAT_SELECT_ANY 2
|
||||
#define EFI_IMAGE_COMDAT_SELECT_SAME_SIZE 3
|
||||
#define EFI_IMAGE_COMDAT_SELECT_EXACT_MATCH 4
|
||||
#define EFI_IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
|
||||
|
||||
//
|
||||
// the following values only be referred in PeCoff, not defined in PECOFF.
|
||||
//
|
||||
#define EFI_IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
|
||||
#define EFI_IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
|
||||
#define EFI_IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
|
||||
|
||||
///
|
||||
/// Relocation format.
|
||||
///
|
||||
typedef struct {
|
||||
UINT32 VirtualAddress;
|
||||
UINT32 SymbolTableIndex;
|
||||
UINT16 Type;
|
||||
} EFI_IMAGE_RELOCATION;
|
||||
|
||||
///
|
||||
/// Size of EFI_IMAGE_RELOCATION
|
||||
///
|
||||
#define EFI_IMAGE_SIZEOF_RELOCATION 10
|
||||
|
||||
//
|
||||
// I386 relocation types.
|
||||
//
|
||||
#define EFI_IMAGE_REL_I386_ABSOLUTE 0x0000 ///< Reference is absolute, no relocation is necessary.
|
||||
#define EFI_IMAGE_REL_I386_DIR16 0x0001 ///< Direct 16-bit reference to the symbols virtual address.
|
||||
#define EFI_IMAGE_REL_I386_REL16 0x0002 ///< PC-relative 16-bit reference to the symbols virtual address.
|
||||
#define EFI_IMAGE_REL_I386_DIR32 0x0006 ///< Direct 32-bit reference to the symbols virtual address.
|
||||
#define EFI_IMAGE_REL_I386_DIR32NB 0x0007 ///< Direct 32-bit reference to the symbols virtual address, base not included.
|
||||
#define EFI_IMAGE_REL_I386_SEG12 0x0009 ///< Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address.
|
||||
#define EFI_IMAGE_REL_I386_SECTION 0x000A
|
||||
#define EFI_IMAGE_REL_I386_SECREL 0x000B
|
||||
#define EFI_IMAGE_REL_I386_REL32 0x0014 ///< PC-relative 32-bit reference to the symbols virtual address.
|
||||
|
||||
//
|
||||
// x64 processor relocation types.
|
||||
//
|
||||
#define IMAGE_REL_AMD64_ABSOLUTE 0x0000
|
||||
#define IMAGE_REL_AMD64_ADDR64 0x0001
|
||||
#define IMAGE_REL_AMD64_ADDR32 0x0002
|
||||
#define IMAGE_REL_AMD64_ADDR32NB 0x0003
|
||||
#define IMAGE_REL_AMD64_REL32 0x0004
|
||||
#define IMAGE_REL_AMD64_REL32_1 0x0005
|
||||
#define IMAGE_REL_AMD64_REL32_2 0x0006
|
||||
#define IMAGE_REL_AMD64_REL32_3 0x0007
|
||||
#define IMAGE_REL_AMD64_REL32_4 0x0008
|
||||
#define IMAGE_REL_AMD64_REL32_5 0x0009
|
||||
#define IMAGE_REL_AMD64_SECTION 0x000A
|
||||
#define IMAGE_REL_AMD64_SECREL 0x000B
|
||||
#define IMAGE_REL_AMD64_SECREL7 0x000C
|
||||
#define IMAGE_REL_AMD64_TOKEN 0x000D
|
||||
#define IMAGE_REL_AMD64_SREL32 0x000E
|
||||
#define IMAGE_REL_AMD64_PAIR 0x000F
|
||||
#define IMAGE_REL_AMD64_SSPAN32 0x0010
|
||||
|
||||
///
|
||||
/// Based relocation format.
|
||||
///
|
||||
typedef struct {
|
||||
UINT32 VirtualAddress;
|
||||
UINT32 SizeOfBlock;
|
||||
} EFI_IMAGE_BASE_RELOCATION;
|
||||
|
||||
///
|
||||
/// Size of EFI_IMAGE_BASE_RELOCATION.
|
||||
///
|
||||
#define EFI_IMAGE_SIZEOF_BASE_RELOCATION 8
|
||||
|
||||
//
|
||||
// Based relocation types.
|
||||
//
|
||||
#define EFI_IMAGE_REL_BASED_ABSOLUTE 0
|
||||
#define EFI_IMAGE_REL_BASED_HIGH 1
|
||||
#define EFI_IMAGE_REL_BASED_LOW 2
|
||||
#define EFI_IMAGE_REL_BASED_HIGHLOW 3
|
||||
#define EFI_IMAGE_REL_BASED_HIGHADJ 4
|
||||
#define EFI_IMAGE_REL_BASED_MIPS_JMPADDR 5
|
||||
#define EFI_IMAGE_REL_BASED_ARM_MOV32A 5
|
||||
#define EFI_IMAGE_REL_BASED_ARM_MOV32T 7
|
||||
#define EFI_IMAGE_REL_BASED_IA64_IMM64 9
|
||||
#define EFI_IMAGE_REL_BASED_MIPS_JMPADDR16 9
|
||||
#define EFI_IMAGE_REL_BASED_DIR64 10
|
||||
|
||||
///
|
||||
/// Line number format.
|
||||
///
|
||||
typedef struct {
|
||||
union {
|
||||
UINT32 SymbolTableIndex; ///< Symbol table index of function name if Linenumber is 0.
|
||||
UINT32 VirtualAddress; ///< Virtual address of line number.
|
||||
} Type;
|
||||
UINT16 Linenumber; ///< Line number.
|
||||
} EFI_IMAGE_LINENUMBER;
|
||||
|
||||
///
|
||||
/// Size of EFI_IMAGE_LINENUMBER.
|
||||
///
|
||||
#define EFI_IMAGE_SIZEOF_LINENUMBER 6
|
||||
|
||||
//
|
||||
// Archive format.
|
||||
//
|
||||
#define EFI_IMAGE_ARCHIVE_START_SIZE 8
|
||||
#define EFI_IMAGE_ARCHIVE_START "!<arch>\n"
|
||||
#define EFI_IMAGE_ARCHIVE_END "`\n"
|
||||
#define EFI_IMAGE_ARCHIVE_PAD "\n"
|
||||
#define EFI_IMAGE_ARCHIVE_LINKER_MEMBER "/ "
|
||||
#define EFI_IMAGE_ARCHIVE_LONGNAMES_MEMBER "// "
|
||||
|
||||
///
|
||||
/// Archive Member Headers
|
||||
///
|
||||
typedef struct {
|
||||
UINT8 Name[16]; ///< File member name - `/' terminated.
|
||||
UINT8 Date[12]; ///< File member date - decimal.
|
||||
UINT8 UserID[6]; ///< File member user id - decimal.
|
||||
UINT8 GroupID[6]; ///< File member group id - decimal.
|
||||
UINT8 Mode[8]; ///< File member mode - octal.
|
||||
UINT8 Size[10]; ///< File member size - decimal.
|
||||
UINT8 EndHeader[2]; ///< String to end header. (0x60 0x0A).
|
||||
} EFI_IMAGE_ARCHIVE_MEMBER_HEADER;
|
||||
|
||||
///
|
||||
/// Size of EFI_IMAGE_ARCHIVE_MEMBER_HEADER.
|
||||
///
|
||||
#define EFI_IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
|
||||
|
||||
|
||||
//
|
||||
// DLL Support
|
||||
//
|
||||
|
||||
///
|
||||
/// Export Directory Table.
|
||||
///
|
||||
typedef struct {
|
||||
UINT32 Characteristics;
|
||||
UINT32 TimeDateStamp;
|
||||
UINT16 MajorVersion;
|
||||
UINT16 MinorVersion;
|
||||
UINT32 Name;
|
||||
UINT32 Base;
|
||||
UINT32 NumberOfFunctions;
|
||||
UINT32 NumberOfNames;
|
||||
UINT32 AddressOfFunctions;
|
||||
UINT32 AddressOfNames;
|
||||
UINT32 AddressOfNameOrdinals;
|
||||
} EFI_IMAGE_EXPORT_DIRECTORY;
|
||||
|
||||
///
|
||||
/// Hint/Name Table.
|
||||
///
|
||||
typedef struct {
|
||||
UINT16 Hint;
|
||||
UINT8 Name[1];
|
||||
} EFI_IMAGE_IMPORT_BY_NAME;
|
||||
|
||||
///
|
||||
/// Import Address Table RVA (Thunk Table).
|
||||
///
|
||||
typedef struct {
|
||||
union {
|
||||
UINT32 Function;
|
||||
UINT32 Ordinal;
|
||||
EFI_IMAGE_IMPORT_BY_NAME *AddressOfData;
|
||||
} u1;
|
||||
} EFI_IMAGE_THUNK_DATA;
|
||||
|
||||
#define EFI_IMAGE_ORDINAL_FLAG BIT31 ///< Flag for PE32.
|
||||
#define EFI_IMAGE_SNAP_BY_ORDINAL(Ordinal) ((Ordinal & EFI_IMAGE_ORDINAL_FLAG) != 0)
|
||||
#define EFI_IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff)
|
||||
|
||||
///
|
||||
/// Import Directory Table
|
||||
///
|
||||
typedef struct {
|
||||
UINT32 Characteristics;
|
||||
UINT32 TimeDateStamp;
|
||||
UINT32 ForwarderChain;
|
||||
UINT32 Name;
|
||||
EFI_IMAGE_THUNK_DATA *FirstThunk;
|
||||
} EFI_IMAGE_IMPORT_DESCRIPTOR;
|
||||
|
||||
|
||||
///
|
||||
/// Debug Directory Format.
|
||||
///
|
||||
typedef struct {
|
||||
UINT32 Characteristics;
|
||||
UINT32 TimeDateStamp;
|
||||
UINT16 MajorVersion;
|
||||
UINT16 MinorVersion;
|
||||
UINT32 Type;
|
||||
UINT32 SizeOfData;
|
||||
UINT32 RVA; ///< The address of the debug data when loaded, relative to the image base.
|
||||
UINT32 FileOffset; ///< The file pointer to the debug data.
|
||||
} EFI_IMAGE_DEBUG_DIRECTORY_ENTRY;
|
||||
|
||||
#define EFI_IMAGE_DEBUG_TYPE_CODEVIEW 2 ///< The Visual C++ debug information.
|
||||
|
||||
///
|
||||
/// Debug Data Structure defined in Microsoft C++.
|
||||
///
|
||||
#define CODEVIEW_SIGNATURE_NB10 SIGNATURE_32('N', 'B', '1', '0')
|
||||
typedef struct {
|
||||
UINT32 Signature; ///< "NB10"
|
||||
UINT32 Unknown;
|
||||
UINT32 Unknown2;
|
||||
UINT32 Unknown3;
|
||||
//
|
||||
// Filename of .PDB goes here
|
||||
//
|
||||
} EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY;
|
||||
|
||||
///
|
||||
/// Debug Data Structure defined in Microsoft C++.
|
||||
///
|
||||
#define CODEVIEW_SIGNATURE_RSDS SIGNATURE_32('R', 'S', 'D', 'S')
|
||||
typedef struct {
|
||||
UINT32 Signature; ///< "RSDS".
|
||||
UINT32 Unknown;
|
||||
UINT32 Unknown2;
|
||||
UINT32 Unknown3;
|
||||
UINT32 Unknown4;
|
||||
UINT32 Unknown5;
|
||||
//
|
||||
// Filename of .PDB goes here
|
||||
//
|
||||
} EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY;
|
||||
|
||||
|
||||
///
|
||||
/// Debug Data Structure defined by Apple Mach-O to Coff utility.
|
||||
///
|
||||
#define CODEVIEW_SIGNATURE_MTOC SIGNATURE_32('M', 'T', 'O', 'C')
|
||||
typedef struct {
|
||||
UINT32 Signature; ///< "MTOC".
|
||||
GUID MachOUuid;
|
||||
//
|
||||
// Filename of .DLL (Mach-O with debug info) goes here
|
||||
//
|
||||
} EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY;
|
||||
|
||||
///
|
||||
/// Resource format.
|
||||
///
|
||||
typedef struct {
|
||||
UINT32 Characteristics;
|
||||
UINT32 TimeDateStamp;
|
||||
UINT16 MajorVersion;
|
||||
UINT16 MinorVersion;
|
||||
UINT16 NumberOfNamedEntries;
|
||||
UINT16 NumberOfIdEntries;
|
||||
//
|
||||
// Array of EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY entries goes here.
|
||||
//
|
||||
} EFI_IMAGE_RESOURCE_DIRECTORY;
|
||||
|
||||
///
|
||||
/// Resource directory entry format.
|
||||
///
|
||||
typedef struct {
|
||||
union {
|
||||
struct {
|
||||
UINT32 NameOffset:31;
|
||||
UINT32 NameIsString:1;
|
||||
} s;
|
||||
UINT32 Id;
|
||||
} u1;
|
||||
union {
|
||||
UINT32 OffsetToData;
|
||||
struct {
|
||||
UINT32 OffsetToDirectory:31;
|
||||
UINT32 DataIsDirectory:1;
|
||||
} s;
|
||||
} u2;
|
||||
} EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY;
|
||||
|
||||
///
|
||||
/// Resource directory entry for string.
|
||||
///
|
||||
typedef struct {
|
||||
UINT16 Length;
|
||||
CHAR16 String[1];
|
||||
} EFI_IMAGE_RESOURCE_DIRECTORY_STRING;
|
||||
|
||||
///
|
||||
/// Resource directory entry for data array.
|
||||
///
|
||||
typedef struct {
|
||||
UINT32 OffsetToData;
|
||||
UINT32 Size;
|
||||
UINT32 CodePage;
|
||||
UINT32 Reserved;
|
||||
} EFI_IMAGE_RESOURCE_DATA_ENTRY;
|
||||
|
||||
///
|
||||
/// Header format for TE images, defined in the PI Specification, 1.0.
|
||||
///
|
||||
typedef struct {
|
||||
UINT16 Signature; ///< The signature for TE format = "VZ".
|
||||
UINT16 Machine; ///< From the original file header.
|
||||
UINT8 NumberOfSections; ///< From the original file header.
|
||||
UINT8 Subsystem; ///< From original optional header.
|
||||
UINT16 StrippedSize; ///< Number of bytes we removed from the header.
|
||||
UINT32 AddressOfEntryPoint; ///< Offset to entry point -- from original optional header.
|
||||
UINT32 BaseOfCode; ///< From original image -- required for ITP debug.
|
||||
UINT64 ImageBase; ///< From original file header.
|
||||
EFI_IMAGE_DATA_DIRECTORY DataDirectory[2]; ///< Only base relocation and debug directory.
|
||||
} EFI_TE_IMAGE_HEADER;
|
||||
|
||||
|
||||
#define EFI_TE_IMAGE_HEADER_SIGNATURE SIGNATURE_16('V', 'Z')
|
||||
|
||||
//
|
||||
// Data directory indexes in our TE image header
|
||||
//
|
||||
#define EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC 0
|
||||
#define EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG 1
|
||||
|
||||
|
||||
///
|
||||
/// Union of PE32, PE32+, and TE headers.
|
||||
///
|
||||
typedef union {
|
||||
EFI_IMAGE_NT_HEADERS32 Pe32;
|
||||
EFI_IMAGE_NT_HEADERS64 Pe32Plus;
|
||||
EFI_TE_IMAGE_HEADER Te;
|
||||
} EFI_IMAGE_OPTIONAL_HEADER_UNION;
|
||||
|
||||
typedef union {
|
||||
EFI_IMAGE_NT_HEADERS32 *Pe32;
|
||||
EFI_IMAGE_NT_HEADERS64 *Pe32Plus;
|
||||
EFI_TE_IMAGE_HEADER *Te;
|
||||
EFI_IMAGE_OPTIONAL_HEADER_UNION *Union;
|
||||
} EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION;
|
||||
|
||||
#endif
|
19
wimboot/wimboot-2.7.3/src/efi/ProcessorBind.h
Normal file
19
wimboot/wimboot-2.7.3/src/efi/ProcessorBind.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef _WIMBOOT_EFI_PROCESSOR_BIND_H
|
||||
#define _WIMBOOT_EFI_PROCESSOR_BIND_H
|
||||
|
||||
/*
|
||||
* EFI header files rely on having the CPU architecture directory
|
||||
* present in the search path in order to pick up ProcessorBind.h. We
|
||||
* use this header file as a quick indirection layer.
|
||||
*
|
||||
*/
|
||||
|
||||
#if __i386__
|
||||
#include <efi/Ia32/ProcessorBind.h>
|
||||
#endif
|
||||
|
||||
#if __x86_64__
|
||||
#include <efi/X64/ProcessorBind.h>
|
||||
#endif
|
||||
|
||||
#endif /* _WIMBOOT_EFI_PROCESSOR_BIND_H */
|
241
wimboot/wimboot-2.7.3/src/efi/Protocol/BlockIo.h
Normal file
241
wimboot/wimboot-2.7.3/src/efi/Protocol/BlockIo.h
Normal file
@@ -0,0 +1,241 @@
|
||||
/** @file
|
||||
Block IO protocol as defined in the UEFI 2.0 specification.
|
||||
|
||||
The Block IO protocol is used to abstract block devices like hard drives,
|
||||
DVD-ROMs and floppy drives.
|
||||
|
||||
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __BLOCK_IO_H__
|
||||
#define __BLOCK_IO_H__
|
||||
|
||||
#define EFI_BLOCK_IO_PROTOCOL_GUID \
|
||||
{ \
|
||||
0x964e5b21, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
|
||||
}
|
||||
|
||||
typedef struct _EFI_BLOCK_IO_PROTOCOL EFI_BLOCK_IO_PROTOCOL;
|
||||
|
||||
///
|
||||
/// Protocol GUID name defined in EFI1.1.
|
||||
///
|
||||
#define BLOCK_IO_PROTOCOL EFI_BLOCK_IO_PROTOCOL_GUID
|
||||
|
||||
///
|
||||
/// Protocol defined in EFI1.1.
|
||||
///
|
||||
typedef EFI_BLOCK_IO_PROTOCOL EFI_BLOCK_IO;
|
||||
|
||||
/**
|
||||
Reset the Block Device.
|
||||
|
||||
@param This Indicates a pointer to the calling context.
|
||||
@param ExtendedVerification Driver may perform diagnostics on reset.
|
||||
|
||||
@retval EFI_SUCCESS The device was reset.
|
||||
@retval EFI_DEVICE_ERROR The device is not functioning properly and could
|
||||
not be reset.
|
||||
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_BLOCK_RESET)(
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
||||
IN BOOLEAN ExtendedVerification
|
||||
);
|
||||
|
||||
/**
|
||||
Read BufferSize bytes from Lba into Buffer.
|
||||
|
||||
@param This Indicates a pointer to the calling context.
|
||||
@param MediaId Id of the media, changes every time the media is replaced.
|
||||
@param Lba The starting Logical Block Address to read from
|
||||
@param BufferSize Size of Buffer, must be a multiple of device block size.
|
||||
@param Buffer A pointer to the destination buffer for the data. The caller is
|
||||
responsible for either having implicit or explicit ownership of the buffer.
|
||||
|
||||
@retval EFI_SUCCESS The data was read correctly from the device.
|
||||
@retval EFI_DEVICE_ERROR The device reported an error while performing the read.
|
||||
@retval EFI_NO_MEDIA There is no media in the device.
|
||||
@retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.
|
||||
@retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
|
||||
@retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
|
||||
or the buffer is not on proper alignment.
|
||||
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_BLOCK_READ)(
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
||||
IN UINT32 MediaId,
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN BufferSize,
|
||||
OUT VOID *Buffer
|
||||
);
|
||||
|
||||
/**
|
||||
Write BufferSize bytes from Lba into Buffer.
|
||||
|
||||
@param This Indicates a pointer to the calling context.
|
||||
@param MediaId The media ID that the write request is for.
|
||||
@param Lba The starting logical block address to be written. The caller is
|
||||
responsible for writing to only legitimate locations.
|
||||
@param BufferSize Size of Buffer, must be a multiple of device block size.
|
||||
@param Buffer A pointer to the source buffer for the data.
|
||||
|
||||
@retval EFI_SUCCESS The data was written correctly to the device.
|
||||
@retval EFI_WRITE_PROTECTED The device can not be written to.
|
||||
@retval EFI_DEVICE_ERROR The device reported an error while performing the write.
|
||||
@retval EFI_NO_MEDIA There is no media in the device.
|
||||
@retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
|
||||
@retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
|
||||
@retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
|
||||
or the buffer is not on proper alignment.
|
||||
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_BLOCK_WRITE)(
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
||||
IN UINT32 MediaId,
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN BufferSize,
|
||||
IN VOID *Buffer
|
||||
);
|
||||
|
||||
/**
|
||||
Flush the Block Device.
|
||||
|
||||
@param This Indicates a pointer to the calling context.
|
||||
|
||||
@retval EFI_SUCCESS All outstanding data was written to the device
|
||||
@retval EFI_DEVICE_ERROR The device reported an error while writting back the data
|
||||
@retval EFI_NO_MEDIA There is no media in the device.
|
||||
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_BLOCK_FLUSH)(
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This
|
||||
);
|
||||
|
||||
/**
|
||||
Block IO read only mode data and updated only via members of BlockIO
|
||||
**/
|
||||
typedef struct {
|
||||
///
|
||||
/// The curent media Id. If the media changes, this value is changed.
|
||||
///
|
||||
UINT32 MediaId;
|
||||
|
||||
///
|
||||
/// TRUE if the media is removable; otherwise, FALSE.
|
||||
///
|
||||
BOOLEAN RemovableMedia;
|
||||
|
||||
///
|
||||
/// TRUE if there is a media currently present in the device;
|
||||
/// othersise, FALSE. THis field shows the media present status
|
||||
/// as of the most recent ReadBlocks() or WriteBlocks() call.
|
||||
///
|
||||
BOOLEAN MediaPresent;
|
||||
|
||||
///
|
||||
/// TRUE if LBA 0 is the first block of a partition; otherwise
|
||||
/// FALSE. For media with only one partition this would be TRUE.
|
||||
///
|
||||
BOOLEAN LogicalPartition;
|
||||
|
||||
///
|
||||
/// TRUE if the media is marked read-only otherwise, FALSE.
|
||||
/// This field shows the read-only status as of the most recent WriteBlocks () call.
|
||||
///
|
||||
BOOLEAN ReadOnly;
|
||||
|
||||
///
|
||||
/// TRUE if the WriteBlock () function caches write data.
|
||||
///
|
||||
BOOLEAN WriteCaching;
|
||||
|
||||
///
|
||||
/// The intrinsic block size of the device. If the media changes, then
|
||||
/// this field is updated.
|
||||
///
|
||||
UINT32 BlockSize;
|
||||
|
||||
///
|
||||
/// Supplies the alignment requirement for any buffer to read or write block(s).
|
||||
///
|
||||
UINT32 IoAlign;
|
||||
|
||||
///
|
||||
/// The last logical block address on the device.
|
||||
/// If the media changes, then this field is updated.
|
||||
///
|
||||
EFI_LBA LastBlock;
|
||||
|
||||
///
|
||||
/// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to
|
||||
/// EFI_BLOCK_IO_PROTOCOL_REVISION2. Returns the first LBA is aligned to
|
||||
/// a physical block boundary.
|
||||
///
|
||||
EFI_LBA LowestAlignedLba;
|
||||
|
||||
///
|
||||
/// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to
|
||||
/// EFI_BLOCK_IO_PROTOCOL_REVISION2. Returns the number of logical blocks
|
||||
/// per physical block.
|
||||
///
|
||||
UINT32 LogicalBlocksPerPhysicalBlock;
|
||||
|
||||
///
|
||||
/// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to
|
||||
/// EFI_BLOCK_IO_PROTOCOL_REVISION3. Returns the optimal transfer length
|
||||
/// granularity as a number of logical blocks.
|
||||
///
|
||||
UINT32 OptimalTransferLengthGranularity;
|
||||
} EFI_BLOCK_IO_MEDIA;
|
||||
|
||||
#define EFI_BLOCK_IO_PROTOCOL_REVISION 0x00010000
|
||||
#define EFI_BLOCK_IO_PROTOCOL_REVISION2 0x00020001
|
||||
#define EFI_BLOCK_IO_PROTOCOL_REVISION3 0x00020031
|
||||
|
||||
///
|
||||
/// Revision defined in EFI1.1.
|
||||
///
|
||||
#define EFI_BLOCK_IO_INTERFACE_REVISION EFI_BLOCK_IO_PROTOCOL_REVISION
|
||||
|
||||
///
|
||||
/// This protocol provides control over block devices.
|
||||
///
|
||||
struct _EFI_BLOCK_IO_PROTOCOL {
|
||||
///
|
||||
/// The revision to which the block IO interface adheres. All future
|
||||
/// revisions must be backwards compatible. If a future version is not
|
||||
/// back wards compatible, it is not the same GUID.
|
||||
///
|
||||
UINT64 Revision;
|
||||
///
|
||||
/// Pointer to the EFI_BLOCK_IO_MEDIA data for this device.
|
||||
///
|
||||
EFI_BLOCK_IO_MEDIA *Media;
|
||||
|
||||
EFI_BLOCK_RESET Reset;
|
||||
EFI_BLOCK_READ ReadBlocks;
|
||||
EFI_BLOCK_WRITE WriteBlocks;
|
||||
EFI_BLOCK_FLUSH FlushBlocks;
|
||||
|
||||
};
|
||||
|
||||
extern EFI_GUID gEfiBlockIoProtocolGuid;
|
||||
|
||||
#endif
|
1169
wimboot/wimboot-2.7.3/src/efi/Protocol/DevicePath.h
Normal file
1169
wimboot/wimboot-2.7.3/src/efi/Protocol/DevicePath.h
Normal file
File diff suppressed because it is too large
Load Diff
276
wimboot/wimboot-2.7.3/src/efi/Protocol/GraphicsOutput.h
Normal file
276
wimboot/wimboot-2.7.3/src/efi/Protocol/GraphicsOutput.h
Normal file
@@ -0,0 +1,276 @@
|
||||
/** @file
|
||||
Graphics Output Protocol from the UEFI 2.0 specification.
|
||||
|
||||
Abstraction of a very simple graphics device.
|
||||
|
||||
Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __GRAPHICS_OUTPUT_H__
|
||||
#define __GRAPHICS_OUTPUT_H__
|
||||
|
||||
#define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID \
|
||||
{ \
|
||||
0x9042a9de, 0x23dc, 0x4a38, {0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a } \
|
||||
}
|
||||
|
||||
typedef struct _EFI_GRAPHICS_OUTPUT_PROTOCOL EFI_GRAPHICS_OUTPUT_PROTOCOL;
|
||||
|
||||
typedef struct {
|
||||
UINT32 RedMask;
|
||||
UINT32 GreenMask;
|
||||
UINT32 BlueMask;
|
||||
UINT32 ReservedMask;
|
||||
} EFI_PIXEL_BITMASK;
|
||||
|
||||
typedef enum {
|
||||
///
|
||||
/// A pixel is 32-bits and byte zero represents red, byte one represents green,
|
||||
/// byte two represents blue, and byte three is reserved. This is the definition
|
||||
/// for the physical frame buffer. The byte values for the red, green, and blue
|
||||
/// components represent the color intensity. This color intensity value range
|
||||
/// from a minimum intensity of 0 to maximum intensity of 255.
|
||||
///
|
||||
PixelRedGreenBlueReserved8BitPerColor,
|
||||
///
|
||||
/// A pixel is 32-bits and byte zero represents blue, byte one represents green,
|
||||
/// byte two represents red, and byte three is reserved. This is the definition
|
||||
/// for the physical frame buffer. The byte values for the red, green, and blue
|
||||
/// components represent the color intensity. This color intensity value range
|
||||
/// from a minimum intensity of 0 to maximum intensity of 255.
|
||||
///
|
||||
PixelBlueGreenRedReserved8BitPerColor,
|
||||
///
|
||||
/// The Pixel definition of the physical frame buffer.
|
||||
///
|
||||
PixelBitMask,
|
||||
///
|
||||
/// This mode does not support a physical frame buffer.
|
||||
///
|
||||
PixelBltOnly,
|
||||
///
|
||||
/// Valid EFI_GRAPHICS_PIXEL_FORMAT enum values are less than this value.
|
||||
///
|
||||
PixelFormatMax
|
||||
} EFI_GRAPHICS_PIXEL_FORMAT;
|
||||
|
||||
typedef struct {
|
||||
///
|
||||
/// The version of this data structure. A value of zero represents the
|
||||
/// EFI_GRAPHICS_OUTPUT_MODE_INFORMATION structure as defined in this specification.
|
||||
///
|
||||
UINT32 Version;
|
||||
///
|
||||
/// The size of video screen in pixels in the X dimension.
|
||||
///
|
||||
UINT32 HorizontalResolution;
|
||||
///
|
||||
/// The size of video screen in pixels in the Y dimension.
|
||||
///
|
||||
UINT32 VerticalResolution;
|
||||
///
|
||||
/// Enumeration that defines the physical format of the pixel. A value of PixelBltOnly
|
||||
/// implies that a linear frame buffer is not available for this mode.
|
||||
///
|
||||
EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
|
||||
///
|
||||
/// This bit-mask is only valid if PixelFormat is set to PixelPixelBitMask.
|
||||
/// A bit being set defines what bits are used for what purpose such as Red, Green, Blue, or Reserved.
|
||||
///
|
||||
EFI_PIXEL_BITMASK PixelInformation;
|
||||
///
|
||||
/// Defines the number of pixel elements per video memory line.
|
||||
///
|
||||
UINT32 PixelsPerScanLine;
|
||||
} EFI_GRAPHICS_OUTPUT_MODE_INFORMATION;
|
||||
|
||||
/**
|
||||
Returns information for an available graphics mode that the graphics device
|
||||
and the set of active video output devices supports.
|
||||
|
||||
@param This The EFI_GRAPHICS_OUTPUT_PROTOCOL instance.
|
||||
@param ModeNumber The mode number to return information on.
|
||||
@param SizeOfInfo A pointer to the size, in bytes, of the Info buffer.
|
||||
@param Info A pointer to callee allocated buffer that returns information about ModeNumber.
|
||||
|
||||
@retval EFI_SUCCESS Valid mode information was returned.
|
||||
@retval EFI_DEVICE_ERROR A hardware error occurred trying to retrieve the video mode.
|
||||
@retval EFI_INVALID_PARAMETER ModeNumber is not valid.
|
||||
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_QUERY_MODE)(
|
||||
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
|
||||
IN UINT32 ModeNumber,
|
||||
OUT UINTN *SizeOfInfo,
|
||||
OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info
|
||||
);
|
||||
|
||||
/**
|
||||
Set the video device into the specified mode and clears the visible portions of
|
||||
the output display to black.
|
||||
|
||||
@param This The EFI_GRAPHICS_OUTPUT_PROTOCOL instance.
|
||||
@param ModeNumber Abstraction that defines the current video mode.
|
||||
|
||||
@retval EFI_SUCCESS The graphics mode specified by ModeNumber was selected.
|
||||
@retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
|
||||
@retval EFI_UNSUPPORTED ModeNumber is not supported by this device.
|
||||
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_SET_MODE)(
|
||||
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
|
||||
IN UINT32 ModeNumber
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
UINT8 Blue;
|
||||
UINT8 Green;
|
||||
UINT8 Red;
|
||||
UINT8 Reserved;
|
||||
} EFI_GRAPHICS_OUTPUT_BLT_PIXEL;
|
||||
|
||||
typedef union {
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Pixel;
|
||||
UINT32 Raw;
|
||||
} EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION;
|
||||
|
||||
///
|
||||
/// actions for BltOperations
|
||||
///
|
||||
typedef enum {
|
||||
///
|
||||
/// Write data from the BltBuffer pixel (0, 0)
|
||||
/// directly to every pixel of the video display rectangle
|
||||
/// (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height).
|
||||
/// Only one pixel will be used from the BltBuffer. Delta is NOT used.
|
||||
///
|
||||
EfiBltVideoFill,
|
||||
|
||||
///
|
||||
/// Read data from the video display rectangle
|
||||
/// (SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in
|
||||
/// the BltBuffer rectangle (DestinationX, DestinationY )
|
||||
/// (DestinationX + Width, DestinationY + Height). If DestinationX or
|
||||
/// DestinationY is not zero then Delta must be set to the length in bytes
|
||||
/// of a row in the BltBuffer.
|
||||
///
|
||||
EfiBltVideoToBltBuffer,
|
||||
|
||||
///
|
||||
/// Write data from the BltBuffer rectangle
|
||||
/// (SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the
|
||||
/// video display rectangle (DestinationX, DestinationY)
|
||||
/// (DestinationX + Width, DestinationY + Height). If SourceX or SourceY is
|
||||
/// not zero then Delta must be set to the length in bytes of a row in the
|
||||
/// BltBuffer.
|
||||
///
|
||||
EfiBltBufferToVideo,
|
||||
|
||||
///
|
||||
/// Copy from the video display rectangle (SourceX, SourceY)
|
||||
/// (SourceX + Width, SourceY + Height) to the video display rectangle
|
||||
/// (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height).
|
||||
/// The BltBuffer and Delta are not used in this mode.
|
||||
///
|
||||
EfiBltVideoToVideo,
|
||||
|
||||
EfiGraphicsOutputBltOperationMax
|
||||
} EFI_GRAPHICS_OUTPUT_BLT_OPERATION;
|
||||
|
||||
/**
|
||||
Blt a rectangle of pixels on the graphics screen. Blt stands for BLock Transfer.
|
||||
|
||||
@param This Protocol instance pointer.
|
||||
@param BltBuffer The data to transfer to the graphics screen.
|
||||
Size is at least Width*Height*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL).
|
||||
@param BltOperation The operation to perform when copying BltBuffer on to the graphics screen.
|
||||
@param SourceX The X coordinate of source for the BltOperation.
|
||||
@param SourceY The Y coordinate of source for the BltOperation.
|
||||
@param DestinationX The X coordinate of destination for the BltOperation.
|
||||
@param DestinationY The Y coordinate of destination for the BltOperation.
|
||||
@param Width The width of a rectangle in the blt rectangle in pixels.
|
||||
@param Height The height of a rectangle in the blt rectangle in pixels.
|
||||
@param Delta Not used for EfiBltVideoFill or the EfiBltVideoToVideo operation.
|
||||
If a Delta of zero is used, the entire BltBuffer is being operated on.
|
||||
If a subrectangle of the BltBuffer is being used then Delta
|
||||
represents the number of bytes in a row of the BltBuffer.
|
||||
|
||||
@retval EFI_SUCCESS BltBuffer was drawn to the graphics screen.
|
||||
@retval EFI_INVALID_PARAMETER BltOperation is not valid.
|
||||
@retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
|
||||
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_BLT)(
|
||||
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
|
||||
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL
|
||||
IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,
|
||||
IN UINTN SourceX,
|
||||
IN UINTN SourceY,
|
||||
IN UINTN DestinationX,
|
||||
IN UINTN DestinationY,
|
||||
IN UINTN Width,
|
||||
IN UINTN Height,
|
||||
IN UINTN Delta OPTIONAL
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
///
|
||||
/// The number of modes supported by QueryMode() and SetMode().
|
||||
///
|
||||
UINT32 MaxMode;
|
||||
///
|
||||
/// Current Mode of the graphics device. Valid mode numbers are 0 to MaxMode -1.
|
||||
///
|
||||
UINT32 Mode;
|
||||
///
|
||||
/// Pointer to read-only EFI_GRAPHICS_OUTPUT_MODE_INFORMATION data.
|
||||
///
|
||||
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
|
||||
///
|
||||
/// Size of Info structure in bytes.
|
||||
///
|
||||
UINTN SizeOfInfo;
|
||||
///
|
||||
/// Base address of graphics linear frame buffer.
|
||||
/// Offset zero in FrameBufferBase represents the upper left pixel of the display.
|
||||
///
|
||||
EFI_PHYSICAL_ADDRESS FrameBufferBase;
|
||||
///
|
||||
/// Amount of frame buffer needed to support the active mode as defined by
|
||||
/// PixelsPerScanLine xVerticalResolution x PixelElementSize.
|
||||
///
|
||||
UINTN FrameBufferSize;
|
||||
} EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE;
|
||||
|
||||
///
|
||||
/// Provides a basic abstraction to set video modes and copy pixels to and from
|
||||
/// the graphics controller's frame buffer. The linear address of the hardware
|
||||
/// frame buffer is also exposed so software can write directly to the video hardware.
|
||||
///
|
||||
struct _EFI_GRAPHICS_OUTPUT_PROTOCOL {
|
||||
EFI_GRAPHICS_OUTPUT_PROTOCOL_QUERY_MODE QueryMode;
|
||||
EFI_GRAPHICS_OUTPUT_PROTOCOL_SET_MODE SetMode;
|
||||
EFI_GRAPHICS_OUTPUT_PROTOCOL_BLT Blt;
|
||||
///
|
||||
/// Pointer to EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE data.
|
||||
///
|
||||
EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *Mode;
|
||||
};
|
||||
|
||||
extern EFI_GUID gEfiGraphicsOutputProtocolGuid;
|
||||
|
||||
#endif
|
88
wimboot/wimboot-2.7.3/src/efi/Protocol/LoadedImage.h
Normal file
88
wimboot/wimboot-2.7.3/src/efi/Protocol/LoadedImage.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/** @file
|
||||
UEFI 2.0 Loaded image protocol definition.
|
||||
|
||||
Every EFI driver and application is passed an image handle when it is loaded.
|
||||
This image handle will contain a Loaded Image Protocol.
|
||||
|
||||
Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __LOADED_IMAGE_PROTOCOL_H__
|
||||
#define __LOADED_IMAGE_PROTOCOL_H__
|
||||
|
||||
#define EFI_LOADED_IMAGE_PROTOCOL_GUID \
|
||||
{ \
|
||||
0x5B1B31A1, 0x9562, 0x11d2, {0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B } \
|
||||
}
|
||||
|
||||
#define EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID \
|
||||
{ \
|
||||
0xbc62157e, 0x3e33, 0x4fec, {0x99, 0x20, 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf } \
|
||||
}
|
||||
|
||||
///
|
||||
/// Protocol GUID defined in EFI1.1.
|
||||
///
|
||||
#define LOADED_IMAGE_PROTOCOL EFI_LOADED_IMAGE_PROTOCOL_GUID
|
||||
|
||||
///
|
||||
/// EFI_SYSTEM_TABLE & EFI_IMAGE_UNLOAD are defined in EfiApi.h
|
||||
///
|
||||
#define EFI_LOADED_IMAGE_PROTOCOL_REVISION 0x1000
|
||||
|
||||
///
|
||||
/// Revision defined in EFI1.1.
|
||||
///
|
||||
#define EFI_LOADED_IMAGE_INFORMATION_REVISION EFI_LOADED_IMAGE_PROTOCOL_REVISION
|
||||
|
||||
///
|
||||
/// Can be used on any image handle to obtain information about the loaded image.
|
||||
///
|
||||
typedef struct {
|
||||
UINT32 Revision; ///< Defines the revision of the EFI_LOADED_IMAGE_PROTOCOL structure.
|
||||
///< All future revisions will be backward compatible to the current revision.
|
||||
EFI_HANDLE ParentHandle; ///< Parent image's image handle. NULL if the image is loaded directly from
|
||||
///< the firmware's boot manager.
|
||||
EFI_SYSTEM_TABLE *SystemTable; ///< the image's EFI system table pointer.
|
||||
|
||||
//
|
||||
// Source location of image
|
||||
//
|
||||
EFI_HANDLE DeviceHandle; ///< The device handle that the EFI Image was loaded from.
|
||||
EFI_DEVICE_PATH_PROTOCOL *FilePath; ///< A pointer to the file path portion specific to DeviceHandle
|
||||
///< that the EFI Image was loaded from.
|
||||
VOID *Reserved; ///< Reserved. DO NOT USE.
|
||||
|
||||
//
|
||||
// Images load options
|
||||
//
|
||||
UINT32 LoadOptionsSize;///< The size in bytes of LoadOptions.
|
||||
VOID *LoadOptions; ///< A pointer to the image's binary load options.
|
||||
|
||||
//
|
||||
// Location of where image was loaded
|
||||
//
|
||||
VOID *ImageBase; ///< The base address at which the image was loaded.
|
||||
UINT64 ImageSize; ///< The size in bytes of the loaded image.
|
||||
EFI_MEMORY_TYPE ImageCodeType; ///< The memory type that the code sections were loaded as.
|
||||
EFI_MEMORY_TYPE ImageDataType; ///< The memory type that the data sections were loaded as.
|
||||
EFI_IMAGE_UNLOAD Unload;
|
||||
} EFI_LOADED_IMAGE_PROTOCOL;
|
||||
|
||||
//
|
||||
// For backward-compatible with EFI1.1.
|
||||
//
|
||||
typedef EFI_LOADED_IMAGE_PROTOCOL EFI_LOADED_IMAGE;
|
||||
|
||||
extern EFI_GUID gEfiLoadedImageProtocolGuid;
|
||||
extern EFI_GUID gEfiLoadedImageDevicePathProtocolGuid;
|
||||
|
||||
#endif
|
562
wimboot/wimboot-2.7.3/src/efi/Protocol/SimpleFileSystem.h
Normal file
562
wimboot/wimboot-2.7.3/src/efi/Protocol/SimpleFileSystem.h
Normal file
@@ -0,0 +1,562 @@
|
||||
/** @file
|
||||
SimpleFileSystem protocol as defined in the UEFI 2.0 specification.
|
||||
|
||||
The SimpleFileSystem protocol is the programmatic access to the FAT (12,16,32)
|
||||
file system specified in UEFI 2.0. It can also be used to abstract a file
|
||||
system other than FAT.
|
||||
|
||||
UEFI 2.0 can boot from any valid EFI image contained in a SimpleFileSystem.
|
||||
|
||||
Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials are licensed and made available under
|
||||
the terms and conditions of the BSD License that accompanies this distribution.
|
||||
The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php.
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __SIMPLE_FILE_SYSTEM_H__
|
||||
#define __SIMPLE_FILE_SYSTEM_H__
|
||||
|
||||
#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \
|
||||
{ \
|
||||
0x964e5b22, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
|
||||
}
|
||||
|
||||
typedef struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL EFI_SIMPLE_FILE_SYSTEM_PROTOCOL;
|
||||
|
||||
typedef struct _EFI_FILE_PROTOCOL EFI_FILE_PROTOCOL;
|
||||
typedef struct _EFI_FILE_PROTOCOL *EFI_FILE_HANDLE;
|
||||
|
||||
///
|
||||
/// Protocol GUID name defined in EFI1.1.
|
||||
///
|
||||
#define SIMPLE_FILE_SYSTEM_PROTOCOL EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID
|
||||
|
||||
///
|
||||
/// Protocol name defined in EFI1.1.
|
||||
///
|
||||
typedef EFI_SIMPLE_FILE_SYSTEM_PROTOCOL EFI_FILE_IO_INTERFACE;
|
||||
typedef EFI_FILE_PROTOCOL EFI_FILE;
|
||||
|
||||
/**
|
||||
Open the root directory on a volume.
|
||||
|
||||
@param This A pointer to the volume to open the root directory.
|
||||
@param Root A pointer to the location to return the opened file handle for the
|
||||
root directory.
|
||||
|
||||
@retval EFI_SUCCESS The device was opened.
|
||||
@retval EFI_UNSUPPORTED This volume does not support the requested file system type.
|
||||
@retval EFI_NO_MEDIA The device has no medium.
|
||||
@retval EFI_DEVICE_ERROR The device reported an error.
|
||||
@retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
|
||||
@retval EFI_ACCESS_DENIED The service denied access to the file.
|
||||
@retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of resources.
|
||||
@retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no
|
||||
longer supported. Any existing file handles for this volume are
|
||||
no longer valid. To access the files on the new medium, the
|
||||
volume must be reopened with OpenVolume().
|
||||
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_OPEN_VOLUME)(
|
||||
IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,
|
||||
OUT EFI_FILE_PROTOCOL **Root
|
||||
);
|
||||
|
||||
#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION 0x00010000
|
||||
|
||||
///
|
||||
/// Revision defined in EFI1.1
|
||||
///
|
||||
#define EFI_FILE_IO_INTERFACE_REVISION EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION
|
||||
|
||||
struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL {
|
||||
///
|
||||
/// The version of the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL. The version
|
||||
/// specified by this specification is 0x00010000. All future revisions
|
||||
/// must be backwards compatible.
|
||||
///
|
||||
UINT64 Revision;
|
||||
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_OPEN_VOLUME OpenVolume;
|
||||
};
|
||||
|
||||
/**
|
||||
Opens a new file relative to the source file's location.
|
||||
|
||||
@param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
|
||||
handle to the source location. This would typically be an open
|
||||
handle to a directory.
|
||||
@param NewHandle A pointer to the location to return the opened handle for the new
|
||||
file.
|
||||
@param FileName The Null-terminated string of the name of the file to be opened.
|
||||
The file name may contain the following path modifiers: "\", ".",
|
||||
and "..".
|
||||
@param OpenMode The mode to open the file. The only valid combinations that the
|
||||
file may be opened with are: Read, Read/Write, or Create/Read/Write.
|
||||
@param Attributes Only valid for EFI_FILE_MODE_CREATE, in which case these are the
|
||||
attribute bits for the newly created file.
|
||||
|
||||
@retval EFI_SUCCESS The file was opened.
|
||||
@retval EFI_NOT_FOUND The specified file could not be found on the device.
|
||||
@retval EFI_NO_MEDIA The device has no medium.
|
||||
@retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no
|
||||
longer supported.
|
||||
@retval EFI_DEVICE_ERROR The device reported an error.
|
||||
@retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
|
||||
@retval EFI_WRITE_PROTECTED An attempt was made to create a file, or open a file for write
|
||||
when the media is write-protected.
|
||||
@retval EFI_ACCESS_DENIED The service denied access to the file.
|
||||
@retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the file.
|
||||
@retval EFI_VOLUME_FULL The volume is full.
|
||||
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_FILE_OPEN)(
|
||||
IN EFI_FILE_PROTOCOL *This,
|
||||
OUT EFI_FILE_PROTOCOL **NewHandle,
|
||||
IN CHAR16 *FileName,
|
||||
IN UINT64 OpenMode,
|
||||
IN UINT64 Attributes
|
||||
);
|
||||
|
||||
//
|
||||
// Open modes
|
||||
//
|
||||
#define EFI_FILE_MODE_READ 0x0000000000000001ULL
|
||||
#define EFI_FILE_MODE_WRITE 0x0000000000000002ULL
|
||||
#define EFI_FILE_MODE_CREATE 0x8000000000000000ULL
|
||||
|
||||
//
|
||||
// File attributes
|
||||
//
|
||||
#define EFI_FILE_READ_ONLY 0x0000000000000001ULL
|
||||
#define EFI_FILE_HIDDEN 0x0000000000000002ULL
|
||||
#define EFI_FILE_SYSTEM 0x0000000000000004ULL
|
||||
#define EFI_FILE_RESERVED 0x0000000000000008ULL
|
||||
#define EFI_FILE_DIRECTORY 0x0000000000000010ULL
|
||||
#define EFI_FILE_ARCHIVE 0x0000000000000020ULL
|
||||
#define EFI_FILE_VALID_ATTR 0x0000000000000037ULL
|
||||
|
||||
/**
|
||||
Closes a specified file handle.
|
||||
|
||||
@param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
|
||||
handle to close.
|
||||
|
||||
@retval EFI_SUCCESS The file was closed.
|
||||
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_FILE_CLOSE)(
|
||||
IN EFI_FILE_PROTOCOL *This
|
||||
);
|
||||
|
||||
/**
|
||||
Close and delete the file handle.
|
||||
|
||||
@param This A pointer to the EFI_FILE_PROTOCOL instance that is the
|
||||
handle to the file to delete.
|
||||
|
||||
@retval EFI_SUCCESS The file was closed and deleted, and the handle was closed.
|
||||
@retval EFI_WARN_DELETE_FAILURE The handle was closed, but the file was not deleted.
|
||||
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_FILE_DELETE)(
|
||||
IN EFI_FILE_PROTOCOL *This
|
||||
);
|
||||
|
||||
/**
|
||||
Reads data from a file.
|
||||
|
||||
@param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
|
||||
handle to read data from.
|
||||
@param BufferSize On input, the size of the Buffer. On output, the amount of data
|
||||
returned in Buffer. In both cases, the size is measured in bytes.
|
||||
@param Buffer The buffer into which the data is read.
|
||||
|
||||
@retval EFI_SUCCESS Data was read.
|
||||
@retval EFI_NO_MEDIA The device has no medium.
|
||||
@retval EFI_DEVICE_ERROR The device reported an error.
|
||||
@retval EFI_DEVICE_ERROR An attempt was made to read from a deleted file.
|
||||
@retval EFI_DEVICE_ERROR On entry, the current file position is beyond the end of the file.
|
||||
@retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
|
||||
@retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to read the current directory
|
||||
entry. BufferSize has been updated with the size
|
||||
needed to complete the request.
|
||||
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_FILE_READ)(
|
||||
IN EFI_FILE_PROTOCOL *This,
|
||||
IN OUT UINTN *BufferSize,
|
||||
OUT VOID *Buffer
|
||||
);
|
||||
|
||||
/**
|
||||
Writes data to a file.
|
||||
|
||||
@param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
|
||||
handle to write data to.
|
||||
@param BufferSize On input, the size of the Buffer. On output, the amount of data
|
||||
actually written. In both cases, the size is measured in bytes.
|
||||
@param Buffer The buffer of data to write.
|
||||
|
||||
@retval EFI_SUCCESS Data was written.
|
||||
@retval EFI_UNSUPPORTED Writes to open directory files are not supported.
|
||||
@retval EFI_NO_MEDIA The device has no medium.
|
||||
@retval EFI_DEVICE_ERROR The device reported an error.
|
||||
@retval EFI_DEVICE_ERROR An attempt was made to write to a deleted file.
|
||||
@retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
|
||||
@retval EFI_WRITE_PROTECTED The file or medium is write-protected.
|
||||
@retval EFI_ACCESS_DENIED The file was opened read only.
|
||||
@retval EFI_VOLUME_FULL The volume is full.
|
||||
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_FILE_WRITE)(
|
||||
IN EFI_FILE_PROTOCOL *This,
|
||||
IN OUT UINTN *BufferSize,
|
||||
IN VOID *Buffer
|
||||
);
|
||||
|
||||
/**
|
||||
Sets a file's current position.
|
||||
|
||||
@param This A pointer to the EFI_FILE_PROTOCOL instance that is the
|
||||
file handle to set the requested position on.
|
||||
@param Position The byte position from the start of the file to set.
|
||||
|
||||
@retval EFI_SUCCESS The position was set.
|
||||
@retval EFI_UNSUPPORTED The seek request for nonzero is not valid on open
|
||||
directories.
|
||||
@retval EFI_DEVICE_ERROR An attempt was made to set the position of a deleted file.
|
||||
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_FILE_SET_POSITION)(
|
||||
IN EFI_FILE_PROTOCOL *This,
|
||||
IN UINT64 Position
|
||||
);
|
||||
|
||||
/**
|
||||
Returns a file's current position.
|
||||
|
||||
@param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
|
||||
handle to get the current position on.
|
||||
@param Position The address to return the file's current position value.
|
||||
|
||||
@retval EFI_SUCCESS The position was returned.
|
||||
@retval EFI_UNSUPPORTED The request is not valid on open directories.
|
||||
@retval EFI_DEVICE_ERROR An attempt was made to get the position from a deleted file.
|
||||
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_FILE_GET_POSITION)(
|
||||
IN EFI_FILE_PROTOCOL *This,
|
||||
OUT UINT64 *Position
|
||||
);
|
||||
|
||||
/**
|
||||
Returns information about a file.
|
||||
|
||||
@param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
|
||||
handle the requested information is for.
|
||||
@param InformationType The type identifier for the information being requested.
|
||||
@param BufferSize On input, the size of Buffer. On output, the amount of data
|
||||
returned in Buffer. In both cases, the size is measured in bytes.
|
||||
@param Buffer A pointer to the data buffer to return. The buffer's type is
|
||||
indicated by InformationType.
|
||||
|
||||
@retval EFI_SUCCESS The information was returned.
|
||||
@retval EFI_UNSUPPORTED The InformationType is not known.
|
||||
@retval EFI_NO_MEDIA The device has no medium.
|
||||
@retval EFI_DEVICE_ERROR The device reported an error.
|
||||
@retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
|
||||
@retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to read the current directory entry.
|
||||
BufferSize has been updated with the size needed to complete
|
||||
the request.
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_FILE_GET_INFO)(
|
||||
IN EFI_FILE_PROTOCOL *This,
|
||||
IN EFI_GUID *InformationType,
|
||||
IN OUT UINTN *BufferSize,
|
||||
OUT VOID *Buffer
|
||||
);
|
||||
|
||||
/**
|
||||
Sets information about a file.
|
||||
|
||||
@param File A pointer to the EFI_FILE_PROTOCOL instance that is the file
|
||||
handle the information is for.
|
||||
@param InformationType The type identifier for the information being set.
|
||||
@param BufferSize The size, in bytes, of Buffer.
|
||||
@param Buffer A pointer to the data buffer to write. The buffer's type is
|
||||
indicated by InformationType.
|
||||
|
||||
@retval EFI_SUCCESS The information was set.
|
||||
@retval EFI_UNSUPPORTED The InformationType is not known.
|
||||
@retval EFI_NO_MEDIA The device has no medium.
|
||||
@retval EFI_DEVICE_ERROR The device reported an error.
|
||||
@retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
|
||||
@retval EFI_WRITE_PROTECTED InformationType is EFI_FILE_INFO_ID and the media is
|
||||
read-only.
|
||||
@retval EFI_WRITE_PROTECTED InformationType is EFI_FILE_PROTOCOL_SYSTEM_INFO_ID
|
||||
and the media is read only.
|
||||
@retval EFI_WRITE_PROTECTED InformationType is EFI_FILE_SYSTEM_VOLUME_LABEL_ID
|
||||
and the media is read-only.
|
||||
@retval EFI_ACCESS_DENIED An attempt is made to change the name of a file to a
|
||||
file that is already present.
|
||||
@retval EFI_ACCESS_DENIED An attempt is being made to change the EFI_FILE_DIRECTORY
|
||||
Attribute.
|
||||
@retval EFI_ACCESS_DENIED An attempt is being made to change the size of a directory.
|
||||
@retval EFI_ACCESS_DENIED InformationType is EFI_FILE_INFO_ID and the file was opened
|
||||
read-only and an attempt is being made to modify a field
|
||||
other than Attribute.
|
||||
@retval EFI_VOLUME_FULL The volume is full.
|
||||
@retval EFI_BAD_BUFFER_SIZE BufferSize is smaller than the size of the type indicated
|
||||
by InformationType.
|
||||
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_FILE_SET_INFO)(
|
||||
IN EFI_FILE_PROTOCOL *This,
|
||||
IN EFI_GUID *InformationType,
|
||||
IN UINTN BufferSize,
|
||||
IN VOID *Buffer
|
||||
);
|
||||
|
||||
/**
|
||||
Flushes all modified data associated with a file to a device.
|
||||
|
||||
@param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
|
||||
handle to flush.
|
||||
|
||||
@retval EFI_SUCCESS The data was flushed.
|
||||
@retval EFI_NO_MEDIA The device has no medium.
|
||||
@retval EFI_DEVICE_ERROR The device reported an error.
|
||||
@retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
|
||||
@retval EFI_WRITE_PROTECTED The file or medium is write-protected.
|
||||
@retval EFI_ACCESS_DENIED The file was opened read-only.
|
||||
@retval EFI_VOLUME_FULL The volume is full.
|
||||
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_FILE_FLUSH)(
|
||||
IN EFI_FILE_PROTOCOL *This
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
//
|
||||
// If Event is NULL, then blocking I/O is performed.
|
||||
// If Event is not NULL and non-blocking I/O is supported, then non-blocking I/O is performed,
|
||||
// and Event will be signaled when the read request is completed.
|
||||
// The caller must be prepared to handle the case where the callback associated with Event
|
||||
// occurs before the original asynchronous I/O request call returns.
|
||||
//
|
||||
EFI_EVENT Event;
|
||||
|
||||
//
|
||||
// Defines whether or not the signaled event encountered an error.
|
||||
//
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// For OpenEx(): Not Used, ignored.
|
||||
// For ReadEx(): On input, the size of the Buffer. On output, the amount of data returned in Buffer.
|
||||
// In both cases, the size is measured in bytes.
|
||||
// For WriteEx(): On input, the size of the Buffer. On output, the amount of data actually written.
|
||||
// In both cases, the size is measured in bytes.
|
||||
// For FlushEx(): Not used, ignored.
|
||||
//
|
||||
UINTN BufferSize;
|
||||
|
||||
//
|
||||
// For OpenEx(): Not Used, ignored.
|
||||
// For ReadEx(): The buffer into which the data is read.
|
||||
// For WriteEx(): The buffer of data to write.
|
||||
// For FlushEx(): Not Used, ignored.
|
||||
//
|
||||
VOID *Buffer;
|
||||
} EFI_FILE_IO_TOKEN;
|
||||
|
||||
/**
|
||||
Opens a new file relative to the source directory's location.
|
||||
|
||||
@param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
|
||||
handle to the source location.
|
||||
@param NewHandle A pointer to the location to return the opened handle for the new
|
||||
file.
|
||||
@param FileName The Null-terminated string of the name of the file to be opened.
|
||||
The file name may contain the following path modifiers: "\", ".",
|
||||
and "..".
|
||||
@param OpenMode The mode to open the file. The only valid combinations that the
|
||||
file may be opened with are: Read, Read/Write, or Create/Read/Write.
|
||||
@param Attributes Only valid for EFI_FILE_MODE_CREATE, in which case these are the
|
||||
attribute bits for the newly created file.
|
||||
@param Token A pointer to the token associated with the transaction.
|
||||
|
||||
@retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was read successfully.
|
||||
If Event is not NULL (asynchronous I/O): The request was successfully
|
||||
queued for processing.
|
||||
@retval EFI_NOT_FOUND The specified file could not be found on the device.
|
||||
@retval EFI_NO_MEDIA The device has no medium.
|
||||
@retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no
|
||||
longer supported.
|
||||
@retval EFI_DEVICE_ERROR The device reported an error.
|
||||
@retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
|
||||
@retval EFI_WRITE_PROTECTED An attempt was made to create a file, or open a file for write
|
||||
when the media is write-protected.
|
||||
@retval EFI_ACCESS_DENIED The service denied access to the file.
|
||||
@retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the file.
|
||||
@retval EFI_VOLUME_FULL The volume is full.
|
||||
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_FILE_OPEN_EX)(
|
||||
IN EFI_FILE_PROTOCOL *This,
|
||||
OUT EFI_FILE_PROTOCOL **NewHandle,
|
||||
IN CHAR16 *FileName,
|
||||
IN UINT64 OpenMode,
|
||||
IN UINT64 Attributes,
|
||||
IN OUT EFI_FILE_IO_TOKEN *Token
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Reads data from a file.
|
||||
|
||||
@param This A pointer to the EFI_FILE_PROTOCOL instance that is the file handle to read data from.
|
||||
@param Token A pointer to the token associated with the transaction.
|
||||
|
||||
@retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was read successfully.
|
||||
If Event is not NULL (asynchronous I/O): The request was successfully
|
||||
queued for processing.
|
||||
@retval EFI_NO_MEDIA The device has no medium.
|
||||
@retval EFI_DEVICE_ERROR The device reported an error.
|
||||
@retval EFI_DEVICE_ERROR An attempt was made to read from a deleted file.
|
||||
@retval EFI_DEVICE_ERROR On entry, the current file position is beyond the end of the file.
|
||||
@retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
|
||||
@retval EFI_OUT_OF_RESOURCES Unable to queue the request due to lack of resources.
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_FILE_READ_EX) (
|
||||
IN EFI_FILE_PROTOCOL *This,
|
||||
IN OUT EFI_FILE_IO_TOKEN *Token
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Writes data to a file.
|
||||
|
||||
@param This A pointer to the EFI_FILE_PROTOCOL instance that is the file handle to write data to.
|
||||
@param Token A pointer to the token associated with the transaction.
|
||||
|
||||
@retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was read successfully.
|
||||
If Event is not NULL (asynchronous I/O): The request was successfully
|
||||
queued for processing.
|
||||
@retval EFI_UNSUPPORTED Writes to open directory files are not supported.
|
||||
@retval EFI_NO_MEDIA The device has no medium.
|
||||
@retval EFI_DEVICE_ERROR The device reported an error.
|
||||
@retval EFI_DEVICE_ERROR An attempt was made to write to a deleted file.
|
||||
@retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
|
||||
@retval EFI_WRITE_PROTECTED The file or medium is write-protected.
|
||||
@retval EFI_ACCESS_DENIED The file was opened read only.
|
||||
@retval EFI_VOLUME_FULL The volume is full.
|
||||
@retval EFI_OUT_OF_RESOURCES Unable to queue the request due to lack of resources.
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_FILE_WRITE_EX) (
|
||||
IN EFI_FILE_PROTOCOL *This,
|
||||
IN OUT EFI_FILE_IO_TOKEN *Token
|
||||
);
|
||||
|
||||
/**
|
||||
Flushes all modified data associated with a file to a device.
|
||||
|
||||
@param This A pointer to the EFI_FILE_PROTOCOL instance that is the file
|
||||
handle to flush.
|
||||
@param Token A pointer to the token associated with the transaction.
|
||||
|
||||
@retval EFI_SUCCESS If Event is NULL (blocking I/O): The data was read successfully.
|
||||
If Event is not NULL (asynchronous I/O): The request was successfully
|
||||
queued for processing.
|
||||
@retval EFI_NO_MEDIA The device has no medium.
|
||||
@retval EFI_DEVICE_ERROR The device reported an error.
|
||||
@retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
|
||||
@retval EFI_WRITE_PROTECTED The file or medium is write-protected.
|
||||
@retval EFI_ACCESS_DENIED The file was opened read-only.
|
||||
@retval EFI_VOLUME_FULL The volume is full.
|
||||
@retval EFI_OUT_OF_RESOURCES Unable to queue the request due to lack of resources.
|
||||
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_FILE_FLUSH_EX) (
|
||||
IN EFI_FILE_PROTOCOL *This,
|
||||
IN OUT EFI_FILE_IO_TOKEN *Token
|
||||
);
|
||||
|
||||
#define EFI_FILE_PROTOCOL_REVISION 0x00010000
|
||||
#define EFI_FILE_PROTOCOL_REVISION2 0x00020000
|
||||
#define EFI_FILE_PROTOCOL_LATEST_REVISION EFI_FILE_PROTOCOL_REVISION2
|
||||
|
||||
//
|
||||
// Revision defined in EFI1.1.
|
||||
//
|
||||
#define EFI_FILE_REVISION EFI_FILE_PROTOCOL_REVISION
|
||||
|
||||
///
|
||||
/// The EFI_FILE_PROTOCOL provides file IO access to supported file systems.
|
||||
/// An EFI_FILE_PROTOCOL provides access to a file's or directory's contents,
|
||||
/// and is also a reference to a location in the directory tree of the file system
|
||||
/// in which the file resides. With any given file handle, other files may be opened
|
||||
/// relative to this file's location, yielding new file handles.
|
||||
///
|
||||
struct _EFI_FILE_PROTOCOL {
|
||||
///
|
||||
/// The version of the EFI_FILE_PROTOCOL interface. The version specified
|
||||
/// by this specification is EFI_FILE_PROTOCOL_LATEST_REVISION.
|
||||
/// Future versions are required to be backward compatible to version 1.0.
|
||||
///
|
||||
UINT64 Revision;
|
||||
EFI_FILE_OPEN Open;
|
||||
EFI_FILE_CLOSE Close;
|
||||
EFI_FILE_DELETE Delete;
|
||||
EFI_FILE_READ Read;
|
||||
EFI_FILE_WRITE Write;
|
||||
EFI_FILE_GET_POSITION GetPosition;
|
||||
EFI_FILE_SET_POSITION SetPosition;
|
||||
EFI_FILE_GET_INFO GetInfo;
|
||||
EFI_FILE_SET_INFO SetInfo;
|
||||
EFI_FILE_FLUSH Flush;
|
||||
EFI_FILE_OPEN_EX OpenEx;
|
||||
EFI_FILE_READ_EX ReadEx;
|
||||
EFI_FILE_WRITE_EX WriteEx;
|
||||
EFI_FILE_FLUSH_EX FlushEx;
|
||||
};
|
||||
|
||||
|
||||
extern EFI_GUID gEfiSimpleFileSystemProtocolGuid;
|
||||
|
||||
#endif
|
134
wimboot/wimboot-2.7.3/src/efi/Protocol/SimpleTextIn.h
Normal file
134
wimboot/wimboot-2.7.3/src/efi/Protocol/SimpleTextIn.h
Normal file
@@ -0,0 +1,134 @@
|
||||
/** @file
|
||||
Simple Text Input protocol from the UEFI 2.0 specification.
|
||||
|
||||
Abstraction of a very simple input device like a keyboard or serial
|
||||
terminal.
|
||||
|
||||
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __SIMPLE_TEXT_IN_PROTOCOL_H__
|
||||
#define __SIMPLE_TEXT_IN_PROTOCOL_H__
|
||||
|
||||
#define EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID \
|
||||
{ \
|
||||
0x387477c1, 0x69c7, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
|
||||
}
|
||||
|
||||
typedef struct _EFI_SIMPLE_TEXT_INPUT_PROTOCOL EFI_SIMPLE_TEXT_INPUT_PROTOCOL;
|
||||
|
||||
///
|
||||
/// Protocol GUID name defined in EFI1.1.
|
||||
///
|
||||
#define SIMPLE_INPUT_PROTOCOL EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID
|
||||
|
||||
///
|
||||
/// Protocol name in EFI1.1 for backward-compatible.
|
||||
///
|
||||
typedef struct _EFI_SIMPLE_TEXT_INPUT_PROTOCOL SIMPLE_INPUT_INTERFACE;
|
||||
|
||||
///
|
||||
/// The keystroke information for the key that was pressed.
|
||||
///
|
||||
typedef struct {
|
||||
UINT16 ScanCode;
|
||||
CHAR16 UnicodeChar;
|
||||
} EFI_INPUT_KEY;
|
||||
|
||||
//
|
||||
// Required unicode control chars
|
||||
//
|
||||
#define CHAR_NULL 0x0000
|
||||
#define CHAR_BACKSPACE 0x0008
|
||||
#define CHAR_TAB 0x0009
|
||||
#define CHAR_LINEFEED 0x000A
|
||||
#define CHAR_CARRIAGE_RETURN 0x000D
|
||||
|
||||
//
|
||||
// EFI Scan codes
|
||||
//
|
||||
#define SCAN_NULL 0x0000
|
||||
#define SCAN_UP 0x0001
|
||||
#define SCAN_DOWN 0x0002
|
||||
#define SCAN_RIGHT 0x0003
|
||||
#define SCAN_LEFT 0x0004
|
||||
#define SCAN_HOME 0x0005
|
||||
#define SCAN_END 0x0006
|
||||
#define SCAN_INSERT 0x0007
|
||||
#define SCAN_DELETE 0x0008
|
||||
#define SCAN_PAGE_UP 0x0009
|
||||
#define SCAN_PAGE_DOWN 0x000A
|
||||
#define SCAN_F1 0x000B
|
||||
#define SCAN_F2 0x000C
|
||||
#define SCAN_F3 0x000D
|
||||
#define SCAN_F4 0x000E
|
||||
#define SCAN_F5 0x000F
|
||||
#define SCAN_F6 0x0010
|
||||
#define SCAN_F7 0x0011
|
||||
#define SCAN_F8 0x0012
|
||||
#define SCAN_F9 0x0013
|
||||
#define SCAN_F10 0x0014
|
||||
#define SCAN_ESC 0x0017
|
||||
|
||||
/**
|
||||
Reset the input device and optionally run diagnostics
|
||||
|
||||
@param This Protocol instance pointer.
|
||||
@param ExtendedVerification Driver may perform diagnostics on reset.
|
||||
|
||||
@retval EFI_SUCCESS The device was reset.
|
||||
@retval EFI_DEVICE_ERROR The device is not functioning properly and could not be reset.
|
||||
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_INPUT_RESET)(
|
||||
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
|
||||
IN BOOLEAN ExtendedVerification
|
||||
);
|
||||
|
||||
/**
|
||||
Reads the next keystroke from the input device. The WaitForKey Event can
|
||||
be used to test for existence of a keystroke via WaitForEvent () call.
|
||||
|
||||
@param This Protocol instance pointer.
|
||||
@param Key A pointer to a buffer that is filled in with the keystroke
|
||||
information for the key that was pressed.
|
||||
|
||||
@retval EFI_SUCCESS The keystroke information was returned.
|
||||
@retval EFI_NOT_READY There was no keystroke data available.
|
||||
@retval EFI_DEVICE_ERROR The keystroke information was not returned due to
|
||||
hardware errors.
|
||||
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_INPUT_READ_KEY)(
|
||||
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
|
||||
OUT EFI_INPUT_KEY *Key
|
||||
);
|
||||
|
||||
///
|
||||
/// The EFI_SIMPLE_TEXT_INPUT_PROTOCOL is used on the ConsoleIn device.
|
||||
/// It is the minimum required protocol for ConsoleIn.
|
||||
///
|
||||
struct _EFI_SIMPLE_TEXT_INPUT_PROTOCOL {
|
||||
EFI_INPUT_RESET Reset;
|
||||
EFI_INPUT_READ_KEY ReadKeyStroke;
|
||||
///
|
||||
/// Event to use with WaitForEvent() to wait for a key to be available
|
||||
///
|
||||
EFI_EVENT WaitForKey;
|
||||
};
|
||||
|
||||
extern EFI_GUID gEfiSimpleTextInProtocolGuid;
|
||||
|
||||
#endif
|
325
wimboot/wimboot-2.7.3/src/efi/Protocol/SimpleTextInEx.h
Normal file
325
wimboot/wimboot-2.7.3/src/efi/Protocol/SimpleTextInEx.h
Normal file
@@ -0,0 +1,325 @@
|
||||
/** @file
|
||||
Simple Text Input Ex protocol from the UEFI 2.0 specification.
|
||||
|
||||
This protocol defines an extension to the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
|
||||
which exposes much more state and modifier information from the input device,
|
||||
also allows one to register a notification for a particular keystroke.
|
||||
|
||||
Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __SIMPLE_TEXT_IN_EX_H__
|
||||
#define __SIMPLE_TEXT_IN_EX_H__
|
||||
|
||||
#include "efi/Protocol/SimpleTextIn.h"
|
||||
|
||||
#define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \
|
||||
{0xdd9e7534, 0x7762, 0x4698, { 0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa } }
|
||||
|
||||
|
||||
typedef struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL;
|
||||
|
||||
/**
|
||||
The Reset() function resets the input device hardware. As part
|
||||
of initialization process, the firmware/device will make a quick
|
||||
but reasonable attempt to verify that the device is functioning.
|
||||
If the ExtendedVerification flag is TRUE the firmware may take
|
||||
an extended amount of time to verify the device is operating on
|
||||
reset. Otherwise the reset operation is to occur as quickly as
|
||||
possible. The hardware verification process is not defined by
|
||||
this specification and is left up to the platform firmware or
|
||||
driver to implement.
|
||||
|
||||
@param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
|
||||
|
||||
@param ExtendedVerification Indicates that the driver may
|
||||
perform a more exhaustive
|
||||
verification operation of the
|
||||
device during reset.
|
||||
|
||||
|
||||
@retval EFI_SUCCESS The device was reset.
|
||||
|
||||
@retval EFI_DEVICE_ERROR The device is not functioning
|
||||
correctly and could not be reset.
|
||||
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_INPUT_RESET_EX)(
|
||||
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
|
||||
IN BOOLEAN ExtendedVerification
|
||||
);
|
||||
|
||||
|
||||
///
|
||||
/// EFI_KEY_TOGGLE_STATE. The toggle states are defined.
|
||||
/// They are: EFI_TOGGLE_STATE_VALID, EFI_SCROLL_LOCK_ACTIVE
|
||||
/// EFI_NUM_LOCK_ACTIVE, EFI_CAPS_LOCK_ACTIVE
|
||||
///
|
||||
typedef UINT8 EFI_KEY_TOGGLE_STATE;
|
||||
|
||||
typedef struct _EFI_KEY_STATE {
|
||||
///
|
||||
/// Reflects the currently pressed shift
|
||||
/// modifiers for the input device. The
|
||||
/// returned value is valid only if the high
|
||||
/// order bit has been set.
|
||||
///
|
||||
UINT32 KeyShiftState;
|
||||
///
|
||||
/// Reflects the current internal state of
|
||||
/// various toggled attributes. The returned
|
||||
/// value is valid only if the high order
|
||||
/// bit has been set.
|
||||
///
|
||||
EFI_KEY_TOGGLE_STATE KeyToggleState;
|
||||
} EFI_KEY_STATE;
|
||||
|
||||
typedef struct {
|
||||
///
|
||||
/// The EFI scan code and Unicode value returned from the input device.
|
||||
///
|
||||
EFI_INPUT_KEY Key;
|
||||
///
|
||||
/// The current state of various toggled attributes as well as input modifier values.
|
||||
///
|
||||
EFI_KEY_STATE KeyState;
|
||||
} EFI_KEY_DATA;
|
||||
|
||||
//
|
||||
// Any Shift or Toggle State that is valid should have
|
||||
// high order bit set.
|
||||
//
|
||||
// Shift state
|
||||
//
|
||||
#define EFI_SHIFT_STATE_VALID 0x80000000
|
||||
#define EFI_RIGHT_SHIFT_PRESSED 0x00000001
|
||||
#define EFI_LEFT_SHIFT_PRESSED 0x00000002
|
||||
#define EFI_RIGHT_CONTROL_PRESSED 0x00000004
|
||||
#define EFI_LEFT_CONTROL_PRESSED 0x00000008
|
||||
#define EFI_RIGHT_ALT_PRESSED 0x00000010
|
||||
#define EFI_LEFT_ALT_PRESSED 0x00000020
|
||||
#define EFI_RIGHT_LOGO_PRESSED 0x00000040
|
||||
#define EFI_LEFT_LOGO_PRESSED 0x00000080
|
||||
#define EFI_MENU_KEY_PRESSED 0x00000100
|
||||
#define EFI_SYS_REQ_PRESSED 0x00000200
|
||||
|
||||
//
|
||||
// Toggle state
|
||||
//
|
||||
#define EFI_TOGGLE_STATE_VALID 0x80
|
||||
#define EFI_KEY_STATE_EXPOSED 0x40
|
||||
#define EFI_SCROLL_LOCK_ACTIVE 0x01
|
||||
#define EFI_NUM_LOCK_ACTIVE 0x02
|
||||
#define EFI_CAPS_LOCK_ACTIVE 0x04
|
||||
|
||||
//
|
||||
// EFI Scan codes
|
||||
//
|
||||
#define SCAN_F11 0x0015
|
||||
#define SCAN_F12 0x0016
|
||||
#define SCAN_PAUSE 0x0048
|
||||
#define SCAN_F13 0x0068
|
||||
#define SCAN_F14 0x0069
|
||||
#define SCAN_F15 0x006A
|
||||
#define SCAN_F16 0x006B
|
||||
#define SCAN_F17 0x006C
|
||||
#define SCAN_F18 0x006D
|
||||
#define SCAN_F19 0x006E
|
||||
#define SCAN_F20 0x006F
|
||||
#define SCAN_F21 0x0070
|
||||
#define SCAN_F22 0x0071
|
||||
#define SCAN_F23 0x0072
|
||||
#define SCAN_F24 0x0073
|
||||
#define SCAN_MUTE 0x007F
|
||||
#define SCAN_VOLUME_UP 0x0080
|
||||
#define SCAN_VOLUME_DOWN 0x0081
|
||||
#define SCAN_BRIGHTNESS_UP 0x0100
|
||||
#define SCAN_BRIGHTNESS_DOWN 0x0101
|
||||
#define SCAN_SUSPEND 0x0102
|
||||
#define SCAN_HIBERNATE 0x0103
|
||||
#define SCAN_TOGGLE_DISPLAY 0x0104
|
||||
#define SCAN_RECOVERY 0x0105
|
||||
#define SCAN_EJECT 0x0106
|
||||
|
||||
/**
|
||||
The function reads the next keystroke from the input device. If
|
||||
there is no pending keystroke the function returns
|
||||
EFI_NOT_READY. If there is a pending keystroke, then
|
||||
KeyData.Key.ScanCode is the EFI scan code defined in Error!
|
||||
Reference source not found. The KeyData.Key.UnicodeChar is the
|
||||
actual printable character or is zero if the key does not
|
||||
represent a printable character (control key, function key,
|
||||
etc.). The KeyData.KeyState is shift state for the character
|
||||
reflected in KeyData.Key.UnicodeChar or KeyData.Key.ScanCode .
|
||||
When interpreting the data from this function, it should be
|
||||
noted that if a class of printable characters that are
|
||||
normally adjusted by shift modifiers (e.g. Shift Key + "f"
|
||||
key) would be presented solely as a KeyData.Key.UnicodeChar
|
||||
without the associated shift state. So in the previous example
|
||||
of a Shift Key + "f" key being pressed, the only pertinent
|
||||
data returned would be KeyData.Key.UnicodeChar with the value
|
||||
of "F". This of course would not typically be the case for
|
||||
non-printable characters such as the pressing of the Right
|
||||
Shift Key + F10 key since the corresponding returned data
|
||||
would be reflected both in the KeyData.KeyState.KeyShiftState
|
||||
and KeyData.Key.ScanCode values. UEFI drivers which implement
|
||||
the EFI_SIMPLE_TEXT_INPUT_EX protocol are required to return
|
||||
KeyData.Key and KeyData.KeyState values. These drivers must
|
||||
always return the most current state of
|
||||
KeyData.KeyState.KeyShiftState and
|
||||
KeyData.KeyState.KeyToggleState. It should also be noted that
|
||||
certain input devices may not be able to produce shift or toggle
|
||||
state information, and in those cases the high order bit in the
|
||||
respective Toggle and Shift state fields should not be active.
|
||||
|
||||
|
||||
@param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
|
||||
|
||||
@param KeyData A pointer to a buffer that is filled in with
|
||||
the keystroke state data for the key that was
|
||||
pressed.
|
||||
|
||||
|
||||
@retval EFI_SUCCESS The keystroke information was
|
||||
returned.
|
||||
|
||||
@retval EFI_NOT_READY There was no keystroke data available.
|
||||
EFI_DEVICE_ERROR The keystroke
|
||||
information was not returned due to
|
||||
hardware errors.
|
||||
|
||||
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_INPUT_READ_KEY_EX)(
|
||||
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
|
||||
OUT EFI_KEY_DATA *KeyData
|
||||
);
|
||||
|
||||
/**
|
||||
The SetState() function allows the input device hardware to
|
||||
have state settings adjusted.
|
||||
|
||||
@param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
|
||||
|
||||
@param KeyToggleState Pointer to the EFI_KEY_TOGGLE_STATE to
|
||||
set the state for the input device.
|
||||
|
||||
|
||||
@retval EFI_SUCCESS The device state was set appropriately.
|
||||
|
||||
@retval EFI_DEVICE_ERROR The device is not functioning
|
||||
correctly and could not have the
|
||||
setting adjusted.
|
||||
|
||||
@retval EFI_UNSUPPORTED The device does not support the
|
||||
ability to have its state set.
|
||||
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_SET_STATE)(
|
||||
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
|
||||
IN EFI_KEY_TOGGLE_STATE *KeyToggleState
|
||||
);
|
||||
|
||||
///
|
||||
/// The function will be called when the key sequence is typed specified by KeyData.
|
||||
///
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_KEY_NOTIFY_FUNCTION)(
|
||||
IN EFI_KEY_DATA *KeyData
|
||||
);
|
||||
|
||||
/**
|
||||
The RegisterKeystrokeNotify() function registers a function
|
||||
which will be called when a specified keystroke will occur.
|
||||
|
||||
@param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
|
||||
|
||||
@param KeyData A pointer to a buffer that is filled in with
|
||||
the keystroke information for the key that was
|
||||
pressed.
|
||||
|
||||
@param KeyNotificationFunction Points to the function to be
|
||||
called when the key sequence
|
||||
is typed specified by KeyData.
|
||||
|
||||
|
||||
@param NotifyHandle Points to the unique handle assigned to
|
||||
the registered notification.
|
||||
|
||||
@retval EFI_SUCCESS The device state was set
|
||||
appropriately.
|
||||
|
||||
@retval EFI_OUT_OF_RESOURCES Unable to allocate necessary
|
||||
data structures.
|
||||
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_REGISTER_KEYSTROKE_NOTIFY)(
|
||||
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
|
||||
IN EFI_KEY_DATA *KeyData,
|
||||
IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction,
|
||||
OUT VOID **NotifyHandle
|
||||
);
|
||||
|
||||
/**
|
||||
The UnregisterKeystrokeNotify() function removes the
|
||||
notification which was previously registered.
|
||||
|
||||
@param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
|
||||
|
||||
@param NotificationHandle The handle of the notification
|
||||
function being unregistered.
|
||||
|
||||
@retval EFI_SUCCESS The device state was set appropriately.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER The NotificationHandle is
|
||||
invalid.
|
||||
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI *EFI_UNREGISTER_KEYSTROKE_NOTIFY)(
|
||||
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
|
||||
IN VOID *NotificationHandle
|
||||
);
|
||||
|
||||
|
||||
///
|
||||
/// The EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL is used on the ConsoleIn
|
||||
/// device. It is an extension to the Simple Text Input protocol
|
||||
/// which allows a variety of extended shift state information to be
|
||||
/// returned.
|
||||
///
|
||||
struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL{
|
||||
EFI_INPUT_RESET_EX Reset;
|
||||
EFI_INPUT_READ_KEY_EX ReadKeyStrokeEx;
|
||||
///
|
||||
/// Event to use with WaitForEvent() to wait for a key to be available.
|
||||
///
|
||||
EFI_EVENT WaitForKeyEx;
|
||||
EFI_SET_STATE SetState;
|
||||
EFI_REGISTER_KEYSTROKE_NOTIFY RegisterKeyNotify;
|
||||
EFI_UNREGISTER_KEYSTROKE_NOTIFY UnregisterKeyNotify;
|
||||
};
|
||||
|
||||
|
||||
extern EFI_GUID gEfiSimpleTextInputExProtocolGuid;
|
||||
|
||||
#endif
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user