2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
5 Desc: DOS function LoadSeg()
12 #include <dos/dosextens.h>
13 #include <proto/dos.h>
14 #include <aros/debug.h>
15 #include "dos_intern.h"
17 #if AROS_MODULES_DEBUG
18 #include <exec/nodes.h>
19 #include <exec/lists.h>
22 struct MinList debug_seglist
, free_debug_segnodes
;
26 /*****************************************************************************
29 #include <proto/dos.h>
31 AROS_LH1(BPTR
, LoadSeg
,
34 AROS_LHA(CONST_STRPTR
, name
, D1
),
37 struct DosLibrary
*, DOSBase
, 25, Dos
)
40 Loads an executable file into memory. Each hunk of the loadfile
41 is loaded into his own memory section and a handle on all of them
42 is returned. The segments can be freed with UnLoadSeg().
45 name - NUL terminated name of the file.
48 Handle to the loaded executable or NULL if the load failed.
49 IoErr() gives additional information in that case.
52 This function is built on top of InternalLoadSeg()
63 *****************************************************************************/
66 AROS_LIBBASE_EXT_DECL(struct DosLibrary
*,DOSBase
)
68 void (* FunctionArray
[3])();
71 FunctionArray
[0] = __AROS_GETVECADDR(DOSBase
,7);
72 FunctionArray
[1] = __AROS_GETVECADDR(SysBase
,33);
73 FunctionArray
[2] = __AROS_GETVECADDR(SysBase
,35);
76 D(bug("[LoadSeg] Opening '%s'...\n", name
));
77 file
= Open (name
, FMF_READ
);
81 D(bug("[LoadSeg] Loading '%s'...\n", name
));
83 segs
= InternalLoadSeg (file
, NULL
, (void *)FunctionArray
, NULL
);
87 #if AROS_MODULES_DEBUG
88 struct debug_segnode
*segnode
;
91 segnode
= (struct debug_segnode
*)REMHEAD(&free_debug_segnodes
);
96 NameFromFH(file
, segnode
->name
, sizeof(segnode
->name
));
98 segnode
->seglist
= segs
;
99 #if defined(__AROS_SET_START_ADDR)
100 __AROS_SET_START_ADDR(segnode
);
102 #warning "if you want gdb debugging of loaded executables implement __AROS_GET_START_ADDR in machine.h"
106 ADDTAIL(&debug_seglist
, segnode
);
114 bug("[LoadSeg] Failed to load '%s'\n", name
);
118 bug("[LoadSeg] Failed to open '%s'\n", name
));