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 


AA custom type with variable
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4300

PostPosted: Wed Apr 06, 2022 10:57 am    Post subject: Reply with quote

That code works fine for me with no modifications. The 'xorkeyt' value is unaligned, but that shouldn't cause a problem.

Make sure to use the symbol 'xorkeyt' when writing to memory:
Code:
writeIntegerLocal('xorkeyt',999999999)

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
dharmang1910
Expert Cheater
Reputation: 0

Joined: 09 May 2010
Posts: 102

PostPosted: Wed Apr 06, 2022 12:36 pm    Post subject: Reply with quote

ParkourPenguin wrote:
That code works fine for me with no modifications. The 'xorkeyt' value is unaligned, but that shouldn't cause a problem.

Make sure to use the symbol 'xorkeyt' when writing to memory:
Code:
writeIntegerLocal('xorkeyt',999999999)


Thank you very much for all of your efforts to help me. I have always respect for you. Now I have to accept my fate that this is not work for me. I don't know what is the problem. Is it CE version or game or mine mistake. Just want to know that how can we align that 'xorkeyt'? I just take chance on it as a last try.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4300

PostPosted: Wed Apr 06, 2022 1:46 pm    Post subject: Reply with quote

allocs happen in the order you specify them.
dharmang1910 wrote:
Code:
alloc(ConvertRoutine,1024)
alloc(ConvertBackRoutine,1024)
alloc(TypeName,256)
alloc(ByteSize,4)
alloc(UsesFloat,1)
alloc(CallMethod,1)
alloc(xorkeyt,4)
The problem here is that the xorkeyt alloc comes after the UsesFloat and CallMethod allocs, both of which take only 1 byte. Put it above them and it will be aligned:
Code:
alloc(ConvertRoutine,1024)
alloc(ConvertBackRoutine,1024)
alloc(TypeName,256)
alloc(ByteSize,4)
alloc(xorkeyt,4)
alloc(UsesFloat,1)
alloc(CallMethod,1)

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
dharmang1910
Expert Cheater
Reputation: 0

Joined: 09 May 2010
Posts: 102

PostPosted: Thu Apr 07, 2022 10:19 am    Post subject: Reply with quote

Dark Byte wrote:
is the xor key stored next to the address, or is it only stored once in the target process somewhere far away?
If next to it, increase the bytesize of the type and encompass the xor key in the data

If far away, then you'll have to reload the custom type each time it changes. Or use a lua custom type (slow)


I have increased bytesize upto 8 but still it shows wrong value.
One thing I noticed today is that it is static value all the time if I add with "registerCustomTypeAutoAssembler[[]]" command. This mean if it is mana value then if I use mana even then it is remain static and not decreasing but If I add same script to CE then it works perfect.

So main I think it is not showing right value because it may be goes to freeze or something. Is timer or thread required to update it constantly???
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25296
Location: The netherlands

PostPosted: Thu Apr 07, 2022 11:14 pm    Post subject: Reply with quote

dharmang1910 wrote:
Is timer or thread required to update it constantly???

if the key changes runtime yes (that includes if it changes at the titlescreen, each time you load a save, the address of the key changes and if you use autoattach)

_________________
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
View user's profile Send private message MSN Messenger
dharmang1910
Expert Cheater
Reputation: 0

Joined: 09 May 2010
Posts: 102

PostPosted: Thu Apr 07, 2022 11:32 pm    Post subject: Reply with quote

Dark Byte wrote:
dharmang1910 wrote:
Is timer or thread required to update it constantly???

if the key changes runtime yes (that includes if it changes at the titlescreen, each time you load a save, the address of the key changes and if you use autoattach)


Key is not get changed in whole game session. But main problem is that is shows same output value all the time even if value changes. But same AA script works fine if added in CE. But main problem for this is that it is not noob friendly and if I add this with script then it is added in single click.

Edit:
When I push key with writeIntegerLocal then value is changed accordigly but then it is not changed even that value changed like decrease/increase health etc.

Is having multiple CE version or CE plugins cause this??
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4300

PostPosted: Fri Apr 08, 2022 12:31 am    Post subject: Reply with quote

Let's go back to this post where you show the contents of the two scripts. It's very weird how the 64-bit code was removed. In hindsight, I don't think you removed that 64-bit code yourself. Maybe it's a bug with CE?
What version of CE are you using? Are you using a 32-bit CE? What about the target process? Run this code:
Code:
local i,v = getCheatEngineFileVersion()
local str = ([[
CE version: %s
      file: %X
     major: %d
     minor: %d
   release: %d
%s
%s]]):format(
  getCEVersion(),
  i,
  v.major,
  v.minor,
  v.release,
  cheatEngineIs64Bit() and 'CE is 64-bit' or 'CE is 32-bit',
  targetIs64Bit() and 'target is 64-bit' or 'target is 32-bit'
)

print(str)
writeToClipboard(str)

If CE is 64-bit and it's executing 32-bit code, that's going to cause problems. It could cause this:
dharmang1910 wrote:
One thing I noticed today is that it is static value all the time if I add with "registerCustomTypeAutoAssembler[[]]" command.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
dharmang1910
Expert Cheater
Reputation: 0

Joined: 09 May 2010
Posts: 102

PostPosted: Fri Apr 08, 2022 6:30 am    Post subject: Reply with quote

[quote="ParkourPenguin"]
If CE is 64-bit and it's executing 32-bit code, that's going to cause problems. It could cause this:
dharmang1910 wrote:
One thing I noticed today is that it is static value all the time if I add with "registerCustomTypeAutoAssembler[[]]" command.

Oh thank you very much for hint.
I have tried to remove 32-Bit section from above both script and tried with "registerCustomTypeAutoAssembler" command and It works perfectly with both scripts. So your doubt is right. It cause by 32-Bit section of code. Here is code that I have modify.

Code:
registerCustomTypeAutoAssembler[[

alloc(ConvertRoutine,1024)
alloc(ConvertBackRoutine,1024)
alloc(TypeName,256)
alloc(xorKey,4)
alloc(ByteSize,8)
registerSymbol(xorKey)

TypeName:
db 'xor custom type',0

xorKey:
dd 0

ByteSize:
dd 4


ConvertRoutine:

mov eax,[rcx]
xor eax,[xorKey]
ret


ConvertBackRoutine:

xor ecx,[xorKey]
mov [r8],ecx

ret
]]


Also here is data I got with your script. It is latest version downloaded from CE website.

Code:
CE version: 7.4
      file: 7000400001C85
     major: 7
     minor: 4
   release: 0
CE is 64-bit
target is 64-bit


Now I will go this way

Code:
Local sixtyfour = cheatEngineIs64Bit()

if sixtyfour == 1 then
register 64bit script
else
register 32 bit script
end
Back to top
View user's profile Send private message
dharmang1910
Expert Cheater
Reputation: 0

Joined: 09 May 2010
Posts: 102

PostPosted: Fri Apr 08, 2022 11:10 pm    Post subject: Reply with quote

ParkourPenguin wrote:
dharmang1910 wrote:
Code:
local key = readInteger(getAddressSafe("location")+0xc)
This might be bad. If getAddressSafe returns nil, then that will generate an error (attempt to perform arithmetic on a nil value). Use the same syntax I did:
Code:
local key = readInteger('[location]+0xc')
CE will try to convert the string passed into read* functions into an address. If that fails, then the function returns nothing- i.e. the local variable `key` will be nil and evaluate to false in the `if` statement.


Can you please tell me how can I define this code as you said above. I have tried your way but it not works so maybe I am doing something wrong.

Code:
{$luacode lBase=rdi}
writeInteger(getAddressSafe(lBase)+0x98,100)
{$asm}
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4300

PostPosted: Sat Apr 09, 2022 12:11 am    Post subject: Reply with quote

If that is part of a code injection (e.g. under newmem), then lBase is an integer and it should work without using getAddressSafe:
Code:
newmem:
{$luacode lBase=rdi}
writeInteger(lBase+0x98,100)
{$asm}
...
This is assuming rdi is the correct address and that injection point doesn't access any other addresses.
Using assembly would be easier:
Code:
newmem:
  mov [rdi+98],100
This does the same thing.

If you define and initialize lBase elsewhere, use a {$lua} block instead:
Code:
...
alloc(lBase,8)
registersymbol(lBase)

lBase:
  dq 0

newmem:
  mov [lBase],rdi
  ...
Code:
// some other script
${lua}
writeInteger('[lBase]+0x98',100)
{$asm}

_________________
I don't know where I'm going, but I'll figure it out when I get there.
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 Lua Scripting All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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