mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
Workaround nuke not autoaddling dep lib (#859)
* #pragma comment(lib, <minhook lib>) * Fix logging path, and make common files not use pch * Move lib import to vcproj from pragma * a * Make copy of vcxproj for minhook from submodule to lib dir * nuke it * .
This commit is contained in:
parent
dbb0cb3d56
commit
b6237267ce
8 changed files with 134 additions and 46 deletions
|
|
@ -1,7 +1,13 @@
|
|||
#include "pch.h"
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
static bool s_bLoaded = false;
|
||||
static std::shared_ptr<void> 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<DWORD>(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<DWORD>(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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue