Port XEX patcher from Unleashed Recompiled. (#4)

* Port XEX patcher from Unleashed Recompiled.

* Fix compilation error on Linux.
This commit is contained in:
Skyth (Asilkan)
2025-02-19 20:22:30 +03:00
committed by GitHub
parent 0fc545a6e2
commit cd6fcb33bd
17 changed files with 1336 additions and 144 deletions

View File

@@ -0,0 +1,32 @@
#pragma once
#include <filesystem>
#if defined(_WIN32)
# include <Windows.h>
#else
# include <sys/mman.h>
#endif
struct MemoryMappedFile {
#if defined(_WIN32)
HANDLE fileHandle = nullptr;
HANDLE fileMappingHandle = nullptr;
LPVOID fileView = nullptr;
LARGE_INTEGER fileSize = {};
#else
int fileHandle = -1;
void *fileView = MAP_FAILED;
off_t fileSize = 0;
#endif
MemoryMappedFile();
MemoryMappedFile(const std::filesystem::path &path);
MemoryMappedFile(MemoryMappedFile &&other);
~MemoryMappedFile();
bool open(const std::filesystem::path &path);
void close();
bool isOpen() const;
uint8_t *data() const;
size_t size() const;
};