Fix global variable casting
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "static_mem.h"
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <string_view>
|
||||
|
||||
unsigned char gh_static_mem[GH_DATA_SIZE];
|
||||
void gh_init_data_segment() {
|
||||
@@ -12,5 +13,19 @@ void gh_init_data_segment() {
|
||||
if (actual != gh_data_size) {
|
||||
throw std::runtime_error("Failed to read gh_datasegment.bin");
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
|
||||
void gh_static_mem_check() {
|
||||
// Quick check
|
||||
const char *testValue = (const char *)&GH_MEM(0x5b68f8);
|
||||
if (std::string_view(testValue) != "Directory") {
|
||||
throw std::runtime_error("gh_datasegment.bin is corrupted");
|
||||
}
|
||||
|
||||
const char *otherValue = (const char *)&GH_MEM(0x005b683c);
|
||||
if (std::string_view(otherValue) != "%s") {
|
||||
throw std::runtime_error("gh_datasegment.bin is corrupted");
|
||||
}
|
||||
}
|
||||
|
@@ -17,6 +17,9 @@ inline uint8_t *memoryMapSafe(size_t addr) {
|
||||
return (uint8_t *)(gh_static_mem + (addr - GH_DATA_START));
|
||||
}
|
||||
|
||||
void gh_init_data_segment();
|
||||
void gh_static_mem_check();
|
||||
|
||||
#define GH_MEM(addr) (checkMappedMemory<addr>(), *memoryMapSafe(addr))
|
||||
|
||||
#endif /* A18E3E17_2A80_4DBD_96CD_1CE0120A164E */
|
||||
|
@@ -2,11 +2,11 @@
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <stdexcept>
|
||||
#include <stdio.h>
|
||||
#include <r3/binders/static_mem.h>
|
||||
|
||||
extern "C" int r3_main(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
LPSTR *cmdline, int showCmd);
|
||||
|
||||
extern void gh_init_data_segment();
|
||||
int main() {
|
||||
try {
|
||||
gh_init_data_segment();
|
||||
|
Reference in New Issue
Block a user