void APIHijack::event_thread_context_init(void *drcontext, bool new_depth) { if (new_depth) { Logger* logger = (Logger*) dr_thread_alloc(drcontext, sizeof(Logger)); logger->Initialize(AUDIT_FILE); drmgr_set_cls_field(drcontext, tlsIdx, logger); } }
EngineCore::EngineCore(std::wstring logFile) { _Logger.Initialize(m_logFile); try { m_engineRunning = false; m_logFile = logFile; m_graphicsCore = new Kiwi::GraphicsCore(); m_sceneManager = new Kiwi::SceneManager(this); }catch(...) { throw; } }
int __cdecl _tmain(int argc, _TCHAR* argv[]) { #if defined(TWO_PIPE) // // Experiment with pipe to pipe so we can debug using VPC and capture // a log of a working debug session. // PipeReader sock; #else SockReader sock; #endif PipeReader pipe; Logger log; // // Save the name of the current running program. This is not presented // in argv[0] as you might expect... but hey, this is Windows. // GetModuleFileName(NULL, g_progname, sizeof (g_progname)); g_progname[sizeof(g_progname) - 1] = _T('\0'); *argv++; --argc; if (argc == 0) usage(); // // Three arguments if you count the program name, the pipe name and // the port (or 2nd pipe). // if (_tcsncmp(*argv, _T("-l"), 2) == 0) { if (!log.Initialize()) { die("couldn't initialize logger"); } argv++; --argc; if (argc == 0) usage(); } bool passive; if (argc == 2) { passive = true; } else if (argc == 3) { passive = false; } else { usage(); } g_log = &log; // // Note: sock.Initialize will fire up the socket pump thread, // pipe initialization needs to be completed before that. // _TCHAR * lpipename = *argv; #define whack_pipe _T("\\\\.\\pipe\\") size_t whackPipeLen = (sizeof(whack_pipe) / sizeof(_TCHAR)) - 1; if (_tcsnccmp(lpipename, whack_pipe, whackPipeLen) != 0) { size_t originalNameLen = _tcslen(lpipename); size_t nameLen = whackPipeLen + originalNameLen + 1; if (nameLen > 1024) // arbitary { die("pipe name is too long."); } lpipename = (_TCHAR *)malloc(nameLen * sizeof(_TCHAR)); if (lpipename == NULL) { die("failed to malloc space for local pipe name."); } memcpy(&lpipename[0], whack_pipe, whackPipeLen * sizeof(_TCHAR)); memcpy(&lpipename[whackPipeLen], *argv, originalNameLen * sizeof(_TCHAR)); lpipename[nameLen - 1] = 0; } argv++; printf("gonna try pipe '%s'\n", lpipename); if (!pipe.Initialize(lpipename, &log, &sock, false, false, "pip")) { die("couldn't open local named pipe, err %d", GetLastError()); } #if !defined(TWO_PIPE) _TCHAR * address; _TCHAR * portnumber; if (passive) { address = NULL; portnumber = *argv; } else { address = *argv++; portnumber = *argv; } if (!sock.Initialize(address, portnumber, &log, &pipe, true, "win")) { die("couldn't open socket."); } #else _TCHAR * rpipename = *argv; if (!sock.Initialize(rpipename, &log, &pipe, true, true, "sok")) { die("couldn't open remote pipe."); } #endif // // We run the pipe reader directly on this thread. // pipe.ThreadEntry(&pipe); return 0; }