-
Notifications
You must be signed in to change notification settings - Fork 125
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
Injecting Clink from shim #437
Comments
Clink has to know what process to inject into. If you don't specify one via Since you're using an .exe shim, the shim is the parent process. But no process id was specified, and the Clink cannot inject into the shim process, so it fails. "Unknown host 'clink.exe'" means "clink.exe is not cmd.exe, so can't inject into clink.exe". The reason it selects Let's back up a few steps: What was the motivation for trying to use scoop-better-shimexe? Any attempt to use an exe shim for Clink will force the OS mode to use the same CPU emulation mode as the exe itself. E.g. on an ARM device, if the exe shim is x64, then the exe shim will force x64 mode even though the CPU is natively ARM64 and even if the original cmd.exe that invoked the shim was ARM64. That's the whole reason Clink has its own If you can share what problem was encountered, maybe there's a better way to solve the problem than creating an exe shim (which will inherently cause other problems). |
Having my profile path automatically included in the arguments without having to edit the batch file. |
If you want to always use a particular profile, have you considered setting |
I knew about it, but using a shim was more appealing to me. Oh well. |
@ImportTaste You can still use a shim. Just not an exe shim. Or if you want to use an exe shim, then you need to make the shim find its parent process and pass that via Or you can simply make your own separate @c:\clink\bin\clink.bat --profile c:\clink\usr %* I think there are several easy ways to get exactly the behavior you want, without using |
I forgot I never replied to this, but here is the launch script I ended up with. I think it's very neat and tidy, so hopefully it will be of help to someone else. @ECHO OFF & SETLOCAL
::Config
SET "_clinkBin=CLINK EXE DIR WITHOUT QUOTES GOES HERE"
SET "_clinkUsr=PROFILE DIR WITHOUT QUOTES GOES HERE"
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
IF ["%*"]==[""] SET "_clinkArg=inject"
IF ["%*"]==["--quiet"] SET "_clinkArg=inject --quiet"
IF NOT DEFINED _clinkArg SET "_clinkArg=%*"
SET "_clinkExe=%_clinkBin%\clink_x%PROCESSOR_ARCHITECTURE:~-2%.exe"
CALL:WIN+R_Test "%~f0"
IF %ERRORLEVEL% EQU 0 (
ENDLOCAL ^
& WMIC.exe PROCESS CALL CREATE ^
"cmd.exe /K SET \"CLINK_PROFILE=%_clinkUsr%\" & \"%_clinkExe%\" %_clinkArg%" >NUL ^
|| PAUSE
) ELSE (
ENDLOCAL ^
& SET "CLINK_PROFILE=%_clinkUsr%" ^
& "%_clinkExe%" %_clinkArg%"
)
EXIT /B 0
:WIN+R_Test
SETLOCAL
SET "_test=%CMDCMDLINE%"
<NUL SET /P="%_test:"=:%" ^
| findstr.exe /B /C:"%COMSPEC% /c ::%~1%: " >NUL
ENDLOCAL & EXIT /B %ERRORLEVEL% The Win+R part refers to the Run window that comes up from that Windows shortcut. If the batch file is on the PATH environment variable, or you insert the full path of the batch file, it'll create a new window that won't immediately close after launch. |
I'm using this repo's shim implementation: https://github.com/kiennq/scoop-better-shimexe
My clink.shim file reads as thus:
When I try the command
clink.exe inject
(clink.exe being the shim), it spits out the following error:#
symbolCalling
C:\Clink\bin\clink_x64.exe --profile "C:\Clink\usr"
directly works correctly, however, so there's something about the way Clink is coded that makes it not work correctly when called from a shim.I tried changing the path to
C:\Clink\bin\clink.bat
, but ran into two problems.clink_x86.exe
instead ofclink_x64.exe
.'"C:\Clink\\clink_x64.exe"' is not recognized as an internal or external command, operable program or batch file.
clink_x86.exe
instead.Here are the shim files (
clink.exe
&clink.shim
): clink_shim.zipThe text was updated successfully, but these errors were encountered: