Skip to content

Commit

Permalink
fix: export fakeSymbol
Browse files Browse the repository at this point in the history
  • Loading branch information
OEOTYAN committed Apr 26, 2024
1 parent 2ef9dc7 commit 97a133b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
23 changes: 11 additions & 12 deletions src/pe_editor/PeEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,7 @@ int generateLibFile() {
std::vector<llvm::object::COFFShortExport> VarExports;
std::ranges::for_each(filteredSymbols, [&](const PdbSymbol& symbol) {
llvm::object::COFFShortExport record;

if (auto fakeSymbol = pe_editor::FakeSymbol::getFakeSymbol(symbol.name); fakeSymbol) {
record.Name = *fakeSymbol;
} else {
record.Name = symbol.name;
}
record.Name = pe_editor::FakeSymbol::getFakeSymbol(symbol.name).value_or(symbol.name);
if (!symbol.isFunction) {
VarExports.push_back(record);
} else {
Expand Down Expand Up @@ -274,14 +269,18 @@ int generateModdedBds() {
| std::views::transform([](const exported_function& fn) { return fn.get_name(); });
std::ranges::copy(names, std::inserter(exportedFunctionsNames, exportedFunctionsNames.end()));

auto filtered = data::filteredSymbols | std::views::filter([&](const PdbSymbol& symbol) {
return !symbol.isFunction && !exportedFunctionsNames.contains(symbol.name);
});
auto filtered =
data::filteredSymbols | std::views::filter([&](const PdbSymbol& symbol) { return !symbol.isFunction; });

for (const auto& symbol : filtered) {
exportedFunctionsNames.insert(symbol.name);
auto fakeSymbol = pe_editor::FakeSymbol::getFakeSymbol(symbol.name).value_or(symbol.name);
if (exportedFunctionsNames.contains(fakeSymbol)) {
continue;
}
exportedFunctionsNames.insert(fakeSymbol);
exported_function func;
func.set_name(symbol.name);

func.set_name(fakeSymbol);
func.set_rva(symbol.rva);
func.set_ordinal(exportOrdinal++);
if (exportOrdinal > 65535) {
Expand Down Expand Up @@ -322,7 +321,7 @@ int generateModdedBds() {

moddedBds.close();
originBds.file.close();
logger->info("Generated modified BDS executable file successfully.");
logger->info("Generated modified BDS executable file successfully. Exported {} symbols.", exportOrdinal);

if (!config::backupBds) {
return 0;
Expand Down
6 changes: 3 additions & 3 deletions tooth.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"format_version": 2,
"tooth": "github.com/LiteLDev/PeEditor",
"version": "3.6.1",
"version": "3.7.0",
"info": {
"name": "PeEditor",
"description": "A tool to inject PreLoader to Minecraft Bedrock Dedicated Server",
"author": "LiteLDev",
"tags": []
},
"asset_url": "https://github.com/LiteLDev/PeEditor/releases/download/v3.6.1/peeditor-v3.6.1-windows-amd64.zip",
"asset_url": "https://github.com/LiteLDev/PeEditor/releases/download/v3.7.0/peeditor-v3.7.0-windows-amd64.zip",
"files": {
"place": [
{
Expand All @@ -17,4 +17,4 @@
}
]
}
}
}
2 changes: 1 addition & 1 deletion xmake-requires.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
commit = "ce583d1736cf4ea43cc0c137e0d45671a446dc4a",
url = "https://github.com/xmake-io/xmake-repo.git"
},
version = "3.23.1"
version = "3.29.2"
},
["ctre#31fecfc4"] = {
repo = {
Expand Down

0 comments on commit 97a133b

Please sign in to comment.