MCPcopy Create free account
hub / github.com/Atarity/Lightpack / init

Method init

Software/hooks/IPCContext.cpp:7–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5}
6
7bool IPCContext::init() {
8 if (NULL == (m_hMutex = OpenMutexW(SYNCHRONIZE, false, HOOKSGRABBER_MUTEX_MEM_NAME))) {
9 m_logger->reportLogError(L"error occured while opening mutex 0x%x", GetLastError());
10 this->free();
11 return false;
12 }
13
14 if (NULL == (m_hSharedMem = OpenFileMappingW(GENERIC_WRITE | GENERIC_READ, false, HOOKSGRABBER_SHARED_MEM_NAME))) {
15 m_logger->reportLogError(L"error occured while opening memory-mapped file 0x%x", GetLastError());
16 this->free();
17 return false;
18 }
19
20 if (NULL == (m_hFrameGrabbedEvent = CreateEventW(NULL, true, false, HOOKSGRABBER_FRAMEGRABBED_EVENT_NAME))) {
21 m_logger->reportLogError(L"error occured while opening event 0x%x", GetLastError());
22 this->free();
23 return false;
24 }
25
26 m_pMemMap = MapViewOfFile(m_hSharedMem, FILE_MAP_WRITE, 0, 0, HOOKSGRABBER_SHARED_MEM_SIZE);
27 if (m_pMemMap == NULL) {
28 m_logger->reportLogError(L"error occured while creating mapview 0x%x", GetLastError());
29 this->free();
30 return false;
31 }
32
33 PVOID pMemMapReadOnly = MapViewOfFile(m_hSharedMem, FILE_MAP_READ, 0, 0, HOOKSGRABBER_SHARED_MEM_SIZE);
34 if (pMemMapReadOnly == NULL) {
35 m_logger->reportLogError(L"error occured while creating read-only mapview 0x%x", GetLastError());
36 this->free();
37 return false;
38 }
39
40 memcpy(&m_memDesc, pMemMapReadOnly, sizeof(m_memDesc));
41
42 UnmapViewOfFile(pMemMapReadOnly);
43
44 m_memDesc.frameId = 0;
45
46 m_logger->reportLogInfo(L"d3d9 device::present(): 0x%x", m_memDesc.d3d9PresentFuncOffset);
47 m_logger->reportLogInfo(L"d3d9 swapchain::present(): 0x%x", m_memDesc.d3d9SCPresentFuncOffset);
48 m_logger->reportLogInfo(L"dxgi swapchain::present(): 0x%x", m_memDesc.dxgiPresentFuncOffset);
49
50 return true;
51}
52
53void IPCContext::free() {
54 if (m_hMutex)

Callers 1

DllMainFunction · 0.45

Calls 3

freeMethod · 0.95
reportLogErrorMethod · 0.80
reportLogInfoMethod · 0.80

Tested by

no test coverage detected