Created
April 18, 2022 10:53
-
-
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)
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
#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