Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
NotificationTrash.ƒ/NotificationTrash.c
#ifndef THINK_C |
#include <GestaltEQU.h> |
#include <OSUtils.h> |
#include <Notification.h> |
#include <Resources.h> |
#endif |
#include <Traps.h> |
#include <gestaltEQU.h> |
#include <GestaltTalk.h> |
OSErr ShowInitIcon( short icon_num, short move_x_by); |
pascal void EndUpdateEntry(WindowPtr wp); |
long *GetStashSpotAddr(); |
gtp *GetGTAddr(); |
pascal void main() |
{ |
Handle initCodeHandle; |
long *localRealAddr; |
gtp *gtPointer; |
short err = 0; |
long sysVersion; |
GestaltTalkPB gpb; |
/* don't load unless we are on 7.0 or later */ |
err = Gestalt(gestaltSystemVersion,&sysVersion); |
if(sysVersion < 0x0700) return; |
initCodeHandle = Get1Resource('INIT',0); |
DetachResource(initCodeHandle); |
localRealAddr = GetStashSpotAddr(); |
*localRealAddr = GetToolTrapAddress( (short)_EndUpDate ); |
SetToolTrapAddress((long)EndUpdateEntry, (short)_EndUpDate); |
gpb.command = guserinit; |
gpb.datalength = 0; |
gpb.data = nil; |
gpb.gtData = nil; |
err = GestaltTalk(&gpb); |
if(err) { |
DebugStr("\pError, gestaltTalk guserinit failed."); |
*localRealAddr = 0; |
return; |
} |
gtPointer = GetGTAddr(); |
*gtPointer = gpb.gtData; |
(void) ShowInitIcon( 128, -1); |
} |
void NotificationTrash(WindowPeek wp) |
{ |
GestaltTalkPB gpb; |
gtp gdata; |
short err = 0; |
FontInfo fi; |
Rect drawRect; |
short lineHt; |
gdata = *GetGTAddr(); |
if(gdata->buffCount) |
if( EqualString("\pTrash", *(wp->titleHandle), false, false) ) { |
GetFontInfo(&fi); |
lineHt = fi.ascent + fi.descent + fi.leading; |
drawRect = wp->port.portRect; |
drawRect.top += lineHt + 32; |
drawRect.left += 2; |
drawRect.bottom -= 17; |
drawRect.right -= 17; |
EraseRect(&drawRect); |
drawRect.bottom = drawRect.top + lineHt; |
MoveTo(drawRect.left,drawRect.bottom); |
DrawString(gdata->dataBuffer); |
} |
} |
pascal void EndUpdateEntry(WindowPtr wp) |
{ |
asm { |
move.l wp,-(sp) |
jsr NotificationTrash |
addq.l #4,sp |
@callOriginal |
jsr GetStashSpotAddr // get pointer to real NMinstall address |
movea.l d0,a0 // get pointer to storage |
move.l (a0),a0 // save addr of NMInstall |
unlk a6 |
jmp (a0) // push address of real NMInstall on stack |
// let the RTS take us there... |
} |
} |
long *GetStashSpotAddr() |
{ |
asm { |
bsr.s @skipStorage |
dc.l 0x00 // pointer to real EndUpdate |
dc.l 0x00 // gestaltTalk gtData |
@skipStorage: |
move.l (sp)+,d0 |
} |
} |
gtp *GetGTAddr() |
{ |
asm { |
bsr.s @skipStorage |
dc.l 0x00 // gestaltTalk gtData |
dc.l 0x00 |
@skipStorage: |
move.l (sp)+,d0 |
} |
} |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-01-14