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

Method FindLibrariesEoCApp

OsiInterface/DataLibrariesEoCApp.cpp:61–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59
60
61 void LibraryManager::FindLibrariesEoCApp()
62 {
63 uint8_t const prologue1[] = {
64 0x8B, 0xC8, // mov ecx, eax
65 0xFF, 0xC0, // inc eax
66 0x89, 0x05 // mov cs:xxx, eax
67 };
68
69 uint8_t const prologue2[] = {
70 0x85, 0xC9, // test ecx, ecx
71 0x75, 0x17, // jnz short loc_xxx
72 0x44, 0x8D, 0x41 // lea r8d, [rdx+XXh]
73 };
74
75 uint8_t const prologue3[] = {
76 0x48, 0x8D, 0x0D // lea rcx, xxx
77 };
78
79 uint8_t const * p = (uint8_t const *)moduleStart_;
80 uint8_t const * moduleEnd = p + moduleSize_;
81
82 for (; p < moduleEnd - 100; p++) {
83 if (*p == 0x8B
84 // && memcmp(p, prologue0, sizeof(prologue0)) == 0
85 && memcmp(p + 0x06, prologue1, sizeof(prologue1)) == 0
86 && memcmp(p + 0x10, prologue2, sizeof(prologue2)) == 0
87 && memcmp(p + 0x18, prologue3, sizeof(prologue3)) == 0) {
88 int32_t rel1 = *(int32_t *)(p + 0x1B);
89 int32_t rel2 = *(int32_t *)(p + 0x22);
90
91 uint8_t const * initFunc = p + rel1 + 0x18 + 7;
92 uint8_t const * freeFunc = p + rel2 + 0x1F + 7;
93
94 auto it = libraries_.find(initFunc);
95 if (it != libraries_.end()) {
96 it->second.refs++;
97 }
98 else {
99 libraries_.insert(std::pair<uint8_t const *, EoCLibraryInfo>(initFunc, { initFunc, freeFunc, 1 }));
100 }
101 }
102 }
103
104#if 0
105 Debug("LibraryManager::FindLibrariesEoCApp(): Found libraries:");
106 for (auto const & v : libraries_) {
107 Debug("\t(Init %p; Dtor %p, Refs %d)!", v.second.initFunc, v.second.freeFunc, v.second.refs);
108 }
109#endif
110 }
111
112 void LibraryManager::FindServerGlobalsEoCApp()
113 {

Callers

nothing calls this directly

Calls 1

DebugFunction · 0.85

Tested by

no test coverage detected