View previous topic :: View next topic |
Author |
Message |
fade2gray Cheater Reputation: 0
Joined: 01 Oct 2010 Posts: 30
|
Posted: Thu May 23, 2024 11:08 am Post subject: [Solved]Lua script to change debugger when starting CE |
|
|
Hi, Lua novice here.
I can see from the celua.txt that I can manipulate CE's settings directly using a Lua script in the autorun folder, I just don't know how to implement what I see.
celua.txt wrote: | Settings class
This class can be used to read out and set settings of cheat engine and of plugins, and store your own data
global functions
reloadSettingsFromRegistry(): This will cause cheat engine to reload the settings from the registry and apply them
getSettings(path Optional): Settings - Returns a settings object. If path is nil it will point to the Cheat Engine main settings (Registry) . If name is provided the settings currently accessed will be the one at the subkey provided
Note: Keep in mind that it returns a new object each call, even if he same name is used multiple times
etc ... etc ... |
Pseudocode for what I'd like to do.
Code: |
if registry value for VEH debugger = 1
set value to 0
if registry value for windows debugger = 1
set value to 0
if registry value for Kernel debugger = 1
set value to 0
if registry value for DBVM debugger = 1
set value to 0
(i.e. have no debugger set as default at CE startup)
|
Thanks for any help.
_________________
I am, and always will be, a CE novice.
Last edited by fade2gray on Mon May 27, 2024 11:28 am; edited 1 time in total |
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 146
Joined: 06 Jul 2014 Posts: 4485
|
Posted: Thu May 23, 2024 12:06 pm Post subject: |
|
|
Code: | local f = getSettingsForm()
print('Windows:',tostring(f.cbUseWindowsDebugger.checked))
print('VEH: ',tostring(f.cbUseVEHDebugger.checked))
print('Kernel: ',tostring(f.cbKDebug.checked))
print('DBVM: ',tostring(f.cbUseDBVMDebugger.checked))
local function to_bool(bytetable)
return byteTableToDword(assert(bytetable), false) ~= 0
end
local reg = getSettings()
print('Windows:',tostring(to_bool(reg.getBinaryValue'Use Windows Debugger')))
print('VEH: ',tostring(to_bool(reg.getBinaryValue'Use VEH Debugger')))
print('Kernel: ',tostring(to_bool(reg.getBinaryValue'Use Kernel Debugger')))
print('DBVM: ',tostring(to_bool(reg.getBinaryValue'Use DBVM Debugger'))) |
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
fade2gray Cheater Reputation: 0
Joined: 01 Oct 2010 Posts: 30
|
Posted: Fri May 24, 2024 6:22 am Post subject: |
|
|
Thanks for the code, but it doesn't do quite what I was hoping for.
The code only displays ...
a) The default debugger settings used when the debugger options are opened for the first time, and ...
b) The settings as they are seen in the debugger options, if they have been subsequently changed.
Thanks for any further advice.
PS: Maybe I need to somehow implement the method, 'setBinaryValue(name, stream, size OPTIONAL)'
Description: |
|
Filesize: |
15.65 KB |
Viewed: |
2513 Time(s) |
|
Description: |
|
Filesize: |
16.04 KB |
Viewed: |
2513 Time(s) |
|
_________________
I am, and always will be, a CE novice. |
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 146
Joined: 06 Jul 2014 Posts: 4485
|
Posted: Fri May 24, 2024 11:41 am Post subject: |
|
|
You could set the `checked` property to false, but why would you want to do that? Other than forbidding the user from debugging the process, I don't see how that would do anything.
There are debugging functions available you might not know about:
Quote: | debugProcess(interface OPT): starts the debugger for the currently opened process (won't ask the user) Optional interface: 0=default, 1=windows debug, 2=VEHDebug, 3=Kerneldebug
debug_isDebugging(): Returns true if the debugger has been started
debug_getCurrentDebuggerInterface() : Returns the current debuggerinterface used (1=windows, 2=VEH 3=Kernel, nil=no debugging active)
... | from celua.txt
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
fade2gray Cheater Reputation: 0
Joined: 01 Oct 2010 Posts: 30
|
Posted: Sat May 25, 2024 8:47 am Post subject: |
|
|
Situation:
I may have previously booted using a DBVM bootloader, start CE and enabled DBVM, performed a scan and then use 'What accesses this address' with the DBVM debugger selected in Settings/Options.
The next time I boot up, I might do so without using the bootloader. If I then try doing 'What accesses this address', forgetting that the DBVM debugger is selected, I end up with a bunch of error messages.
I just thought it may be a simple solution to use Lua to automatically toggle from DBVM/Kernel debugger to the Windows/VEH debugger to avoid that situation.
Otherwise, I'll just use the following script to remind myself.
Code: | local function to_bool(bytetable)
return byteTableToDword(assert(bytetable), false) ~= 0
end
local reg = getSettings()
local dbgrDBVM = tostring(to_bool(reg.getBinaryValue'Use DBVM Debugger'))
local dbgrKernel = tostring(to_bool(reg.getBinaryValue'Use Kernel Debugger'))
if dbgrDBVM == "true" or dbgrKernel == "true" then
print("Warning: The DBVM or Kernel debugger is selected in Options.\n\nDon't forget to select the Windows or VEH debugger before using \'What writes to/accesses this address\' if DBVM isn't running.")
end |
Quote: | You could set the `checked` property to false ... |
I would try, but I can't figure how to do that.
_________________
I am, and always will be, a CE novice. |
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 146
Joined: 06 Jul 2014 Posts: 4485
|
Posted: Sat May 25, 2024 11:37 am Post subject: |
|
|
fade2gray wrote: | I just thought it may be a simple solution to use Lua to automatically toggle from DBVM/Kernel debugger to the Windows/VEH debugger to avoid that situation. |
Code: | local f = getSettingsForm()
if f.cbUseDBVMDebugger.checked or f.cbKDebug.checked then
-- radio control: all others are automatically set to false
f.cbUseWindowsDebugger.checked = true
end |
Note that this won't modify the settings in the registry. The next time you start CE, the DBVM debugger could still be checked by default.
Code: | local f = getSettingsForm()
if f.cbUseDBVMDebugger.checked or f.cbKDebug.checked then
f.cbUseWindowsDebugger.checked = true
local reg = getSettings()
reg["Use Windows Debugger"] = true
reg["Use Kernel Debugger"] = false
reg["Use DBVM Debugger"] = false
end | PS: I noticed setting the "Value" property of the TLuaSettings class correctly interprets boolean values; no need to access raw byte tables. Reading any setting just returns a string, and bools in the registry are usually just integers:
Code: | print(tostring(getSettings()["Use Windows Debugger"] ~= '0')) |
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
fade2gray Cheater Reputation: 0
Joined: 01 Oct 2010 Posts: 30
|
Posted: Mon May 27, 2024 5:58 am Post subject: |
|
|
Thanks for trying, but I can't get any of the above to work as I'd like.
Is it not possible to use 'setBinaryValue(name, bytetable)'?
_________________
I am, and always will be, a CE novice. |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 463
Joined: 09 May 2003 Posts: 25478 Location: The netherlands
|
Posted: Mon May 27, 2024 10:37 am Post subject: |
|
|
try '1'
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
fade2gray Cheater Reputation: 0
Joined: 01 Oct 2010 Posts: 30
|
Posted: Mon May 27, 2024 11:24 am Post subject: |
|
|
Thank you DB.
Code: |
local function to_bool(bytetable)
return byteTableToDword(assert(bytetable), false) ~= 0
end
local reg = getSettings()
local dbgrDBVM = tostring(to_bool(reg.getBinaryValue'Use DBVM Debugger'))
local dbgrKernel = tostring(to_bool(reg.getBinaryValue'Use Kernel Debugger'))
if dbgrDBVM == "true" or dbgrKernel == "true" then
reg["Use VEH Debugger"] = '1'
reg["Use Windows Debugger"] = '0'
reg["Use Kernel Debugger"] = '0'
reg["Use DBVM Debugger"] = '0'
end |
_________________
I am, and always will be, a CE novice. |
|
Back to top |
|
|
|