MCPcopy Create free account
hub / github.com/connorjaydunn/BinaryShield / save

Method save

src/pe.cpp:23–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21}
22
23bool PE::save(std::string path)
24{
25 // create a new file for writing our protected.exe to
26 HANDLE hOutputFile = CreateFileA(path.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
27
28 if (hOutputFile == INVALID_HANDLE_VALUE)
29 {
30 std::cerr << "error while creating output file: " << std::endl;
31 return 0;
32 }
33
34 // write our protected.exe bytes to new file
35 DWORD bytesWritten = 0;
36 if (!WriteFile(hOutputFile, bytes.data(), bytes.size(), &bytesWritten, NULL))
37 {
38 std::cerr << "error while writing to output file: " << std::endl;
39 CloseHandle(hOutputFile);
40 return 0;
41 }
42
43 CloseHandle(hOutputFile);
44 return 1;
45}
46
47void PE::addFunctionByRva(DWORD startRva, DWORD endRva)
48{

Callers 1

mainFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected