Solved

memory

Posted on 2000-04-09
30
478 Views
Last Modified: 2008-02-01
given a program name (or process id) how can i read/write certain values in the memory?
i know there is api to do it.. but i cant figure out how to use it
thanks
0
Comment
Question by:goldwire368
  • 8
  • 6
  • 5
  • +3
30 Comments
 
LVL 28

Expert Comment

by:AzraSound
Comment Utility
take a look at those memory api functions to get you started:

http://www.vbapi.com/ref/funcc.html#memory
0
 

Author Comment

by:goldwire368
Comment Utility
no offense to anyone who actually tries to give descent answers..... but what part of: "i cant figure out how to use it" dont you understand? besides that... the list of memory API has nothing to do with reading or writing!
here is a list of the api i need help with, for all of you special people:
ReadProcessMemory
WriteProcessMemory
0
 
LVL 28

Expert Comment

by:AzraSound
Comment Utility
typically at this site when someone "cant figure out how to use it" they post code and we point out where they went wrong.  when i saw none i just read memory api and pointed you to a link i had that i knew referenced some memory api calls.  your attitude isnt going to make you all too popular here
0
 

Author Comment

by:goldwire368
Comment Utility
The reason why i am posting on experts-exchange, is because i dont have alot of time to go searching link by link figuring this stuff out. But then i post this question and i still get useless urls which waist more of my time, and that defeats the whole purpose of comming here in the 1st place. So im just suggesting, next time you are going to post some information about a question... make sure your info is about the subject, not just some useless url u thought was educational.
0
 
LVL 27

Expert Comment

by:Ark
Comment Utility
Hi
VB itself has some functions for working with memory. For example:
'---reading memory---
Declare Sub ReadMemByte Lib "MSVBVM50" Alias "GetMem1" (ByVal MemAddress As Long, var As Byte) '- get one byte from address into variavble
Declare Sub ReadMemInteger Lib "MSVBVM50" Alias "GetMem2" (ByVal MemAddress As Long, var As Integer) '- get integer from address into variavble
Declare Sub ReadMemLong Lib "MSVBVM50" Alias "GetMem4" (ByVal MemAddress As Long, var As Long) '- get long from address into variavble
Declare Sub ReadMemCurrency Lib "MSVBVM50" Alias "GetMem8" (ByVal MemAddress As Long, var As Currensy) '- get currency (8 bytes) from address into variavble
Declare Sub ReadMemString Lib "MSVBVM50" Alias "GetMemStr" (ByVal MemAddress As Long, ByVal var As String) '- get string from address into variavble
Declare Sub ReadMemObject Lib "MSVBVM50" Alias "GetMemObj" (ByVal MemAddress As Long, var As Object) '- get string from address into variavble
'---writing memory---
Declare Sub WriteMemByte Lib "MSVBVM50" Alias "PutMem1" (ByVal MemAddress As Long, var As Byte) '- write one byte to address from variavble
' other declaration are the same. To find variable address you can use VarPtr (or StrPtr, ObjPtr) VB functions.
Simple sample - getting bios info (note - works only with W95/W98 - NT don't map bios addresses into process memory, so you'll receive GPF):
'-------------
Option Explicit

Private Declare Sub GetMem1 Lib "msvbvm50.dll" (ByVal _
   MemAddress As Long, var As Byte)

Private Function GetBIOSDate() As String
  Dim p As Byte, MemAddr As Long, sBios As String
  Dim i As Integer
  MemAddr = &HFFFF5
  For i = 0 To 7
      Call GetMem1(MemAddr + i, p)
      sBios = sBios & Chr$(p)
  Next i
  GetBIOSDate = sBios
End Function
'Using
'Text1.Text = GetBiosDate

'PS - MSVBVM60 has same functions
Cheers
0
 
LVL 28

Accepted Solution

by:
AzraSound earned 100 total points
Comment Utility
at this link is an example written incorporating the ReadProcessMemory api call.  he uses it to resolve pointers to pointers and i dont think thats what you are really looking for but at least it demonstrates how the syntax and everything is implemented.
0
 
LVL 28

Expert Comment

by:AzraSound
Comment Utility
0
 
LVL 14

Expert Comment

by:wsh2
Comment Utility
goldwire368 writes:
"no offense to anyone who actually tries to give descent answers..... but what part of: "i cant figure out how to use it" dont you understand?"

and then writes:
"The reason why i am posting on experts-exchange, is because i dont have alot of time to go searching link by link figuring this stuff out. But then i post this question and i still get useless urls which waist more of my time"

--------------------------------------
Hey, this is some kinda friendly person, huh? Ark and Azra.. I don't know why you are even responding to this spoiled child.. <sheesh>. Now let me see, how can I explain manners in 25 words or less, so we don't waste his "valuable" time.. <smile>.
0
 
LVL 28

Expert Comment

by:AzraSound
Comment Utility
you could post a link for him which actually takes him  to your "25 words or less" explanation of the term. He'd really appreciate it!!  =)
0
 
LVL 14

Expert Comment

by:wsh2
Comment Utility
Azra:
Or perhaps 25 links of one word each.. gawd.. just imagine if he had to piece together a sentence.. it boggles the mind!.. <lol> and a <smile>.
0
 
LVL 27

Expert Comment

by:Ark
Comment Utility
Hi
Azra and wsh2. I've just posted these functions to show this VB dll's futures to everybody who is interesting in direct memory access from VB. I've recently found them and tried to show. Take a look:
' In this case you can remove first declaration hidden function VarPtr from VB is the same, but in case of objects you need it
' Private Declare Function VarPtr Lib "msvbvm50.dll" (var As Any) As Long
Private Declare Sub PutMem4 Lib "msvbvm50.dll" (ByVal p As Long, ByVal value As Long)
Private Declare Sub GetMem4 Lib "msvbvm50.dll" (ByVal p As Long, var As Long)

Private Sub Command1_Click()
  Dim a As Long, b As Long
  Dim p As Long
  a = 100: b = 0
  p = VarPtr(a)
  MsgBox "OldValue_b = " & CStr(b)
  GetMem4 p, b
  MsgBox "NewValue_b = " & CStr(b)
  b = 200
  MsgBox "OldValue_a = " & CStr(a)
  PutMem4 p, b
  MsgBox "NewValue_a = " & CStr(a)
End Sub

' Of course simple way is a = b, but this is another way. MS hide many usefull functions and I like to find them. :-P to MS.
Cheers
0
 
LVL 14

Expert Comment

by:mcrider
Comment Utility
Ark, Interresting stuff!

Cheers!®©
0
 
LVL 14

Expert Comment

by:mcrider
Comment Utility
wsh2,

Waiting for those "manners in 25 word or less"... <VBG> Maybe something here is appropriate: http://www1.experts-exchange.com/ExpertInput/Q_10277744.html

Cheers!®©
0
 
LVL 14

Expert Comment

by:wsh2
Comment Utility
mcrider:
Great link!!!... <still laughing>.. Thank YOU.. <huge smile>.
0
 

Expert Comment

by:netfox2600
Comment Utility
I have to say I agree with Goldwire368, because I have been in the same situations. I ask a questions and next thing I know I have a URL sent to me that has to do with the general topic but not the answer to the specific question I asked. Now don't be blaming each other. Goldy probably has had quite the bombardment of url's; I have bumped into him in the past and found the same situtation. Now that doesnt excuse him for his somewhat "rash" reply but lets remember that we are all here to answer questions to the best of our knowledge and not criticize each others reply, and the only person doing that after this mascarade here is "Ark". Now lets all just forget about this and enjoy "mcrider"s link, :)  
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:goldwire368
Comment Utility
Thanks man, no hard feelings ;)
0
 
LVL 28

Expert Comment

by:AzraSound
Comment Utility
None at all.  Glad the link helped you out.
0
 
LVL 14

Expert Comment

by:wsh2
Comment Utility
netfox2600:
Barney, the purple dinosaur would be proud of you.. <smile>.

Often times.. the simplest way to convey an answer (particularily to a question that is unclear) is through a hyperlink. This serves three purposes.

1. It gives proper credit to the author of the solution. As an expert, we may or may not have implemented the code.. as such.. if there is a problem.. you know whom to go to.

2. Many sites are loaded with additional examples and/or nuances of the base code. Sometimes.. the code implementation requires other modules..and the whole thing is too lengthy to post here.

3. How do you think WE became experts? Mainly it is/was by visiting all these sites and reading/using what they have to offer. There is NO substitute for doing your homework.. if you truly want to be better. Laying a solution out on a platter, teachs very little. I am disappointed that you feel the questioner should leave ALL the work up to the Expert.. and NOT do any work of their own. Of what benefit is that?

All of us here contribute our time and expertise for FREE. Even if it is only a hyperlink comment, one should be grateful that an expert took his/her valuable time to assist in the questioner's plea. If you don't like the hyperlink.. just move on to the next comment.. <smile>.
0
 

Author Comment

by:goldwire368
Comment Utility
First, if i wanted to learn about this, i would definatly spend the time and research it. but right now, all i am interested in, is the answer. Not all of the steps to get there. I can worry about that later. Second, i am giving points to find the answer. If i was paying you nothing, i would except your kind of answer, wsh2. If i hired a painter to paint my house, I wouldnt want him to paint one side then tell me to do the rest because it is fun and educational. That is the reason for paying him in the 1st place, so i dont have to do it.
0
 

Expert Comment

by:netfox2600
Comment Utility
You know what? I admire the fact that you have no acknowledgment to comments outside of your own. I happen to support html links. BUT the message i typed was that its good if the html actually answers the question.
It usually helps. Really.
Even if a website is on the topic of the question, it doesn't help if it doesn't answer the question. That is what i am trying to say.

Also you can recognize the fact that many people do thier own searching towards websites before posting a question on EE. Most likely they looked at a vast multitude of sites, so sending them another is really going to help. Also, again, especially if it doesnt even contain the answer.

And all of a sudden why do you think the questioner should do some of the work (maybe even after looking on many sites) when he is actaully giving you points for a completed answer?

"I am disappointed that you feel the questioner should leave ALL the work up to the Expert.. and NOT do any work of their own." Why should you be? You are the one getting the points. That is like hiring a contractor to build a building with specifications, and then the contractor giving you a 2x4!

In otherwords, you are saying "Lets all be one big disgruntled family and i get paid for it. You consult me as long as you do my work too."

Barney, the purple dinosaur would be proud of you.
0
 

Expert Comment

by:netfox2600
Comment Utility
By the way, why are you even here "wsh2"? You don't even have to do with the question, you just tried to pry everyone else away from GW368. Some expert.
GW & I talk over the net, and word of keyboard gets around. That is my excuse. What is yours?
0
 
LVL 14

Expert Comment

by:mcrider
Comment Utility
netfox2600,

Now... Now... Play nice... wsh2 has just as much of a right to post as any other expert.


Cheers!®©
0
 

Expert Comment

by:netfox2600
Comment Utility
I'm not saying he doesn't, he has full rights to say anything. But I was curious how he wound up here... without even assiting in the question. :-P
0
 
LVL 14

Expert Comment

by:wsh2
Comment Utility
Netfox2600:
Uhh.. as with any question you want to comment on.. you read it.. <duh>.

Like you and "Goldfinger'.. Azra and Ark happen to be my "bond" type friends.
And I suppose, like you, I tend to take the junkyard dog mentality a bit serious. When "G-String" started to bandy his offhand remarks about.. I naturally took offense.

Rather than pay credence to OldCrier's question (which I easily could have done).. I felt more obliged to comment on his/her demeanor.. or lack thereof.. and that is how I got here.. <smile>.

Now.. spare me the 9 months of incubation after 1 night of drunken bliss part.. how did you get here Netfox2600?.. <smile>.
0
 
LVL 14

Expert Comment

by:wsh2
Comment Utility
mcrider writes: "Now... Now... Play nice" Ok.. ok.. mc.. so what is with the mother hen bit?.. Don't you think we have enough clucks as there is?.. <lol> and a <wink>.

To be honest, I enjoy their repartee.. and think that they have accorded themselves very well.. <bowing humbly in their direction>. Knowing this.. I am certain.. that "GoldaMeir368", and his trusty sidelick "Atari2600", will make their proper amends soon.. <smile>.

0
 

Expert Comment

by:netfox2600
Comment Utility
I ALREADY posted earlier that the reason i am here is the same reason you are here; merely taking "offense" and standing up to a fellow friend. And although i dont appreciate your little word slangs on our names, i have to agree I am enjoying this too. But I honestly think it is getting old too, and although i could sling back some of the comments you said to me, i think ill sit this one out. I enjoyed this little mascarade, and maybe, we will meet again somehow (cough, cough). So, type to ya later... i think we both have better things to do.

Ah hell i have to include this... FOAD. Elaboration? Ask GW. Have a nice day. <wink>
0
 
LVL 14

Expert Comment

by:wsh2
Comment Utility
Netfox2600:
<tipping backwardz baseball cap and bowing>.. The pleasure has been all mine.. Good luck to you in your future endeavors.. <smile>

Oh.. and as to FOAD.. I can't spare the points.. I want to get my house painted !!!.. <lol> and a <wink>.
0
 
LVL 14

Expert Comment

by:mcrider
Comment Utility
wsh2,

All I have to say is "Cluck, Cluck, Cluck!" <VBG>

Cheers!®©
0
 

Author Comment

by:goldwire368
Comment Utility
There is a technical term that escribes people like you, "Sir WaSHmyfeet". Its called a SmartAss. Where you have nothing to do in your life except sit around and make up little puns about about someones name. Just because you, "IQis2", road the Little Cheese for most of your life doesnt mean u have to share all of your meaningless
remarks about 'StickyFingers?' or whatever the hell you do in your spare time. Well, 'i-WiSH-i-could-program-vb', i need to get back to my day-job. Thats correcto! some people do actually work for a living, but until you hit puberty, you wont really have to worry about that. Well, i must say.... it has been fun, never really met a pos like you. so until we meet again, i wish you the best of luck in finding a friend or 2(if your lucky).
oh! and by the way. <grin> I can be just as funny as you!!
<does a little dance> (even though technically i never left this chair, its fun to be in your own little pretend world, right?)
0
 
LVL 14

Expert Comment

by:wsh2
Comment Utility
Gawd.. at least NetFox2600 can write.. <sheesh>. ColdFire, YOU owe her.. <wink>.

Get this.. I actually agree with you.. Hold onto that day job!!!.. Oh, and by the way, "I'll have french fries with my order, Thank YOU".. <smile>.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now