Skip to content

Enable use of RtlDisownModuleHeapAllocation when available #256

@jonwis

Description

@jonwis

__declspec(selectany) NTSTATUS(__stdcall *g_pfnRtlDisownModuleHeapAllocation)(_In_ HANDLE heapHandle, _In_ PVOID address) WI_PFN_NOEXCEPT = nullptr;
// Allocate and disown the allocation so that Appverifier does not complain about a false leak
inline PVOID ProcessHeapAlloc(_In_ DWORD flags, _In_ size_t size)
{
PVOID allocation = ::HeapAlloc(::GetProcessHeap(), flags, size);
if (g_pfnRtlDisownModuleHeapAllocation)
{
(void)g_pfnRtlDisownModuleHeapAllocation(::GetProcessHeap(), allocation);

This API is now publicly documented - https://docs.microsoft.com/en-us/windows/win32/DevNotes/rtlsupportapi/nf-rtlsupportapi-rtldisownmoduleheapallocation

Move the setting of the function pointer to the global init path when available so apps using appverifier and wil no longer get a "leak" warning.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions