@The trick
You probably shouldn't use HeapLock and HeapUnlock when creating the heap with the HEAP_NO_SERIALIZE flag as stated in the MSDN:
If the HeapLock and HeapUnlock functions are called on a heap created with the HEAP_NO_SERIALIZE flag, the results are undefined.