Code after GetProcAddress() line is not executable

57 views Asked by At

I created game.dll with exported main function, so when I call this function from GetProcAddress, I am running the infinite game loop and other stuff there, but I never reached lines below. If I am closing game window, this console game also closes. How I could do it asynchronously or what should I do?

#include <stdio.h> 
#include <windows.h> 
 
typedef int (*MYPROC)(LPTSTR); 
 
VOID main(VOID) 
{ 
    HINSTANCE hinstLib; 
    MYPROC ProcAdd; 
    BOOL fFreeResult, fRunTimeLinkSuccess = FALSE; 
 
    hinstLib = LoadLibrary(TEXT(" Game")); 
 
    if (hinstLib != NULL) 
    { 
        ProcAdd = (MYPROC) GetProcAddress(hinstLib, TEXT("GameStart")); 
 
        if (NULL != ProcAdd) 
        {
            fRunTimeLinkSuccess = TRUE;
            void(ProcAdd()); 
        }
 
        // never called stuff after running game
 
        fFreeResult = FreeLibrary(hinstLib); 
    }
 
    if (! fRunTimeLinkSuccess) 
        printf("Message via alternative method\n"); 
}

I tried to unlock the console application, while running the game, but can't figure out what should I do...

0

There are 0 answers