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

Scoop style shims #2174

Open
TheCakeIsNaOH opened this issue Jan 12, 2021 · 18 comments
Open

Scoop style shims #2174

TheCakeIsNaOH opened this issue Jan 12, 2021 · 18 comments

Comments

@TheCakeIsNaOH
Copy link
Member

This is a request is to support scoop style shims, in addition to the currently supported shimgen style shims.

Presumably using the new c++ shim available here: https://github.com/kiennq/scoop-better-shimexe/

This type of shim works by having one compiled binary and simply copying it to the directory that is on the path, renaming it to whatever you want the shim to be called, and creating a .shim text file that has the path to the original executable you want to shim, and any arguments for the original executable.

The advantages of this type of shim:

The disadvantages of this type of shim:

  • Requires .shim files next to the actual shim.
  • Probably others, but I haven't played around with this type of shim to know if there are other edge cases.
@ferventcoder
Copy link
Member

You know we already have shims? And they copied the idea from us - so the title of this is interesting.

@ferventcoder
Copy link
Member

Copied and enhanced, the best form of flattery. 👍

@TheCakeIsNaOH
Copy link
Member Author

I'm working on a drop in replacement for the current shimgen.exe:
https://github.com/TheCakeIsNaOH/scoop-style-shimgen

@WenceyWang
Copy link

Using this type of shim also has the advantage that current shimgen is trying to read metadata from the targeted exe and use some of the string inside to generate code without even escaping it, which causes easy-to-see security issues. (https://github.com/chocolatey/shimgen/issues/59)

@WenceyWang
Copy link

I'm working on a drop in replacement for the current shimgen.exe: https://github.com/TheCakeIsNaOH/scoop-style-shimgen

And I think it's not necessary to implement the GUI option as it's not being used in choco at all: https://github.com/chocolatey/choco/blob/develop/src/chocolatey/infrastructure.app/services/ShimGenerationService.cs#L74

@TheCakeIsNaOH
Copy link
Member Author

@ImportTaste
Copy link

ImportTaste commented Jan 18, 2022

Given it's not thoroughly tested yet (as listed in Disadvantages), would it not be appropriate to supply a compilation in the Releases section?

Also, what's your impression of this project? https://github.com/71/scoop-better-shimexe It seems like it accomplishes just about all the same things, and it has been thoroughly tested. Like your project, it's also MIT licensed. The only thing it seems to lack is the GUI option.

Why not integrate that project's code since it has been thoroughly tested? You could add what it lacks easily enough, I'm sure.

@TheCakeIsNaOH
Copy link
Member Author

TheCakeIsNaOH commented Jan 18, 2022

would it not be appropriate to supply a compilation in the Releases section?

As I noted above, I'm still working on it, so I'm not quite ready for a proper release yet.

Why not integrate that project's code since it has been thoroughly tested? You could add what it lacks easily enough, I'm sure.

The shim is based on that project's code:
image
image

It's the shimgen.exe part that primarily needs to testing, not the shim.exe as much.

@ImportTaste
Copy link

ImportTaste commented Jan 18, 2022

would it not be appropriate to supply a compilation in the Releases section?

As I noted above, I'm still working on it, so I'm not quite ready for a proper release yet.

Why not integrate that project's code since it has been thoroughly tested? You could add what it lacks easily enough, I'm sure.

The shim is based on that project's code:

It's the shimgen.exe part that primarily needs to testing, not the shim.exe as much.

I'm not entirely sure I understand the need to convert the primary shim code to cpp, is there something I'm missing there?

((Also, ouch, light theme screenshots hurt. You should really use Github's dark theme.))

@RichiCoder1
Copy link
Member

RichiCoder1 commented Jan 18, 2022

I'm not entirely sure I understand the need to convert the primary shim code to cpp, is there something I'm missing there?

In theory, two parts:

  1. Startup Speed/overheard. Zero overhead from dotnet, in theory could be replicated via Self-contained/R2R.
  2. Binary Size (compared to self-contained)

@TheCakeIsNaOH
Copy link
Member Author

I'm not entirely sure I understand the need to convert the primary shim code to cpp, is there something I'm missing there?

Are you talking about the 71 shim written in C being rewritten in CPP by kiennq?

There is apparently a memory bug in the C version: 71/scoop-better-shimexe#9
And I known CPP better, so that is what I went with.

@ImportTaste
Copy link

I'm not entirely sure I understand the need to convert the primary shim code to cpp, is there something I'm missing there?

In theory, two parts:

  1. Startup Speed/overheard. Zero overhead from dotnet, in theory could be replicated via Self-contained/R2R.
  2. Binary Size (compared to self-contained)

I was referring the conversion from C to CPP

@pauby
Copy link
Member

pauby commented Jan 19, 2022

@ImportTaste We're going a little off-topic here. If we need to debate the why's and language specifics, I think that should be discussed in the repository it's being created in rather than here.

@ImportTaste
Copy link

@ImportTaste We're going a little off-topic here. If we need to debate the why's and language specifics, I think that should be discussed in the repository it's being created in rather than here.

I don't see why a question relating to the performance of the replacement shims wouldn't be relevant, considering the main sticking point of this issue is the poor performance of ShimGen.

However, having seen this comment: 71/scoop-better-shimexe#9 (comment) and having compiled both myself (using x64_x86 to compile a 32-bit binary, the C version is 114kb; the C++ version is 121kb, a trivial difference), I'm now convinced that @TheCakeIsNaOH is making the right call here.

@pauby
Copy link
Member

pauby commented Jan 19, 2022

I don't see why a question relating to the performance of the replacement shims wouldn't be relevant, considering the main sticking point of this issue is the poor performance of ShimGen.

The replacement that is being discussed is not a Chocolatey project and this repository is for Choco issues, not Shimgen issues or it's replacement.

@chocolatey chocolatey deleted a comment from ImportTaste Jan 19, 2022
@WenceyWang
Copy link

I think we can make a choco package containing the better-shimgen and just replace the original shimgen while installing and place it back while uninstalling.
I have been doing so in my domain with a C# shimgen written by myself and everything works fine so far.

@TheCakeIsNaOH
Copy link
Member Author

I think we can make a choco package containing the better-shimgen and just replace the original shimgen while installing and place it back while uninstalling.

This would not be allowed on the community repository, at least not without a special exemption.

It should work, it is what I would do to distribute it internally for testing most likely.

@pauby
Copy link
Member

pauby commented Jan 20, 2022

Just to confirm what @TheCakeIsNaOH said, we wouldn't permit a package like this on the Community Repository as those packages should not make any changes to any Chocolatey folders or the content within in (other than their package folder).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants