From eaa80f48af88df24fcb2599fb10d96f5029c2706 Mon Sep 17 00:00:00 2001 From: jmcmullan Date: Sun, 21 Jul 2013 15:03:06 +0000 Subject: [PATCH] dos.library: Fix C:AddDataTypes on OS 3.9 C:AddDataTypes on OS 3.9 was not passing a FH to InternalLoadSeg, which was causing NameFromFH() in our internal segtracker to die. Resolved by using fh_Func2 to hold a 'this is a filehandle' marker. Signed-off-by: Jason S. McMullan git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@47747 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- rom/dos/allocdosobject.c | 2 ++ rom/dos/dos_intern.h | 4 ++++ rom/dos/internalloadseg_support.c | 9 ++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/rom/dos/allocdosobject.c b/rom/dos/allocdosobject.c index fab282dc92..ea99c0dc14 100644 --- a/rom/dos/allocdosobject.c +++ b/rom/dos/allocdosobject.c @@ -66,6 +66,8 @@ fh->fh_Pos = -1; fh->fh_End = -1; + + fh->fh_Func2 = DOS_FH_MAGIC; } return mem; diff --git a/rom/dos/dos_intern.h b/rom/dos/dos_intern.h index 45b3b1e95a..b2b0efb1c4 100644 --- a/rom/dos/dos_intern.h +++ b/rom/dos/dos_intern.h @@ -89,6 +89,10 @@ struct vfp ((struct FileHandle *)BADDR(f))->fh_Pos<((struct FileHandle *)BADDR(f))->fh_End? \ *((struct FileHandle *)BADDR(f))->fh_Pos++=c,0:FPutC(f,c)) +#define DOS_FH_MAGIC AROS_MAKE_ID('F','h','n','d') +#define ISFILEHANDLE(f) \ + ((((struct FileHandle *)BADDR(f))->fh_Func2) == DOS_FH_MAGIC) + /* Softlink handling */ STRPTR ResolveSoftlink(BPTR cur, struct DevProc *dvp, CONST_STRPTR name, struct DosLibrary *DOSBase); LONG RootDir(struct DevProc *dvp, struct DosLibrary *DOSBase); diff --git a/rom/dos/internalloadseg_support.c b/rom/dos/internalloadseg_support.c index 37a5cd1a54..51c99f5bd7 100644 --- a/rom/dos/internalloadseg_support.c +++ b/rom/dos/internalloadseg_support.c @@ -9,7 +9,14 @@ static char *getname(BPTR file, char **bufferp, struct DosLibrary *DOSBase) { - if (DOSBase) { + /* Some applications pass a non-filehandle to + * Dos/InternalLoadSeg, so don't try to register + * the hunks if this is not a real FileHandle + * + * A real-life example of this is C:AddDataTypes + * from AmigaOS 3.9 + */ + if (ISFILEHANDLE(file) && DOSBase) { char *buffer = AllocMem(512, MEMF_ANY); if (buffer) { *bufferp = buffer; -- 2.11.4.GIT