Help with infinite item usage code

Memory scanning, code injection, debugger internals and other gamemodding related discussion
Post Reply
Lulu
Cheater
Cheater
Posts: 25
Joined: Wed Feb 10, 2021 4:11 am
Reputation: 15

Help with infinite item usage code

Post by Lulu »

Hi,
This is for SMT Nocturne remaster, it uses Unity.
So I found that if I comment out this line "mov [rax+rdi+20],bl" , it will freeze the item quantities.
But the problem is items don't increase when you pick them up either.
Can someone help show me how to fix it or how to make a "minimum item quantity" script where item quantities don't go below a certain value but can still increase?
I'm new at this so I don't know if any other information is needed.

Code: Select all

[ENABLE]
//code from here to '[DISABLE]' will be used to enable the cheat

 
 
aobscanmodule(INJECT,GameAssembly.dll,88 5C 38 20 33 3D 24 B2 31 01) // should be unique
alloc(newmem,$1000,INJECT)

label(code)
label(return)

newmem:

code:
  //mov [rax+rdi+20],bl
  xor edi,[GameAssembly.dll+4D9CA1D]
  jmp return

INJECT:
  jmp newmem
  nop 5
return:
registersymbol(INJECT)

[DISABLE]
//code from here till the end of the code will be used to disable the cheat
INJECT:
  db 88 5C 38 20 33 3D 24 B2 31 01

unregistersymbol(INJECT)
dealloc(newmem)

{
// ORIGINAL CODE - INJECTION POINT: GameAssembly.dll+3A817EF

GameAssembly.dll+3A817BF: 48 8B 15 E2 53 3A FF  - mov rdx,[GameAssembly.dll+2E26BA8]
GameAssembly.dll+3A817C6: 48 8B 82 B8 00 00 00  - mov rax,[rdx+000000B8]
GameAssembly.dll+3A817CD: 48 8B 00              - mov rax,[rax]
GameAssembly.dll+3A817D0: 48 85 C0              - test rax,rax
GameAssembly.dll+3A817D3: 0F 84 A8 01 00 00     - je GameAssembly.dll+3A81981
GameAssembly.dll+3A817D9: 48 8B 40 70           - mov rax,[rax+70]
GameAssembly.dll+3A817DD: 48 85 C0              - test rax,rax
GameAssembly.dll+3A817E0: 0F 84 9B 01 00 00     - je GameAssembly.dll+3A81981
GameAssembly.dll+3A817E6: 3B 78 18              - cmp edi,[rax+18]
GameAssembly.dll+3A817E9: 0F 83 62 01 00 00     - jae GameAssembly.dll+3A81951
// ---------- INJECTING HERE ----------
GameAssembly.dll+3A817EF: 88 5C 38 20           - mov [rax+rdi+20],bl
// ---------- DONE INJECTING  ----------
GameAssembly.dll+3A817F3: 33 3D 24 B2 31 01     - xor edi,[GameAssembly.dll+4D9CA1D]
GameAssembly.dll+3A817F9: 48 8B 6C 24 30        - mov rbp,[rsp+30]
GameAssembly.dll+3A817FE: 48 8B 5C 24 38        - mov rbx,[rsp+38]
GameAssembly.dll+3A81803: 48 8B 74 24 40        - mov rsi,[rsp+40]
GameAssembly.dll+3A81808: 48 83 C4 20           - add rsp,20
GameAssembly.dll+3A8180C: 5F                    - pop rdi
GameAssembly.dll+3A8180D: C3                    - ret 
GameAssembly.dll+3A8180E: 8D 8F 60 03 00 00     - lea ecx,[rdi+00000360]
GameAssembly.dll+3A81814: 31 D2                 - xor edx,edx
GameAssembly.dll+3A81816: E8 25 68 57 FE        - call GameAssembly.dll+1FF8040
}

User avatar
notpikachu
Table Makers
Table Makers
Posts: 311
Joined: Wed Apr 01, 2020 10:32 am
Reputation: 331

Re: Help with infinite item usage code

Post by notpikachu »

Lulu wrote:
Sat May 22, 2021 1:13 pm
...
Howdy, I don't have that game but I can give you a similar example. Here's a game I recently cheat, Dragon Ball Z: Legend of Z RPG (shameless plug). So, let's take a look on its buy/sell item function, which is this.

Code: Select all

newmem:

code:
  mov edx,[ebx+14]
  mov [edx+esi],al  // here's the item quantity right after the buy sell is press
  jmp return

jeje:
  jmp newmem
  nop
return:
registersymbol(jeje)
So, you just need a simple jae here, which mean jump if above or equal. For example, I want to limit it to 10 but still want to increase it.

Code: Select all

newmem:
  cmp al,a
  jae code
  mov edx,[ebx+14]
  mov [edx+esi],a //item quantity
  jmp return
code:
  mov edx,[ebx+14]
  mov [edx+esi],al // original item quantity
  jmp return
Image

and that's it. of course there's a lot of way to do this, like via lua, but I'm not an expert~ gonna leave this to the master :P

Edit1: Fix some typo and code comments

Lulu
Cheater
Cheater
Posts: 25
Joined: Wed Feb 10, 2021 4:11 am
Reputation: 15

Re: Help with infinite item usage code

Post by Lulu »

notpikachu wrote:
Sat May 22, 2021 1:53 pm
...
Hey thanks for replying !
I tried to copy your code and it correctly set the item quantity to 10 but then the items underneath it will disappear.
My game's code is a bit different than yours, there's a XOR function, it might be the problem but I don't know what it does, something about bits ? :? .

Code: Select all

newmem:
  cmp bl,a
  jae code
  mov [rax+rdi+20],a
  xor edi,[GameAssembly.dll+4D9CA1D]
  jmp return
code:
  mov [rax+rdi+20],bl
  xor edi,[GameAssembly.dll+4D9CA1D]
  jmp return

INJECT:
  jmp newmem
  nop 5
return:
registersymbol(INJECT)
When I use Bead Chain, it's correctly set to 10 but Chakra Drop and Chakra Pot disappear.

Image

User avatar
notpikachu
Table Makers
Table Makers
Posts: 311
Joined: Wed Apr 01, 2020 10:32 am
Reputation: 331

Re: Help with infinite item usage code

Post by notpikachu »

Lulu wrote:
Sat May 22, 2021 5:59 pm
...
Tbh, I'm not sure either as I don't have the game (man, I really like the megaten series :( ) but there's a chance is this line:

Code: Select all

mov [rax+rdi+20],a
try changing it to something like

Code: Select all

mov byte ptr  [rax+rdi+20],a
My bad, forget to say, if you item quantity is in byte, you need to do this or it mess up the other values. (It depends on each games and how they handle the item quantity).

Edit1: Just to be sure, maybe this too, can't check :lol:
Edit2: After checking cmp byte ptr is not needed for this case :sleep:

Lulu
Cheater
Cheater
Posts: 25
Joined: Wed Feb 10, 2021 4:11 am
Reputation: 15

Re: Help with infinite item usage code

Post by Lulu »

I tried the byte ptr thing and it's working !!
Thanks a lot !!

Post Reply

Who is online

Users browsing this forum: No registered users