Is it possible to suppress MessageBox when running a specific command?

僤鯓⒐⒋嵵緔 提交于 2020-01-05 04:37:08

问题


I'm using Tortoise SVN, and TortoisePlink for remote ssh connections. From time to time TortoisePlink is displaying errors like:

---------------------------
TortoisePlink Fatal Error
---------------------------
Network error: Software caused connection abort
---------------------------
OK   
---------------------------

And they appears as messagebox and needs to be clicked by end-user.

I have tried to suppress messagebox by using -batch from command line, but problem still can be reproduced. For me it's sufficient if I'll disable messagebox prompting and print for example in command line same information - since my batch will retry later on again automatically.

Does there exists such software which can override default windows behavior and print in console window whatever is displayed in message box.

I guess in simplest terms such command line tool can be easily created, using for example

http://www.codeproject.com/Articles/44326/MinHook-The-Minimalistic-x-x-API-Hooking-Libra

and override MessageBoxA / MessageBoxW - but have anyone done this kind of thing ?


回答1:


I think you're going about this the wrong way. Instead of trying to suppress the dialog boxes that TortoisePlink is showing, use the original Plink. TortoisePlink is a fork of Plink to explicitly show message boxes and not print anything on a command line, because it's designed for an UI app and not for console apps.

And if you really only want to use svn from a batch file, don't use TortoiseSVN but the original svn command line client (can be installed with the TSVN installer as well) and use the 'svn' command from the command line.




回答2:


TortoisePLink.exe is targetted for end-user - so it's intended to display message boxes, however - there also exists a command line version of PLink.exe, and it can be downloaded from here:

http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

Please notice that "TortoiseSVN" > "Settings" > "Network" > "SSH Client" should use TortoisePLink.exe - errors will be displayed to end-user.

For following file however -

%appdata%\Subversion\
file ‘config’:
In section [tunnels]
Add line like this:
ssh = Plink.exe  -l <your login> -pw <password>

You should use command line version of PLink.exe (that is also displaying command prompt when launched).

It's easier to save PLink.exe next with TortoisePLink.exe, that is into C:\Program Files\TortoiseSVN\bin.

I have tried to make a command line tool for supressing messageboxes, but it's useless for TortoisePLink.exe (Haven't debugged what is the problem), but in case if you're interested (Have other means to use it):

https://sourceforge.net/p/diagnostic/svn/HEAD/tree/Tools/msgboxSupress/

msSupress.cpp is compiled into .dll and it uses minimalistic hook for windows to disable MessageBoxA and MessageBoxW - actually they will be printed to console or redirected to file.

msSupressExe.cpp is compiled into .exe and it starts process in suspended mode, replaces .exe's entry point with EB FE (jump short into itself), waits until that address is reached, injects .dll and .dll will hook new process.

I have tested only on 64-bit platform - I suspect that command being executed must match same platform as as msSupress.exe.

So typically TortoisePlink.exe will display messagebox - but when executed like this:

mbSupress.exe "C:\Program Files\TortoiseSVN\bin\TortoisePlink.exe"

Same stuff as shown over message box will be displayed in console.

I think this solution is good prototype for further virus or trojan construction - using technique like this will allow to intercept even keyboard presses on any application - but I now made a command line utility, not a virus.



来源:https://stackoverflow.com/questions/40586680/is-it-possible-to-suppress-messagebox-when-running-a-specific-command

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!