MCPcopy Create free account
hub / github.com/SecurityAnalysts01/ShellcodeLoader / Writetofile

Function Writetofile

ShellQMaker/ShellQMaker/ShellQMaker.h:68–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66
67
68BOOL Writetofile(PBYTE file, DWORD contentLen, PCHAR path)
69{
70
71 HANDLE pFile;
72 PBYTE tmpBuf = nullptr;
73 DWORD dwBytesWrite, dwBytesToWrite;
74 pFile = CreateFileA(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
75 if (pFile == INVALID_HANDLE_VALUE)
76 {
77 CloseHandle(pFile);
78 HeapFree(GetProcessHeap(), 0, file);
79 return FALSE;
80 }
81 dwBytesToWrite = contentLen;
82 dwBytesWrite = 0;
83 tmpBuf = file;
84 do {
85 WriteFile(pFile, tmpBuf, dwBytesToWrite, &dwBytesWrite, NULL);
86 dwBytesToWrite -= dwBytesWrite;
87 tmpBuf += dwBytesWrite;
88
89 } while (dwBytesToWrite > 0);
90
91 CloseHandle(pFile);
92 HeapFree(GetProcessHeap(), 0, file);
93 return TRUE;
94}

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected