Changeset 73703 in vbox
- Timestamp:
- Aug 16, 2018 9:27:22 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/memsafer-r3.cpp
r69111 r73703 87 87 /** The allocator used for this node. */ 88 88 RTMEMSAFERALLOCATOR enmAllocator; 89 /** XOR scrambler value for memory. */ 90 uintptr_t uScramblerXor; 89 91 } RTMEMSAFERNODE; 90 92 /** Pointer to an allocation tracking node. */ … … 101 103 /** Tree of allocation nodes. */ 102 104 static AVLPVTREE g_pMemSaferTree; 103 /** XOR scrambler value for memory. */104 static uintptr_t g_uMemSaferScramblerXor;105 105 /** XOR scrambler value pointers. */ 106 106 static uintptr_t g_uMemSaferPtrScramblerXor; … … 116 116 RT_NOREF_PV(pvUserIgnore); 117 117 118 g_uMemSaferScramblerXor = (uintptr_t)RTRandU64();119 118 g_uMemSaferPtrScramblerXor = (uintptr_t)RTRandU64(); 120 119 g_cMemSaferPtrScramblerRotate = RTRandU32Ex(0, ARCH_BITS - 1); … … 203 202 RTDECL(int) RTMemSaferScramble(void *pv, size_t cb) 204 203 { 205 #ifdef RT_STRICT206 204 PRTMEMSAFERNODE pThis = rtMemSaferNodeLookup(pv); 207 205 AssertReturn(pThis, VERR_INVALID_POINTER); 208 206 AssertMsgReturn(cb == pThis->cbUser, ("cb=%#zx != %#zx\n", cb, pThis->cbUser), VERR_INVALID_PARAMETER); 209 #endif 207 208 /* First time we get a new xor value. */ 209 if (!pThis->uScramblerXor) 210 pThis->uScramblerXor = (uintptr_t)RTRandU64(); 210 211 211 212 /* Note! This isn't supposed to be safe, just less obvious. */ … … 214 215 while (cb > 0) 215 216 { 216 *pu ^= g_uMemSaferScramblerXor;217 *pu ^= pThis->uScramblerXor; 217 218 pu++; 218 219 cb -= sizeof(*pu); … … 226 227 RTDECL(int) RTMemSaferUnscramble(void *pv, size_t cb) 227 228 { 228 #ifdef RT_STRICT229 229 PRTMEMSAFERNODE pThis = rtMemSaferNodeLookup(pv); 230 230 AssertReturn(pThis, VERR_INVALID_POINTER); 231 231 AssertMsgReturn(cb == pThis->cbUser, ("cb=%#zx != %#zx\n", cb, pThis->cbUser), VERR_INVALID_PARAMETER); 232 #endif233 232 234 233 /* Note! This isn't supposed to be safe, just less obvious. */ … … 237 236 while (cb > 0) 238 237 { 239 *pu ^= g_uMemSaferScramblerXor;238 *pu ^= pThis->uScramblerXor; 240 239 pu++; 241 240 cb -= sizeof(*pu);
Note:
See TracChangeset
for help on using the changeset viewer.