Skip to content

Instantly share code, notes, and snippets.

@TymianekPL
Created April 18, 2022 10:53
Show Gist options
  • Save TymianekPL/950771256c69ec0230b930b3cd1bf229 to your computer and use it in GitHub Desktop.
Save TymianekPL/950771256c69ec0230b930b3cd1bf229 to your computer and use it in GitHub Desktop.
Gist for "How to make your own protocol" video (https://youtu.be/X8mzTqV58-U)
#include <stdio.h>
#include <string.h>
#include <Windows.h>
int main(int argc, char **argv)
{
if(argc != 2)
{
printf("That command requried 1 argument");
return 1;
}
char *protocol = strtok(argv[1], "://");
char *command = strtok(NULL, "://");
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(&si));
si.cb = sizeof(&si);
ZeroMemory(&pi, sizeof(&pi));
if(!CreateProcess(NULL, command, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{
printf("Process creation failed: %d", GetLastError());
getchar();
return 1;
}
getchar();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment