Results 1 to 7 of 7

Thread: Someone Test really fast

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2005
    Posts
    76

    Someone Test really fast

    Can someone tell me if it does infact get a value for the pHandle. I am having problems but I think it is because I am in a computer lab and don't have PROCESS_ALL_ACCESS. If it doesn't work at first could you replace that value with PROCESS_VM_READ. Thanks a lot!

    'In button:

    Private Sub Command1_Click()
    Dim hwnd As Long
    Dim pid As Long
    Dim phandle As Long
    Dim str As String

    hwnd = FindWindow(vbNullString, "Calculator")
    MsgBox hwnd
    If (hwnd = 0) Then Exit Sub
    GetWindowThreadProcessId hwnd, pid
    MsgBox pid
    phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
    MsgBox phandle
    If (phandle = 0) Then Exit Sub
    end sub

    'In .bas:

    Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
    Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
    Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByVal lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
    Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByVal lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
    Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
    Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Public Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
    Public Declare Function GetNextWindow Lib "user32" Alias "GetWindow" (ByVal hwnd As Long, ByVal wFlag As Long) As Long
    Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As Any, pSrc As Any, ByVal ByteLen As Long)

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Someone Test really fast

    I'd be happy to except that PROCESS_ALL_ACCESS isn't defined or declared anywhere. What is that?

    Also, what is PROCESS_VM_READ? Neither show up in the Constants section of the API viewer.

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Someone Test really fast

    Never mind. I had to Goggle them, but I got the constants definitions.

    Anyway, with PROCESS_ALL_ACCESS, I got a handle, a pid and a phandle.

    Do you need to have this infor posted, or are you just interested in whether I got anything other than 0?

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2005
    Posts
    76

    Re: Someone Test really fast

    Anything but 0....thanks a lot man. Damn computers in the lab won't let me do stuff to the processes I guess.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jan 2005
    Posts
    76

    Re: Someone Test really fast

    Any idea why this doesn't work on Windows XP?

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Someone Test really fast

    Quote Originally Posted by Lyric8
    Any idea why this doesn't work on Windows XP?
    I ran it on XP Pro, and it worked fine.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jan 2005
    Posts
    76

    Re: Someone Test really fast

    Fails on the 2 xp machines i have tried it on... UGHSSSSS no idea. Thanks though hack. appreciate it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width