![]() |
Gray C++ Libraries
0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
|
#include <cMem.h>
Static Public Member Functions | |
static void __cdecl | IsValidFailHandler (int nSig) |
static ptrdiff_t | Diff (const void *pEnd, const void *pStart) noexcept |
static bool | IsValidApp (const void *pData) noexcept |
static bool __stdcall | IsValid (const void *pData, size_t nSize=1, bool bWriteAccess=false) noexcept |
static bool | IsCorrupt (const void *pData, size_t nSize=1, bool bWriteAccess=false) noexcept |
static bool | IsZeros (const void *pData, size_t nSize) noexcept |
static COMPARE_t | Compare (const void *p1, const void *p2, size_t nSizeBlock) noexcept |
static COMPARE_t | CompareSecure (const void *p1, const void *p2, size_t nSizeBlock) noexcept |
static size_t __stdcall | CompareIndex (const void *p1, const void *p2, size_t nSizeBlock) |
static void | Zero (void *pData, size_t nSizeBlock) noexcept |
static void | ZeroSecure (void *pData, size_t nSizeBlock) noexcept |
static void | Xor (BYTE *pDst, const BYTE *pSrc, size_t nBlockSize) noexcept |
static void | Xor2 (BYTE *pDst, const BYTE *pSrc1, const BYTE *pSrc2, size_t nBlockSize) noexcept |
static void | Copy (void *pDst, const void *pSrc, size_t nSizeBlock) noexcept |
static void | CopyOverlap (void *pDst, const void *pSrc, size_t nSizeBlock) noexcept |
static void | ReverseBytes (void *pDst, size_t nSizeBlock) noexcept |
static void | CopyReverse (void *pDst, const void *pSrc, size_t nSizeBlock) noexcept |
static void | Fill (void *pDst, size_t nSize, BYTE bVal) noexcept |
static void | CopyRepeat (void *pDst, size_t nDstSize, const void *pSrc, size_t nSrcSize) noexcept |
static void | CopyHtoN (BYTE *pDst, const void *pSrc, size_t nSizeBlock) noexcept |
static void | CopyNtoH (void *pDst, const BYTE *pSrc, size_t nSizeBlock) noexcept |
static void | Swap (void *pvMem1, void *pvMem2, size_t nBlockSize) noexcept |
static StrLen_t __stdcall | ConvertToString (char *pszDst, StrLen_t iSizeDstMax, const BYTE *pSrc, size_t iLenSrc) |
static size_t __stdcall | ReadFromString (BYTE *pDst, size_t iLenBytesMax, const char *pszSrc) |
static StrLen_t | GetHexDigestSize (size_t nSize) noexcept |
static StrLen_t __stdcall | GetHexDigest (OUT char *pszHexString, const BYTE *pData, size_t nSizeData) |
static HRESULT __stdcall | SetHexDigest (const char *pszHexString, OUT BYTE *pData, size_t nSizeData) |
Static Public Attributes | |
static volatile uintptr_t | sm_bDontOptimizeOut0 = 0 |
used to trick the optimizer. Always 0. More... | |
static volatile uintptr_t | sm_bDontOptimizeOutX = 1 |
used to trick the optimizer. Unknown value. More... | |
Friends | |
class | cMemTests |
a void type memory block. test bytes, Move memory bytes around. May be on heap, const memory space or static in stack. do NOT assume. use cHeap.
|
inlinestaticnoexcept |
Compare two blocks of memory. ASSUME both are at least nSizeBlock sized. Does not assume memory alignment.
|
static |
Compare two buffers and return at what point they differ. Does not assume memory alignment for uintptr_t block compares.
|
inlinestaticnoexcept |
constant-time buffer comparison. NOT efficient. Prevents timing based hacks.
|
static |
Write bytes out to a string as comma separated base 10 number values. Try to use SetHexDigest() instead. opposite of cMem::ReadFromString().
|
inlinestaticnoexcept |
Copy a block of memory. same as CopyMemory(), RtlCopyMemory, memcpy()
|
inlinestaticnoexcept |
Copy from Host (Local Native) Order into Network Order (Big Endian)
|
inlinestaticnoexcept |
Copy from Network Order (Big Endian) to Host Order (Local Native)
|
inlinestaticnoexcept |
Copy possibly overlapping blocks of memory. start from end or beginning if needed. same as MoveMemory RtlMoveMemory, memmove, hmemcpy(),
|
inlinestaticnoexcept |
Fill pDst with repeating copies of pSrc.
|
inlinestaticnoexcept |
Copy a block of memory BYTEs reversed. e.g. {3,2,1} = {1,2,3}, nSizeBlock = 3
|
inlinestaticnoexcept |
|
inlinestaticnoexcept |
Same as memset(). but with argument order change.
|
static |
Get the final hash as a pre-formatted string of hex digits. opposite of cMem::SetHexDigest ASSUME sizeof(pszHexString) >= SizeHexDigest
|
inlinestaticnoexcept |
< How much space does the hex digest need?
|
inlinestaticnoexcept |
is this a NOT valid/corrupt pointer? nullptr is not corrupt.
|
staticnoexcept |
Is this pointer valid to read/write to ? On heap, stack or static const data space. similar to _MFC_VER AfxIsValidAddress(), AtlIsValidAddress()
linux / POSIX version of IsBadReadPtr()
|
inlinestaticnoexcept |
Is this pointer into App space? Not kernel space. Kernel Space <= 1G or 2G for linux Does not mean I have write permissions. Used to sanity check pointers. Ensure NOT offset from nullptr?
|
static |
|
inlinestaticnoexcept |
Is all zeros ? nSize = 0 = true.
|
static |
Read/Parse bytes in from string as comma separated base 10 number values. opposite of cMem::ConvertToString().
|
inlinestaticnoexcept |
|
static |
Set binary pDigest from string pszHexString opposite of cMem::GetHexDigest
|
inlinestaticnoexcept |
swap copy 2 blocks of memory by bytes. like cMemT::Swap() but for 2 arbitrary sized blocks. swap them byte by byte. use cMemT::Swap<> instead if possible for intrinsic types.
|
inlinestaticnoexcept |
|
inlinestaticnoexcept |
|
inlinestaticnoexcept |
Zero a block of memory. same as RtlZeroMemory() but maybe not the same as SecureZeroMeory() to make sure it is not optimized out. (for password clearing)
|
inlinestaticnoexcept |
This is for security purposes. Not for initialization. Zero destructed values so they leave no trace. like SecureZeroMeory() and RtlSecureZeroMemory(). ensure it doesn't get optimized out. (like in an inline destructor)
|
friend |
used to trick the optimizer. Always 0.
used to trick the optimizer. Unknown value.