AylinCE Grandmaster Cheater Supreme Reputation: 34
Joined: 16 Feb 2017 Posts: 1432
|
Posted: Mon Jun 19, 2023 4:00 am Post subject: Create - edit - read key to Windows Registry. |
|
|
Disclaimer:
This coding has been prepared only to give an example of the Lua language.
Cheat Engine is not responsible for your intended use (Good or Bad) and its consequences.
Although the Cheat Engine Forum (CEF) wants to popularize the use of the Lua language and make people turn to coding more;
It can never be held responsible for misuse of codes published by users.
By using these codes, you agree to the above terms.
And by posting this code, I agree to the above terms.
See the last part of this topic:
https://forum.cheatengine.org/viewtopic.php?t=620274
In case of updating or resetting the CE, the VIP codes you saved for the user become invalid and you have to create and save it again.
Here is another solution.
You will now load and read the code into a different key instead of the CE registration key ( getSettings() ).
Thus, changes made in CE will not affect your Trainer and user code.
Here is your code:
Code: |
--###########################################################--
--###########################################################--
local registry = {}
local reg = [[%WINDIR%/System32/reg.exe ]]
local userKey = [[HKEY_CURRENT_USER\SOFTWARE\]]
local function execute (cmd)
local res1,res2 = os.execute(cmd)
return res1,res2
end
function registry.createkey(key)
local ok, ec, out, err = execute(reg..[[ADD ]]..key..[[ /f]])
if not ok then
return false
else
return true
end
end
function registry.writevalue(key, name, vtype, value)
newkey1 = registry.createkey(key)
local command
if name == "(Default)" or name == nil then
command = reg..[[ADD ]]..key.." /ve /t "..vtype.." /d "..value.." /f"
else
command = reg..[[ADD ]]..key.." /v "..name.." /t "..vtype.." /d "..value.." /f"
end
local ok, ec, out, err = execute(command)
if not ok then
return "false"
else
return "true"
end
end
function registry.readKey(key,keyName)
local handle = io.popen(reg..[[query ]]..key..[[ /v ]]..keyName)
tmp = {}
for line in handle:lines() do
table.insert(tmp,line)
print(line)
end
result = ""
for i,k in pairs(tmp) do
rd = tmp[i]:match("REG_SZ%s+(.*)")
if rd~=nil then
result=rd
end
end
return result
end
--###########################################################--
--###########################################################--
-- Recording and reading usage:
--The names and vip code here are examples. You can give them a new name and vip code.
keyValue = "55ZS12DF66"
keySettings = "MyKey"
keyName = "VIP"
--Write (Save) key: ( Or change - save key )
aa11 = registry.writevalue(userKey..keySettings, keyName, "REG_SZ", keyValue)
print(11,aa11)
-- Read (Load) key
aa22 = registry.readKey(userKey..keySettings, keyName)
if aa22=="" then
print(21,"not found!")
else
print(22,aa22)
end |
Of course, it is possible to interfere and edit this code from the outside.
Therefore, it should be combined with the "Machine Id" code I gave in the previous topic.
So even though the Registration key code is edited, the Machine Id code will be difficult to change and will keep your code secure.
My advice is to open Reg.exe and the corresponding registry folder and find a name close to the keys there and save it.
--########################################--
And one more topic.
I hope you don't make any wrong attempts to damage your reputation while using the code.
Remember; Anyone who wishes to use the code agrees to the terms of the "Disclaimer".
( Don't bother CE! )
Until we talk about something else crazy, enjoy it.
_________________
|
|