473,783 Members | 2,317 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ReadProcessMemo ry (VB2005)

63 New Member
Hi all,

I got a problem with my code to check a game's chat position and write text to the game when a command is written by someone on the chat. I haven't figured out yet how to make it send keys to the gamewindow when it's not focussed, and WriteProcessMem ory, but that's for a later issue.

This is my current code:

Expand|Select|Wrap|Line Numbers
  1. Public Const PROCESS_ALL_ACCESS As Long = &H1F0FFF
  2. Declare Auto Function FindWindow Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
  3. Public Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As IntPtr, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Byte, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
  4. Public Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByRef lpBuffer As Integer, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
  5. Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As IntPtr) As Integer
  6. Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As IntPtr
  7.  
  8.     Public Sub ReadChat(ByVal Command As String)
  9.  
  10.         Dim hwnd As Integer
  11.         Dim hprocess As Integer
  12.         Dim readprocess
  13.         Dim chataddress As Integer
  14.         Dim votesneeded As String = txtvotesneeded.Text
  15.  
  16.         If hwnd = FindWindow(vbNullString, Game1) = True Then
  17.             chataddress = &H698726
  18.         ElseIf hwnd = FindWindow(vbNullString, Game2) = True Then
  19.             chataddress = &H685381
  20.         Else
  21.             MsgBox("Please Startup the game first before clicking the Start button", MsgBoxStyle.Critical, "Error!")
  22.         End If
  23.  
  24.         On Error Resume Next
  25.         MsgBox("Error #17 occured. Please ask for help at support forum.", MsgBoxStyle.Critical, "Error!")
  26.  
  27.         If hwnd >= 0 Then
  28.             hprocess = OpenProcess(PROCESS_ALL_ACCESS, False, hwnd)
  29.             readprocess = ReadProcessMemory(hprocess, ChatAddress, 78, 78, vbNullString)
  30.             CloseHandle(hprocess)
  31.         End If
  32.  
  33.         If readprocess = Command Then
  34.             SendKeys.Send("{T}")
  35.             Wait(100)
  36.             SendKeys.Send("There are " & votesneeded & " more votes needed to skip map.")
  37.             Wait(100)
  38.             SendKeys.Send("{ENTER}")
  39.         End If
  40.  
  41.     End Sub
  42.  
The game consists of 2 different versions, that's why I want it to change the chataddress to suit each version.
I'm not sure if I done all this code the right way. The only error it gave me during runtime was something with "readproces s". A conversion from type String to type Double failed.

I hope someone can help me get this code right and help me taking any errors out which could prevent it from working perfect.

Thanks in advance !
Evolution445
Sep 12 '07 #1
5 2926
Killer42
8,435 Recognized Expert Expert
Um... what data type is readprocess supposed to be?
Sep 13 '07 #2
Evolution445
63 New Member
Um... what data type is readprocess supposed to be?
Expand|Select|Wrap|Line Numbers
  1. Dim readprocess
  2.  
  3. readprocess = ReadProcessMemory(hprocess, ChatAddress, 78, 78, vbNullString)
  4.  
Would the problem be solved if I Dim readprocess as Double ?
Sep 13 '07 #3
Killer42
8,435 Recognized Expert Expert
Would the problem be solved if I Dim readprocess as Double ?
I don't know, but it wouldn't hurt to try.

I guess the main questions to be answered would be...
  • What data type does ReadProcessMemo ry() function return?
  • What are the specific details of the error?
  • Exactly where in the code does the error occur?

If this were VB6, I'd advise against calling a variable Command, since that's the name under which command-line parameters are retrieved. But in VB2005, I don't know how that works.
Sep 13 '07 #4
hariharanmca
1,977 Top Contributor
I think this link will help you.

Write/ReadProcessMemo ry errors of 487 and 299
Sep 13 '07 #5
Evolution445
63 New Member
I don't know, but it wouldn't hurt to try.

I guess the main questions to be answered would be...
  • What data type does ReadProcessMemo ry() function return?
  • What are the specific details of the error?
  • Exactly where in the code does the error occur?

If this were VB6, I'd advise against calling a variable Command, since that's the name under which command-line parameters are retrieved. But in VB2005, I don't know how that works.
ReadProcessMemo ry should only read the chat position and see if there's a specified word written by someone. I think it should only return either True or False.

I think this is how it should go, or what it suposes to do:
------------------
* Read the chataddress with ReadProcessMemo ry
* If "......." is written Then
* Respond using SendKeys
------------------

This is where the error occured:
Expand|Select|Wrap|Line Numbers
  1.         If readprocess = Command Then
  2.             SendKeys.Send("{T}")
  3.             Wait(100)
  4.             SendKeys.Send("There are " & votesneeded & " more votes needed to skip map.")
  5.             Wait(100)
  6.             SendKeys.Send("{ENTER}")
  7.         End If
  8.  
I'm not sure if I done this right. Infact, I'm not sure about whole my code.
Any help is appreciated.
Sep 15 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

9
8258
by: Luke | last post by:
I am trying to convert some VB6 projects to VB.NET, however I'm having trouble finding documentation of a new format for some functions, in specific ReadProcessMemory. Since .NET no longer supports the 'as any' declare I found myself trying integers & longs, however all attempts throw back the error message 'Object reference not set to an instance of an object.'. My API declare is as follows Public Declare Function ReadProcessMemory Lib...
2
6329
by: pangel83 | last post by:
I've been trying for days to write a piece of VB.NET code that will read from winamp's memory space the paths of the files from the current winamp playlist. The GETPLAYLISTFILE command of the winamp API will only return a pointer to the position of the asked path. An article available on http://msmvps.com/ch21st/archive/2004/02/26.aspx provides a VB6 implementation of this, using the ReadProcessMemory Windows API command, but something...
2
1319
by: Jerry Spence1 | last post by:
1. Is there a more suitable, dedicated newsfeed for VB2005 yet? 2. I'm confused as to which version to get. I work for a small company and we will just need VB2005 on my PC. Therefore that tends to suggest the express version, but I write some pretty complicated stuff (including SQLServer transactions, network programming etc) and I am wondering what is missing from the Express version in terms of components, functionality etc. I don't...
0
2028
by: Rich | last post by:
Hello, I just upgraded a vb2003 app to vb2005. The vb2003 app had/has a statusbar object - which contains panels and I can see the properties of the statusbar in the properties window in vb2005. But in the tools list of vb2005 I do not see a statusbar selection. Instead I see a statusStrip, and even though the Items collection has a property to set the statusStrip labels to sunken, etched,... I can see these appearances when I...
1
1667
by: erickwan88 | last post by:
I am doing a final year project for my school and is going to provide for an organization, so I am asking for some help on here. Indeed, I have no idea on how to get the input from my pen driver and use on vb2005 as when I activate the pen driver, it will run its own program itself and when I deactivate it, it become a mouse. Therefore, I need to find out how to use the pen to write words on the vb2005 program instead of being either a...
15
2028
by: Aalaan | last post by:
I am presently a user of classic vb6 and hang out on those newsgroups. Some of you may be aware that there is a very anti MS and vb2005 feeling there. I have tried to get them to tell me which features of vb2005 are actually worse then vb6 in practice, and forget the philosophy of backward compatibility for a moment. I would now like to hear "the other side". Could *anyone who previously used vb6* (only those pleased; I feel the others...
1
4440
by: Jeffrey Christiansen | last post by:
I wanted to add a toggle button to a VB2005 form to be used for a simple Windows Application (i.e. compiled to a "*.exe"), so I added the ActiveX Microsoft Forms Object toggle button, however I can't get this button does work properly. The documentation I found in the FM20.CHM files says the button state can be determined from its "Value" property, but the property list shown in VB2005 does not have a "Value" property. How is the button...
1
2250
by: Vae07 | last post by:
Ok so here is a brief summary of my problem. I need a pop up form that submits input text box information to a pocket excel workbook upon a command botton click. Text box inputs are checked for validity upon individual text box exit (don't have a problem with this part). All this could be done with Excel VBA easily, but pocket excel doesn't have VBA/Macro support. In as much, I have been trying to create a VB2005 application that I can load...
0
1594
by: =?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?= | last post by:
Hi, can someone postme a running sample of the ReadProcessMemory(...) function. I would like to dump the complete memory of the main module in my application e.g MyApplication.exe into a file. Here is a working example of the API import call:
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9946
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.