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 


Auto-fill pointerscanner scanoptions window

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> LUA Tutorials
View previous topic :: View next topic  
Author Message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Thu Apr 26, 2012 8:25 am    Post subject: Auto-fill pointerscanner scanoptions window This post has 1 review(s) Reply with quote

Auto-fill pointerscanner scanoptions window
Custom settings (address, maxlevel, offsets) at the end of script.

Script only do this:
address to find, pointer must end with specific offsets checkbox, offsets and max level

This is for current ce revision and newer.
Code:
RequiredCEVersion=6.2
if (getCEVersion==nil) or (getCEVersion()<RequiredCEVersion) then
  messageDialog('Please install Cheat Engine '..RequiredCEVersion, mtError, mbOK)
  closeCE()
end

function searchForForm(name)
  local formptr
  local formname

  for i=0, getFormCount() - 1  do
    formptr = getForm(i)
    formname = getProperty(formptr,'name')
    if formname == name then
      return formptr
    end
  end

  return nil
end

function searchForSubmenu(parentForm,menuname,index)
  local menu = component_findComponentByName(parentForm, menuname)
  local submenu = menuItem_getItem(menu, index)
  return submenu
end

function PointerScanSettingsWindowSet(timer)

  timer_setEnabled(timer,false)

  PSSF = searchForForm('frmPointerScannerSettings')


  local edtAddress = component_findComponentByName(PSSF
                 ,'edtAddress')
  control_setCaption(edtAddress,myADDRESS)

  local editMaxLevel = component_findComponentByName(PSSF
                 ,'editMaxLevel')

  control_setCaption(editMaxLevel,myMAXLEVEL)

  local MustEndOffset = component_findComponentByName(PSSF
                 ,'cbMustEndWithSpecificOffset')

  setProperty(MustEndOffset,'Checked','false') --clean
  setProperty(MustEndOffset,'Checked','true')
  -- now EditOffset1 already exist


  local AddButton  = component_findComponentByName(PSSF,'btnAddOffset')
  if (#myOffsets > 1) then
    for i=1,#myOffsets - 1 do control_doClick(AddButton) end
  end

  for i=1,#myOffsets do
    local EditOffset  = component_findComponentByName(PSSF,'EdtOffset'..i)
    control_setCaption(EditOffset,myOffsets[i])
  end

end


function pointerscan()

  local submenuToPSF = searchForSubmenu(getMemoryViewForm(),'Extra1',11)
  menuItem_doClick(submenuToPSF)
  local PSF = searchForForm('frmPointerScanner')
  form_centerScreen(PSF)

  local submenuToPSSF = searchForSubmenu(PSF,'Pointerscanner1',0)

  local             myTimer = createTimer(nil,true)
  timer_setInterval(myTimer,500)
      timer_onTimer(myTimer,PointerScanSettingsWindowSet)

  menuItem_doClick(submenuToPSSF)

end


myADDRESS = '00466666'
myMAXLEVEL = 3
myOffsets = {'200','50'} -- last offset is 200

pointerscan()


If you want to set

Edit boxes:
"from"
"to"
"maximum offset value"
"nr of threads scanning"

add this:
Code:
local edtReverseStart = component_findComponentByName(PSSF
                 ,'edtReverseStart')
control_setCaption(edtReverseStart,'00000000')


local edtReverseStop = component_findComponentByName(PSSF
                 ,'edtReverseStop')
control_setCaption(edtReverseStop,'7FFFFFFF')


local editStructsize = component_findComponentByName(PSSF
                 ,'editStructsize')
control_setCaption(editStructsize,'2048')


local edtThreadcount = component_findComponentByName(PSSF
                 ,'edtThreadcount')
control_setCaption(edtThreadcount,'2')




Check boxes:
"address must be 32bit aligned"
"only find paths with static address"
"don't include pointers with read-only nodes"
"stop traversing a path when static has been found"

add this:
Code:
local CbAlligned = component_findComponentByName(PSSF
                 ,'CbAlligned')
setProperty(CbAlligned,'Checked','true')


local cbStaticOnly = component_findComponentByName(PSSF
                 ,'cbStaticOnly')
setProperty(cbStaticOnly,'Checked','true')


local cbNoReadOnly = component_findComponentByName(PSSF
                 ,'cbNoReadOnly')
setProperty(cbNoReadOnly,'Checked','true')


local cbOnlyOneStatic = component_findComponentByName(PSSF
                 ,'cbOnlyOneStatic')
setProperty(cbOnlyOneStatic,'Checked','true')


You can merge this script with memscan_fistScan and memscan_nextScan instructions.






For example, I know correct "end offsets" for pointer and I know how hero structure looks like.

pointer to medallion: [[[[baseaddress]+250]+14]+29c]

structure:
0x29c medallion (1byte) - when charged = 1
0x2ac EXP (4byte)
0x2b0 talent (4byte)


The problem is: I don't know pointer base address for other game version (Retail vs STEAM).

I figured out that I can use groupscan for searching for this structure. We can read EXP and talent values, they are inside witcher 2 inventory menu.

Group scan command looks like this:
1:1 w:15 4:exp 4:talent

Then launch pointerscan for found address.

Final tool is here (tool for witcher 2): link
You can test it with calc.exe. Copy and paste calc.exe file, rename it to witcher2.exe, launch witcher2.exe(calc), then launch tool.

Values to try:
15345,34 (most probably, zero results)
0,0 (many results, like few 100s)
0,1 (few 10s)
if you write unique values (my calc.exe and exp:0 talent:2), pointerscan begins.


tool for witcher 2 full lua script:

you need form (UDF1) with button (onclick set to CEButton1Click) and two edit boxes (UDF1_CEEdit1 and UDF1_CEEdit2)


Code:
function searchForFormAndSetText(name,text)
  local formptr
  local formname

  for i=0, getFormCount() - 1  do
    formptr = getForm(i)
    formname = getProperty(formptr,'name')
    if formname == name then
      if text then control_setCaption(formptr, text) end
      return formptr
    end
  end

  return nil
end

function searchForSubmenu(parentForm,menuname,index)
  local menu = component_findComponentByName(parentForm, menuname)
  local submenu = menuItem_getItem(menu, index)
  return submenu
end

function PointerScanSettingsWindowSet(timer)

  timer_setEnabled(timer,false)

  PSSF = searchForFormAndSetText('frmPointerScannerSettings',
                              'PRESS ONLY OK BUTTON! Then save file.')


  local edtAddress = component_findComponentByName(PSSF
                 ,'edtAddress')
  control_setCaption(edtAddress,myADDRESS)
 
  local editMaxLevel = component_findComponentByName(PSSF
                 ,'editMaxLevel')

  control_setCaption(editMaxLevel,myMAXLEVEL)

  local MustEndOffset = component_findComponentByName(PSSF
                 ,'cbMustEndWithSpecificOffset')

  setProperty(MustEndOffset,'Checked','false') --clean
  setProperty(MustEndOffset,'Checked','true')
  -- now EditOffset1 already exist


  local AddButton  = component_findComponentByName(PSSF,'btnAddOffset')
  if (#myOffsets > 1) then
    for i=1,#myOffsets - 1 do control_doClick(AddButton) end
  end

  for i=1,#myOffsets do
    local EditOffset  = component_findComponentByName(PSSF,'EdtOffset'..i)
    control_setCaption(EditOffset,myOffsets[i])
  end

end


function pointerscan()

  local submenuToPSF = searchForSubmenu(getMemoryViewForm(),'Extra1',11)
  menuItem_doClick(submenuToPSF)
  local PSF = searchForFormAndSetText('frmPointerScanner'
                              ,'Searching pointer for Witcher 2 v3, wait')
  form_centerScreen(PSF)

  local submenuToPSSF = searchForSubmenu(PSF,'Pointerscanner1',0)

  local             myTimer = createTimer(nil,true)
  timer_setInterval(myTimer,500)
      timer_onTimer(myTimer,PointerScanSettingsWindowSet)

  menuItem_doClick(submenuToPSSF)

end








ms = createMemScan()
FL = createFoundList(ms)
memscanusedbefore=false

strings_add(getAutoAttachList(), "witcher2.exe")
control_setCaption(UDF1,control_getCaption(UDF1_CEButton1))
form_show(UDF1)

myADDRESS = nil
myMAXLEVEL = 3
myOffsets = {'29c','14','250'} -- last offset is 29c


function CEButton1Click(sender)
  local exp = control_getCaption(UDF1_CEEdit1)

  local talent = control_getCaption(UDF1_CEEdit2)

  local groupscancommand = '1:1 w:15 4:'..exp..' 4:'..talent

  if (memscanusedbefore==true) then foundlist_deinitialize(FL) end
  memscanusedbefore=true

  memscan_firstScan(ms, soExactValue, vtGrouped, rtRounded, groupscancommand,
                  "", "0x00000000", "0x7fffffff", "+W*X-C", fsmAligned, "4",
                  false, false, false, false)

  memscan_waitTillDone(ms)
  foundlist_initialize(FL)

  FlCount = foundlist_getCount(FL)
  if (FlCount == 1) then
    myADDRESS = foundlist_getAddress(FL,0)
    pointerscan()
  else
    message = [[Nothing found, did you write correct values?]]

    if (FlCount~=0) then message=[[
More than 1 address found,
please change exp or talent value (kill monster or something)]]
    end
 
    showMessage(message..'\r\n\r\nAddresses found: '..FlCount)
  end
 
end

function FormClose(sender)
  foundlist_deinitialize(FL)
  object_destroy(ms)
  form_hide(UDF1)
  closeCE()
  return caFree --Possible options: caHide, caFree, caMinimize, caNone
end




errors? suggestions? send PM.

_________________
Back to top
View user's profile Send private message MSN Messenger
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