Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
dumbasPL committed Jun 8, 2024
1 parent ff6f8f4 commit 33daa45
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/include/bootstrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
__forceinline auto get_bootstrap_shellcode(ULONG_PTR xor_key, ULONG_PTR section_virtual_offset, ULONG section_size) {
std::array<BYTE, 67> entrypoint = {
// constants
0x48, 0xB9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // mov rcx, 0h
0x48, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // mov rdx, 0h
0x49, 0xB8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // mov r8, 0h
0x48, 0xB9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // mov rcx, 0h - xor_key
0x48, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // mov rdx, 0h - section_virtual_offset
0x49, 0xB8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // mov r8, 0h - section_virtual_offset + section_size (end of section)

// add image base address to constants (this removes the need for a relocation table)
0x65, 0x48, 0x8B, 0x04, 0x25, 0x60, 0x00, 0x00, 0x00, // mov rax, gs:[60h] ; PEB
Expand Down
20 changes: 14 additions & 6 deletions src/include/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,20 @@ inline DWORD find_process_by_name(LPCWSTR lpProcessName) {
}

namespace fumo {
template<class... Args>
int error(int code, const WCHAR* fmt, Args... args) {
std::wstring message = std::vformat(fmt, std::make_wformat_args(std::forward<decltype(args)>(args)...));
message.append(L"\n\nError code: " + std::to_wstring(code));
message.append(L"\nWin32 error: " + std::to_wstring(GetLastError()));
MessageBoxW(NULL, message.c_str(), L"FUMO LOADER ERROR", MB_OK | MB_ICONERROR);
template <typename... Args>
std::wstring error_string(int code, std::wformat_string<Args...> fmt, Args&&... args) {
std::wstring message;
auto it = std::back_inserter(message);
std::format_to(it, fmt, std::forward<Args>(args)...);
std::format_to(it, L"\n\nFumo loader error: {}", code);
std::format_to(it, L"\nWin32 error: {}", GetLastError());
return message;
}

template <typename... Args>
int error(int code, std::wformat_string<Args...> fmt, Args&&... args) {
auto message = error_string(code, fmt, std::forward<Args>(args)...);
MessageBoxW(NULL, message.c_str(), L"FUMO LOADER ERROR", MB_OK | MB_ICONERROR | MB_SYSTEMMODAL);
return code;
}
}
2 changes: 1 addition & 1 deletion src/initial_loader/initial_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ NTSYSAPI ULONG RtlRandomEx(PULONG Seed);
#define DEBUG

#ifdef DEBUG
#define EXIT_WITH_ERROR(error, message) {fnMessageBoxA(nullptr, xorstr_(message), xorstr_("Error"), MB_OK | MB_ICONERROR); fnExitProcess(error);}
#define EXIT_WITH_ERROR(error, message) {fnMessageBoxA(nullptr, xorstr_(message), xorstr_("Error"), MB_OK | MB_ICONERROR | MB_SYSTEMMODAL); fnExitProcess(error);}
#else
#define EXIT_WITH_ERROR(error, message) {fnExitProcess(error);}
#endif
Expand Down

0 comments on commit 33daa45

Please sign in to comment.