Skip to content

Commit

Permalink
Merge pull request #2 from kkent030315/main
Browse files Browse the repository at this point in the history
Fix address space leak
  • Loading branch information
hasherezade committed Jun 23, 2021
2 parents 0e5656e + b199805 commit b960807
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ int wmain(int argc, wchar_t *argv[])

bool is_ok = transacted_hollowing(targetPath, payladBuf, (DWORD) payloadSize);

free_buffer(payladBuf, payloadSize);
free_buffer(payladBuf);
if (is_ok) {
std::cerr << "[+] Done!" << std::endl;
} else {
Expand Down
4 changes: 2 additions & 2 deletions util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ BYTE *buffer_payload(wchar_t *filename, OUT size_t &r_size)
return localCopyAddress;
}

void free_buffer(BYTE* buffer, size_t buffer_size)
void free_buffer(BYTE* buffer)
{
if (buffer == NULL) return;
VirtualFree(buffer, buffer_size, MEM_DECOMMIT);
VirtualFree(buffer, 0, MEM_RELEASE);
}

wchar_t* get_file_name(wchar_t *full_path)
Expand Down
2 changes: 1 addition & 1 deletion util.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <Windows.h>

BYTE *buffer_payload(wchar_t *filename, OUT size_t &r_size);
void free_buffer(BYTE* buffer, size_t buffer_size);
void free_buffer(BYTE* buffer);

//get file name from the full path
wchar_t* get_file_name(wchar_t *full_path);
Expand Down

0 comments on commit b960807

Please sign in to comment.