86 lines
2.6 KiB
C++
Raw Normal View History

2024-05-03 01:54:36 +08:00
#pragma comment(linker, "/subsystem:windows /entry:wmainCRTStartup")
2024-01-08 23:37:00 +08:00
2024-04-02 15:36:52 +08:00
int dllinjectwmain(int argc, wchar_t *argv[]);
int ntleaswmain(int argc, wchar_t *wargv[]);
2024-05-03 22:31:17 +08:00
int updatewmain(int argc, wchar_t *wargv[]);
2024-03-23 18:33:58 +08:00
bool checkisapatch();
2024-01-08 23:37:00 +08:00
#ifndef _WIN64
2024-08-11 19:29:37 +08:00
// int mainmp3(int argc, wchar_t *argv[]);
2024-04-02 15:36:52 +08:00
int LRwmain(int argc, wchar_t *argv[]);
int jbjwmain(int argc, wchar_t *argv[]);
int dreyewmain(int argc, wchar_t *argv[]);
int kingsoftwmain(int argc, wchar_t *argv[]);
int voiceroid2wmain(int argc, wchar_t *argv[]);
int lewmain(int argc, wchar_t *argv[]);
int neospeech(int argc, wchar_t *argv[]);
int neospeechlist(int argc, wchar_t *argv[]);
2024-07-09 21:20:21 +08:00
int eztrans(int argc, wchar_t *argv[]);
2024-09-12 21:01:26 +08:00
int atlaswmain(int argc, wchar_t *argv[]);
2024-01-08 23:37:00 +08:00
#else
#endif // !_WIN64
2024-04-02 15:36:52 +08:00
void listprocessmodule_1(std::ofstream &of, DWORD processPID)
{
DWORD need;
2024-01-08 23:37:00 +08:00
HMODULE modules1[1] = {};
HANDLE hProcess = ::OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processPID);
if (hProcess)
{
2024-04-02 15:36:52 +08:00
if (EnumProcessModules(hProcess, modules1, sizeof(modules1), &need) == 0)
return;
2024-01-08 23:37:00 +08:00
auto modules = std::make_unique<HMODULE[]>(need / sizeof(HMODULE));
2024-04-02 15:36:52 +08:00
if (EnumProcessModules(hProcess, modules.get(), need, &need) == 0)
return;
for (int i = 0; i < need / sizeof(HMODULE); i++)
{
wchar_t fileName[MAX_PATH] = {0};
2024-01-08 23:37:00 +08:00
GetModuleFileNameExW(hProcess, modules.get()[i], fileName, sizeof(fileName));
2024-04-02 15:36:52 +08:00
auto s = std::wstring(fileName);
of.write((char *)s.c_str(), s.size() * 2);
of.write((char *)L"\n", 2);
2024-01-08 23:37:00 +08:00
}
2024-04-02 15:36:52 +08:00
}
2024-01-08 23:37:00 +08:00
}
2024-04-02 15:36:52 +08:00
int listprocessmodule(int argc, wchar_t *argv[])
{
std::ofstream of(argv[1], std::ios_base::binary);
for (int i = 2; i < argc; i++)
{
auto pid = std::stoi(argv[i]);
listprocessmodule_1(of, pid);
2024-01-08 23:37:00 +08:00
}
of.close();
return 0;
}
2024-04-02 15:36:52 +08:00
int wmain(int argc, wchar_t *argv[])
2024-01-08 23:37:00 +08:00
{
2024-04-02 15:36:52 +08:00
if (checkisapatch())
return 1;
2024-01-08 23:37:00 +08:00
auto argv0 = std::wstring(argv[1]);
2024-07-08 22:25:59 +08:00
typedef int (*wmaint)(int, wchar_t **);
std::map<std::wstring, wmaint> fm = {
{L"dllinject", dllinjectwmain},
{L"ntleas", ntleaswmain},
{L"listpm", listprocessmodule},
{L"update", updatewmain},
2024-01-08 23:37:00 +08:00
#ifndef _WIN64
2024-08-11 19:29:37 +08:00
// {L"mainmp3", mainmp3},
2024-07-08 22:25:59 +08:00
{L"LR", LRwmain},
{L"le", lewmain},
{L"jbj7", jbjwmain},
{L"dreye", dreyewmain},
{L"kingsoft", kingsoftwmain},
{L"voiceroid2", voiceroid2wmain},
{L"neospeech", neospeech},
{L"neospeechlist", neospeechlist},
2024-07-09 21:20:21 +08:00
{L"eztrans", eztrans},
2024-09-12 21:01:26 +08:00
{L"atlaswmain", atlaswmain},
2024-01-08 23:37:00 +08:00
#else
2024-07-08 22:25:59 +08:00
2024-01-08 23:37:00 +08:00
#endif // !_WIN64
2024-07-08 22:25:59 +08:00
};
return fm[argv0](argc - 1, argv + 1);
2024-01-08 23:37:00 +08:00
}