Question about OpenProcess in C# menu

Shout-Out

User Tag List

Results 1 to 5 of 5
  1. #1
    mrdennis87's Avatar Member Authenticator enabled
    Reputation
    1
    Join Date
    Feb 2012
    Posts
    36
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question about OpenProcess in C#

    I just want to make sure I am doing this correct as I am learning C# currently.

    I know you must first open the process, read or write to the memory then close the process. My question is..

    If you Open the process will that value be the window handle? ex.

    Intptr hReadProcess = OpenProcess(0x001F0FFF, false, ProcessID);

    The reason I am asking is because every time I call open process it returns a value(the window handle?) but changes every time you read it.

    I am calling OpenProcess, and this is my code to convert the integer to a string

    TXTBA.Text = Convert.ToString(hReadProcess);

    Any help is appreciated, thank you in advance.
    Last edited by mrdennis87; 07-27-2012 at 08:57 AM.

    Question about OpenProcess in C#
  2. #2
    SKU's Avatar Contributor
    Reputation
    306
    Join Date
    May 2007
    Posts
    565
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, that's not the window handle, it's an open handle to the specified process. (Think of a process without a window!)

    If you want the window handle, google:

    * FindWindow
    * EnumWindows
    * GetWindowThreadProcessId
    * ..

  3. #3
    Envoke's Avatar Contributor
    Reputation
    105
    Join Date
    Jan 2009
    Posts
    201
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
            [DllImport("kernel32.dll")]
            public static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);
    
                Process[] m_proccess = null;
                m_proccess = Process.GetProcessesByName("Wow");
                if (m_proccess.Length != 0)
                {
                    if (m_proccess[0] == null)
                        return false;
    
                   IntPtr Handle = OpenProcess(0x001F0FFF, false, m_proccess[0].Id);
                }
    Owner and developer of LevelUp WoW Bot

  4. #4
    mrdennis87's Avatar Member Authenticator enabled
    Reputation
    1
    Join Date
    Feb 2012
    Posts
    36
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Envoke View Post
    Code:
            [DllImport("kernel32.dll")]
            public static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);
    
                Process[] m_proccess = null;
                m_proccess = Process.GetProcessesByName("Wow");
                if (m_proccess.Length != 0)
                {
                    if (m_proccess[0] == null)
                        return false;
    
                   IntPtr Handle = OpenProcess(0x001F0FFF, false, m_proccess[0].Id);
                }
    Thank you for providing the code, I compared it to what I'm doing in my project, and I am doing it correct. I am in the process of trying to read the memory at the moment. To call the readprocessmemory I need to have the handle. ex. readmemory(handle, etc). When I am using the open process function it is giving me random numbers. First time I call it will be like 1302, second time will be 2405, and third 2605 etc.. I thought the handle would be the same every time I get it. Sorry If I confused my question. I am trying to figure out why the handle is changing every time I call for it.

  5. #5
    Envoke's Avatar Contributor
    Reputation
    105
    Join Date
    Jan 2009
    Posts
    201
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by mrdennis87 View Post
    Thank you for providing the code, I compared it to what I'm doing in my project, and I am doing it correct. I am in the process of trying to read the memory at the moment. To call the readprocessmemory I need to have the handle. ex. readmemory(handle, etc). When I am using the open process function it is giving me random numbers. First time I call it will be like 1302, second time will be 2405, and third 2605 etc.. I thought the handle would be the same every time I get it. Sorry If I confused my question. I am trying to figure out why the handle is changing every time I call for it.
    Are you trying to figure out why ReadProcessMemory wont work or are you trying to figure out why the handle is changing?
    Owner and developer of LevelUp WoW Bot

Similar Threads

  1. A question about converting
    By krazy12766 in forum World of Warcraft General
    Replies: 2
    Last Post: 08-22-2006, 08:02 PM
  2. question about model editing
    By Zanatons in forum WoW ME Questions and Requests
    Replies: 1
    Last Post: 08-17-2006, 09:21 PM
  3. questions about model editing
    By Zanatons in forum WoW ME Questions and Requests
    Replies: 1
    Last Post: 08-17-2006, 05:32 PM
  4. Question about MCing - Frostwolf
    By Hydrox in forum World of Warcraft General
    Replies: 0
    Last Post: 07-21-2006, 02:53 AM
  5. questions about model editing
    By Avianar47 in forum World of Warcraft General
    Replies: 2
    Last Post: 07-08-2006, 09:41 PM
All times are GMT -5. The time now is 06:48 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search