| 48 | } |
| 49 | |
| 50 | HOOKSDLL_API BOOL APIENTRY DllMain(HINSTANCE hModule, DWORD fdwReason, LPVOID lpReserved) { |
| 51 | UNREFERENCED_PARAMETER(lpReserved); |
| 52 | |
| 53 | if (fdwReason == DLL_PROCESS_ATTACH /*|| fdwReason == DLL_THREAD_ATTACH*/) // When initializing.... |
| 54 | { |
| 55 | // __asm__("int $3"); |
| 56 | // We don't need thread notifications for what we're doing. Thus, get |
| 57 | // rid of them, thereby eliminating some of the overhead of this DLL |
| 58 | DisableThreadLibraryCalls(hModule); |
| 59 | |
| 60 | HMODULE hProc = GetModuleHandle(NULL); |
| 61 | GetModuleFileNameA(hProc, executableName, sizeof (executableName)); |
| 62 | PathStripPathA(executableName); |
| 63 | |
| 64 | WCHAR *wstrEventSource = getEventSourceName(executableName); |
| 65 | |
| 66 | gLog->initLog(wstrEventSource, PRISMATIK_LOG_SEVERITY_INFO); |
| 67 | gLog->reportLogInfo(L"Library initialization..."); |
| 68 | |
| 69 | free(wstrEventSource); |
| 70 | |
| 71 | // void *zctx = zmq_ctx_new(); |
| 72 | // void *req_socket = zmq_socket(zctx, ZMQ_REQ); |
| 73 | // zmq_connect(req_socket, ""); |
| 74 | |
| 75 | |
| 76 | if (!gIpcContext) |
| 77 | gIpcContext = new IPCContext(gLog); |
| 78 | |
| 79 | if (gIpcContext->init()) { |
| 80 | |
| 81 | if (NULL == (g_syncRunMutex = CreateMutex(NULL, false, NULL))) { |
| 82 | } |
| 83 | |
| 84 | gLog->setLogLevel(gIpcContext->m_memDesc.logLevel); |
| 85 | |
| 86 | if (!d3d9FrameGrabber) { |
| 87 | d3d9FrameGrabber = D3D9FrameGrabber::getInstance(g_syncRunMutex); |
| 88 | d3d9FrameGrabber->setIPCContext(gIpcContext); |
| 89 | } |
| 90 | |
| 91 | if (d3d9FrameGrabber->isGAPILoaded()) { |
| 92 | if (!d3d9FrameGrabber->init() || !d3d9FrameGrabber->installHooks()) { |
| 93 | DWORD errorcode = GetLastError(); |
| 94 | gLog->reportLogError(L"error occured while hijacking d3d9 0x%x", errorcode); |
| 95 | } else { |
| 96 | gLog->reportLogInfo(L"d3d9 hook has been installed successfully"); |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | if(!dxgiFrameGrabber) { |
| 101 | dxgiFrameGrabber = DxgiFrameGrabber::getInstance(); |
| 102 | dxgiFrameGrabber->setIPCContext(gIpcContext); |
| 103 | } |
| 104 | |
| 105 | if(dxgiFrameGrabber->isGAPILoaded()) { |
| 106 | if (!dxgiFrameGrabber->init() || !dxgiFrameGrabber->installHooks()) { |
| 107 | DWORD errorcode = GetLastError(); |
nothing calls this directly
no test coverage detected