Skip to content
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

No prompt shown #32

Closed
nixxo opened this issue Dec 14, 2020 · 8 comments
Closed

No prompt shown #32

nixxo opened this issue Dec 14, 2020 · 8 comments
Labels
bug Something isn't working PRIORITY High priority

Comments

@nixxo
Copy link

nixxo commented Dec 14, 2020

Hi,
first thanks for picking up this project and make updates to it.
I've been using clink 0.4.9 for a while and wanted to try this new version.

But it seems to not work as intended on my machine.

Clink v0.4.9 [git:2fd2c2] Copyright (c) 2012-2016 Martin Ridgers
http://mridgers.github.io/clink

R:\clink_0.4.9>cd
R:\clink_0.4.9

R:\clink_0.4.9>

and the new version simply doesn't show any prompt or even provide tab completion

Clink v1.1.8.f031c7 Copyright (c) 2012-2018 Martin Ridgers Portions
Copyright (c) 2020 Christopher Antos
http://github.com/chrisant996/clink

cd
R:\clink.1.1.8.f031c7

I saw the clink.promptfilter in the docs and tried setting if to False but nothing changed. What am I missing?

p.s: I'm on Win7 [Version 6.1.7601]
p.s.2 It's related to #31 since I experienced it at the same way and than tried to investigate if it was a 'scoop' problem, or a 'conemu' problem, so I tried running clink clean in cmd and the same thing happended.

@nixxo
Copy link
Author

nixxo commented Dec 14, 2020

Log for 0.4.9

 4256 do_inject                  190 Version: 0.4.9
 4256 do_inject                  191 DLL: C:\Users\Utente\scoop\apps\clink\current\clink_dll_x64.dll
 4256 do_inject                  193 Parent pid: 3912
 4256 check_dll_version           52 DLL version: 00000004 0009b2fe
 4256 do_inject_impl             283 Creating remote thread at 00000000776A60B0 with parameter 0000000000530000
 3912 set_rl_readline_name        58 Setting rl_readline_name to 'cmd.exe'
 3912 hook_trap_veh              120 VEH hit - caller is 000000004A5E1A98.
 3912 hook_jmp                   408 Attemping jump hook.
 3912 hook_jmp                   409 Target is kernel32.dll, ReadConsoleW @ 00000000776FA610
 3912 hook_jmp_impl              351 Attempting to hook at 00000000776FA610 with 000007FED99463A0
 3912 get_instruction_length     316 Matched prolog E85EBEE9 (mask = 000000FF)
 3912 hook_jmp                   419 Success!
 3912 hook_iat                    77 Attempting to hook IAT for module 000007FED9940000
 3912 hook_iat                    78 Target is (null),ReadConsoleW (by_name=1)
 3912 iterate_imports             94 Checking imports in 'dbghelp.dll'
 3912 iterate_imports             94 Checking imports in 'KERNEL32.dll'
 3912 hook_iat                   104 Found import at 000007FED99A1210 (value = 00000000776FA610)
 3912 hook_iat                    77 Attempting to hook IAT for module 000000004A5E0000
 3912 hook_iat                    78 Target is (null),WriteConsoleW (by_name=1)
 3912 iterate_imports             94 Checking imports in 'msvcrt.dll'
 3912 iterate_imports             94 Checking imports in 'ntdll.dll'
 3912 iterate_imports             94 Checking imports in 'KERNEL32.dll'
 3912 hook_iat                   104 Found import at 000000004A6095F8 (value = 00000000776A2D80)
 3912 hook_iat                    77 Attempting to hook IAT for module 000007FED9940000
 3912 hook_iat                    78 Target is (null),WriteConsoleW (by_name=1)
 3912 iterate_imports             94 Checking imports in 'dbghelp.dll'
 3912 iterate_imports             94 Checking imports in 'KERNEL32.dll'
 3912 hook_iat                   104 Found import at 000007FED99A1180 (value = 00000000776A2D80)
 3912 hook_iat                    77 Attempting to hook IAT for module 000000004A5E0000
 3912 hook_iat                    78 Target is (null),SetEnvironmentVariableW (by_name=1)
 3912 iterate_imports             94 Checking imports in 'msvcrt.dll'
 3912 iterate_imports             94 Checking imports in 'ntdll.dll'
 3912 iterate_imports             94 Checking imports in 'KERNEL32.dll'
 3912 hook_iat                   104 Found import at 000000004A609690 (value = 00000000776A5F20)
 3912 hook_iat                    77 Attempting to hook IAT for module 000007FED9940000
 3912 hook_iat                    78 Target is (null),SetEnvironmentVariableW (by_name=1)
 3912 iterate_imports             94 Checking imports in 'dbghelp.dll'
 3912 iterate_imports             94 Checking imports in 'KERNEL32.dll'
 3912 hook_iat                   104 Found import at 000007FED99A1198 (value = 00000000776A5F20)
 3912 initialise_fwrite          185 Disabling ANSI support. Found 'conemuhk64.dll'

Log for 1.1.8

1388 hook_setter::hook_setter   36 >>> Started hook transaction.
1388 hook_iat                   53 Attempting to hook IAT for module 000000004A5E0000
1388 hook_iat                   54 Target is (null),SetEnvironmentVariableW (by_name=1)
1388 pe_info::iterate_imports  154 Checking imports in 'msvcrt.dll'
1388 pe_info::iterate_imports  154 Checking imports in 'ntdll.dll'
1388 pe_info::iterate_imports  154 Checking imports in 'KERNEL32.dll'
1388 hook_iat                   81 Found import at 000000004A609690 (value = 00000000776A5F20)
1388 hook_iat                   53 Attempting to hook IAT for module 000007FEC8780000
1388 hook_iat                   54 Target is (null),SetEnvironmentVariableW (by_name=1)
1388 pe_info::iterate_imports  154 Checking imports in 'VERSION.dll'
1388 pe_info::iterate_imports  154 Checking imports in 'SHLWAPI.dll'
1388 pe_info::iterate_imports  154 Checking imports in 'dbghelp.dll'
1388 pe_info::iterate_imports  154 Checking imports in 'KERNEL32.dll'
1388 hook_iat                   81 Found import at 000007FEC88381D0 (value = 00000000776A5F20)
1388 hook_iat                   53 Attempting to hook IAT for module 000000004A5E0000
1388 hook_iat                   54 Target is (null),WriteConsoleW (by_name=1)
1388 pe_info::iterate_imports  154 Checking imports in 'msvcrt.dll'
1388 pe_info::iterate_imports  154 Checking imports in 'ntdll.dll'
1388 pe_info::iterate_imports  154 Checking imports in 'KERNEL32.dll'
1388 hook_iat                   81 Found import at 000000004A6095F8 (value = 00000000776A2D80)
1388 hook_iat                   53 Attempting to hook IAT for module 000007FEC8780000
1388 hook_iat                   54 Target is (null),WriteConsoleW (by_name=1)
1388 pe_info::iterate_imports  154 Checking imports in 'VERSION.dll'
1388 pe_info::iterate_imports  154 Checking imports in 'SHLWAPI.dll'
1388 pe_info::iterate_imports  154 Checking imports in 'dbghelp.dll'
1388 pe_info::iterate_imports  154 Checking imports in 'KERNEL32.dll'
1388 hook_iat                   81 Found import at 000007FEC88380C8 (value = 00000000776A2D80)
1388 hook_iat                   53 Attempting to hook IAT for module 000000004A5E0000
1388 hook_iat                   54 Target is (null),GetEnvironmentVariableW (by_name=1)
1388 pe_info::iterate_imports  154 Checking imports in 'msvcrt.dll'
1388 pe_info::iterate_imports  154 Checking imports in 'ntdll.dll'
1388 pe_info::iterate_imports  154 Checking imports in 'KERNEL32.dll'
1388 hook_iat                   81 Found import at 000000004A609668 (value = 00000000776A80F0)
1388 hook_iat                   53 Attempting to hook IAT for module 000007FEC8780000
1388 hook_iat                   54 Target is (null),GetEnvironmentVariableW (by_name=1)
1388 pe_info::iterate_imports  154 Checking imports in 'VERSION.dll'
1388 pe_info::iterate_imports  154 Checking imports in 'SHLWAPI.dll'
1388 pe_info::iterate_imports  154 Checking imports in 'dbghelp.dll'
1388 pe_info::iterate_imports  154 Checking imports in 'KERNEL32.dll'
1388 hook_iat                   81 Found import at 000007FEC88381C8 (value = 00000000776A80F0)
1388 hook_setter::commit        88 <<< Hook transaction committed.
1388 hook_iat                   53 Attempting to hook IAT for module 000000004A5E0000
1388 hook_iat                   54 Target is (null),GetEnvironmentVariableW (by_name=1)
1388 pe_info::iterate_imports  154 Checking imports in 'msvcrt.dll'
1388 pe_info::iterate_imports  154 Checking imports in 'ntdll.dll'
1388 pe_info::iterate_imports  154 Checking imports in 'KERNEL32.dll'
1388 hook_iat                   81 Found import at 000000004A609668 (value = 000007FEC878D380)
1388 hook_setter::hook_setter   36 >>> Started hook transaction.
1388 hook_setter::add_detour   119 Attempting to hook ReadConsoleW in kernelbase.dll with 000007FEC878D6F0.
1388 hook_setter::add_detour   123 Unable to find ReadConsoleW in kernelbase.dll.
1388 hook_setter::commit        88 <<< Hook transaction committed.

I think the problem is 1388 hook_setter::add_detour 123 Unable to find ReadConsoleW in kernelbase.dll.

@nixxo nixxo closed this as completed Dec 14, 2020
@nixxo nixxo reopened this Dec 14, 2020
@nixxo
Copy link
Author

nixxo commented Dec 14, 2020

ups, clicked Close instead of comment.

@chrisant996
Copy link
Owner

Thank you for the logs! Yes, the problem is the failure to find ReadConsoleW in kernelbase.dll.

This looks like a Windows 7 compatibility issue in Clink.
I'll have to dig a bit to find a solution for Windows 7.

@chrisant996 chrisant996 added bug Something isn't working PRIORITY High priority labels Dec 17, 2020
@nixxo
Copy link
Author

nixxo commented Dec 17, 2020

I think, for the very little experience that I have, that ReadConsoleW does not exist in kernelbase.dll on win7 (at least on my machine)

I opened kernel32.dll with an hex editor and looked for the string ReadConsoleW and found it but doing so in kernelbase.dll gives no result.
Maybe on win7 you just have to hook on the kernel32.dll (like 0.4.9 clink) instead on hooking kernelbase.dll

I just checked downloading from here https://www.dll-files.com/kernelbase.dll.html the kernelbase.dll of win10 and the string ReadConsoleW is present in the dll. So microsoft moved some functions from kernel32 to kernelbase I suppose.

@chrisant996
Copy link
Owner

Thanks for saving me time by researching it for me!

Can you try v1.1.10?

I've made Clink try to hook ReadConsoleW in whichever of kernelbase.dll and kernel32.dll contain it (either or both). It's working on Win10 still, and I temporarily made some changes to emulate some aspects of if it were to run on Win7 and I think it will work on Win7 now.

@nixxo
Copy link
Author

nixxo commented Dec 17, 2020

It works:

1798 hook_setter::hook_setter   36 >>> Started hook transaction.
1798 hook_setter::add_detour   119 Attempting to hook ReadConsoleW in kernel32.dll with 000007FECAC2DAE0.
1798 add_repair_iat_node       135 Attempting to hook IAT for module 000007FECAC20000.
1798 add_repair_iat_node       143 Target is ReadConsoleW (by name).
1798 pe_info::iterate_imports  154 Checking imports in 'VERSION.dll'
1798 pe_info::iterate_imports  154 Checking imports in 'SHLWAPI.dll'
1798 pe_info::iterate_imports  154 Checking imports in 'dbghelp.dll'
1798 pe_info::iterate_imports  154 Checking imports in 'KERNEL32.dll'
1798 add_repair_iat_node       168 Found import at 000007FECACDC1C0 (value is 000000007723A610).
1798 hook_setter::commit        88 <<< Hook transaction committed.
1798 history_db::initialise    789 master bank ctag: |CTAG_1608233236_76284_5784_0
1798 history_db::compact       922 History:  0 active, 0 deleted

@chrisant996
Copy link
Owner

Excellent. Thank you for the fast confirmation!

@j-lecrivain
Copy link

Working wonderfully. Thanks you for fast fixing @chrisant996.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working PRIORITY High priority
Projects
None yet
Development

No branches or pull requests

3 participants