summaryrefslogtreecommitdiffhomepage
path: root/windows/nsis-plugins/src/osinfo/update.cpp
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2021-12-16 10:58:03 +0100
committerDavid Lönnhager <david.l@mullvad.net>2022-01-11 14:19:38 +0100
commit52577f1b1fa6c49c3cee08d2b8129d2a8e3f62ff (patch)
tree315be2ab8e5693ea6f27f4165ae00892a28a0164 /windows/nsis-plugins/src/osinfo/update.cpp
parent82d652a5767027c6246fbc2384b48bd23c21563e (diff)
downloadmullvadvpn-52577f1b1fa6c49c3cee08d2b8129d2a8e3f62ff.tar.xz
mullvadvpn-52577f1b1fa6c49c3cee08d2b8129d2a8e3f62ff.zip
Remove osinfo from nsis-plugins
Diffstat (limited to 'windows/nsis-plugins/src/osinfo/update.cpp')
-rw-r--r--windows/nsis-plugins/src/osinfo/update.cpp97
1 files changed, 0 insertions, 97 deletions
diff --git a/windows/nsis-plugins/src/osinfo/update.cpp b/windows/nsis-plugins/src/osinfo/update.cpp
deleted file mode 100644
index 4b62bc05f9..0000000000
--- a/windows/nsis-plugins/src/osinfo/update.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-#include <stdafx.h>
-#include "update.h"
-#include <libcommon/error.h>
-#include <libcommon/filesystem.h>
-#include <libcommon/memory.h>
-#include <algorithm>
-#include <fstream>
-#include <filesystem>
-
-namespace
-{
-
-// Jason found this to be a reliable marker of the signature check fix:
-// https://git.zx2c4.com/wireguard-windows/tree/installer/customactions.c#n145
-const char PATCH_MARKER[] = "Signature Hash";
-
-}
-
-namespace update
-{
-
-bool HasSetupApiSha2Fix()
-{
- common::memory::ScopeDestructor destructor;
-
- common::fs::ScopedNativeFileSystem nativeFileSystem;
-
- const auto systemDir = common::fs::GetKnownFolderPath(FOLDERID_System);
- const auto setupApiPath = std::filesystem::path(systemDir).append(L"setupapi.dll");
-
- const auto setupApiHandle = CreateFileW(
- setupApiPath.c_str(),
- GENERIC_READ,
- FILE_SHARE_READ,
- nullptr,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL,
- nullptr
- );
-
- if (INVALID_HANDLE_VALUE == setupApiHandle)
- {
- THROW_WINDOWS_ERROR(GetLastError(), "CreateFileW");
- }
-
- destructor += [=]() {
- CloseHandle(setupApiHandle);
- };
-
- const auto mapping = CreateFileMappingW(setupApiHandle, nullptr, PAGE_READONLY, 0, 0, nullptr);
-
- if (nullptr == mapping)
- {
- THROW_WINDOWS_ERROR(GetLastError(), "CreateFileMappingW");
- }
-
- destructor += [=]() {
- CloseHandle(mapping);
- };
-
- const auto bytes = MapViewOfFile(mapping, FILE_MAP_READ, 0, 0, 0);
-
- if (nullptr == bytes)
- {
- THROW_WINDOWS_ERROR(GetLastError(), "MapViewOfFile");
- }
-
- destructor += [=]() {
- UnmapViewOfFile(bytes);
- };
-
- MEMORY_BASIC_INFORMATION meminfo;
-
- if (0 == VirtualQuery(bytes, &meminfo, sizeof(meminfo)))
- {
- THROW_WINDOWS_ERROR(GetLastError(), "VirtualQuery");
- }
-
- constexpr auto PATCH_MARKER_SIZE = sizeof(PATCH_MARKER) - 1;
-
- if (meminfo.RegionSize < PATCH_MARKER_SIZE)
- {
- return false;
- }
-
- for (size_t i = 0; i <= meminfo.RegionSize - PATCH_MARKER_SIZE; i++)
- {
- if (0 == memcmp((void*)((char*)bytes + i), PATCH_MARKER, PATCH_MARKER_SIZE))
- {
- return true;
- }
- }
-
- return false;
-}
-
-}