Randomize a memory buffer.
- Parameters
-
| nSeed | A seed for the internal linear congruential generator. The value can be retrieved by a call to the GetDefaultSeed function. |
| [out] | pMemory | A pointer to memory to randomize. |
| cbMemory | Size of the buffer pointed to by pMemory, in bytes. |
- Returns
- The function returns the last random byte sequence written to the buffer. If
cbMemory is less than sizeof(unsigned long long), the return value will include highest-order bytes of nSeed as lowest-order bytes of the return value, together with lowest-order random bytes as the highest-order bytes of the return value. Generally, if the destination buffer is not a multiple of words, that is cbMemory is not a multiple of sizeof(unsigned long long), the return value will be composed of the two lastly-written words, assuming the existence of a pseudo-element with the value of nSeed at the region of memory just before pMemory. On the other hand, if cbMemory is a multiple of sizeof(unsigned long long), then the return value can be used as a seed for subsedquent calls to RandomizeMemory_LE in a chain used to randomize several buffers using consistent pseudo-random generator state formed from an initial seed.
The pseudo-random number generator used by the function is a linear congruential generator \(\forall n \ge 0, x_n = (A \cdot x_{n-1} + B) \mod 2^{64}\), where \(x_{-1}\) equals nSeed, \(A\) is 0xD1342543DE82EF95 and \(B\) is 5. The function writes cbMemory lowest-order bytes of the value \(X = \sum_{n=0}^{\infty} x_n \cdot 2^{64n}\) to pMemory, starting from the lowest-order byte of \(x_0\).
- See also
- RandomizeMemory_BE;
RandomizeMemory.