feat: support makepdb format.
This commit is contained in:
@@ -17,7 +17,8 @@ known as magicblob), PreLoader no longer handles PDB. The source code in the cur
|
||||
- Just execute `xmake` to complete the build.
|
||||
|
||||
### Usage
|
||||
- --output-format can be `auto` / `txt` / `fakepdb`
|
||||
|
||||
- --output-format can be `auto` / `txt` / `fakepdb` / `makepdb`
|
||||
|
||||
```
|
||||
Usage: askrva [--help] [--version] --output VAR [--output-failed VAR] [--output-format VAR] path
|
||||
|
||||
33
AskRVA/src/format/output/makepdb.cpp
Normal file
33
AskRVA/src/format/output/makepdb.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "format/output/makepdb.h"
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace format::output {
|
||||
|
||||
void OutputMakePDBFile::record(std::string_view symbol, uint64_t rva, bool is_function) {
|
||||
m_records.emplace(std::string(symbol), rva, is_function);
|
||||
}
|
||||
|
||||
void OutputMakePDBFile::save(std::string_view path) const {
|
||||
std::ofstream ofs(path.data());
|
||||
if (!ofs) {
|
||||
throw std::runtime_error("Failed to open save file.");
|
||||
}
|
||||
|
||||
nlohmann::json data;
|
||||
|
||||
// MakePDB - Format V1
|
||||
data["version"] = 1;
|
||||
|
||||
for (const auto& [symbol, rva, is_fun] : m_records) {
|
||||
data["data"].emplace_back(nlohmann::json{
|
||||
{"symbol", symbol},
|
||||
{"rva", rva },
|
||||
{"is_function", is_fun}
|
||||
});
|
||||
}
|
||||
|
||||
ofs << data.dump(4);
|
||||
}
|
||||
|
||||
} // namespace format::output
|
||||
16
AskRVA/src/format/output/makepdb.h
Normal file
16
AskRVA/src/format/output/makepdb.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "format/output/all.h"
|
||||
|
||||
namespace format::output {
|
||||
|
||||
class OutputMakePDBFile : public DefaultOutputFile {
|
||||
public:
|
||||
void record(std::string_view symbol, uint64_t rva, bool is_function) override;
|
||||
void save(std::string_view path) const override;
|
||||
|
||||
private:
|
||||
std::unordered_set<std::tuple<std::string, uint64_t, bool>> m_records;
|
||||
};
|
||||
|
||||
} // namespace format::output
|
||||
Reference in New Issue
Block a user