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
| #include <string>
#include <windows.h>
#include "common.h"
void *ReallocMaison(void *buffer, int nb) {
void *resultbuffer;
resultbuffer = realloc(buffer, nb * sizeof(char));
return resultbuffer;
}
int main() {
char *buffer;
tplug plugin;
HINSTANCE hHandle;
hHandle = LoadLibrary("Dll.dll");
if (hHandle == NULL) return 0;
plugin.PluginLoad = (pLoad) GetProcAddress (hHandle, "PluginLoad");
plugin.PluginUnload = (pUnload) GetProcAddress (hHandle, "PluginUnload");
plugin.PluginWork = (pWork) GetProcAddress (hHandle, "PluginWork");
plugin.pReallocMaison = &ReallocMaison;
plugin.PluginLoad();
buffer = (char *) malloc(3);
strcpy(buffer,"AAA");
plugin.PluginWork(&plugin, buffer);
printf("%s\n",buffer);
plugin.PluginUnload();
system("PAUSE");
return 0;
} |