patch exec
This commit is contained in:
parent
e8be93a37e
commit
ecce77f471
@ -9,11 +9,35 @@
|
||||
#include <utils/hook.hpp>
|
||||
#include <utils/string.hpp>
|
||||
|
||||
namespace filesystem
|
||||
namespace game::filesystem
|
||||
{
|
||||
namespace
|
||||
file::file(std::string name)
|
||||
: name_(std::move(name))
|
||||
{
|
||||
|
||||
char* buffer{};
|
||||
const auto size = game::FS_ReadFile(this->name_.data(), &buffer);
|
||||
|
||||
if (size >= 0 && buffer)
|
||||
{
|
||||
this->valid_ = true;
|
||||
this->buffer_.append(buffer, size);
|
||||
game::FS_FreeFile(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
bool file::exists() const
|
||||
{
|
||||
return this->valid_;
|
||||
}
|
||||
|
||||
const std::string& file::get_buffer() const
|
||||
{
|
||||
return this->buffer_;
|
||||
}
|
||||
|
||||
const std::string& file::get_name() const
|
||||
{
|
||||
return this->name_;
|
||||
}
|
||||
|
||||
class component final : public component_interface
|
||||
@ -26,4 +50,4 @@ namespace filesystem
|
||||
};
|
||||
}
|
||||
|
||||
REGISTER_COMPONENT(filesystem::component)
|
||||
REGISTER_COMPONENT(game::filesystem::component)
|
@ -1,6 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
namespace filesystem
|
||||
namespace game::filesystem
|
||||
{
|
||||
class file
|
||||
{
|
||||
public:
|
||||
file(std::string name);
|
||||
|
||||
[[nodiscard]] bool exists() const;
|
||||
[[nodiscard]] const std::string& get_buffer() const;
|
||||
[[nodiscard]] const std::string& get_name() const;
|
||||
|
||||
private:
|
||||
bool valid_ = false;
|
||||
std::string name_;
|
||||
std::string buffer_;
|
||||
};
|
||||
}
|
@ -5,6 +5,7 @@
|
||||
#include "game/dvars.hpp"
|
||||
|
||||
#include "fastfiles.hpp"
|
||||
#include "filesystem.hpp"
|
||||
#include "dvars.hpp"
|
||||
|
||||
#include <utils/hook.hpp>
|
||||
@ -193,6 +194,18 @@ namespace patches
|
||||
*checksum = dvar->checksum;
|
||||
return true;
|
||||
}
|
||||
|
||||
char* db_read_raw_file_stub(const char* filename, char* buf, const int size)
|
||||
{
|
||||
const auto file = game::filesystem::file(filename);
|
||||
if (file.exists())
|
||||
{
|
||||
snprintf(buf, size, "%s\n", file.get_buffer().data());
|
||||
return buf;
|
||||
}
|
||||
|
||||
return game::DB_ReadRawFile(filename, buf, size);
|
||||
}
|
||||
}
|
||||
|
||||
class component final : public component_interface
|
||||
@ -229,6 +242,9 @@ namespace patches
|
||||
utils::hook::set<uint8_t>(0xB0A9AC_b, 0xEB); // setclientdvar
|
||||
utils::hook::set<uint8_t>(0xB0ACC8_b, 0xEB); // setclientdvars
|
||||
|
||||
// Allow executing custom cfg files with the "exec" command
|
||||
utils::hook::call(0xB7CEF9_b, db_read_raw_file_stub);
|
||||
|
||||
// don't reset our fov
|
||||
utils::hook::set<uint8_t>(0x8A6160_b, 0xC3);
|
||||
|
||||
|
@ -56,8 +56,8 @@ namespace game
|
||||
WEAK symbol<bool(std::int32_t, void(__cdecl*)(XAssetHeader, void*), const void*)> DB_EnumXAssets_FastFile{ 0xA76CE0 };
|
||||
WEAK symbol<bool(XAssetType type, const char* name)> DB_IsXAssetDefault{ 0xA780D0 };
|
||||
WEAK symbol<XAssetHeader(XAssetType type, const char* name, int allowCreateDefault)> DB_FindXAssetHeader{ 0xA76E00 };
|
||||
|
||||
WEAK symbol<bool(const char* zoneName)> DB_IsLocalized{ 0x3BC500 };
|
||||
WEAK symbol<char* (const char* filename, char* buf, int size)> DB_ReadRawFile{ 0xA79E30 };
|
||||
|
||||
WEAK symbol<dvar_t* (const char* name, bool value,
|
||||
unsigned int flags, const char* description)> Dvar_RegisterBool{ 0xCEB380 };
|
||||
@ -89,6 +89,8 @@ namespace game
|
||||
WEAK symbol<unsigned int(const char* name)> Dvar_GenerateChecksum{ 0xCEA520 };
|
||||
WEAK symbol<void(dvar_t* dvar, int value)> Dvar_SetInt{ 0xCED3D0 };
|
||||
|
||||
WEAK symbol<__int64(const char* qpath, char** buffer)> FS_ReadFile{ 0xCDE200 };
|
||||
WEAK symbol<void(char* buffer)> FS_FreeFile{ 0xCDE1F0 };
|
||||
WEAK symbol<void(int h, const char* fmt, ...)> FS_Printf{ 0xCDD1C0 };
|
||||
|
||||
WEAK symbol<const char* (int, int, int)> Key_KeynumToString{ 0x9A95E0 };
|
||||
|
Loading…
Reference in New Issue
Block a user