This post put me on the track of loading an exe from a resource, but I haven't been able to find out how to start running the executable after LockResource
.
Do I need to use the memory address returned from LockResource
, and then run it somehow like that?
I will be loading a SUBSYSTEM:CONSOLE
program into a SUBSYSTEM:SYSTEM
program in my end program, but I would like to know the more basic way of two SUBSYSTEM:CONSOLE
programs, as the knowledge will be useful anyway.
Code:
#include <windows.h>
#include <iostream>
#include "resource.h"
HGLOBAL hResLoad; // handle to loaded resource
HRSRC hRes; // handle/ptr. to res. info. in hExe
LPVOID lpResLock; // pointer to resource data
int main() {
hRes = FindResource(NULL, MAKEINTRESOURCE(IDR_MYFILE), RT_RCDATA);
hResLoad = LoadResource(hExe, hRes);
lpResLock = LockResource(hResLoad);
}
Thanks in advance.