[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] pnet/image image.h, 1.34, 1.35 link.c, 1.31, 1.32
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] pnet/image image.h, 1.34, 1.35 link.c, 1.31, 1.32 meta_build.c, 1.35, 1.36 |
Date: |
Mon, 24 Nov 2003 09:04:15 +0000 |
Update of /cvsroot/dotgnu-pnet/pnet/image
In directory subversions:/tmp/cvs-serv18897/image
Modified Files:
image.h link.c meta_build.c
Log Message:
Dynamic loading for images referred to via ModuleRef tokens.
Index: meta_build.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/image/meta_build.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -d -r1.35 -r1.36
*** meta_build.c 24 Nov 2003 07:46:17 -0000 1.35
--- meta_build.c 24 Nov 2003 09:04:13 -0000 1.36
***************
*** 560,564 ****
goto moduleImport;
}
! /* TODO: dynamically load the specified module
*/
}
break;
--- 560,570 ----
goto moduleImport;
}
! if(!_ILImageDynamicLinkModule(image,
image->filename,
!
ILModule_Name((ILModule *)scope),
!
loadFlags, &importImage) &&
! importImage != 0)
! {
! goto moduleImport;
! }
}
break;
Index: image.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/image/image.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** image.h 23 Nov 2003 02:30:07 -0000 1.34
--- image.h 24 Nov 2003 09:04:13 -0000 1.35
***************
*** 505,508 ****
--- 505,516 ----
/*
+ * Perform dynamic linking on a module reference.
+ * Returns a load error
+ */
+ int _ILImageDynamicLinkModule(ILImage *image, const char *filename,
+ const char
*moduleName, int flags,
+ ILImage **newImage);
+
+ /*
* Free the information associated with an image's tokens.
*/
Index: link.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/image/link.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** link.c 23 Nov 2003 02:30:07 -0000 1.31
--- link.c 24 Nov 2003 09:04:13 -0000 1.32
***************
*** 706,709 ****
--- 706,785 ----
}
+ int _ILImageDynamicLinkModule(ILImage *image, const char *filename,
+ const char
*moduleName, int flags,
+ ILImage **newImage)
+ {
+ char *pathname;
+ int error;
+ int len, retryLower;
+
+ /* Clear the return image before we start */
+ *newImage = 0;
+
+ /* If we loaded the parent from an insecure source, then bail out
+ without attempting to load the module files */
+ if((flags & IL_LOADFLAG_INSECURE) != 0 || !filename)
+ {
+ return 0;
+ }
+
+ /* Strip the final component from the filename */
+ len = strlen(filename);
+ while(len > 0 && filename[len - 1] != '/' && filename[len - 1] != '\\')
+ {
+ --len;
+ }
+ if(len > 0)
+ {
+ --len;
+ }
+
+ /* Ignore this module if we already have it */
+ if(ILContextGetFile(image->context, moduleName) != 0)
+ {
+ return 0;
+ }
+
+ /* Ignore this module if its name contains a '/' or '\', because
+ files in other directories may be a security risk */
+ if(ILMemChr(moduleName, '/', strlen(moduleName)) != 0 ||
+ ILMemChr(moduleName, '\\', strlen(moduleName)) != 0)
+ {
+ return 0;
+ }
+
+ /* Get the full pathname of the referenced file */
+ retryLower = 0;
+ pathname = TestPathForFile(filename, len,
+ moduleName,
strlen(moduleName),
+ 0, 0, &retryLower,
0);
+ if(!pathname && retryLower)
+ {
+ pathname = TestPathForFile(filename, len,
+ moduleName,
strlen(moduleName),
+ 0, 0,
&retryLower, 1);
+ }
+ if(!pathname)
+ {
+ #if IL_DEBUG_META
+ fprintf(stderr, "could not locate the file %s\n", moduleName);
+ #endif
+ return IL_LOADERR_UNRESOLVED;
+ }
+
+ /* Load the image */
+ error = ILImageLoadFromFile(pathname, image->context,
+ newImage, flags, 0);
+ ILFree(pathname);
+ if(error == -1)
+ {
+ return IL_LOADERR_UNRESOLVED;
+ }
+ else
+ {
+ return error;
+ }
+ }
+
int ILImageLoadAssembly(const char *name, ILContext *context,
ILImage *parentImage, ILImage
**image)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] pnet/image image.h, 1.34, 1.35 link.c, 1.31, 1.32 meta_build.c, 1.35, 1.36,
Rhys Weatherley <address@hidden> <=