-
Notifications
You must be signed in to change notification settings - Fork 127
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
how to fully support ansi colors without ansicon? #461
Comments
Clink is not a general purpose ANSI emulator -- it doesn't affect anything other than Clink output.
Also, other console mode programs are not Clink output. The crash you experienced may or may not be the same crash as in the issue you linked. (I don't think it's the same crash, I think it's a different crash occurring for different reasons.) Sometime this week or maybe next week, I'll try to reproduce the ANSICON issues you described on Win7 and see if there's anything Clink can do about them, or if there's a fix I can potentially recommend in the ANSICON repo. Though it seems like development and maintenance stopped on ANSICON a few years ago. |
here are the steps I did and it is reproducible: https://github.com/chrisant996/clink/releases/download/v1.4.25/clink.1.4.25.e0d48c.zip https://github.com/adoxa/ansicon/releases/download/v1.89/ansi189-bin.zip then I open a default cmd with nothing injected in it, then I run: ansicon -p
clink.bat |
That's a crash in Clink (the fault module is clink_dll_x64.dll). That's not a crash in ANSICON, so it is definitely not the same as the crash you cited. The good news is that it might be possible to do something about a crash in Clink, depending on what's happening and why. I'll know more when I get a chance (later) to reproduce the issue with a debugger attached. |
Did you intend to launch a separate new console for Clink? Might Not Be What You Intended
That injects ansicon into the current console, and then starts a NEW console for Clink ansicon. The crash happens in the new console, and I suspect ansicon actively collides with Clink while they're both trying to hook things. I'll investigate that in the next week or so. Hopefully it will be possible to prevent the crash, but it will depend on specifically what ansicon is doing. This Is What You NeedFirst, a one-time action:
After that, use the following:
The one-time action tells Clink to use its own built-in terminal emulation. I'll make a change in Clink so that And using |
ANSI??.DLL (ansicon) has a bad RVA sometimes: - Run `ansicon -p` - Run `clink.bat` - Starts a new console with ansicon injected. - While Clink is initializing, the first RVA in ANSI??.DLL's import table far exceeds the SizeOfImage for the DLL. Instead of trying to dereference the bad RVA, log it and skip it.
Now it works, thank you so much for guiding me to the right way.
no, I usually run clink by a shortcut in my start menu,the shortcut call a bat that contains more things and this line: call "pathtoClink\clink\clink.bat" --profile pathtoClink\clink_profile so it does not open a new window. the problem was that I did not add the I think the doc should be changed for
and because is there a possibility to run ansicon after clink? this is because ansicon slow down the console, so I do not want it to be running all the time in all my consoles like clink, I want to run it when needed only for one specific console only using a doskey or a bat in the path. here is a quick test: print 1.3mb txt file with type
ansicon made the console take the double of time needed to do the same task. if it is not possible to load ansicon after clink, can we unload the clink dll? I attempted to unload the clink dll using process hacker to test if I may be able to unload clink then run ansicon then run clink again, but it failed, the console crashes after unloading the clink dll. thanks for your time and help. |
Users shouldn't have to do that. I've changed Clink so that it automatically uses terminal emulation when ansicon is detected.
Ah, that's an interesting phrasing quirk. But interestingly, it might be accurate, after the change I committed this evening. 🙂
Ah, I see. Yes, ansicon is known to be very inefficient. For example, it performs a separate console write operation for each individual character, which ruins performance. Ansicon and Clink conflict when Ansicon is loaded after: Ansicon ends up unable to intercept the output from internal cmd commands like the
Sorry, that's not possible at this time. Un-hooking is inherently risky, and I don't want to invest a ton of time on that and all the support headaches that go along with that.
Right. You've unloaded the code, but the OS API functions are still hooked and pointing at addresses that you've now unloaded the code from. Crashing is the best you can hope for in that case. 🙂 |
perfect. the problem is solved , I will wait for the next release to test it (I could not compile it , I got errors). thank you again for your time, help and explanation, I learned a lot of things. have a good time. |
UPDATE:
No, because ansicon has code here that explicitly refuses to hook an API if the API has already been hooked by anything else. That's why ansicon doesn't affect the If/when you're able to upgrade from Windows 7 to Windows 8.1 or higher, then you won't need ansicon anymore. In the meantime, there's no way to load ansicon after Clink and there's no way to unload Clink once it's loaded.
How did you try to compile it? Maybe you're using mingw, and maybe the mingw build is broken again? Mingw is not a supported compiler for Clink: even when I fix the errors, there are parts of Clink that actually are simply omitted when compiling under Mingw, because of limitations in Mingw. |
thank you very much for the time and effort you spent to investigate the ansicon problem. upgrading is difficult if not impossible for me for now, but I solve it by creating two console shortcuts, one for clink that I use daily and another for ansicon to use when needed only.
yes, exactly. I used mingw64 x86_64-8.1.0-release-win32-seh-rt_v6-rev0 I got a lot of errors, here is the log I should have used visual studio after what you told me now. I downloaded the new version v1.4.26 the crash is solved for the case of:
but a strange thing is happening now when I colorize the prompt:
another strange point is that if I run also, if I use |
Oops, yes, I broke the |
that was really quick. it works perfectly. thank you so much. |
Hi, I hope you are fine.
I m on win 7 64, clink does support ansi colors but not this case:
this file contains the ansi colors, in cmd run it by
type AnsiColors16_badr.txt
AnsiColors16_badr.txt
with clink I get
![image](https://private-user-images.githubusercontent.com/40046489/243570269-888cfc08-1b93-441c-a6f3-2972491c9192.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjExMjM4MTQsIm5iZiI6MTcyMTEyMzUxNCwicGF0aCI6Ii80MDA0NjQ4OS8yNDM1NzAyNjktODg4Y2ZjMDgtMWI5My00NDFjLWE2ZjMtMjk3MjQ5MWM5MTkyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzE2VDA5NTE1NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTMzYjI1NTMzM2JhOTZjNjEzZjBmOTY4MGM1OTQ4NmMxZTEzNDJmODA4N2E0MGY0YTcxODgzMjc5MTg2ZTI4MmMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.vvmQfkD9nvsInFVR8p88chECB-euIsvRU2L3hncDMmM)
with ansicon I get the correct output
![image](https://private-user-images.githubusercontent.com/40046489/243570028-455df8e6-ed52-4f5e-81b4-d8df82f31892.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjExMjM4MTQsIm5iZiI6MTcyMTEyMzUxNCwicGF0aCI6Ii80MDA0NjQ4OS8yNDM1NzAwMjgtNDU1ZGY4ZTYtZWQ1Mi00ZjVlLTgxYjQtZDhkZjgyZjMxODkyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzE2VDA5NTE1NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE1YzAyMDg1NTI2NDY3ODgwNDFkNThmM2Q1Y2IwYTk0M2JmNGIwYTRhOTAxODRlOWM3NTQ1NDU3ZjkxMjMwMmUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.vxq9EssiQNOdiIg7b-GoRAitz2FH9cg7342sJ5TVqKQ)
see this second example using miller
with clink I get
![image](https://private-user-images.githubusercontent.com/40046489/243569234-eecd567a-c71a-43b8-b3c4-92df630f7147.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjExMjM4MTQsIm5iZiI6MTcyMTEyMzUxNCwicGF0aCI6Ii80MDA0NjQ4OS8yNDM1NjkyMzQtZWVjZDU2N2EtYzcxYS00M2I4LWIzYzQtOTJkZjYzMGY3MTQ3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzE2VDA5NTE1NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWJmMjJlMTFlNWQyNzYzODUyOGMxNDg3Nzc1NDZlMDIxN2UzOWE4NTRiNWQxYWM3ZTU3N2U1ZmNkZDJkNTgzYTgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.hDPlrAFjdNMuilVKVkKsZ013rbAMb1cPQbLAgMXyWrE)
with ansicon I get the correct output
![image](https://private-user-images.githubusercontent.com/40046489/243568921-ed4b5a63-d1e7-4619-bf66-7a452246d826.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjExMjM4MTQsIm5iZiI6MTcyMTEyMzUxNCwicGF0aCI6Ii80MDA0NjQ4OS8yNDM1Njg5MjEtZWQ0YjVhNjMtZDFlNy00NjE5LWJmNjYtN2E0NTIyNDZkODI2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzE2VDA5NTE1NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTZmMDUzYTg1ODQwNjVmZGRlMWU4ODM1YWMyNWQ2ODIxZDQ0NTA2MmZlOGI2ZTczNjZhNjhhZjVmYWZlM2EwNjYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.BvnRAMI5F4wpeL5aEUIZu5lUNsB9V54qFT72duXmkhw)
I attempted to run clink and ansicon but it does not work, when I run ansicon after clink nothing happens (ansicon does nothing), when I run ansicon before clink the console crashs as you said here #460 (comment)
can clink support this type of tools that outputs in ansi colors? a lot of tools does this and disabling clink everytime to run those commands is frustrating. I hope there is a solution.
thank you for your time and your excellent work with the new clink.
The text was updated successfully, but these errors were encountered: