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:
kizer 2022-05-30 02:18:00 +09:00 committed by GitHub
parent dbb0cb3d56
commit b6237267ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 134 additions and 46 deletions

View file

@ -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;
}