Jump to content

Memory Read ( Only on changed value )


Recommended Posts

So, I'm trying to make kind of a simple logging list, but it's spamming the same value over and over when reading the memory address.

I'm hoping  there is a simple way to make it create a list entry each time the value changes, not just continuously until the value changes.

Example:

#include <KryMemory.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Memory List", 225, 212, 188, 125)
$Data = GUICtrlCreateListView("Time|Data", 0, 0, 225, 188)
_GUICtrlListView_SetColumnWidth($Data, 0, 50)
_GUICtrlListView_SetColumnWidth($Data, 1, 200)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$PROCESS = _Process_Open("Example.exe", $PROCESS_ALL_ACCESS, False)

While 1

    $nMsg = GUIGetMsg()
    Switch $nMsg

        Case $GUI_EVENT_CLOSE
            _Process_Close($PROCESS)
            Exit

    EndSwitch

$VAR_OFFSET[2] = [0x102, 0x80]
$VAR = _Process_ReadMemoryPointer($PROCESS, 0x008015D0, $VAR_OFFSET, "dword"))
$VAR2_OFFSET[2] = [0x104, 0x80]
$VAR2 = _Process_ReadMemoryPointer($PROCESS, 0x008015D0, $VAR2_OFFSET, "dword"))

Select

    Case $VAR = 1
        GUICtrlCreateListViewItem(@MIN & @SEC & "|" & $VAR2, $Data)
        
    Case $VAR = 2
        GUICtrlCreateListViewItem(@MIN & @SEC & "|" & $VAR2, $Data)
        
EndSelect
WEnd

 

The problem is, once VAR is set to any value, it will stay the same until changed. Which inturn makes the value get contantly posted to my ListView, instead of just one time.

The only workaround I have is to _Process_WriteMemoryPointer() and change the value myself, but it doesn't work all the time. Sometimes the value will still get posted 2 or 4 times per instance. I think there is a better way to do it.

KryMemory.au3

Edited by Banrukai
Link to comment
Share on other sites

The program I'm trying to read a memory value from doesn't matter, as I'm just using test scenarios.
Any program would suffice.

The only thing I need is:

  • Read memory address value
  • Log value in a ListView only one time
  • Wait for the value you to change
  • Log new value
Link to comment
Share on other sites

Because it's not a control, it's a memory address.

Much like an on and off switch. A window pops up, and the value is 26, then it closes, the value becomes 16.

Depending on which state this window is in, the value will change then persist. If my script is constantly reading the value, then it will spam my list box, unless I manually change the value so it does not equal 26 or 16.

I would release the exe, but I can't since it is one of our applications at work. I'm trying to create a workaround for an issue we are experiencing, until we get an update.

Link to comment
Share on other sites

Can you tell me why anybody should figure out the adress from a programm and modify your script for working with this programm?

When you like to get help it's your turn to make a runable reproducer showing the issue. And therefore the example.exe you used in this reproducer script is needed. So hurry up and post both.

Link to comment
Share on other sites

The issue is straightforward, you just don't want to help.

I'm assuming because of one of the following reasons:
 

  • My issue has to do with reading memory from another process
  • You think this is for a game, therefore it would be against the rules of this forum

To be honest, you're quite pushy, maybe I would do better to just seek out information on my own. Seeming how this is supposed to be a "General Help and Support" section, I'm getting neither help, nor a solution to my issue. This rather defeats the purpose of having this section. 

I haven't asked anyone to figure out any kind of address for the program I am reading memory from. The address '0x008015D0', and the offsets are just examples aswell, THEREFORE, there is no need to post any exe. The issue isn't particular to any exe, but rather memory reading in general.

If you would like to test out the script above, then replace 'Example.exe' with any exe, and modify the target address/offsets with any valid readable address. 

As I've said many times, I am trying to achieve the following:

  • Read memory address
  • Select case if value = a certain value
  • If the value is found, then post the results of the other address 'VAR2' into the ListView
  • Continue loop

The issue is that I only want the script to post the results when VAR changes. ( 26 or 16 )

I really don't understand the confusion. Case value = value, do action. <--- But only do the action one time, until the value changes again. 

Link to comment
Share on other sites

So your question has nothing to do with reading memory. No wonder people are confused. To act on a value only if it is different from the previous time, you should do something like this.

Switch $value
    Case somevalue1
        if $value <> $previousValue Then
            Do Something
            $previousValue = $value
        EndIf
    Case somevalue2
        if $value <> $previousValue Then
            Do Something
            $previousValue = $value
        EndIf
    Case somevalue3
        if $value <> $previousValue Then
            Do Something
            $previousValue = $value
        EndIf
    Case somevalue4
        if $value <> $previousValue Then
            Do Something
            $previousValue = $value
        EndIf
EndSwitch

 

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

Thanks for the reply, I figured it was something very simple...

Sometimes the simplest things can stump someone for hours, or even days.

One thing though, where are you defining the previousValue?

Something like this?

 

$PROCESS = _Process_Open("Example.exe", $PROCESS_ALL_ACCESS, False)

$VAR_OFFSET[2] = [0x102, 0x80]
$VAR = _Process_ReadMemoryPointer($PROCESS, 0x008015D0, $VAR_OFFSET, "dword"))
$VAR2_OFFSET[2] = [0x104, 0x80]
$VAR2 = _Process_ReadMemoryPointer($PROCESS, 0x008015D0, $VAR2_OFFSET, "dword"))

Local $previousValue = 0

Switch $value
    Case 26
        if $value <> $previousValue Then
            GUICtrlCreateListViewItem(@MIN & @SEC & "|" & $VAR2, $Data)
            $previousValue = $value
        EndIf
    Case 16
        if $value <> $previousValue Then
            GUICtrlCreateListViewItem(@MIN & @SEC & "|" & $VAR2, $Data)
            $previousValue = $value
        EndIf
EndSwitch

 

Edited by Banrukai
Link to comment
Share on other sites

forgive us for our rudeness. Usually when we see memory reading - 9999 out of 10,000 it is for a game. I've been here over 10 years and I can only count on one hand the number of times I've seen a reason to read memory (including yours) that is legit.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...