Jump to content

[Solved]Memory programming in AutoIt


Szhlopp
 Share

Recommended Posts

I found my address and it's global offsets. However, CheatEngine is telling me that "4294964117 = -3179". If I am to program what I want I need to know how to convert that large number into the negative number I need. It's for a coordinate system.

I enter -3179 in the 4byte search and it comes back with "4294964117" everytime. I know for sure I have the right address. And it works great when the number is positive. But as soon as it goes negative I have no idea anymore on how to convert it :mellow:

Thanks!

Szhlopp

Edited by Szhlopp
Link to comment
Share on other sites

$Number = 4294964117

$int = DllStructCreate("int")
$uint = DllStructCreate("uint")

DllStructSetData($int,1,$Number)
DllStructSetData($uint,1,$Number)
MsgBox(0, $Number, "Int:" & DllStructGetData($int,1) & @CRLF & "uInt:" & DllStructGetData($uint,1))

or native AutoIt Code

; http://support.microsoft.com/kb/189323
; Gibt Die Zahl mit Vorzeichen zurück.
; Bei Fehler ( kleiner 0 oder größer MAXINT_4) wird der übergebene Wert zurückgegeben und @error auf 1 gesetzt.

; in AutoIt this is long, int and uint,ulong,dword
Func UnsignedToLong($Value)
    Local Const $OFFSET_4 = 4294967296
    Local Const $MAXINT_4 = 2147483647
    If $Value < 0 Or $Value >= $OFFSET_4 Then Return SetError(1,0,$Value) ;' Overflow
    If $Value <= $MAXINT_4 Then
          Return $Value
        Else
          Return $Value - $OFFSET_4
    EndIf
EndFunc

; in AutoIt this is long, int and uint,ulong,dword
Func LongToUnsigned($Value)
    Local Const $OFFSET_4 = 4294967296
    If $Value < 0 Then
        Return $Value + $OFFSET_4
    Else
        Return $Value
    EndIf
EndFunc

; in AutoIt this is Short and UShort
Func UnsignedToInteger($Value)
    Local Const $OFFSET_2 = 65536
    Local Const $MAXINT_2 = 32767
    If $Value < 0 Or $Value >= $OFFSET_2 Then Return SetError(1,0,$Value) ;' Overflow
    If $Value <= $MAXINT_2 Then
        Return $Value
    Else
        Return $Value - $OFFSET_2
    EndIf
EndFunc

; in AutoIt this is Short and UShort
Func IntegerToUnsigned($Value)
    Local Const $OFFSET_2 = 65536
    If $Value < 0 Then
        Return $Value + $OFFSET_2
    Else
        Return $Value
    EndIf
EndFunc
Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

$Number = 4294964117

$int = DllStructCreate("int")
$uint = DllStructCreate("uint")

DllStructSetData($int,1,$Number)
DllStructSetData($uint,1,$Number)
MsgBox(0, $Number, "Int:" & DllStructGetData($int,1) & @CRLF & "uInt:" & DllStructGetData($uint,1))

or native AutoIt Code

; http://support.microsoft.com/kb/189323
; Gibt Die Zahl mit Vorzeichen zurück.
; Bei Fehler ( kleiner 0 oder größer MAXINT_4) wird der übergebene Wert zurückgegeben und @error auf 1 gesetzt.

; in AutoIt this is long, int and uint,ulong,dword
Func UnsignedToLong($Value)
    Local Const $OFFSET_4 = 4294967296
    Local Const $MAXINT_4 = 2147483647
    If $Value < 0 Or $Value >= $OFFSET_4 Then Return SetError(1,0,$Value) ;' Overflow
    If $Value <= $MAXINT_4 Then
          Return $Value
        Else
          Return $Value - $OFFSET_4
    EndIf
EndFunc

; in AutoIt this is long, int and uint,ulong,dword
Func LongToUnsigned($Value)
    Local Const $OFFSET_4 = 4294967296
    If $Value < 0 Then
        Return $Value + $OFFSET_4
    Else
        Return $Value
    EndIf
EndFunc

; in AutoIt this is Short and UShort
Func UnsignedToInteger($Value)
    Local Const $OFFSET_2 = 65536
    Local Const $MAXINT_2 = 32767
    If $Value < 0 Or $Value >= $OFFSET_2 Then Return SetError(1,0,$Value) ;' Overflow
    If $Value <= $MAXINT_2 Then
        Return $Value
    Else
        Return $Value - $OFFSET_2
    EndIf
EndFunc

; in AutoIt this is Short and UShort
Func IntegerToUnsigned($Value)
    Local Const $OFFSET_2 = 65536
    If $Value < 0 Then
        Return $Value + $OFFSET_2
    Else
        Return $Value
    EndIf
EndFunc
Thanks!
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...