home *** CD-ROM | disk | FTP | other *** search
- ;/*
- SC resopt desc_MacPICT2.c nodebug opt optsize link nostrt nostkext nostkchk
- quit
- */
- /* Execute this file to compile with SAS C
- * Ex. "1.Ram:>execute desc_MacPICT2.c"
- *
- * Otherwise it must be compiled with no stack checking.
- * It must not be linked with any startup code so that DTHook is
- * the entry point for the executable.
- *
- */
-
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <dos/dos.h>
- #include <dos/dosextens.h>
- #include <datatypes/datatypes.h>
- #include <datatypes/pictureclass.h>
-
- #include <clib/exec_protos.h>
- #include <clib/dos_protos.h>
- #include <clib/utility_protos.h>
-
- #include <pragmas/exec_pragmas.h>
- #include <pragmas/dos_pragmas.h>
- #include <pragmas/utility_pragmas.h>
-
- #define SysBase dthc->dthc_SysBase
- #define DOSBase dthc->dthc_DOSBase
- #define UtilityBase dthc->dthc_UtilityBase
-
- #define HEADER_SIZE 0x200
- #define PICT_picVersion 0x0011
- #define PICT_MacPICT2 0x02ff
- #define BUFSIZE 0x80
- #define MAXCHECK 0x3e /* BUFSIZE/2 - 2 */
-
- BOOL __asm DTHook (register __a0 struct DTHookContext * dthc)
- {
- BOOL retval = FALSE;
- ULONG n;
- UWORD *buffer;
- BPTR fh;
-
- /* Make sure we have a filehandle */
- if (fh = dthc->dthc_FileHandle) {
-
- /* Allocate a buffer */
- if(buffer = AllocVec(BUFSIZE, MEMF_PUBLIC)) {
-
- Seek(fh, HEADER_SIZE, OFFSET_BEGINNING);
- if(Read(fh, buffer, BUFSIZE) == BUFSIZE) {
- n = 5;
- while((n < MAXCHECK) && (buffer[n]==0)) n++;
- if((buffer[n]==PICT_picVersion) && (buffer[n+1]==PICT_MacPICT2))
- retval = TRUE;
- }
- /* Do not steal memory */
- FreeVec(buffer);
- }
- }
- return retval;
- }
-
-
-