Skip to content

Instantly share code, notes, and snippets.

@dockimbel
Created August 23, 2012 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dockimbel/3435800 to your computer and use it in GitHub Desktop.
Save dockimbel/3435800 to your computer and use it in GitHub Desktop.
DLL loading testing program
#include "stdafx.h"
#include <Windows.h>
int (*foo)(int) = NULL;
int _tmain(int argc, _TCHAR* argv[])
{
HMODULE handle = LoadLibraryA("temp.dll");
printf("error: %i\n", GetLastError());
printf("hModule: %i\n", handle);
foo = (int (*)(int)) GetProcAddress(handle, "f1");
printf("error: %i\n", GetLastError());
printf("&f1: %x\n", foo);
printf("%i\n", foo(123));
printf("error: %i\n", GetLastError());
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment