Author Topic: Apple event logging  (Read 7939 times)

Offline OS923

  • Platinum Member
  • *****
  • Posts: 888
Apple event logging
« 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.

Offline nanopico

  • Moderator
  • Platinum Member
  • *****
  • Posts: 767
Re: Apple event logging
« Reply #1 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.
If it ain't broke, don't fix it, or break it so you can fix it!

Offline OS923

  • Platinum Member
  • *****
  • Posts: 888
Re: Apple event logging
« Reply #2 on: October 07, 2016, 07:40:13 AM »

Offline OS923

  • Platinum Member
  • *****
  • Posts: 888
Re: Apple event logging
« Reply #3 on: November 06, 2016, 01:32:56 AM »
I abandoned this project.
It requires inline assembler.
This can't be done with CodeWarrior 68K.

Offline nanopico

  • Moderator
  • Platinum Member
  • *****
  • Posts: 767
Re: Apple event logging
« Reply #4 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?
If it ain't broke, don't fix it, or break it so you can fix it!

Offline OS923

  • Platinum Member
  • *****
  • Posts: 888
Re: Apple event logging
« Reply #5 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.

Offline OS923

  • Platinum Member
  • *****
  • Posts: 888
Re: Apple event logging
« Reply #6 on: November 18, 2016, 02:37:48 AM »
Is it possible to get the address of the stack in C++?

Offline OS923

  • Platinum Member
  • *****
  • Posts: 888
Re: Apple event logging
« Reply #7 on: November 18, 2016, 03:59:53 AM »
It's possible to store assembler instructions as numbers in a C++ array.

Offline nanopico

  • Moderator
  • Platinum Member
  • *****
  • Posts: 767
Re: Apple event logging
« Reply #8 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.
If it ain't broke, don't fix it, or break it so you can fix it!

Offline OS923

  • Platinum Member
  • *****
  • Posts: 888
Re: Apple event logging
« Reply #9 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.
« Last Edit: April 06, 2017, 06:18:33 AM by OS923 »

Offline OS923

  • Platinum Member
  • *****
  • Posts: 888
Re: Apple event logging
« Reply #10 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

Offline OS923

  • Platinum Member
  • *****
  • Posts: 888
Re: Apple event logging
« Reply #11 on: December 12, 2020, 03:49:53 AM »
Inline assembler was introduced in "MW C/C++ PPC" plugin 2.3.2 (CW Pro 5.3) and "MW C/C++ 68K" plugin 2.4 (CW Pro 6).

What they didn't tell you is that you have to type your inline assembler as
Code: [Select]
asm(...);instead of
Code: [Select]
asm{...}Then I learned to patch the selector based traps and this works well.