From d4d6c6c8b6ca52e702f2043c2558770f66fb7ff9 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Fri, 7 Jun 2019 02:24:28 -0400 Subject: [PATCH 1/3] add tests --- CMakeLists.txt | 1 + testractor/CMakeLists.txt | 1 + testractor/resource.h | 27 ++++++++++++++++++++++ testractor/testractor.cpp | 46 ++++++++++++++++++++++++++++++++++++++ testractor/testractor.rc | Bin 0 -> 5894 bytes 5 files changed, 75 insertions(+) create mode 100644 testractor/CMakeLists.txt create mode 100644 testractor/resource.h create mode 100644 testractor/testractor.cpp create mode 100644 testractor/testractor.rc diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f6c8ca..268576e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,3 +34,4 @@ add_subdirectory(GUI) add_subdirectory(GUI/host) add_subdirectory(texthook) add_subdirectory(extensions) +add_subdirectory(testractor) diff --git a/testractor/CMakeLists.txt b/testractor/CMakeLists.txt new file mode 100644 index 0000000..7bca354 --- /dev/null +++ b/testractor/CMakeLists.txt @@ -0,0 +1 @@ +add_executable(Testractor WIN32 testractor.cpp testractor.rc) diff --git a/testractor/resource.h b/testractor/resource.h new file mode 100644 index 0000000..707fe42 --- /dev/null +++ b/testractor/resource.h @@ -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 diff --git a/testractor/testractor.cpp b/testractor/testractor.cpp new file mode 100644 index 0000000..29d17a9 --- /dev/null +++ b/testractor/testractor.cpp @@ -0,0 +1,46 @@ +#include "common.h" +#include "resource.h" + +wchar_t buffer[1000] = {}; +std::array vars = {}; + +int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE, _In_ LPWSTR, _In_ int) +{ + 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 (std::invalid_argument&) {} + } + } + 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; +} diff --git a/testractor/testractor.rc b/testractor/testractor.rc new file mode 100644 index 0000000000000000000000000000000000000000..611d32dedf49adb39c2a7ad5815cd86fa15722b9 GIT binary patch literal 5894 zcmd^DT~8W86ur+)`X9FVqN!1rMLv?I39_(~A`n2Ui3w>`l*D2Kn)ac;z3n-77#DEY zMNvZAY=+sLxpU9lPwvd`U)!=RjvPo|&SWSzGD7RgEyj*8Hj+E}BG>pT$$LDGT*`$E z(1sYlMSqU5A$qR6!`m6&9ej~nU%r86OWw*GploZuhS33LuR(pTw5bQ{x8zDvG1MRA zyK*p?r2Kf#pBSt6Sm_-pL-I>VPQ6}1OY3rok^a3N+juit9mz(7UPme^`B95KP`pze z_EaOZ#kv%wBFEB|7SP(#07474D`Ui$8XoffiN}du*#VE11Xxj)I@WI}Y7L`xj2@y7 zFynxi88LJLzN%IyM)QM^idFzlSw}@*uS{exf7iRCdPEL;D$xaaH=67;*f( zXY(7%Dg53paSptIk!XHhSl`ocSF%!2u8gu1a9}L^h`BCW8DkajtfOb1 zurmi3^Ob)ExuJ;v3$6<1D?mTS82Ox_nYqu(wTZP&_ddWaDlN#EQAJ8MwqGOG+Rk2?i zrPgn4PrH;fXBs*eD7kSX)+V@T@XM^+h3tpm)IhduV^s@p%*{l%{GN)J9%H3}v#HX( zHX{9r5_+<`Bt+_uh#7eBa%7}rM9gaREW?i3F=B2k>Faxr_0q!9JckiVR2OlvEZ?EW z7)*C*-b48;s`qRUs>S9UlPgllB?DB`BjmYr=#=@*W+UeKB3cz$h7m)}yK3jOY9T+B zbDoBjPDDzpbr(nS5|KQWW^trUBGRtfadD*GM5L_x>*7e+M5O!+c|@nsS*I!`{EK^-Aj>TOk$FHZJVKRz|;OR=Ab%d=hSFg9bvpwrFRz+1*vUU8{wF0%X z?AgqT_bI1Do>iF#%c!i#l^F3@(N$k`waxl*vfk$YY~2>k$Ii0at{@*DAS?5X&3%zu zZYmF3>K5h$)QAu1nZvV@Ygkn_=j6W!T2{0T(9iCO{7pSNBIJJ=p>QE%ica>=cpc;oMrcyBX%V>^9EYjtV$yL$cO{yu;vc!NF9T_QRC E0Y|BuhX4Qo literal 0 HcmV?d00001 From d56a4196b281539692874764a323f5521f15cb2d Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Sun, 9 Jun 2019 07:56:23 -0400 Subject: [PATCH 2/3] rename --- CMakeLists.txt | 2 +- testbed/CMakeLists.txt | 1 + testractor/testractor.cpp => testbed/main.cpp | 2 +- {testractor => testbed}/resource.h | 0 .../testractor.rc => testbed/resource.rc | Bin 5894 -> 5896 bytes testractor/CMakeLists.txt | 1 - 6 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 testbed/CMakeLists.txt rename testractor/testractor.cpp => testbed/main.cpp (90%) rename {testractor => testbed}/resource.h (100%) rename testractor/testractor.rc => testbed/resource.rc (98%) delete mode 100644 testractor/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 268576e..a3270e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,4 +34,4 @@ add_subdirectory(GUI) add_subdirectory(GUI/host) add_subdirectory(texthook) add_subdirectory(extensions) -add_subdirectory(testractor) +add_subdirectory(testbed) diff --git a/testbed/CMakeLists.txt b/testbed/CMakeLists.txt new file mode 100644 index 0000000..66c9427 --- /dev/null +++ b/testbed/CMakeLists.txt @@ -0,0 +1 @@ +add_executable(Testbed WIN32 main.cpp resource.rc) diff --git a/testractor/testractor.cpp b/testbed/main.cpp similarity index 90% rename from testractor/testractor.cpp rename to testbed/main.cpp index 29d17a9..1c99f21 100644 --- a/testractor/testractor.cpp +++ b/testbed/main.cpp @@ -4,7 +4,7 @@ wchar_t buffer[1000] = {}; std::array vars = {}; -int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE, _In_ LPWSTR, _In_ int) +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) { ShowWindow(CreateDialogParamW(hInstance, MAKEINTRESOURCEW(IDD_DIALOG1), NULL, [](HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -> INT_PTR { diff --git a/testractor/resource.h b/testbed/resource.h similarity index 100% rename from testractor/resource.h rename to testbed/resource.h diff --git a/testractor/testractor.rc b/testbed/resource.rc similarity index 98% rename from testractor/testractor.rc rename to testbed/resource.rc index 611d32dedf49adb39c2a7ad5815cd86fa15722b9..64dd59d3d94ec63264651d5e7ab4123093e8d667 100644 GIT binary patch delta 44 ycmZqE>(JZqij~)p!GJ-BL4m=L!IZ&t@^{vQydey!48;s33`sybW%FS+X8`~J1`AdI delta 42 ycmeCsYt!5Cij~)h!I(jZL4m=L!HmIj@^{vQ+%62642cXm4EYS{n~$xeDX} diff --git a/testractor/CMakeLists.txt b/testractor/CMakeLists.txt deleted file mode 100644 index 7bca354..0000000 --- a/testractor/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_executable(Testractor WIN32 testractor.cpp testractor.rc) From 0f44a0c6f8ca3b6859784fa15d413b0ba53edba9 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Sun, 9 Jun 2019 08:10:44 -0400 Subject: [PATCH 3/3] start injeccted --- testbed/main.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/testbed/main.cpp b/testbed/main.cpp index 1c99f21..dabe57e 100644 --- a/testbed/main.cpp +++ b/testbed/main.cpp @@ -1,4 +1,5 @@ #include "common.h" +#include "defs.h" #include "resource.h" wchar_t buffer[1000] = {}; @@ -6,6 +7,8 @@ std::array 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) @@ -26,7 +29,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) { GetWindowTextW((HWND)lParam, buffer, std::size(buffer)); try { vars.at(LOWORD(wParam) - IDC_EDIT1) = std::stoi(buffer); } - catch (std::invalid_argument&) {} + catch (...) {} } } break;