forked from Frans-Willem/CsrSpiDrivers
-
Notifications
You must be signed in to change notification settings - Fork 102
/
dllmain.c
36 lines (30 loc) · 1023 Bytes
/
dllmain.c
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 <windows.h>
#include "spi.h"
typedef uint32_t (pttrans_get_version_t)(void);
/* Public variable */
uint32_t pttrans_api_version = 0;
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
HMODULE pttdll;
pttrans_get_version_t *pttrans_get_version;
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinstDLL);
/* Detect SPI API version by calling a function from pttransport.dll */
if ((pttdll = GetModuleHandle("pttransport.dll"))) {
if ((pttrans_get_version = (pttrans_get_version_t *)GetProcAddress(pttdll,
"pttrans_get_version")))
{
pttrans_api_version = pttrans_get_version();
pttrans_get_version = NULL;
pttdll = NULL;
}
}
break;
case DLL_PROCESS_DETACH:
spi_deinit();
break;
}
return TRUE;
}