aboutsummaryrefslogtreecommitdiff
path: root/Patches/dllcall.h
blob: ab7b1283085cd8bc3ed114cbfc0efe4df6d7b9f5 (plain)
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
#ifndef __DLLCALL_H
#define __DLLCALL_H

#include "windows.h"

void loadeffect(HMODULE *lib, FARPROC *proc, char *name)
{
	if(*lib) FreeLibrary(*lib);

	*lib = LoadLibrary(name);
	if(!*lib)
	{
		post("loadeffect: failed to load %s", name);
		return;
	}
	*proc = GetProcAddress(*lib, "perform_effect");
	if(!*proc)
	{
		post("loadeffect: failed to get perform_effect from %s", name);
		FreeLibrary(*lib);
		*lib=NULL;
		return;
	}
}

void loadcopy(HMODULE *lib, FARPROC *proc, char *name)
{
	if(*lib) FreeLibrary(*lib);

	*lib = LoadLibrary(name);
	if(!*lib)
	{
		post("loadcopy: failed to load %s", name);
		return;
	}
	*proc = GetProcAddress(*lib, "perform_copy");
	if(!*proc)
	{
		post("loadcopy: failed to get perform_copy from %s", name);
		FreeLibrary(*lib);
		*lib=NULL;
		return;
	}
}

#endif