Skip to content

Commit b2f8e46

Browse files
committed
Improve logging, Revert to Directory Link (#543 / #535)
1 parent 08a8ebb commit b2f8e46

2 files changed

Lines changed: 35 additions & 21 deletions

File tree

MSEdgeRedirect.au3

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ Func ActiveMode(ByRef $aCMDLine)
6363

6464
$aCMDLine = FixTreeIntegrity($aCMDLine)
6565
CheckEdgeIntegrity($aCMDLine[1])
66-
$aCMDLine[1] = StringReplace($aCMDLine[1], "msedge.exe", "IFEO\msedge.exe")
66+
$aCMDLine[1] = StringReplace($aCMDLine[1], "Application\msedge.exe", "IFEO\msedge.exe")
6767

68+
_ArrayDisplay($aCMDLine, "CMDLine Parameters Before Processing", Default, Default, 0x400)
69+
6870
Select
6971
Case $aCMDLine[0] = 1 ; No Parameters
7072
ContinueCase
@@ -85,7 +87,7 @@ Func ActiveMode(ByRef $aCMDLine)
8587
ContinueCase
8688
Case $aCMDLine[0] = 2 And $aCMDLine[2] = "--inprivate" ; In Private Browsing, No Parameters
8789
ContinueCase
88-
Case _ArraySearch($aCMDLine, "--winrt-background-task-event", 2, 0, 0, 1) > 0 ; #94 & #95, Apps
90+
Case _ArraySearch($aCMDLine, "--winrt-background-task-event", 2, 0, 0, 1) > 0 ; #094 & #095, Apps
8991
ContinueCase
9092
Case _ArraySearch($aCMDLine, "--web-widget-jumplist-launch", 2, 0, 0, 1) > 0 ; #123, EdgeBar
9193
ContinueCase
@@ -95,28 +97,32 @@ Func ActiveMode(ByRef $aCMDLine)
9597
ContinueCase
9698
Case _ArraySearch($aCMDLine, "--remote-debugging-port=", 2, 0, 0, 1) > 0 ; #271, Debugging Apps
9799
ContinueCase
98-
Case _ArraySearch($aCMDLine, "--profile-directory=", 2, 0, 0, 1) > 0 ; #68, Multiple Profiles
100+
Case _ArraySearch($aCMDLine, "--profile-directory=", 1, 0, 0, 1) > 0 ; #68, Multiple Profiles, Start at 1 instead of 2 in case of missing parameters
99101
ContinueCase
100102
Case _ArraySearch($aCMDLine, "--user-data-dir=", 2, 0, 0, 1) > 0 ; #463, Multiple Profiles
101-
ContinueCase
103+
$sCMDLine = _ArrayToString($aCMDLine, " ", 2, -1)
104+
_Log($hLogs[$AppGeneral], "Passing Allowed Flag:" & @CRLF & _ArrayToString($aCMDLine, ": ") & @CRLF)
105+
_SafeRun($aCMDLine[1], $sCMDLine)
102106
Case $sParent = "MSEdgeRedirect.exe"
107+
_Log($hLogs[$AppGeneral], "Caught Recursive Call:" & @CRLF & _ArrayToString($aCMDLine, ": ") & @CRLF)
103108
$iIndex = _ArraySearch($aCMDLine, "--from-ie-to-edge", 2, 0, 0, 1)
104109
If $iIndex Then
105110
_ArrayDelete($aCMDLine, $iIndex)
106111
$sCMDLine = _ArrayToString($aCMDLine, " ", 2, -1)
112+
_Log($hLogs[$AppGeneral], "Decoding Recursive Call:" & @CRLF & _ArrayToString($aCMDLine, ": ") & @CRLF)
107113
_DecodeAndRun(Default, $sCMDLine)
108114
EndIf
109-
$sCMDLine = _ArrayToString($aCMDLine, " ", 2, -1)
110-
_SafeRun($aCMDLine[1], $sCMDLine)
111115
Case _DoesParentProcessWantEdge($sParent)
112116
ContinueCase
113117
Case $aCMDLine[0] = 2 And $aCMDLine[2] = "--continue-active-setup"
118+
_Log($hLogs[$AppGeneral], "Passing Setup Call:" & @CRLF & _ArrayToString($aCMDLine, ": ") & @CRLF)
114119
_SafeRun($aCMDLine[1], $aCMDLine[2])
115120
Case _IsURLLocalHost($aCMDLine)
116121
$sCMDLine = _ArrayToString($aCMDLine, " ", 2, -1)
117122
_Log($hLogs[$URIFailures], "Skipped Localhost URL: " & $sCMDLine & @CRLF)
118123
Case Else
119124
$sCMDLine = _ArrayToString($aCMDLine, " ", 2, -1)
125+
_Log($hLogs[$AppGeneral], "Caught Something Else:" & @CRLF & _ArrayToString($aCMDLine, ": ") & @CRLF)
120126
_DecodeAndRun($aCMDLine[1], $sCMDLine)
121127
EndSelect
122128

@@ -130,7 +136,7 @@ Func CheckEdgeIntegrity($sLocation)
130136
Exit
131137
Else
132138
Select
133-
Case Not FileExists(StringReplace($sLocation, "\msedge.exe", "\IFEO\msedge.exe"))
139+
Case Not FileExists(StringReplace($sLocation, "Application\msedge.exe", "\IFEO\msedge.exe"))
134140
If WinExists(_Translate($aMUI[1], "Admin File Copy Required")) Then
135141
_LogClose()
136142
Exit ; #202
@@ -549,7 +555,7 @@ Func ReactiveMode($bHide = False)
549555
EndFunc
550556

551557
Func SINK_OnObjectReady($oProcess)
552-
ProcessClose($oProcess.TargetInstance.ProcessID)
558+
;ProcessClose($oProcess.TargetInstance.ProcessID)
553559

554560
Local $sProcessPath
555561
Local $sCommandline
@@ -565,8 +571,8 @@ Func SINK_OnObjectReady($oProcess)
565571

566572
$sCommandline = _WinAPI_GetProcessCommandLine($oProcess.TargetInstance.ProcessID)
567573
$sProcessPath = _WinAPI_GetProcessFileName($oProcess.TargetInstance.ProcessID)
568-
ConsoleWrite($sCommandline & @CRLF)
569-
If StringRegExp($sCommandline, $sRegex) Then _DecodeAndRun($sProcessPath, $sCommandline)
574+
ShellExecute("C:\Users\rcmaehl\Documents\GitHub\MSEdgeRedirect\del.exe", $sCommandline)
575+
; If StringRegExp($sCommandline, $sRegex) Then _DecodeAndRun($sProcessPath, $sCommandline)
570576
EndFunc
571577

572578
Func _registerProcessCreation()
@@ -650,15 +656,16 @@ Func _DecodeAndRun($sEdge = $aEdges[1], $sCMDLine = "")
650656

651657
; Run Edge
652658
Case StringRegExp($sCMDLine, "--default-search-provider=\? --out-pipe-name=MSEdgeDefault[a-z0-9]+")
653-
_Log($hLogs[$AppSecurity], "Passed Through MS-Settings Call: " & $sCMDLine & @CRLF)
659+
_Log($hLogs[$AppSecurity], "Passing MS-Settings Call: " & $sCMDLine & @CRLF)
654660
_SafeRun($sEdge, $sCMDLine)
655661
Case $sCMDLine = "--no-startup-window --win-session-start"
656-
_Log($hLogs[$AppSecurity], "Passed Through MSEdge Startup Call: " & $sCMDLine & @CRLF)
662+
_Log($hLogs[$AppSecurity], "Passing MSEdge Startup Call: " & $sCMDLine & @CRLF)
657663
_SafeRun($sEdge, $sCMDLine)
658664

659665
; Run Another App
660666
Case FileExists(StringReplace($sCMDLine, "--single-argument ", "")); File Handling
661667
If _GetSettingValue("NoFiles", "Bool") Or _GetSettingValue("NoPDFs", "Bool") Then
668+
_Log($hLogs[$AppGeneral], "Caught File Call:" & @CRLF & _ArrayToString($aCMDLine, ": ") & @CRLF)
662669
$sCMDLine = StringReplace($sCMDLine, "--single-argument ", "")
663670
If _IsSafeFile($sCMDLine) Then ShellExecute('"' & $sCMDLine & '"', "", "", $SHEX_EDIT)
664671
EndIf
@@ -686,12 +693,14 @@ Func _DecodeAndRun($sEdge = $aEdges[1], $sCMDLine = "")
686693
$sCMDLine = StringRegExpReplace($sCMDLine, "(?i)(.*)(--app-fallback-url=)", "")
687694
$sCMDLine = StringRegExpReplace($sCMDLine, "(?i)(?= --)(.*)", "")
688695
If _IsSafeURL($sCMDLine) Then
696+
_Log($hLogs[$AppGeneral], "Caught PWA Call:" & @CRLF & _ArrayToString($aCMDLine, ": ") & @CRLF)
689697
ShellExecute($sCMDLine)
690698
Else
691699
_Log($hLogs[$URIFailures], "Invalid App URL: " & $sCMDLine & @CRLF)
692700
EndIf
693701
Case StringInStr($sCMDLine, "--ip-aumid=") ; Edge "Apps"
694702
If _IsSafeApp($sCMDLine) Then
703+
_Log($hLogs[$AppGeneral], "Caught AUMID Call:" & @CRLF & _ArrayToString($aCMDLine, ": ") & @CRLF)
695704
_SafeRun($sEdge, $sCMDLine)
696705
Else
697706
_Log($hLogs[$URIFailures], "Invalid App URL: " & $sCMDLine & @CRLF)
@@ -701,9 +710,12 @@ Func _DecodeAndRun($sEdge = $aEdges[1], $sCMDLine = "")
701710
EndSelect
702711

703712
Case StringInStr($sCMDLine, "ux=copilot") ; CoPilot
713+
_Log($hLogs[$AppGeneral], "Caught Co-Pilot Call:" & @CRLF & _ArrayToString($aCMDLine, ": ") & @CRLF)
704714
If _GetSettingValue("NoPilot", "Bool") Then
715+
_Log($hLogs[$AppGeneral], "Dropping Co-Pilot Call:" & @CRLF & _ArrayToString($aCMDLine, ": ") & @CRLF)
705716
ShellExecute("ms-settings:")
706717
Else
718+
_Log($hLogs[$AppGeneral], "Passing Co-Pilot Call:" & @CRLF & _ArrayToString($aCMDLine, ": ") & @CRLF)
707719
_SafeRun($sEdge, $sCMDLine)
708720
EndIf
709721

@@ -715,14 +727,18 @@ Func _DecodeAndRun($sEdge = $aEdges[1], $sCMDLine = "")
715727

716728
; Do Either (Drop Call or Run Edge)
717729
Case StringInStr($sCMDLine, "bing.com/chat") Or StringInStr($sCMDLine, "bing.com%2Fchat") ; Fix BingAI
718-
If _GetSettingValue("NoChat", "Bool") Then
730+
_Log($hLogs[$AppGeneral], "Caught Bing Chat Call:" & @CRLF & _ArrayToString($aCMDLine, ": ") & @CRLF)
731+
If _GetSettingValue("NoChat", "Bool") Then
732+
_Log($hLogs[$AppGeneral], "Skipped Bing Chat Call:" & @CRLF & _ArrayToString($aCMDLine, ": ") & @CRLF)
719733
ContinueCase
720734
Else
735+
_Log($hLogs[$AppGeneral], "Passing Bing Chat Call:" & @CRLF & _ArrayToString($aCMDLine, ": ") & @CRLF)
721736
_SafeRun($sEdge, $sCMDLine)
722737
EndIf
723738

724739
; Call Default Browser
725740
Case StringInStr($sCMDLine, "bing.com/spotlight?spotlightid") ; Fix Windows Spotlight
741+
_Log($hLogs[$AppGeneral], "Caught Windows Spotlight Call:" & @CRLF & _ArrayToString($aCMDLine, ": ") & @CRLF)
726742
$sCMDLine = StringRegExpReplace($sCMDLine, "(?i)spotlight\?spotlightid=[^&]+&", "search?")
727743
ContinueCase
728744
Case StringInStr($sCMDLine, "&url=") ; Fix Windows 11 Widgets
@@ -752,6 +768,7 @@ Func _DecodeAndRun($sEdge = $aEdges[1], $sCMDLine = "")
752768
; Catch Misc Edge Flags (MUST BE LOWEST PRIORITY)
753769
Case StringLeft($sCMDLine, 2) = "--"
754770
If _GetSettingValue("RunUnsafe") Then
771+
_Log($hLogs[$AppSecurity], "" & "Allowed Unsafe Flag: " & $sCMDLine & @CRLF)
755772
_SafeRun($sEdge, $sCMDLine)
756773
Else
757774
_Log($hLogs[$AppSecurity], "" & "Blocked Unsafe Flag: " & $sCMDLine & @CRLF)

MSEdgeRedirect_Wrapper.au3

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,13 @@ Func RunRemoval($bUpdate = False)
224224
If FileExists(StringReplace($aEdges[$iLoop], "msedge.exe", "msedge_no_ifeo.exe")) Then ; Pre-0.7.3.0
225225
FileDelete(StringReplace($aEdges[$iLoop], "msedge.exe", "msedge_no_ifeo.exe"))
226226
EndIf
227-
If FileExists(StringReplace($aEdges[$iLoop], "Application\msedge.exe", "IFEO\")) Then ; 0.7.3.0+
227+
If FileExists(StringReplace($aEdges[$iLoop], "Application\msedge.exe", "IFEO\")) Then ; 0.7.3.0+, 0.8.1.0+
228228
DirRemove(StringReplace($aEdges[$iLoop], "Application\msedge.exe", "IFEO\"))
229229
EndIf
230230
If FileExists(StringReplace($aEdges[$iLoop], "\msedge.exe", "\msedge_IFEO.exe")) Then ; 0.8.0.0+
231231
FileDelete(StringReplace($aEdges[$iLoop], "\msedge.exe", "\msedge_IFEO.exe"))
232232
EndIf
233-
If FileExists(StringReplace($aEdges[$iLoop], "\msedge.exe", "\IFEO\msedge.exe")) Then ; 0.8.1.0+
233+
If FileExists(StringReplace($aEdges[$iLoop], "\msedge.exe", "\IFEO\msedge.exe")) Then ; 0.8.1.0 Dev
234234
FileDelete(StringReplace($aEdges[$iLoop], "\msedge.exe", "\IFEO\msedge.exe"))
235235
DirRemove(StringReplace($aEdges[$iLoop], "\msedge.exe", "\IFEO\"))
236236
EndIf
@@ -264,10 +264,8 @@ Func RunRepair()
264264
;;;
265265
Else
266266
_Log($hLogs[$Install], "Repairing SymLinks." & @CRLF)
267-
If Not FileExists(StringReplace($aEdges[$iLoop], "\msedge.exe", "\IFEO\")) Then
268-
DirCreate(StringReplace($aEdges[$iLoop], "\msedge.exe", "\IFEO\"))
269-
EndIf
270-
_WinAPI_CreateSymbolicLink(StringReplace($aEdges[$iLoop], "\msedge.exe", "\IFEO\msedge.exe"), $aEdges[$iLoop])
267+
_WinAPI_CreateSymbolicLink(StringReplace($aEdges[$iLoop], "Application\msedge.exe", "IFEO\"), StringReplace($aEdges[$iLoop], "\msedge.exe", ""), True)
268+
If @error Then _Log($hLogs[$Install], "[WARNING] Unable to Create IFEO Directory for " & $aEdges[$iLoop] & @CRLF)
271269
EndIf
272270
EndIf
273271
Next
@@ -1429,8 +1427,7 @@ Func SetIFEORegistry(ByRef $aChannels)
14291427
If $iLoop = $aEdges[0] Then
14301428
;;;
14311429
Else
1432-
DirCreate(StringReplace($aEdges[$iLoop], "\msedge.exe", "\IFEO\"))
1433-
_WinAPI_CreateSymbolicLink(StringReplace($aEdges[$iLoop], "\msedge.exe", "\IFEO\msedge.exe"), $aEdges[$iLoop])
1430+
_WinAPI_CreateSymbolicLink(StringReplace($aEdges[$iLoop], "Application\msedge.exe", "IFEO\"), StringReplace($aEdges[$iLoop], "\msedge.exe", ""), True)
14341431
EndIf
14351432
EndIf
14361433
Next

0 commit comments

Comments
 (0)