-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpluginloader.c
More file actions
39 lines (27 loc) · 824 Bytes
/
Copy pathpluginloader.c
File metadata and controls
39 lines (27 loc) · 824 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
/* SPDX-License-Identifier: GPL-2.0-or-later */
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "pluginloader.h"
void LoadPluginsFromDirectory(LPCWSTR directoryPath, PluginList *plugins)
{
HANDLE hFind;
WIN32_FIND_DATAW findData;
WCHAR searchPath[MAX_PATH];
plugins->count = 0;
wsprintfW(searchPath, L"%s\\*.dll", directoryPath);
hFind = FindFirstFileW(searchPath, &findData);
if(hFind == INVALID_HANDLE_VALUE)
return;
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);
}