Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- kit_parser.cpp
- #include <algorithm>
- #include "kit_parser.hpp"
- #include "helpers\utils.hpp"
- std::vector<paint_kit> k_skins;
- std::vector<paint_kit> k_gloves;
- std::vector<paint_kit> k_stickers;
- class CCStrike15ItemSchema;
- class CCStrike15ItemSystem;
- template <typename Key, typename Value>
- struct Node_t
- {
- int previous_id;
- int next_id;
- void* _unknown_ptr;
- int _unknown;
- Key key;
- Value value;
- };
- template <typename Key, typename Value>
- struct Head_t
- {
- Node_t<Key, Value>* memory;
- int allocation_count;
- int grow_size;
- int start_element;
- int next_available;
- int _unknown;
- int last_element;
- };
- struct String_t
- {
- char* buffer;
- int capacity;
- int grow_size;
- int length;
- };
- struct CPaintKit
- {
- int id;
- String_t name;
- String_t description;
- String_t item_name;
- String_t material_name;
- String_t image_inventory;
- char pad_0x0054[0x8C];
- };
- struct CStickerKit
- {
- int id;
- int item_rarity;
- String_t name;
- String_t description;
- String_t item_name;
- String_t material_name;
- String_t image_inventory;
- int tournament_event_id;
- int tournament_team_id;
- int tournament_player_id;
- bool is_custom_sticker_material;
- float rotate_end;
- float rotate_start;
- float scale_min;
- float scale_max;
- float wear_min;
- float wear_max;
- String_t image_inventory2;
- String_t image_inventory_large;
- std::uint32_t pad0[4];
- };
- auto get_export(const char* module_name, const char* export_name) -> void*
- {
- HMODULE mod;
- while (!((mod = GetModuleHandleA(module_name))))
- Sleep(100);
- return reinterpret_cast<void*>(GetProcAddress(mod, export_name));
- }
- auto initialize_kits() -> void
- {
- const auto V_UCS2ToUTF8 = static_cast<int(*)(const wchar_t* ucs2, char* utf8, int len)>(get_export("vstdlib.dll", "V_UCS2ToUTF8"));
- const auto sig_address = Utils::PatternScan(GetModuleHandle(L"client_panorama.dll"), "E8 ? ? ? ? FF 76 0C 8D 48 04 E8");
- // Skip the opcode, read rel32 address
- const auto item_system_offset = *reinterpret_cast<std::int32_t*>(sig_address + 1);
- const auto item_system_fn = reinterpret_cast<CCStrike15ItemSystem* (*)()>(sig_address + 5 + item_system_offset);
- const auto item_schema = reinterpret_cast<CCStrike15ItemSchema*>(std::uintptr_t(item_system_fn()) + sizeof(void*));
- {
- const auto get_paint_kit_definition_offset = *reinterpret_cast<std::int32_t*>(sig_address + 11 + 1);
- const auto get_paint_kit_definition_fn = reinterpret_cast<CPaintKit*(__thiscall*)(CCStrike15ItemSchema*, int)>(sig_address + 11 + 5 + get_paint_kit_definition_offset);
- const auto start_element_offset = *reinterpret_cast<std::intptr_t*>(std::uintptr_t(get_paint_kit_definition_fn) + 8 + 2);
- const auto head_offset = start_element_offset - 12;
- const auto map_head = reinterpret_cast<Head_t<int, CPaintKit*>*>(std::uintptr_t(item_schema) + head_offset);
- for (auto i = 0; i <= map_head->last_element; ++i)
- {
- const auto paint_kit = map_head->memory[i].value;
- if (paint_kit->id == 9001)
- continue;
- const auto wide_name = g_Localize->Find(paint_kit->item_name.buffer + 1);
- char name[256];
- V_UCS2ToUTF8(wide_name, name, sizeof(name));
- if (paint_kit->id < 10000)
- k_skins.push_back({ paint_kit->id, name });
- else
- k_gloves.push_back({ paint_kit->id, name });
- }
- std::sort(k_skins.begin(), k_skins.end());
- std::sort(k_gloves.begin(), k_gloves.end());
- }
- }
- kit_parser.hpp
- #pragma once
- #include <vector>
- struct paint_kit
- {
- int id;
- std::string name;
- auto operator < (const paint_kit& other) const -> bool
- {
- return name < other.name;
- }
- };
- extern std::vector<paint_kit> k_skins;
- extern std::vector<paint_kit> k_gloves;
- extern auto initialize_kits() -> void;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement