Browse Source

Fiixed CriticalSection and crash-on-exit

pull/46/head
Anairkoen Schno 4 years ago
parent
commit
cdaf06b858
3 changed files with 18 additions and 5 deletions
  1. +11
    -0
      Doorstop/Proxy/main.c
  2. +4
    -1
      Doorstop/Proxy/mono.h
  3. +3
    -4
      IPA.Loader/Utilities/CriticalSection.cs

+ 11
- 0
Doorstop/Proxy/main.c View File

@ -181,6 +181,17 @@ void *ownMonoJitInitVersion(const char *root_domain_name, const char *runtime_ve
mono_install_unhandled_exception_hook(unhandledException, NULL);
wchar_t* dll_path_w; // self path
size_t dll_path_len = get_module_path((HINSTANCE)&__ImageBase, &dll_path_w, NULL, 0);
char* self_dll_path = memalloc(dll_path_len + 1);
WideCharToMultiByte(CP_UTF8, 0, dll_path_w, -1, self_dll_path, dll_path_len + 1, NULL, NULL);
mono_dllmap_insert(NULL, "i:bsipa-doorstop", NULL, self_dll_path, NULL); // remap `bsipa-doorstop` to this assembly
memfree(self_dll_path);
memfree(dll_path_w);
unhandledMutex = CreateMutexW(NULL, FALSE, NULL);
LOG("Invoking method!\n");


+ 4
- 1
Doorstop/Proxy/mono.h View File

@ -40,7 +40,7 @@ typedef enum {
void (*mono_jit_parse_options)(int argc, char * argv[]);
void (*mono_debug_init)(MonoDebugFormat format);
void(*mono_debug_domain_create)(void*);
void (*mono_debug_domain_create)(void*);
void *(*mono_jit_init_version)(const char *root_domain_name, const char *runtime_version);
void *(*mono_domain_assembly_open)(void *domain, const char *name);
@ -61,6 +61,8 @@ void *(*mono_string_new_utf16)(void *domain, const wchar_t *text, INT32 len);
void* (*mono_object_to_string)(void* obj, void** exc);
void (*mono_dllmap_insert)(void* assemblyImage, const char* dll, const char* func, const char* tdll, const char* tfunc);
char* (*mono_string_to_utf8)(void* str);
void (*mono_free)(void*);
@ -101,5 +103,6 @@ inline void loadMonoFunctions(HMODULE monoLib)
GET_MONO_PROC(mono_object_to_string);
GET_MONO_PROC(mono_string_to_utf8);
GET_MONO_PROC(mono_free);
GET_MONO_PROC(mono_dllmap_insert);
GET_MONO_PROC(mono_install_unhandled_exception_hook);
}

+ 3
- 4
IPA.Loader/Utilities/CriticalSection.cs View File

@ -18,9 +18,6 @@ namespace IPA.Utilities
{
Logger.log.Debug("Configuring exit handlers");
AppDomain.CurrentDomain.ProcessExit -= Reset;
AppDomain.CurrentDomain.ProcessExit += Reset;
ResetExitHandlers();
}
@ -52,7 +49,7 @@ namespace IPA.Utilities
uint filterMax,
ref Win32.PeekMessageParams removeMsg);
[DllImport("winhttp")]
[DllImport("bsipa-doorstop")]
public static extern void SetPeekMessageHook(
[MarshalAs(UnmanagedType.FunctionPtr)]
PeekMessageHook hook);
@ -139,6 +136,8 @@ namespace IPA.Utilities
_handler = null;
isInExecuteSection = false;
Reset(null, null);
if (exitRecieved)
Environment.Exit(1);
}


Loading…
Cancel
Save