int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pCmdLine, int nCmdShow) { DbgInitialise(hInstance); g_App.SetAppValues(hInstance, APPNAME, IDS_APP_TITLE) ; // Perform application initialization: if(! g_App.InitInstance(nCmdShow)) { DbgTerminate(); return (FALSE) ; } HACCEL hAccelTable ; hAccelTable = LoadAccelerators(hInstance, g_App.GetAppName()) ; // Main message loop: MSG msg ; while(GetMessage(&msg, NULL, 0, 0)) { if(! TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg) ; DispatchMessage(&msg) ; } } DbgTerminate(); return ((int) msg.wParam) ; }
DWORD WINAPI DbgRegisterObjectCreation(const CHAR *szObjectName, const WCHAR *wszObjectName) { /* If this fires you have a mixed DEBUG/RETAIL build */ ASSERT(!!szObjectName ^ !!wszObjectName); /* Create a place holder for this object description */ ObjectDesc *pObject = new ObjectDesc; ASSERT(pObject); /* It is valid to pass a NULL object name */ if (pObject == NULL) { return FALSE; } /* Check we have been initialised - we may not be initialised when we are being pulled in from an executable which has globally defined objects as they are created by the C++ run time before WinMain is called */ if (m_bInit == FALSE) { DbgInitialise(GetModuleHandle(NULL)); } /* Grab the list critical section */ EnterCriticalSection(&m_CSDebug); /* If no name then default to UNKNOWN */ if (!szObjectName && !wszObjectName) { szObjectName = pUnknownName; } /* Put the new description at the head of the list */ pObject->m_szName = szObjectName; pObject->m_wszName = wszObjectName; pObject->m_dwCookie = ++m_dwNextCookie; pObject->m_pNext = pListHead; pListHead = pObject; m_dwObjectCount++; DWORD ObjectCookie = pObject->m_dwCookie; ASSERT(ObjectCookie); if(wszObjectName) { DbgLog((LOG_MEMORY,2,TEXT("Object created %d (%ls) %d Active"), pObject->m_dwCookie, wszObjectName, m_dwObjectCount)); } else { DbgLog((LOG_MEMORY,2,TEXT("Object created %d (%hs) %d Active"), pObject->m_dwCookie, szObjectName, m_dwObjectCount)); } LeaveCriticalSection(&m_CSDebug); return ObjectCookie; }