Solved

Using VB to edit specific memory locations values

Posted on 2002-07-04
14
262 Views
Last Modified: 2010-05-02
I have found a few memory locations on my computer that i'd like to edit using VB, whats the syntax envolved in doing such a thing?

Example:
Lets say the memory location is "D5D419" and the memory value is "1234556789" how do i edit that memory value for that specific location using VB code to be "abcdefghij"?

Thanks
0
Comment
Question by:craigewens
  • 4
  • 2
  • 2
  • +6
14 Comments
 
LVL 6

Expert Comment

by:pierrecampe
ID: 7130802
you cannot do that
however in dos mode you could do it with Quickbasic
if i remember right like so:
def seg = TheSegmentAdres
poke TheOffsetAdres,1234
0
 
LVL 2

Author Comment

by:craigewens
ID: 7130808
Well i have heard of the "poke" cmd before, here is MSDNs definition:
In dynamic data exchange (DDE), to send data from a destination application to a source application. A form's LinkMode property must be set to Source to allow a destination application to send data to controls on the form.


This is where i fall over....I'm sure it's possible (espicially if it's possible in dos) but i'm unsure of the syntax again... Help!
0
 
LVL 6

Expert Comment

by:pierrecampe
ID: 7130827
the DDE poke is not the same as the Quickbasic poke
the Quickbasic poke 'pokes' a value in a memory location
DDE's poke sends a value to a DDE recipient
and no you can not do it in windows, simply because the memory windows allocates to your program is not physical memory
well maybe it can be done with C and a program that runs in the kernel, but thats way out of my league, and of VB's
 
0
 
LVL 2

Author Comment

by:craigewens
ID: 7130846
Hummm... so what stops me from getting my variable (the value i wish to place into a certain mem loaction) and passing it through a dos cmd to the relavent mem location to achieve the same thing?.. i know it's not as sexy but would such a thing get the job done till a more suitable solution comes along or someone else comes up with a different idea?

No offence, but its 2am here and i'm certainly not thinking straight :)

Do you know for sure it's impossible to do it through VB 100%?

I certainly dont... (which is obvious)

Either way i'm off to bed... lets see how many comments we get tomorrow morning...

night.
0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 7130870
Hi!

IF AND ONLY IF both proggys are created by you...

Why don't you save whatever variables you want into a file, then let the 2 proggys communicate through that : )

That's it!

glass cookie : )

PS. Ignore me if this is out-of-point : )
0
 
LVL 6

Expert Comment

by:pierrecampe
ID: 7130886
>>so what stops me...
well for one thing it has to be true dos mode
and in dos you can only reach 640K of memory
and dos uses a segmented memory model (16 bits you know)
and you have to know very well what you are doing,if not and you are lucky the system will crash,if you are unlucky the system will not crash and some data will be corrupted
but if you really have to do it, there is a program that comes with dos that will allow you to do it: debug.exe
and Qbasic comes with dos to
and then there is the powerbasic console compiler wich still has 'peek' and 'poke'(if i remember well)
so just go ahead, crashing only hurts for a moment
>>Do you know for sure it's impossible to do it through VB 100%?
well lets say i am 99.999999% sure
have a good night
0
 
LVL 2

Expert Comment

by:egsemsem
ID: 7131442
well, I think there might be way to do this, but I am not sure whether it will work or not.

Firstly, add this decleration.

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)

and when you want to edit a location, use this line of code:

CopyMemory ByVal MemLoc, ByVal StrPtr(NewVal), LenB(NewVal)

MemLoc is the memory location, which is in your case: "D5D419" . But, you should convert this value to long. I think this could be done by doing the following:
  MemLoc = CLng(&HD5D419)
Notice that I added &H before the hexa address.

And finally NewVal is the string that holds the new value, which is "abcdefghij".

Notice also that the length (in bytes) of the source string must be equal to or less than the destination.  

To be honest, I didn't test. However, try it!

Osama
 
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 6

Expert Comment

by:pierrecampe
ID: 7131549
well the problem with copymemory is that it needs valid pointers
and i doubt that a physical memory adress is a valid pointer
it ofcource is well suited to copy from one variable to another
but for that saying a=b is the preferred way
>>Notice also that the length (in bytes) of the source string must be equal to or less than the destination
well thats not needed you know, copymemory will gladly overwrite anything thats in memory
>>To be honest, I didn't test. However, try it!
yes why not try it, crashing only hurst a moment

0
 
LVL 28

Accepted Solution

by:
AzraSound earned 50 total points
ID: 7132260
May provide insight:
"Scan Another Process for a Memory Value and Replace It"
http://www.freevbcode.com/ShowCode.Asp?ID=4115
0
 
LVL 1

Expert Comment

by:MartijnB
ID: 7135479
AzraSound has got it right.
You CAN use RtlMoveMemory to read and write to a memory location, but only a location in your own app's memory.
The Peek and Poke functions do exist in VB, but have the same problem. DOS programs have the same restrictions.

Martijn
0
 
LVL 27

Expert Comment

by:Ark
ID: 7136752
Hi, craigewens.
I'm highly recomended you to read Jeffry Richer's book "Programming applications for win32" for understanding how windows work with RAM.
BTW, AzraSound, did you check sample on XP? Someone told me it doesn't work.

Cheers
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 7137721
Hey Ark,
Don't know...I don't have an XP machine to test it out on.  It wouldn't surprise me with Microsoft's wonderful history of backwards compatibility.   :-)
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7990686
Hi craigewens,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Split points between: AzraSound and Ark

craigewens, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 

Expert Comment

by:SpideyMod
ID: 8053238
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange

Ark points for you at:
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20535656.html
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 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

21 Experts available now in Live!

Get 1:1 Help Now