2021-01-01 19:50:16 +01:00
|
|
|
#include <windows.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2021-02-08 11:30:21 +01:00
|
|
|
#include "json_utils.h"
|
2021-02-08 01:18:57 +01:00
|
|
|
#include "struct.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "func.h"
|
2021-02-08 11:30:21 +01:00
|
|
|
#include "mod.h"
|
2021-01-01 19:50:16 +01:00
|
|
|
|
|
|
|
HINSTANCE hInstance = NULL;
|
|
|
|
|
2021-02-08 11:50:39 +01:00
|
|
|
static void tr1m_inject() {
|
2021-02-10 14:51:11 +01:00
|
|
|
INJECT(0x0041AF90, S_LoadLevel);
|
2021-01-01 19:50:16 +01:00
|
|
|
INJECT(0x0041B3F0, LoadRooms);
|
2021-02-07 15:18:03 +01:00
|
|
|
INJECT(0x0041BC60, LoadItems);
|
2021-02-10 14:51:11 +01:00
|
|
|
INJECT(0x0041BFC0, GetFullPath);
|
|
|
|
INJECT(0x0041C020, FindCdDrive);
|
2021-02-07 21:13:18 +01:00
|
|
|
INJECT(0x0041D5A0, LevelStats);
|
2021-02-10 14:51:11 +01:00
|
|
|
INJECT(0x0041DD00, DrawGameInfo);
|
|
|
|
INJECT(0x0041E2C0, init_game_malloc);
|
|
|
|
INJECT(0x0041E3B0, game_free);
|
2021-02-09 20:47:51 +01:00
|
|
|
INJECT(0x00422250, InitialiseFXArray);
|
2021-02-10 14:51:11 +01:00
|
|
|
INJECT(0x00428020, InitialiseLara);
|
|
|
|
INJECT(0x0042A2C0, DB_Log);
|
2021-02-09 23:44:44 +01:00
|
|
|
INJECT(0x0042A300, InitialiseLOTArray);
|
2021-02-10 14:51:11 +01:00
|
|
|
INJECT(0x004302D0, S_DrawHealthBar);
|
|
|
|
INJECT(0x00430450, S_DrawAirBar);
|
2021-01-01 19:50:16 +01:00
|
|
|
}
|
|
|
|
|
2021-02-08 11:50:39 +01:00
|
|
|
static int tr1m_read_config() {
|
2021-02-08 11:30:21 +01:00
|
|
|
FILE *fp = fopen("TR1Main.json", "rb");
|
|
|
|
if (!fp) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
fseek(fp, 0, SEEK_END);
|
|
|
|
int cfg_size = ftell(fp);
|
|
|
|
fseek(fp, 0, SEEK_SET);
|
|
|
|
|
|
|
|
char *cfg_data = malloc(cfg_size);
|
2021-02-08 11:50:39 +01:00
|
|
|
if (!cfg_data) {
|
|
|
|
fclose(fp);
|
|
|
|
return 0;
|
|
|
|
}
|
2021-02-08 11:30:21 +01:00
|
|
|
fread(cfg_data, 1, cfg_size, fp);
|
2021-02-08 11:50:39 +01:00
|
|
|
fclose(fp);
|
2021-02-08 11:30:21 +01:00
|
|
|
|
|
|
|
json_value *json = json_parse((const json_char*)cfg_data, cfg_size);
|
|
|
|
|
2021-02-09 22:20:22 +01:00
|
|
|
TR1MConfig.disable_healing_between_levels = tr1m_json_get_boolean_value(
|
|
|
|
json, "disable_healing_between_levels"
|
2021-02-08 11:50:39 +01:00
|
|
|
);
|
|
|
|
TR1MConfig.disable_medpacks = tr1m_json_get_boolean_value(
|
|
|
|
json, "disable_medpacks"
|
|
|
|
);
|
2021-02-09 22:23:33 +01:00
|
|
|
TR1MConfig.fix_end_of_level_freeze = tr1m_json_get_boolean_value(
|
|
|
|
json, "fix_end_of_level_freeze"
|
|
|
|
);
|
2021-02-08 11:30:21 +01:00
|
|
|
|
|
|
|
json_value_free(json);
|
|
|
|
free(cfg_data);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2021-02-08 11:50:39 +01:00
|
|
|
BOOL APIENTRY DllMain(
|
|
|
|
HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved
|
|
|
|
) {
|
2021-01-01 19:50:16 +01:00
|
|
|
switch (fdwReason) {
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
freopen("./TR1Main.log", "w", stdout);
|
2021-02-08 11:50:39 +01:00
|
|
|
tr1m_read_config();
|
2021-01-01 19:50:16 +01:00
|
|
|
TRACE("Attached");
|
|
|
|
hInstance = hinstDLL;
|
2021-02-08 11:50:39 +01:00
|
|
|
tr1m_inject();
|
2021-01-01 19:50:16 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
TRACE("Detached");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DLL_THREAD_ATTACH:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DLL_THREAD_DETACH:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|