mirror of
https://github.com/fedddddd/iw5-gsc-utils.git
synced 2025-07-03 01:31:49 +00:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
3a492f51d9 | |||
d4ba37cde5 | |||
2ded4c6a2a | |||
24b3a9369e | |||
1d94fdd88d | |||
0af6b1cb13 |
@ -27,7 +27,7 @@ namespace gsc
|
||||
{
|
||||
if (function.second == id)
|
||||
{
|
||||
return function.first;
|
||||
return function.first.data();
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ namespace gsc
|
||||
{
|
||||
if (function.second == id)
|
||||
{
|
||||
return function.first;
|
||||
return function.first.data();
|
||||
}
|
||||
}
|
||||
|
||||
@ -251,7 +251,8 @@ namespace gsc
|
||||
const auto index = function_map_start++;
|
||||
|
||||
functions[index] = func;
|
||||
(*game::plutonium::function_map_rev)[name] = index;
|
||||
const auto name_view = utils::memory::get_allocator()->duplicate_string(name);
|
||||
(*game::plutonium::function_map_rev)[name_view] = index;
|
||||
}
|
||||
}
|
||||
|
||||
@ -262,7 +263,8 @@ namespace gsc
|
||||
const auto index = method_map_start++;
|
||||
|
||||
methods[index] = func;
|
||||
(*game::plutonium::method_map_rev)[name] = index;
|
||||
const auto name_view = utils::memory::get_allocator()->duplicate_string(name);
|
||||
(*game::plutonium::method_map_rev)[name_view] = index;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
#include "signatures.hpp"
|
||||
#include <utils/hook.hpp>
|
||||
|
||||
#define PAYLOAD_SIZE 0x20000000
|
||||
|
||||
namespace signatures
|
||||
{
|
||||
size_t load_image_size()
|
||||
@ -34,7 +32,8 @@ namespace signatures
|
||||
{
|
||||
const char* string_ptr = nullptr;
|
||||
std::string mask(string.size(), 'x');
|
||||
utils::hook::signature signature(PAYLOAD_SIZE, get_image_size() - PAYLOAD_SIZE);
|
||||
const auto base = reinterpret_cast<size_t>(GetModuleHandle("plutonium-bootstrapper-win32.exe"));
|
||||
utils::hook::signature signature(base, get_image_size() - base);
|
||||
|
||||
signature.add({
|
||||
string,
|
||||
@ -53,23 +52,27 @@ namespace signatures
|
||||
{
|
||||
char bytes[4] = {0};
|
||||
const auto string_ptr = find_string_ptr(string);
|
||||
memcpy(bytes, &string_ptr, sizeof(bytes));
|
||||
return find_string_ptr(bytes);
|
||||
if (!string_ptr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::memcpy(bytes, &string_ptr, sizeof(bytes));
|
||||
return find_string_ptr({bytes, 4});
|
||||
}
|
||||
|
||||
bool process_maps()
|
||||
{
|
||||
const auto string_ref = find_string_ref("Couldn't resolve builtin function id for name '%s'!");
|
||||
const auto string_ref = find_string_ref("couldn't resolve builtin function id for name '%s'!");
|
||||
if (!string_ref)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto map_ptr = *reinterpret_cast<size_t*>(string_ref - 0x3A);
|
||||
const auto map_ptr = *reinterpret_cast<size_t*>(string_ref - 0x2B);
|
||||
game::plutonium::function_map_rev.set(map_ptr);
|
||||
game::plutonium::method_map_rev.set(map_ptr + 0x20);
|
||||
game::plutonium::file_map_rev.set(map_ptr + 0x40);
|
||||
game::plutonium::token_map_rev.set(map_ptr + 0x60);
|
||||
game::plutonium::token_map_rev.set(map_ptr + 0xBC);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -83,13 +86,13 @@ namespace signatures
|
||||
|
||||
const auto offset = *reinterpret_cast<size_t*>(string_ref + 5);
|
||||
game::plutonium::printf.set(string_ref + 4 + 5 + offset);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool process()
|
||||
{
|
||||
load_function_tables();
|
||||
process_printf();
|
||||
return process_maps();
|
||||
return process_printf() && process_maps();
|
||||
}
|
||||
}
|
||||
|
@ -8,12 +8,12 @@ namespace scripting
|
||||
namespace
|
||||
{
|
||||
std::unordered_map<std::string, uint16_t> lowercase_map(
|
||||
const std::unordered_map<std::string, uint16_t>& old_map)
|
||||
const std::unordered_map<std::string_view, uint16_t>& old_map)
|
||||
{
|
||||
std::unordered_map<std::string, uint16_t> new_map{};
|
||||
for (auto& entry : old_map)
|
||||
{
|
||||
new_map[utils::string::to_lower(entry.first)] = entry.second;
|
||||
new_map[utils::string::to_lower(entry.first.data())] = entry.second;
|
||||
}
|
||||
|
||||
return new_map;
|
||||
@ -71,20 +71,6 @@ namespace scripting
|
||||
}
|
||||
}
|
||||
|
||||
std::string find_file(unsigned int id)
|
||||
{
|
||||
const auto& file_map = *game::plutonium::file_map_rev;
|
||||
for (const auto& file : file_map)
|
||||
{
|
||||
if (file.second == id)
|
||||
{
|
||||
return file.first;
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string find_token(unsigned int id)
|
||||
{
|
||||
const auto& token_map = *game::plutonium::token_map_rev;
|
||||
@ -99,6 +85,11 @@ namespace scripting
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string find_file(unsigned int id)
|
||||
{
|
||||
return find_token(id);
|
||||
}
|
||||
|
||||
int find_token_id(const std::string& name)
|
||||
{
|
||||
const auto& token_map = *game::plutonium::token_map_rev;
|
||||
|
@ -86,9 +86,8 @@ namespace game
|
||||
|
||||
namespace plutonium
|
||||
{
|
||||
WEAK symbol<std::unordered_map<std::string, std::uint16_t>> function_map_rev{0};
|
||||
WEAK symbol<std::unordered_map<std::string, std::uint16_t>> method_map_rev{0};
|
||||
WEAK symbol<std::unordered_map<std::string, std::uint16_t>> file_map_rev{0};
|
||||
WEAK symbol<std::unordered_map<std::string_view, std::uint16_t>> function_map_rev{0};
|
||||
WEAK symbol<std::unordered_map<std::string_view, std::uint16_t>> method_map_rev{0};
|
||||
WEAK symbol<std::unordered_map<std::string, std::uint16_t>> token_map_rev{0};
|
||||
WEAK symbol<int(const char* fmt, ...)> printf{0};
|
||||
WEAK symbol<void*> function_table{0};
|
||||
|
@ -1,8 +1,14 @@
|
||||
#include <stdinc.hpp>
|
||||
#include <fstream>
|
||||
#include "io.hpp"
|
||||
|
||||
namespace utils::io
|
||||
{
|
||||
bool remove_file(const std::string& file)
|
||||
{
|
||||
return DeleteFileA(file.data()) == TRUE;
|
||||
}
|
||||
|
||||
bool file_exists(const std::string& file)
|
||||
{
|
||||
return std::ifstream(file).good();
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
namespace utils::io
|
||||
{
|
||||
bool remove_file(const std::string& file);
|
||||
bool file_exists(const std::string& file);
|
||||
bool write_file(const std::string& file, const std::string& data, bool append = false);
|
||||
bool read_file(const std::string& file, std::string* data);
|
||||
|
Reference in New Issue
Block a user