dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnet/engine int_proto.h,1.51,1.52 int_table.


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnet/engine int_proto.h,1.51,1.52 int_table.c,1.53,1.54 lib_reflect.c,1.31,1.32
Date: Fri, 28 Mar 2003 20:39:24 -0500

Update of /cvsroot/dotgnu-pnet/pnet/engine
In directory subversions:/tmp/cvs-serv18915/engine

Modified Files:
        int_proto.h int_table.c lib_reflect.c 
Log Message:


Add the "Assembly.LoadFromBytes" internalcall.


Index: int_proto.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/int_proto.h,v
retrieving revision 1.51
retrieving revision 1.52
diff -C2 -r1.51 -r1.52
*** int_proto.h 28 Mar 2003 01:05:33 -0000      1.51
--- int_proto.h 29 Mar 2003 01:39:22 -0000      1.52
***************
*** 282,290 ****
  extern ILObject * _IL_Assembly_GetExecutingAssembly(ILExecThread * _thread);
  extern ILObject * _IL_Assembly_GetType(ILExecThread * _thread, ILObject * 
_this, ILString * _p1, ILBool _p2, ILBool _p3);
  extern ILObject * _IL_Assembly_GetManifestResourceStream(ILExecThread * 
_thread, ILObject * _this, ILString * _p1);
  extern ILString * _IL_Assembly_GetSatellitePath(ILExecThread * _thread, 
ILObject * _this, ILString * _p1);
  extern ILObject * _IL_Assembly_LoadFromFile(ILExecThread * _thread, ILString 
* _p1, ILInt32 * error, ILObject * _p3);
- extern ILObject * _IL_Assembly_GetCallingAssembly(ILExecThread * _thread);
- extern ILObject * _IL_Assembly_LoadFromName(ILExecThread * _thread, ILString 
* _p1, ILInt32 * error, ILObject * _p3);
  extern ILObject * _IL_Assembly_GetEntryAssembly(ILExecThread * _thread);
  extern System_Array * _IL_Assembly_GetExportedTypes(ILExecThread * _thread, 
ILObject * _this);
--- 282,290 ----
  extern ILObject * _IL_Assembly_GetExecutingAssembly(ILExecThread * _thread);
  extern ILObject * _IL_Assembly_GetType(ILExecThread * _thread, ILObject * 
_this, ILString * _p1, ILBool _p2, ILBool _p3);
+ extern ILObject * _IL_Assembly_GetCallingAssembly(ILExecThread * _thread);
+ extern ILObject * _IL_Assembly_LoadFromBytes(ILExecThread * _thread, 
System_Array * _p1, ILInt32 * error, ILObject * _p3);
  extern ILObject * _IL_Assembly_GetManifestResourceStream(ILExecThread * 
_thread, ILObject * _this, ILString * _p1);
  extern ILString * _IL_Assembly_GetSatellitePath(ILExecThread * _thread, 
ILObject * _this, ILString * _p1);
  extern ILObject * _IL_Assembly_LoadFromFile(ILExecThread * _thread, ILString 
* _p1, ILInt32 * error, ILObject * _p3);
  extern ILObject * _IL_Assembly_GetEntryAssembly(ILExecThread * _thread);
  extern System_Array * _IL_Assembly_GetExportedTypes(ILExecThread * _thread, 
ILObject * _this);
***************
*** 294,297 ****
--- 294,298 ----
  extern System_Array * _IL_Assembly_GetManifestResourceNames(ILExecThread * 
_thread, ILObject * _this);
  extern System_Array * _IL_Assembly_GetTypes(ILExecThread * _thread, ILObject 
* _this);
+ extern ILObject * _IL_Assembly_LoadFromName(ILExecThread * _thread, ILString 
* _p1, ILInt32 * error, ILObject * _p3);
  extern void _IL_Assembly_GetEntryPoint(ILExecThread * _thread, void * 
_result, ILObject * _this);
  

Index: int_table.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/int_table.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -C2 -r1.53 -r1.54
*** int_table.c 28 Mar 2003 01:05:33 -0000      1.53
--- int_table.c 29 Mar 2003 01:39:22 -0000      1.54
***************
*** 1539,1547 ****
        IL_METHOD("GetExecutingAssembly", "()oSystem.Reflection.Assembly;", 
_IL_Assembly_GetExecutingAssembly, marshal_pp)
        IL_METHOD("GetType", "(ToSystem.String;ZZ)oSystem.Type;", 
_IL_Assembly_GetType, marshal_ppppbb)
        IL_METHOD("GetManifestResourceStream", 
"(ToSystem.String;)oSystem.IO.Stream;", _IL_Assembly_GetManifestResourceStream, 
marshal_pppp)
        IL_METHOD("GetSatellitePath", "(ToSystem.String;)oSystem.String;", 
_IL_Assembly_GetSatellitePath, marshal_pppp)
        IL_METHOD("LoadFromFile", 
"(oSystem.String;&ioSystem.Reflection.Assembly;)oSystem.Reflection.Assembly;", 
_IL_Assembly_LoadFromFile, marshal_ppppp)
-       IL_METHOD("GetCallingAssembly", "()oSystem.Reflection.Assembly;", 
_IL_Assembly_GetCallingAssembly, marshal_pp)
-       IL_METHOD("LoadFromName", 
"(oSystem.String;&ioSystem.Reflection.Assembly;)oSystem.Reflection.Assembly;", 
_IL_Assembly_LoadFromName, marshal_ppppp)
        IL_METHOD("GetEntryAssembly", "()oSystem.Reflection.Assembly;", 
_IL_Assembly_GetEntryAssembly, marshal_pp)
        IL_METHOD("GetExportedTypes", "(T)[oSystem.Type;", 
_IL_Assembly_GetExportedTypes, marshal_ppp)
--- 1539,1547 ----
        IL_METHOD("GetExecutingAssembly", "()oSystem.Reflection.Assembly;", 
_IL_Assembly_GetExecutingAssembly, marshal_pp)
        IL_METHOD("GetType", "(ToSystem.String;ZZ)oSystem.Type;", 
_IL_Assembly_GetType, marshal_ppppbb)
+       IL_METHOD("GetCallingAssembly", "()oSystem.Reflection.Assembly;", 
_IL_Assembly_GetCallingAssembly, marshal_pp)
+       IL_METHOD("LoadFromBytes", 
"([B&ioSystem.Reflection.Assembly;)oSystem.Reflection.Assembly;", 
_IL_Assembly_LoadFromBytes, marshal_ppppp)
        IL_METHOD("GetManifestResourceStream", 
"(ToSystem.String;)oSystem.IO.Stream;", _IL_Assembly_GetManifestResourceStream, 
marshal_pppp)
        IL_METHOD("GetSatellitePath", "(ToSystem.String;)oSystem.String;", 
_IL_Assembly_GetSatellitePath, marshal_pppp)
        IL_METHOD("LoadFromFile", 
"(oSystem.String;&ioSystem.Reflection.Assembly;)oSystem.Reflection.Assembly;", 
_IL_Assembly_LoadFromFile, marshal_ppppp)
        IL_METHOD("GetEntryAssembly", "()oSystem.Reflection.Assembly;", 
_IL_Assembly_GetEntryAssembly, marshal_pp)
        IL_METHOD("GetExportedTypes", "(T)[oSystem.Type;", 
_IL_Assembly_GetExportedTypes, marshal_ppp)
***************
*** 1551,1554 ****
--- 1551,1555 ----
        IL_METHOD("GetManifestResourceNames", "(T)[oSystem.String;", 
_IL_Assembly_GetManifestResourceNames, marshal_ppp)
        IL_METHOD("GetTypes", "(T)[oSystem.Type;", _IL_Assembly_GetTypes, 
marshal_ppp)
+       IL_METHOD("LoadFromName", 
"(oSystem.String;&ioSystem.Reflection.Assembly;)oSystem.Reflection.Assembly;", 
_IL_Assembly_LoadFromName, marshal_ppppp)
        IL_METHOD("GetEntryPoint", "(T)vSystem.RuntimeMethodHandle;", 
_IL_Assembly_GetEntryPoint, marshal_vppp)
  IL_METHOD_END

Index: lib_reflect.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/lib_reflect.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -r1.31 -r1.32
*** lib_reflect.c       6 Mar 2003 23:48:53 -0000       1.31
--- lib_reflect.c       29 Mar 2003 01:39:22 -0000      1.32
***************
*** 1159,1162 ****
--- 1159,1215 ----
  
  /*
+  * internal static Assembly LoadFromBytes(byte[] bytes, out int error,
+  *                                                                            
  Assembly parent);
+  */
+ ILObject *_IL_Assembly_LoadFromBytes(ILExecThread *thread,
+                                                                        
System_Array *bytes,
+                                                                        
ILInt32 *error,
+                                                                        
ILObject *parent)
+ {
+       ILImage *image;
+       int loadError;
+ 
+       /* Bail out if "bytes" is NULL (should be trapped higher
+          up the stack, but let's be paranoid anyway) */
+       if(!bytes)
+       {
+               *error = LoadError_FileNotFound;
+               return 0;
+       }
+ 
+       /* TODO: check security permissions */
+ 
+       /* Attempt to load the image.  Note: we deliberately don't supply
+          the "IL_LOADFLAG_IN_PLACE" flag because we don't want the user
+          to be able to modify the IL binary after we have loaded it.
+          Or worse, have the garbage collector throw the "bytes" array away */
+       loadError = ILImageLoadFromMemory(ArrayToBuffer(bytes),
+                                                                         
(unsigned long)(long)(bytes->length),
+                                                                         
thread->process->context,
+                                                                         
&image, IL_LOADFLAG_FORCE_32BIT, 0);
+       if(loadError == 0)
+       {
+               *error = LoadError_OK;
+               return ImageToAssembly(thread, image);
+       }
+ 
+       /* Convert the error code into something the C# library knows about */
+       if(loadError == -1)
+       {
+               *error = LoadError_FileNotFound;
+       }
+       else if(loadError == IL_LOADERR_MEMORY)
+       {
+               *error = LoadError_FileNotFound;
+               ILExecThreadThrowOutOfMemory(thread);
+       }
+       else
+       {
+               *error = LoadError_BadImage;
+       }
+       return 0;
+ }
+ 
+ /*
   * private static Type GetType(String typeName, bool throwOnError,
   *                                                       bool ignoreCase)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]