Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Converting AOB

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Sat Dec 10, 2016 10:10 pm    Post subject: Converting AOB Reply with quote

Hi guys,

Code:

function string.trimstart(s, c)
    if (not c) then c = ' '; end
    s = string.reverse(s);
    s = string.trimend(s, c);
    return string.reverse(s);
end

-- desc: Trims the end of a string for whitespace.
function string.trimend(s, c)
    if (not c) then c = ' '; end
    if (string.sub(s, -1) == c) then
        s = string.sub(s, 0, -2);
        s = string.trimend(s, c);
    end
    return s;
end

-- desc: Trims a string of whitespace.
function string.trim(s, c)
    if (not c) then c = ' '; end
    s = string.trimstart(s, c);
    s = string.trimend(s, c);
    return s;
end

-- desc: Converts the given string to a hex array string.
function str2hexstr(str)
    local ret = '';
    for x = 1, #str do
        -- Pull a single character from the string..
        local val = str:sub(x, x);
        -- Convert the character to hex..
        local c = string.byte(val);
        -- Append to the result..
        ret = ret .. string.format('%02X ', c);
    end
    -- Trim and return the result..
    return ret:trim();
end

---- Test
input= 1  --- get input value using CEEdit, identifying as 'String Value"
input=str2hexstr(input)
print(input)
------- result = 31  (as AOB) or AOB string ?


------- Use DEC_HEX
function DEC_HEX(IN)
    local B,K,OUT,I,D=16,"0123456789ABCDEF","",0
    while IN>0 do
        I=I+1
        IN,D=math.floor(IN/B),math.mod(IN,B)+1
        OUT=string.sub(K,D,D)..OUT
    end
    return OUT
end

a=DEC_HEX(1)
print(a)

1



I know for number = 1 (pushbyte 1), will give AOB = 24 01
I have search for some lua references to convert number to AOB.
Is there any function to do that ?

Thank and regard
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sat Dec 10, 2016 10:31 pm    Post subject: Reply with quote

Code:
wordToByteTable(number): {}       - Converts a word to a bytetable
dwordToByteTable(number): {}      - Converts a dword to a bytetable
qwordToByteTable(number): {}      - Converts a qword to a bytetable
floatToByteTable(number): {}      - Converts a float to a bytetable
doubleToByteTable(number): {}     - Converts a double to a bytetable
stringToByteTable(string): {}     - Converts a string to a bytetable
wideStringToByteTable(string): {} - Converts a string to a widestring and converts that to a bytetable

string.format("%X", number)
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Sun Dec 11, 2016 6:22 am    Post subject: Reply with quote

Thanks Zanzer,

Test
Code:

a=1
print(unpack(wordToByteTable(a)))
print(unpack(dwordToByteTable(a)))
print(unpack(qwordToByteTable(a)))
print(unpack(floatToByteTable(a)))
print(unpack(doubleToByteTable(a)))
print(unpack(stringToByteTable(tostring(a))))
print(unpack(wideStringToByteTable(tostring(a))))
print(string.format("%X", a))

1 0
1 0 0 0
1 0 0 0 0 0 0 0
0 0 128 63
0 0 0 0 0 0 240 63
49
49 0
1


I just looking for some references to get understand from where pushbyte 1 refer as 24 01 in AVM2 opcode
Back to top
View user's profile Send private message
panraven
Grandmaster Cheater
Reputation: 62

Joined: 01 Oct 2008
Posts: 958

PostPosted: Sun Dec 11, 2016 6:43 am    Post subject: Reply with quote

Corroder wrote:
Thanks Zanzer,
....

I just looking for some references to get understand from where pushbyte 1 refer as 24 01 in AVM2 opcode


https://konghack.com/content/19-avm2instructions

_________________
- Retarded.
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Sun Dec 11, 2016 8:27 am    Post subject: Reply with quote

Thanks Panraven

I am also get AVM2 overview from adobe :

http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/actionscript/articles/avm2overview.pdf

regards
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites