Using a function from GetProcAddress

It seems comfortable sometimes to explicitly load a DLL, but the problem is i have no idea how to actually use the address GetProcAddress returns...that's my code so far and it seems to work till the commented part.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <windows.h>
#include <iostream>
using namespace std;

int main()
{

	char DLL  [] = "User32";
	char PROC [] = "MessageBoxA";
	
	HANDLE Proc;
	HMODULE hDLL;
	

	cout << "Attempting to load .DLL..." << endl;
	hDLL = LoadLibrary(DLL);
	
	if(hDLL == NULL)
	
		{
		cout << ".DLL load FAILED!!1" << endl;
		}

	else

		{

		cout << "DLL handle is: " << hDLL << endl<<endl;
		cout << "Attempting to get process address..." << endl;
		Proc = GetProcAddress(hDLL,PROC);
		
		if(Proc == NULL)
			{
			FreeLibrary(hDLL);
			cout << "Process load FAILED!!1" << endl;
			}

		else
			
			{
			cout << "Process address found at: " << Proc << endl << endl;
			//Proc(NULL,NULL,NULL,NULL);
			FreeLibrary(hDLL);
			}
		}	
	

return 0;
}


thx ahead :)
Last edited on
Topic archived. No new replies allowed.