mirror of
https://github.com/a2x/cs2-dumper.git
synced 2025-10-08 12:00:02 +08:00
Refactored code
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
namespace sdk {
|
||||
class SchemaClassFieldData_t {
|
||||
public:
|
||||
[[nodiscard]] std::string get_name() const noexcept;
|
||||
|
||||
[[nodiscard]] std::uint16_t get_offset() const noexcept;
|
||||
};
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
namespace sdk {
|
||||
class SchemaClassFieldData_t;
|
||||
|
||||
class CSchemaClassInfo {
|
||||
public:
|
||||
[[nodiscard]] std::uint16_t get_fields_count() const noexcept;
|
||||
|
||||
[[nodiscard]] std::vector<SchemaClassFieldData_t*> get_fields() const noexcept;
|
||||
};
|
||||
}
|
@@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace sdk {
|
||||
class CSchemaSystemTypeScope;
|
||||
|
||||
class CSchemaSystem {
|
||||
public:
|
||||
static CSchemaSystem* get() noexcept;
|
||||
|
||||
[[nodiscard]] std::vector<CSchemaSystemTypeScope*> get_type_scopes() const noexcept;
|
||||
};
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
namespace sdk {
|
||||
class CSchemaClassInfo;
|
||||
class CSchemaType_DeclaredClass;
|
||||
|
||||
class CSchemaSystemTypeScope {
|
||||
public:
|
||||
[[nodiscard]] CSchemaClassInfo* find_declared_class(std::string_view class_name) const noexcept;
|
||||
|
||||
[[nodiscard]] std::vector<CSchemaType_DeclaredClass*> get_declared_classes() const noexcept;
|
||||
|
||||
[[nodiscard]] std::string get_module_name() const noexcept;
|
||||
};
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
namespace sdk {
|
||||
class CSchemaType_DeclaredClass {
|
||||
public:
|
||||
[[nodiscard]] std::string get_class_name() const noexcept;
|
||||
};
|
||||
}
|
10
include/sdk/schema_class_field_data.hpp
Normal file
10
include/sdk/schema_class_field_data.hpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
namespace sdk {
|
||||
class SchemaClassFieldData {
|
||||
public:
|
||||
[[nodiscard]] std::string name() const noexcept;
|
||||
|
||||
[[nodiscard]] std::uint16_t offset() const noexcept;
|
||||
};
|
||||
}
|
10
include/sdk/schema_class_info.hpp
Normal file
10
include/sdk/schema_class_info.hpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
namespace sdk {
|
||||
class SchemaClassInfo {
|
||||
public:
|
||||
[[nodiscard]] std::uint16_t fields_count() const noexcept;
|
||||
|
||||
void for_each_field(const std::function<void(SchemaClassFieldData*)>& callback) const noexcept;
|
||||
};
|
||||
}
|
10
include/sdk/schema_system.hpp
Normal file
10
include/sdk/schema_system.hpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
namespace sdk {
|
||||
class SchemaSystem {
|
||||
public:
|
||||
static SchemaSystem* get() noexcept;
|
||||
|
||||
[[nodiscard]] std::vector<SchemaSystemTypeScope*> type_scopes() const noexcept;
|
||||
};
|
||||
}
|
10
include/sdk/schema_system_type_scope.hpp
Normal file
10
include/sdk/schema_system_type_scope.hpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
namespace sdk {
|
||||
class SchemaSystemTypeScope {
|
||||
public:
|
||||
void for_each_class(const std::function<void(std::pair<std::string, SchemaClassInfo*>)>& callback) const noexcept;
|
||||
|
||||
[[nodiscard]] std::string module_name() const noexcept;
|
||||
};
|
||||
}
|
10
include/sdk/schema_type_declared_class.hpp
Normal file
10
include/sdk/schema_type_declared_class.hpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
namespace sdk {
|
||||
class SchemaTypeDeclaredClass {
|
||||
public:
|
||||
[[nodiscard]] std::string binary_name() const noexcept;
|
||||
|
||||
[[nodiscard]] std::string module_name() const noexcept;
|
||||
};
|
||||
}
|
@@ -1,13 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
#include "process.hpp"
|
||||
|
||||
#include "c_schema_class_field_data.hpp"
|
||||
#include "c_schema_class_info.hpp"
|
||||
#include "c_schema_system.hpp"
|
||||
#include "c_schema_system_type_scope.hpp"
|
||||
#include "c_schema_type_declared_class.hpp"
|
||||
#include "schema_class_field_data.hpp"
|
||||
#include "schema_class_info.hpp"
|
||||
#include "schema_type_declared_class.hpp"
|
||||
#include "schema_system_type_scope.hpp"
|
||||
#include "schema_system.hpp"
|
||||
#include "utl_ts_hash.hpp"
|
||||
|
119
include/sdk/utl_ts_hash.hpp
Normal file
119
include/sdk/utl_ts_hash.hpp
Normal file
@@ -0,0 +1,119 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace sdk {
|
||||
template <class T, typename K>
|
||||
class HashBucketDataInternal {
|
||||
public:
|
||||
HashBucketDataInternal<T, K>* next() const noexcept {
|
||||
return process::read_memory<HashBucketDataInternal<T, K>*>(reinterpret_cast<std::uint64_t>(this) + 0x8);
|
||||
}
|
||||
|
||||
public:
|
||||
T data; // 0x0
|
||||
std::byte pad_0[0x8]; // 0x8
|
||||
K ui_key; // 0x10
|
||||
};
|
||||
|
||||
template <class T, typename K>
|
||||
class HashFixedDataInternal {
|
||||
public:
|
||||
HashFixedDataInternal<T, K>* next() const noexcept {
|
||||
return process::read_memory<HashFixedDataInternal<T, K>*>(reinterpret_cast<std::uint64_t>(this) + 0x8);
|
||||
}
|
||||
|
||||
public:
|
||||
K ui_key; // 0x0
|
||||
std::byte pad_0[0x8]; // 0x8
|
||||
T data; // 0x10
|
||||
};
|
||||
|
||||
template <class T, typename K>
|
||||
struct HashAllocatedData {
|
||||
std::array<HashFixedDataInternal<T, K>, 128> list() const noexcept {
|
||||
return process::read_memory<std::array<HashFixedDataInternal<T, K>, 128>>(reinterpret_cast<std::uint64_t>(this) + 0x18);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T, typename K>
|
||||
class HashUnallocatedData {
|
||||
public:
|
||||
HashUnallocatedData<T, K>* next() const noexcept {
|
||||
return process::read_memory<HashUnallocatedData<T, K>*>(reinterpret_cast<std::uint64_t>(this));
|
||||
}
|
||||
|
||||
K ui_key() const noexcept {
|
||||
return process::read_memory<K>(reinterpret_cast<std::uint64_t>(this) + 0x10);
|
||||
}
|
||||
|
||||
std::array<HashBucketDataInternal<T, K>, 256> block_list() const noexcept {
|
||||
return process::read_memory<std::array<HashBucketDataInternal<T, K>, 256>>(reinterpret_cast<std::uint64_t>(this) + 0x20);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T, typename K>
|
||||
struct HashBucket {
|
||||
std::byte pad_0[0x10]; // 0x0
|
||||
HashAllocatedData<T, K>* allocated_data; // 0x10
|
||||
HashUnallocatedData<T, K>* unallocated_data; // 0x18
|
||||
};
|
||||
|
||||
class UtlMemoryPool {
|
||||
public:
|
||||
[[nodiscard]] std::int32_t block_size() const noexcept {
|
||||
return blocks_per_blob_;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::int32_t count() const noexcept {
|
||||
return block_allocated_size_;
|
||||
}
|
||||
|
||||
private:
|
||||
std::int32_t block_size_; // 0x0
|
||||
std::int32_t blocks_per_blob_; // 0x4
|
||||
std::int32_t grow_mode_; // 0x8
|
||||
std::int32_t blocks_allocated_; // 0xC
|
||||
std::int32_t block_allocated_size_; // 0x10
|
||||
std::int32_t peak_alloc_; // 0x14
|
||||
};
|
||||
|
||||
template <class T, typename K = std::uint64_t>
|
||||
class UtlTsHash {
|
||||
public:
|
||||
[[nodiscard]] std::int32_t block_size() const noexcept {
|
||||
return entry_memory.block_size();
|
||||
}
|
||||
|
||||
[[nodiscard]] std::int32_t count() const noexcept {
|
||||
return entry_memory.count();
|
||||
}
|
||||
|
||||
std::vector<T> elements() const noexcept {
|
||||
std::vector<T> list;
|
||||
|
||||
const auto& unallocated_data = buckets.unallocated_data;
|
||||
|
||||
std::int32_t index = 0;
|
||||
|
||||
for (auto element = unallocated_data; element != nullptr; element = element->next()) {
|
||||
const auto block_list = element->block_list();
|
||||
|
||||
for (std::int32_t i = 0; i < block_size() && i != count(); ++i) {
|
||||
list.emplace_back(block_list[i].data);
|
||||
|
||||
++index;
|
||||
|
||||
if (index >= count())
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private:
|
||||
UtlMemoryPool entry_memory; // 0x0
|
||||
HashBucket<T, K> buckets; // 0x18
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user