1
1
#include < windows.h>
2
2
#include < cstdio>
3
3
#include < shlwapi.h>
4
- #include < crtdbg.h>
5
4
#include < nlohmann/json.hpp>
6
5
#include < locale>
7
6
#include < codecvt>
8
7
#include < fstream>
9
8
#include < filesystem>
10
- #include < direct.h>
11
- #include < minidumpapiset.h>
12
9
#include " Module.hpp"
13
10
#include " ModConfigMenu.hpp"
14
11
#include " SWRSToys.h"
15
12
16
13
#define CRenderer_Unknown1 ((void (__thiscall *)(int , int ))0x404AF0 )
17
- #define REAL_VERSION_STR " alpha 0.4.1 "
14
+ #define REAL_VERSION_STR " alpha 0.4.2 "
18
15
#ifdef _NOTEX
19
16
#define MOD_REAL_VERSION_STR REAL_VERSION_STR " no texture"
20
17
#else
@@ -41,7 +38,7 @@ Module *head = nullptr;
41
38
SokuLib::SWRFont font;
42
39
HMODULE myModule;
43
40
44
- std::wstring getLastError (int err = GetLastError() )
41
+ std::wstring getLastError (int err)
45
42
{
46
43
wchar_t *s = nullptr ;
47
44
std::wstring str;
@@ -55,55 +52,6 @@ std::wstring getLastError(int err = GetLastError())
55
52
return str;
56
53
}
57
54
58
- LONG WINAPI UnhandledExFilter (PEXCEPTION_POINTERS ExPtr)
59
- {
60
- if (!ExPtr) {
61
- puts (" No ExPtr...." );
62
- return 0 ;
63
- }
64
- puts (" Caught fatal exception! Generating dump..." );
65
-
66
- wchar_t buf[2048 ];
67
- wchar_t buf2[MAX_PATH];
68
- time_t timer;
69
- char timebuffer[31 ];
70
- struct tm * tm_info;
71
-
72
- time (&timer);
73
- tm_info = localtime (&timer);
74
- strftime (timebuffer, sizeof (timebuffer), " %Y-%m-%d-%H-%M-%S" , tm_info);
75
- mkdir (" crashes" );
76
- wsprintfW (buf2, L" crashes/crash_%S.dmp" , timebuffer);
77
- wsprintfW (buf, L" Game crashed!\n Received fatal exception %X at address %x.\n " , ExPtr->ExceptionRecord ->ExceptionCode , ExPtr->ExceptionRecord ->ExceptionAddress );
78
-
79
- HANDLE hFile = CreateFileW (buf2, GENERIC_READ | GENERIC_WRITE, 0 , nullptr , CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr );
80
-
81
- if (hFile != INVALID_HANDLE_VALUE) {
82
- MINIDUMP_EXCEPTION_INFORMATION md;
83
- md.ThreadId = GetCurrentThreadId ();
84
- md.ExceptionPointers = ExPtr;
85
- md.ClientPointers = FALSE ;
86
- BOOL win = MiniDumpWriteDump (GetCurrentProcess (), GetCurrentProcessId (), hFile, MiniDumpNormal, &md, nullptr , nullptr );
87
-
88
- if (!win) {
89
- wcscat (buf, L" MiniDumpWriteDump failed.\n " );
90
- wcscat (buf, getLastError ().c_str ());
91
- wcscat (buf, L" : " );
92
- } else
93
- wcscat (buf, L" Minidump created " );
94
- wcscat (buf, buf2);
95
- CloseHandle (hFile);
96
- } else {
97
- wcscat (buf, L" CreateFileW(" );
98
- wcscat (buf, buf2);
99
- wcscat (buf, L" ) failed: " );
100
- wcscat (buf, getLastError ().c_str ());
101
- }
102
- printf (" %S\n " , buf);
103
- MessageBoxW (nullptr , buf, L" Fatal Error" , MB_ICONERROR);
104
- return EXCEPTION_CONTINUE_SEARCH;
105
- }
106
-
107
55
void loadAssets ()
108
56
{
109
57
if (loaded)
@@ -221,6 +169,14 @@ void generateFakeIni()
221
169
{
222
170
std::ofstream stream{std::wstring (app_path) + L" \\ SWRSToys.ini" };
223
171
172
+ stream << " ; /!\\ DO NOT MODIFY /!\\ " << std::endl;
173
+ stream << " ; This file is autogenerated by SokuModLoader." << std::endl;
174
+ stream << " ; Any change made here will be LOST." << std::endl;
175
+ stream << " ; If you want to modify the mod list, go inside the mod config menu in game." << std::endl;
176
+ stream << " ; If your game can't open, the file you are looking for is ModLoaderSettings.json." << std::endl;
177
+ stream << " ; To disable a mod there, write false next to \" enabled\" ." << std::endl;
178
+ stream << " ; Alternatively, you can delete ModLoaderSettings.json so that" << std::endl;
179
+ stream << " ; on next boot, it gets regenerated from this very file (in which case modifying it is fine)." << std::endl;
224
180
stream << " [Module]" << std::endl;
225
181
for (size_t i = 0 ; i < modules.size (); i++) {
226
182
if (!modules[i].enabled )
@@ -579,7 +535,6 @@ bool Hook(HMODULE this_module)
579
535
puts (" Loading settings file" );
580
536
loadSettings (gameHash, this_module);
581
537
puts (" Placing hooks" );
582
- SetUnhandledExceptionFilter (UnhandledExFilter);
583
538
VirtualProtect ((PVOID)TEXT_SECTION_OFFSET, TEXT_SECTION_SIZE, PAGE_EXECUTE_WRITECOPY, &old);
584
539
*(char *)0x81FF00 = 0x90 ;
585
540
*(char *)0x81FF01 = 0x50 ;
0 commit comments