mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
feat: optional CTD reports to gauge stability
This commit is contained in:
parent
1767bbf5b1
commit
d2ecddbf35
4 changed files with 57 additions and 10 deletions
|
|
@ -1,11 +1,13 @@
|
|||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <windows.h>
|
||||
#include <minidumpapiset.h>
|
||||
#include <tlhelp32.h>
|
||||
#include <winhttp.h>
|
||||
|
||||
#include "../Dalamud.Boot/crashhandler_shared.h"
|
||||
|
||||
DWORD WINAPI MyThreadFunction(LPVOID lpParam)
|
||||
DWORD WINAPI ExitCheckThread(LPVOID lpParam)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
|
|
@ -53,7 +55,7 @@ int main()
|
|||
CreateThread(
|
||||
NULL, // default security attributes
|
||||
0, // use default stack size
|
||||
MyThreadFunction, // thread function name
|
||||
ExitCheckThread, // thread function name
|
||||
NULL, // argument to thread function
|
||||
0, // use default creation flags
|
||||
NULL); // returns the thread identifier
|
||||
|
|
@ -132,5 +134,38 @@ int main()
|
|||
CloseHandle(process);
|
||||
CloseHandle(file_mapping);
|
||||
|
||||
if (getenv("DALAMUD_NO_METRIC"))
|
||||
return 0;
|
||||
|
||||
HINTERNET internet = WinHttpOpen(L"DALAMUDCRASHHANDLER", WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY, NULL, NULL, WINHTTP_FLAG_SECURE_DEFAULTS);
|
||||
HINTERNET connect = NULL, request = NULL;
|
||||
if (internet)
|
||||
{
|
||||
connect = WinHttpConnect(internet, L"kamori.goats.dev", INTERNET_DEFAULT_HTTPS_PORT, 0);
|
||||
}
|
||||
|
||||
if (connect)
|
||||
{
|
||||
std::wstringstream url{ L"/Dalamud/Metric/ReportCrash/" };
|
||||
url << "?lt=" << info_share->Lifetime << "&code=" << std::hex << info_share->ExceptionCode;
|
||||
|
||||
request = WinHttpOpenRequest(internet, L"GET", url.str().c_str(), NULL, NULL, NULL, 0);
|
||||
}
|
||||
|
||||
if (request)
|
||||
{
|
||||
bool sent = WinHttpSendRequest(request,
|
||||
WINHTTP_NO_ADDITIONAL_HEADERS,
|
||||
0, WINHTTP_NO_REQUEST_DATA, 0,
|
||||
0, 0);
|
||||
|
||||
if (!sent)
|
||||
std::cout << "Failed to send metric: " << std::hex << GetLastError() << std::endl;
|
||||
}
|
||||
|
||||
if (request) WinHttpCloseHandle(request);
|
||||
if (connect) WinHttpCloseHandle(connect);
|
||||
if (internet) WinHttpCloseHandle(internet);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,13 +48,13 @@
|
|||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>Dbghelp.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>Winhttp.lib;Dbghelp.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
|
@ -64,7 +64,7 @@
|
|||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
|
@ -72,6 +72,7 @@
|
|||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>Dbghelp.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue