|
-
Feb 12th, 2008, 09:48 AM
#1
Thread Starter
Member
[2008] How to retrieve value from exe?
Not sure how to word this right as I've never done it before. Also not sure which language I should code it in..
How would I go about getting a value from an exe if I already know what address it's located at?
For example..in the app I'm making that calculates the current xp per hour, I need to be able to retrieve the total xp on my char from the game exe. I already know that the xp is located at 0080B910 and can see it with my debugger.
I just need to grab that value and put it into a var in my program.
The only language I'm semi-decent at is VB .NET but am willing to learn more if needed, I'll have to eventually anyways.
Help me out here guys =)
-
Feb 12th, 2008, 12:07 PM
#2
Re: [2008] How to retrieve value from exe?
You'd use ReadProcessMemory in kernel32.
Code:
Private Declare Function ReadProcessMemory Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
-
Feb 12th, 2008, 09:18 PM
#3
Thread Starter
Member
Re: [2008] How to retrieve value from exe?
Thanks 
I think I've almost got it.
I just don't understand what I'm supposed to use for lpBuffer and lpNumberOfBytesWritten.
var is coming out as 0..
What are lpBuffer and lpNumberOfBytesWritten supposed to be?
Code:
Declare Function ReadProcessMemory Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As IntPtr
Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As System.IntPtr
Private Sub btnCurrentXP_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCurrentXP.Click
Dim var As String
Dim windowhandle As IntPtr
windowhandle = FindWindow(vbNullString, "My Window Handle")
var = ReadProcessMemory(windowhandle, 8435984, 0, 8, 0)
MsgBox(var)
End Sub
-
Feb 13th, 2008, 08:54 AM
#4
Re: [2008] How to retrieve value from exe?
lpBuffer is where it puts the result. lpNumberOfBytesWritten will be 0. Most of the Windows API functions are, I think the term is, "reflexive". That is, you give them an empty variable as one of their arguments, the function uses that as a pointer for where to stuff results. It's very handy if you want to return multiple values from a single function. VB.NET can do similar things.
Code:
Declare Function ReadProcessMemory Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As IntPtr
Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As System.IntPtr
Private Sub btnCurrentXP_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCurrentXP.Click
Dim windowhandle As IntPtr
Dim intResult As Long
windowhandle = FindWindow(vbNullString, "My Window Handle")
'You are reading 8 bytes from offset 8435984 from process
'"windowhandle" and returning the result into intResult.
ReadProcessMemory(windowhandle, 8435984, intResult, 8, 0)
MsgBox(intResult)
End Sub
Last edited by Jenner; Feb 13th, 2008 at 09:49 AM.
-
Sep 3rd, 2009, 08:08 AM
#5
Lively Member
Re: [2008] How to retrieve value from exe?
If you want to use it for a different program/executable file then what do you need to change and how do you know where to find that piece of information required?
-
Sep 4th, 2009, 05:53 PM
#6
Lively Member
Re: [2008] How to retrieve value from exe?
Can anyone one help me?
Much appreciated
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|