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 


[Solved] NOPing Code via Scripting

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
Menoetius
Cheater
Reputation: 0

Joined: 01 Jul 2018
Posts: 29

PostPosted: Tue Apr 07, 2020 11:22 am    Post subject: [Solved] NOPing Code via Scripting Reply with quote

Hello, I've got a solid base pointer along with a pointer that holds a value that gets written to by the game, and I want to be able to NOP the code via scripting.

So I have the bullet count, and can find out what writes to it, but I'm unsure of how to proceed with the scripting.

Code:
mov ebp, [dosbox.exe+12F1F8C] //Always from this address
...
dec ebp  //decreases the value
...
...
mov [eax+ecx], ebp //replaces old ammo count <--

Going to dosbox.exe+12F1F8C yields constantly changing code and/or read data. Noping that line (not what's at the address) does NOT affect bullet loss, only the following lines will nullify the ammo loss.

How should I proceed to basically enable a script that gives infinite ammo? If there are other better options, please do let me know. Thank you kindly in advance.

[Edit]
Solution in the comments provided by OldCheatEngineUser



mov ebp, [dosbox.exe+12f1f8c].png
 Description:
 Filesize:  42.75 KB
 Viewed:  3754 Time(s)

mov ebp, [dosbox.exe+12f1f8c].png



_________________
Big Gun
#1
Shoot the Hell Outta You


Last edited by Menoetius on Tue Apr 14, 2020 1:25 am; edited 1 time in total
Back to top
View user's profile Send private message
JustSmile
How do I cheat?
Reputation: 0

Joined: 08 Apr 2020
Posts: 1

PostPosted: Wed Apr 08, 2020 10:07 am    Post subject: Reply with quote

Have u tried the simplest Approach
i think this is more easier than it seems

try noping the "dec line" see what happens
Back to top
View user's profile Send private message
Menoetius
Cheater
Reputation: 0

Joined: 01 Jul 2018
Posts: 29

PostPosted: Wed Apr 08, 2020 3:20 pm    Post subject: Reply with quote

Yeh I have, that also works, that's not an issue. What I'm saying is the only thing the same about these functions on game reload is [dosbox.exe+12F1F8C]. I'm wondering if I could hinge something off of that.

I know how to NOP, what I need is either:
an AOBscan - which does require a lot of bytes AND doesn't work until the first shot is fired - I actually do have a working AOBscan for a couple of these, but the AOBs are pretty long and again, dont work until the first shot is fired
OR
Some sort of offset? but the function is in a different memory usually on load that I can use instead of an AOBscan.

_________________
Big Gun
#1
Shoot the Hell Outta You
Back to top
View user's profile Send private message
OldCheatEngineUser
Whateven rank
Reputation: 20

Joined: 01 Feb 2016
Posts: 1586

PostPosted: Thu Apr 09, 2020 10:30 am    Post subject: Reply with quote

you cant really NOP anything, because technically you will be NOPing both dosbox routines and emulated routines. ----- thats a definite crash or improper stuff will happen.
_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote:
i am a sweetheart.
Back to top
View user's profile Send private message Visit poster's website
Menoetius
Cheater
Reputation: 0

Joined: 01 Jul 2018
Posts: 29

PostPosted: Thu Apr 09, 2020 10:48 am    Post subject: Reply with quote

That is true, however I've been able to construct AOBscans that rewrite/disable without an impass (so far). What other options do I have in regards to things similar to this?

Should I make a thread that resets values, an AOBscan replace of something static, or an injection site?

So far:
AOBscan: works after first shot fired, but have to do it for all weapons despite pooling ammo. Very lengthy Array to find, as well as rewrites EMU processes (suboptimal)
Thread: works okay, BUT I'm not versed enough to understand why a jmp during a thread crashes it no matter what. If you know why something like this when it jumps to M__LOOP crashes, please let me know:
Code:
globalalloc(T__LOOP,1000)//NEVER DEALLOC THREADS
createthread(T__LOOP)

label(N__LOOP)           //necessary
registersymbol(N__LOOP)

label(M__LOOP)
registersymbol(M__LOOP)  //memory space to do stuff


I__LOOP:               //resets values
  db 0

T__LOOP:
  inc [I__LOOP]         //increments value
//do
  jmp M__LOOP           //<-- absolutely smashes the game
//do
  push #500             //hundreths of seconds for stack to sleep
  call sleep            //waits for designated time

  cmp [N__LOOP],1       //compares to exit condition
  jne T__LOOP

  ret


M__LOOP:
  mov [tmp], 2          //works inside T__LOOP, crashes outside

N__LOOP:                //exit boolean
  db 0

Value-Lock Hotkeys: Works for this situation, but there are others where it does not and would like to be able to navigate around such a problem in the future

_________________
Big Gun
#1
Shoot the Hell Outta You
Back to top
View user's profile Send private message
OldCheatEngineUser
Whateven rank
Reputation: 20

Joined: 01 Feb 2016
Posts: 1586

PostPosted: Thu Apr 09, 2020 11:23 am    Post subject: Reply with quote

im using my phone to post, so excuse any typos or even if i missed something.

first im trying figure out what are you doing here, you code flow:
- inc [i_loop] // increment by 1, data type inetger 1 byte
- jmp m_loop

push #500 // never executed // 500 milliseconds (0.5seconds)
call sleep // because it jumps to m_loop and never returns

m_loop:
mov dword ptr [tmp],2 // assuming tmp is registered from outside the script + allocated 4 bytes of memory

basically copy value 2 into memory location tmp, but then it never returns back to t_loop

what will happen? whats after mov [tmp],2 ?
well, it will be add [eax],al this instruction have the following opcode/bytes 00 00

so you probably want to either do spaghetti jumps or call.

so a quick fix is:
call m_loop
...
m_loop:
mov [tmp],2
ret



also you did not allocate memory for i_loop, so allocate or move it under m_loop

_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote:
i am a sweetheart.
Back to top
View user's profile Send private message Visit poster's website
Menoetius
Cheater
Reputation: 0

Joined: 01 Jul 2018
Posts: 29

PostPosted: Thu Apr 09, 2020 11:42 am    Post subject: Reply with quote

Basically I'm just trying to figure out how createthread works best. I kept adding simple commands that work on their own to test what crashes or makes a loop.

The I__LOOP is simply a counter that counts the loop runs.
tmp is just a place in memory that I want to set value to - I know it doesn't reference anything, its more like using a "print" statement
mov [tmp], 2 simply tests that I can indeed do such a thing without crashing
M__LOOP or main/memory of loop is where I would like the instructions to be executed. Because I know that the previous command mov [tmp], 2 works, and jmp M__LOOP that holds the instructions of mov [tmp], 2 does not, I can discern that that is why the thread/game crashes.
Placing a "ret" after M__LOOP ends the thread immediately, which I can discern from the counter I implemented.


Here's the whole thing:

Code:
globalalloc(I__LOOP, 8) //gives space for counter

registersymbol(tmp)     //temporary value to modify
alloc(tmp,8)

[ENABLE]
globalalloc(T__LOOP,1000)//NEVER DEALLOC THREADS
createthread(T__LOOP)

label(N__LOOP)           //necessary
registersymbol(N__LOOP)

label(M__LOOP)
registersymbol(M__LOOP)  //memory space to do stuff


I__LOOP:               //resets values
  db 0

T__LOOP:
  inc [I__LOOP]         //increments value
//do
  jmp M__LOOP           //<-- absolutely smashes the game
//do
  push #500             //hundreths of seconds for stack to sleep
  call sleep            //waits for designated time

  cmp [N__LOOP],1       //compares to exit condition
  jne T__LOOP

  ret


M__LOOP:
  mov [tmp], 2          //works inside T__LOOP, crashes outside

N__LOOP:                //exit boolean
  db 0


[disable]


N__LOOP:                //ceases loop
  db 1



So to put simply, I need to figure out how to utilize a jmp from the T(hread)__LOOP to M(ain/memory)__LOOP or things like it without crashing to the thread, but I dont know enough about assembly or CE to solve it myself even after looking up solutions.

I was actually going to make a new forum post about this part, as my initial question dealt with: the best way of finding a location of code (in an emulator) and modifying the function via scripting (automated).

_________________
Big Gun
#1
Shoot the Hell Outta You
Back to top
View user's profile Send private message
OldCheatEngineUser
Whateven rank
Reputation: 20

Joined: 01 Feb 2016
Posts: 1586

PostPosted: Thu Apr 09, 2020 11:55 am    Post subject: Reply with quote

im assuming main/memory loop mean dosbox instructions, then this cant be done.

because each thread have it own registers, so your thread's registers are not same as dosbox threads. so you should indeed crash.

and either ways you dont wanna do it with a JMP because as soon as it hits a RET instruction the thread will be returned to the operating system.

Menoetius wrote:
Placing a "ret" after M__LOOP ends the thread immediately, which I can discern from the counter I implemented.

only if you used JMP M_LOOP.
CALL and RET are used in pair (except for anti-disassembly purposes) it should not terminate if you use CALL.

_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote:
i am a sweetheart.
Back to top
View user's profile Send private message Visit poster's website
Menoetius
Cheater
Reputation: 0

Joined: 01 Jul 2018
Posts: 29

PostPosted: Thu Apr 09, 2020 12:22 pm    Post subject: Reply with quote

Solid, my man. call/ret is what I needed for a thread, not jmp. I missed that in your previous post.

M__LOOP is a substitute for a list of commands I want to do, such as set ALL ammo counters to whatever, or something of the like (a bunch of mov [ammo_address number1], 42), not directly use a game function address.

Thank you again for that.


For future reference and learning purposes, would you happen to know other methods of: automating locating memory(such as aobscan, static injection), and then being able to continually replace it on game reload(as it will automate again). AOBs for emus are volatile and/or recurring, but looking at static injection, perhaps I could use that to discover where the functions will load (Assuming I already have a base game address).

Again thank you so much with your assistance thus far c:

_________________
Big Gun
#1
Shoot the Hell Outta You
Back to top
View user's profile Send private message
OldCheatEngineUser
Whateven rank
Reputation: 20

Joined: 01 Feb 2016
Posts: 1586

PostPosted: Thu Apr 09, 2020 12:52 pm    Post subject: Reply with quote

FOR ME, dosbox never change the address so pointers are not needed. (again for me)

as for finding and populating the address-list, you need to have at least base address + distance from each memory address that hold weapons data.

then using lua scripts you can populate the address-list with entries (current address + offset to next address).

but i have no idea how to use lua, nor CE's API. (only assembly programming and scripting)

_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote:
i am a sweetheart.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking 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 can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites