mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-01 07:07:49 +00:00
AK: Implement demangle() for MSVC ABI
This implements demangle() using Windows API. Also some rudimentary test is provided.
This commit is contained in:
parent
1861f24979
commit
e03c558a0a
Notes:
github-actions[bot]
2025-06-18 00:40:29 +00:00
Author: https://github.com/tomaszstrejczek 🔰
Commit: e03c558a0a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5000
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/R-Goc
6 changed files with 107 additions and 6 deletions
43
Tests/AK/TestDelayLoadWindows.cpp
Normal file
43
Tests/AK/TestDelayLoadWindows.cpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Tomasz Strejczek
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/Demangle.h>
|
||||
|
||||
#include <AK/Windows.h>
|
||||
#include <psapi.h>
|
||||
|
||||
static bool is_dll_loaded(wchar_t const* dll_name)
|
||||
{
|
||||
HMODULE mods[1024];
|
||||
DWORD needed;
|
||||
HANDLE process = GetCurrentProcess();
|
||||
|
||||
if (EnumProcessModules(process, mods, sizeof(mods), &needed)) {
|
||||
for (unsigned int i = 0; i < (needed / sizeof(HMODULE)); i++) {
|
||||
wchar_t mod_name[MAX_PATH];
|
||||
if (GetModuleFileNameExW(process, mods[i], mod_name,
|
||||
sizeof(mod_name) / sizeof(wchar_t))) {
|
||||
wchar_t const* base = wcsrchr(mod_name, L'\\');
|
||||
if (base && _wcsicmp(base + 1, dll_name) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
TEST_CASE(class_method)
|
||||
{
|
||||
auto test_string = "?unicode_substring_view@Utf16View@AK@@QEBA?AV12@_K0@Z"sv;
|
||||
auto expected_result = "public: class AK::Utf16View __cdecl AK::Utf16View::unicode_substring_view(unsigned __int64,unsigned __int64)const __ptr64"sv;
|
||||
|
||||
EXPECT_EQ(false, is_dll_loaded(L"dbghelp.dll"));
|
||||
EXPECT_EQ(expected_result, demangle(test_string));
|
||||
EXPECT_EQ(true, is_dll_loaded(L"dbghelp.dll"));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue