Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42722

Problem with For/Loop, need help

$
0
0
Hello all. I used the code below to get the values from the memory address of a program. It supported multiple instances of the program. However, since the program updated the last time, the values are stored in dynamic addresses if the string lenght in question is >= 16. Please, read the green part in the code below, I think you'll understand what my problem is.

Code:

Public Function GETDATA()

    Dim x As Integer
    Dim myProcess As PROCESSENTRY32
    Dim mySnapshot As Long
    Dim dxs1, dxs2 As Integer
   
    Dim stringacc1 As String
    Dim stringpass1, stringpass2 As String
    Dim stringstaticacc, stringstaticpass As String
    Dim stringfinalacc, stringfinalpass As String
   
    Dim conta As Integer
    Dim pcs(3) As Long
    Dim acc(3) As String
    Dim pass(3) As String
   
    conta = 0
   
    myProcess.dwSize = Len(myProcess)
   
    mySnapshot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
    ProcessFirst mySnapshot, myProcess
    If InStr(1, Strings.UCase(myProcess.szexeFile), "DZOM") Then
    pcs(conta) = myProcess.th32ProcessID
    conta = conta + 1
    End If
   
    While ProcessNext(mySnapshot, myProcess)
    If InStr(1, Strings.UCase(myProcess.szexeFile), "DZOM") Then
    pcs(conta) = myProcess.th32ProcessID
    conta = conta + 1
    End If
    Wend

    For x = 0 To 3
    If pcs(x) <> 0 Then
   
   
   
' --- HERE STARTS THE PROBLEM
' The addresses used to be static for acc(x) and pass(x), so they could be used in each loop/for all program instances without issue
' Now they are sometimes dynamic so I have to compare the values of 5 addresses to find the correct ones. The problem? Dynamically reading and comparing the addresses for each loop/program instance
    stringstaticacc = ReadMemory_String(pcs(x), "&h00946CC4", 32)
    stringstaticpass = ReadMemory_String(pcs(x), "&h00946CE0", 32)
    stringacc1 = ReadMemory_String(pcs(x), "&h01FFF1E0", 32)
    stringpass1 = ReadMemory_String(pcs(x), "&h01C2AB68", 32)
    stringpass2 = ReadMemory_String(pcs(x), "&h02000F80", 32)
       
' I want that acc(x) and pass(x), in each loop (that is, for each process instance of the program), read anew the addresses (above), and compare the values (below) and accordingly use the correct addresses depending on what they found       
    If Len(stringstaticacc) >= 6 And Len(stringstaticpass) >= 8 Then
    stringfinalacc = stringstaticacc
    stringfinalpass = stringstaticpass
    End If
    If stringstaticacc <> stringacc1 And Len(stringstaticpass) >= 8 And Len(stringacc1) >= 16 Then
    stringfinalacc = stringacc1
    stringfinalpass = stringstaticpass
    End If
    If Len(stringstaticacc) >= 6 And stringstaticpass <> stringpass1 And Len(stringpass1) >= 16 Then
    stringfinalacc = stringstaticacc
    stringfinalpass = stringpass1
    End If
    If stringstaticacc <> stringacc1 And stringstaticpass <> stringpass2 And Len(stringacc1) >= 16 And Len(stringpass2) >= 16 Then
    stringfinalacc = stringacc1
    stringfinalpass = stringpass2
    End If
'  --- HERE ENDS THE PROBLEM

 
    Formulary.TXTP(x).Text = stringfinalacc
    dxs1 = Len(Formulary.TXTP(x).Text)
    If dxs1 <> 0 Then
    acc(x) = Left$(stringfinalacc, dxs1)
    Else
    acc(x) = ""
    End If


    Formulary.TXTP(x).Text = stringfinalpass
    dxs2 = Len(Formulary.TXTP(x).Text)
    If dxs2 <> 0 Then
    pass(x) = Left$(stringfinalpass, dxs2)
    Else
    pass(x) = ""
    End If
   
         

    Formulary.L(x).Caption = x & ": " & acc(x) & " / " & pass(x)
    End If
    Next
   
    End Function


Viewing all articles
Browse latest Browse all 42722

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>