From 009095d9af5f48e4bf67da5ae7f39068a9af3e37 Mon Sep 17 00:00:00 2001 From: Peter Date: Fri, 9 Feb 2024 00:33:57 +0800 Subject: [PATCH] Create stub for toolhelp32 --- CMakeSettings.json | 16 ++++++++++++++++ include/wil/toolhelp32.h | 36 ++++++++++++++++++++++++++++++++++++ tests/CMakeLists.txt | 1 + tests/Toolhelp32Tests.cpp | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+) create mode 100644 CMakeSettings.json create mode 100644 include/wil/toolhelp32.h create mode 100644 tests/Toolhelp32Tests.cpp diff --git a/CMakeSettings.json b/CMakeSettings.json new file mode 100644 index 00000000..1dad0e11 --- /dev/null +++ b/CMakeSettings.json @@ -0,0 +1,16 @@ +{ + "configurations": [ + { + "name": "x64-Debug", + "generator": "Ninja", + "configurationType": "Debug", + "inheritEnvironments": [ "msvc_x64_x64" ], + "buildRoot": "${projectDir}\\out\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "cmakeToolchain": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/vcpkg/scripts/buildsystems/vcpkg.cmake" + } + ] +} \ No newline at end of file diff --git a/include/wil/toolhelp32.h b/include/wil/toolhelp32.h new file mode 100644 index 00000000..051d935f --- /dev/null +++ b/include/wil/toolhelp32.h @@ -0,0 +1,36 @@ +#ifndef __WIL_TOOLHELP32_INCLUDED +#define __WIL_TOOLHELP32_INCLUDED +#include +namespace wil +{ + namespace details + { + + } + + template + void for_each_process(TCallback&& /*callback*/) + { + + } + + template + void for_each_thread(TCallback&& /*callback*/) + { + + } + + template + void for_each_module(TCallback&& /*callback*/) + { + + } + + template + void for_each_heap(TCallback&& /*callback*/) + { + + } +} + +#endif \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d5f7c743..99434393 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -75,6 +75,7 @@ set(COMMON_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/WistdTests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/wiTest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/../natvis/wil.natvis + ${CMAKE_CURRENT_SOURCE_DIR}/Toolhelp32Tests.cpp ) if (MSVC) diff --git a/tests/Toolhelp32Tests.cpp b/tests/Toolhelp32Tests.cpp new file mode 100644 index 00000000..b0167b27 --- /dev/null +++ b/tests/Toolhelp32Tests.cpp @@ -0,0 +1,32 @@ +#include "common.h" +#include +#include +#include + +TEST_CASE("Toolhelp32", "[EnumProcesses]") +{ + wil::for_each_process([](PROCESSENTRY32 entry) { + REQUIRE_FALSE(std::strlen(entry.szExeFile) == 0); + }); +} + +TEST_CASE("Toolhelp32", "[EnumModules]") +{ + wil::for_each_module([](MODULEENTRY32 entry) { + REQUIRE_FALSE(std::strlen(entry.szExePath) == 0); + }); +} + +TEST_CASE("Toolhelp32", "[EnumThreads]") +{ + wil::for_each_thread([](THREADENTRY32 entry) { + REQUIRE_FALSE(entry.th32ThreadID == 0); + }); +} + +TEST_CASE("Toolhelp32", "[EnumHeaps]") +{ + wil::for_each_heap([](HEAPLIST32 entry) { + REQUIRE_FALSE(entry.th32HeapID == 0); + }); +} \ No newline at end of file