Advertisement
Guest User

Untitled

a guest
Jul 1st, 2019
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.71 KB | None | 0 0
  1.  
  2.  
  3. kit_parser.cpp
  4.  
  5.  
  6. #include <algorithm>
  7. #include "kit_parser.hpp"
  8. #include "helpers\utils.hpp"
  9. std::vector<paint_kit> k_skins;
  10. std::vector<paint_kit> k_gloves;
  11. std::vector<paint_kit> k_stickers;
  12. class CCStrike15ItemSchema;
  13. class CCStrike15ItemSystem;
  14. template <typename Key, typename Value>
  15. struct Node_t
  16. {
  17. int previous_id;
  18. int next_id;
  19. void* _unknown_ptr;
  20. int _unknown;
  21. Key key;
  22. Value value;
  23. };
  24. template <typename Key, typename Value>
  25. struct Head_t
  26. {
  27. Node_t<Key, Value>* memory;
  28. int allocation_count;
  29. int grow_size;
  30. int start_element;
  31. int next_available;
  32. int _unknown;
  33. int last_element;
  34. };
  35. struct String_t
  36. {
  37. char* buffer;
  38. int capacity;
  39. int grow_size;
  40. int length;
  41. };
  42. struct CPaintKit
  43. {
  44. int id;
  45. String_t name;
  46. String_t description;
  47. String_t item_name;
  48. String_t material_name;
  49. String_t image_inventory;
  50. char pad_0x0054[0x8C];
  51. };
  52.  
  53. struct CStickerKit
  54. {
  55. int id;
  56.  
  57. int item_rarity;
  58.  
  59. String_t name;
  60. String_t description;
  61. String_t item_name;
  62. String_t material_name;
  63. String_t image_inventory;
  64.  
  65. int tournament_event_id;
  66. int tournament_team_id;
  67. int tournament_player_id;
  68. bool is_custom_sticker_material;
  69.  
  70. float rotate_end;
  71. float rotate_start;
  72.  
  73. float scale_min;
  74. float scale_max;
  75.  
  76. float wear_min;
  77. float wear_max;
  78.  
  79. String_t image_inventory2;
  80. String_t image_inventory_large;
  81.  
  82. std::uint32_t pad0[4];
  83. };
  84.  
  85. auto get_export(const char* module_name, const char* export_name) -> void*
  86. {
  87. HMODULE mod;
  88. while (!((mod = GetModuleHandleA(module_name))))
  89. Sleep(100);
  90. return reinterpret_cast<void*>(GetProcAddress(mod, export_name));
  91. }
  92. auto initialize_kits() -> void
  93. {
  94. const auto V_UCS2ToUTF8 = static_cast<int(*)(const wchar_t* ucs2, char* utf8, int len)>(get_export("vstdlib.dll", "V_UCS2ToUTF8"));
  95.  
  96. const auto sig_address = Utils::PatternScan(GetModuleHandle(L"client_panorama.dll"), "E8 ? ? ? ? FF 76 0C 8D 48 04 E8");
  97. // Skip the opcode, read rel32 address
  98. const auto item_system_offset = *reinterpret_cast<std::int32_t*>(sig_address + 1);
  99.  
  100. const auto item_system_fn = reinterpret_cast<CCStrike15ItemSystem* (*)()>(sig_address + 5 + item_system_offset);
  101.  
  102. const auto item_schema = reinterpret_cast<CCStrike15ItemSchema*>(std::uintptr_t(item_system_fn()) + sizeof(void*));
  103.  
  104. {
  105.  
  106. const auto get_paint_kit_definition_offset = *reinterpret_cast<std::int32_t*>(sig_address + 11 + 1);
  107.  
  108. const auto get_paint_kit_definition_fn = reinterpret_cast<CPaintKit*(__thiscall*)(CCStrike15ItemSchema*, int)>(sig_address + 11 + 5 + get_paint_kit_definition_offset);
  109.  
  110. const auto start_element_offset = *reinterpret_cast<std::intptr_t*>(std::uintptr_t(get_paint_kit_definition_fn) + 8 + 2);
  111.  
  112. const auto head_offset = start_element_offset - 12;
  113. const auto map_head = reinterpret_cast<Head_t<int, CPaintKit*>*>(std::uintptr_t(item_schema) + head_offset);
  114. for (auto i = 0; i <= map_head->last_element; ++i)
  115. {
  116. const auto paint_kit = map_head->memory[i].value;
  117. if (paint_kit->id == 9001)
  118. continue;
  119. const auto wide_name = g_Localize->Find(paint_kit->item_name.buffer + 1);
  120.  
  121. char name[256];
  122.  
  123. V_UCS2ToUTF8(wide_name, name, sizeof(name));
  124. if (paint_kit->id < 10000)
  125. k_skins.push_back({ paint_kit->id, name });
  126. else
  127. k_gloves.push_back({ paint_kit->id, name });
  128.  
  129.  
  130. }
  131. std::sort(k_skins.begin(), k_skins.end());
  132. std::sort(k_gloves.begin(), k_gloves.end());
  133. }
  134.  
  135.  
  136.  
  137. }
  138.  
  139.  
  140.  
  141.  
  142. kit_parser.hpp
  143.  
  144.  
  145. #pragma once
  146. #include <vector>
  147. struct paint_kit
  148. {
  149. int id;
  150. std::string name;
  151. auto operator < (const paint_kit& other) const -> bool
  152. {
  153. return name < other.name;
  154. }
  155. };
  156. extern std::vector<paint_kit> k_skins;
  157. extern std::vector<paint_kit> k_gloves;
  158. extern auto initialize_kits() -> void;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement