Sign in to follow this  
Followers 0
TrickyDeath

String, interger and binary stuff question

10 posts in this topic

Hello everyone,

Again here with my new question.

I do have a value what is "text" string, what i read from memory adress, but i do not understand when i convert it, why i geting only the first 4 letter from the word...

I was reading how does it storeing in memory, but i am not 100% sure, i did understand right. :(

Anyone can explain how does it work? Or why i get only the first 4 letter only?

Ps.:

Useing Nomadmemory.

BinaryToString($MemRead, 1), 0, 0

The valuse is correct, if i do not convert it at all, but the valuse includeing only numbers. I tried different convert way, but nothing.


Sry for my bad English, and double sry, but I am learning AutoIT language by myself. :)

[u]Tricky[/u]

You can't teach a man anything, you can only help him, find it within himself. (Galileo Galilei)

Share this post


Link to post
Share on other sites



If you are reading from a memory address you probably also have to specify the amount of bytes to read?

Share this post


Link to post
Share on other sites

I wana read commands and those commands can be short how short i want, but i do not wana use 4 letter length strings for command. My problem is this memory storeing thing is new for me, so i am on just about the begning.

I made a GUI with 1 edit and 3 different button on it. Each button storeing the text from Edit in the same value.

I did used Cheat Engine to find the adress for it, and in that program it showeing me the full lengh of the string, but with AutoIT i see only the first 4 letter somehow, and i could not find out why. BTW the GUI is just for test, cause i can try make it work w/o NET connection. Once it will work, i can change the process. Unfortunately skype and viber do not have any controll what i can read with autoIT to read the messages what i am geting or sending. :(

At least i did not found anything like that.

One sec i put the code here in new post, just let me find it.


Sry for my bad English, and double sry, but I am learning AutoIT language by myself. :)

[u]Tricky[/u]

You can't teach a man anything, you can only help him, find it within himself. (Galileo Galilei)

Share this post


Link to post
Share on other sites

#include <NomadMemory.au3>
#include <Array.au3>
#include <String.au3>

#Region Communication List
Global $System[8][2], $Answares[6]
Global $MemRead, $Value, $OrderRegister, $OrderList
;Order List
$System[0][0] = "Shotdown PC" ;Shotdown PC
$System[1][0] = "Open emails"
$System[2][0] = "Undeclared"
$System[3][0] = "Undeclared"
$System[4][0] = "Undeclared"
$System[5][0] = "Undeclared"
$System[6][0] = "Undeclared"
$System[7][0] = "?"

;Function List
$System[0][1] = "ShotDown_PC"
$System[1][1] = "Open_Emails"
$System[2][1] = "Undeclared"
$System[3][1] = "Undeclared"
$System[4][1] = "Undeclared"
$System[5][1] = "Undeclared"
$System[6][1] = "Undeclared"
$System[7][1] = "Help"

;Answare List
$Answares[0] = "Login Failed"
$Answares[1] = "Incorrect Username and / or Password!"
$Answares[2] = "Acces Denide!"
$Answares[3] = "Acces Granted! Wellcome!"
$Answares[4] = "Undeclared"
$Answares[5] = "Undeclared"

$OrderList = $System[0][0] & @CRLF & $System[1][0] & @CRLF & $System[2][0] & @CRLF & $System[3][0] & @CRLF & $System[4][0] & @CRLF & $System[5][0] & @CRLF & $System[6][0] & @CRLF & $System[7][0]
#EndRegion Communication List

_Main()

While 1
    Sleep(100)
WEnd

Func _Main()
    if ProcessExists("Memtest.exe") = 0 Then
        Run("Memtest.exe", "G:\_Instal\4GL\AutoIT\Scripts\Windows\")
    EndIf
    MemoryOpen()
EndFunc   ;==>_Main

#Region - Work together !!!
Func MemoryOpen() ;Work properly !!!
    ;Reading the value from the Process searched Memory Adress

    While 1
        $Process = _MemoryOpen(ProcessExists("Memtest.exe"))
        ;$Process = _MemoryOpen(ProcessExists("Memtest.exe"))
        If Not @error Then
            $MemRead = _MemoryRead("0x" & "0095CD48", $Process)
            ;$MemRead = _MemoryRead("0x" & "0095A578", $Process)
            ToolTip(BinaryToString($MemRead, 1), 0, 0)
            If $OrderRegister <> $MemRead Then
                $OrderRegister = $MemRead
                _Arguments()
            EndIf
            _MemoryClose($Process)
        EndIf
        Sleep(100)
    WEnd
EndFunc   ;==>MemoryOpen

Func _Arguments()
    For $i = 0 To UBound($System) - 1
        If $MemRead = $System[$i][0] Then
            Call($System[$i][1])
        EndIf
    Next
EndFunc   ;==>_Arguments
#EndRegion - Work together !!!

The argument functions include only 1 messagebox message to see it work or not.

Do u need the memtest.exe code as well? also made with autoIT.

nvm, i post that as well.

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Memtest", 140, 170)
$Input1 = GUICtrlCreateInput("", 10, 10, 120, 21)
$btn = GUICtrlCreateButton("Number", 10, 40, 120)
$btn2 = GUICtrlCreateButton("String", 10, 70, 120)
$btn3 = GUICtrlCreateButton("Binary", 10, 100, 120)
$btn4 = GUICtrlCreateButton("Normal", 10, 130, 120)
GUISetState(@SW_SHOW)

Local $Text

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $btn
            $Text = Number(GUICtrlRead($Input1))
        Case $btn2
            $Text = String(GUICtrlRead($Input1))
        Case $btn3
            $Text = Binary(GUICtrlRead($Input1))
        Case $btn4
            $Text = GUICtrlRead($Input1)
    EndSwitch
WEnd

If have any other question let me know.


Sry for my bad English, and double sry, but I am learning AutoIT language by myself. :)

[u]Tricky[/u]

You can't teach a man anything, you can only help him, find it within himself. (Galileo Galilei)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

you need to specify the length to read, default is a dword (4 bytes).

$MemRead = _MemoryRead("0x" & "0095CD48", $Process, "char[80]")
Edited by Geir1983

Share this post


Link to post
Share on other sites

I would be happy if we have a nice help file for that nomadmemory, but since that is just a home made function... the description not telling you everything. I like AutoIT help file, you can learn so much thing, without comming to forum all the time with any single simple question.

What does "char[80]" mean exactly?


Sry for my bad English, and double sry, but I am learning AutoIT language by myself. :)

[u]Tricky[/u]

You can't teach a man anything, you can only help him, find it within himself. (Galileo Galilei)

Share this post


Link to post
Share on other sites

like you said, nomad.au3 is not part of the autoit package.. but it does have documentation for each of the functions inside the source code.

char[80] means it will read 80 characters (letters numbers etc), I did not test it but think it should work?

Share this post


Link to post
Share on other sites

I will chek it, just have to turn on my notebook, cause i am working on that at work, when i do have too much free time and nothing to do. :D

Actualy i start codeing on my mobile phone, then the boss will not realy notice what i do. :D

When the code is done and i go home, i jsut send it to my PC, so i can test it and see it is work or not.


Sry for my bad English, and double sry, but I am learning AutoIT language by myself. :)

[u]Tricky[/u]

You can't teach a man anything, you can only help him, find it within himself. (Galileo Galilei)

Share this post


Link to post
Share on other sites

Ok i did test your example, and work perfect. Thank you for your help. Now i can continue to work on rest of the code to make the whole communication between PC and my phone. :-)


Sry for my bad English, and double sry, but I am learning AutoIT language by myself. :)

[u]Tricky[/u]

You can't teach a man anything, you can only help him, find it within himself. (Galileo Galilei)

Share this post


Link to post
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
Sign in to follow this  
Followers 0

  • Similar Content

    • Dragonfighter
      By Dragonfighter
      I'm searching a way to do xor and shift and if possible also other operations. Thanks in advance for the replies.
    • rudi
      By rudi
      Hello.
      I'm too stupid to see my mistake:
      To investigate the internal "dictionary" of TIFF files I'd like to read in the files in binary mode and to check, if there are more than one pages "in" this TIFF.
      Notepad++, "View as Hex" is presenting the first bytes as "49 49 2a 20 08 20 20 20 12" for the TIF attached to this posting
      The "TIFF Header Format" is easy:
      Offset 00h, 2 Byte = Byte Order, "II"=intel, "MM"=motorola. (I = 0x49)
      --> II
      Offset 02h, 2 Byte = Version Nr.
      Offset 04h, 4 Byte = pointer to first IFD entry
      Description of TIFF header: https://www.awaresystems.be/imaging/tiff/faq.html#q3
       

      Howto read and analyse the binary content correctly? This is my messy, not operational code:
       
      $sampleTiff="H:\daten\tif\11\11\111111.TIF" $h=FileOpen($sampleTiff,16) $content=FileRead($h) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $content = ' & $content & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console FileClose($h) $type=VarGetType($content) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $type = ' & $type & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $ToString=BinaryToString($content) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $ToString = ' & $ToString & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console ConsoleWrite(@CRLF & @CRLF) $content=StringTrimLeft($content,2) ; cut off the leading "0x" ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $content = ' & $content & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console for $i = 1 to 8 step 8 $next=StringMid($content,$i,2) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $next = ' & $next & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $Chr=BinaryToString($next) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Chr = ' & $Chr & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console ConsoleWrite(@CRLF & "---" & @CRLF) Next Regards, Rudi.
      111111.TIF
    • ur
      By ur
      When I am trying to compile the autoit files with aut2exe.
      I am getting below error.
      There is no issue in code as the same code is getting compiled on different machine.
      I tried reinstalling the AUtoIT, but the issue replicates.

      Any suggestions?
    • cheeroke
      By cheeroke
      Hi all,
      I got this code and would like to be able to change Baud Rate and instead of sending character by character i would like to be able (if possible) to send whole string. But i don't know how to change it.
      I am taking input from file and processing whole line (this is done in FilesHandling.au3).
      To execute this i am just calling SendData("FileName", int) in "main" script.
      Any help very appreciated.
      #include <WinAPI.au3> #include <Array.au3> #include "FilesHandling.au3" ;init DLL function, we need handle to call the function $h = DllCall("Kernel32.dll", "hwnd", "CreateFile", "str", "\\.\COM19", "int", BitOR($GENERIC_READ,$GENERIC_WRITE), "int", 0, "ptr", 0, "int", $OPEN_EXISTING, "int", $FILE_ATTRIBUTE_NORMAL, "int", 0) $handle=$h[0] Func SendData($FileName, $LineNumber) ;string to be send $c = readFile($FileName, $LineNumber) $cLenght = StringLen($c) $aArray = StringSplit($c, "") ;_ArrayDisplay($aArray, "", Default, 64) For $i = 1 To $cLenght writeChar($handle, $aArray[$i], $cLenght) Next ;move to next line writeChar($handle, @CR,1) EndFunc ;write a single char func writeChar($handle,$c,) $stString = DLLStructCreate("char str") $lpNumberOfBytesWritten = 0 DllStructSetData($stString, 1, $c) $res = _WinAPI_WriteFile($handle, DllStructGetPtr($stString, "str"), 1,$lpNumberOfBytesWritten) if ($res<>true) then ConsoleWrite ( _WinAPI_GetLastErrorMessage() & @LF) EndIf EndFunc  
    • FroVN
      By FroVN
      Hi, i have a problem :" can't set the name of file with a special character like: \;/;";|;...  have anyway to short the StringInSrt and Stringreplace? i am using this code but too long
      $title=InputBox(0,'','','')
         if StringInStr($title,'\') or StringInStr($title,'/') or StringInStr($title,':') or StringInStr($title,'*') or StringInStr($title,'?') or StringInStr($title,'"') or StringInStr($title,'<') or StringInStr($title,'>') or StringInStr($title,'|') Then
             $title=StringReplace($title,'\','-')
              $title=StringReplace($title,'/','-')
               $title=StringReplace($title,':','-')
                $title=StringReplace($title,'*','-')
                 $title=StringReplace($title,'?','-')
                  $title=StringReplace($title,'"','-')
                   $title=StringReplace($title,'<','-')
                    $title=StringReplace($title,'>','-')
                     $title=StringReplace($title,'|','-')
         EndIf