Kartom

Untitled

Oct 4th, 2024
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 61.41 KB | Source Code | 0 0
  1. #NoTrayIcon
  2. #RequireAdmin
  3. #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
  4. #AutoIt3Wrapper_Icon=ICONS/Logo.ico
  5. #AutoIt3Wrapper_Outfile_x64=GenP-3.4.14.1.exe
  6. #AutoIt3Wrapper_Res_Comment=GenP v3.4.14.1
  7. #AutoIt3Wrapper_Res_Description=GenP v3.4.14.1
  8. #AutoIt3Wrapper_Res_Fileversion=3.4.14.1
  9. #AutoIt3Wrapper_Res_ProductName=GenP v3.4.14.1
  10. #AutoIt3Wrapper_Res_ProductVersion=3.4.14.1
  11. #AutoIt3Wrapper_Res_CompanyName=GenP
  12. #AutoIt3Wrapper_Res_LegalCopyright=GenP
  13. #AutoIt3Wrapper_Res_LegalTradeMarks=GenP
  14. #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
  15. #AutoIt3Wrapper_Run_Au3Stripper=y
  16. #Au3Stripper_Parameters=/pe /sf /sv /rm
  17. #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
  18.  
  19. #include <ProgressConstants.au3>
  20. #include <WindowsConstants.au3>
  21. #include <GUIConstantsEx.au3>
  22. #include <EditConstants.au3>
  23. #include <GuiListView.au3>
  24. #include <WinAPIProc.au3>
  25. #include <Constants.au3>
  26. #include <String.au3>
  27. #include <WinAPI.au3>
  28. #include <Misc.au3>
  29.  
  30. AutoItSetOption("GUICloseOnESC", 0)  ;1=ESC closes, 0=ESC won't close
  31.  
  32. Global Const $g_AppWndTitle = "GenP v3.4.14.1", $g_AppVersion = "Original version by uncia/CGP - GenP Community Edition - v3.4.14.1"
  33.  
  34. If _Singleton($g_AppWndTitle, 1) = 0 Then
  35.     Exit
  36. EndIf
  37.  
  38. Global $MyLVGroupIsExpanded = True
  39. Global $fInterrupt = 0
  40. Global $FilesToPatch[0][1], $FilesToPatchNull[0][1]
  41. Global $FilesToRestore[0][1], $fFilesListed = 0
  42. Global $MyhGUI, $hTab, $hMainTab, $hLogTab, $idMsg, $idListview, $g_idListview, $idButtonSearch, $idButtonStop
  43. Global $idButtonCustomFolder, $idBtnCure, $idBtnDeselectAll, $ListViewSelectFlag = 1
  44. Global $idBtnBlockPopUp, $idBtnPatchCC, $idMemo, $timestamp, $idLog, $idBtnRestore, $idBtnCopyLog
  45.  
  46. Global $sINIPath = @ScriptDir & "\config.ini"
  47. If Not FileExists($sINIPath) Then
  48.     FileInstall("config.ini", @ScriptDir & "\config.ini")
  49. EndIf
  50.  
  51. Global $MyDefPath = IniRead($sINIPath, "Default", "Path", "C:\Program Files\Adobe")
  52. If Not FileExists($MyDefPath) Or Not StringInStr(FileGetAttrib($MyDefPath), "D") Then
  53.     IniWrite($sINIPath, "Default", "Path", "C:\Program Files\Adobe")
  54.     $MyDefPath = "C:\Program Files\Adobe"
  55. EndIf
  56.  
  57. FileInstall("NSudoLG.exe", @TempDir & "\NSudoLG.exe", 1)
  58.  
  59. Local $sNSudoLGPath = @TempDir & "\NSudoLG.exe"
  60.  
  61. If Not (@UserName = "SYSTEM") And FileExists($sNSudoLGPath) Then
  62.     Local $iAnswer = MsgBox(4, "TrustedInstaller", "Do you wish to elevate GenP to TrustedInstaller to allow for patching of XD/UWP apps? Do not use this option if you encounter any issues, it is experimental!")
  63.     If $iAnswer = 6 Then
  64.         Exit Run($sNSudoLGPath & ' -U:T -P:E -M:S "' & @ScriptFullPath & '"')
  65.     EndIf
  66. Else
  67.     Local $sFixPath = "C:\Windows\System32\config\systemprofile\Desktop"
  68.     If Not FileExists($sFixPath) Then
  69.         DirCreate($sFixPath)
  70.     EndIf
  71. EndIf
  72.  
  73. FileDelete($sNSudoLGPath)
  74.  
  75. Global $MyRegExpGlobalPatternSearchCount = 0, $Count = 0, $idProgressBar
  76. Global $aOutHexGlobalArray[0], $aNullArray[0], $aInHexArray[0]
  77. Global $MyFileToParse = "", $MyFileToParsSweatPea = "", $MyFileToParseEaclient = ""
  78. Global $sz_type, $bFoundAcro32 = False, $bFoundLrARM = False, $bFoundCCARM = False, $bFoundPsARM = False, $bFoundGenericARM = False, $aSpecialFiles, $sSpecialFiles = "|"
  79. Global $ProgressFileCountScale, $FileSearchedCount
  80.  
  81. Local $tTargetFileList_Adobe = IniReadSection($sINIPath, "TargetFiles")
  82. Global $TargetFileList_Adobe[0]
  83. If Not @error Then
  84.     ReDim $TargetFileList_Adobe[$tTargetFileList_Adobe[0][0]]
  85.     For $i = 1 To $tTargetFileList_Adobe[0][0]
  86.         $TargetFileList_Adobe[$i - 1] = StringReplace($tTargetFileList_Adobe[$i][1], '"', "")
  87.     Next
  88. EndIf
  89. ;_ArrayDisplay($TargetFileList_Adobe, "TargetFileList_Adobe")
  90.  
  91. $aSpecialFiles = IniReadSection($sINIPath, "CustomPatterns")
  92. ;_ArrayDisplay($aSpecialFiles)
  93. For $i = 1 To UBound($aSpecialFiles) - 1
  94.     $sSpecialFiles = $sSpecialFiles & $aSpecialFiles[$i][0] & "|"
  95. Next
  96. ;MsgBox(0, "", $sSpecialFiles)
  97.  
  98. GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
  99.  
  100. MainGui()
  101.  
  102. While 1
  103.     $idMsg = GUIGetMsg()
  104.  
  105.     Select
  106.         Case $idMsg = $GUI_EVENT_CLOSE
  107.             GUIDelete($MyhGUI)
  108.             Exit
  109.         Case $idMsg = $GUI_EVENT_RESIZED
  110.             ContinueCase
  111.         Case $idMsg = $GUI_EVENT_RESTORE
  112.             ContinueCase
  113.         Case $idMsg = $GUI_EVENT_MAXIMIZE
  114.             Local $iWidth
  115.             Local $aGui = WinGetPos($MyhGUI)
  116.             Local $aRect = _GUICtrlListView_GetViewRect($g_idListview)
  117.             If ($aRect[2] > $aGui[2]) Then
  118.                 $iWidth = $aGui[2] - 75
  119.             Else
  120.                 $iWidth = $aRect[2] - 25
  121.             EndIf
  122.             GUICtrlSendMsg($idListview, $LVM_SETCOLUMNWIDTH, 1, $iWidth)
  123.  
  124.         Case $idMsg = $idButtonStop
  125.             $ListViewSelectFlag = 0   ; Set Flag to Deselected State
  126.             FillListViewWithInfo()
  127.             MemoWrite(@CRLF & "Path" & @CRLF & "---" & @CRLF & $MyDefPath & @CRLF & "---" & @CRLF & "Waiting for user action.")
  128.             GUICtrlSetState($idButtonStop, $GUI_HIDE)
  129.             GUICtrlSetState($idButtonSearch, $GUI_SHOW)
  130.             GUICtrlSetState($idButtonSearch, 64)
  131.             GUICtrlSetState($idBtnRestore, $GUI_HIDE)
  132.             GUICtrlSetState($idBtnBlockPopUp, $GUI_SHOW)
  133.             GUICtrlSetState($idBtnBlockPopUp, 64)
  134.             GUICtrlSetState($idBtnDeselectAll, 128)
  135.             GUICtrlSetState($idBtnCure, 128)
  136.             GUICtrlSetState($idBtnPatchCC, 64)
  137.  
  138.         Case $idMsg = $idButtonSearch
  139.             $fInterrupt = 0
  140.             GUICtrlSetState($idButtonSearch, $GUI_HIDE)
  141.             GUICtrlSetState($idButtonStop, $GUI_SHOW)
  142.             ToggleLog(0)
  143.             GUICtrlSetState($idBtnDeselectAll, 128)
  144.             GUICtrlSetState($idBtnBlockPopUp, 128)
  145.             GUICtrlSetState($idListview, 128)
  146.             GUICtrlSetState($idBtnCure, 128)
  147.             GUICtrlSetState($idButtonCustomFolder, 128)
  148.             GUICtrlSetState($idBtnPatchCC, 128)
  149.             ;Search through all files and folders in directory and fill ListView
  150.             _GUICtrlListView_DeleteAllItems($g_idListview)
  151.             _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER))
  152.             _GUICtrlListView_AddItem($idListview, "", 0)
  153.             _GUICtrlListView_AddItem($idListview, "", 1)
  154.             _GUICtrlListView_AddItem($idListview, "", 2)
  155.             _GUICtrlListView_AddItem($idListview, "", 2)
  156.  
  157.             _GUICtrlListView_RemoveAllGroups($idListview)
  158.             _GUICtrlListView_InsertGroup($idListview, -1, 1, "", 1)    ; Group 1
  159.             _GUICtrlListView_SetGroupInfo($idListview, 1, "Info", 1, $LVGS_COLLAPSIBLE)
  160.  
  161.             _GUICtrlListView_AddSubItem($idListview, 0, "", 1)
  162.             _GUICtrlListView_AddSubItem($idListview, 1, "Preparing...", 1)
  163.             _GUICtrlListView_AddSubItem($idListview, 2, "", 1)
  164.             _GUICtrlListView_AddSubItem($idListview, 3, "Be patient, please.", 1)
  165.             _GUICtrlListView_SetItemGroupID($idListview, 0, 1)
  166.             _GUICtrlListView_SetItemGroupID($idListview, 1, 1)
  167.             _GUICtrlListView_SetItemGroupID($idListview, 2, 1)
  168.             _GUICtrlListView_SetItemGroupID($idListview, 3, 1)
  169.  
  170.             _Expand_All_Click()
  171.             _GUICtrlListView_SetGroupInfo($idListview, 1, "Info", 1, $LVGS_COLLAPSIBLE)
  172.  
  173.  
  174.             ; Clear previous results
  175.             $FilesToPatch = $FilesToPatchNull
  176.             $FilesToRestore = $FilesToPatchNull
  177.  
  178.             $timestamp = TimerInit()
  179.  
  180.             Local $FileCount
  181.             Local $aSize = DirGetSize($MyDefPath, $DIR_EXTENDED)     ; extended mode
  182.             If UBound($aSize) >= 2 Then
  183.                 $FileCount = $aSize[1]
  184.                 $ProgressFileCountScale = 100 / $FileCount
  185.                 $FileSearchedCount = 0
  186.                 ProgressWrite(0)
  187.                 RecursiveFileSearch($MyDefPath, 0, $FileCount)   ;Search through all files and folders
  188.                 Sleep(100)
  189.                 ProgressWrite(0)
  190.             EndIf
  191.  
  192.             If $MyDefPath = "C:\Program Files" Or $MyDefPath = "C:\Program Files\Adobe" Then
  193.                 Local $sProgramFiles = EnvGet('ProgramFiles(x86)') & "\Common Files\Adobe"
  194.                 $aSize = DirGetSize($sProgramFiles, $DIR_EXTENDED)     ; extended mode
  195.                 If UBound($aSize) >= 2 Then
  196.                     $FileCount = $aSize[1]
  197.                     RecursiveFileSearch($sProgramFiles, 0, $FileCount)   ;Search through all files and folders
  198.                     ProgressWrite(0)
  199.                 EndIf
  200.             EndIf
  201.  
  202.             FillListViewWithFiles()
  203.  
  204.             If _GUICtrlListView_GetItemCount($idListview) > 0 Then
  205.  
  206.                 _Assign_Groups_To_Found_Files()
  207.  
  208.                 $ListViewSelectFlag = 1   ; Set Flag to Selected State
  209.                 GUICtrlSetState($idButtonSearch, 128)
  210.                 GUICtrlSetState($idBtnDeselectAll, 128)
  211.                 GUICtrlSetState($idBtnCure, 64)
  212.                 GUICtrlSetState($idBtnCure, 256)     ; Set focus
  213.  
  214.                 If UBound($FilesToRestore) > 0 Then
  215.                     GUICtrlSetState($idBtnBlockPopUp, $GUI_HIDE)
  216.                     GUICtrlSetState($idBtnRestore, 64)
  217.                     GUICtrlSetState($idBtnRestore, $GUI_SHOW)
  218.                 EndIf
  219.             Else
  220.                 $ListViewSelectFlag = 0   ; Set Flag to Deselected State
  221.                 FillListViewWithInfo()
  222.                 GUICtrlSetState($idBtnCure, 128)
  223.                 GUICtrlSetState($idBtnDeselectAll, 128)
  224.                 GUICtrlSetState($idButtonSearch, 64)
  225.                 GUICtrlSetState($idButtonSearch, 256)     ; Set focus
  226.             EndIf
  227.  
  228.             ;_Collapse_All_Click()
  229.             _Expand_All_Click()
  230.  
  231.             GUICtrlSetState($idBtnDeselectAll, 64)
  232.             GUICtrlSetState($idBtnBlockPopUp, 64)
  233.             GUICtrlSetState($idListview, 64)
  234.             GUICtrlSetState($idButtonCustomFolder, 64)
  235.             GUICtrlSetState($idButtonSearch, $GUI_SHOW)
  236.             GUICtrlSetState($idButtonStop, $GUI_HIDE)
  237.             GUICtrlSetState($idBtnPatchCC, 64)
  238.  
  239.         Case $idMsg = $idButtonCustomFolder     ; Select Custom Path
  240.  
  241.             ToggleLog(0)
  242.  
  243.             MyFileOpenDialog()
  244.             _Expand_All_Click()
  245.  
  246.             If $fFilesListed = 0 Then
  247.                 GUICtrlSetState($idBtnCure, 128)
  248.                 GUICtrlSetState($idBtnDeselectAll, 128)
  249.                 GUICtrlSetState($idButtonSearch, 64)
  250.                 GUICtrlSetState($idButtonSearch, 256)     ; Set focus
  251.             Else
  252.                 GUICtrlSetState($idButtonSearch, 128)
  253.                 GUICtrlSetState($idBtnDeselectAll, 64)
  254.                 GUICtrlSetState($idBtnCure, 64)
  255.                 GUICtrlSetState($idBtnCure, 256)     ; Set focus
  256.             EndIf
  257.  
  258.         Case $idMsg = $idBtnDeselectAll     ; Deselect-Select All
  259.             ToggleLog(0)
  260.             If $ListViewSelectFlag = 1 Then
  261.                 For $i = 0 To _GUICtrlListView_GetItemCount($idListview) - 1
  262.                     _GUICtrlListView_SetItemChecked($idListview, $i, 0)
  263.                 Next
  264.                 $ListViewSelectFlag = 0   ; Set Flag to Deselected State
  265.             Else
  266.                 For $i = 0 To _GUICtrlListView_GetItemCount($idListview) - 1
  267.                     _GUICtrlListView_SetItemChecked($idListview, $i, 1)
  268.                 Next
  269.                 $ListViewSelectFlag = 1   ; Set Flag to Selected State
  270.             EndIf
  271.  
  272.  
  273.         Case $idMsg = $idBtnBlockPopUp     ; Pop-up button
  274.             ToggleLog(0)
  275.             BlockPopUp()
  276.  
  277.         Case $idMsg = $idBtnPatchCC     ; Patch Creative Cloud button
  278.             Global $appsPanelFile
  279.             Global $containerBLFile
  280.             Global $adobeDesktopServiceFile
  281.             ToggleLog(0)
  282.             GUICtrlSetState($hLogTab, $GUI_SHOW)
  283.             GUICtrlSetState($idBtnDeselectAll, 128)
  284.             GUICtrlSetState($idBtnBlockPopUp, 128)
  285.             GUICtrlSetState($idListview, 128)
  286.             GUICtrlSetState($idButtonCustomFolder, 128)
  287.             GUICtrlSetState($idButtonSearch, 128)
  288.             GUICtrlSetState($idBtnPatchCC, 128)
  289.             If FileExists("C:\Program Files\Common Files\Adobe\Adobe Desktop Common\AppsPanel\AppsPanelBL.dll") Then
  290.                 $appsPanelFile = "C:\Program Files\Common Files\Adobe\Adobe Desktop Common\AppsPanel\AppsPanelBL.dll"
  291.             ElseIf FileExists("C:\Program Files (x86)\Common Files\Adobe\Adobe Desktop Common\AppsPanel\AppsPanelBL.dll") Then
  292.                 $appsPanelFile = "C:\Program Files (x86)\Common Files\Adobe\Adobe Desktop Common\AppsPanel\AppsPanelBL.dll"
  293.             Else
  294.                 $appsPanelFile = FileOpenDialog("Select a File", @ScriptDir, "AppsPanelBL.dll (AppsPanelBL.dll)")
  295.             EndIf
  296.             ProgressWrite(0)
  297.             If FileExists($appsPanelFile) Then
  298.                 MyGlobalPatternSearch($appsPanelFile)
  299.                 Sleep(100)
  300.                 MemoWrite(@CRLF & "File Path:" & @CRLF & "" & @CRLF & $appsPanelFile & @CRLF & "" & @CRLF & "")
  301.                 Sleep(100)
  302.                 MyGlobalPatternPatch($appsPanelFile, $aOutHexGlobalArray)
  303.                 Sleep(500)
  304.             EndIf
  305.             ProgressWrite(0)
  306.             If $bFoundCCARM = False Then
  307.                 If FileExists("C:\Program Files\Common Files\Adobe\Adobe Desktop Common\ADS\ContainerBL.dll") Then
  308.                     $containerBLFile = "C:\Program Files\Common Files\Adobe\Adobe Desktop Common\ADS\ContainerBL.dll"
  309.                 ElseIf FileExists("C:\Program Files (x86)\Common Files\Adobe\Adobe Desktop Common\ADS\ContainerBL.dll") Then
  310.                     $containerBLFile = "C:\Program Files (x86)\Common Files\Adobe\Adobe Desktop Common\ADS\ContainerBL.dll"
  311.                 Else
  312.                     $containerBLFile = FileOpenDialog("Select a File", @ScriptDir, "ContainerBL.dll (ContainerBL.dll)")
  313.                 EndIf
  314.                 ProgressWrite(0)
  315.                 If FileExists($containerBLFile) Then
  316.                     MyGlobalPatternSearch($containerBLFile)
  317.                     Sleep(100)
  318.                     MemoWrite(@CRLF & "File Path:" & @CRLF & "" & @CRLF & $containerBLFile & @CRLF & "" & @CRLF & "")
  319.                     Sleep(100)
  320.                     MyGlobalPatternPatch($containerBLFile, $aOutHexGlobalArray)
  321.                     Sleep(500)
  322.                 EndIf
  323.                 ProgressWrite(0)
  324.                 If FileExists("C:\Program Files\Common Files\Adobe\Adobe Desktop Common\ADS\Adobe Desktop Service.exe") Then
  325.                     $adobeDesktopServiceFile = "C:\Program Files\Common Files\Adobe\Adobe Desktop Common\ADS\Adobe Desktop Service.exe"
  326.                 ElseIf FileExists("C:\Program Files (x86)\Common Files\Adobe\Adobe Desktop Common\ADS\Adobe Desktop Service.exe") Then
  327.                     $adobeDesktopServiceFile = "C:\Program Files (x86)\Common Files\Adobe\Adobe Desktop Common\ADS\Adobe Desktop Service.exe"
  328.                 Else
  329.                     $adobeDesktopServiceFile = FileOpenDialog("Select a File", @ScriptDir, "Adobe Desktop Service.exe (Adobe Desktop Service.exe)")
  330.                 EndIf
  331.                 If FileExists($adobeDesktopServiceFile) Then
  332.                     MyGlobalPatternSearch($adobeDesktopServiceFile)
  333.                     Sleep(100)
  334.                     MemoWrite(@CRLF & "File Path:" & @CRLF & "" & @CRLF & $adobeDesktopServiceFile & @CRLF & "" & @CRLF & "")
  335.                     Sleep(100)
  336.                     MyGlobalPatternPatch($adobeDesktopServiceFile, $aOutHexGlobalArray)
  337.                     Sleep(500)
  338.                 EndIf
  339.                 ProgressWrite(0)
  340.                 MemoWrite(@CRLF & "All files patched." & @CRLF & "" & @CRLF & "")
  341.             Else
  342.                 ProgressWrite(0)
  343.                 MemoWrite(@CRLF & "Creative Cloud patching aborted due to unsupported architecture." & @CRLF & "" & @CRLF & "")
  344.                 $bFoundCCARM = False
  345.             EndIf
  346.             GUICtrlSetState($idBtnDeselectAll, 64)
  347.             GUICtrlSetState($idBtnBlockPopUp, 64)
  348.             GUICtrlSetState($idListview, 64)
  349.             GUICtrlSetState($idButtonCustomFolder, 64)
  350.             GUICtrlSetState($idButtonSearch, 64)
  351.             GUICtrlSetState($idBtnPatchCC, 64)
  352.  
  353.         Case $idMsg = $idBtnCure
  354.             ToggleLog(0)
  355.             GUICtrlSetState($idListview, 128)
  356.             GUICtrlSetState($idBtnDeselectAll, 128)
  357.             GUICtrlSetState($idButtonSearch, 128)
  358.             GUICtrlSetState($idBtnCure, 128)
  359.             GUICtrlSetState($idBtnBlockPopUp, 128)
  360.             GUICtrlSetState($idBtnRestore, 128)
  361.             GUICtrlSetState($idButtonCustomFolder, 128)
  362.             GUICtrlSetState($idBtnPatchCC, 128)
  363.             _Expand_All_Click()
  364.             _GUICtrlListView_EnsureVisible($idListview, 0, 0)
  365.  
  366.             Local $ItemFromList
  367.             For $i = 0 To _GUICtrlListView_GetItemCount($idListview) - 1
  368.  
  369.                 If _GUICtrlListView_GetItemChecked($idListview, $i) = True Then
  370.  
  371.                     _GUICtrlListView_SetItemSelected($idListview, $i)
  372.                     $ItemFromList = _GUICtrlListView_GetItemText($idListview, $i, 1)
  373.  
  374.                     MyGlobalPatternSearch($ItemFromList)
  375.                     ProgressWrite(0)
  376.                     Sleep(100)
  377.                     MemoWrite(@CRLF & "Path" & @CRLF & "---" & @CRLF & $ItemFromList & @CRLF & "---" & @CRLF & "medication :)")
  378.                     LogWrite(1, $ItemFromList)
  379.                     Sleep(100)
  380.  
  381.                     MyGlobalPatternPatch($ItemFromList, $aOutHexGlobalArray)
  382.  
  383.  
  384.                     ; Scroll control 10 pixels - 1 line
  385.                     _GUICtrlListView_Scroll($idListview, 0, 10)
  386.                     _GUICtrlListView_EnsureVisible($idListview, $i, 0)
  387.                     Sleep(100)
  388.  
  389.                 EndIf
  390.  
  391.                 _GUICtrlListView_SetItemChecked($idListview, $i, False)
  392.             Next
  393.  
  394.             _GUICtrlListView_DeleteAllItems($g_idListview)
  395.             _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER))
  396.  
  397.  
  398.             _GUICtrlListView_RemoveAllGroups($idListview)
  399.             _GUICtrlListView_InsertGroup($idListview, -1, 1, "", 1)    ; Group 1
  400.             _GUICtrlListView_SetGroupInfo($idListview, 1, "Info", 1, $LVGS_COLLAPSIBLE)
  401.  
  402.             MemoWrite(@CRLF & "Path" & @CRLF & "---" & @CRLF & $MyDefPath & @CRLF & "---" & @CRLF & "waiting for user action")
  403.             GUICtrlSetState($idListview, 64)
  404.             GUICtrlSetState($idButtonSearch, 64)
  405.             GUICtrlSetState($idButtonCustomFolder, 64)
  406.             GUICtrlSetState($idBtnBlockPopUp, 64)
  407.             GUICtrlSetState($idBtnBlockPopUp, $GUI_SHOW)
  408.             GUICtrlSetState($idBtnRestore, $GUI_HIDE)
  409.             GUICtrlSetState($idBtnCure, 128)
  410.             GUICtrlSetState($idButtonSearch, 256)     ; Set focus
  411.             GUICtrlSetState($idBtnPatchCC, 64)
  412.             FillListViewWithInfo()
  413.  
  414.             If $bFoundAcro32 = True Then
  415.                 MsgBox($MB_SYSTEMMODAL, "Information", "GenP does not patch the x86 version of Acrobat. Please use the x64 version of Acrobat.")
  416.                 LogWrite(1, "GenP does not patch the x86 version of Acrobat. Please use the x64 version of Acrobat.")
  417.             EndIf
  418.  
  419.             If $bFoundLrARM = True Then
  420.                 MsgBox($MB_SYSTEMMODAL, "Information", "GenP does not patch the ARM version of Lightroom. Please use the x64 version of Lightroom.")
  421.                 LogWrite(1, "GenP does not patch the ARM version of Lightroom. Please use the x64 version of Lightroom.")
  422.             EndIf
  423.  
  424.             If $bFoundPsARM = True Then
  425.                 MsgBox($MB_SYSTEMMODAL, "Information", "GenP does not patch the ARM version of Photoshop. Please use the x64 version of Photoshop.")
  426.                 LogWrite(1, "GenP does not patch the ARM version of Photoshop. Please use the x64 version of Photoshop.")
  427.             EndIf
  428.  
  429.             If $bFoundGenericARM = True Then
  430.                 MsgBox($MB_SYSTEMMODAL, "Information", "GenP cannot patch files with ARM architecture.")
  431.                 LogWrite(1, "GenP cannot patch files with ARM architecture.")
  432.             EndIf
  433.  
  434.             ToggleLog(1)
  435.  
  436.             GUICtrlSetState($hLogTab, $GUI_SHOW)
  437.  
  438.         Case $idMsg = $idBtnRestore
  439.             GUICtrlSetData($idLog, "Activity Log" & @CRLF)
  440.             ToggleLog(0)
  441.             GUICtrlSetState($idListview, 128)
  442.             GUICtrlSetState($idBtnDeselectAll, 128)
  443.             GUICtrlSetState($idButtonSearch, 128)
  444.             GUICtrlSetState($idBtnCure, 128)
  445.             GUICtrlSetState($idBtnBlockPopUp, 128)
  446.             GUICtrlSetState($idBtnRestore, 128)
  447.             GUICtrlSetState($idButtonCustomFolder, 128)
  448.             GUICtrlSetState($idBtnPatchCC, 128)
  449.             _Expand_All_Click()
  450.             _GUICtrlListView_EnsureVisible($idListview, 0, 0)
  451.  
  452.             Local $ItemFromList, $iCheckedItems, $iProgress
  453.             For $i = 0 To _GUICtrlListView_GetItemCount($idListview) - 1
  454.  
  455.                 If _GUICtrlListView_GetItemChecked($idListview, $i) = True Then
  456.  
  457.                     _GUICtrlListView_SetItemSelected($idListview, $i)
  458.  
  459.                     $ItemFromList = _GUICtrlListView_GetItemText($idListview, $i, 1)
  460.                     $iCheckedItems = _GUICtrlListView_GetSelectedCount($idListview)
  461.                     $iProgress = 100 / $iCheckedItems
  462.                     ProgressWrite(0)
  463.                     RestoreFile($ItemFromList)
  464.  
  465.                     ProgressWrite($iProgress)
  466.                     Sleep(100)
  467.                     MemoWrite(@CRLF & "Path" & @CRLF & "---" & @CRLF & $ItemFromList & @CRLF & "---" & @CRLF & "restoring :)")
  468.                     Sleep(100)
  469.  
  470.                     ; Scroll control 10 pixels - 1 line
  471.                     _GUICtrlListView_Scroll($idListview, 0, 10)
  472.                     _GUICtrlListView_EnsureVisible($idListview, $i, 0)
  473.                     Sleep(100)
  474.  
  475.                 EndIf
  476.  
  477.                 _GUICtrlListView_SetItemChecked($idListview, $i, False)
  478.             Next
  479.  
  480.             _GUICtrlListView_DeleteAllItems($g_idListview)
  481.             _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER))
  482.  
  483.             _GUICtrlListView_RemoveAllGroups($idListview)
  484.             _GUICtrlListView_InsertGroup($idListview, -1, 1, "", 1)    ; Group 1
  485.             _GUICtrlListView_SetGroupInfo($idListview, 1, "Info", 1, $LVGS_COLLAPSIBLE)
  486.  
  487.             MemoWrite(@CRLF & "Path" & @CRLF & "---" & @CRLF & $MyDefPath & @CRLF & "---" & @CRLF & "waiting for user action")
  488.             GUICtrlSetState($idListview, 64)
  489.             GUICtrlSetState($idButtonCustomFolder, 64)
  490.             GUICtrlSetState($idBtnBlockPopUp, 64)
  491.             GUICtrlSetState($idBtnBlockPopUp, $GUI_SHOW)
  492.             GUICtrlSetState($idBtnRestore, $GUI_HIDE)
  493.             GUICtrlSetState($idBtnRestore, 64)
  494.             GUICtrlSetState($idBtnCure, 128)
  495.             GUICtrlSetState($idButtonSearch, 64)
  496.             GUICtrlSetState($idButtonSearch, 256)     ; Set focus
  497.             GUICtrlSetState($idBtnPatchCC, 64)
  498.             FillListViewWithInfo()
  499.  
  500.             ToggleLog(1)
  501.  
  502.         Case $idMsg = $idBtnCopyLog
  503.             SendToClipBoard()
  504.  
  505.     EndSelect
  506. WEnd
  507.  
  508.  
  509. Func MainGui()
  510.     $MyhGUI = GUICreate($g_AppWndTitle, 595, 710, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX, $GUI_SS_DEFAULT_GUI))
  511.     $hTab = GUICtrlCreateTab(0, 1, 597, 710)
  512.  
  513.     $hMainTab = GUICtrlCreateTabItem("Main")
  514.     $idListview = GUICtrlCreateListView("", 10, 35, 575, 555)
  515.     GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
  516.     $g_idListview = GUICtrlGetHandle($idListview) ; get the handle for use in the notify events
  517.     _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER, $LVS_EX_CHECKBOXES))
  518.     $iStyles = _WinAPI_GetWindowLong($MyhGUI, $GWL_STYLE)
  519.     _WinAPI_SetWindowLong($MyhGUI, $GWL_STYLE, BitXOR($iStyles, $WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX))
  520.  
  521.     ; Add columns
  522.     _GUICtrlListView_SetItemCount($idListview, UBound($FilesToPatch))
  523.     _GUICtrlListView_AddColumn($idListview, "", 20)
  524.     _GUICtrlListView_AddColumn($idListview, "", 532, 2)
  525.  
  526.     ; Build groups
  527.     _GUICtrlListView_EnableGroupView($idListview)
  528.     _GUICtrlListView_InsertGroup($idListview, -1, 1, "", 1) ; Group 1
  529.     _GUICtrlListView_SetGroupInfo($idListview, 1, "Info", 1, $LVGS_COLLAPSIBLE)
  530.  
  531.     FillListViewWithInfo()
  532.  
  533.     $idButtonCustomFolder = GUICtrlCreateButton("Path", 10, 630, 80, 30)
  534.     GUICtrlSetTip(-1, "Select Path that You want -> press Search -> press Patch button")
  535.     GUICtrlSetImage(-1, "imageres.dll", -4, 0)
  536.     GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
  537.  
  538.     $idButtonSearch = GUICtrlCreateButton("Search", 110, 630, 80, 30)
  539.     GUICtrlSetTip(-1, "Let GenP find Apps automatically in current path")
  540.     GUICtrlSetImage(-1, "imageres.dll", -8, 0)
  541.     GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
  542.  
  543.     $idButtonStop = GUICtrlCreateButton("Stop", 110, 630, 80, 30)
  544.     GUICtrlSetState(-1, $GUI_HIDE)
  545.     GUICtrlSetTip(-1, "Stop searching for Apps")
  546.     GUICtrlSetImage(-1, "imageres.dll", -8, 0)
  547.     GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
  548.  
  549.     $idBtnDeselectAll = GUICtrlCreateButton("De/Select", 210, 630, 80, 30)
  550.     GUICtrlSetState(-1, $GUI_DISABLE)
  551.     GUICtrlSetTip(-1, "De/Select All files")
  552.     GUICtrlSetImage(-1, "imageres.dll", -76, 0)
  553.     GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
  554.  
  555.     $idBtnCure = GUICtrlCreateButton("Patch", 305, 630, 80, 30)
  556.     GUICtrlSetState(-1, $GUI_DISABLE)
  557.     GUICtrlSetTip(-1, "Patch all selected files")
  558.     GUICtrlSetImage(-1, "imageres.dll", -102, 0)
  559.     GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
  560.  
  561.     $idBtnBlockPopUp = GUICtrlCreateButton("Pop-up", 405, 630, 80, 30)
  562.     GUICtrlSetTip(-1, "Block Unlicensed Pop-up via Windows Firewall")
  563.     GUICtrlSetImage(-1, "imageres.dll", -101, 0)
  564.     GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
  565.  
  566.     $idBtnRestore = GUICtrlCreateButton("Restore", 405, 630, 80, 30)
  567.     GUICtrlSetState(-1, $GUI_HIDE)
  568.     GUICtrlSetTip(-1, "Restore Original Files")
  569.     GUICtrlSetImage(-1, "imageres.dll", -113, 0)
  570.     GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
  571.  
  572.     $idBtnPatchCC = GUICtrlCreateButton("Patch CC", 505, 630, 80, 30)
  573.     GUICtrlSetImage(-1, "imageres.dll", -74, 0)
  574.     GUICtrlSetTip(-1, "Patch Creative Cloud")
  575.     GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
  576.  
  577.     $idProgressBar = GUICtrlCreateProgress(10, 597, 575, 25, $PBS_SMOOTHREVERSE)
  578.     GUICtrlSetResizing(-1, $GUI_DOCKVCENTER)
  579.  
  580.     GUICtrlCreateLabel($g_AppVersion, 10, 677, 575, 25, $ES_CENTER)
  581.     GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM)
  582.     GUICtrlCreateTabItem("")
  583.  
  584.     $hLogTab = GUICtrlCreateTabItem("Log")
  585.     $idMemo = GUICtrlCreateEdit("", 10, 35, 575, 555, BitOR($ES_READONLY, $ES_CENTER, $WS_DISABLED))
  586.     GUICtrlSetResizing(-1, $GUI_DOCKVCENTER)
  587.  
  588.     $idLog = GUICtrlCreateEdit("", 10, 35, 575, 555, BitOR($WS_VSCROLL, $ES_AUTOVSCROLL, $ES_READONLY))
  589.     GUICtrlSetResizing(-1, $GUI_DOCKVCENTER)
  590.     GUICtrlSetState($idLog, $GUI_HIDE)
  591.     GUICtrlSetData($idLog, "Activity Log" & @CRLF)
  592.  
  593.     $idBtnCopyLog = GUICtrlCreateButton("Copy", 257, 630, 80, 30)
  594.     GUICtrlSetTip(-1, "Copy log to the clipboard")
  595.     GUICtrlSetImage(-1, "imageres.dll", -77, 0)
  596.     GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
  597.  
  598.     GUICtrlCreateLabel($g_AppVersion, 10, 677, 575, 25, $ES_CENTER)
  599.     GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM)
  600.     GUICtrlCreateTabItem("")
  601.  
  602.     MemoWrite(@CRLF & "Path" & @CRLF & "---" & @CRLF & $MyDefPath & @CRLF & "---" & @CRLF & "Waiting for user action.")
  603.  
  604.     GUICtrlSetState($idButtonSearch, 256) ; Set focus
  605.     GUISetState(@SW_SHOW)
  606.  
  607.     GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
  608. EndFunc   ;==>MainGui
  609.  
  610. Func RecursiveFileSearch($INSTARTDIR, $DEPTH, $FileCount)
  611.     ;_FileListToArrayEx
  612.     _GUICtrlListView_SetItemText($idListview, 1, "Searching for files.", 1)
  613.     ;_GUICtrlListView_SetItemGroupID($idListview, 0, 1)
  614.  
  615.     Local $RecursiveFileSearch_MaxDeep = 6
  616.     ; Local $RecursiveFileSearch_WhenFoundRaiseToLevel = 0 ;0 to disable raising
  617.     If $DEPTH > $RecursiveFileSearch_MaxDeep Then Return
  618.  
  619.     Local $STARTDIR = $INSTARTDIR & "\"
  620.     $FileSearchedCount += 1
  621.  
  622.     Local $HSEARCH = FileFindFirstFile($STARTDIR & "*.*")
  623.     If @error Then Return
  624.  
  625.     Local $NEXT, $IPATH, $isDir
  626.  
  627.     While $fInterrupt = 0
  628.  
  629.         $NEXT = FileFindNextFile($HSEARCH)
  630.         $FileSearchedCount += 1
  631.  
  632.         If @error Then ExitLoop
  633.         $isDir = StringInStr(FileGetAttrib($STARTDIR & $NEXT), "D")
  634.  
  635.         If $isDir Then
  636.             Local $targetDepth
  637.             $targetDepth = RecursiveFileSearch($STARTDIR & $NEXT, $DEPTH + 1, $FileCount)
  638.             ; raise up in recursion to wanted level
  639. ;~          if ( $targetDepth > 0 ) and _
  640. ;~           ( $targetDepth < $DEPTH ) Then _
  641. ;~              Return $targetDepth
  642.         Else
  643.             $IPATH = $STARTDIR & $NEXT
  644.             Local $FileNameCropped
  645.             If (IsArray($TargetFileList_Adobe)) Then
  646.                 For $AdobeFileTarget In $TargetFileList_Adobe
  647.                     $FileNameCropped = StringSplit(StringLower($IPATH), StringLower($AdobeFileTarget), $STR_ENTIRESPLIT)
  648.                     If @error <> 1 Then
  649.                         If Not StringInStr($IPATH, ".bak") Then
  650.                             ;_ArrayAdd( $FilesToPatch, $DEPTH & " - " & $IPATH )
  651.                             If StringInStr($IPATH, "Adobe") Or StringInStr($IPATH, "Acrobat") Then
  652.                                 If StringInStr($IPATH, "4.js") And Not StringInStr($IPATH, "UXP\com.adobe.ccx.start\js\4.js") Then
  653.                                     Return
  654.                                 EndIf
  655.                                 If StringInStr($IPATH, "manifest.json") And Not StringInStr($IPATH, "UXP\com.adobe.ccx.start\manifest.json") Then
  656.                                     Return
  657.                                 EndIf
  658.                                 _ArrayAdd($FilesToPatch, $IPATH)
  659.                             EndIf
  660.                         Else
  661.                             _ArrayAdd($FilesToRestore, $IPATH)
  662.                         EndIf
  663.  
  664.                         ; File Found and stored - Quit search in current dir
  665. ;~                  return $RecursiveFileSearch_WhenFoundRaiseToLevel
  666.                     EndIf
  667.                 Next
  668.             EndIf
  669.         EndIf
  670.     WEnd
  671.  
  672.     ;Lazy screenupdates
  673.     If 1 = Random(0, 10, 1) Then
  674.         MemoWrite(@CRLF & "Searching in " & $FileCount & " files" & @TAB & @TAB & "Found : " & UBound($FilesToPatch) & @CRLF & _
  675.                 "---" & @CRLF & _
  676.                 "Level: " & $DEPTH & " Time elapsed : " & Round(TimerDiff($timestamp) / 1000, 0) & " second(s)" & @TAB & @TAB & "Excluded because of *.bak: " & UBound($FilesToRestore) & @CRLF & _
  677.                 "---" & @CRLF & _
  678.                 $INSTARTDIR _
  679.                 )
  680.         ProgressWrite($ProgressFileCountScale * $FileSearchedCount)
  681.     EndIf
  682.  
  683.     FileClose($HSEARCH)
  684. EndFunc   ;==>RecursiveFileSearch
  685.  
  686. Func FillListViewWithInfo()
  687.  
  688.     _GUICtrlListView_DeleteAllItems($g_idListview)
  689.     _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER))
  690.  
  691.     _Expand_All_Click()
  692.     _GUICtrlListView_SetGroupInfo($idListview, 1, "Info", 1, $LVGS_COLLAPSIBLE)
  693.  
  694.     ; Add items
  695.     For $i = 0 To 17
  696.         _GUICtrlListView_AddItem($idListview, "", $i)
  697.         _GUICtrlListView_SetItemGroupID($idListview, $i, 1)
  698.     Next
  699.  
  700.     _GUICtrlListView_AddSubItem($idListview, 0, "", 1)
  701.     _GUICtrlListView_AddSubItem($idListview, 1, "To patch all apps in the default location:", 1)
  702.     _GUICtrlListView_AddSubItem($idListview, 2, "Press 'Search Files', then press 'Patch Files'.", 1)
  703.     _GUICtrlListView_AddSubItem($idListview, 3, "Default path - C:\Program Files\Adobe", 1)
  704.     _GUICtrlListView_AddSubItem($idListview, 4, '-------------------------------------------------------------', 1)
  705.     _GUICtrlListView_AddSubItem($idListview, 5, "To patch Creative Cloud, press 'Patch CC'.", 1)
  706.     _GUICtrlListView_AddSubItem($idListview, 6, '-------------------------------------------------------------', 1)
  707.     _GUICtrlListView_AddSubItem($idListview, 7, "After searching, some products may already be patched.", 1)
  708.     _GUICtrlListView_AddSubItem($idListview, 8, "To select/deselect products to patch, LEFT CLICK on the product group.", 1)
  709.     _GUICtrlListView_AddSubItem($idListview, 9, "To select/deselect individual files, RIGHT CLICK on the file.", 1)
  710.     _GUICtrlListView_AddSubItem($idListview, 10, "Auditon may require a clean re-install when updating to a newer release.", 1)
  711.     _GUICtrlListView_AddSubItem($idListview, 11, '-------------------------------------------------------------', 1)
  712.     _GUICtrlListView_AddSubItem($idListview, 12, "What's new in GenP:", 1)
  713.     _GUICtrlListView_AddSubItem($idListview, 13, "Added Character Animator (Beta) support.", 1)
  714.     _GUICtrlListView_AddSubItem($idListview, 14, "Fixed issues with TrustedInstaller elevation and 32-bit Creative Cloud installations.", 1)
  715.     _GUICtrlListView_AddSubItem($idListview, 15, "Added Hosts file backup and prevented it from being overwritten.", 1)
  716.     _GUICtrlListView_AddSubItem($idListview, 16, "Removed support for all Maxon products due to compatibility reasons.", 1)
  717.     _GUICtrlListView_AddSubItem($idListview, 17, "You should OPTIONALLY remove any old GenP/Adobe entries within your Hosts file for this update.", 1)
  718.  
  719.     $fFilesListed = 0
  720.  
  721. EndFunc   ;==>FillListViewWithInfo
  722.  
  723. Func FillListViewWithFiles()
  724.  
  725.     _GUICtrlListView_DeleteAllItems($g_idListview)
  726.     _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER, $LVS_EX_CHECKBOXES))
  727.  
  728.     ; Two column load
  729.     If UBound($FilesToPatch) > 0 Then
  730.         Global $aItems[UBound($FilesToPatch)][2]
  731.         For $i = 0 To UBound($aItems) - 1
  732.             $aItems[$i][0] = $i
  733.             $aItems[$i][1] = $FilesToPatch[$i][0]
  734.  
  735.         Next
  736.         _GUICtrlListView_AddArray($idListview, $aItems)
  737.  
  738.         MemoWrite(@CRLF & UBound($FilesToPatch) & " File(s) were found in " & Round(TimerDiff($timestamp) / 1000, 0) & " second(s) at:" & @CRLF & "---" & @CRLF & $MyDefPath & @CRLF & "---" & @CRLF & "Press the 'Patch Files'")
  739.         LogWrite(1, UBound($FilesToPatch) & " File(s) were found in " & Round(TimerDiff($timestamp) / 1000, 0) & " second(s)" & @CRLF)
  740.         ;_ArrayDisplay($FilesToPatch)
  741.         $fFilesListed = 1
  742.     Else
  743.         MemoWrite(@CRLF & "Nothing was found in" & @CRLF & "---" & @CRLF & $MyDefPath & @CRLF & "---" & @CRLF & "waiting for user action")
  744.         LogWrite(1, "Nothing was found in " & $MyDefPath)
  745.         $fFilesListed = 0
  746.     EndIf
  747.  
  748. EndFunc   ;==>FillListViewWithFiles
  749.  
  750. ; Write a line to the memo control
  751. Func MemoWrite($sMessage)
  752.     GUICtrlSetData($idMemo, $sMessage)
  753. EndFunc   ;==>MemoWrite
  754.  
  755. Func LogWrite($bTS, $sMessage)
  756.     GUICtrlSetDataEx($idLog, $sMessage, $bTS)
  757. EndFunc   ;==>LogWrite
  758.  
  759. Func ToggleLog($bShow)
  760.     If $bShow = 1 Then
  761.         GUICtrlSetState($idMemo, $GUI_HIDE)
  762.         GUICtrlSetState($idLog, $GUI_SHOW)
  763.     Else
  764.         GUICtrlSetState($idLog, $GUI_HIDE)
  765.         GUICtrlSetState($idMemo, $GUI_SHOW)
  766.     EndIf
  767. EndFunc   ;==>ToggleLog
  768.  
  769. Func SendToClipBoard()
  770.     If BitAND(GUICtrlGetState($idMemo), $GUI_HIDE) = $GUI_HIDE Then
  771.         ClipPut(GUICtrlRead($idLog))
  772.     Else
  773.         ClipPut(GUICtrlRead($idMemo))
  774.     EndIf
  775. EndFunc   ;==>SendToClipBoard
  776.  
  777. Func GUICtrlSetDataEx($hWnd, $sText, $bTS)
  778.     If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  779.     Local $iLength = DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $hWnd, "uint", 0x000E, "wparam", 0, "lparam", 0)
  780.     DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $hWnd, "uint", 0xB1, "wparam", $iLength[0], "lparam", $iLength[0]) ; $EM_SETSEL
  781.     If $bTS = 1 Then
  782.         Local $iData = @CRLF & @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & "." & @MSEC & " " & $sText
  783.     Else
  784.         Local $iData = $sText
  785.     EndIf
  786.     DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $hWnd, "uint", 0xC2, "wparam", True, "wstr", $iData) ; $EM_REPLACESEL
  787. EndFunc   ;==>GUICtrlSetDataEx
  788.  
  789. ; Send a message to the Progress control
  790. Func ProgressWrite($msg_Progress)
  791.     ;_SendMessage($hWnd_Progress, $PBM_SETPOS, $msg_Progress)
  792.     GUICtrlSetData($idProgressBar, $msg_Progress)
  793. EndFunc   ;==>ProgressWrite
  794.  
  795.  
  796. Func MyFileOpenDialog()
  797.     ; Create a constant variable in Local scope of the message to display in FileOpenDialog.
  798.     Local Const $sMessage = "Select a Path"
  799.  
  800.     ; Display an open dialog to select a file.
  801.     FileSetAttrib("C:\Program Files\WindowsApps", "-H")
  802.     Local $MyTempPath = FileSelectFolder($sMessage, $MyDefPath, 0, $MyDefPath, $MyhGUI)
  803.  
  804.  
  805.     If @error Then
  806.         ; Display the error message.
  807.         ;MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.")
  808.         FileSetAttrib("C:\Program Files\WindowsApps", "+H")
  809.         MemoWrite(@CRLF & "Path" & @CRLF & "---" & @CRLF & $MyDefPath & @CRLF & "---" & @CRLF & "waiting for user action")
  810.  
  811.     Else
  812.         GUICtrlSetState($idBtnCure, 128)
  813.         $MyDefPath = $MyTempPath
  814.         IniWrite($sINIPath, "Default", "Path", $MyDefPath)
  815.         _GUICtrlListView_DeleteAllItems($g_idListview)
  816.         _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
  817.         _GUICtrlListView_AddItem($idListview, "", 0)
  818.         _GUICtrlListView_AddItem($idListview, "", 1)
  819.         _GUICtrlListView_AddItem($idListview, "", 2)
  820.         _GUICtrlListView_AddItem($idListview, "", 3)
  821.         _GUICtrlListView_AddItem($idListview, "", 4)
  822.         _GUICtrlListView_AddItem($idListview, "", 5)
  823.         _GUICtrlListView_AddItem($idListview, "", 6)
  824.         _GUICtrlListView_AddSubItem($idListview, 0, "", 1)
  825.         _GUICtrlListView_AddSubItem($idListview, 1, "Path:", 1)
  826.         _GUICtrlListView_AddSubItem($idListview, 2, " " & $MyDefPath, 1)
  827.         _GUICtrlListView_AddSubItem($idListview, 3, "Step 1:", 1)
  828.         _GUICtrlListView_AddSubItem($idListview, 4, " Press 'Search Files' - wait until GenP finds all files", 1)
  829.         _GUICtrlListView_AddSubItem($idListview, 5, "Step 2:", 1)
  830.         _GUICtrlListView_AddSubItem($idListview, 6, " Press 'Patch Files' - wait until GenP will do it's job", 1)
  831.         _GUICtrlListView_SetItemGroupID($idListview, 0, 1)
  832.         _GUICtrlListView_SetItemGroupID($idListview, 1, 1)
  833.         _GUICtrlListView_SetItemGroupID($idListview, 2, 1)
  834.         _GUICtrlListView_SetItemGroupID($idListview, 3, 1)
  835.         _GUICtrlListView_SetItemGroupID($idListview, 4, 1)
  836.         _GUICtrlListView_SetItemGroupID($idListview, 5, 1)
  837.         _GUICtrlListView_SetItemGroupID($idListview, 6, 1)
  838.         _GUICtrlListView_SetGroupInfo($idListview, 1, "Info", 1, $LVGS_COLLAPSIBLE)
  839.  
  840.         FileSetAttrib("C:\Program Files\WindowsApps", "+H")
  841.         MemoWrite(@CRLF & "Path" & @CRLF & "---" & @CRLF & $MyDefPath & @CRLF & "---" & @CRLF & "Press the Search button")
  842.         ; Display the selected folder.
  843.         ;MsgBox($MB_SYSTEMMODAL, "", "You chose the following folder:" & @CRLF & $MyDefPath)
  844.         GUICtrlSetState($idBtnBlockPopUp, $GUI_SHOW)
  845.         GUICtrlSetState($idBtnRestore, $GUI_HIDE)
  846.         $fFilesListed = 0
  847.  
  848.     EndIf
  849.  
  850. EndFunc   ;==>MyFileOpenDialog
  851.  
  852.  
  853. Func _ProcessCloseEx($sName)
  854.     Local $iPID = Run("TASKKILL /F /T /IM " & $sName, @TempDir, @SW_HIDE)
  855.     ProcessWaitClose($iPID)
  856. EndFunc   ;==>_ProcessCloseEx
  857.  
  858.  
  859. Func MyGlobalPatternSearch($MyFileToParse)
  860.     ;ConsoleWrite($MyFileToParse & @CRLF)
  861.     $aInHexArray = $aNullArray   ; Nullifay Array that will contain Hex later
  862.     $aOutHexGlobalArray = $aNullArray     ; Nullifay Array that will contain Hex later
  863.  
  864.     ProgressWrite(0)
  865.     $MyRegExpGlobalPatternSearchCount = 0
  866.     $Count = 15
  867.  
  868.     Local $sFileName = StringRegExpReplace($MyFileToParse, "^.*\\", "")
  869.     Local $sExt = StringRegExpReplace($sFileName, "^.*\.", "")
  870.  
  871.     MemoWrite(@CRLF & $MyFileToParse & @CRLF & "---" & @CRLF & "Preparing to Analyze" & @CRLF & "---" & @CRLF & "*****")
  872.     LogWrite(1, "Checking File: " & $sFileName & " ")
  873.     ;MsgBox($MB_SYSTEMMODAL,"","$sFileName = " & $sFileName & @CRLF & "$sExt = " & $sExt)
  874.  
  875.     If $sExt = "exe" Then
  876.         _ProcessCloseEx("""" & $sFileName & """")
  877.     EndIf
  878.  
  879.     If $sFileName = "AppsPanelBL.dll" Or $sFileName = "ContainerBL.dll" Or $sFileName = "Adobe Desktop Service.exe" Then
  880.         _ProcessCloseEx("""Creative Cloud.exe""")
  881.         _ProcessCloseEx("""Adobe Desktop Service.exe""")
  882.         Sleep(100)
  883.     EndIf
  884.  
  885.     If StringInStr($sSpecialFiles, $sFileName) Then
  886.         ;MsgBox($MB_SYSTEMMODAL, "", "Special File: " & $sFileName)
  887.         LogWrite(0, " - using Custom Patterns")
  888.         ExecuteSearchPatterns($sFileName, 0, $MyFileToParse)
  889.     Else
  890.         LogWrite(0, " - using Default Patterns")
  891.         ExecuteSearchPatterns($sFileName, 1, $MyFileToParse)
  892.         ;MsgBox($MB_SYSTEMMODAL, "", "File: " & $sFileName & @CRLF & "Not in Special Files")
  893.     EndIf
  894.     Sleep(100)
  895. EndFunc   ;==>MyGlobalPatternSearch
  896.  
  897. Func ExecuteSearchPatterns($FileName, $DefaultPatterns, $MyFileToParse)
  898.  
  899.     Local $aPatterns, $sPattern, $sData, $aArray, $sSearch, $sReplace, $iPatternLength
  900.  
  901.     If $DefaultPatterns = 0 Then
  902.         $aPatterns = IniReadArray($sINIPath, "CustomPatterns", $FileName, "")
  903.     Else
  904.         $aPatterns = IniReadArray($sINIPath, "DefaultPatterns", "Values", "")
  905.     EndIf
  906.  
  907.     ;_ArrayDisplay($aPatterns, "Patterns for " & $FileName)
  908.  
  909.     For $i = 0 To UBound($aPatterns) - 1
  910.         $sPattern = $aPatterns[$i]
  911.         $sData = IniRead($sINIPath, "Patches", $sPattern, "")
  912.         If StringInStr($sData, "|") Then
  913.             $aArray = StringSplit($sData, "|")
  914.             If UBound($aArray) = 3 Then
  915.  
  916.                 $sSearch = StringReplace($aArray[1], '"', '')
  917.                 $sReplace = StringReplace($aArray[2], '"', '')
  918.  
  919.                 $iPatternLength = StringLen($sSearch)
  920.                 If $iPatternLength <> StringLen($sReplace) Or Mod($iPatternLength, 2) <> 0 Then
  921.                     MsgBox($MB_SYSTEMMODAL, "Error", "Pattern Error in config.ini:" & $sPattern & @CRLF & $sSearch & @CRLF & $sReplace)
  922.                     Exit
  923.                 EndIf
  924.  
  925.                 ;MsgBox(0,0, $MyFileToParse & @CRLF & $sSearch & @CRLF  & $aReplace & @CRLF  & $sPattern )
  926.                 LogWrite(1, "Searching for: " & $sPattern & ": " & $sSearch)
  927.  
  928.                 MyRegExpGlobalPatternSearch($MyFileToParse, $sSearch, $sReplace, $sPattern)
  929.  
  930.                 ;Exit ; STOP AT FIRST VALUE - COMMENT OUT TO CONTINUE
  931.             EndIf
  932.             ;Exit
  933.         EndIf
  934.  
  935.     Next
  936.  
  937. EndFunc   ;==>ExecuteSearchPatterns
  938.  
  939.  
  940. Func MyRegExpGlobalPatternSearch($FileToParse, $PatternToSearch, $PatternToReplace, $PatternName)  ; Path to a file to parse
  941.     ;MsgBox($MB_SYSTEMMODAL, "Path", $FileToParse)
  942.     ;ConsoleWrite($FileToParse & @CRLF)
  943.     Local $hFileOpen = FileOpen($FileToParse, $FO_READ + $FO_BINARY)
  944.  
  945.     FileSetPos($hFileOpen, 60, 0)
  946.  
  947.     $sz_type = FileRead($hFileOpen, 4)
  948.     FileSetPos($hFileOpen, Number($sz_type) + 4, 0)
  949.  
  950.     $sz_type = FileRead($hFileOpen, 2)
  951.  
  952.     If $sz_type = "0x4C01" And StringInStr($FileToParse, "Acrobat", 2) > 0 Then ; Acrobat x86 won't work with this script
  953.  
  954.         MemoWrite(@CRLF & $FileToParse & @CRLF & "---" & @CRLF & "File is 32bit. Aborting..." & @CRLF & "---")
  955.         FileClose($hFileOpen)
  956.         Sleep(100)
  957.         $bFoundAcro32 = True
  958.  
  959.     ElseIf $sz_type = "0x64AA" Then ; AArch64 (ARM64) and ~~AArch32 (ARM32) architectures~~ (big-endian). only exist as photoshop, lightroom, and ccdesktop at time of writing
  960.  
  961.         If StringInStr($FileToParse, "Lightroom", 2) > 0 Then ; Lightroom ARM
  962.             MemoWrite(@CRLF & $FileToParse & @CRLF & "---" & @CRLF & "Lightroom is ARM. Aborting..." & @CRLF & "---")
  963.             FileClose($hFileOpen)
  964.             Sleep(100)
  965.             $bFoundLrARM = True
  966.  
  967.         ElseIf StringInStr($FileToParse, "AppsPanelBL.dll", 2) Or StringInStr($FileToParse, "ContainerBL.dll", 2) Or StringInStr($FileToParse, "Adobe Desktop Service.exe", 2) > 0 Then ; CC Desktop ARM
  968.             MemoWrite(@CRLF & $FileToParse & @CRLF & "---" & @CRLF & "Creative Cloud is ARM. Aborting..." & @CRLF & "---")
  969.             FileClose($hFileOpen)
  970.             Sleep(100)
  971.             $bFoundCCARM = True
  972.  
  973.         ElseIf StringInStr($FileToParse, "Photoshop", 2) > 0 Then ; Photoshop ARM
  974.             MemoWrite(@CRLF & $FileToParse & @CRLF & "---" & @CRLF & "Photoshop is ARM. Aborting..." & @CRLF & "---")
  975.             FileClose($hFileOpen)
  976.             Sleep(100)
  977.             $bFoundPsARM = True
  978.  
  979.         Else ; Other ARM
  980.             MemoWrite(@CRLF & $FileToParse & @CRLF & "---" & @CRLF & "File is ARM. Aborting..." & @CRLF & "---")
  981.             FileClose($hFileOpen)
  982.             Sleep(100)
  983.             $bFoundGenericARM = True
  984.  
  985.         EndIf
  986.  
  987.     Else
  988.  
  989.         FileSetPos($hFileOpen, 0, 0)
  990.  
  991.         Local $sFileRead = FileRead($hFileOpen)
  992.  
  993.         Local $GeneQuestionMark, $AnyNumOfBytes, $OutStringForRegExp
  994.         For $i = 256 To 1 Step -2 ; limiting to 256 -?-
  995.             $GeneQuestionMark = _StringRepeat("??", $i / 2) ; Repeat the string -??- $i/2 times.
  996.             $AnyNumOfBytes = "(.{" & $i & "})"
  997.             $OutStringForRegExp = StringReplace($PatternToSearch, $GeneQuestionMark, $AnyNumOfBytes)
  998.             $PatternToSearch = $OutStringForRegExp
  999.         Next
  1000.  
  1001.         Local $sSearchPattern = $OutStringForRegExp     ;string
  1002.         Local $aReplacePattern = $PatternToReplace     ;string
  1003.         Local $sWildcardSearchPattern = "", $sWildcardReplacePattern = "", $sFinalReplacePattern = ""
  1004.         Local $aInHexTempArray[0]
  1005.         Local $sSearchCharacter = "", $sReplaceCharacter = ""
  1006.  
  1007.         $aInHexTempArray = $aNullArray
  1008.         $aInHexTempArray = StringRegExp($sFileRead, $sSearchPattern, $STR_REGEXPARRAYGLOBALFULLMATCH, 1)
  1009.  
  1010.         For $i = 0 To UBound($aInHexTempArray) - 1
  1011.  
  1012.             $aInHexArray = $aNullArray
  1013.             $sSearchCharacter = ""
  1014.             $sReplaceCharacter = ""
  1015.             $sWildcardSearchPattern = ""
  1016.             $sWildcardReplacePattern = ""
  1017.             $sFinalReplacePattern = ""
  1018.  
  1019.  
  1020.             $aInHexArray = $aInHexTempArray[$i]
  1021.             ;_ArrayDisplay($aInHexArray)
  1022.  
  1023.             If @error = 0 Then
  1024.                 $sWildcardSearchPattern = $aInHexArray[0]   ; full founded Search Pattern index 0
  1025.                 $sWildcardReplacePattern = $aReplacePattern
  1026.  
  1027.                 ;MsgBox(-1,"",$sWildcardSearchPattern & @CRLF & $sWildcardReplacePattern) ; full search and full patch with ?? symbols
  1028.  
  1029.                 If StringInStr($sWildcardReplacePattern, "?") Then
  1030.                     ;MsgBox($MB_SYSTEMMODAL, "Found ? symbol", "Constructing new Replace string")
  1031.                     For $j = 1 To StringLen($sWildcardReplacePattern) + 1
  1032.                         ; Retrieve a characters from the $jth position in each string.
  1033.                         $sSearchCharacter = StringMid($sWildcardSearchPattern, $j, 1)
  1034.                         $sReplaceCharacter = StringMid($sWildcardReplacePattern, $j, 1)
  1035.  
  1036.                         If $sReplaceCharacter <> "?" Then
  1037.                             $sFinalReplacePattern &= $sReplaceCharacter
  1038.                         Else
  1039.                             $sFinalReplacePattern &= $sSearchCharacter
  1040.                         EndIf
  1041.  
  1042.                     Next
  1043.                 Else
  1044.                     $sFinalReplacePattern = $sWildcardReplacePattern
  1045.                 EndIf
  1046.  
  1047.                 _ArrayAdd($aOutHexGlobalArray, $sWildcardSearchPattern)
  1048.                 _ArrayAdd($aOutHexGlobalArray, $sFinalReplacePattern)
  1049.  
  1050.                 ConsoleWrite($PatternName & "---" & @TAB & $sWildcardSearchPattern & "  " & @CRLF)
  1051.                 ConsoleWrite($PatternName & "R" & "--" & @TAB & $sFinalReplacePattern & "   " & @CRLF)
  1052.                 MemoWrite(@CRLF & $FileToParse & @CRLF & "---" & @CRLF & $PatternName & @CRLF & "---" & @CRLF & $sWildcardSearchPattern & @CRLF & $sFinalReplacePattern)
  1053.                 LogWrite(1, "Replacing with: " & $sFinalReplacePattern)
  1054.  
  1055.             Else
  1056.                 ConsoleWrite($PatternName & "---" & @TAB & "No" & " " & @CRLF)
  1057.                 MemoWrite(@CRLF & $FileToParse & @CRLF & "---" & @CRLF & $PatternName & "---" & "No")
  1058.             EndIf
  1059.             $MyRegExpGlobalPatternSearchCount += 1
  1060.  
  1061.         Next
  1062.         FileClose($hFileOpen)
  1063.         $sFileRead = ""
  1064.         ProgressWrite(Round($MyRegExpGlobalPatternSearchCount / $Count * 100))
  1065.         Sleep(100)
  1066.  
  1067.     EndIf      ;==>If $sz_type = "0x4C01"
  1068.  
  1069. EndFunc   ;==>MyRegExpGlobalPatternSearch
  1070.  
  1071.  
  1072. ;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  1073.  
  1074. Func MyGlobalPatternPatch($MyFileToPatch, $MyArrayToPatch)
  1075.     ;MsgBox($MB_SYSTEMMODAL, "", $MyFileToPatch)
  1076.     ;_ArrayDisplay($MyArrayToPatch)
  1077.     ProgressWrite(0)
  1078.     ;MemoWrite("Current path" & @CRLF & "---" & @CRLF & $MyFileToPatch & @CRLF & "---" & @CRLF & "medication :)")
  1079.     Local $iRows = UBound($MyArrayToPatch) ; Total number of rows
  1080.     If $iRows > 0 Then
  1081.         MemoWrite(@CRLF & "Path" & @CRLF & "---" & @CRLF & $MyFileToPatch & @CRLF & "---" & @CRLF & "medication :)")
  1082.         Local $hFileOpen = FileOpen($MyFileToPatch, $FO_READ + $FO_BINARY)
  1083.         Local $sFileRead = FileRead($hFileOpen)
  1084.         Local $sStringOut
  1085.  
  1086.         For $i = 0 To $iRows - 1 Step 2
  1087.             $sStringOut = StringReplace($sFileRead, $MyArrayToPatch[$i], $MyArrayToPatch[$i + 1], 0, 1)
  1088.             $sFileRead = $sStringOut
  1089.             $sStringOut = $sFileRead
  1090.             ProgressWrite(Round($i / $iRows * 100))
  1091.         Next
  1092.  
  1093.         ;MsgBox($MB_SYSTEMMODAL, "", "binary: " & Binary($sStringOut))
  1094.         FileClose($hFileOpen)
  1095.         FileMove($MyFileToPatch, $MyFileToPatch & ".bak", $FC_OVERWRITE)
  1096.         Local $hFileOpen1 = FileOpen($MyFileToPatch, $FO_OVERWRITE + $FO_BINARY)
  1097.         FileWrite($hFileOpen1, Binary($sStringOut))
  1098.         FileClose($hFileOpen1)
  1099.         ProgressWrite(0)
  1100.         Sleep(100)
  1101.         ;MemoWrite1(@CRLF & "---" & @CRLF & "Waitng for your command :)" & @CRLF & "---")
  1102.  
  1103.         LogWrite(1, "File patched." & @CRLF)
  1104.  
  1105.     Else
  1106.         ;Empty array - > no search-replace patterns
  1107.         ;File is already patched or no patterns were found .
  1108.         MemoWrite(@CRLF & "No patterns were found" & @CRLF & "---" & @CRLF & "or" & @CRLF & "---" & @CRLF & "file is already patched.")
  1109.         Sleep(100)
  1110.  
  1111.         LogWrite(1, "No patterns were found or file already patched." & @CRLF)
  1112.  
  1113.     EndIf
  1114.     ;Sleep(100)
  1115.     ;MemoWrite2("***")
  1116. EndFunc   ;==>MyGlobalPatternPatch
  1117.  
  1118. Func RestoreFile($MyFileToDelete)
  1119.     If FileExists($MyFileToDelete & ".bak") Then
  1120.         FileDelete($MyFileToDelete)
  1121.         FileMove($MyFileToDelete & ".bak", $MyFileToDelete, $FC_OVERWRITE)
  1122.         Sleep(100)
  1123.         MemoWrite(@CRLF & "File restored" & @CRLF & "---" & @CRLF & $MyFileToDelete)
  1124.         LogWrite(1, $MyFileToDelete)
  1125.         LogWrite(1, "File restored.")
  1126.     Else
  1127.         Sleep(100)
  1128.         MemoWrite(@CRLF & "No backup file found" & @CRLF & "---" & @CRLF & $MyFileToDelete)
  1129.         LogWrite(1, $MyFileToDelete)
  1130.         LogWrite(1, "No backup file found.")
  1131.     EndIf
  1132. EndFunc   ;==>RestoreFile
  1133.  
  1134. ;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  1135.  
  1136. Func BlockPopUp()
  1137.     GUICtrlSetState($hLogTab, $GUI_SHOW)
  1138.     GUICtrlSetState($idBtnBlockPopUp, 128)
  1139.     MemoWrite(@CRLF & "Checking for an active internet connection..." & @CRLF & "" & @CRLF & "")
  1140.     Local $sCmdInfo = """C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe"" -Command ""Test-Connection 8.8.8.8 -Count 1 -Quiet"""
  1141.     Local $iPID = Run($sCmdInfo, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD))
  1142.     Local $sOutput = ""
  1143.     While 1
  1144.         $sOutput &= StdoutRead($iPID)
  1145.         If @error Then ExitLoop
  1146.     WEnd
  1147.     ProcessWaitClose($iPID)
  1148.     If StringReplace($sOutput, @CRLF, "") = "True" Then
  1149.         MemoWrite(@CRLF & "Resolving ip-addresses..." & @CRLF & "" & @CRLF & "")
  1150.         $sCmdInfo = """C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe"" -Command ""$currentDate=Get-Date;$ipAddresses=@();try{$SOA=(Resolve-DnsName -Name adobe.io -Type SOA -ErrorAction Stop).PrimaryServer}catch{$SOA=$null};if($SOA){Do{if((New-TimeSpan -Start $currentDate -End (Get-Date)).TotalSeconds -gt 5){if($ipAddresses.Count -eq 0){$ipAddresses+='False'};break};try{$ipAddress=(Resolve-DnsName -Name adobe.io -Server $SOA -ErrorAction Stop).IPAddress}catch{$ipAddress=$null};if($ipAddress){$ipAddresses+=$ipAddress};$ipAddresses=$ipAddresses|Select -Unique|Sort-Object}While($ipAddresses.Count -lt 8)}else{$ipAddresses+='False'};Do{if((New-TimeSpan -Start $currentDate -End (Get-Date)).TotalSeconds -gt 5 -or $ipAddresses[0] -eq 'False'){break};try{$ipAddress=(Resolve-DnsName -Name 3u6k9as4bj.adobestats.io -ErrorAction Stop).IPAddress}catch{$ipAddress=$null};if($ipAddress){$ipAddresses+=$ipAddress};$ipAddresses=$ipAddresses|Select -Unique|Sort-Object}While($ipAddresses.Count -lt 12 -and $ipAddresses[0] -ne 'False');$ipAddresses=$ipAddresses -ne 'False'|Select -Unique|Sort-Object;$ipAddressList=if($ipAddresses.Count -eq 0){'False'}else{$ipAddresses -join ','};$ipAddressList"""
  1151.         $iPID = Run($sCmdInfo, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD))
  1152.         $sOutput = ""
  1153.         While 1
  1154.             $sOutput &= StdoutRead($iPID)
  1155.             If @error Then ExitLoop
  1156.         WEnd
  1157.         ProcessWaitClose($iPID)
  1158.         If StringInStr($sOutput, "False") Then
  1159.             MemoWrite(@CRLF & "Failed to resolve ip-addresses, try using a VPN..." & @CRLF & "" & @CRLF & "")
  1160.             Sleep(2000)
  1161.         Else
  1162.             MemoWrite(@CRLF & "Adding Windows Firewall rule..." & @CRLF & "" & @CRLF & "")
  1163.             $sCmdInfo = "netsh advfirewall firewall delete rule name=""Adobe Unlicensed Pop-up"""
  1164.             $iPID = Run($sCmdInfo, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD))
  1165.             ProcessWaitClose($iPID)
  1166.             $sCmdInfo = "netsh advfirewall firewall add rule name=""Adobe Unlicensed Pop-up"" dir=out action=block remoteip=""" & StringReplace($sOutput, @CRLF, "") & """"
  1167.             $iPID = Run($sCmdInfo, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD))
  1168.             ProcessWaitClose($iPID)
  1169.         EndIf
  1170.         MemoWrite(@CRLF & "Blocking Hosts..." & @CRLF & "" & @CRLF & "")
  1171.         $sCmdInfo = """C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe"" -Command ""try{if(-not([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)){Write-Host 'Script execution failed...';return};$hostsPath='C:\Windows\System32\drivers\etc\hosts';$bakPath=$hostsPath+'.bak';if(-not(Test-Path $bakPath)){Copy-Item -Path $hostsPath -Destination $bakPath};$webContent=(Invoke-RestMethod -Uri 'https://a.dove.isdumb.one/list.txt' -UseBasicParsing).Split($([char]0x0A))|ForEach-Object{ $_.Trim()};$currentHostsContent=Get-Content -Path $hostsPath;$startMarker='# <GenP>';$endMarker='# </GenP>';$blockStart=$currentHostsContent.IndexOf($startMarker);$blockEnd=$currentHostsContent.IndexOf($endMarker);if($blockStart -eq -1 -or $blockEnd -eq -1){$currentHostsContent+=$startMarker;$currentHostsContent+=$endMarker;$blockStart=$currentHostsContent.IndexOf($startMarker);$blockEnd=$currentHostsContent.IndexOf($endMarker)};$newBlock=@($startMarker)+$webContent+$endMarker;$newHostsContent=$currentHostsContent[0..($blockStart-1)]+$newBlock+$currentHostsContent[($blockEnd+1)..$currentHostsContent.Length];Set-Content -Path $hostsPath -Value $newHostsContent;Write-Host 'Script execution complete.'}catch{Write-Host 'Script execution failed...'}"""
  1172.         $iPID = Run($sCmdInfo, "", @SW_HIDE, $STDOUT_CHILD)
  1173.         $sOutput = ""
  1174.         While 1
  1175.             $sLine = StdoutRead($iPID)
  1176.             If @error Then ExitLoop
  1177.             $sOutput &= $sLine
  1178.         WEnd
  1179.         If StringInStr($sOutput, "Script execution complete.") Then
  1180.             MemoWrite(@CRLF & "All Hosts blocked." & @CRLF & "" & @CRLF & "")
  1181.         Else
  1182.             MemoWrite(@CRLF & "Failed to block Hosts, try using a VPN..." & @CRLF & "" & @CRLF & "")
  1183.         EndIf
  1184.     Else
  1185.         MemoWrite(@CRLF & "You are not connected to the internet..." & @CRLF & "" & @CRLF & "")
  1186.         GUICtrlSetState($idBtnBlockPopUp, 64)
  1187.     EndIf
  1188. EndFunc   ;==>BlockPopUp
  1189.  
  1190. ;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  1191.  
  1192. Func _ListView_LeftClick($hListView, $lParam)
  1193.     Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
  1194.     Local $iIndex = DllStructGetData($tInfo, "Index")
  1195.  
  1196.     If $iIndex <> -1 Then
  1197.         Local $iX = DllStructGetData($tInfo, "X")
  1198.         Local $aIconRect = _GUICtrlListView_GetItemRect($hListView, $iIndex, 1)
  1199.         If $iX < $aIconRect[0] And $iX >= 5 Then
  1200.             Return 0
  1201.         Else
  1202.             Local $aHit
  1203.             $aHit = _GUICtrlListView_HitTest($g_idListview)
  1204.             If $aHit[0] <> -1 Then
  1205.                 Local $GroupIdOfHitItem = _GUICtrlListView_GetItemGroupID($idListview, $aHit[0])
  1206.                 If _GUICtrlListView_GetItemChecked($g_idListview, $aHit[0]) = 1 Then
  1207.                     For $i = 0 To _GUICtrlListView_GetItemCount($idListview) - 1
  1208.                         If _GUICtrlListView_GetItemGroupID($idListview, $i) = $GroupIdOfHitItem Then
  1209.                             _GUICtrlListView_SetItemChecked($g_idListview, $i, 0)
  1210.                         EndIf
  1211.                     Next
  1212.                 Else
  1213.                     For $i = 0 To _GUICtrlListView_GetItemCount($idListview) - 1
  1214.                         If _GUICtrlListView_GetItemGroupID($idListview, $i) = $GroupIdOfHitItem Then
  1215.                             _GUICtrlListView_SetItemChecked($g_idListview, $i, 1)
  1216.                         EndIf
  1217.                     Next
  1218.                 EndIf
  1219.                 ;$g_iIndex = $aHit[0]
  1220.             EndIf
  1221.         EndIf
  1222.     EndIf
  1223. EndFunc   ;==>_ListView_LeftClick
  1224.  
  1225.  
  1226. Func _ListView_RightClick()
  1227.     Local $aHit
  1228.     $aHit = _GUICtrlListView_HitTest($g_idListview)
  1229.     If $aHit[0] <> -1 Then
  1230.         If _GUICtrlListView_GetItemChecked($g_idListview, $aHit[0]) = 1 Then
  1231.             _GUICtrlListView_SetItemChecked($g_idListview, $aHit[0], 0)
  1232.         Else
  1233.             _GUICtrlListView_SetItemChecked($g_idListview, $aHit[0], 1)
  1234.         EndIf
  1235.         ;$g_iIndex = $aHit[0]
  1236.     EndIf
  1237. EndFunc   ;==>_ListView_RightClick
  1238.  
  1239. Func _Assign_Groups_To_Found_Files()
  1240.  
  1241.     ;_GUICtrlListView_RemoveAllGroups ( $idListview )
  1242.     Local $MyListItemCount = _GUICtrlListView_GetItemCount($idListview)
  1243.     Local $ItemFromList
  1244.  
  1245.     ;MsgBox(-1,"ItemCount",_GUICtrlListView_GetItemCount($idListview))
  1246.     ;MsgBox(-1,"GroupCount",_GUICtrlListView_GetGroupCount($idListview))
  1247.  
  1248.     For $i = 0 To $MyListItemCount - 1
  1249.         _GUICtrlListView_SetItemChecked($idListview, $i)
  1250.  
  1251.         ; Build groups
  1252.         $ItemFromList = _GUICtrlListView_GetItemText($idListview, $i, 1)
  1253.  
  1254.         Select
  1255.             Case StringInStr($ItemFromList, "Acrobat")
  1256.                 _GUICtrlListView_InsertGroup($idListview, $i, 1, "", 1)
  1257.                 _GUICtrlListView_SetItemGroupID($idListview, $i, 1)
  1258.                 _GUICtrlListView_SetGroupInfo($idListview, 1, "Acrobat", 1, $LVGS_COLLAPSIBLE)
  1259.  
  1260.             Case StringInStr($ItemFromList, "Aero")
  1261.                 _GUICtrlListView_InsertGroup($idListview, $i, 2, "", 1)
  1262.                 _GUICtrlListView_SetItemGroupID($idListview, $i, 2)
  1263.                 _GUICtrlListView_SetGroupInfo($idListview, 2, "Aero", 1, $LVGS_COLLAPSIBLE)
  1264.  
  1265.             Case StringInStr($ItemFromList, "After Effects")
  1266.                 _GUICtrlListView_InsertGroup($idListview, $i, 3, "", 1)
  1267.                 _GUICtrlListView_SetItemGroupID($idListview, $i, 3)
  1268.                 _GUICtrlListView_SetGroupInfo($idListview, 3, "After Effects", 1, $LVGS_COLLAPSIBLE)
  1269.  
  1270.  
  1271.             Case StringInStr($ItemFromList, "Animate")
  1272.                 _GUICtrlListView_InsertGroup($idListview, $i, 4, "", 1)
  1273.                 _GUICtrlListView_SetItemGroupID($idListview, $i, 4)
  1274.                 _GUICtrlListView_SetGroupInfo($idListview, 4, "Animate", 1, $LVGS_COLLAPSIBLE)
  1275.  
  1276.  
  1277.             Case StringInStr($ItemFromList, "Audition")
  1278.                 _GUICtrlListView_InsertGroup($idListview, $i, 5, "", 1)
  1279.                 _GUICtrlListView_SetItemGroupID($idListview, $i, 5)
  1280.                 _GUICtrlListView_SetGroupInfo($idListview, 5, "Audition", 1, $LVGS_COLLAPSIBLE)
  1281.  
  1282.             Case StringInStr($ItemFromList, "Adobe Bridge")
  1283.                 _GUICtrlListView_InsertGroup($idListview, $i, 6, "", 1)
  1284.                 _GUICtrlListView_SetItemGroupID($idListview, $i, 6)
  1285.                 _GUICtrlListView_SetGroupInfo($idListview, 6, "Bridge", 1, $LVGS_COLLAPSIBLE)
  1286.  
  1287.             Case StringInStr($ItemFromList, "Character Animator")
  1288.                 _GUICtrlListView_InsertGroup($idListview, $i, 7, "", 1)
  1289.                 _GUICtrlListView_SetItemGroupID($idListview, $i, 7)
  1290.                 _GUICtrlListView_SetGroupInfo($idListview, 7, "Character Animator", 1, $LVGS_COLLAPSIBLE)
  1291.  
  1292.             Case StringInStr($ItemFromList, "Dimension")
  1293.                 _GUICtrlListView_InsertGroup($idListview, $i, 9, "", 1)
  1294.                 _GUICtrlListView_SetItemGroupID($idListview, $i, 9)
  1295.                 _GUICtrlListView_SetGroupInfo($idListview, 9, "Dimension", 1, $LVGS_COLLAPSIBLE)
  1296.  
  1297.             Case StringInStr($ItemFromList, "Dreamweaver")
  1298.                 _GUICtrlListView_InsertGroup($idListview, $i, 10, "", 1)
  1299.                 _GUICtrlListView_SetItemGroupID($idListview, $i, 10)
  1300.                 _GUICtrlListView_SetGroupInfo($idListview, 10, "Dreamweaver", 1, $LVGS_COLLAPSIBLE)
  1301.  
  1302.             Case StringInStr($ItemFromList, "Illustrator")
  1303.                 _GUICtrlListView_InsertGroup($idListview, $i, 11, "", 1)
  1304.                 _GUICtrlListView_SetItemGroupID($idListview, $i, 11)
  1305.                 _GUICtrlListView_SetGroupInfo($idListview, 11, "Illustrator", 1, $LVGS_COLLAPSIBLE)
  1306.  
  1307.             Case StringInStr($ItemFromList, "InCopy")
  1308.                 _GUICtrlListView_InsertGroup($idListview, $i, 12, "", 1)
  1309.                 _GUICtrlListView_SetItemGroupID($idListview, $i, 12)
  1310.                 _GUICtrlListView_SetGroupInfo($idListview, 12, "InCopy", 1, $LVGS_COLLAPSIBLE)
  1311.  
  1312.             Case StringInStr($ItemFromList, "InDesign")
  1313.                 _GUICtrlListView_InsertGroup($idListview, $i, 13, "", 1)
  1314.                 _GUICtrlListView_SetItemGroupID($idListview, $i, 13)
  1315.                 _GUICtrlListView_SetGroupInfo($idListview, 13, "InDesign", 1, $LVGS_COLLAPSIBLE)
  1316.  
  1317.             Case StringInStr($ItemFromList, "Lightroom CC")
  1318.                 _GUICtrlListView_InsertGroup($idListview, $i, 14, "", 1)
  1319.                 _GUICtrlListView_SetItemGroupID($idListview, $i, 14)
  1320.                 _GUICtrlListView_SetGroupInfo($idListview, 14, "Lightroom CC", 1, $LVGS_COLLAPSIBLE)
  1321.  
  1322.             Case StringInStr($ItemFromList, "Lightroom Classic")
  1323.                 _GUICtrlListView_InsertGroup($idListview, $i, 15, "", 1)
  1324.                 _GUICtrlListView_SetItemGroupID($idListview, $i, 15)
  1325.                 _GUICtrlListView_SetGroupInfo($idListview, 15, "Lightroom Classic", 1, $LVGS_COLLAPSIBLE)
  1326.  
  1327.             Case StringInStr($ItemFromList, "Media Encoder")
  1328.                 _GUICtrlListView_InsertGroup($idListview, $i, 16, "", 1)
  1329.                 _GUICtrlListView_SetItemGroupID($idListview, $i, 16)
  1330.                 _GUICtrlListView_SetGroupInfo($idListview, 16, "Media Encoder", 1, $LVGS_COLLAPSIBLE)
  1331.  
  1332.             Case StringInStr($ItemFromList, "Photoshop")
  1333.                 _GUICtrlListView_InsertGroup($idListview, $i, 17, "", 1)
  1334.                 _GUICtrlListView_SetItemGroupID($idListview, $i, 17)
  1335.                 _GUICtrlListView_SetGroupInfo($idListview, 17, "Photoshop", 1, $LVGS_COLLAPSIBLE)
  1336.  
  1337.             Case StringInStr($ItemFromList, "Premiere Pro")
  1338.                 _GUICtrlListView_InsertGroup($idListview, $i, 18, "", 1)
  1339.                 _GUICtrlListView_SetItemGroupID($idListview, $i, 18)
  1340.                 _GUICtrlListView_SetGroupInfo($idListview, 18, "Premiere Pro", 1, $LVGS_COLLAPSIBLE)
  1341.  
  1342.             Case StringInStr($ItemFromList, "Premiere Rush")
  1343.                 _GUICtrlListView_InsertGroup($idListview, $i, 19, "", 1)
  1344.                 _GUICtrlListView_SetItemGroupID($idListview, $i, 19)
  1345.                 _GUICtrlListView_SetGroupInfo($idListview, 19, "Premiere Rush", 1, $LVGS_COLLAPSIBLE)
  1346.  
  1347.             Case StringInStr($ItemFromList, "Substance 3D Designer")
  1348.                 _GUICtrlListView_InsertGroup($idListview, $i, 20, "", 1)
  1349.                 _GUICtrlListView_SetItemGroupID($idListview, $i, 20)
  1350.                 _GUICtrlListView_SetGroupInfo($idListview, 20, "Substance 3D Designer", 1, $LVGS_COLLAPSIBLE)
  1351.  
  1352.             Case StringInStr($ItemFromList, "Substance 3D Modeler")
  1353.                 _GUICtrlListView_InsertGroup($idListview, $i, 21, "", 1)
  1354.                 _GUICtrlListView_SetItemGroupID($idListview, $i, 21)
  1355.                 _GUICtrlListView_SetGroupInfo($idListview, 21, "Substance 3D Modeler", 1, $LVGS_COLLAPSIBLE)
  1356.  
  1357.             Case StringInStr($ItemFromList, "Substance 3D Painter")
  1358.                 _GUICtrlListView_InsertGroup($idListview, $i, 22, "", 1)
  1359.                 _GUICtrlListView_SetItemGroupID($idListview, $i, 22)
  1360.                 _GUICtrlListView_SetGroupInfo($idListview, 22, "Substance 3D Painter", 1, $LVGS_COLLAPSIBLE)
  1361.  
  1362.             Case StringInStr($ItemFromList, "Substance 3D Sampler")
  1363.                 _GUICtrlListView_InsertGroup($idListview, $i, 23, "", 1)
  1364.                 _GUICtrlListView_SetItemGroupID($idListview, $i, 23)
  1365.                 _GUICtrlListView_SetGroupInfo($idListview, 23, "Substance 3D Sampler", 1, $LVGS_COLLAPSIBLE)
  1366.  
  1367.             Case StringInStr($ItemFromList, "Substance 3D Stager")
  1368.                 _GUICtrlListView_InsertGroup($idListview, $i, 24, "", 1)
  1369.                 _GUICtrlListView_SetItemGroupID($idListview, $i, 24)
  1370.                 _GUICtrlListView_SetGroupInfo($idListview, 24, "Substance 3D Stager", 1, $LVGS_COLLAPSIBLE)
  1371.  
  1372.             Case StringInStr($ItemFromList, "Adobe.Fresco")
  1373.                 _GUICtrlListView_InsertGroup($idListview, $i, 25, "", 1)
  1374.                 _GUICtrlListView_SetItemGroupID($idListview, $i, 25)
  1375.                 _GUICtrlListView_SetGroupInfo($idListview, 25, "Fresco", 1, $LVGS_COLLAPSIBLE)
  1376.  
  1377.             Case StringInStr($ItemFromList, "Adobe.XD")
  1378.                 _GUICtrlListView_InsertGroup($idListview, $i, 26, "", 1)
  1379.                 _GUICtrlListView_SetItemGroupID($idListview, $i, 26)
  1380.                 _GUICtrlListView_SetGroupInfo($idListview, 26, "XD", 1, $LVGS_COLLAPSIBLE)
  1381.  
  1382.             Case StringInStr($ItemFromList, "PhotoshopExpress")
  1383.                 _GUICtrlListView_InsertGroup($idListview, $i, 27, "", 1)
  1384.                 _GUICtrlListView_SetItemGroupID($idListview, $i, 27)
  1385.                 _GUICtrlListView_SetGroupInfo($idListview, 27, "PhotoshopExpress", 1, $LVGS_COLLAPSIBLE)
  1386.  
  1387.             Case Else
  1388.                 _GUICtrlListView_InsertGroup($idListview, $i, 29, "", 1)
  1389.                 _GUICtrlListView_SetItemGroupID($idListview, $i, 29)
  1390.                 _GUICtrlListView_SetGroupInfo($idListview, 29, "Miscellaneous", 1, $LVGS_COLLAPSIBLE)
  1391.         EndSelect
  1392.     Next
  1393.  
  1394.     ;MsgBox(-1,"ItemCount",_GUICtrlListView_GetItemCount($idListview))
  1395.     ;MsgBox(-1,"GroupCount",_GUICtrlListView_GetGroupCount($idListview))
  1396.  
  1397. EndFunc   ;==>_Assign_Groups_To_Found_Files
  1398.  
  1399. Func _Collapse_All_Click()
  1400.     Local $aInfo, $aCount = _GUICtrlListView_GetGroupCount($idListview) ; Group Count
  1401.     If $aCount > 0 Then
  1402.         If $MyLVGroupIsExpanded = 1 Then
  1403.             ; Change group information
  1404.             For $i = 1 To 28
  1405.                 $aInfo = _GUICtrlListView_GetGroupInfo($idListview, $i)
  1406.                 _GUICtrlListView_SetGroupInfo($idListview, $i, $aInfo[0], $aInfo[1], $LVGS_COLLAPSED)
  1407.             Next
  1408.         Else
  1409.             _Expand_All_Click()
  1410.         EndIf
  1411.         $MyLVGroupIsExpanded = Not $MyLVGroupIsExpanded
  1412.     EndIf
  1413.  
  1414. EndFunc   ;==>_Collapse_All_Click
  1415.  
  1416.  
  1417. Func _Expand_All_Click()
  1418.     Local $aInfo, $aCount = _GUICtrlListView_GetGroupCount($idListview) ; Group Count
  1419.     If $aCount > 0 Then
  1420.         ; Change group information
  1421.         For $i = 1 To 28
  1422.             $aInfo = _GUICtrlListView_GetGroupInfo($idListview, $i)
  1423.             _GUICtrlListView_SetGroupInfo($idListview, $i, $aInfo[0], $aInfo[1], $LVGS_NORMAL)
  1424.             _GUICtrlListView_SetGroupInfo($idListview, $i, $aInfo[0], $aInfo[1], $LVGS_COLLAPSIBLE)
  1425.         Next
  1426.     EndIf
  1427.  
  1428. EndFunc   ;==>_Expand_All_Click
  1429.  
  1430. Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
  1431.     If BitAND($wParam, 0x0000FFFF) = $idButtonStop Then $fInterrupt = 1
  1432.     Return $GUI_RUNDEFMSG
  1433. EndFunc   ;==>WM_COMMAND
  1434.  
  1435. Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
  1436.     #forceref $hWnd, $iMsg, $wParam, $lParam
  1437.     Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
  1438.     Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
  1439.     Local $iCode = DllStructGetData($tNMHDR, "Code")
  1440.     Switch $hWndFrom
  1441.         Case $g_idListview
  1442.             Switch $iCode
  1443.                 Case $LVN_COLUMNCLICK ; A column was clicked
  1444.                     _Collapse_All_Click()
  1445.                     ; No return value
  1446.                 Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
  1447.                     _ListView_LeftClick($g_idListview, $lParam)
  1448.                     ; No return value
  1449.                 Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
  1450.                     _ListView_RightClick()
  1451.                     ; No return value
  1452.             EndSwitch
  1453.     EndSwitch
  1454.     Return $GUI_RUNDEFMSG
  1455. EndFunc   ;==>WM_NOTIFY
  1456.  
  1457. Func IniReadArray($FileName, $section, $key, $default)
  1458.     Local $sINI = IniRead($FileName, $section, $key, $default)
  1459.     $sINI = StringReplace($sINI, '"', '')
  1460.     StringReplace($sINI, ",", ",")
  1461.     Local $aSize = @extended
  1462.     Local $aReturn[$aSize + 1]
  1463.     Local $aSplit = StringSplit($sINI, ",")
  1464.     For $i = 0 To $aSize
  1465.         $aReturn[$i] = $aSplit[$i + 1]
  1466.     Next
  1467.     Return $aReturn
  1468. EndFunc   ;==>IniReadArray
  1469.  
  1470. Func ReplaceToArray($sParam)
  1471.     Local $sString = StringReplace($sParam, '"', '')
  1472.     StringReplace($sString, ",", ",")
  1473.     Local $aSize = @extended
  1474.     Local $aReturn[$aSize + 1]
  1475.     Local $aSplit = StringSplit($sString, ",")
  1476.     For $i = 0 To $aSize
  1477.         $aReturn[$i] = $aSplit[$i + 1]
  1478.     Next
  1479.     Return $aReturn
  1480. EndFunc   ;==>ReplaceToArray
  1481.  
Tags: adobe
Add Comment
Please, Sign In to add comment