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