From 45a0b8990da4bd43e84de34032ac0d6552f35426 Mon Sep 17 00:00:00 2001 From: Stefan Schmidt Date: Thu, 9 Jan 2025 01:19:53 +0100 Subject: [PATCH] winapi: Implement SecureZeroMemory() --- lib/winapi/winbase.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/winapi/winbase.h b/lib/winapi/winbase.h index 38774f99e..a2d17921d 100644 --- a/lib/winapi/winbase.h +++ b/lib/winapi/winbase.h @@ -140,6 +140,19 @@ BOOL IsBadWritePtr (LPVOID lp, UINT_PTR ucb); BOOL GetOverlappedResult (HANDLE hFile, LPOVERLAPPED lpOverlapped, LPDWORD lpNumberOfBytesTransferred, BOOL bWait); +static inline PVOID SecureZeroMemory (PVOID ptr, SIZE_T cnt) +{ + volatile char *cur_ptr = (volatile char *)ptr; + volatile char *end_ptr = (volatile char *)ptr + cnt; + + while (cur_ptr < end_ptr) { + *cur_ptr = 0; + cur_ptr++; + } + + return ptr; +} + #ifndef UNICODE #define OutputDebugString OutputDebugStringA #else