2 Copyright © 2011, The AROS Development Team. All rights reserved.
5 Desc: Code to dynamically load ELF executables under AOS.
11 * $ bin/linux-x86_64/tools/m68k-amiga-aros-gcc -Os -I /path/to/src/AROS \
12 * SetPatchAROS.c -o SetPatchAROS.elf
13 * $ bin/linux-x86_64/tools/elf2hunk SetPatchAROS.elf SetPatchAROS
15 * Copy SetPatchAROS to your AOS installation, and add the following
16 * to your startup script:
20 * Send a ^C to the SetPatchAROS to unload it.
25 #include <aros/asmcall.h>
26 #include <dos/stdio.h>
28 #include <proto/alib.h>
29 #include <proto/utility.h>
30 #include <proto/exec.h>
31 #include <proto/dos.h>
33 #include <exec/rawfmt.h>
37 /************* ExecBase Patches ********************/
39 static APTR oldRawDoFmt
;
40 static AROS_UFH5(APTR
, myRawDoFmt
,
41 AROS_UFHA(CONST_STRPTR
, fmt
, A0
),
42 AROS_UFHA(APTR
, args
, A1
),
43 AROS_UFHA(VOID_FUNC
, putch
, A2
),
44 AROS_UFHA(APTR
, putptr
, A3
),
45 AROS_UFHA(struct ExecBase
*, SysBase
, A6
))
52 const ULONG m68k_string
= 0x16c04e75;
56 const ULONG m68k_count
= 0x52934e75;
59 const ULONG m68k_serial
= 0x4eeefdfc;
61 switch ((IPTR
)putch
) {
62 case (IPTR
)RAWFMTFUNC_STRING
:
63 putch
= (VOID_FUNC
)&m68k_string
;
65 case (IPTR
)RAWFMTFUNC_COUNT
:
66 putch
= (VOID_FUNC
)&m68k_count
;
68 case (IPTR
)RAWFMTFUNC_SERIAL
:
69 putch
= (VOID_FUNC
)&m68k_serial
;
75 return AROS_UFC5(APTR
, oldRawDoFmt
,
76 AROS_UFCA(CONST_STRPTR
, fmt
, A0
),
77 AROS_UFCA(APTR
, args
, A1
),
78 AROS_UFCA(VOID_FUNC
, putch
, A2
),
79 AROS_UFCA(APTR
, putptr
, A3
),
80 AROS_UFCA(struct ExecBase
*, SysBase
, A6
));
85 /************* DosLibrary Patches ******************/
87 #define PROTO_KERNEL_H /* Don't pick up AROS kernel hooks */
89 /* Really stupid way to deal with this,
90 * but what we're going to do is make our
91 * patches, and wait for a ^C.
93 * When we get a ^C, unpatch ourselves from
94 * Dos/LoadSeg(), and exit.
100 int main(int argc
, char **argv
)
104 DOSBase
= OpenLibrary("dos.library", 0);
105 if (DOSBase
!= NULL
) {
106 struct Library
*sbl
= (APTR
)SysBase
;
107 if (sbl
->lib_Version
> 40) {
108 FPrintf(Output(), "SetPatchAROS: Unsupported exec.library %ld.%ld\n",
109 sbl
->lib_Version
, sbl
->lib_Revision
);
110 CloseLibrary((APTR
)DOSBase
);
115 oldRawDoFmt
= SetFunction((struct Library
*)SysBase
, -87 * LIB_VECTSIZE
, myRawDoFmt
);
118 PutStr("AROS Support active. Press ^C to unload.\n");
119 Wait(SIGBREAKF_CTRL_C
);
122 SetFunction((struct Library
*)SysBase
, -87 * LIB_VECTSIZE
, oldRawDoFmt
);
125 PutStr("AROS Support unloaded.\n");
126 CloseLibrary(DOSBase
);