Cheat Engine 6.5 Tutorial: Be Mindful of Compares and Flags! (PUSHF and POPF)

Поделиться
HTML-код
  • Опубликовано: 31 дек 2024

Комментарии • 30

  • @sirboomtastic7376
    @sirboomtastic7376 6 лет назад +2

    i like this not only because its helpful but the fact you went back to a cheat from the past you struggled with, because im still very much a noob in all this but when i learn more things its nice going back to a game or cheat i just couldnt do in the past and get my revenge on it :D

  • @FreeER
    @FreeER 8 лет назад +3

    Great video xD
    In summary: if you can get away with it avoid changing instructions in-between compares (and cmp, as shown in the video, is not the only type of compare that exists, let CE tell you at the bottom of the disassembly) and conditional jumps. Otherwise you need to either make sure the instructions you are adding don't affect the flag(s) the jump looks at or that you save and restore the flag(s) with pushf and popf.
    Alternatively you may be able to inject at the compare instruction, and then move it to the end of the code so that the flags get set after your code has run.
    Just like any other issue, once you understand the problem you can probably figure out several solutions for it xD

  • @ChrisFayte
    @ChrisFayte 8 лет назад +3

    Great info pal. I have ran into that myself, and when they we all kept dying and I couldn't seem to find the problem I said screw it and went with pointers instead. .lol . Now I can guarantee this is the reason that was happening so now I have another troubleshoot I can try.. Thank you for this!!.

    • @StephenChapman
      @StephenChapman  8 лет назад +5

      So many things to learn, man. This particular thing had me stumped for a good 30-45 minutes or so as it was the first time I'd run into it, lol. Part of that may be because I used to write all my scripts such that they pushed/popped the state of ALL registers no matter what I was doing. It's a good practice if you want to ensure you don't run into "problems" like this, but it's added overhead (granted, it's inconsequential overhead, but overhead nonetheless) to push all register values to the stack, etc. I like to focus a lot on optimization these days, but there are things I like to do in scripts that are far from optimal. For instance, like in this video where I move max health into a register and then move that into current health. I could just skip putting anything there at all and simply jump to return, effectively skipping the entire instruction I'm creating an injection around!

    • @ChrisFayte
      @ChrisFayte 8 лет назад +4

      Stephen Chapman I had always seen on the forums where they were pushing and popping the flags in different scripts, at the time, it seemed like for no reason.. But now I see how important doing that is. Flags can definitely run the game into the ground if they are not handled properly. But now knowing this, it does free up a lot of room to be able to do more things far from optimal as you put it, which any game hacker enjoys doing.. I'm the type that just likes to see if the outlandish can be done... lol

  • @aedn7066
    @aedn7066 2 года назад

    Thank you so much for the explanation.
    I encountered the same issue on some of my modifications and forgot about the flags.

  • @sayansanyal2545
    @sayansanyal2545 4 года назад

    Same thing is happening with my watchdogs... Exactly same flag issue, but pushing and popping the flag isn't working... The issue is purely with flags because if I delete the flag and run the different conditions as different scripts, then everything works as expected, it's just whenever I change the value from 0 to 1, and then go into fire, my character dies.. Any solution will be highly helpful

  • @mastermax7777
    @mastermax7777 6 лет назад

    good stuff, i didnt even know about this instruction

  • @heaptv2348
    @heaptv2348 8 лет назад

    Good tutorial lol, no one has ever thought this thing
    xD

  • @weysinchathamazight9956
    @weysinchathamazight9956 5 лет назад

    Thank you , you helped me with this video a lot thanks God

  • @boxwithoutatop7243
    @boxwithoutatop7243 8 лет назад

    could you please do a short tutorial video on earthbound, Im using the zsnes emulator and i can't figure out the issue i'm having with the power meter.
    EDIT: I would explain the issue but i'm not sure that i can...

    • @StephenChapman
      @StephenChapman  8 лет назад

      You probably just need to enable mapped memory in your settings (EDIT -> SETTINGS -> SCAN SETTINGS -> Check MEM_MAPPED), then do changed/unchanged value scans if increase/decreased scans don't work.

    • @boxwithoutatop7243
      @boxwithoutatop7243 8 лет назад

      It is checked, I am able to find the address that influences the value (power level). the issue i'm having is once I actually change the value.

    • @StephenChapman
      @StephenChapman  8 лет назад

      What's the issue? Do you change the value but the game still does what it would have done anyway? If so, you'll need to see what writes to that address and then try futzing with the instruction.

    • @boxwithoutatop7243
      @boxwithoutatop7243 8 лет назад

      The address that I've found is the base address, and when I change the value on cheat engine it changes both the actual amount and the displayed amount, but once I play the game it changes the amount and scrolls all the way down to zero, no matter the value it was on when I changed it, and both in the actual amount and in the displayed amount hits every countable number before it hits zero. So if I changed the value to 15, it will go 14, 13, 12 and so on.

  • @biehdc
    @biehdc 8 лет назад

    once back in the game "Remember Me" i had a funny situation with flags. I had a custom value wich says, if it should cheat or not and my programm was something like this:
    pushf ---

    • @StephenChapman
      @StephenChapman  8 лет назад

      This is where break/trace comes in handy to help you debug your scripts, especially if you're absolutely certain that something should work but it doesn't.

    • @biehdc
      @biehdc 8 лет назад

      excatly what i did in first place^^

    • @StephenChapman
      @StephenChapman  8 лет назад

      What differences did you see? That should've shown you exactly why one solution worked over the other, instead of you being unsure why the second solution worked over your original one. Did you pay close attention to the flags register as you stepped through? I'd have to see your script exactly to have an idea of why the first example didn't work. I can think of a few reasons based on the template you gave here, but it would all be dependent upon exactly what the rest of the script looked like. I can try to help figure it out if you'd like.

    • @biehdc
      @biehdc 8 лет назад

      at the time i wrote this script, i wasnt educated enouth to proper disasm in my head

  • @NotJustSomeGuy
    @NotJustSomeGuy 8 лет назад

    What does push/pop do?

    • @StephenChapman
      @StephenChapman  8 лет назад +2

      Giving you the 10,000-foot view, push takes values from registers (small sections of memory build into your CPU) and places them on "the stack" (which is a massive convoluted topic for another day) so they are saved. Pop, in contrast, takes things from the stack and places them into registers. You can think of "the stack" as a literal stack of something that grows as you place things on it, and shrinks as you remove things from it. Imagine you have a table and you put a book on it, then you put a book on top of that book, then you put a book on top of that book. It's a growing stack. Adding a book to the stack of books is "push." Taking a book off the stack of books and putting it in its own place is "pop." In this case, we're dealing with data, not books. And the book analogy is somewhat incorrect in relation to how a stack actually grows in memory (it grows downward, like an icicle), but it's not really necessary for you to worry about that to just know what push/pop does. =)

    • @NotJustSomeGuy
      @NotJustSomeGuy 8 лет назад

      Thanks. I don't get why in some injections you need to use it but in others you don't. =)

    • @StephenChapman
      @StephenChapman  8 лет назад +1

      You'll come to understand it as you learn more about this stuff. The basic premise is that you sometimes want to preserve a specific state of the game so that you can restore that state after you're done with your code injection. As with the case in this video, I needed to store the state of the EFLAGS register, then restore it when I was done with my code injection. The end result is the game continues on as if I was never there mucking around with stuff. However, when I didn't push/pop the EFLAGS register, the result of my compare in the script was overwriting something that it shouldn't have been.

    • @NotJustSomeGuy
      @NotJustSomeGuy 8 лет назад

      Alright, thanks again

  • @denkisan8719
    @denkisan8719 8 лет назад

    Can you make a tutorial on how to use strings in cheat engine

  • @brestoissobre
    @brestoissobre 8 лет назад

    i love you

  • @DirtyMofo
    @DirtyMofo 8 лет назад +1

    FIRST! Mwah ha ha...