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 Lua Script to C++?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
forested
Newbie cheater
Reputation: 0

Joined: 04 Jul 2015
Posts: 23

PostPosted: Thu Aug 06, 2015 11:18 pm    Post subject: Converting Lua Script to C++? Reply with quote

Is there any easy way of doing this? (I don't know c++ so ukno halp)
also this is my script for anybody that wants to convert it to c++
for me and send me the source <3

Code:
aalist=getAutoAttachList() -- Auto attaches to the specified process
stringlist_add(aalist,"DickGobler.exe");
 
form_show(UDF1)
 
function scanAob(array)

result = nil
scan = createMemScan(true)

memscan_returnOnlyOneResult(scan, true)
memscan_firstScan(scan, soExactValue, vtByteArray, rtTruncated, array, nil,

0x00000000, 0xFFFFFFFF, "*W", fsmNotAligned, nil, true, false, false, false)
memscan_waitTillDone(scan)

result = memscan_getOnlyResult(scan)
result = string.format("%x", result)
result = ("0"):rep(8-#result) .. result
end
 
 
function Speedhack()
   debugProcess(3);
         debugger_onBreakpoint=function()
             if EIP==getAddress'006BAE2A'then
                 hasChangedARegister=true;
                 ECX=getAddress'42C80000';
                 changedEAX=true;
             end;
             debug_continueFromBreakpoint(co_run);
             return 1;
         end;

   debug_setBreakpoint(getAddress'006BAE2A');
end
Back to top
View user's profile Send private message
STN
I post too much
Reputation: 43

Joined: 09 Nov 2005
Posts: 2676

PostPosted: Fri Aug 07, 2015 5:24 am    Post subject: Reply with quote

LUA is a scripting language and the functions you are using makes use of CE built-in functions. To convert your code to c++, you will need to make CE export these functions or figure out a way to call them (a plugin perhaps ?).

Or write your own functions in c++ and use them.

_________________
Cheat Requests/Tables- Fearless Cheat Engine
https://fearlessrevolution.com
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Fri Aug 07, 2015 10:22 am    Post subject: Reply with quote

Based on the code you are asking about you are going to need to be able to do a few things.

1. Opening a process while debugging or attaching as a debugger.
2. Scan for an array of bytes.
3. Setting breakpoints.

For 1, you can find information on how to create a debugger here:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms681675(v=vs.85).aspx
http://www.codeproject.com/Articles/43682/Writing-a-basic-Windows-debugger

If you want to attach as a debugger to an existing process, then you will need to look into using:
- DebugActiveProcess, DebugBreakProcess, DebugSetProcessKillOnExit, DebugActiveProcessStop and similar.

2. Scanning for an array of bytes is fairly simple and there are a lot of examples on the web of doing it. Externally you will need to use ReadProcessMemory to dump the memory region you want to scan within. Since your example shows you scanning all memory regions you will need VirtualQueryEx to get the various regions of memory and scan each one as needed. After you can get the info of each region, just dump the memory of the region then scan within it.

You can find various array of byte scanning methods for C++ by looking for FindPattern on Google.

3. For setting a breakpoint and altering the context of a thread, you will need to look into using:
- GetThreadContext / SetThreadContext

You can also check out these links which contain info on setting breakpoints and such (memory and hardware):
http://www.codeproject.com/Articles/28071/Toggle-hardware-data-read-execute-breakpoints-prog
https://github.com/mmorearty/hardware-breakpoints

You can set normal breakpoints by writing to the processes memory and writing a single byte '0xCC' to signify an int3 break. Keep in mind you will need to keep track of that original bytes data and reapply it during debugging to prevent crashes. When a breakpoint is hit using this, you must restore the original data before you continue executing.

For that you will want to look into:
- VirtualProtectEx, WriteProcessMemory, FlushInstructionCache

_________________
- 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 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