27 lines
781 B
C++
27 lines
781 B
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <cstdint>
|
|
|
|
namespace voidlibc::loader::windows_handoff {
|
|
|
|
struct LoadResult {
|
|
void* handle = nullptr; // opaque OS handle (HMODULE on Windows)
|
|
std::string error;
|
|
bool ok = true;
|
|
};
|
|
|
|
// Write `bytes` to a temp file and load it via LoadLibraryEx (Windows) /
|
|
// dlopen from a temp file (stub for non-Windows builds so the code compiles
|
|
// everywhere). The temp file is deleted once the DLL is loaded.
|
|
LoadResult load_pe_buffer(const std::vector<std::uint8_t>& bytes);
|
|
|
|
// Resolve a symbol from a handle returned by load_pe_buffer.
|
|
void* get_proc(void* handle, const char* name);
|
|
|
|
// Unload a handle returned by load_pe_buffer.
|
|
void unload(void* handle);
|
|
|
|
} // namespace voidlibc::loader::windows_handoff
|