Created
November 8, 2023 12:18
-
-
Save phraemer/79361ae872f4f704ba9e50f9e9e7bdc2 to your computer and use it in GitHub Desktop.
A wrapper for inserting missing args to signtool. E.g. PACE wraptool does not pass /fd
This file contains hidden or 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
#include <iostream> | |
#include <fstream> | |
#include <vector> | |
int main(int argc, char* argv[]) | |
{ | |
// Print out the build date and time | |
std::cout << "frankensign build: " << __DATE__ << " " << __TIME__ << std::endl; | |
std::cout << "called with args: " << std::endl; | |
// Store the passed arguments in a vector | |
std::vector<std::string> args; | |
for (int i = 1; i < argc; ++i) | |
{ | |
std::cout << ' ' << argv[i]; | |
args.push_back(argv[i]); | |
} | |
std::cout << std::endl; | |
// Insert "/fd SHA256" before /t | |
args.insert(std::find(args.begin(), args.end(), "/t"), "/fd SHA256"); | |
// Build the command to call signtool.exe | |
std::string command = "\"C:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.22621.0\\x64\\signtool.exe\""; | |
for (const auto& arg : args) | |
{ | |
command += " " + arg; | |
} | |
// Call signtool.exe | |
const auto exit_code = std::system(command.c_str()); | |
if (exit_code == 0) | |
{ | |
std::cout << "Success!" << std::endl; | |
} | |
else | |
{ | |
std::cout << "Failed!" << std::endl; | |
} | |
return exit_code; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment