HMODULE wutil_LibModuleHandle() { HMODULE hModule; const DWORD flags = GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS|GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT; const BOOL ok = GetModuleHandleEx(flags, (LPCWSTR)&wutil_LibModuleHandle, &hModule); // (avoid ENSURE etc. because we're called from debug_DisplayError) wdbg_assert(ok); return hModule; }
void wdbg_heap_Validate() { int ok = TRUE; __try { // NB: this is a no-op if !_CRTDBG_ALLOC_MEM_DF. // we could call _heapchk but that would catch fewer errors. ok = _CrtCheckMemory(); } __except(EXCEPTION_EXECUTE_HANDLER) { ok = FALSE; } wdbg_assert(ok == TRUE); // else: heap is corrupt! }