From 4a02a154fe512107004717f0bc699bc75a33d7ed Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Sat, 23 Jul 2022 19:31:11 -0500 Subject: [PATCH] trivial: don't use /proc/self/exe on Windows Fixes: #4864 --- libfwupdplugin/fu-quirks.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libfwupdplugin/fu-quirks.c b/libfwupdplugin/fu-quirks.c index 0203124c3..79f45fcdf 100644 --- a/libfwupdplugin/fu-quirks.c +++ b/libfwupdplugin/fu-quirks.c @@ -22,6 +22,11 @@ #include "fu-quirks.h" #include "fu-string.h" +#ifdef _WIN32 +#include +#include +#endif + /** * FuQuirks: * @@ -334,6 +339,12 @@ fu_quirks_add_quirks_for_resources(FuQuirks *self, g_auto(GStrv) children = NULL; g_autoptr(GBytes) blob_self = NULL; g_autoptr(GError) error_local = NULL; +#ifdef _WIN32 + gchar self_exe[MAX_PATH]; + GetModuleFileNameA(NULL, self_exe, MAX_PATH); +#else + const gchar *self_exe = "/proc/self/exe"; +#endif children = g_resources_enumerate_children(path, G_RESOURCE_LOOKUP_FLAGS_NONE, &error_local); if (children == NULL) { @@ -353,7 +364,7 @@ fu_quirks_add_quirks_for_resources(FuQuirks *self, } /* add the hash of the current binary to verify it has not changed */ - blob_self = fu_bytes_get_contents("/proc/self/exe", error); + blob_self = fu_bytes_get_contents(self_exe, error); if (blob_self == NULL) return FALSE; hash_self = g_compute_checksum_for_bytes(G_CHECKSUM_SHA256, blob_self);