Linux and Windows platform fixes
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
#include "Platform.h"
|
||||
#include <unistd.h>
|
||||
#include <sys/reboot.h>
|
||||
|
||||
void Platform::Initialize()
|
||||
{
|
||||
// TODO: root permission check here
|
||||
extern "C" {
|
||||
#include <efivar.h>
|
||||
}
|
||||
|
||||
void Platform::Initialize() { }
|
||||
|
||||
bool Platform::UEFICheck()
|
||||
{
|
||||
return efi_variables_supported();
|
||||
|
||||
@@ -62,7 +62,7 @@ std::pair<std::uint8_t*, std::size_t> Platform::UEFIReadVariable(const std::stri
|
||||
auto nameUTF16 = boost::locale::conv::utf_to_utf<char16_t, char>(name);
|
||||
|
||||
const std::size_t bufferSize = 2048;
|
||||
std::uint8_t* data = new std::uint8_t[bufferSize];
|
||||
std::uint8_t* data = std::malloc(bufferSize);
|
||||
std::size_t size = GetFirmwareEnvironmentVariableW(reinterpret_cast<LPCWSTR>(nameUTF16.c_str()), EFI_GLOBAL_GUID, data, sizeof(std::uint8_t) * bufferSize);
|
||||
if (size == 0) {
|
||||
std::stringstream message;
|
||||
|
||||
+11
-4
@@ -53,13 +53,15 @@ int main(int argc, char* argv[])
|
||||
VERBOSE = arg_verbose.getValue();
|
||||
|
||||
// Print boot order
|
||||
if (arg_list.getValue()) { // --list
|
||||
printBootOrder(uefi);
|
||||
return 0;
|
||||
}
|
||||
if (VERBOSE) { // --verbose
|
||||
std::cout << "Current boot order:" << std::endl;
|
||||
}
|
||||
if (VERBOSE || arg_list.getValue()) { // --verbose --list
|
||||
printBootOrder(uefi);
|
||||
}
|
||||
if (arg_list.getValue()) { // --list
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Fetch boot order
|
||||
auto order = uefi.ReadBootOrder();
|
||||
@@ -133,6 +135,11 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (VERBOSE) { // --verbose
|
||||
std::cout << "New boot order:" << std::endl;
|
||||
printBootOrder(uefi);
|
||||
}
|
||||
|
||||
// Reboot
|
||||
if (!arg_noreboot.getValue() && !arg_current.getValue()) { // --noreboot --current
|
||||
std::cout << "Rebooting..." << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user