Solved

Using VB to edit specific memory locations values

Posted on 2002-07-04
14
263 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Use Multiple Forms 4 49
JSON Response and request in VB6 application 11 252
Add and format columns in vb6 7 47
Passing a Text Box name to a Sub 6 79
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

864 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