Search code examples
c++windowsheap-memoryheap

Which option has precendence if I enable and disable FrontEndHeapDebugOptions at the same time?


The undocumented (I can't find a MSDN reference) FrontEndHeapDebugOptions Registry key has two flags:

  • Bit 2 (0x04) for disabling the Segment Heap, thus forcing NT Heap
  • Bit 3 (0x08) for enabling the Segment Heap

This is e.g. mentioned in the Windows Internals 7 book. The book doesn't further explain the Registry key.

I see that we need 2 bits here, because Microsoft wants a 3-state flag: enabled, disabled and default.

But since both, enabled and disabled can now be specified at the same time, which one takes precedence?

For completeness, above setting is a DWORD under
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\MyApp.exe


Solution

  • I have created a small application which allocates memory in a loop. I then used WinDbg's !heap command to check what kind of heaps were created. Running it on Windows 10 22H2 (Build 19045.5247) revealed the following:

    • 0x00 resulted in an NT Heap, so NT Heaps are the default.
    • 0x04 resulted in an NT Heap, as expected, since Segment Heap is disabled.
    • 0x08 resulted in a Segment Heap, as expected, since Segment Heap is enabled.
    • 0x0C resulted in an NT Heap, so disabling takes precedence over enabling.