From 18902eecabe5eaeecd2319097699b3e7d4252f63 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 29 Jul 2024 21:52:04 +0100 Subject: [PATCH] library: init zeroed memory in stub gen I don't understand why this was necessary. C and C++ standards specify that this memory should be zeroed by virtue of it being static and constant, yet various different compilers produce various different errors about this line... --- src/library/dll/stub_inject_generator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/dll/stub_inject_generator.cxx b/src/library/dll/stub_inject_generator.cxx index b107c59..a3ee085 100644 --- a/src/library/dll/stub_inject_generator.cxx +++ b/src/library/dll/stub_inject_generator.cxx @@ -70,7 +70,7 @@ int wmain(int argc, const wchar_t **argv) { std::cout << "};" << std::endl; } // embed the amount of zeroes we'll need (WriteProcessMemory needs actual memory to copy from) - std::cout << "static const uint8_t zeroes[" << stub_nt_headers->OptionalHeader.SizeOfHeaders << "];" << std::endl; + std::cout << "static constexpr uint8_t zeroes[" << stub_nt_headers->OptionalHeader.SizeOfHeaders << "] = {0};" << std::endl; std::cout << "void InjectStub(HANDLE process) {" << std::endl; // allocate memory in the remote process