Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have implemented a function now that basically does what is intended after finding a list of magic numbers on wiki <a href="https://en.wikipedia.org/wiki/Magic_number_%28programming%29" rel="nofollow">(Magic numbers)</a>:</p> <pre><code>/** Performs a check for potentially unintiialised data \remarks May incorrectly report uninitialised data as it is always possible the contained data may match the magic numbers in rare circumstances so this function should be used for initial identification of uninitialised data only */ bool hasUninitialisedData( const char* data, size_t lenData ) { const unsigned int kUninitialisedMagic[] = { 0xABABABAB, // Used by Microsoft's HeapAlloc() to mark "no man's land" guard bytes after allocated heap memory 0xABADCAFE, // A startup to this value to initialize all free memory to catch errant pointers 0xBAADF00D, // Used by Microsoft's LocalAlloc(LMEM_FIXED) to mark uninitialised allocated heap memory 0xBADCAB1E, // Error Code returned to the Microsoft eVC debugger when connection is severed to the debugger 0xBEEFCACE, // Used by Microsoft .NET as a magic number in resource files 0xCCCCCCCC, // Used by Microsoft's C++ debugging runtime library to mark uninitialised stack memory 0xCDCDCDCD, // Used by Microsoft's C++ debugging runtime library to mark uninitialised heap memory 0xDEADDEAD, // A Microsoft Windows STOP Error code used when the user manually initiates the crash. 0xFDFDFDFD, // Used by Microsoft's C++ debugging heap to mark "no man's land" guard bytes before and after allocated heap memory 0xFEEEFEEE, // Used by Microsoft's HeapFree() to mark freed heap memory }; const unsigned int kUninitialisedMagicCount = sizeof(kUninitialisedMagic)/sizeof(kUninitialisedMagic[0]); if ( lenData &lt; 4 ) return assert(false=="not enough data for checks!"), false; for ( unsigned int i =0; i &lt; lenData - 4; ++i ) //&lt; we don't check the last few bytes as keep to full 4-byte/int checks for now, this is where the -4 comes in { for ( unsigned int iMagic = 0; iMagic &lt; kUninitialisedMagicCount; ++iMagic ) { const unsigned int* ival = reinterpret_cast&lt;const unsigned int*&gt;(data + i); if ( *ival == kUninitialisedMagic[iMagic] ) return true; } } return false; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload