MCPcopy Create free account
hub / github.com/Norbyte/ositools / FindServerGlobalsEoCApp

Method FindServerGlobalsEoCApp

OsiInterface/DataLibrariesEoCApp.cpp:112–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110 }
111
112 void LibraryManager::FindServerGlobalsEoCApp()
113 {
114 EoCLibraryInfo const * serverLib{ nullptr };
115 for (auto const & v : libraries_) {
116 if (v.second.refs > 100) {
117 serverLib = &v.second;
118 break;
119 }
120 }
121
122 if (serverLib == nullptr) {
123 Fail("LibraryManager::FindServerGlobalsEoCApp(): Could not find esv library!");
124 return;
125 }
126
127 for (auto p = serverLib->initFunc; p < serverLib->initFunc + 0x1000; p++) {
128 if (p[0] == 0x48 && p[1] == 0x89 && p[2] == 0x05
129 && p[7] == 0xEB && p[8] == 0x07
130 && p[9] == 0x48 && p[10] == 0x89
131 && p[16] == 0xE8
132 && p[21] == 0xE8
133 && p[26] == 0xE8
134 && p[31] == 0xE8
135 && p[36] == 0xE8) {
136
137 uint8_t const * funcPtr = p + 16;
138 for (auto i = 0; i < 36; i++) {
139 int32_t rel = *(int32_t *)(funcPtr + 1);
140 uint8_t const * registrantFunc = funcPtr + rel + 5;
141 serverRegisterFuncs_[i] = registrantFunc;
142 funcPtr += 5;
143 }
144
145 funcPtr = p + 16 + (36 * 5) + 0x2C;
146 for (auto i = 0; i < 14; i++) {
147 int32_t rel = *(int32_t *)(funcPtr + 1);
148 uint8_t const * registrantFunc = funcPtr + rel + 5;
149 serverRegisterFuncs_[i + 36] = registrantFunc;
150 funcPtr += 5;
151 }
152
153 for (auto i = 0; i < std::size(serverRegisterFuncs_); i++) {
154 uint8_t const * r = serverRegisterFuncs_[i];
155 if (r[0] == 0x48 && r[1] == 0x83 && r[2] == 0xEC /* sub rsp, XXh */
156 && r[4] == 0x48 && r[5] == 0x8B && r[6] == 0x05 /* mov rax, cs:xxx */) {
157
158 int32_t rel = *(int32_t *)(r + 7);
159 uint8_t const * registrantObj = r + rel + 4 + 7;
160 serverGlobals_[i] = (uint8_t const **)registrantObj;
161
162 }
163 else {
164 serverGlobals_[i] = nullptr;
165 Debug("LibraryManager::FindServerGlobalsEoCApp(): Could not extract global from func @ %p", r);
166 }
167 }
168 }
169 }

Callers

nothing calls this directly

Calls 2

DebugFunction · 0.85
FailFunction · 0.70

Tested by

no test coverage detected