forked from flarialmc/dll-oss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitemget.cpp
More file actions
138 lines (115 loc) · 4.17 KB
/
itemget.cpp
File metadata and controls
138 lines (115 loc) · 4.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#include "itemget.h"
#include <Psapi.h>
#include <iostream>
// グローバル変数の定義
std::vector<ItemInfo> allItems;
bool showItemList = false;
bool initialized = false;
// オリジナル関数のポインタ
typedef void (*RegisterItemFn)(void* registry, void* itemInfo);
RegisterItemFn originalRegisterItem = nullptr;
// アイテム登録関数のフック
void hookedRegisterItem(void* registry, void* itemInfo) {
if (originalRegisterItem) {
originalRegisterItem(registry, itemInfo);
}
// アイテム情報を保存
ItemInfo* info = static_cast<ItemInfo*>(itemInfo);
allItems.push_back(*info);
}
// メモリパターンスキャン関数
uintptr_t FindPattern(const char* module, const char* pattern, const char* mask) {
MODULEINFO modInfo;
GetModuleInformation(GetCurrentProcess(), GetModuleHandleA(module), &modInfo, sizeof(MODULEINFO));
uintptr_t start = (uintptr_t)modInfo.lpBaseOfDll;
uintptr_t end = start + modInfo.SizeOfImage;
for (uintptr_t i = start; i < end; ++i) {
bool found = true;
for (size_t j = 0; j < strlen(mask); ++j) {
if (mask[j] == 'x' && *(char*)(i + j) != pattern[j]) {
found = false;
break;
}
}
if (found) return i;
}
return 0;
}
// アイテムレジストリ関数のアドレス特定
LPVOID FindRegisterItemFunction() {
// 実際のパターンはバイナリ解析により特定する必要がある
const char* pattern = "\x48\x89\x5C\x24\x00\x55\x56\x57\x41\x54"; // 例
const char* mask = "xxxx?xxxxx";
return (LPVOID)FindPattern("Minecraft.Windows.exe", pattern, mask);
}
// 初期化関数
void InitializeItemGet() {
if (initialized) return;
// MinHookの初期化
if (MH_Initialize() != MH_OK) {
std::cout << "MinHookの初期化に失敗しました" << std::endl;
return;
}
// アイテム登録関数のアドレスを特定
LPVOID registerItemAddr = FindRegisterItemFunction();
if (!registerItemAddr) {
std::cout << "アイテム登録関数のアドレスが見つかりません" << std::endl;
return;
}
// フックの作成
if (MH_CreateHook(registerItemAddr, &hookedRegisterItem,
reinterpret_cast<LPVOID*>(&originalRegisterItem)) != MH_OK) {
std::cout << "フックの作成に失敗しました" << std::endl;
return;
}
// フックの有効化
if (MH_EnableHook(MH_ALL_HOOKS) != MH_OK) {
std::cout << "フックの有効化に失敗しました" << std::endl;
return;
}
initialized = true;
std::cout << "ItemGet機能が初期化されました" << std::endl;
}
// 終了処理
void ShutdownItemGet() {
if (!initialized) return;
MH_DisableHook(MH_ALL_HOOKS);
MH_Uninitialize();
initialized = false;
allItems.clear();
}
// アイテムリストの表示
void RenderItemList() {
if (!showItemList) return;
ImGui::Begin("アイテムリスト", &showItemList);
if (ImGui::BeginTabBar("ItemListTabs")) {
if (ImGui::BeginTabItem("アイテム一覧")) {
static char searchText[256] = "";
ImGui::InputText("検索", searchText, IM_ARRAYSIZE(searchText));
ImGui::BeginChild("ItemList", ImVec2(0, 0), true);
for (const auto& item : allItems) {
if (strlen(searchText) == 0 ||
item.name.find(searchText) != std::string::npos) {
ImGui::Text("名前: %s", item.name.c_str());
ImGui::Text("ID: %d", item.id);
ImGui::Text("説明: %s", item.description.c_str());
ImGui::Separator();
}
}
ImGui::EndChild();
ImGui::EndTabItem();
}
ImGui::EndTabBar();
}
ImGui::End();
}
// アイテムリストの表示/非表示を切り替え
void ToggleItemList() {
showItemList = !showItemList;
}
// 全アイテムの収集
void CollectAllItems() {
allItems.clear();
// ここでアイテムレジストリから全アイテムを収集
// 実際の実装はゲームの構造に依存
}