Mac OS 9 Lives! (Classic Mac OS Forum)

Classic Mac OS Software (Discussions on Applications) => Hacking the System, Mac OS 9.3, and Beyond ! => Topic started by: OS923 on September 14, 2016, 09:12:13 AM

Title: Apple event logging
Post by: OS923 on September 14, 2016, 09:12:13 AM
I search a program, extension or control panel to log Apple events.
Then I can learn how Finder communicates with other programs.
(This is largely undocumented.)
Think of the possibilities: how to write things like CopyAgent or write a program that is compatible with CopyAgent.

In 1992 there was the control panel AETracker, but this doesn't work on my MDD with OS 9.2.2.

I'm writing something similar which is based on AEGizmos but it's not finished yet.
Title: Re: Apple event logging
Post by: nanopico on September 14, 2016, 11:38:39 AM
I search a program, extension or control panel to log Apple events.
Then I can learn how Finder communicates with other programs.
(This is largely undocumented.)
Think of the possibilities: how to write things like CopyAgent or write a program that is compatible with CopyAgent.

In 1992 there was the control panel AETracker, but this doesn't work on my MDD with OS 9.2.2.

I'm writing something similar which is based on AEGizmos but it's not finished yet.

A lot of that communication isn't through apple events.  Some is yes, but some is through calls into and out of them.
Title: Re: Apple event logging
Post by: OS923 on October 07, 2016, 07:40:13 AM
I found Capture AE
http://files.macscripter.net/Prog_Utilities/CaptureAE.hqx
Title: Re: Apple event logging
Post by: OS923 on November 06, 2016, 01:32:56 AM
I abandoned this project.
It requires inline assembler.
This can't be done with CodeWarrior 68K.
Title: Re: Apple event logging
Post by: nanopico on November 06, 2016, 03:23:53 PM
I abandoned this project.
It requires inline assembler.
This can't be done with CodeWarrior 68K.

Could it be done within MPW and you just export it as a shared library from there?
Title: Re: Apple event logging
Post by: OS923 on November 18, 2016, 02:36:39 AM
I need assembler to get the address of the stack.
If I do a function call, then the stack changes.
Title: Re: Apple event logging
Post by: OS923 on November 18, 2016, 02:37:48 AM
Is it possible to get the address of the stack in C++?
Title: Re: Apple event logging
Post by: OS923 on November 18, 2016, 03:59:53 AM
It's possible to store assembler instructions as numbers in a C++ array.
Title: Re: Apple event logging
Post by: nanopico on November 18, 2016, 06:40:06 AM
Is it possible to get the address of the stack in C++?

Yes, but not through any published API if I recall (I may be wrong on that).
I recall seeing several private functions in private libraries that can be called, if you know the correct function signature and the calling nature of the function (stack based or register based).

It's possible to store assembler instructions as numbers in a C++ array.

Yeah it's pretty cool too.  It's also possible to just shove that list into some arbitrary location (I.E. outside of any process in mapped memory) and then jump to it.  I did do that exact thing to call kernel functions that have no API what so ever.
If you need to return from the code you need to manually manipulate the registers so that you don't crash the system (done that one before too).

Fun stuff that is.
Title: Re: Apple event logging
Post by: OS923 on April 06, 2017, 05:58:45 AM
I found 2 solutions that don't require assembler.

AEGetTheCurrentEvent can be used in a GetNextEvent patch and a WaitNextEvent patch to detect 'null' events. This allows you to give your INIT time at a moment that it doesn’t bother other processes.

A special handler of the type keyPreDispatch allows you to look at an Apple event right before it's processed by AEProcessEvent. (So it doesn't log the reply.) It has an advantage over patching Pack8 to change AESend because it doesn't log events that were sent with the option kDontExecute (that were sent for the purpose of being recorded by Script Editor).

Last night I saved my first successful Apple event log to a text file.
Title: Re: Apple event logging
Post by: OS923 on October 16, 2017, 01:08:16 AM
I found a 3rd solution with OSA. See http://www.gsehi.com/computing/problems/TrackAE.php

I released it as a control panel + extension + translation program. The translation is in a separate program because I don't want the extension to lose time.

You can download it here: http://www.gsehi.com/computing/software/macos/LogAE.php