| 239 | } |
| 240 | |
| 241 | string Process::doReadClassName (void * vptr) |
| 242 | { |
| 243 | if (!checkValidAddress(vptr)) |
| 244 | throw std::runtime_error(fmt::format("invalid vtable ptr {}", vptr)); |
| 245 | |
| 246 | char* rtti = Process::readPtr(((char*)vptr - sizeof(void*))); |
| 247 | #ifndef WIN32 |
| 248 | char* typestring = Process::readPtr(rtti + sizeof(void*)); |
| 249 | #else /* WIN32 */ |
| 250 | #ifdef DFHACK64 |
| 251 | void* base; |
| 252 | if (!RtlPcToFileHeader(rtti, &base)) |
| 253 | return "dummy"; |
| 254 | char* typeinfo = (char *)base + readDWord(rtti + 0xC); |
| 255 | char* typestring = typeinfo + 0x10; |
| 256 | #else |
| 257 | char* typeinfo = readPtr(rtti + 0xC); |
| 258 | char* typestring = typeinfo + 0x8; |
| 259 | #endif |
| 260 | #endif /* WIN32 */ |
| 261 | std::string raw = readCString(typestring); |
| 262 | if (raw.length() == 0) |
| 263 | return "dummy"; |
| 264 | |
| 265 | string status; |
| 266 | string demangled = cxx_demangle(raw, &status); |
| 267 | |
| 268 | if (demangled.length() == 0) { |
| 269 | return "dummy"; |
| 270 | } |
| 271 | |
| 272 | return demangled; |
| 273 | } |
| 274 | |
| 275 | #ifndef WIN32 |
| 276 | #ifndef _DARWIN |
nothing calls this directly
no test coverage detected