-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
943 additions
and
920 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,21 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.CommandLine; | ||
using System.IO; | ||
|
||
var binOption = new Option<FileInfo>( | ||
name: "--bin", | ||
description: "Binary data to attach to the image"); | ||
var imageOption = new Option<FileInfo>( | ||
name: "--image", | ||
description: "PE image to add the binary resource into"); | ||
var nameOption = new Option<string>( | ||
name: "--name", | ||
description: "Resource name"); | ||
var rootCommand = new RootCommand("Inject native resources into a Portable Executable image"); | ||
rootCommand.AddOption(binOption); | ||
rootCommand.AddOption(imageOption); | ||
rootCommand.AddOption(nameOption); | ||
CliOption<FileInfo> binOption = new("--bin") { Description = "Binary data to attach to the image" }; | ||
CliOption<FileInfo> imageOption = new("--image") { Description = "PE image to add the binary resource into" }; | ||
CliOption<string> nameOption = new("--name") { Description = "Resource name" }; | ||
CliRootCommand rootCommand = new("Inject native resources into a Portable Executable image"); | ||
rootCommand.Options.Add(binOption); | ||
rootCommand.Options.Add(imageOption); | ||
rootCommand.Options.Add(nameOption); | ||
|
||
rootCommand.SetHandler((FileInfo binaryData, FileInfo peImage, string name) => | ||
{ | ||
using ResourceUpdater updater = new(peImage); | ||
updater.AddBinaryResource(name, File.ReadAllBytes(binaryData.FullName)); | ||
}, | ||
binOption, | ||
imageOption, | ||
nameOption); | ||
rootCommand.SetAction(result => | ||
{ | ||
using ResourceUpdater updater = new(result.GetValue(imageOption)!); | ||
updater.AddBinaryResource(result.GetValue(nameOption)!, File.ReadAllBytes(result.GetValue(binOption)!.FullName)); | ||
}); | ||
|
||
return rootCommand.Invoke(args); | ||
return new CliConfiguration(rootCommand).Invoke(args); |
Oops, something went wrong.