-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incompatibility when AutoRun injects AutoHotkey, AnsiCon, and Clink #169
Comments
Please share your clink_settings file. History is working fine for me and I haven't knowingly made any changes near history in some time, so knowing more information about your configuration would help track down what might be happening. |
I haven't knowingly altered it.
|
First of all, let me be clear: I believe you. 🙂 I need help tracking down why history stopped working for you. I can't find a way to reproduce that, so I need more information about the configuration (and maybe scripts) in your Clink installation.
|
It is indeed the autorun command I use that's affecting things. This is my autorun command in full:
It doesn't seem to relate to the contents of the scripts I call ( One pattern I have found is removing the first command only and my history starts working again. Equally, removing the second command only and my history starts working again. However, removing the fourth command and my history does not work in the same way that calling all four commands together and my history does not work. Does any of this relate to changes made in |
Have you noticed that nothing about Clink works? 🙂 History is one thing that doesn't work, but also nothing else about Clink works, either. During AutoRun you're injecting AutoHotkey, then AnsiCon, then Clink.
What changed in v1.2.33 is in response to #159, I changed Clink to use Detours hooking, instead of IAT hooking. Another user mentioned that an antivirus suite was interfering with Clink. Analysis of why revealed that the antivirus suite was (probably intentionally) corrupting OS data structures related to IAT hooking, causing Clink to be unable to hook the necessary APIs. So I rewrote it to not use IAT hooking at all, in the hopes of bypassing that particular kind of interference from an antivirus suite. I've made an adjustment to the Detours hooking, and now Clink seems to be able to inject during AutoRun even when other programs have used IAT hooking. |
By the way:
|
The fix was working ... and then it stopped working. Will have to research further. |
The good news is that all of the hooking actually worked: all of the APIs were successfully hooked, and Clink's overrides are reached successfully.
Here is what's happening:
That's inefficient and unnecessary on the part of AnsiCon. By the way, you may know this already, but if you're using Windows 10, you should stop using AnsiCon. The built in support in Windows 10 is much better than AnsiCon, and AnsiCon can only cause problems. For example, the built in support handles 8-bit color and 24-bit color, among other things. What I'll do is this:
|
Fixed by ba71118. Clink now uses IAT hooking for everything. BackgroundLong ago it used jmp hooking for everything. Martin slowly converted various hooks to use IAT hooking, but never converted ReadConsoleW to use IAT hooking. One of the first things I did was fix a jmp hooking problem with ReadConsoleW, and then I integrated the Detours library to do more sophisticated jmp hooking. But it turns out the simplest and (apparently) best thing to do would have been to just convert ReadConsoleW to use IAT hooking. The benefit of Detours hooking is it can hook more reliably than IAT hooking, and can hook more kinds of things than IAT can. That drawback is a big problem for Clink if anything hooks and interferes with normal WriteConsoleW functionality. Which AnsiCon does. Not only does AnsiCon split one WriteConsoleW call into many tiny calls (which isn't good for speed, either), it also intercepts and handles ANSI escape sequences on its own, before Clink gets them. That completely breaks Clink's terminal emulation capabilities. ResolutionSo for best stability and reliability, Clink now uses IAT hooking for all APIs that it hooks. But if there's no other way to get Clink to work (e.g. #159), then it's possible to use |
Aha! No, I noticed my history was broken and stopped there before reverting to
Windows 10. I installed AnsiCon a while ago to correct colours that weren't showing properly in my cmd. Since you questioned its use, I've removed it from my AutoRun and things look to be fine. 24-bit colour is nice! 🌈
I use it to position the cmd window correctly so the AutoHotkey script that runs is fairly minimal but noted, I'll see if I can do without.
Done ✔️
Super. Having an opt-in flag for Detours hooking sounds like the best thing to do. Thanks for fixing this. I can confirm |
Autohotkey scripts, however small, does tend to take some time to load up the interpretter. Normally, this time is unnoticible, but as christan said, cmd tends to be invoked implicitly for many tasks and the delay can become quite large depending on your workflow. I would suggest having a always-on script that watches for the cmd windows, positions them, and adds its hwnd to an ignore-list. Its easily doable with |
Thanks, I'll take a look at that idea. For info, this is my AHK script: #SingleInstance, Force
#NoEnv
WinGetTitle, WinTitle, A
If InStr(WinTitle, "C:\WINDOWS\SYSTEM32\cmd.exe - """) OR InStr(WinTitle, "cmd - """)
{
BlockInput, On
Send, #`` ; Apply Sizer profile: Win+` | http://www.brianapps.net/sizer4/
BlockInput, Off
}
Return |
Also, is there a reason you don't want to use the |
Good point - any reason this variable isn't used when Clink updates the autorun registry entry? I see as part of the installer you can choose not to create |
I've installed both
1.2.33
and1.2.34
but my history only persists whilst my cmd is open - I cannot access any previously run commands. Reverting back to1.2.32
fixes the issue and brings back my history.On a side, it would also be helpful to configure the directory clink installs into via the installer.
e.g.
C:\Program Files (x86)\clink
rather thanC:\Program Files (x86)\clink\1.2.34.6cb41a
Reason being I have a custom setting for
Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Command Processor\Autorun
and every time a new update for clink is released I have to update this setting with the new version number and commit hash of clink. Just a minor annoyance.Also, one thing many installers allow is skipping the installation of start menu shortcuts (I don't use them). I'm not sure how simple this would be with the "Nullsoft Install System" installer that's in use.
Thanks for all your work.
The text was updated successfully, but these errors were encountered: