-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpluginloader.c
More file actions
40 lines (28 loc) · 844 Bytes
/
pluginloader.c
File metadata and controls
40 lines (28 loc) · 844 Bytes
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
/* SPDX-License-Identifier: GPL-2.0-or-later */
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "pluginloader.h"
PluginsLoaded LoadPluginsFromDirectory(LPCWSTR directoryPath)
{
HANDLE hFind;
WIN32_FIND_DATAW findData;
WCHAR searchPath[MAX_PATH];
PluginsLoaded plugins = {0};
wsprintfW(searchPath, L"%s\\*.dll", directoryPath);
hFind = FindFirstFileW(searchPath, &findData);
if(hFind == INVALID_HANDLE_VALUE)
return plugins;
do
{
if(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
continue;
WCHAR fullDllPath[MAX_PATH];
wsprintfW(fullDllPath, L"%s\\%s", directoryPath, findData.cFileName);
HMODULE hMod = LoadLibraryW(fullDllPath);
if(hMod && plugins.count < 128)
plugins.hModules[plugins.count++] = hMod;
}
while(FindNextFileW(hFind, &findData));
FindClose(hFind);
return plugins;
}