diff --git a/Dalamud.Boot/Dalamud.Boot.vcxproj b/Dalamud.Boot/Dalamud.Boot.vcxproj
index 0366155e4..7b9c52f46 100644
--- a/Dalamud.Boot/Dalamud.Boot.vcxproj
+++ b/Dalamud.Boot/Dalamud.Boot.vcxproj
@@ -32,8 +32,12 @@
obj\$(Configuration)\
-
-
+
+ $(LibraryPath)
+
+
+ $(SolutionDir)bin\lib\$(Configuration)\libMinHook\;$(LibraryPath)
+
Level3
@@ -95,8 +99,36 @@
NotUsing
NotUsing
-
-
+
+ NotUsing
+ NotUsing
+
+
+ true
+ true
+ NotUsing
+ NotUsing
+
+
+ NotUsing
+ NotUsing
+
+
+ NotUsing
+ NotUsing
+
+
+ NotUsing
+ NotUsing
+
+
+ NotUsing
+ NotUsing
+
+
+ NotUsing
+ NotUsing
+
@@ -120,6 +152,14 @@
+
+
+
+
+
+
+
+
@@ -129,11 +169,6 @@
-
-
- {f142a341-5ee0-442d-a15f-98ae9b48dbae}
-
-
diff --git a/Dalamud.Boot/Dalamud.Boot.vcxproj.filters b/Dalamud.Boot/Dalamud.Boot.vcxproj.filters
index b6991f9eb..b4e788664 100644
--- a/Dalamud.Boot/Dalamud.Boot.vcxproj.filters
+++ b/Dalamud.Boot/Dalamud.Boot.vcxproj.filters
@@ -11,6 +11,12 @@
{0c915688-91ea-431f-8b68-845cad422a50}
+
+ {e31f7ca0-db29-4198-8b91-bb11b339705f}
+
+
+ {6ec5597d-e293-4d2a-a307-7444c8fac04b}
+
@@ -41,10 +47,25 @@
Dalamud.Boot DLL
- Dalamud.Boot DLL
+ Common Boot
- Dalamud.Boot DLL
+ Common Boot
+
+
+ MinHook
+
+
+ MinHook
+
+
+ MinHook
+
+
+ MinHook
+
+
+ MinHook
@@ -82,10 +103,34 @@
Dalamud.Boot DLL
- Dalamud.Boot DLL
+ Common Boot
- Dalamud.Boot DLL
+ Common Boot
+
+
+ MinHook
+
+
+ MinHook
+
+
+ MinHook
+
+
+ MinHook
+
+
+ MinHook
+
+
+ MinHook
+
+
+ MinHook
+
+
+ MinHook
\ No newline at end of file
diff --git a/Dalamud.Boot/dllmain.cpp b/Dalamud.Boot/dllmain.cpp
index 9bf871e80..cc3d38018 100644
--- a/Dalamud.Boot/dllmain.cpp
+++ b/Dalamud.Boot/dllmain.cpp
@@ -9,13 +9,19 @@ HMODULE g_hModule;
HINSTANCE g_hGameInstance = GetModuleHandleW(nullptr);
DllExport DWORD WINAPI Initialize(LPVOID lpParam, HANDLE hMainThreadContinue) {
- logging::log_file.open(utils::get_env("DALAMUD_BOOT_LOGFILE"), std::ios_base::out | std::ios_base::app);
-
if (bootconfig::is_show_console())
ConsoleSetup(L"Dalamud Boot");
-
- if (!logging::log_file) {
- logging::print("Couldn't open log file!");
+
+ if (const auto logFilePath = utils::get_env("DALAMUD_BOOT_LOGFILE"); logFilePath.empty())
+ logging::print("No log file path given; not logging to file.");
+ else {
+ try {
+ logging::start_file_logging(logFilePath);
+ logging::print(L"Logging to file: {}", logFilePath);
+ } catch (const std::exception& e) {
+ logging::print(L"Couldn't open log file: {}", logFilePath);
+ logging::print("Error: {} / {}", errno, e.what());
+ }
}
logging::print("Dalamud.Boot Injectable, (c) 2021 XIVLauncher Contributors");
diff --git a/Dalamud.Boot/logging.cpp b/Dalamud.Boot/logging.cpp
index 73c5a02f0..e2ec89d17 100644
--- a/Dalamud.Boot/logging.cpp
+++ b/Dalamud.Boot/logging.cpp
@@ -1,7 +1,13 @@
-#include "pch.h"
+#define WIN32_LEAN_AND_MEAN
+#include
+
+#include
+#include
+
#include "logging.h"
static bool s_bLoaded = false;
+static std::shared_ptr s_hLogFile;
void logging::print(Level level, const char* s) {
SYSTEMTIME st;
@@ -39,14 +45,27 @@ void logging::print(Level level, const char* s) {
DWORD wr{};
WriteFile(GetStdHandle(STD_ERROR_HANDLE), &estr[0], static_cast(estr.size()), &wr, nullptr);
- if (log_file.is_open())
- {
- log_file << estr;
- log_file.flush();
+ if (s_hLogFile) {
+ WriteFile(s_hLogFile.get(), &estr[0], static_cast(estr.size()), &wr, nullptr);
}
}
}
+void logging::start_file_logging(const std::filesystem::path& path) {
+ if (s_hLogFile)
+ return;
+
+ const auto h = CreateFile(path.wstring().c_str(),
+ GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ nullptr, OPEN_ALWAYS, 0, nullptr);
+ if (h == INVALID_HANDLE_VALUE)
+ throw std::runtime_error(std::format("Win32 error {}(0x{:x})", GetLastError(), GetLastError()));
+
+ SetFilePointer(h, 0, 0, FILE_END);
+ s_hLogFile = { h, &CloseHandle };
+}
+
void logging::update_dll_load_status(bool loaded) {
s_bLoaded = loaded;
}
diff --git a/Dalamud.Boot/logging.h b/Dalamud.Boot/logging.h
index e661cac17..6822b8763 100644
--- a/Dalamud.Boot/logging.h
+++ b/Dalamud.Boot/logging.h
@@ -1,15 +1,13 @@
#pragma once
+#include
#include
#include
#include
-#include
#include "unicode.h"
namespace logging {
- inline std::ofstream log_file;
-
enum Level : int {
Verbose = 0,
V = 0,
@@ -65,5 +63,7 @@ namespace logging {
print(level, std::format(pcszFormat, std::forward(arg1), std::forward(args)...));
}
+ void start_file_logging(const std::filesystem::path& path);
+
void update_dll_load_status(bool loaded);
};
diff --git a/Dalamud.Boot/unicode.cpp b/Dalamud.Boot/unicode.cpp
index 9d66d29f2..9598fb509 100644
--- a/Dalamud.Boot/unicode.cpp
+++ b/Dalamud.Boot/unicode.cpp
@@ -1,5 +1,3 @@
-#include "pch.h"
-
#include "unicode.h"
size_t unicode::decode(EncodingTag, char32_t& out, const char8_t* in, size_t nRemainingBytes, bool strict) {
diff --git a/Dalamud.Injector/EntryPoint.cs b/Dalamud.Injector/EntryPoint.cs
index 62cc2580c..8fbb14792 100644
--- a/Dalamud.Injector/EntryPoint.cs
+++ b/Dalamud.Injector/EntryPoint.cs
@@ -108,7 +108,7 @@ namespace Dalamud.Injector
#if DEBUG
var logPath = Path.Combine(baseDirectory, $"{filename}.log");
#else
- var logPath = Path.Combine(baseDirectory, "..", "..", "..", "dalamud.injector.log");
+ var logPath = Path.Combine(baseDirectory, "..", "..", "..", $"{filename}.log");
#endif
return logPath;
diff --git a/Dalamud.sln b/Dalamud.sln
index f4167f9ed..546e31dfe 100644
--- a/Dalamud.sln
+++ b/Dalamud.sln
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.31424.327
+# Visual Studio Version 17
+VisualStudioVersion = 17.1.32319.34
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CEF7D22B-CB85-400E-BD64-349A30E3C097}"
ProjectSection(SolutionItems) = preProject
@@ -34,8 +34,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FFXIVClientStructs", "lib\F
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FFXIVClientStructs.Generators", "lib\FFXIVClientStructs\FFXIVClientStructs.Generators\FFXIVClientStructs.Generators.csproj", "{05AB2F46-268B-4915-806F-DDF813E2D59D}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libMinHook", "lib\TsudaKageyu-minhook\build\VC16\libMinHook.vcxproj", "{F142A341-5EE0-442D-A15F-98AE9B48DBAE}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -188,18 +186,6 @@ Global
{05AB2F46-268B-4915-806F-DDF813E2D59D}.Release|x64.Build.0 = Release|Any CPU
{05AB2F46-268B-4915-806F-DDF813E2D59D}.Release|x86.ActiveCfg = Release|Any CPU
{05AB2F46-268B-4915-806F-DDF813E2D59D}.Release|x86.Build.0 = Release|Any CPU
- {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|Any CPU.ActiveCfg = Debug|x64
- {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|Any CPU.Build.0 = Debug|x64
- {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|x64.ActiveCfg = Debug|x64
- {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|x64.Build.0 = Debug|x64
- {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|x86.ActiveCfg = Debug|Win32
- {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|x86.Build.0 = Debug|Win32
- {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|Any CPU.ActiveCfg = Release|x64
- {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|Any CPU.Build.0 = Release|x64
- {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|x64.ActiveCfg = Release|x64
- {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|x64.Build.0 = Release|x64
- {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|x86.ActiveCfg = Release|Win32
- {F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -210,7 +196,6 @@ Global
{2F7FF0A8-B619-4572-86C7-71E46FE22FB8} = {E15BDA6D-E881-4482-94BA-BE5527E917FF}
{C9B87BD7-AF49-41C3-91F1-D550ADEB7833} = {E15BDA6D-E881-4482-94BA-BE5527E917FF}
{05AB2F46-268B-4915-806F-DDF813E2D59D} = {E15BDA6D-E881-4482-94BA-BE5527E917FF}
- {F142A341-5EE0-442D-A15F-98AE9B48DBAE} = {E15BDA6D-E881-4482-94BA-BE5527E917FF}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {79B65AC9-C940-410E-AB61-7EA7E12C7599}