public unsafe void ThreadPoolDequeueWorkObject(object workID) { this.ThreadPoolDequeueWork((long)((ulong)(*(IntPtr *)((void *)JitHelpers.UnsafeCastToStackPointer <object>(ref workID))))); }
internal Type LoadTypeForWinRTTypeNameInContext(string typeName) { if (typeName is null) { throw new ArgumentNullException(nameof(typeName)); } lock (_unloadLock) { VerifyIsAlive(); Type?type = null; LoadTypeForWinRTTypeNameInContextInternal(_nativeAssemblyLoadContext, typeName, JitHelpers.GetObjectHandleOnStack(ref type)); return(type !); } }
// This method is invoked when First is called on a managed implementation of IBindableIterable. internal IBindableIterator First_Stub() { IEnumerable _this = JitHelpers.UnsafeCast <IEnumerable>(this); return(new EnumeratorToIteratorAdapter <object>(new NonGenericToGenericEnumerator(_this.GetEnumerator()))); }
public unsafe void ThreadPoolDequeueWorkObject(object workID) { // convert the Object Id to a long ThreadPoolDequeueWork((long)*((void **)JitHelpers.UnsafeCastToStackPointer(ref workID))); }
public unsafe void ThreadTransferReceiveHandledObj(object id, int kind, string info) { ThreadTransferReceive((long)*((void **)JitHelpers.UnsafeCastToStackPointer(ref id)), kind, info); }
/// <summary> /// Creates a new span over the entirety of the target array. /// </summary> /// <param name="array">The target array.</param> public Span(T[] array) { JitHelpers.SetByRef(out _rawPointer, ref JitHelpers.GetArrayData(array)); _length = array.Length; }
public override Type[] GetExportedTypes() { Type[]? types = null; RuntimeAssembly runtimeAssembly = this; GetExportedTypes(JitHelpers.GetQCallAssemblyOnStack(ref runtimeAssembly), JitHelpers.GetObjectHandleOnStack(ref types)); return(types !); }
internal void CopyTo <K, V>(KeyValuePair <K, V>[] array, int arrayIndex) { if (array == null) { throw new ArgumentNullException("array"); } if (arrayIndex < 0) { throw new ArgumentOutOfRangeException("arrayIndex"); } if (array.Length <= arrayIndex && this.Count <K, V>() > 0) { throw new ArgumentException(Environment.GetResourceString("Argument_IndexOutOfArrayBounds")); } if (array.Length - arrayIndex < this.Count <K, V>()) { throw new ArgumentException(Environment.GetResourceString("Argument_InsufficientSpaceToCopyCollection")); } foreach (KeyValuePair <K, V> keyValuePair in (IEnumerable <KeyValuePair <K, V> >)JitHelpers.UnsafeCast <IIterable <KeyValuePair <K, V> > >((object)this)) { array[arrayIndex++] = keyValuePair; } }
public static Assembly[] GetLoadedAssemblies() { Assembly[] assemblies = null; GetLoadedAssembliesInternal(JitHelpers.GetObjectHandleOnStack(ref assemblies)); return(assemblies); }
private SafeTypeNameParserHandle[] GetTypeArguments() { SafeTypeNameParserHandle[] o = (SafeTypeNameParserHandle[])null; TypeNameParser._GetTypeArguments(this.m_NativeParser, JitHelpers.GetObjectHandleOnStack <SafeTypeNameParserHandle[]>(ref o)); return(o); }
private int[] GetModifiers() { int[] o = (int[])null; TypeNameParser._GetModifiers(this.m_NativeParser, JitHelpers.GetObjectHandleOnStack <int[]>(ref o)); return(o); }
private string[] GetNames() { string[] o = (string[])null; TypeNameParser._GetNames(this.m_NativeParser, JitHelpers.GetObjectHandleOnStack <string[]>(ref o)); return(o); }
public unsafe void ThreadTransferReceiveHandledObj(object id, int kind, string info) { this.ThreadTransferReceive((long)((ulong)(*(IntPtr *)((void *)JitHelpers.UnsafeCastToStackPointer <object>(ref id)))), kind, info); }
public unsafe void ThreadTransferSendObj(object id, int kind, string info, bool multiDequeues) { this.ThreadTransferSend((long)((ulong)(*(IntPtr *)((void *)JitHelpers.UnsafeCastToStackPointer <object>(ref id)))), kind, info, multiDequeues); }
public Assembly LoadFromNativeImagePath(string nativeImagePath, string assemblyPath) { if (nativeImagePath == null) { throw new ArgumentNullException(nameof(nativeImagePath)); } lock (unloadLock) { VerifyIsAlive(); if (PathInternal.IsPartiallyQualified(nativeImagePath)) { throw new ArgumentException(SR.GetResourceString("Argument_AbsolutePathRequired"), nameof(nativeImagePath)); } if (assemblyPath != null && PathInternal.IsPartiallyQualified(assemblyPath)) { throw new ArgumentException(SR.GetResourceString("Argument_AbsolutePathRequired"), nameof(assemblyPath)); } // Basic validation has succeeded - lets try to load the NI image. RuntimeAssembly loadedAssembly = null; LoadFromPath(m_pNativeAssemblyLoadContext, assemblyPath, nativeImagePath, JitHelpers.GetObjectHandleOnStack(ref loadedAssembly)); return(loadedAssembly); } }
internal unsafe static void StoreOverlappedInCCW(Object windowsRuntimeBuffer, NativeOverlapped *overlapped) { StoreOverlappedPtrInCCW(JitHelpers.GetObjectHandleOnStack(ref windowsRuntimeBuffer), overlapped); }
/// <summary> /// Checks to see if two spans point at the same memory. Note that /// this does *not* check to see if the *contents* are equal. /// </summary> public bool Equals(Span <T> other) { return((_length == other._length) && (_length == 0 || JitHelpers.ByRefEquals(ref JitHelpers.GetByRef <T>(ref _rawPointer), ref JitHelpers.GetByRef <T>(ref other._rawPointer)))); }
public override int Compare(T x, T y) => JitHelpers.EnumCompareTo(x, y);
/// <summary> /// An internal helper for creating spans. Not for public use. /// </summary> private Span(ref T ptr, int length) { JitHelpers.SetByRef(out _rawPointer, ref ptr); _length = length; }
public Assembly LoadFromNativeImagePath(string nativeImagePath, string assemblyPath) { if (nativeImagePath == null) { throw new ArgumentNullException("nativeImagePath"); } if (Path.IsRelative(nativeImagePath)) { throw new ArgumentException( Environment.GetResourceString("Argument_AbsolutePathRequired"), "nativeImagePath"); } // Check if the nativeImagePath has ".ni.dll" or ".ni.exe" extension if (!(nativeImagePath.EndsWith(".ni.dll", StringComparison.InvariantCultureIgnoreCase) || nativeImagePath.EndsWith(".ni.exe", StringComparison.InvariantCultureIgnoreCase))) { throw new ArgumentException("nativeImagePath"); } if (assemblyPath != null && Path.IsRelative(assemblyPath)) { throw new ArgumentException(Environment.GetResourceString("Argument_AbsolutePathRequired"), "assemblyPath"); } // Basic validation has succeeded - lets try to load the NI image. // Ask LoadFile to load the specified assembly in the DefaultContext RuntimeAssembly loadedAssembly = null; LoadFromPath(m_pNativeAssemblyLoadContext, assemblyPath, nativeImagePath, JitHelpers.GetObjectHandleOnStack(ref loadedAssembly)); return loadedAssembly; }
internal string?GetCodeBase(bool copiedName) { string? codeBase = null; RuntimeAssembly runtimeAssembly = this; GetCodeBase(JitHelpers.GetQCallAssemblyOnStack(ref runtimeAssembly), copiedName, JitHelpers.GetStringHandleOnStack(ref codeBase)); return(codeBase); }
private StrongName GenerateStrongNameEvidence() { byte[] o = (byte[])null; string s = (string)null; ushort majorVersion = 0; ushort minorVersion = 0; ushort build = 0; ushort revision = 0; AssemblyEvidenceFactory.GetStrongNameInformation(this.m_targetAssembly.GetNativeHandle(), JitHelpers.GetObjectHandleOnStack <byte[]>(ref o), JitHelpers.GetStringHandleOnStack(ref s), out majorVersion, out minorVersion, out build, out revision); if (o == null || o.Length == 0) { return((StrongName)null); } return(new StrongName(new StrongNamePublicKeyBlob(o), s, new Version((int)majorVersion, (int)minorVersion, (int)build, (int)revision), (Assembly)this.m_targetAssembly)); }
public unsafe void ThreadTransferSendObj(object id, int kind, string info, bool multiDequeues) { ThreadTransferSend((long)*((void **)JitHelpers.UnsafeCastToStackPointer(ref id)), kind, info, multiDequeues); }
private PermissionRequestEvidence GeneratePermissionRequestEvidence() { PermissionSet o1 = (PermissionSet)null; PermissionSet o2 = (PermissionSet)null; PermissionSet o3 = (PermissionSet)null; AssemblyEvidenceFactory.GetAssemblyPermissionRequests(this.m_targetAssembly.GetNativeHandle(), JitHelpers.GetObjectHandleOnStack <PermissionSet>(ref o1), JitHelpers.GetObjectHandleOnStack <PermissionSet>(ref o2), JitHelpers.GetObjectHandleOnStack <PermissionSet>(ref o3)); if (o1 != null || o2 != null || o3 != null) { return(new PermissionRequestEvidence(o1, o2, o3)); } return((PermissionRequestEvidence)null); }
public Assembly LoadFromNativeImagePath(string nativeImagePath, string assemblyPath) { if (nativeImagePath == null) { throw new ArgumentNullException(nameof(nativeImagePath)); } if (PathInternal.IsPartiallyQualified(nativeImagePath)) { throw new ArgumentException(SR.Argument_AbsolutePathRequired, nameof(nativeImagePath)); } if (assemblyPath != null && PathInternal.IsPartiallyQualified(assemblyPath)) { throw new ArgumentException(SR.Argument_AbsolutePathRequired, nameof(assemblyPath)); } // Basic validation has succeeded - lets try to load the NI image. // Ask LoadFile to load the specified assembly in the DefaultContext RuntimeAssembly loadedAssembly = null; LoadFromPath(m_pNativeAssemblyLoadContext, assemblyPath, nativeImagePath, JitHelpers.GetObjectHandleOnStack(ref loadedAssembly)); return(loadedAssembly); }
public static void SwapMethodBody(Type cls, int methodtoken, IntPtr rgIL, int methodSize, int flags) { if (methodSize <= 0 || methodSize >= 4128768) { throw new ArgumentException(Environment.GetResourceString("Argument_BadSizeForData"), "methodSize"); } if (cls == (Type)null) { throw new ArgumentNullException("cls"); } Module module = cls.Module; ModuleBuilder moduleBuilder = module as ModuleBuilder; InternalModuleBuilder internalModuleBuilder = !((Module)moduleBuilder != (Module)null) ? module as InternalModuleBuilder : moduleBuilder.InternalModule; if ((Module)internalModuleBuilder == (Module)null) { throw new NotSupportedException(Environment.GetResourceString("NotSupported_NotDynamicModule")); } RuntimeType runtimeType; if (cls is TypeBuilder) { TypeBuilder typeBuilder = (TypeBuilder)cls; if (!typeBuilder.IsCreated()) { throw new NotSupportedException(Environment.GetResourceString("NotSupported_NotAllTypesAreBaked", (object)typeBuilder.Name)); } runtimeType = typeBuilder.BakedRuntimeType; } else { runtimeType = cls as RuntimeType; } if (runtimeType == (RuntimeType)null) { throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), "cls"); } StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; lock (internalModuleBuilder.GetRuntimeAssembly().SyncRoot) MethodRental.SwapMethodBody(runtimeType.GetTypeHandleInternal(), methodtoken, rgIL, methodSize, flags, JitHelpers.GetStackCrawlMarkHandle(ref stackMark)); }
// This method is invoked when First is called on a managed implementation of IIterable<T>. internal IIterator <T> First_Stub <T>() { IEnumerable <T> _this = JitHelpers.UnsafeCast <IEnumerable <T> >(this); return(new EnumeratorToIteratorAdapter <T>(_this.GetEnumerator())); }
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable public static void SwapMethodBody( Type cls, // [in] class containing the method int methodtoken, // [in] method token IntPtr rgIL, // [in] pointer to bytes int methodSize, // [in] the size of the new method body in bytes int flags) // [in] flags { if (methodSize <= 0 || methodSize >= 0x3f0000) { throw new ArgumentException(Environment.GetResourceString("Argument_BadSizeForData"), "methodSize"); } if (cls == null) { throw new ArgumentNullException("cls"); } Contract.EndContractBlock(); Module module = cls.Module; InternalModuleBuilder internalMB; ModuleBuilder mb = module as ModuleBuilder; if (mb != null) { internalMB = mb.InternalModule; } else { internalMB = module as InternalModuleBuilder; } // can only swap method body on dynamic module // dynamic internal module type is always exactly InternalModuleBuilder, non-dynamic is always something different if (internalMB == null) { throw new NotSupportedException(Environment.GetResourceString("NotSupported_NotDynamicModule")); } RuntimeType rType; if (cls is TypeBuilder) { // If it is a TypeBuilder, make sure that TypeBuilder is already been baked. TypeBuilder typeBuilder = (TypeBuilder)cls; if (!typeBuilder.IsCreated()) { throw new NotSupportedException(Environment.GetResourceString("NotSupported_NotAllTypesAreBaked", typeBuilder.Name)); } // get the corresponding runtime type for the TypeBuilder. rType = typeBuilder.BakedRuntimeType; } else { rType = cls as RuntimeType; } if (rType == null) { throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), "cls"); } StackCrawlMark mark = StackCrawlMark.LookForMyCaller; RuntimeAssembly rtAssembly = internalMB.GetRuntimeAssembly(); lock (rtAssembly.SyncRoot) { SwapMethodBody(rType.GetTypeHandleInternal(), methodtoken, rgIL, methodSize, flags, JitHelpers.GetStackCrawlMarkHandle(ref mark)); } }
public Assembly LoadFromStream(Stream assembly, Stream assemblySymbols) { if (assembly == null) { throw new ArgumentNullException(nameof(assembly)); } if (assembly.Length <= 0) { throw new BadImageFormatException(SR.BadImageFormat_BadILFormat); } int iAssemblyStreamLength = (int)assembly.Length; int iSymbolLength = 0; // Allocate the byte[] to hold the assembly byte[] arrAssembly = new byte[iAssemblyStreamLength]; // Copy the assembly to the byte array assembly.Read(arrAssembly, 0, iAssemblyStreamLength); // Get the symbol stream in byte[] if provided byte[] arrSymbols = null; if (assemblySymbols != null) { iSymbolLength = (int)assemblySymbols.Length; arrSymbols = new byte[iSymbolLength]; assemblySymbols.Read(arrSymbols, 0, iSymbolLength); } RuntimeAssembly loadedAssembly = null; unsafe { fixed(byte *ptrAssembly = arrAssembly, ptrSymbols = arrSymbols) { LoadFromStream(m_pNativeAssemblyLoadContext, new IntPtr(ptrAssembly), iAssemblyStreamLength, new IntPtr(ptrSymbols), iSymbolLength, JitHelpers.GetObjectHandleOnStack(ref loadedAssembly)); } } return(loadedAssembly); }
internal void Clear() { IBindableVector _this = JitHelpers.UnsafeCast <IBindableVector>(this); _this.Clear(); }