Im trying to write a function that gets the address of MessageBoxA from a structure pointer that I pass to it and then uses that address to call MessageBoxA. The problem is that I try to call MessageBoxA 5 times with this method, but my program always crashes after 3 times and i have no idea why.
void code(struct ShellD * s)
{
s->pMsgBox(NULL,"s","s",MB_OK);
s->pMsgBox(NULL,"s","s",MB_OK);
s->pMsgBox(NULL,"s","s",MB_OK);
s->pMsgBox(NULL,"s","s",MB_OK);
s->pMsgBox(NULL,"s","s",MB_OK);
}
int main(int argc, char **argv)
{
struct ShellD SD;
SD.pMsgBox = GetProcAddress(LoadLibraryA("user32.dll"),"MessageBoxA");
code(&SD);
}