Skip to content

Commit

Permalink
Merge pull request #17 from isanae/delay-parameter
Browse files Browse the repository at this point in the history
Delay parameter
  • Loading branch information
isanae authored Sep 9, 2019
2 parents 10071a6 + fad0510 commit 0783b3e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion include/usvfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions include/usvfsparameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ along with usvfs. If not, see <http://www.gnu.org/licenses/>.

#include "logging.h"
#include "dllimport.h"
#include <chrono>

enum class CrashDumpsType : uint8_t {
None,
Expand All @@ -40,6 +41,7 @@ struct USVFSParameters {
LogLevel logLevel{LogLevel::Debug};
CrashDumpsType crashDumpsType{CrashDumpsType::None};
char crashDumpsPath[260];
std::chrono::milliseconds delayProcess{0};
};

}
9 changes: 8 additions & 1 deletion src/usvfs_dll/usvfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,10 @@ void __cdecl InitHooks(LPVOID parameters, size_t)
usvfs_dump_type = params->crashDumpsType;
usvfs_dump_path = ush::string_cast<std::wstring>(params->crashDumpsPath, ush::CodePage::UTF8);

if (params->delayProcess.count() > 0) {
::Sleep(static_cast<unsigned long>(params->delayProcess.count()));
}

SetLogLevel(params->logLevel);

if (exceptionHandler == nullptr) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 0783b3e

Please # to comment.