Skip to content

Commit b5ee842

Browse files
committed
Upload progress
1 parent 6919b11 commit b5ee842

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed

library/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ elseif(UNIX)
330330
set(PROJECT_LIBS rt dl dfhack-md5 ${DFHACK_TINYXML})
331331
else(WIN32)
332332
# FIXME: do we really need psapi?
333-
set(PROJECT_LIBS psapi dfhack-md5 ${DFHACK_TINYXML})
333+
set(PROJECT_LIBS psapi dbghelp dfhack-md5 ${DFHACK_TINYXML})
334334
endif()
335335

336336
set(VERSION_SRCS DFHackVersion.cpp)

library/LuaApi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3778,7 +3778,7 @@ static int internal_cxxDemangle(lua_State *L)
37783778
{
37793779
string mangled = luaL_checkstring(L, 1);
37803780
string status;
3781-
string demangled = cxx_demangle(mangled, &status);
3781+
string demangled = Core::getInstance().p->cxxDemangle(mangled, &status);
37823782
if (demangled.length())
37833783
{
37843784
lua_pushstring(L, demangled.c_str());

library/Process-windows.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ distribution.
2929

3030
#define WIN32_LEAN_AND_MEAN
3131
#include <windows.h>
32+
#include <dbghelp.h>
3233
#include <psapi.h>
3334

3435
#include <cstring>
@@ -429,3 +430,22 @@ int Process::memProtect(void *ptr, const int length, const int prot)
429430

430431
return !VirtualProtect(ptr, length, prot_native, &old_prot);
431432
}
433+
434+
std::string Process::cxxDemangle(const std::string &mangled_name, std::string *status_out) {
435+
const char* mangled_cstr = mangled_name.c_str();
436+
437+
char demangled[MAX_SYM_NAME];
438+
DWORD flags = UNDNAME_NO_FUNCTION_RETURNS | UNDNAME_NO_ACCESS_SPECIFIERS | UNDNAME_NAME_ONLY | UNDNAME_NO_ALLOCATION_MODEL;
439+
440+
if (*mangled_cstr == '.') {
441+
// Symbol is a type, demangle as such
442+
flags |= UNDNAME_NO_ARGUMENTS;
443+
mangled_cstr++;
444+
}
445+
446+
DWORD res = UnDecorateSymbolName(mangled_cstr, (char*)&demangled, MAX_SYM_NAME, flags);
447+
if (res == 0) {
448+
return "dummy";
449+
}
450+
return std::string((char*)&demangled);
451+
}

library/include/MemAccess.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,9 @@ namespace DFHack
295295
EXEC = 4
296296
};
297297

298+
/// demangle symbol native to the platform
299+
std::string cxxDemangle(const std::string &mangled_name, std::string *status_out);
300+
298301
uint32_t getPE() { return my_pe; }
299302
std::string getMD5() { return my_md5; }
300303

scripts

0 commit comments

Comments
 (0)