Skip to content

Commit

Permalink
Create stub for toolhelp32
Browse files Browse the repository at this point in the history
  • Loading branch information
HO-COOH committed Feb 8, 2024
1 parent 832d0c5 commit 009095d
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 0 deletions.
16 changes: 16 additions & 0 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
36 changes: 36 additions & 0 deletions include/wil/toolhelp32.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#ifndef __WIL_TOOLHELP32_INCLUDED
#define __WIL_TOOLHELP32_INCLUDED
#include <TlHelp32.h>
namespace wil
{
namespace details
{

}

template<typename TCallback>
void for_each_process(TCallback&& /*callback*/)
{

}

template<typename TCallback>
void for_each_thread(TCallback&& /*callback*/)
{

}

template<typename TCallback>
void for_each_module(TCallback&& /*callback*/)
{

}

template<typename TCallback>
void for_each_heap(TCallback&& /*callback*/)
{

}
}

#endif
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
32 changes: 32 additions & 0 deletions tests/Toolhelp32Tests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "common.h"
#include <WinUser.h>
#include <wil/toolhelp32.h>
#include <cstring>

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);
});
}

0 comments on commit 009095d

Please sign in to comment.