Skip to content

Commit

Permalink
testing mlock
Browse files Browse the repository at this point in the history
  • Loading branch information
radu committed Jun 22, 2024
1 parent 0e4239d commit a658979
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/test_zeroize.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
0.5,
1,
2,
2.97,
# 2.97,
4,
]


Expand Down Expand Up @@ -57,16 +58,24 @@ def test_zeroize1_sizes(self):
buffer_address = arr2.buffer_info()[0]
buffer_size = arr2.buffer_info()[1] * arr2.itemsize

# Define VirtualLock function from kernel32.dll
VirtualLock = ctypes.windll.kernel32.VirtualLock
VirtualLock.argtypes = [ctypes.c_void_p, ctypes.c_size_t]
VirtualLock.restype = ctypes.c_bool

VirtualUnlock = ctypes.windll.kernel32.VirtualUnlock
VirtualUnlock.argtypes = [ctypes.c_void_p, ctypes.c_size_t]
VirtualUnlock.restype = ctypes.c_bool

if VirtualLock(ctypes.c_void_p(buffer_address), ctypes.c_size_t(buffer_size)):
print("Memory locked")
else:
print("Failed to lock memory")

if VirtualUnlock(ctypes.c_void_p(buffer_address), ctypes.c_size_t(buffer_size)):
print("Memory unlocked")
else:
print("Failed to unlock memory")

zeroize1(arr)
zeroize1(arr_np)
zeroize1(arr2)
Expand Down

0 comments on commit a658979

Please sign in to comment.