Skip to content

[BUG] First argument is skipped #7

Closed

Description

@dreamwhite

Good morning and thank you so much for writing this tool.
I'm using it and despite it serves the same purpose as modGRUBShell.efi it's way more portable (especially when having ESPs with low space issues).

Anyway, I'm experiencing a weird bug while trying to execute the tool via OpenCore. I don't know if you ever had any Hackintoshing experience in the past or not, but basically it's a bootloader and for what concerns us, it can be used also for creating custom tools entries (e.g. CFG Lock unlock entry which runs .\setup_var.efi CFG_LOCK_OFFSET 0x00 -n VarStoreId).

What basically happens is that after adding the tool in the bootloader configuration file, it skips the first argument.

Below the code that I added to the bootloader configuration file:

<dict>
	<key>Arguments</key>
	<string>0x527 0x00 -n Setup</string>
	<key>Auxiliary</key>
	<true/>
	<key>Comment</key>
	<string>UEFI command-line tool for read/write access of variables - CFG Lock unlock</string>
	<key>Enabled</key>
	<true/>
	<key>Flavour</key>
	<string>Auto</string>
	<key>FullNvramAccess</key>
	<true/>
	<key>Name</key>
	<string>setup_var - CFG Unlock</string>
	<key>Path</key>
	<string>setup_var.efi</string>
	<key>RealPath</key>
	<true/>
	<key>TextMode</key>
	<true/>
</dict>

What concerns us is the Arguments key with the value 0x527 0x00 -n Setup. If I run that custom entry, it doesn't write in the offset but rather reads the value of 0x00 under Setup VarStoreName, so it skips the first argument.

I already discussed this with the devs of the bootloader (you can read more here), and they pointed out this line which may be the reason of the bug.

The only way I could find to temporarily fix it is adding .\setup_var.efi (potentially can be literally any string, as it doesn't need to be any particular value) so the tool correctly parses the argument.

Do you think this can be fixed? Thank you so much and have a great day

--
dreamwhite

Activity

  1. dreamwhite commented on Dec 16, 2022

    @dreamwhite
    Author

    I temporarily commented line 172 and the tool works using OpenCore, but if I try running it from a UEFI shell (such as OpenShell.efi) then it raises the following error:

    image

    I'm definitely not a RUST nor a UEFI developer, but I think the right thing to do is:

    • if booting from a UEFI shell environment, then skip the first argument
    • if booting via other methods, such as OpenCore, then don't skip the first argument
  2. datasone commented on Dec 22, 2022

    @datasone
    Owner

    I've added some checks to mitigate this problem in 0.2.0.
    In short, if the program detects the first arg as a named argument (i.e. starts with '-'), or as a valid number, it will not drop it. Though it's a simple check, I think it could cover most common cases.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions