Skip to content

Force Proxy to any Windows/MacOS/Linux Application TCP and UDP traffic

#198 - added safe closure on installation, Run post install

AnoF-Cyberef72e0b3583d
diff --git a/Windows/cli/main.c b/Windows/cli/main.c
index 29638cc..fab50ff 100644
--- a/Windows/cli/main.c
+++ b/Windows/cli/main.c
@@ -16,7 +16,7 @@
#pragma comment(lib, "advapi32.lib")
-#define VERSION "4.0.11-Beta"
+#define VERSION "4.0.13-Beta"
#define MAX_PROXY_CONFIGS 16
#define MAX_RULES 256
diff --git a/Windows/gui/res/app.manifest b/Windows/gui/res/app.manifest
index ee33c00..325c1b4 100644
--- a/Windows/gui/res/app.manifest
+++ b/Windows/gui/res/app.manifest
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
- <assemblyIdentity version="4.0.11.0" processorArchitecture="*" name="InterceptSuite.ProxyBridge.NativeGUI" type="win32"/>
+ <assemblyIdentity version="4.0.13.0" processorArchitecture="*" name="InterceptSuite.ProxyBridge.NativeGUI" type="win32"/>
<!-- Require administrator: WinDivert needs elevation to load its kernel driver. -->
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
diff --git a/Windows/gui/res/resource.h b/Windows/gui/res/resource.h
index ec3982e..74a57ee 100644
--- a/Windows/gui/res/resource.h
+++ b/Windows/gui/res/resource.h
@@ -9,8 +9,8 @@
#define PB_VER_MINOR 0
#define PB_VER_PATCH 11
#define PB_VER_BUILD 0
-#define PB_VER_STR "4.0.11-Beta" // narrow, for the .rc VERSIONINFO strings
-#define PB_VER_STRW L"4.0.11-Beta" // wide, for the C/About UI
+#define PB_VER_STR "4.0.13-Beta" // narrow, for the .rc VERSIONINFO strings
+#define PB_VER_STRW L"4.0.13-Beta" // wide, for the C/About UI
#define IDI_APPICON 101
diff --git a/Windows/installer/ProxyBridge.nsi b/Windows/installer/ProxyBridge.nsi
index b444075..aaa306c 100644
--- a/Windows/installer/ProxyBridge.nsi
+++ b/Windows/installer/ProxyBridge.nsi
@@ -1,5 +1,5 @@
!define PRODUCT_NAME "ProxyBridge"
-!define PRODUCT_VERSION "4.0.11-Beta"
+!define PRODUCT_VERSION "4.0.13-Beta"
!define PRODUCT_PUBLISHER "InterceptSuite"
!define PRODUCT_WEB_SITE "https://github.com/InterceptSuite/ProxyBridge"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
@@ -8,7 +8,7 @@
Unicode True
; Version Information
-VIProductVersion "4.0.11.0"
+VIProductVersion "4.0.13.0"
VIAddVersionKey "ProductName" "${PRODUCT_NAME}"
VIAddVersionKey "ProductVersion" "${PRODUCT_VERSION}"
VIAddVersionKey "CompanyName" "${PRODUCT_PUBLISHER}"
@@ -36,6 +36,10 @@ RequestExecutionLevel admin
!insertmacro MUI_PAGE_LICENSE "..\..\\LICENSE"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
+
+; Finish page offers to launch ProxyBridge - checkbox is checked by default.
+!define MUI_FINISHPAGE_RUN "$INSTDIR\ProxyBridge.exe"
+!define MUI_FINISHPAGE_RUN_TEXT "Run ProxyBridge now"
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
@@ -44,10 +48,21 @@ RequestExecutionLevel admin
!insertmacro MUI_LANGUAGE "English"
Section "MainSection" SEC01
- ; Kill any running ProxyBridge instance before overwriting files.
- ; This prevents "file in use" errors on update/reinstall.
- nsExec::ExecToLog 'taskkill /F /IM ProxyBridge.exe'
- nsExec::ExecToLog 'taskkill /F /IM ProxyBridge_CLI.exe'
+ ; A running ProxyBridge locks the files we need to overwrite. Detect it and ask
+ ; the user before closing it, instead of killing it silently.
+ nsExec::ExecToStack 'cmd /c tasklist /FI "IMAGENAME eq ProxyBridge.exe" /NH | findstr /I "ProxyBridge.exe"'
+ Pop $0 ; findstr exit code: 0 = a matching process is running
+ Pop $1 ; captured output (unused)
+ StrCmp $0 "0" 0 install_proceed
+ MessageBox MB_YESNO|MB_ICONQUESTION "ProxyBridge is currently running and must be closed to continue the installation.$\n$\nClose ProxyBridge now and continue?$\n$\nYes - close ProxyBridge and install$\nNo - cancel and close the installer" IDYES install_kill IDNO install_abort
+ install_abort:
+ Quit
+ install_kill:
+ nsExec::ExecToLog 'taskkill /F /IM ProxyBridge.exe'
+ nsExec::ExecToLog 'taskkill /F /IM ProxyBridge_CLI.exe'
+ Sleep 1500
+ install_proceed:
+
; Stop and unload the WinDivert driver so WinDivert64.sys can be replaced.
nsExec::ExecToLog 'sc stop WinDivert'
nsExec::ExecToLog 'sc delete WinDivert'
@@ -90,6 +105,25 @@ Section -Post
SectionEnd
Section Uninstall
+ ; If ProxyBridge is running, its files stay locked and can only be removed after a
+ ; reboot. Detect it and offer to close it so the uninstall can complete now.
+ nsExec::ExecToStack 'cmd /c tasklist /FI "IMAGENAME eq ProxyBridge.exe" /NH | findstr /I "ProxyBridge.exe"'
+ Pop $0 ; findstr exit code: 0 = a matching process is running
+ Pop $1 ; captured output (unused)
+ StrCmp $0 "0" 0 uninst_proceed
+ MessageBox MB_YESNO|MB_ICONQUESTION "ProxyBridge is currently running.$\n$\nClose it and continue the uninstall?$\n$\nYes - close ProxyBridge and remove all files now$\nNo - continue without closing (some files may be removed only after a reboot)" IDYES uninst_kill IDNO uninst_proceed
+ uninst_kill:
+ nsExec::ExecToLog 'taskkill /F /IM ProxyBridge.exe'
+ nsExec::ExecToLog 'taskkill /F /IM ProxyBridge_CLI.exe'
+ Sleep 1500
+ uninst_proceed:
+
+ ; Stop the WinDivert driver first so WinDivert64.sys isn't held open.
+ nsExec::ExecToLog 'sc stop WinDivert'
+ nsExec::ExecToLog 'sc delete WinDivert'
+ DeleteRegKey HKLM "SYSTEM\CurrentControlSet\Services\WinDivert"
+ Sleep 500
+
Delete "$INSTDIR\ProxyBridge.exe"
Delete "$INSTDIR\ProxyBridge_CLI.exe"
Delete "$INSTDIR\ProxyBridgeCore.dll"
@@ -110,12 +144,6 @@ Section Uninstall
; Broadcast environment change
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
- ; Stop and remove the WinDivert kernel driver service so a future reinstall
- ; doesn't inherit a stale/disabled entry (error 1058).
- nsExec::ExecToLog 'sc stop WinDivert'
- nsExec::ExecToLog 'sc delete WinDivert'
- DeleteRegKey HKLM "SYSTEM\CurrentControlSet\Services\WinDivert"
-
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
SetAutoClose true
SectionEnd
diff --git a/Windows/src/ProxyBridge.c b/Windows/src/ProxyBridge.c
index 8cc566d..85fd577 100644
--- a/Windows/src/ProxyBridge.c
+++ b/Windows/src/ProxyBridge.c
@@ -17,7 +17,7 @@
#define LOCAL_PROXY_PORT 34010
#define LOCAL_UDP_RELAY_PORT 34011 // its running UDP port still make sure to not run on same port as TCP, opening same port and tcp and udp cause issue and handling port at relay server response injection
#define MAX_PROCESS_NAME 1024
-#define VERSION "4.0.11-Beta"
+#define VERSION "4.0.13-Beta"
#define PID_CACHE_SIZE 1024
#define PID_CACHE_TTL_MS 30000
// Single packet-processor thread eliminates TCP packet reordering.