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

Method OnRegisterDIVFunctions

OsiInterface/OsirisProxy.cpp:191–255  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189#endif
190
191void OsirisProxy::OnRegisterDIVFunctions(void * Osiris, DivFunctions * Functions)
192{
193 // FIXME - register before OsirisWrappers!
194 StoryLoaded = false;
195 DynGlobals.OsirisObject = Osiris;
196 uint8_t * interfaceLoadPtr = nullptr;
197 // uint8_t * errorMessageFunc = ResolveRealFunctionAddress((uint8_t *)Functions->ErrorMessage);
198 uint8_t * errorMessageFunc = ResolveRealFunctionAddress((uint8_t *)Wrappers.ErrorOriginal);
199
200 // Try to find ptr of gOsirisInterface
201 OsirisInterface * osirisInterface = nullptr;
202 for (uint8_t * ptr = errorMessageFunc; ptr < errorMessageFunc + 64; ptr++) {
203 // Look for the instruction "mov rbx, cs:gOsirisInterface"
204 if (ptr[0] == 0x48 && ptr[1] == 0x8B && ptr[2] == 0x1D && ptr[6] < 0x02) {
205 int32_t relOffset = *reinterpret_cast<int32_t *>(ptr + 3);
206 uint64_t osiPtr = (uint64_t)ptr + relOffset + 7;
207 osirisInterface = *(OsirisInterface **)osiPtr;
208 DynGlobals.Manager = osirisInterface->Manager;
209 break;
210 }
211 }
212
213 if (DynGlobals.Manager == nullptr) {
214 Fail("Could not locate OsirisInterface");
215 }
216
217 if (LoggingEnabled) {
218 RestartLogging(L"Runtime");
219 }
220
221#if 0
222 Debug("OsirisProxy::OnRegisterDIVFunctions: Initializing story.");
223 Debug("\tErrorMessageProc = %p", errorMessageFunc);
224 Debug("\tOsirisManager = %p", Globals.Manager);
225 Debug("\tOsirisInterface = %p", osirisInterface);
226#endif
227
228#if !defined(OSI_NO_DEBUGGER)
229 // FIXME - move to DebuggerHooks
230 if (DebuggingEnabled) {
231 if (DebuggerThread == nullptr) {
232 Debug("Starting debugger server");
233 debugInterface_ = std::make_unique<DebugInterface>(DebuggerPort);
234 debugMsgHandler_ = std::make_unique<DebugMessageHandler>(std::ref(*debugInterface_));
235
236 DebuggerThread = new std::thread(std::bind(DebugThreadRunner, std::ref(*debugInterface_)));
237 }
238 } else if (!DebugDisableLogged) {
239 Debug("Debugging not enabled; not starting debugger server thread.");
240 DebugDisableLogged = true;
241 }
242#endif
243
244 if (ExtensionsEnabled) {
245 if (Libraries.PostStartupFindLibraries()) {
246 FunctionLibrary.PostStartup();
247 }
248 }

Callers

nothing calls this directly

Calls 8

DebugFunction · 0.85
PostStartupMethod · 0.80
ShowStartupErrorMethod · 0.80
InitializationFailedMethod · 0.80
FailFunction · 0.70

Tested by

no test coverage detected