You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.1 KiB
46 lines
1.1 KiB
#include <iostream>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
std::string demangle(const std::string& mangled) {
|
|
std::string result;
|
|
std::vector<std::string> parts;
|
|
|
|
size_t i = 0;
|
|
while (i < mangled.size()) {
|
|
if (std::isdigit(mangled[i])) {
|
|
// Read length of the following name
|
|
size_t length = 0;
|
|
while (std::isdigit(mangled[i])) {
|
|
length = length * 10 + (mangled[i] - '0');
|
|
i++;
|
|
}
|
|
// Get the name part
|
|
std::string name = mangled.substr(i, length);
|
|
parts.push_back(name);
|
|
i += length;
|
|
} else {
|
|
// Handle other characters (if needed)
|
|
// result += mangled[i];
|
|
i++;
|
|
}
|
|
}
|
|
|
|
// Join parts with '.'
|
|
for (const auto& part : parts) {
|
|
if (!result.empty()) {
|
|
result += ".";
|
|
}
|
|
result += part;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
int main() {
|
|
std::string mangledName = "_ZNKiflytop13zscanprotocol16ZSCanProtocolCom7callcmdEiiPhii";
|
|
std::string demangledName = demangle(mangledName);
|
|
|
|
std::cout << "Demangled Name: " << demangledName << std::endl;
|
|
return 0;
|
|
}
|