void PDataManager::UnregisterPdata(RUNTIME_FUNCTION* pdata) { if (AutoSystemInfo::Data.IsWin8OrLater()) { NtdllLibrary::Instance->DeleteGrowableFunctionTable(pdata); } else { BOOLEAN success = RtlDeleteFunctionTable(pdata); Assert(success); } }
/* static */ void XDataAllocator::Unregister(XDataAllocation * xdataInfo) { #ifdef _WIN32 // Delete the table if (AutoSystemInfo::Data.IsWin8OrLater()) { NtdllLibrary::Instance->DeleteGrowableFunctionTable(xdataInfo->functionTable); } else { BOOLEAN success = RtlDeleteFunctionTable(&xdataInfo->pdata); Assert(success); } #else // !_WIN32 Assert(ReadHead(xdataInfo->address)); // should be non-empty .eh_frame __deregister_frame(xdataInfo->address); #endif }
~MemoryManager() { #ifdef _WIN32 if (!RtlDeleteFunctionTable(s_unwind.data())) { LOG_FATAL(GENERAL, "RtlDeleteFunctionTable(%p) failed! Error %u", s_unwind_info, GetLastError()); } if (!VirtualFree(s_memory, 0, MEM_DECOMMIT)) { LOG_FATAL(GENERAL, "VirtualFree(%p) failed! Error %u", s_memory, GetLastError()); } #else if (!::mmap(s_memory, s_memory_size, PROT_NONE, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0)) { LOG_FATAL(GENERAL, "mmap(%p) failed! Error %d", s_memory, errno); } // TODO: unregister EH frames if necessary #endif }