private static void ValidateInjectArgs(InjectArgs args) { ValidateOperationArgs(args); // embedding resource file should exist if (!File.Exists(args.ResourcePath)) { var message = string.Format(Localization.ValidateArgsResourceFile, args.ResourcePath); throw new IOException(message); } }
private static void WriteInjectOutput(InjectArgs args) { // load resource data var resourceData = ReadResource(args.ResourcePath); // try to copy pe TryCopySource(args.SourcePath, args.OutputPath); // update pe var updateHandle = BeginUpdateResource(args.OutputPath); using (var updateDisposable = new PInvoke.DisposableHandle(updateHandle, h => PInvoke.DiscardUpdateResource(updateHandle))) { UpdateResource(updateHandle, args.ResourceType, args.ResourceName, resourceData, args.OutputPath); CompleteUpdateResource(updateHandle, args.OutputPath); updateDisposable.SuppressDispose(); } }