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 


Convert Pointer To Code Script

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> LUA Tutorials
View previous topic :: View next topic  
Author Message
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8517
Location: 127.0.0.1

PostPosted: Sun Dec 09, 2012 1:57 pm    Post subject: Convert Pointer To Code Script Reply with quote

I wrote this for the beta of Cheat Engine 6.x a while ago and kinda forgot about it. It was released in the beta section for testing but I don't think many really checked it out. So I'm uploading the last released version here for others to check out.

The purpose of this script is it will allow you to convert a pointer in your table to a programming language. Currently I coded support for C++ and C# but I left the script modular to make adding new languages very easy. You can check the converters out in the code on how to make your own.

Download
http://www.mediafire.com/?guk1il8fq968j59

Installation
Drop the converter.lua into your autorun folder in your Cheat Engine folder.

Default locations for this are:
32bit: C:\Program Files\Cheat Engine 6.2\autorun
64bit: C:\Program Files (x86)\Cheat Engine 6.2\autorun

And drop the converters folder into the autorun folder so the folder structure remains in tact.

Usage
This script adds a new menu to your right-click menu when you right-click entries in your table(s).

Simply right-click a pointer, and choose a sub-option which will be a language to convert it to. Once the script finishes the newly generated code will be pasted into your clipboard.

The converters DO work with scripts that use registered globals as addresses too. For example I have:
Code:

[ENABLE]
REGISTERSYMBOL(player_x)
REGISTERSYMBOL(player_y)
REGISTERSYMBOL(player_z)
alloc(player_x,4)
alloc(player_y,4)
alloc(player_z,4)
alloc(newmem,2048) //2kb should be enough
label(returnhere)
label(originalcode)
label(exit)

newmem: //this is allocated memory, you have read,write,execute access
//place your code here

originalcode:
push eax
push ecx
mov ecx, eax

lea eax, dword ptr[ecx+04]
mov [player_y], eax

lea eax, [ecx+08]
mov [player_z], eax

lea eax, [ecx+00]
mov [player_x], eax

pop ecx
pop eax

fld dword ptr [eax+04]
fadd dword ptr [ebp-08]

exit:
jmp returnhere

"DBProBasic3DDebug.dll"+1E2E7:
jmp newmem
nop
returnhere:

[DISABLE]
"DBProBasic3DDebug.dll"+1E2E7:
fld dword ptr [eax+04]
fadd dword ptr [ebp-08]
dealloc(player_x)
dealloc(player_y)
dealloc(player_z)
dealloc(cave)
UNREGISTERSYMBOL(player_x)
UNREGISTERSYMBOL(player_y)
UNREGISTERSYMBOL(player_z)


And I have a pointer for the z coord:
Address: player_z
Offset 1: 0

I convert this to C++ using converter and get:
Code:

    DWORD dwBaseAddress = 0x02EB0008;
    DWORD dwCurrValue   = NULL;
    float flResult = 0.0f;
    DWORD dwOffsets[]   = { 0x0 };
    DWORD dwOffsetCount = sizeof( dwOffsets ) / sizeof( dwOffsets[ 0 ] );

    ReadProcessMemory( hProcess, (LPVOID)dwBaseAddress, &dwCurrValue, 4, NULL );

    for( unsigned int x = 0; x < ( dwOffsetCount - 1 ); x++ )
    {
        dwBaseAddress = dwCurrValue + dwOffsets[ x ];
        ReadProcessMemory( hProcess, (LPVOID)dwBaseAddress, &dwCurrValue, 4, NULL );
    }

    dwBaseAddress = dwCurrValue + dwOffsets[ dwOffsetCount - 1 ];
    ReadProcessMemory( hProcess, (LPVOID)dwBaseAddress, &flResult, sizeof( flResult ), NULL );



Notice
The code produced by both the included converts can be written differently / better.
They are not recommended code.
They are simply examples to show you how to use this script to write your own converters for your favorite language.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> LUA Tutorials 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 cannot download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites