title: Substituting/overriding Windows CRT for low-level debugging
body: <p>I have been looking at <a href="https://github.com/ValveSoftware/source-sdk-2013/blob/master/mp/src/public/tier0/memoverride.cpp" rel="nofollow noreferrer">some Source Engine code</a> recently, and in the very low layers the developers have a file called <code>memoverride.cpp</code> which overrides some core runtime facilities for debugging purposes. This involves re-implementing the entire interface that the CRT provides (eg. functions for <code>malloc</code> and <code>msize</code>, stubs for <code>_crtBreakAlloc</code>, etc.) and routing the calls through a custom class to keep track of allocations and the like.</p>
  
  <p>I thought this was interesting and tried to recreate it myself out of curiosity, but when linking I get conflicts between the custom implementation and <code>libucrt</code>'s symbols. If I use the <code>/Zl</code> compiler option on Windows to not link against the Windows CRT, I then get all sorts of undefined symbols regarding the rest of the CRT functionality (the string functions, for example).</p>
  
  <p>Is this approach advisable for low-level debugging, and if so, what's the correct way to accomplish it? Would it require not linking against the CRT at all, or only choosing parts of it?</p>