• Updated 2023-07-12: Hello, Guest! Welcome back, and be sure to check out this follow-up post about our outage a week or so ago.

Skipping a confirmation alert and doing the OK code path?

gingerbeardman

Active member
I am modifying FinderHack, https://macintoshgarden.org/apps/finderhack

in two ways

1. change the hot key for "Move To Trash" (done with simple hex edit to change menu key from "T" 0x54 to "Backspace/Delete" 0x08)
2. to skip the confirmation dialog alert (I'm close but not there yet, help appreciated)

(the goal being to get "Move to Trash" hot key on System 7.1, as it was not officially introduced until System 7.5.3)

Anyway,

The main code for the extension is in a CDRV resource, which is actually a DRVR resource. I was able to decompile it using `resource_dasm`:


The relevant code seems to be in the function starting at 0x00000746
Alert syscall is at ~ 0x00000760
return value from the alert is checked against 0x01 at ~0x00000770
I've tested this by changing the compare value form 0x01 to something else and then the OK button doesn't result in the file being deleted.

Anyway, my question, what should I be looking to NOP or jump over to be able to skip this alert dialog and do the code path as if "OK" was pressed.

Feel like I am close lacking a key bit of understanding.

Happy to read some book chapters or other material if it will enable me do this!

Cheers,
matt

1713200969159.png

1713201212361.png
 
Last edited:

cheesestraws

Well-known member
Can you post the ten or so instructions above the _Alert trap too please?

edit: ignore this too, I just saw the link. I'm so tired.
 

cheesestraws

Well-known member
Alright, third post's the charm, right? Try this. I appreciate this is a bit terse - please ask questions if it's unclear why it's these things we're doing.
  1. We need not to push the parameters to _Alert onto the stack.
    • nop out (with 0x4E71 four times) the four words starting at 0x00000758 (replacing the move.l -[A7], 0x3E90000 and clr.l -[A7].
  2. We need not to call the Alert trap
    • nop out (with 0x4E71 once) the _Alert trap at 0x00000760
  3. We need to not pop the return from _Alert from the stack
    • nop out (with 0x4E71 once) the word at 0x00000762 (replacing move.w D4, [A7]+)
  4. Now we need the comparison to always succeed.
    • patch the instruction at 0x00000770 from cmp.w D0, D4 to cmp.w D0, D0 (0xB040)
The first three should prevent the alert being displayed without stuffing the stack right up, and the last should make it think you always pressed OK, I think.
 
Last edited:

gingerbeardman

Active member
Thanks! That did the trick :)

Looking at my previous tries the only bit I missed was a way to force the comparison. What reference do you recommend to figuring out the hex op codes?

Also I notice that, at least on my emulated setup, the file can take up to a few seconds to be deleted which is more noticeable without the confirmation. So, I have added a note to the revised download package about this.

I also gave you a thanks credit in the readme of the updated version.

Cheers!
 

cheesestraws

Well-known member
Thanks! That did the trick :)

Yay! You're very welcome.

Looking at my previous tries the only bit I missed was a way to force the comparison.

Yes, I'm afraid the required skill for that bit was deviousness rather than anything actually technical...

What reference do you recommend to figuring out the hex op codes?

There's a table of common instructions here: https://info.sonicretro.org/SCHG:68000_ASM-to-Hex_Code_Reference but for arbitrary instructions, the easiest way I've found is just to put it into Easy68k (http://www.easy68k.com/ - which I think @stepleton originally introduced me to!) and hit 'assemble' and it gives me a listing including hex. Other options exist, I'm sure, that's just the one I usually have installed.
 
Top