mirror of
https://github.com/fedddddd/iw5-gsc-utils.git
synced 2025-04-20 21:05:44 +00:00
Fixes for pluto update
This commit is contained in:
parent
1d94fdd88d
commit
24b3a9369e
@ -27,7 +27,7 @@ namespace gsc
|
|||||||
{
|
{
|
||||||
if (function.second == id)
|
if (function.second == id)
|
||||||
{
|
{
|
||||||
return function.first;
|
return function.first.data();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ namespace gsc
|
|||||||
{
|
{
|
||||||
if (function.second == id)
|
if (function.second == id)
|
||||||
{
|
{
|
||||||
return function.first;
|
return function.first.data();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,7 +251,8 @@ namespace gsc
|
|||||||
const auto index = function_map_start++;
|
const auto index = function_map_start++;
|
||||||
|
|
||||||
functions[index] = func;
|
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++;
|
const auto index = method_map_start++;
|
||||||
|
|
||||||
methods[index] = func;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,23 +52,35 @@ namespace signatures
|
|||||||
{
|
{
|
||||||
char bytes[4] = {0};
|
char bytes[4] = {0};
|
||||||
const auto string_ptr = find_string_ptr(string);
|
const auto string_ptr = find_string_ptr(string);
|
||||||
memcpy(bytes, &string_ptr, sizeof(bytes));
|
if (!string_ptr)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::memcpy(bytes, &string_ptr, sizeof(bytes));
|
||||||
return find_string_ptr({bytes, 4});
|
return find_string_ptr({bytes, 4});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool process_maps()
|
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)
|
if (!string_ref)
|
||||||
{
|
{
|
||||||
return false;
|
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::function_map_rev.set(map_ptr);
|
||||||
|
printf("%p\n", map_ptr);
|
||||||
|
|
||||||
|
|
||||||
|
auto& map = *game::plutonium::function_map_rev;
|
||||||
|
for (const auto& [k, v] : map)
|
||||||
|
{
|
||||||
|
printf("%s %i\n", k.data(), v);
|
||||||
|
}
|
||||||
game::plutonium::method_map_rev.set(map_ptr + 0x20);
|
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 + 0xBC);
|
||||||
game::plutonium::token_map_rev.set(map_ptr + 0x60);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,12 +94,15 @@ namespace signatures
|
|||||||
|
|
||||||
const auto offset = *reinterpret_cast<size_t*>(string_ref + 5);
|
const auto offset = *reinterpret_cast<size_t*>(string_ref + 5);
|
||||||
game::plutonium::printf.set(string_ref + 4 + 5 + offset);
|
game::plutonium::printf.set(string_ref + 4 + 5 + offset);
|
||||||
|
utils::hook::jump(reinterpret_cast<uintptr_t>(&printf), game::plutonium::printf);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool process()
|
bool process()
|
||||||
{
|
{
|
||||||
load_function_tables();
|
load_function_tables();
|
||||||
return process_printf() && process_maps();
|
process_printf();
|
||||||
|
return process_maps();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,12 @@ namespace scripting
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
std::unordered_map<std::string, uint16_t> lowercase_map(
|
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{};
|
std::unordered_map<std::string, uint16_t> new_map{};
|
||||||
for (auto& entry : old_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;
|
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)
|
std::string find_token(unsigned int id)
|
||||||
{
|
{
|
||||||
const auto& token_map = *game::plutonium::token_map_rev;
|
const auto& token_map = *game::plutonium::token_map_rev;
|
||||||
@ -92,13 +78,18 @@ namespace scripting
|
|||||||
{
|
{
|
||||||
if (token.second == id)
|
if (token.second == id)
|
||||||
{
|
{
|
||||||
return token.first;
|
return token.first.data();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string find_file(unsigned int id)
|
||||||
|
{
|
||||||
|
return find_token(id);
|
||||||
|
}
|
||||||
|
|
||||||
int find_token_id(const std::string& name)
|
int find_token_id(const std::string& name)
|
||||||
{
|
{
|
||||||
const auto& token_map = *game::plutonium::token_map_rev;
|
const auto& token_map = *game::plutonium::token_map_rev;
|
||||||
|
@ -86,10 +86,10 @@ namespace game
|
|||||||
|
|
||||||
namespace plutonium
|
namespace plutonium
|
||||||
{
|
{
|
||||||
WEAK symbol<std::unordered_map<std::string, std::uint16_t>> function_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, std::uint16_t>> method_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>> file_map_rev{0};
|
|
||||||
WEAK symbol<std::unordered_map<std::string, std::uint16_t>> token_map_rev{0};
|
WEAK symbol<std::unordered_map<std::string, std::uint16_t>> token_map_rev{0};
|
||||||
|
WEAK symbol<std::unordered_map<std::uint16_t, std::string_view>> token_map{0};
|
||||||
WEAK symbol<int(const char* fmt, ...)> printf{0};
|
WEAK symbol<int(const char* fmt, ...)> printf{0};
|
||||||
WEAK symbol<void*> function_table{0};
|
WEAK symbol<void*> function_table{0};
|
||||||
WEAK symbol<void*> method_table{0};
|
WEAK symbol<void*> method_table{0};
|
||||||
|
@ -1,8 +1,14 @@
|
|||||||
#include <stdinc.hpp>
|
#include <stdinc.hpp>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include "io.hpp"
|
||||||
|
|
||||||
namespace utils::io
|
namespace utils::io
|
||||||
{
|
{
|
||||||
|
bool remove_file(const std::string& file)
|
||||||
|
{
|
||||||
|
return DeleteFileA(file.data()) == TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
bool file_exists(const std::string& file)
|
bool file_exists(const std::string& file)
|
||||||
{
|
{
|
||||||
return std::ifstream(file).good();
|
return std::ifstream(file).good();
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
namespace utils::io
|
namespace utils::io
|
||||||
{
|
{
|
||||||
|
bool remove_file(const std::string& file);
|
||||||
bool file_exists(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 write_file(const std::string& file, const std::string& data, bool append = false);
|
||||||
bool read_file(const std::string& file, std::string* data);
|
bool read_file(const std::string& file, std::string* data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user