Dynamically linking libraries
I've searched and read. Most of everything was repetetive and I've learned this much:
Code:
typedef VOID (*MYPROC)(LPTSTR); // <- Pt. 1
MYPROC Function;
HINSTANCE hInstLib;
hInstLib = LoadLibrary("whatever.dll");
if (hInstLib != NULL)
{
Function = (MYPROC)GetProcAddress(hInstLib, "functionname");
if (Function == NULL)
return 0;
}
Function("string?");
FreeLibrary(hInstLib);
Now, where I've labeled Pt. 1, I have a few questions. I'm just guessing here, but it looks like we're defining MYPROC to be similar to a function. Such that the VOID means the function in the dll returns nothing, and the LPTSTR is a parameter. What about more parameters? (I've never used typedef before and not too sure of its capabilities)
Code:
typedef VOID (*MYPROC)(LPTSTR)(INT iSize);
//or
typedef VOID (*MYPROC)(LPTSTR, INT iSize);
//or can you only have one parameter?
More questions about the dll files. What if you don't know the names of the functions? I'm hoping there might be a way to get an array of pointers to all functions. Also, what about finding the number of parameters/parameter types of a function?
It would seem that if I'm going to call a dll function, that I would know the name, parameters and what it does. But I have the urge to load random dll files, call functions and find out what they do. I know it's dangerous, but I'm in the mood to take a risk. Any information would be of great help.