Open gjf opened 3 years ago
Good questions! Thanks! I will answer them in turn.
Yes, as you said, it is easy to determine the architecture of the target file, but getting the address of the API LoadLibraryW
across architectures is much more complicated: first we need to parse the export table of the kernel32.dll
file, get the offset of LoadLibraryW
in the file, and then remotely get the address of kernel32.dll
in memory. These tasks require writing hundreds of lines of code, but with the same architecture just one line of GetProcAddress(kernel32, "LoadLibraryW")
will give us what we need. (In other words, I slacked off. :P)
Similarly, it is easy to determine the system version, but the problem is that version.dll
export functions for Win7 and Win10 are a bit different.
https://github.com/SpriteOvO/Telegram-Anti-Revoke/blob/de181c4bf43cfb24a8e29f022bc88d6b86703790/Source/Core/OS/Windows/DllMain.cpp#L13-L56
As you can see from the plugin's exported functions above, the indexes corresponding to the names of the exported functions no longer correspond from 3 onwards. Although most programs import functions by name rather than index, so even if the index is wrong it won't cause a problem, I just don't want to break the indexes.
tbh, I don't think it's strange.
If you update within Telegram, this will probably overwrite the plugin file and you will have to download the plugin again. If not, the associated path is also likely to change to itself after launch.
Finally, I don't intend to develop a feature to block ads, Telegram has already given too much as a free software, and I believe it will not show very annoying type of ads, which is acceptable to me.
Thanks for answers.
It looks like we are looking at this problem from different point of view. I don't suggest to change the code. I just suggest to create some kind of stub, a "starter" that will:
In fact p3D is not necessary as the user can simply start a stub once again after update.
Once I had a similar task in other world. Yes, the solution could be more pretty but I am a lazy bastard with strong batch scripting knowledge. So I coded it and then transfered to exe using some batch compiler:
if "%~1"=="u" goto uninstall
if "%~1"=="U" goto uninstall
if "%~1"=="/u" goto uninstall
if "%~1"=="/U" goto uninstall
if exist tspec32_orig.exe goto final
ren tspec32.exe tspec32_orig.exe
copy /b /v /y .\SysData\Languages\TSpec32ResourceCHS.dll .\SysData\Languages\TSpec32_origResourceCHS.dll
copy /b /v /y .\SysData\Languages\TSpec32ResourceDEU.dll .\SysData\Languages\TSpec32_origResourceDEU.dll
copy /b /v /y .\SysData\Languages\TSpec32ResourceENG.dll .\SysData\Languages\TSpec32_origResourceENG.dll
copy /b /v /y .\SysData\Languages\TSpec32ResourceESN.dll .\SysData\Languages\TSpec32_origResourceESN.dll
copy /b /v /y .\SysData\Languages\TSpec32ResourceFRA.dll .\SysData\Languages\TSpec32_origResourceFRA.dll
copy /b /v /y .\SysData\Languages\TSpec32ResourceJPN.dll .\SysData\Languages\TSpec32_origResourceJPN.dll
copy /b /v /y .\SysData\Languages\TSpec32ResourceRUS.dll .\SysData\Languages\TSpec32_origResourceRUS.dll
sc config MSSQL$ITEVA2014 start=demand
sc config MSSQL$ITEVA start=demand
sc config MSSQLFDLauncher$ITEVA2014 start=demand
sc config msftesql$ITEVA start=demand
sc config SQLBrowser start=demand
sc config SReportServer$ITEVA2014 start=demand
sc config SQLWriter start=demand
:final
move /Y %MYFILES%\starter.exe .\tspec32.exe
goto end
:uninstall
sc config MSSQL$ITEVA2014 start=auto
sc config MSSQL$ITEVA start=auto
sc config MSSQLFDLauncher$ITEVA2014 start=auto
sc config msftesql$ITEVA start=auto
rem sc config MSSQLServerADHelper start=disabled
rem sc config SQLAgent$ITEVA2014 start=disabled
sc config SQLBrowser start=demand
sc config SReportServer$ITEVA2014 start=demand
sc config SQLWriter start=demand
del .\tspec32.exe /q /f
rename .\tspec32_orig.exe tspec32.exe
del .\SysData\Languages\TSpec32_origResourceCHS.dll /q /f
del .\SysData\Languages\TSpec32_origResourceDEU.dll /q /f
del .\SysData\Languages\TSpec32_origResourceENG.dll /q /f
del .\SysData\Languages\TSpec32_origResourceESN.dll /q /f
del .\SysData\Languages\TSpec32_origResourceFRA.dll /q /f
del .\SysData\Languages\TSpec32_origResourceJPN.dll /q /f
del .\SysData\Languages\TSpec32_origResourceRUS.dll /q /f
:end
del %~s0 /q /f
Whereas "starter.exe" in fact is:
sc start MSSQL$ITEVA2014
sc start MSSQL$ITEVA
ping -n 3 127.0.0.1 > nul
start /wait tspec32_orig.exe
sc stop MSSQL$ITEVA2014
sc stop MSSQL$ITEVA
sc stop MSSQLFDLauncher$ITEVA2014
sc stop msftesql$ITEVA
sc stop MSSQLServerADHelper
sc stop SQLAgent$ITEVA2014
sc stop SQLBrowser
sc stop SReportServer$ITEVA2014
sc stop SQLWriter
del %~s0 /q /f
This code was of course simpler then I requested and in fact just allows to start and stop MSSQL only when it is required. However I don't think it will require too much work to create a starter for your modules as well as add parameter transfer from "TAR-Launcher-XXX.exe" (renamed to telegram.exe) to telegram.exe (renamed to telegram.bin).
Kindly add a Cool Icon to TAR-Launcher-ARCH.exe. Thanks
Just some ideas to the whole design.
As for now we have two different folders for Win7 and Win10 with two different folders for x86 and x64 in each. Why don't you automate the process?
In fact all these actions can be automated even in a script but I really think it would be better to put it in original project by design.
I'd be happy to help the author if any of my suggestions looked unclear.
Taking into account future advertisement "additions" in Telegram - I really think there is a big future in this project.