2018-07-12 08:18:04 +08:00
|
|
|
#include "Extensions.h"
|
2018-05-25 16:34:40 +08:00
|
|
|
#include <Windows.h>
|
|
|
|
#include <map>
|
2018-07-12 08:18:04 +08:00
|
|
|
#include <vector>
|
2018-05-25 16:34:40 +08:00
|
|
|
|
|
|
|
std::map<DWORD, ExtensionFunction> extensionFunctions;
|
|
|
|
|
|
|
|
void LoadExtensions()
|
|
|
|
{
|
|
|
|
wchar_t path[MAX_PATH];
|
|
|
|
wchar_t* end = path + GetModuleFileNameW(nullptr, path, MAX_PATH);
|
|
|
|
while (*(--end) != L'\\');
|
|
|
|
*(end + 1) = L'*';
|
|
|
|
*(end + 2) = L'\0';
|
|
|
|
WIN32_FIND_DATAW fileData;
|
|
|
|
HANDLE file = FindFirstFileW(path, &fileData);
|
|
|
|
do
|
|
|
|
{
|
2018-07-12 08:18:04 +08:00
|
|
|
if (!(fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
2018-05-25 16:34:40 +08:00
|
|
|
{
|
2018-05-26 18:48:14 +08:00
|
|
|
if (wcsstr(fileData.cFileName, L"_nexthooker_extension.dll"))
|
2018-05-25 16:34:40 +08:00
|
|
|
{
|
2018-07-12 08:18:04 +08:00
|
|
|
extensionFunctions[wcstoul(fileData.cFileName, nullptr, 10)] = (ExtensionFunction)GetProcAddress(LoadLibraryW(fileData.cFileName), "NewSentence");
|
2018-05-25 16:34:40 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (FindNextFileW(file, &fileData) != 0);
|
|
|
|
}
|
|
|
|
|
2018-07-12 08:18:04 +08:00
|
|
|
std::wstring DispatchSentenceToExtensions(std::wstring sentence, DWORD64 info)
|
2018-05-25 16:34:40 +08:00
|
|
|
{
|
|
|
|
for (auto extension : extensionFunctions)
|
|
|
|
{
|
2018-07-12 08:18:04 +08:00
|
|
|
sentence = extension.second(sentence, info);
|
2018-05-25 16:34:40 +08:00
|
|
|
}
|
2018-07-12 08:18:04 +08:00
|
|
|
return sentence;
|
2018-05-25 16:34:40 +08:00
|
|
|
}
|