From 7490d08197f5e36bbec371f6aabea04c1224c06c Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Fri, 11 Nov 2016 20:46:19 +0100 Subject: [PATCH] Linux and Windows platform fixes --- src/Platform_Linux.cpp | 9 ++++----- src/Platform_Windows.cpp | 2 +- src/main.cpp | 15 +++++++++++---- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/Platform_Linux.cpp b/src/Platform_Linux.cpp index c5f3027..ae6c237 100644 --- a/src/Platform_Linux.cpp +++ b/src/Platform_Linux.cpp @@ -1,12 +1,11 @@ #include "Platform.h" -#include #include - -void Platform::Initialize() -{ - // TODO: root permission check here +extern "C" { +#include } +void Platform::Initialize() { } + bool Platform::UEFICheck() { return efi_variables_supported(); diff --git a/src/Platform_Windows.cpp b/src/Platform_Windows.cpp index cfb614a..31245ad 100644 --- a/src/Platform_Windows.cpp +++ b/src/Platform_Windows.cpp @@ -62,7 +62,7 @@ std::pair Platform::UEFIReadVariable(const std::stri auto nameUTF16 = boost::locale::conv::utf_to_utf(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(nameUTF16.c_str()), EFI_GLOBAL_GUID, data, sizeof(std::uint8_t) * bufferSize); if (size == 0) { std::stringstream message; diff --git a/src/main.cpp b/src/main.cpp index 9f303e9..0aec526 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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;