-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
110 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include <iostream> | ||
#include <sstream> | ||
#include <thread> | ||
#include <Windows.h> | ||
#include <psapi.h> | ||
|
||
using namespace std; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
}; |