Skip to content

Instantly share code, notes, and snippets.

@Allana-git
Last active Sep 14, 2021
Embed
What would you like to do?
tlhelp32.h wrapper for c++23
using heap_list32_t = HEAPLIST32;
using heap_entry32_t = HEAPENTRY32;
using process_entry32_t = PROCESSENTRY32;
using thread_entry32_t = THREADENTRY32;
using module_entry32_t = MODULEENTRY32;
enum class thc32cs_flag_t : std::int32_t {
th32cs_snapheaplist = 0x000001,
th32cs_snapprocess = 0x000002,
th32cs_snapthread = 0x000004,
th32cs_snapmodule = 0x000008,
th32cs_snapmodule32 = 0x000010,
th32cs_inherit = 0x800000,
th32cs_snapall = ( th32cs_snapheaplist | th32cs_snapprocess |
th32cs_snapthread | th32cs_snapmodule )
};
enum class hf32_flag_t : std::int32_t {
hf32_default = 0x000001,
hf32_shared = 0x000002
};
enum class lf32_flag_t : std::int32_t {
lf32_fixed = 0x000001,
lf32_free = 0x000002,
lf32_movable = 0x000004
};
struct tl_help32_t {
auto tool_help32_read_process_memory ( std::int32_t id, void* address, void* buffer, std::size_t size, std::size_t* bytes_read ) noexcept -> std::int32_t {
return Toolhelp32ReadProcessMemory( id, address, reinterpret_cast <LPVOID> ( buffer ), size, reinterpret_cast <SIZE_T*> ( bytes_read ) );
}
auto heap32_first ( heap_entry32_t* heap_entry, std::int32_t id, std::int32_t heap_id ) noexcept -> std::int32_t {
return Heap32First( reinterpret_cast <LPHEAPENTRY32> ( heap_entry ), id, heap_id );
}
auto heap32_list_first ( void* snapshot, heap_list32_t* heap_list ) noexcept -> std::int32_t {
return Heap32ListFirst( static_cast <HANDLE> ( snapshot ), reinterpret_cast <LPHEAPLIST32> ( heap_list ) );
}
auto heap32_list_next ( void* snapshot, heap_list32_t* heap_list ) noexcept -> std::int32_t {
return Heap32ListNext( reinterpret_cast <HANDLE> ( snapshot ), reinterpret_cast <LPHEAPLIST32> ( heap_list ) );
}
auto process32_first ( void* snapshot, process_entry32_t* entry ) noexcept -> std::int32_t {
return Process32First( reinterpret_cast <HANDLE> ( snapshot ), reinterpret_cast <LPPROCESSENTRY32> ( entry ) );
}
auto process32_next ( void* snapshot, process_entry32_t* entry ) noexcept -> std::int32_t {
return Process32Next( reinterpret_cast <HANDLE> ( snapshot ), reinterpret_cast <LPPROCESSENTRY32> ( entry ) );
}
auto thread32_first ( void* snapshot, thread_entry32_t* entry ) noexcept -> std::int32_t {
return Thread32First( reinterpret_cast <HANDLE> ( snapshot ), reinterpret_cast <LPTHREADENTRY32> ( entry ) );
}
auto thread32_next ( void* snapshot, thread_entry32_t* entry ) noexcept -> std::int32_t {
return Thread32Next( reinterpret_cast <HANDLE> ( snapshot ), reinterpret_cast <LPTHREADENTRY32> ( entry ) );
}
auto module32_first ( void* snapshot, module_entry32_t* module_entry ) noexcept -> std::int32_t {
return Module32First( reinterpret_cast <HANDLE> ( snapshot ), reinterpret_cast <LPMODULEENTRY32> ( module_entry ) );
}
auto module32_next ( void* snapshot, module_entry32_t* module_entry ) noexcept -> std::int32_t {
return Module32Next( reinterpret_cast <HANDLE> ( snapshot ), reinterpret_cast <LPMODULEENTRY32> ( module_entry ) );
}
auto create_tool_help32_snapshot ( std::int32_t flags, std::int32_t id ) noexcept -> void* {
return CreateToolhelp32Snapshot( flags, id );
}
auto heap32_next ( heap_entry32_t* heap_entry ) noexcept -> std::int32_t {
return Heap32Next( reinterpret_cast <LPHEAPENTRY32> ( heap_entry ) );
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment