Merge pull request #146 from Artikash/add-test

Add testbed to quickly test hooking.
This commit is contained in:
Akash Mozumdar 2019-06-09 08:30:26 -04:00 committed by GitHub
commit ae0398a243
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 78 additions and 0 deletions

View File

@ -36,3 +36,4 @@ add_subdirectory(GUI)
add_subdirectory(GUI/host) add_subdirectory(GUI/host)
add_subdirectory(texthook) add_subdirectory(texthook)
add_subdirectory(extensions) add_subdirectory(extensions)
add_subdirectory(testbed)

1
testbed/CMakeLists.txt Normal file
View File

@ -0,0 +1 @@
add_executable(Testbed WIN32 main.cpp resource.rc)

49
testbed/main.cpp Normal file
View File

@ -0,0 +1,49 @@
#include "common.h"
#include "defs.h"
#include "resource.h"
wchar_t buffer[1000] = {};
std::array<int, 10> vars = {};
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
{
LoadLibraryW(ITH_DLL);
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); }
catch (...) {}
}
}
break;
}
return FALSE;
}, 0), SW_SHOW);
std::thread([] { while (true) lstrlenW(L"こんにちは"); }).detach();
MSG msg;
while (GetMessageW(&msg, NULL, 0, 0) > 0)
{
TranslateMessage(&msg);
DispatchMessageW(&msg);
}
return 0;
}

27
testbed/resource.h Normal file
View File

@ -0,0 +1,27 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by testractor.rc
//
#define IDD_DIALOG1 101
#define IDC_EDIT1 1000
#define IDC_EDIT2 1001
#define IDC_EDIT3 1002
#define IDC_EDIT4 1003
#define IDC_EDIT5 1004
#define IDC_EDIT6 1005
#define IDC_EDIT7 1006
#define IDC_EDIT8 1007
#define IDC_EDIT9 1008
#define IDC_EDIT10 1009
#define IDC_STATIC -1
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 103
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1011
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

BIN
testbed/resource.rc Normal file

Binary file not shown.