Fetch view angles offset

This commit is contained in:
a2x 2023-09-09 02:56:47 +10:00
parent 24d56461ff
commit b6b8ee2fde
7 changed files with 47 additions and 14 deletions

View File

@ -1,5 +1,6 @@
public static class client.dll { public static class client_dll {
public const ulong entity_list = 0x1623bb8; public const ulong entity_list = 0x1623bb8;
public const ulong local_player_controller = 0x1714290; public const ulong local_player_controller = 0x1714290;
public const ulong view_angles = 0x1773ab0;
public const ulong view_matrix = 0x1714d00; public const ulong view_matrix = 0x1714d00;
} }

View File

@ -2,8 +2,9 @@
#include <cstddef> #include <cstddef>
namespace client.dll { namespace client_dll {
constexpr std::ptrdiff_t entity_list = 0x1623bb8; constexpr std::ptrdiff_t entity_list = 0x1623bb8;
constexpr std::ptrdiff_t local_player_controller = 0x1714290; constexpr std::ptrdiff_t local_player_controller = 0x1714290;
constexpr std::ptrdiff_t view_angles = 0x1773ab0;
constexpr std::ptrdiff_t view_matrix = 0x1714d00; constexpr std::ptrdiff_t view_matrix = 0x1714d00;
} }

View File

@ -1,7 +1,8 @@
{ {
"client.dll": { "client_dll": {
"entity_list": 23215032, "entity_list": 23215032,
"local_player_controller": 24199824, "local_player_controller": 24199824,
"view_angles": 24591024,
"view_matrix": 24202496 "view_matrix": 24202496
} }
} }

View File

@ -1,6 +1,7 @@
#[allow(non_snake_case, non_upper_case_globals)] #[allow(non_snake_case, non_upper_case_globals)]
pub mod client.dll { pub mod client_dll {
pub const entity_list: usize = 0x1623bb8; pub const entity_list: usize = 0x1623bb8;
pub const local_player_controller: usize = 0x1714290; pub const local_player_controller: usize = 0x1714290;
pub const view_angles: usize = 0x1773ab0;
pub const view_matrix: usize = 0x1714d00; pub const view_matrix: usize = 0x1714d00;
} }

View File

@ -11,6 +11,8 @@ namespace process {
[[nodiscard]] std::optional<std::uintptr_t> get_module_base(std::string_view module_name) noexcept; [[nodiscard]] std::optional<std::uintptr_t> get_module_base(std::string_view module_name) noexcept;
[[nodiscard]] std::optional<std::uintptr_t> resolve_jmp(std::uintptr_t address) noexcept;
[[nodiscard]] std::optional<std::uintptr_t> resolve_rip_relative_address(std::uintptr_t address) noexcept; [[nodiscard]] std::optional<std::uintptr_t> resolve_rip_relative_address(std::uintptr_t address) noexcept;
bool read_memory(std::uintptr_t address, void* buffer, std::size_t size) noexcept; bool read_memory(std::uintptr_t address, void* buffer, std::size_t size) noexcept;

View File

@ -88,34 +88,48 @@ void generate_files_for_type_scope(const sdk::CSchemaSystemTypeScope* type_scope
} }
} }
std::uint64_t get_entity_list() noexcept { std::optional<std::uint64_t> get_entity_list() noexcept {
const std::optional<std::uint64_t> address = process::find_pattern("client.dll", "48 8B 0D ? ? ? ? 48 89 7C 24 ? 8B FA C1 EB"); const std::optional<std::uint64_t> address = process::find_pattern("client.dll", "48 8B 0D ? ? ? ? 48 89 7C 24 ? 8B FA C1 EB");
if (!address.has_value()) if (!address.has_value())
return 0; return std::nullopt;
return process::resolve_rip_relative_address(address.value()).value_or(0); return process::resolve_rip_relative_address(address.value()).value_or(0);
} }
std::uint64_t get_local_player() noexcept { std::optional<std::uint64_t> get_local_player() noexcept {
std::optional<std::uint64_t> address = process::find_pattern("client.dll", "48 8B 0D ? ? ? ? F2 0F 11 44 24 ? F2 41 0F 10 00"); std::optional<std::uint64_t> address = process::find_pattern("client.dll", "48 8B 0D ? ? ? ? F2 0F 11 44 24 ? F2 41 0F 10 00");
if (!address.has_value()) if (!address.has_value())
return 0; return std::nullopt;
address = process::resolve_rip_relative_address(address.value()); address = process::resolve_rip_relative_address(address.value());
if (!address.has_value()) if (!address.has_value())
return 0; return std::nullopt;
return process::read_memory<std::uint64_t>(address.value()) + 0x50; return process::read_memory<std::uint64_t>(address.value()) + 0x50;
} }
std::uint64_t get_view_matrix() noexcept { std::optional<std::uint64_t> get_view_angles() noexcept {
std::optional<std::uint64_t> address = process::find_pattern("client.dll", "48 8B 0D ? ? ? ? 48 8B 01 48 FF 60 30");
if (!address.has_value())
return std::nullopt;
address = process::resolve_rip_relative_address(address.value());
if (!address.has_value())
return std::nullopt;
return process::read_memory<std::uint64_t>(address.value()) + 0x4510;
}
std::optional<std::uint64_t> get_view_matrix() noexcept {
const std::optional<std::uint64_t> address = process::find_pattern("client.dll", "48 8D 0D ? ? ? ? 48 C1 E0 06"); const std::optional<std::uint64_t> address = process::find_pattern("client.dll", "48 8D 0D ? ? ? ? 48 C1 E0 06");
if (!address.has_value()) if (!address.has_value())
return 0; return std::nullopt;
return process::resolve_rip_relative_address(address.value()).value_or(0); return process::resolve_rip_relative_address(address.value()).value_or(0);
} }
@ -129,18 +143,25 @@ void fetch_offsets() noexcept {
return; return;
} }
const std::uint64_t entity_list_rva = get_entity_list() - client_base.value(); const auto get_client_rva = [&client_base](const std::uint64_t address) -> std::uint64_t {
const std::uint64_t local_player_controller_rva = get_local_player() - client_base.value(); return address - client_base.value();
const std::uint64_t view_matrix_rva = get_view_matrix() - client_base.value(); };
const std::uint64_t entity_list_rva = get_client_rva(get_entity_list().value_or(0));
const std::uint64_t local_player_controller_rva = get_client_rva(get_local_player().value_or(0));
const std::uint64_t view_angles_rva = get_client_rva(get_view_angles().value_or(0));
const std::uint64_t view_matrix_rva = get_client_rva(get_view_matrix().value_or(0));
spdlog::info("entity list: {:#x}", entity_list_rva); spdlog::info("entity list: {:#x}", entity_list_rva);
spdlog::info("local player controller: {:#x}", local_player_controller_rva); spdlog::info("local player controller: {:#x}", local_player_controller_rva);
spdlog::info("view angles: {:#x}", view_angles_rva);
spdlog::info("view matrix: {:#x}", view_matrix_rva); spdlog::info("view matrix: {:#x}", view_matrix_rva);
const Entries entries = { const Entries entries = {
{ "client_dll", { { "client_dll", {
{ "entity_list", entity_list_rva }, { "entity_list", entity_list_rva },
{ "local_player_controller", local_player_controller_rva }, { "local_player_controller", local_player_controller_rva },
{ "view_angles", view_angles_rva },
{ "view_matrix", view_matrix_rva } { "view_matrix", view_matrix_rva }
} } } }
}; };

View File

@ -136,6 +136,12 @@ namespace process {
return std::nullopt; return std::nullopt;
} }
std::optional<std::uintptr_t> resolve_jmp(const std::uintptr_t address) noexcept {
const auto displacement = read_memory<std::int32_t>(address + 0x1);
return address + displacement + 0x5;
}
std::optional<std::uintptr_t> resolve_rip_relative_address(const std::uintptr_t address) noexcept { std::optional<std::uintptr_t> resolve_rip_relative_address(const std::uintptr_t address) noexcept {
const auto displacement = read_memory<std::int32_t>(address + 0x3); const auto displacement = read_memory<std::int32_t>(address + 0x3);