ui: Added used memory footer item on Windows

This commit is contained in:
WerWolv 2021-03-07 13:20:55 +01:00
parent 8423f78586
commit af444999bf
3 changed files with 37 additions and 0 deletions

View File

@ -13,6 +13,8 @@ add_library(${PROJECT_NAME} SHARED
source/content/tools_entries.cpp
source/content/data_processor_nodes.cpp
source/content/footer_items.cpp
source/math_evaluator.cpp
source/lang/en_US.cpp

View File

@ -0,0 +1,31 @@
#include <hex/plugin.hpp>
#if defined(OS_WINDOWS)
#include <windows.h>
#include <psapi.h>
#endif
namespace hex::plugin::builtin {
void addFooterItems() {
#if defined(OS_WINDOWS)
ContentRegistry::Interface::addFooterItem([] {
static MEMORYSTATUSEX memInfo;
static PROCESS_MEMORY_COUNTERS_EX pmc;
if (ImGui::GetFrameCount() % 60 == 0) {
memInfo.dwLength = sizeof(MEMORYSTATUSEX);
GlobalMemoryStatusEx(&memInfo);
GetProcessMemoryInfo(GetCurrentProcess(), reinterpret_cast<PROCESS_MEMORY_COUNTERS*>(&pmc), sizeof(pmc));
}
auto totalMem = memInfo.ullTotalPhys;
auto usedMem = pmc.PrivateUsage;
ImGui::TextUnformatted(hex::format("{0} / {1}", hex::toByteString(usedMem), hex::toByteString(totalMem)).c_str());
});
#endif
}
}

View File

@ -9,6 +9,8 @@ namespace hex::plugin::builtin {
void registerSettings();
void registerDataProcessorNodes();
void addFooterItems();
void registerLanguageEnUS();
void registerLanguageDeDE();
void registerLanguageItIT();
@ -26,6 +28,8 @@ IMHEX_PLUGIN_SETUP("Built-in", "WerWolv", "Default ImHex functionality") {
registerSettings();
registerDataProcessorNodes();
addFooterItems();
registerLanguageEnUS();
registerLanguageDeDE();
registerLanguageItIT();