Jump to content


Photo
- - - - -

processHandle never work?


  • Please log in to reply
5 replies to this topic

#1 a-sm

a-sm

    n00bie

  • Members
  • 4 posts

Posted 05 February 2013 - 11:36 AM

Hello all, I'm having problem with my VB6 program. I'm creating a bot for a games, but I meet a strange problem.

I have this window handle, and it works nice.
dim hwnd as long
hwnd=FindWindow(vbNullString, "Element Client")

But this code:
processHandle=OpenProcess(PROCESS_ALL_ACCESS, false, procId)

It never work as it returns 0, I have this problem since the first time I reinstall my OS. What could be the cause? Is it related to my new OS?

Thanks in advance :)

#2 a-sm

a-sm

    n00bie

  • Members
  • 4 posts

Posted 05 February 2013 - 11:40 AM

In addition, CE can write and read the game perfectly. It just my VB that cannot open the process.

#3 KEMiCZA

KEMiCZA

    Administrator

  • Administrators
  • 400 posts
  • LocationBelgium

Posted 05 February 2013 - 10:58 PM

It's possible that the given procId parameter is invalid. Can you post more of your code?

Since you said it's a problem after installing a new OS try running your application with administrator rights.

#4 STN

STN

    Administrator

  • Administrators
  • 792 posts
  • LocationRight next to Mitt Romney

Posted 07 February 2013 - 04:41 AM

After Windows Vista and onwards, the PROCESS_ALL_ACCESS parameter wouldn't work anymore, it was due to the parameter enumeration value change or something i can't recall now.

Use the accesses you require with a bitwise operator like VM_READ | VM_WRITE or the + sign would work even etc.
Posted Image


DEViATED Game Trainers- Owning your asses since Sept 2010!
-Still OWNING
not really =(

#5 a-sm

a-sm

    n00bie

  • Members
  • 4 posts

Posted 07 February 2013 - 03:57 PM

Could you post the VM_READ, VM_WRITE constants mr. STN?
I couldn't find them in VB6 Api Text Viewer.

For the + sign, you mean it would be like:
processHandle=OpenProcess(+, false, procId)

Also another small questions about VB6. They are:

1. How to find the Window Caption from process name??
Like I have a "notepad.exe", and want to retrieve the Window Caption just from the "notepad.exe" process. Without having the process on top (foreground). The reason I want this module is because I have created a Bot for Perfect World in VB6, but then I meet this problem. When I minimized the program into the System Tray, my program cannot find the window since it doesn't listed in Windows's Window Lists anymore. I figured that to solve this problem is by hooking into the right process, since Perfect World can be played in multiple client, it will have two or more Window Captions. Lets take it that I have renamed the first window caption into "My Element Client". So I could get the handle by filtering it like: GetProcess("elementclient.exe") Where ProcessCaption="My Element Client".

2. How to read a byte, 2 byte, and 4 byte values with ReadProcessMemory? As my program always return a wrong value if I change the byte into 1 or 2. Here's the module:

Public Function readIt(address As Long, value As Long, byteLength As Byte)
Dim hWnd As Long, procId As Long, processHandle As Long
hWnd = FindWindow(vbNullString, gameName)

If (hWnd = 0) Then
MsgBox "Cannot find the game", vbCritical, "Error occured"
Exit Function
End If

GetWindowThreadProcessId hWnd, procId
processHandle = OpenProcess(PROCESS_ALL_ACCESS, False, procId)

If (processHandle = 0) Then
MsgBox "Cannot handle the game", vbCritical, "Error occured"
Exit Function
End If

ReadProcessMemory processHandle, address, value, byteLength, 0&
CloseHandle hProc
End Function

Thanks before :)

#6 nasheba

nasheba

    Member

  • Members
  • 54 posts

Posted 31 May 2013 - 05:49 PM

HA!! VB6 is still alive and kicking i thought

it was dead its like using softice on win8:)






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users