Skip to content

Commit

Permalink
Patcher now re-registers Flash ActiveX automatically, just to be sure..
Browse files Browse the repository at this point in the history
Added script that reinstalls Flash on Windows 10 after it got removed by KB4577586
  • Loading branch information
leecher1337 committed Feb 19, 2021
1 parent 1a895dc commit a36a828
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 21 deletions.
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,15 @@ https://gist.github.com/KuromeSan/56d8b724c0696b54f9f81994ae3591d1

Unfortunately, I only found patchers for the timebomb that were written in .NET.
Now I definitely don't want to pollute my system with .NET Framework and the patcher above didn't even work properly on Windows XP.
So I decided to write my own little patcher that is just a tiny executable wihout any dependencies.
So I decided to write my own little patcher that is just a tiny executable without any dependencies.
It is based on the work mentioned above.

# How to use?
Depending on whether you are on x86 or x64 System, download flashpatch_x86.exe or flashpatch_x64.exe from Releases-page.
If you just want to look in the default locations and patch Flash installation there, simply run the .exe
If you want to scan a certain directory or patch a specifig file, specify it as a commandline parameter.

# What to do with Internet Explorer 11?
It may be that you need to re-register Flash in order to get Flash working with IE11
Open cmd.exe Shell (on 64bit OS in 64bit Mode) as Administrator and:

```
regsvr32 %systemroot%\SysWOW64\Macromed\Flash\flash.ocx
regsvr32 %systemroot%\System32\Macromed\Flash\flash.ocx
```
# How to reinstall flash after KB4577586 removed it?
On Windows 7 and below, just download and install it from the sites mentioned [here](https://gist.github.com/KuromeSan/56d8b724c0696b54f9f81994ae3591d1#finally)
On Windows 10, you need to download the latest Flash player from KB4580325 and reinstall its contents.
For this, download reinst_flash_w10.cmd to the same directory as the flashpatch_???.exe files and run it, it downloads mentioned updated flash version and copies it to System directory again.
33 changes: 21 additions & 12 deletions flashpatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,33 @@ static BOOL PatchFile(char *pszFile);
static BOOL ShowError(LPSTR pszError);
static BOOL EnablePrivilege (HANDLE hProcess, LPCTSTR lpPrivilegeName);

static int LocateExes(void)
static int ScanFlashFolder(int nFolder)
{
char szDir[MAX_PATH], *p;
char szDir[MAX_PATH+16], *p, *pszDir = szDir+9;
int nFiles = 0;

printf ("Scanning...\n");
if (SHGetSpecialFolderPath(NULL, szDir, CSIDL_SYSTEM, FALSE))
strcpy(szDir, "regsvr32 ");
if (SHGetSpecialFolderPath(NULL, pszDir, nFolder, FALSE))
{
strcat(szDir, "\\Macromed\\Flash");
nFiles += ScanFolder(szDir);
strcat(pszDir, "\\Macromed\\Flash");
p = pszDir + strlen(pszDir);
nFiles += ScanFolder(pszDir);
strcpy(p, "\\flash.ocx");
if (GetFileAttributes(pszDir) != INVALID_FILE_ATTRIBUTES)
WinExec(szDir, SW_HIDE);
}
return nFiles;
}

static int LocateExes(void)
{
char szDir[MAX_PATH], *p;
int nFiles = 0;

printf ("Scanning...\n");
nFiles += ScanFlashFolder(CSIDL_SYSTEM);
#ifdef _WIN64
if (SHGetSpecialFolderPath(NULL, szDir, CSIDL_SYSTEMX86, FALSE))
{
strcat(szDir, "\\Macromed\\Flash");
nFiles += ScanFolder(szDir);
}
nFiles += ScanFlashFolder(CSIDL_SYSTEMX86);
#endif
if (SHGetSpecialFolderPath(NULL, szDir, CSIDL_LOCAL_APPDATA, FALSE))
{
Expand Down Expand Up @@ -127,7 +136,7 @@ static BOOL PatchFile(char *pszFile)
HANDLE hFile;
BOOL bRet=FALSE;
BYTE Timestamp[] = {0x00, 0x00, 0x40, 0x46, 0x3E, 0x6F, 0x77, 0x42};
BYTE Infinity[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x7F};
BYTE Infinity[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x7F};
PBYTE lpSig, lpMem;

printf ("Checking %s....", pszFile);
Expand Down
93 changes: 93 additions & 0 deletions reinst_flash_w10.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
@echo off
rem
rem Are we even needed?
rem
wmic qfe get hotfixid | find /i "KB4577586" >nul
if errorlevel 0 echo [*] Evil update KB4577586 installed.
if not exist %systemroot%\System32\Macromed\Flash\Flash.ocx goto noflash
if exist %systemroot%\SysWOW64 (
if not exist %systemroot%\SysWOW64\Macromed\Flash\Flash.ocx goto noflash
)
if "%1"=="/FORCE" goto noflash
echo Flash is still present, are you sure that you want me to run?
echo If so, start me with /FORCE parameter
goto fini

:noflash
rem Ensure that we are run from 64bit prompt
if "%ProgramFiles(x86)%" == "" goto StartExec
if not exist %SystemRoot%\Sysnative\cmd.exe goto StartExec
%SystemRoot%\Sysnative\cmd.exe /C "%~f0" %*
exit /b
:StartExec
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "%1", "%1", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
pushd "%CD%"
CD /D "%~dp0"

setlocal
set ARCH=amd64
reg query HKLM\Hardware\Description\System\CentralProcessor\0 /v Identifier | Find /i "x86" >nul
if not errorlevel 1 set ARCH=wow64

if not exist KB4580325.msu (
echo [*] Downloading update...
bitsadmin /transfer KB4580325.msu /download /priority normal http://download.windowsupdate.com/d/msdownload/update/software/secu/2020/10/windows10.0-kb4580325-x64_b6e8f5b34fd68a4e3c29a540000327f6d0675a7f.msu %CD%\KB4580325.msu
if not exist KB4580325.msu (
echo [-] Download failed
goto fini
)
)

echo [*] Extracting contents...
md ContentMSU
expand KB4580325.msu /F:* .\ContentMSU >nul
cd ContentMSU
md ContentCAB
expand Windows*.cab /F:* .\ContentCAB >nul
cd ContentCAB

echo [*] Copying Flash..
cd %ARCH%_adobe*
call :copyflash System32
if "%ARCH%"=="amd64" (
cd ..\wow64_adobe*
call :copyflash SysWOW64
copy /y flashplayercplapp.cpl %systemroot%\SysWOW64\
copy /y flashplayerapp.exe %systemroot%\SysWOW64\
set ARCH=x64
) else (
copy /y flashplayercplapp.cpl %systemroot%\System32\
copy /y flashplayerapp.exe %systemroot%\System32\
set ARCH=x86
)
cd ..\..\..
rmdir /s /q ContentMSU
if not exist flashpatch_%ARCH%.exe (
echo [-] flashpatch_%ARCH%.exe not found!
goto fini
)
flashpatch_%ARCH%.exe
exit /B

:copyflash
md %systemroot%\%1\Macromed\Flash
md %systemroot%\%1\Macromed\Temp
copy /y flash.ocx %systemroot%\%1\Macromed\Flash\
copy /y flashutil_activex.dll %systemroot%\%1\Macromed\Flash\
copy /y flashutil_activex.exe %systemroot%\%1\Macromed\Flash\
copy /y activex.vch %systemroot%\%1\Macromed\Flash\
exit /B

:fini
pause

0 comments on commit a36a828

Please sign in to comment.