I am trying to fopen a file into a file buffer and then create a new process with it. I was trying ASM to goto the start of the file but sadly because of windows it wouldn't actually do anything because all of the information on the top of a windows executable. So I tried to create a new process, and I am not to good with the windows API. Can anyone tell me what I am doing wrong?
#include <stdio.h>
#include <windows.h>
#include <WinBase.h>
char *file0_buffer;
int file0_size;
STARTUPINFO si;
PROCESS_INFORMATION pi;
int main(int argc, char **argv){
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
FILE *file0 = fopen("./input.exe", "rb");
if(file0 == NULL){printf("fopen file0 error"); getchar(); return 0;}
fseek(file0, 0, SEEK_END);
file0_size = ftell(file0);
rewind(file0);
file0_buffer = (char*)malloc(file0_size);
fread(file0_buffer, sizeof(char), file0_size, file0);
fclose(file0);
CreateProcess(NULL, NULL, NULL, NULL, TRUE, CREATE_DEFAULT_ERROR_MODE, &file0_buffer, NULL, &si, &pi);
getchar(); return 0;
}