/*
test_caller.cpp
*/
#include <windows.h>
#include <stdio.h>
#include "test_dll.h"
#define LIBNAME "test_dll.dll"
#define FUNC_TEST "test"
typedef int (WINAPI *func_test)(int);
int main(int ac, char **av)
{
HMODULE hmodule = LoadLibrary(LIBNAME);
if(!hmodule){
fprintf(stderr
, "cannot load module: %s\n", LIBNAME
); return 1;
}
func_test test = (func_test)GetProcAddress(hmodule, FUNC_TEST);
if(!test){
fprintf(stderr
, "cannot get proccess: %s\n", FUNC_TEST
); return 2;
}
fprintf(stdout
, "test: %d\n", test
(6)); FreeLibrary(hmodule);
return 0;
}
LyoKICB0ZXN0X2NhbGxlci5jcHAKKi8KCiNpbmNsdWRlIDx3aW5kb3dzLmg+CiNpbmNsdWRlIDxzdGRpby5oPgoKI2luY2x1ZGUgInRlc3RfZGxsLmgiCgojZGVmaW5lIExJQk5BTUUgInRlc3RfZGxsLmRsbCIKCiNkZWZpbmUgRlVOQ19URVNUICJ0ZXN0Igp0eXBlZGVmIGludCAoV0lOQVBJICpmdW5jX3Rlc3QpKGludCk7CgppbnQgbWFpbihpbnQgYWMsIGNoYXIgKiphdikKewogIEhNT0RVTEUgaG1vZHVsZSA9IExvYWRMaWJyYXJ5KExJQk5BTUUpOwogIGlmKCFobW9kdWxlKXsKICAgIGZwcmludGYoc3RkZXJyLCAiY2Fubm90IGxvYWQgbW9kdWxlOiAlc1xuIiwgTElCTkFNRSk7CiAgICByZXR1cm4gMTsKICB9CiAgZnVuY190ZXN0IHRlc3QgPSAoZnVuY190ZXN0KUdldFByb2NBZGRyZXNzKGhtb2R1bGUsIEZVTkNfVEVTVCk7CiAgaWYoIXRlc3QpewogICAgZnByaW50ZihzdGRlcnIsICJjYW5ub3QgZ2V0IHByb2NjZXNzOiAlc1xuIiwgRlVOQ19URVNUKTsKICAgIHJldHVybiAyOwogIH0KICBmcHJpbnRmKHN0ZG91dCwgInRlc3Q6ICVkXG4iLCB0ZXN0KDYpKTsKICBGcmVlTGlicmFyeShobW9kdWxlKTsKICByZXR1cm4gMDsKfQ==