From fad051000c5f427c0f08833fef7ac022bbc68c65 Mon Sep 17 00:00:00 2001
From: isanae <14251494+isanae@users.noreply.github.com>
Date: Sun, 8 Sep 2019 02:19:20 -0400
Subject: [PATCH] added a delay parameter: adds a sleep before unfreezing the
process so there's time to hook a debugger
---
include/usvfs.h | 3 ++-
include/usvfsparameters.h | 2 ++
src/usvfs_dll/usvfs.cpp | 9 ++++++++-
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/include/usvfs.h b/include/usvfs.h
index 38027618..2f842816 100644
--- a/include/usvfs.h
+++ b/include/usvfs.h
@@ -176,7 +176,8 @@ DLLEXPORT void WINAPI USVFSInitParameters(USVFSParameters *parameters,
bool debugMode,
LogLevel logLevel,
CrashDumpsType crashDumpsType,
- const char *crashDumpsPath);
+ const char *crashDumpsPath,
+ std::chrono::milliseconds delayProcess={});
DLLEXPORT int WINAPI CreateMiniDump(PEXCEPTION_POINTERS exceptionPtrs, CrashDumpsType type, const wchar_t* dumpPath);
diff --git a/include/usvfsparameters.h b/include/usvfsparameters.h
index c6461d30..7aaf4d73 100644
--- a/include/usvfsparameters.h
+++ b/include/usvfsparameters.h
@@ -22,6 +22,7 @@ along with usvfs. If not, see .
#include "logging.h"
#include "dllimport.h"
+#include
enum class CrashDumpsType : uint8_t {
None,
@@ -40,6 +41,7 @@ struct USVFSParameters {
LogLevel logLevel{LogLevel::Debug};
CrashDumpsType crashDumpsType{CrashDumpsType::None};
char crashDumpsPath[260];
+ std::chrono::milliseconds delayProcess{0};
};
}
diff --git a/src/usvfs_dll/usvfs.cpp b/src/usvfs_dll/usvfs.cpp
index 5779dd91..c0915009 100644
--- a/src/usvfs_dll/usvfs.cpp
+++ b/src/usvfs_dll/usvfs.cpp
@@ -327,6 +327,10 @@ void __cdecl InitHooks(LPVOID parameters, size_t)
usvfs_dump_type = params->crashDumpsType;
usvfs_dump_path = ush::string_cast(params->crashDumpsPath, ush::CodePage::UTF8);
+ if (params->delayProcess.count() > 0) {
+ ::Sleep(static_cast(params->delayProcess.count()));
+ }
+
SetLogLevel(params->logLevel);
if (exceptionHandler == nullptr) {
@@ -775,11 +779,14 @@ void WINAPI USVFSInitParameters(USVFSParameters *parameters,
const char *instanceName, bool debugMode,
LogLevel logLevel,
CrashDumpsType crashDumpsType,
- const char *crashDumpsPath)
+ const char *crashDumpsPath,
+ std::chrono::milliseconds delayProcess)
{
parameters->debugMode = debugMode;
parameters->logLevel = logLevel;
parameters->crashDumpsType = crashDumpsType;
+ parameters->delayProcess = delayProcess;
+
strncpy_s(parameters->instanceName, instanceName, _TRUNCATE);
if (crashDumpsPath && *crashDumpsPath && strlen(crashDumpsPath) < _countof(parameters->crashDumpsPath)) {
memcpy(parameters->crashDumpsPath, crashDumpsPath, strlen(crashDumpsPath)+1);