2019-06-07 02:24:28 -04:00
|
|
|
|
#include "common.h"
|
2019-06-09 08:10:44 -04:00
|
|
|
|
#include "defs.h"
|
2019-06-07 02:24:28 -04:00
|
|
|
|
#include "resource.h"
|
2019-06-10 22:23:06 -04:00
|
|
|
|
#include <filesystem>
|
|
|
|
|
#include <fstream>
|
|
|
|
|
#include <sstream>
|
2019-07-16 21:55:40 +05:30
|
|
|
|
#include <QApplication>
|
2019-06-07 02:24:28 -04:00
|
|
|
|
|
|
|
|
|
wchar_t buffer[1000] = {};
|
|
|
|
|
std::array<int, 10> vars = {};
|
2019-08-06 11:41:49 -04:00
|
|
|
|
int& mode = vars.at(0);
|
2019-06-07 02:24:28 -04:00
|
|
|
|
|
2019-07-16 21:55:40 +05:30
|
|
|
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int _)
|
2019-06-07 02:24:28 -04:00
|
|
|
|
{
|
2019-07-16 21:55:40 +05:30
|
|
|
|
QApplication a(_ = 0, DUMMY);
|
2019-08-06 11:41:49 -04:00
|
|
|
|
static std::vector<std::unique_ptr<std::remove_pointer_t<HMODULE>, Functor<FreeLibrary>>> extensions;
|
2019-06-10 22:23:06 -04:00
|
|
|
|
for (auto file : std::filesystem::directory_iterator(std::filesystem::current_path()))
|
|
|
|
|
if (file.path().extension() == L".dll"
|
|
|
|
|
&& (std::stringstream() << std::ifstream(file.path(), std::ios::binary).rdbuf()).str().find("OnNewSentence") != std::string::npos)
|
2019-07-16 21:55:40 +05:30
|
|
|
|
extensions.emplace_back(LoadLibraryW(file.path().c_str()));
|
2019-06-09 08:10:44 -04:00
|
|
|
|
|
2019-06-07 02:24:28 -04:00
|
|
|
|
ShowWindow(CreateDialogParamW(hInstance, MAKEINTRESOURCEW(IDD_DIALOG1), NULL, [](HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -> INT_PTR
|
|
|
|
|
{
|
|
|
|
|
switch (uMsg)
|
|
|
|
|
{
|
|
|
|
|
case WM_CLOSE:
|
|
|
|
|
{
|
|
|
|
|
DestroyWindow(hWnd);
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
case WM_DESTROY:
|
|
|
|
|
{
|
|
|
|
|
PostQuitMessage(0);
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
|
{
|
|
|
|
|
if (HIWORD(wParam) == EN_CHANGE)
|
|
|
|
|
{
|
|
|
|
|
GetWindowTextW((HWND)lParam, buffer, std::size(buffer));
|
|
|
|
|
try { vars.at(LOWORD(wParam) - IDC_EDIT1) = std::stoi(buffer); }
|
2019-06-09 08:10:44 -04:00
|
|
|
|
catch (...) {}
|
2019-08-06 11:41:49 -04:00
|
|
|
|
//if (vars.at(1)) extensions.clear();
|
|
|
|
|
if (LOWORD(wParam) - IDC_EDIT1 == 1 && mode == 1)
|
|
|
|
|
{
|
|
|
|
|
std::wstring buffer(vars.at(1), 0);
|
|
|
|
|
std::wifstream("StressTest.txt", std::ios::in | std::ios::binary).read(buffer.data(), vars.at(1));
|
|
|
|
|
std::ignore = std::remove(buffer.begin(), buffer.end(), 0);
|
|
|
|
|
for (int i = 0; i < buffer.size(); i += 700) lstrlenW(buffer.c_str() + i);
|
|
|
|
|
}
|
2019-06-07 02:24:28 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return FALSE;
|
|
|
|
|
}, 0), SW_SHOW);
|
|
|
|
|
|
2019-08-06 11:41:49 -04:00
|
|
|
|
std::thread([] { while (true) Sleep(vars.at(2)), mode == 2 && lstrlenW(L"こんにちは\n (Hello)"); }).detach();
|
2019-06-10 22:23:06 -04:00
|
|
|
|
|
|
|
|
|
STARTUPINFOW info = { sizeof(info) };
|
|
|
|
|
wchar_t commandLine[] = { L"Textractor -p\"Test.exe\"" };
|
|
|
|
|
CreateProcessW(NULL, commandLine, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &info, DUMMY);
|
2019-06-07 02:24:28 -04:00
|
|
|
|
|
|
|
|
|
MSG msg;
|
|
|
|
|
while (GetMessageW(&msg, NULL, 0, 0) > 0)
|
|
|
|
|
{
|
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
|
DispatchMessageW(&msg);
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|