Skip to content

Commit

Permalink
winapi: Implement SecureZeroMemory()
Browse files Browse the repository at this point in the history
  • Loading branch information
thrimbor committed Jan 9, 2025
1 parent 3a29e28 commit 45a0b89
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/winapi/winbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 45a0b89

Please sign in to comment.