Jump to content

Possible to change process name of attached WoW process?


Brian

Recommended Posts

Hello, it's not possible to change the process name(on runtime => you can retaliate at msdn documentation) and you must specify which IntPtr do you mean:

There are several IntPtr which you can get from the process but i belive you want the mainwindowhandle? or you can explain for what the IntPtr is needed.

 

Edit: forgot to write that you can change the process name by simply rename wow.exe but it will doesn't affect the process name while it's running:

Logging.Write(wManager.Wow.Memory.WowMemory.Memory.GetProcess().ProcessName);

 

Link to comment
Share on other sites

2 hours ago, reapler said:

Hello, it's not possible to change the process name(on runtime => you can retaliate at msdn documentation) and you must specify which IntPtr do you mean:

There are several IntPtr which you can get from the process but i belive you want the mainwindowhandle? or you can explain for what the IntPtr is needed.

 

Edit: forgot to write that you can change the process name by simply rename wow.exe but it will doesn't affect the process name while it's running:


Logging.Write(wManager.Wow.Memory.WowMemory.Memory.GetProcess().ProcessName);

 

I need to change the process name and I can do it via 

 

[DllImport("user32.dll")]
 static extern void SetWindowText(IntPtr hWnd, string windowName);

 

But I need to get the main window handle.. Also, wManger.WoW.Memory.WoWMemory.Memory.. no GetProcess exists, only serialize

Link to comment
Share on other sites

So, i wrote a method which works (at least for me):

        [DllImport("user32.dll")]
        static extern bool SetWindowText(IntPtr hWnd, string text);
        public void SetText(string processname, string text)
        {
            IntPtr mainWindowHandle = IntPtr.Zero;
            foreach (var obj in System.Diagnostics.Process.GetProcesses())
            {
                //or you can search for other parameter / characteristics which wow contains but searching for processname is normaly enough
                if (obj.ProcessName == processname)// => in my case the executable in my wow folder is Wow.exe
                {
                    Logging.Write("Process found: " + obj.ProcessName + "[" + obj.Id + "].");
                    mainWindowHandle = obj.MainWindowHandle;
                    break;
                }
            }
            if (mainWindowHandle != IntPtr.Zero)
            {
                SetWindowText(mainWindowHandle, text);
            }
            else
            {
                Logging.Write("No process with the name '" +processname+"' was found.\nPlease check your executable's name.");
            }
        }

usage:

SetText("Wow","Hello World!");

 

 

but remember:

processname != windowtext => the field "ProcessName" is read only so it can't be changed on running processes. If you really want to change the process' name, you can only influence it on startup or by creating a new process.

 

 

Edit: this one gets the right one, if several processes exist:

        [DllImport("user32.dll")]
        static extern bool SetWindowText(IntPtr hWnd, string text);
        public void SetText(string processname, string text)
        {
            IntPtr mainWindowHandle = IntPtr.Zero;
            foreach (var obj in System.Diagnostics.Process.GetProcesses())
            {
                if (obj.ProcessName == processname)// => in my case the executable in my wow folder is Wow.exe
                {
                    if (wManager.Wow.Memory.PlayerName(obj.Id) == wManager.Wow.ObjectManager.ObjectManager.Me.Name)
                    {
                        Logging.Write("Process found: " + obj.ProcessName + "[" + obj.Id + "][" + wManager.Wow.ObjectManager.ObjectManager.Me.Name+ "]");
                        mainWindowHandle = obj.MainWindowHandle;
                        break;
                    }
                }
            }
            if (mainWindowHandle != IntPtr.Zero)
            {
                SetWindowText(mainWindowHandle, text);
            }
            else
            {
                Logging.Write("No process with the name '" +processname+"' was found.\nPlease check your executable's name.");
            }
        }

 

Link to comment
Share on other sites

1 hour ago, reapler said:

So, i wrote a method which works (at least for me):


        [DllImport("user32.dll")]
        static extern bool SetWindowText(IntPtr hWnd, string text);
        public void SetText(string processname, string text)
        {
            IntPtr mainWindowHandle = IntPtr.Zero;
            foreach (var obj in System.Diagnostics.Process.GetProcesses())
            {
                //or you can search for other parameter / characteristics which wow contains but searching for processname is normaly enough
                if (obj.ProcessName == processname)// => in my case the executable in my wow folder is Wow.exe
                {
                    Logging.Write("Process found: " + obj.ProcessName + "[" + obj.Id + "].");
                    mainWindowHandle = obj.MainWindowHandle;
                    break;
                }
            }
            if (mainWindowHandle != IntPtr.Zero)
            {
                SetWindowText(mainWindowHandle, text);
            }
            else
            {
                Logging.Write("No process with the name '" +processname+"' was found.\nPlease check your executable's name.");
            }
        }

usage:


SetText("Wow","Hello World!");

 

 

but remember:

processname != windowtext => the field "ProcessName" is read only so it can't be changed on running processes. If you really want to change the process' name, you can only influence it on startup or by creating a new process.

 

 

Edit: this one gets the right one, if several processes exist:


        [DllImport("user32.dll")]
        static extern bool SetWindowText(IntPtr hWnd, string text);
        public void SetText(string processname, string text)
        {
            IntPtr mainWindowHandle = IntPtr.Zero;
            foreach (var obj in System.Diagnostics.Process.GetProcesses())
            {
                if (obj.ProcessName == processname)// => in my case the executable in my wow folder is Wow.exe
                {
                    if (wManager.Wow.Memory.PlayerName(obj.Id) == wManager.Wow.ObjectManager.ObjectManager.Me.Name)
                    {
                        Logging.Write("Process found: " + obj.ProcessName + "[" + obj.Id + "][" + wManager.Wow.ObjectManager.ObjectManager.Me.Name+ "]");
                        mainWindowHandle = obj.MainWindowHandle;
                        break;
                    }
                }
            }
            if (mainWindowHandle != IntPtr.Zero)
            {
                SetWindowText(mainWindowHandle, text);
            }
            else
            {
                Logging.Write("No process with the name '" +processname+"' was found.\nPlease check your executable's name.");
            }
        }

 

Thanks, I'll test later when Im available.  The second method is exactly what I'm looking for!

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...