From aa28d3e12abeee4b7034f7411c8941cc54d29c05 Mon Sep 17 00:00:00 2001
From: ValdikSS <iam@valdikss.org.ru>
Date: Thu, 15 Feb 2018 15:41:28 +0300
Subject: [PATCH] Make sure to search DLLs only in safe path, not in current
 working dir

---
 goodbyedpi.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/goodbyedpi.c b/goodbyedpi.c
index ce316ca..fdbc93c 100644
--- a/goodbyedpi.c
+++ b/goodbyedpi.c
@@ -326,6 +326,10 @@ int main(int argc, char *argv[]) {
     char *hdr_name_addr = NULL, *hdr_value_addr = NULL;
     int hdr_value_len;
 
+    // Make sure to search DLLs only in safe path, not in current working dir.
+    SetDllDirectory("");
+    SetSearchPathMode(BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE | BASE_SEARCH_PATH_PERMANENT);
+
     if (!running_from_service) {
         running_from_service = 1;
         if (service_register(argc, argv)) {