Skip to content

Commit 009095d

Browse files
committed
Create stub for toolhelp32
1 parent 832d0c5 commit 009095d

File tree

4 files changed

+85
-0
lines changed

4 files changed

+85
-0
lines changed

CMakeSettings.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "x64-Debug",
5+
"generator": "Ninja",
6+
"configurationType": "Debug",
7+
"inheritEnvironments": [ "msvc_x64_x64" ],
8+
"buildRoot": "${projectDir}\\out\\build\\${name}",
9+
"installRoot": "${projectDir}\\out\\install\\${name}",
10+
"cmakeCommandArgs": "",
11+
"buildCommandArgs": "",
12+
"ctestCommandArgs": "",
13+
"cmakeToolchain": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/vcpkg/scripts/buildsystems/vcpkg.cmake"
14+
}
15+
]
16+
}

include/wil/toolhelp32.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#ifndef __WIL_TOOLHELP32_INCLUDED
2+
#define __WIL_TOOLHELP32_INCLUDED
3+
#include <TlHelp32.h>
4+
namespace wil
5+
{
6+
namespace details
7+
{
8+
9+
}
10+
11+
template<typename TCallback>
12+
void for_each_process(TCallback&& /*callback*/)
13+
{
14+
15+
}
16+
17+
template<typename TCallback>
18+
void for_each_thread(TCallback&& /*callback*/)
19+
{
20+
21+
}
22+
23+
template<typename TCallback>
24+
void for_each_module(TCallback&& /*callback*/)
25+
{
26+
27+
}
28+
29+
template<typename TCallback>
30+
void for_each_heap(TCallback&& /*callback*/)
31+
{
32+
33+
}
34+
}
35+
36+
#endif

tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ set(COMMON_SOURCES
7575
${CMAKE_CURRENT_SOURCE_DIR}/WistdTests.cpp
7676
${CMAKE_CURRENT_SOURCE_DIR}/wiTest.cpp
7777
${CMAKE_CURRENT_SOURCE_DIR}/../natvis/wil.natvis
78+
${CMAKE_CURRENT_SOURCE_DIR}/Toolhelp32Tests.cpp
7879
)
7980

8081
if (MSVC)

tests/Toolhelp32Tests.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include "common.h"
2+
#include <WinUser.h>
3+
#include <wil/toolhelp32.h>
4+
#include <cstring>
5+
6+
TEST_CASE("Toolhelp32", "[EnumProcesses]")
7+
{
8+
wil::for_each_process([](PROCESSENTRY32 entry) {
9+
REQUIRE_FALSE(std::strlen(entry.szExeFile) == 0);
10+
});
11+
}
12+
13+
TEST_CASE("Toolhelp32", "[EnumModules]")
14+
{
15+
wil::for_each_module([](MODULEENTRY32 entry) {
16+
REQUIRE_FALSE(std::strlen(entry.szExePath) == 0);
17+
});
18+
}
19+
20+
TEST_CASE("Toolhelp32", "[EnumThreads]")
21+
{
22+
wil::for_each_thread([](THREADENTRY32 entry) {
23+
REQUIRE_FALSE(entry.th32ThreadID == 0);
24+
});
25+
}
26+
27+
TEST_CASE("Toolhelp32", "[EnumHeaps]")
28+
{
29+
wil::for_each_heap([](HEAPLIST32 entry) {
30+
REQUIRE_FALSE(entry.th32HeapID == 0);
31+
});
32+
}

0 commit comments

Comments
 (0)