forked from yang123vc/slshim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.bat
127 lines (110 loc) · 4.13 KB
/
install.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
@echo off
echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
echo @@@@@@@@@@@@@@@ YOU'RE NOW ENTERING THE DANGER ZONE @@@@@@@@@@@@@@@@@
echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
echo.
echo UNLESS YOU TRUST YOUR ABILITY TO DO DAMAGE CONTROL, DO NOT PROCEED
echo.
echo This batch file replaces 5 core system files with our own version.
echo Things can go wrong horribly - commonly AV and WU interfering.
echo.
echo In particular, explorer.exe depends on these files. In the worst case
echo you wont be able to boot into desktop, you'll have to run sfc from
echo recovery.
echo.
echo Also, this script is not particularly smart either and might abort
echo with things half-installed in rare circumstances.
echo.
echo If something damages slshim installation (typically WU), it is usually
echo sufficient to run this batch file again (it is designed to handle
echo "reinstalls" too) to restore full functionality.
echo.
set /P c=Are you sure you want to proceed [Y/N]?
if /I "%c%" EQU "Y" goto i_know_what_i_am_doing
echo Stay safe now.
exit
:i_know_what_i_am_doing
rem
rem We're very careful to not burn bridges:
rem
rem We rename the replaced files as filename.slold
rem If some .slold file already exists, we use
rem random number as a suffix instead, and keep
rem the original .slold.
rem
echo.
echo === Copying and linking files ===
echo.
set sysdir=%windir%\system32
set offdir=microsoft shared\officesoftwareprotectionplatform
set office=%commonprogramfiles%\%offdir%
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto 64BIT
rem
rem 32bits
rem
set bits=32
call:dofiles
goto initsvc
:64BIT
set bits=64
call:dofiles
set bits=32
set sysdir=%windir%\syswow64
set office=%commonprogramfiles(x86)%\%offdir%
call:dofiles
set bits=64
goto initsvc
:dofiles
echo Creating %sysdir%\slshim.dll ...
move %sysdir%\slshim.dll %windir%\Temp\slshim.%random% > nul 2> nul
copy slshim%bits%.dll %sysdir%\slshim.dll > nul
icacls "%sysdir%\slshim.dll" /L /Grant "NT SERVICE\TrustedInstaller":F 2> nul > nul
for %%d in (slc,slcext,sppc,sppcext,slwga) do (
set dirname=%sysdir%
set fname=%%d
call:backupandlink
)
if not exist "%office%" exit /b
set dirname=%office%
set fname=osppc
:backupandlink
set fullname=%dirname%\%fname%
rem already linked to us, leave it
fsutil reparsepoint query "%fullname%.dll" > nul && exit /b
takeown /F "%fullname%.dll" > nul
icacls "%fullname%.dll" /Grant Administrators:F > nul
ren "%fullname%.dll" %fname%.slold 2> nul > nul
ren "%fullname%.dll" %fname%.%random% 2> nul > nul
rem if the above failed, mklink error will be visible
if "%fname%" == "osppc" (
mklink "%fullname%.dll" %sysdir%\slshim.dll
) else (
mklink "%fullname%.dll" slshim.dll
)
icacls "%fullname%.dll" /L /Grant "NT SERVICE\TrustedInstaller":F 2> nul > nul
exit /b
:initsvc
rem We now force the service, because it is integral to deal with kernel
rem cache APIs (eg even notepad would cry otherwise)
echo.
echo === Creating kernel cache service ===
echo.
sc create SLShim binPath= "%%SystemRoot%%\system32\svchost.exe -k DcomLaunch" start= auto type= share group= Base && rundll32 slshim%bits%.dll SLShimInit
sc sidtype SLShim unrestricted
reg add HKLM\SYSTEM\CurrentControlSet\services\SLShim\Parameters /f /v ServiceDll /t REG_EXPAND_SZ /d %%SystemRoot%%\system32\slshim.dll
sc start SLShim > nul 2> nul
echo.
echo === Disabling old SPPSVC services ===
echo.
reg add HKLM\SYSTEM\CurrentControlSet\services\sppuinotify /f /v Start /t REG_DWORD /d 4
reg add HKLM\SYSTEM\CurrentControlSet\services\sppsvc /f /v Start /t REG_DWORD /d 4
reg add HKLM\SYSTEM\CurrentControlSet\services\osppsvc /f /v Start /t REG_DWORD /d 4
reg import tokens.reg
echo ========
echo All done now. You'll have to reboot for changes to take effect.
echo Changes to kernel policy will propagate on second reboot as the service
echo is not fully active yet.
echo.
echo Note that if anything above looks fishy (ie errors), run uninstall.bat.
echo If uninstall barks at you it can't find all backup files (partial install),
echo run echo `sfc /scannow` to repair your system.