Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add incompatibility check for PrivateProfileRedirector < 0.6.2 #735

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
#include "Utils/GameSetting.h"
#include "Utils/Serialize.h"
#include "Utils/UI.h"
#include "Utils/WinApi.h"
1 change: 1 addition & 0 deletions src/Utils/Format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace Util
}
return result;
}

std::string DefinesToString(const std::vector<D3D_SHADER_MACRO>& defines)
{
std::string result;
Expand Down
30 changes: 30 additions & 0 deletions src/Utils/WinApi.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "WinApi.h"

namespace Util
{
std::optional<REL::Version> GetDllVersion(const std::wstring& dllPath)
{
DWORD handle = 0;
DWORD size = GetFileVersionInfoSize(dllPath.c_str(), &handle);
if (size == 0) {
return std::nullopt;
}

std::vector<BYTE> buffer(size);
if (!GetFileVersionInfo(dllPath.c_str(), handle, size, buffer.data())) {
return std::nullopt;
}

VS_FIXEDFILEINFO* fileInfo = nullptr;
UINT fileInfoSize = 0;
if (!VerQueryValue(buffer.data(), L"\\", reinterpret_cast<void**>(&fileInfo), &fileInfoSize)) {
return std::nullopt;
}

if (fileInfoSize == sizeof(VS_FIXEDFILEINFO)) {
return REL::Version(HIWORD(fileInfo->dwFileVersionMS), LOWORD(fileInfo->dwFileVersionMS), HIWORD(fileInfo->dwFileVersionLS), LOWORD(fileInfo->dwFileVersionLS));
}

return std::nullopt;
}
} // namespace Util
6 changes: 6 additions & 0 deletions src/Utils/WinApi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

namespace Util
{
std::optional<REL::Version> GetDllVersion(const std::wstring& dllPath);
} // namespace Util
5 changes: 5 additions & 0 deletions src/XSEPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ bool Load()
REL::IDDatabase::get().IsVRAddressLibraryAtLeastVersion("0.158.0", true);
}

auto privateProfileRedirectorVersion = Util::GetDllVersion(L"Data/SKSE/Plugins/PrivateProfileRedirector.dll");
if (privateProfileRedirectorVersion.has_value() && privateProfileRedirectorVersion.value().compare(REL::Version(0, 6, 2)) == std::strong_ordering::less) {
stl::report_and_fail("Old version of PrivateProfileRedirector detected, 0.6.2+ required if using it."sv);
}

auto messaging = SKSE::GetMessagingInterface();
messaging->RegisterListener("SKSE", MessageHandler);

Expand Down
Loading