diff --git a/.gitignore b/.gitignore index 9ea395f..61b8896 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +CMakeLists.txt.user CMakeCache.txt CMakeFiles CMakeScripts @@ -7,3 +8,4 @@ cmake_install.cmake install_manifest.txt compile_commands.json CTestTestfile.cmake +_deps \ No newline at end of file diff --git a/README.md b/README.md index 4b18e82..d8494e4 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ # WTCPPoofer - Window Title Spoofer + CPP Window Title Spoofer + +### Why? +No reason at all i just had needed it for a test and now i have nothing to do with it anymore so to save "you?" some time you can clone it. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..f537a00 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.19) +project(WindowSpoofer) + +set(CMAKE_CXX_STANDARD 20) + +add_executable(WindowSpoofer main.cpp util.cpp inc.cpp) \ No newline at end of file diff --git a/src/inc.cpp b/src/inc.cpp new file mode 100644 index 0000000..b747db3 --- /dev/null +++ b/src/inc.cpp @@ -0,0 +1,7 @@ +#include +#include +#include +#include +#include + +using namespace std; \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..0b799b7 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,55 @@ +#include "util.cpp" + +bool loop = false; +string processID; +string processWindowTitle; + +void changeWindowTitle_loop() { + bool startOnce = true; + + while (loop || startOnce) { + startOnce = false; // stop once started + + HWND processHandle = Util::find_main_window(stoi(processID)); + bool isChanged = SetWindowTextA(processHandle, processWindowTitle.c_str()); + cout << (isChanged ? "+" : "."); // give some sort of information if the process is still active + } +} + +int main(int argc, char **argv) { + SetConsoleTitle("WindowTitleSpoofer"); + + string loopYN; + + if (argv[1] == nullptr || argv[2] == nullptr) { + cout << "Hey you can also launch using arguments. [argv[1] = processID, argv[2] = processWindowTitle]" << endl; + + cout << "Process ID: "; + getline(cin, processID); + + cout << "Window Title: "; + getline(cin, processWindowTitle); + + loop: + cout << "Loop spoof [y, n]: "; + getline(cin, loopYN); + } else { + processID = argv[1]; + processWindowTitle = argv[2]; + loopYN = argv[3]; + } + + // Define loop status else ask again + if (loopYN != "y" && loopYN != "n") goto loop; + loop = loopYN == "y"; + + // Start background thread + thread(changeWindowTitle_loop).detach(); + + // If console resumed stop loop & program + cout << "Press a key to exit from the program." << endl; + cin.get(); + + loop = false; + exit(0); +} \ No newline at end of file diff --git a/src/util.cpp b/src/util.cpp new file mode 100644 index 0000000..0408188 --- /dev/null +++ b/src/util.cpp @@ -0,0 +1,36 @@ +#include "inc.cpp" + +class Util { + struct handle_data { + unsigned long process_id; + HWND window_handle; + }; + + static BOOL is_main_window(HWND handle) { + return GetWindow(handle, GW_OWNER) == (HWND) nullptr && IsWindowVisible(handle); + } + + static BOOL CALLBACK enum_windows_callback(HWND handle, LPARAM lParam) { + handle_data &data = *(handle_data *) lParam; + unsigned long process_id = 0; + GetWindowThreadProcessId(handle, &process_id); + if (data.process_id != process_id || !is_main_window(handle)) return TRUE; + + data.window_handle = handle; + return FALSE; + } + + /*** + * Enumerate windows from a process_id in order to get the process handle + * @param process_id + * @return HANDLE + */ +public: + static HWND find_main_window(unsigned long process_id) { + handle_data data{}; + data.process_id = process_id; + data.window_handle = nullptr; + EnumWindows(enum_windows_callback, (LPARAM) &data); + return data.window_handle; + } +}; \ No newline at end of file