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 


Create - edit - read key to Windows Registry.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> LUA Tutorials
View previous topic :: View next topic  
Author Message
AylinCE
Grandmaster Cheater Supreme
Reputation: 32

Joined: 16 Feb 2017
Posts: 1253

PostPosted: Mon Jun 19, 2023 4:00 am    Post subject: Create - edit - read key to Windows Registry. Reply with quote

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! Wink )

Until we talk about something else crazy, enjoy it.

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Rafael Lima
How do I cheat?
Reputation: 0

Joined: 05 Feb 2021
Posts: 1
Location: Brasil

PostPosted: Mon Jun 19, 2023 8:51 am    Post subject: Good Reply with quote

good
_________________
Não se limite a aprender!
Back to top
View user's profile Send private message
Asuna098
How do I cheat?
Reputation: 0

Joined: 21 Jan 2023
Posts: 1

PostPosted: Mon Jun 19, 2023 9:48 am    Post subject: Reply with quote

Thanks ..
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 32

Joined: 16 Feb 2017
Posts: 1253

PostPosted: Mon Jun 19, 2023 9:54 am    Post subject: Reply with quote

Thanks for the feedback.
Feel free to write a review or leave a reputation if it worked for you.

Note: You can read many keys in the Registry with the Read method.

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
a2z
Advanced Cheater
Reputation: 0

Joined: 28 Nov 2022
Posts: 58

PostPosted: Sat Aug 26, 2023 10:08 am    Post subject: Reply with quote

Where to replace with this new code in here?
https://forum.cheatengine.org/viewtopic.php?t=613418
Back to top
View user's profile Send private message
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