Gaming Community
Forum
 
Go Back   D3scene > Software/Hardware > Development
Register Blogs Live view Downloads D3 Clan FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

[C++] Window name changer

This 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!
Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 06-30-2009, 04:50 PM
Serverman's Avatar
Paranoia!

 
Join Date: Jan 2008
Posts: 2,621
Blog Entries: 3
Thanks: 87
Thanked 84 Times in 50 Posts
Reputation: 782
Rep Power: 6
Serverman is a splendid one to beholdServerman is a splendid one to beholdServerman is a splendid one to beholdServerman is a splendid one to beholdServerman is a splendid one to beholdServerman is a splendid one to beholdServerman is a splendid one to behold
[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
Attached Files
File Type: rar Windowhandlertest.rar (4.9 KB, 6 views)
Reply With Quote
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!
  #2  
Old 06-30-2009, 04:58 PM
Jolinar's Avatar
<- 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
Jolinar is a splendid one to beholdJolinar is a splendid one to beholdJolinar is a splendid one to beholdJolinar is a splendid one to beholdJolinar is a splendid one to beholdJolinar is a splendid one to behold
Send a message via ICQ to Jolinar Send a message via AIM to Jolinar Send a message via MSN to Jolinar Send a message via Yahoo to Jolinar Send a message via Skype™ to Jolinar
Gosh you are pro :0 Nah, GJ for a C++ nub like you
Reply With Quote
  #3  
Old 06-30-2009, 04:59 PM
Serverman's Avatar
Paranoia!

 
Join Date: Jan 2008
Posts: 2,621
Blog Entries: 3
Thanks: 87
Thanked 84 Times in 50 Posts
Reputation: 782
Rep Power: 6
Serverman is a splendid one to beholdServerman is a splendid one to beholdServerman is a splendid one to beholdServerman is a splendid one to beholdServerman is a splendid one to beholdServerman is a splendid one to beholdServerman is a splendid one to behold
Psssh! You do it better!
Reply With Quote
  #4  
Old 07-06-2009, 07:40 AM
Darimus's Avatar
Hacker

 
Join Date: Jul 2008
Posts: 176
Thanks: 0
Thanked 56 Times in 28 Posts
Reputation: 257
Rep Power: 3
Darimus is a jewel in the roughDarimus is a jewel in the roughDarimus is a jewel in the rough
Quote:
Originally Posted by Serverman View Post
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.
Reply With Quote
The Following User Says Thank You to Darimus For This Useful Post:
  #5  
Old 07-06-2009, 02:11 PM
Serverman's Avatar
Paranoia!

 
Join Date: Jan 2008
Posts: 2,621
Blog Entries: 3
Thanks: 87
Thanked 84 Times in 50 Posts
Reputation: 782
Rep Power: 6
Serverman is a splendid one to beholdServerman is a splendid one to beholdServerman is a splendid one to beholdServerman is a splendid one to beholdServerman is a splendid one to beholdServerman is a splendid one to beholdServerman is a splendid one to behold
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.
Reply With Quote
  #6  
Old 07-06-2009, 06:18 PM
Darimus's Avatar
Hacker

 
Join Date: Jul 2008
Posts: 176
Thanks: 0
Thanked 56 Times in 28 Posts
Reputation: 257
Rep Power: 3
Darimus is a jewel in the roughDarimus is a jewel in the roughDarimus is a jewel in the rough
Quote:
Originally Posted by Serverman View Post
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).
Reply With Quote
  #7  
Old 07-06-2009, 06:25 PM
Serverman's Avatar
Paranoia!

 
Join Date: Jan 2008
Posts: 2,621
Blog Entries: 3
Thanks: 87
Thanked 84 Times in 50 Posts
Reputation: 782
Rep Power: 6
Serverman is a splendid one to beholdServerman is a splendid one to beholdServerman is a splendid one to beholdServerman is a splendid one to beholdServerman is a splendid one to beholdServerman is a splendid one to beholdServerman is a splendid one to behold
Uhm, without the handle, how can i control the process?
Reply With Quote
  #8  
Old 07-07-2009, 07:06 AM
Darimus's Avatar
Hacker

 
Join Date: Jul 2008
Posts: 176
Thanks: 0
Thanked 56 Times in 28 Posts
Reputation: 257
Rep Power: 3
Darimus is a jewel in the roughDarimus is a jewel in the roughDarimus is a jewel in the rough
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.
Reply With Quote
  #9  
Old 07-07-2009, 11:32 AM
Serverman's Avatar
Paranoia!

 
Join Date: Jan 2008
Posts: 2,621
Blog Entries: 3
Thanks: 87
Thanked 84 Times in 50 Posts
Reputation: 782
Rep Power: 6
Serverman is a splendid one to beholdServerman is a splendid one to beholdServerman is a splendid one to beholdServerman is a splendid one to beholdServerman is a splendid one to beholdServerman is a splendid one to beholdServerman is a splendid one to behold
Clever boy.... I'll try it sometime
Reply With Quote
  #10  
Old 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
risker is a splendid one to beholdrisker is a splendid one to beholdrisker is a splendid one to beholdrisker is a splendid one to beholdrisker is a splendid one to beholdrisker is a splendid one to behold
Send a message via MSN to risker

Sexy serverman

Goodjob
Reply With Quote
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!
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
WoW Stat Changer hendricius WoW Hacks 52 10-06-2009 04:22 AM
Memoirs of World of Warcraft Hallowsend WoW Patches 6 07-12-2009 07:52 AM
Half-Life 2 Guide Jolinar Half Life 2 0 06-25-2008 08:21 PM
Blowhole in Plexi Window Volund Case Modding 0 05-18-2008 03:14 PM
Plexiglass/modder's mesh window Volund Case Modding 0 05-17-2008 05:22 PM


All times are GMT +1. The time now is 08:39 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.0 ©2009, Crawlability, Inc.
vBulletin style developed by Transverse Styles