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 a CE table into a .dll to inject into a program.

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

Joined: 08 May 2017
Posts: 14
Location: I don't exist... Unfortunately

PostPosted: Sun Jun 03, 2018 11:29 pm    Post subject: Converting a CE table into a .dll to inject into a program. Reply with quote

This way I can get practice on actually writing C/C++ code and produce my goal program rather than working with CE's Lua scripting.

I have a very basic .dll injector set up, although recommendations for different ways or even a guide on manual mapping would be appreciated.


Examples:
Code:
aobscan(MainContext_AOB, 00 00 00 00 10 01 04 00 ?? ?? ?? ?? 00 00 00 00 ?? ?? ?? ?? 00 00 00 00)


Code:
-- Get AddressList Variables, AddressList is an Object named "al":
al = getAddressList()
MouseY = al.getMemoryRecordByDescription("MouseY")
MouseX = al.getMemoryRecordByDescription("MouseX")
MouseZ = al.getMemoryRecordByDescription("MouseZ")
TransientY = al.getMemoryRecordByDescription("TransientY")
TransientX = al.getMemoryRecordByDescription("TransientX")
TransientZ = al.getMemoryRecordByDescription("TransientZ")
ModelY = al.getMemoryRecordByDescription("ModelY")
ModelX = al.getMemoryRecordByDescription("ModelX")
ModelZ = al.getMemoryRecordByDescription("ModelZ")
TargetY = al.getMemoryRecordByDescription("TargetY")
TargetX = al.getMemoryRecordByDescription("TargetX")
TargetZ = al.getMemoryRecordByDescription("TargetZ")
VT = al.getMemoryRecordByDescription("Valid Terrain")
-- Global Real Variables (For Later Use):
transX = tonumber (TransientY.Value)
transY = tonumber (TransientX.Value)
transZ = tonumber (TransientZ.Value)
cursorY = tonumber (MouseY.Value)
cursorX = tonumber (MouseX.Value)
cursorZ = tonumber (MouseZ.Value)
targetPosY = tonumber (TargetY.Value)
targetPosX = tonumber (TargetX.Value)
targetPosZ = tonumber (TargetZ.Value)
validterrain = tonumber (VT.Value)

al = getAddressList()
mr = al.getMemoryRecordByDescription("Gravity")
-- get hotkeys, based on position in list aka index not ID (at least fairly sure it's index)
hk = mr.Hotkey[0]
-- set a function to run the second hotkey after the first has run
-- and the first key has been released
hk.onPostHotKey = function(sender)
  timer = createTimer()
  timer.Interval = 100 -- check every 100 milliseconds
  timer.OnTimer = function(timer)
    if not isKeyPressed(hk.keys[1]) then
      sender.Owner.Hotkey[1].doHotkey()
      timer.destroy()
    end
  end
end

-- function to make key not repeat --
setGlobalKeyPollInterval(100)

function createNonRepHotkey(func, ...)
  local getTickCount=getTickCount
  local lastTickCount=0
  local function changedBehaviour(sender)
    local TC = getTickCount()
    --call orig func when elap is bigger than 300ms
    if (TC - lastTickCount) > 300 then func(sender) end
    lastTickCount = TC
  end

  local hk = createHotkey(changedBehaviour, ...)
  hk.DelayBetweenActivate = 10

  return hk
end

-- create the hotkey
ClickToTeleportHK = createNonRepHotkey(function()
  -- get the value of Mouse
local valueY = tonumber (MouseY.Value)
local valueX = tonumber (MouseX.Value)
local valueZ = tonumber (MouseZ.Value)
-- divide by 32 and add 0.2
valueY = (valueY /-32) + 0.2
valueX = (valueX /32)
valueZ = (valueZ /32)
-- store the value in Transient Position
TransientY.Value = tostring(valueY)
TransientX.Value = tostring(valueX)
TransientZ.Value = tostring(valueZ)
ModelY.Value = tostring(valueY)
ModelX.Value = tostring(valueX)
ModelZ.Value = tostring(valueZ)

end,
{VK_F6})

-- create the hotkey
TeleportToTargetHK = createHotkey(function()
-- get Target Agent Position
local valueY = tonumber (TargetY.Value)
local valueX = tonumber (TargetX.Value)
local valueZ = tonumber (TargetZ.Value)

-- divide by 32 and add 0.2
valueY = (valueY /-32) + 0.2
valueX = (valueX /32)
valueZ = (valueZ /32)
  -- store the value in Transient Position
TransientY.Value = tostring(valueY)
TransientX.Value = tostring(valueX)
TransientZ.Value = tostring(valueZ)
ModelY.Value = tostring(valueY)
ModelX.Value = tostring(valueX)
ModelZ.Value = tostring(valueZ)

end,
{VK_F5})


What functions in C should I use to replace AoB scans like this?
Basically, I want to know what functions that already exist can be used to mimic the features of CE and perhaps help to convert my Lua script that worked off of CE addresses into something that works into a lone-standing .dll program.

Thanks Very Happy

_________________
Um... Hello... Thanks for taking the time to read my pointless signature Smile
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8516
Location: 127.0.0.1

PostPosted: Mon Jun 04, 2018 12:21 pm    Post subject: Reply with quote

Google for FindPattern C/C++ and you'll find a ton of examples of how to do AoB scanning in other languages.
_________________
- 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 -> General programming 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