 |  [C++] Window name changerThis is a discussion on [C++] Window name changer within the Development forum part of the Software/Hardware category; Ok, i made this cool program wich can change a windows name to whatever you want...
Thanks to Tyrano for ...  Welcome on D3scene.com! Make sure to register - it's free and very quick! You have to register before you can post and participate in our discussions with 70000 other registered members. Downloads, user profiles and some forums can only be seen by registered members. After you create your free account you will be able to customize many options, you will have the full access to new hacks, latest cheats and last but not least will see no advertisements at all. We would love to see you around in our community! 
06-30-2009, 04:50 PM
|  | Paranoia! | | Join Date: Jan 2008
Posts: 2,621
Thanks: 87
Thanked 84 Times in 50 Posts
Reputation: 782
Rep Power: 6 | | | [C++] Window name changer Ok, i made this cool program wich can change a windows name to whatever you want...
Thanks to Tyrano for his (or whoever he stole it from  ) debug access code Code: #include <windows.h>
#include <iostream>
#include <string>
using namespace std;
void EnableDebugPriv( ) //Thanks to Tyrano for this...
{
HANDLE hToken;
LUID sedebugnameValue;
TOKEN_PRIVILEGES tkp;
OpenProcessToken( GetCurrentProcess( ), TOKEN_ADJUST_PRIVILEGES |TOKEN_QUERY, &hToken );
LookupPrivilegeValue( NULL, SE_DEBUG_NAME, &sedebugnameValue );
tkp.PrivilegeCount = 1;tkp.Privileges[0].Luid = sedebugnameValue;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges( hToken, false, &tkp, sizeof( tkp ), NULL, NULL );
CloseHandle( hToken );
}
int main()
{
SetConsoleTitle("Window namechanger");
cout << "Enter window name" << endl;
string what;
getline (cin, what);
EnableDebugPriv();
HWND hWindow = FindWindow(NULL,what.c_str());
if(!hWindow)
{
cout << "Window not found" << endl;
system( "pause" );
return 1;
}
cout << "Thank you, Found Process, attempting to get PID" << endl;
DWORD pid;
GetWindowThreadProcessId( hWindow, &pid );
HANDLE hOpen = OpenProcess( PROCESS_ALL_ACCESS, false, pid );
if( !hOpen )
{
cout << "Can't open process." << endl;
system( "pause" );
return 1;
}
cout << "Success! Got PID, insert new window name"<< endl;
getline (cin, what);
SetWindowText(hWindow,what.c_str());
hWindow = FindWindow(NULL,what.c_str());
if(!hWindow)
{
cout << "Error occured...." << endl;
system( "pause" );
return 1;
}
else
{
cout << "Name changed successfully"<< endl;
for(;;) {
if (!FindWindow(NULL,what.c_str()))
{
SetWindowText(hWindow,what.c_str());
}
}
system( "pause");
}
return 0;
}
I've compiled it with Visual C++, but i think it should work with any standard c++ compiler...
The .exe is included. BTW, it is cpu heavy if you leave it running after the namechange... The problem is that some programs change the title back, but if you dont care about that, heres a code wich will not keep on changing it all the time Code: #include <windows.h>
#include <iostream>
#include <string>
using namespace std;
void EnableDebugPriv( )
{
HANDLE hToken;
LUID sedebugnameValue;
TOKEN_PRIVILEGES tkp;
OpenProcessToken( GetCurrentProcess( ), TOKEN_ADJUST_PRIVILEGES |TOKEN_QUERY, &hToken );
LookupPrivilegeValue( NULL, SE_DEBUG_NAME, &sedebugnameValue );
tkp.PrivilegeCount = 1;tkp.Privileges[0].Luid = sedebugnameValue;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges( hToken, false, &tkp, sizeof( tkp ), NULL, NULL );
CloseHandle( hToken );
}
int main()
{
SetConsoleTitle("Window namechanger");
cout << "Enter window name" << endl;
string what;
getline (cin, what);
EnableDebugPriv();
HWND hWindow = FindWindow(NULL,what.c_str());
if(!hWindow)
{
cout << "Window not found" << endl;
system( "pause" );
return 1;
}
cout << "Thank you, Found Process, attempting to get PID" << endl;
DWORD pid;
GetWindowThreadProcessId( hWindow, &pid );
HANDLE hOpen = OpenProcess( PROCESS_ALL_ACCESS, false, pid );
if( !hOpen )
{
cout << "Can't open process." << endl;
system( "pause" );
return 1;
}
cout << "Success! Got PID, insert new window name"<< endl;
getline (cin, what);
SetWindowText(hWindow,what.c_str());
hWindow = FindWindow(NULL,what.c_str());
if(!hWindow)
{
cout << "Error occured...." << endl;
system( "pause" );
return 1;
}
else
{
cout << "Name changed successfully"<< endl;
/* for(;;) {
if (!FindWindow(NULL,what.c_str()))
{
SetWindowText(hWindow,what.c_str());
}
}*/
system( "pause");
}
return 0;
}
You will have to compile the last one yourself | | D3scene |
Welcome to D3scene - probably the best location for all Gamers.
To participate in our friendly environment you have to register. After completing registration you will have full access to all threads and features. We care about members and try to make your stay as pleasant as possible. We are unique with the following feature for members - you will not see a single Advertisement!
The best: registration is completely free. It will not cost you a single penny or harm you in any way. You will lose nothing except 1 minute of your time. So why not register? We would be happy to see you around!
| 
06-30-2009, 04:58 PM
|  | <- not a little red yoshi | | Join Date: May 2008
Posts: 1,046
Thanks: 70
Thanked 71 Times in 52 Posts
Reputation: 650
Rep Power: 5 | | Gosh you are pro :0 Nah, GJ for a C++ nub like you | 
06-30-2009, 04:59 PM
|  | Paranoia! | | Join Date: Jan 2008
Posts: 2,621
Thanks: 87
Thanked 84 Times in 50 Posts
Reputation: 782
Rep Power: 6 | | Psssh! You do it better! | 
07-06-2009, 07:40 AM
|  | Hacker | | Join Date: Jul 2008
Posts: 176
Thanks: 0
Thanked 56 Times in 28 Posts
Reputation: 257
Rep Power: 3 | | Quote:
Originally Posted by Serverman Ok, i made this cool program wich can change a windows name to whatever you want...
Thanks to Tyrano for his (or whoever he stole it from  ) debug access code Code: #include <windows.h>
#include <iostream>
#include <string>
using namespace std;
void EnableDebugPriv( ) //Thanks to Tyrano for this...
{
HANDLE hToken;
LUID sedebugnameValue;
TOKEN_PRIVILEGES tkp;
OpenProcessToken( GetCurrentProcess( ), TOKEN_ADJUST_PRIVILEGES |TOKEN_QUERY, &hToken );
LookupPrivilegeValue( NULL, SE_DEBUG_NAME, &sedebugnameValue );
tkp.PrivilegeCount = 1;tkp.Privileges[0].Luid = sedebugnameValue;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges( hToken, false, &tkp, sizeof( tkp ), NULL, NULL );
CloseHandle( hToken );
}
int main()
{
SetConsoleTitle("Window namechanger");
cout << "Enter window name" << endl;
string what;
getline (cin, what);
EnableDebugPriv();
HWND hWindow = FindWindow(NULL,what.c_str());
if(!hWindow)
{
cout << "Window not found" << endl;
system( "pause" );
return 1;
}
cout << "Thank you, Found Process, attempting to get PID" << endl;
DWORD pid;
GetWindowThreadProcessId( hWindow, &pid );
HANDLE hOpen = OpenProcess( PROCESS_ALL_ACCESS, false, pid );
if( !hOpen )
{
cout << "Can't open process." << endl;
system( "pause" );
return 1;
}
cout << "Success! Got PID, insert new window name"<< endl;
getline (cin, what);
SetWindowText(hWindow,what.c_str());
hWindow = FindWindow(NULL,what.c_str());
if(!hWindow)
{
cout << "Error occured...." << endl;
system( "pause" );
return 1;
}
else
{
cout << "Name changed successfully"<< endl;
for(;;) {
if (!FindWindow(NULL,what.c_str()))
{
SetWindowText(hWindow,what.c_str());
}
}
system( "pause");
}
return 0;
}
I've compiled it with Visual C++, but i think it should work with any standard c++ compiler...
The .exe is included. BTW, it is cpu heavy if you leave it running after the namechange... The problem is that some programs change the title back, but if you dont care about that, heres a code wich will not keep on changing it all the time Code: #include <windows.h>
#include <iostream>
#include <string>
using namespace std;
void EnableDebugPriv( )
{
HANDLE hToken;
LUID sedebugnameValue;
TOKEN_PRIVILEGES tkp;
OpenProcessToken( GetCurrentProcess( ), TOKEN_ADJUST_PRIVILEGES |TOKEN_QUERY, &hToken );
LookupPrivilegeValue( NULL, SE_DEBUG_NAME, &sedebugnameValue );
tkp.PrivilegeCount = 1;tkp.Privileges[0].Luid = sedebugnameValue;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges( hToken, false, &tkp, sizeof( tkp ), NULL, NULL );
CloseHandle( hToken );
}
int main()
{
SetConsoleTitle("Window namechanger");
cout << "Enter window name" << endl;
string what;
getline (cin, what);
EnableDebugPriv();
HWND hWindow = FindWindow(NULL,what.c_str());
if(!hWindow)
{
cout << "Window not found" << endl;
system( "pause" );
return 1;
}
cout << "Thank you, Found Process, attempting to get PID" << endl;
DWORD pid;
GetWindowThreadProcessId( hWindow, &pid );
HANDLE hOpen = OpenProcess( PROCESS_ALL_ACCESS, false, pid );
if( !hOpen )
{
cout << "Can't open process." << endl;
system( "pause" );
return 1;
}
cout << "Success! Got PID, insert new window name"<< endl;
getline (cin, what);
SetWindowText(hWindow,what.c_str());
hWindow = FindWindow(NULL,what.c_str());
if(!hWindow)
{
cout << "Error occured...." << endl;
system( "pause" );
return 1;
}
else
{
cout << "Name changed successfully"<< endl;
/* for(;;) {
if (!FindWindow(NULL,what.c_str()))
{
SetWindowText(hWindow,what.c_str());
}
}*/
system( "pause");
}
return 0;
}
You will have to compile the last one yourself  | ...Why do you get debug privileges and open the process? You realize that neither of those are necessary to change a window's title?
On another note, you do a for(;  to loop indefinitely, which is fine, but you should insert a Sleep(1) at the very least to make this process not take up 100% of the processor.
Last edited by Darimus; 07-06-2009 at 07:43 AM.
| | The Following User Says Thank You to Darimus For This Useful Post: | | 
07-06-2009, 02:11 PM
|  | Paranoia! | | Join Date: Jan 2008
Posts: 2,621
Thanks: 87
Thanked 84 Times in 50 Posts
Reputation: 782
Rep Power: 6 | | Yes, i was thinking about that...
BTW... It won't find the window without debug access...
And putting in the sleep helped alot, went from 99% CPU usage down to 00% hehe...  too
Last edited by Serverman; 07-06-2009 at 02:43 PM.
| 
07-06-2009, 06:18 PM
|  | Hacker | | Join Date: Jul 2008
Posts: 176
Thanks: 0
Thanked 56 Times in 28 Posts
Reputation: 257
Rep Power: 3 | | Quote:
Originally Posted by Serverman Yes, i was thinking about that...
BTW... It won't find the window without debug access...
And putting in the sleep helped alot, went from 99% CPU usage down to 00% hehe...  too  | FindWindow should work fine without debug access; it's OpenProcess that fails without proper access, but the only reason to use OpenProcess is to obtain a HANDLE, which is unnecessary to modify a window's title (a HWND type). | 
07-06-2009, 06:25 PM
|  | Paranoia! | | Join Date: Jan 2008
Posts: 2,621
Thanks: 87
Thanked 84 Times in 50 Posts
Reputation: 782
Rep Power: 6 | | | Uhm, without the handle, how can i control the process? | 
07-07-2009, 07:06 AM
|  | Hacker | | Join Date: Jul 2008
Posts: 176
Thanks: 0
Thanked 56 Times in 28 Posts
Reputation: 257
Rep Power: 3 | | | All that's necessary to change the window title is the SetWindowText function, (internally, a SendMessage call using WM_SETTEXT), which doesn't require debug privileges, nor a HANDLE parameter. | 
07-07-2009, 11:32 AM
|  | Paranoia! | | Join Date: Jan 2008
Posts: 2,621
Thanks: 87
Thanked 84 Times in 50 Posts
Reputation: 782
Rep Power: 6 | | Clever boy.... I'll try it sometime | 
07-09-2009, 08:12 PM
| | Banned User | | Join Date: Oct 2008 Location: Australia
Posts: 2,862
Thanks: 29
Thanked 46 Times in 29 Posts
Reputation: 671
Rep Power: 0 | | | | | D3scene |
Welcome to D3scene - probably the best location for all Gamers.
To participate in our friendly environment you have to register. After completing registration you will have full access to all threads and features. We care about members and try to make your stay as pleasant as possible. We are unique with the following feature for members - you will not see a single Advertisement!
The best: registration is completely free. It will not cost you a single penny or harm you in any way. You will lose nothing except 1 minute of your time. So why not register? We would be happy to see you around!
| | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | All times are GMT +1. The time now is 08:39 PM. | |  |