-
-
Notifications
You must be signed in to change notification settings - Fork 39
Add sendCtrlC method #49
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
Conversation
|
Added a commit that moves the ctrl+C sending into a separate executable. I like this better. |
|
Done. Please review. |
|
Taking the justification, the approach looks reasonable to me. Otherwise it will unlikely work in Jenkins, but I have not checked it so far |
|
Yes! The EXE file needs to live next to the DLL file. So, when we unpack the DLL, we should unpack the EXE as well. |
oleg-nenashev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requesting changes according to the discussion above
|
I finally got around to working on this today. Please take a look. I'll need to do more testing. |
native/winp.cpp
Outdated
| si.cb = sizeof(si); | ||
| ZeroMemory(&pi, sizeof(pi)); | ||
|
|
||
| std::wstring exepath = GetDllFilename(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can remove code for GetDllFilename again
|
Done with testing. DLL and EXE are extracted alright and the sendCtrlC() method works. |
oleg-nenashev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some local testing yesterday. Yes, it seems to work well
|
Thanks for your help! |
|
@oleg-nenashev do you have a timeline for the release of the next version of WinP and can this pull request be included? I'd like to move forward with the change to Jenkins and need a new WinP for that. I appreciate your help. |
|
Hi @stephanreiter . I didn't forget about it. I was doing some internal review of the EXE introduction risks. If it helps, I am happy to ship an alpha version so that I unblock your follow-up PR |
|
That'd be nice, Oleg, but I don't want to generate extra work for you. I am glad to hear that you're making sure this change doesn't break anything in WinP and I'll be happy to wait for a release when the time is here. I was just wondering when that might be. Planning summer activities at work ... :) |
|
I have tested the build locally in a cycle, and it seems the test is flaky. |
|
So it fails to attach to the console sometimes. I will improve the diagnostics messaging |
Hi! I'd like to discuss adding a sendCtrlC method to a WinProcess, which I'd need to address a defect in Jenkins (JENKINS-17116) in pull request jenkinsci/jenkins#3414
Sending Ctrl+C is super awkward on Windows. Essentially we have to attach to the target's console, generate the Ctrl+C event, and detach again. That is only safe if we do it in a separate process that has only this purpose.
In the code below I am adding a function that can be called by rundll32 to winp.dll, which does exactly that.
There's a downside to this though: rundll32 is seen as suspicous by many anti-virus solutions, so the invocation might be blocked. What's even worse is that in this case rundll32 might show a message box that access was blocked, which is not acceptable.
The only solution is to not bake the Ctrl+C sending code into winp.dll, but into a separate exe.
Can we ship that exe with the jar and make the DLL call it? The DLL manages to find itself in the filesystem, so if our new exe was placed next to it, we could determine its path as well.
Thanks for taking a look!