--- stlink-1.8.0/src/stlink-lib/chipid.c.orig	2024-02-01 00:01:58.000000000 +0100
+++ stlink-1.8.0/src/stlink-lib/chipid.c	2025-01-10 10:19:57.002442200 +0100
@@ -210,6 +210,26 @@
 #if defined(STLINK_HAVE_DIRENT_H)
 #include <dirent.h>
 
+static char *getDLLPath()
+{
+    HMODULE hModule;
+    if (GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCSTR)&getDLLPath, &hModule)) {
+        char *modulePath = (char *)malloc(MAX_PATH);
+        if (modulePath == NULL) {
+            return NULL;
+        }
+        if (GetModuleFileNameA(hModule, modulePath, MAX_PATH) > 0) {
+            char *lastBackslash = strrchr(modulePath, '\\');
+            if (lastBackslash) {
+                *lastBackslash = '\0';
+                return modulePath;
+            }
+        }
+        free(modulePath);
+    }
+    return NULL;
+}
+
 void init_chipids(char *dir_to_scan) {
   DIR *d;
   uint32_t nl; // namelen
@@ -219,6 +239,18 @@
     dir_to_scan = "./";
   }
 
+  char chips_path[MAX_PATH];
+  if (strcmp(dir_to_scan, STLINK_CHIPS_DIR) == 0) {
+    char *dll_path = getDLLPath();
+    if (!dll_path) {
+      ELOG("Failed to get DLL path\n");
+    } else {
+      snprintf(chips_path, MAX_PATH, "%s/../share/stlink/chips", dll_path);
+      free(dll_path);
+      dir_to_scan = chips_path;
+    }
+  }
+  
   devicelist = NULL;
   d = opendir(dir_to_scan);
 
