public static MethodBase GetMethodFromHandle (RuntimeMethodHandle handle) { MethodBase res = GetMethodFromIntPtr (handle.Value, IntPtr.Zero); Type t = res.DeclaringType; if (t.IsGenericType || t.IsGenericTypeDefinition) throw new ArgumentException ("Cannot resolve method because it's declared in a generic class."); return res; }
// // This overload of GetMethodForHandle only accepts handles for methods declared on non-generic types (the method, however, // can be an instance of a generic method.) To resolve handles for methods declared on generic types, you must pass // the declaring type explicitly using the two-argument overload of GetMethodFromHandle. // // This is a vestige from desktop generic sharing that got itself enshrined in the code generated by the C# compiler for Linq Expressions. // public sealed override MethodBase GetMethodFromHandle(RuntimeMethodHandle runtimeMethodHandle) { ExecutionEnvironment executionEnvironment = ReflectionCoreExecution.ExecutionEnvironment; MethodHandle methodHandle; RuntimeTypeHandle declaringTypeHandle; RuntimeTypeHandle[] genericMethodTypeArgumentHandles; if (!executionEnvironment.TryGetMethodFromHandle(runtimeMethodHandle, out declaringTypeHandle, out methodHandle, out genericMethodTypeArgumentHandles)) throw new ArgumentException(SR.Argument_InvalidHandle); MethodBase methodBase = ReflectionCoreExecution.ExecutionDomain.GetMethod(declaringTypeHandle, methodHandle, genericMethodTypeArgumentHandles); if (methodBase.DeclaringType.IsConstructedGenericType) // For compat with desktop, insist that the caller pass us the declaring type to resolve members of generic types. throw new ArgumentException(SR.Format(SR.Argument_MethodDeclaringTypeGeneric, methodBase)); return methodBase; }
// // This overload of GetMethodHandle can handle all method handles. // public sealed override MethodBase GetMethodFromHandle(RuntimeMethodHandle runtimeMethodHandle, RuntimeTypeHandle declaringTypeHandle) { ExecutionEnvironment executionEnvironment = ReflectionCoreExecution.ExecutionEnvironment; MethodHandle methodHandle; RuntimeTypeHandle[] genericMethodTypeArgumentHandles; if (!executionEnvironment.TryGetMethodFromHandleAndType(runtimeMethodHandle, declaringTypeHandle, out methodHandle, out genericMethodTypeArgumentHandles)) { // This may be a method declared on a non-generic type: this api accepts that too so try the other table. RuntimeTypeHandle actualDeclaringTypeHandle; if (!executionEnvironment.TryGetMethodFromHandle(runtimeMethodHandle, out actualDeclaringTypeHandle, out methodHandle, out genericMethodTypeArgumentHandles)) throw new ArgumentException(SR.Argument_InvalidHandle); if (!actualDeclaringTypeHandle.Equals(declaringTypeHandle)) throw new ArgumentException(SR.Format(SR.Argument_ResolveMethodHandle, ReflectionCoreNonPortable.GetTypeForRuntimeTypeHandle(declaringTypeHandle), ReflectionCoreNonPortable.GetTypeForRuntimeTypeHandle(actualDeclaringTypeHandle))); } MethodBase methodBase = ReflectionCoreExecution.ExecutionDomain.GetMethod(declaringTypeHandle, methodHandle, genericMethodTypeArgumentHandles); return methodBase; }
public bool PosTest2() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("Verify different instances are equal when they have the same values..."); try { //default value is zero RuntimeMethodHandle myHandle = new RuntimeMethodHandle(); if (!myHandle.Equals(myRuntimeMethodHandle)) { TestLibrary.TestFramework.LogError("003","The two instance should be different!"); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("004","Unexpected exception occurs: " + e); retVal = false; } return retVal; }
public bool PosTest1() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("Verify clone instance is equal to it original..."); try { RuntimeMethodHandle myHandle = new RuntimeMethodHandle(); object cloneHandle = myHandle; if (!myHandle.Equals(cloneHandle)) { TestLibrary.TestFramework.LogError("001","The two instances should be equal!"); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("002","Unexpected exception occurs: " + e); retVal = false; } return retVal; }
public bool PosTest2() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("Verify cloned instance has the same hashcode of it original..."); try { RuntimeMethodHandle myHandle1 = new RuntimeMethodHandle(); RuntimeMethodHandle myHandle2 = myHandle1; if (myHandle1.GetHashCode() != myHandle2.GetHashCode()) { TestLibrary.TestFramework.LogError("003","The two instances should have the same hashcode!"); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("004","Unexpected exception occurs: " + e); return retVal; } return retVal; }
public bool PosTest1() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("Verify different instances of RuntimeMethodGetHashCode..."); try { RuntimeMethodHandle myHandle1 = new RuntimeMethodHandle(); RuntimeMethodHandle myHandle2 = new RuntimeMethodHandle(); if (myHandle1.GetHashCode() != myHandle2.GetHashCode()) { TestLibrary.TestFramework.LogError("001","The two instance should have the same HashCode!"); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("002","Unexpected exception occurs: " + e); retVal = false; } return retVal; }
private static RuntimeMethodInfo?AssignAssociates( int tkMethod, RuntimeType declaredType, RuntimeType reflectedType) { if (MetadataToken.IsNullToken(tkMethod)) { return(null); } Debug.Assert(declaredType != null); Debug.Assert(reflectedType != null); bool isInherited = declaredType != reflectedType; IntPtr[]? genericArgumentHandles = null; int genericArgumentCount = 0; RuntimeType[] genericArguments = declaredType.GetTypeHandleInternal().GetInstantiationInternal(); if (genericArguments != null) { genericArgumentCount = genericArguments.Length; genericArgumentHandles = new IntPtr[genericArguments.Length]; for (int i = 0; i < genericArguments.Length; i++) { genericArgumentHandles[i] = genericArguments[i].GetTypeHandleInternal().Value; } } RuntimeMethodHandleInternal associateMethodHandle = ModuleHandle.ResolveMethodHandleInternal(RuntimeTypeHandle.GetModule(declaredType), tkMethod, genericArgumentHandles, genericArgumentCount, null, 0); Debug.Assert(!associateMethodHandle.IsNullHandle(), "Failed to resolve associateRecord methodDef token"); if (isInherited) { MethodAttributes methAttr = RuntimeMethodHandle.GetAttributes(associateMethodHandle); // ECMA MethodSemantics: "All methods for a given Property or Event shall have the same accessibility // (ie the MemberAccessMask subfield of their Flags row) and cannot be CompilerControlled [CLS]" // Consequently, a property may be composed of public and private methods. If the declared type != // the reflected type, the private methods should not be exposed. Note that this implies that the // identity of a property includes it's reflected type. if ((methAttr & MethodAttributes.MemberAccessMask) == MethodAttributes.Private) { return(null); } // Note this is the first time the property was encountered walking from the most derived class // towards the base class. It would seem to follow that any associated methods would not // be overriden -- but this is not necessarily true. A more derived class may have overriden a // virtual method associated with a property in a base class without associating the override with // the same or any property in the derived class. if ((methAttr & MethodAttributes.Virtual) != 0) { bool declaringTypeIsClass = (RuntimeTypeHandle.GetAttributes(declaredType) & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Class; // It makes no sense to search for a virtual override of a method declared on an interface. if (declaringTypeIsClass) { int slot = RuntimeMethodHandle.GetSlot(associateMethodHandle); // Find the override visible from the reflected type associateMethodHandle = RuntimeTypeHandle.GetMethodAt(reflectedType, slot); } } } RuntimeMethodInfo?associateMethod = RuntimeType.GetMethodBase(reflectedType, associateMethodHandle) as RuntimeMethodInfo; // suppose a property was mapped to a method not in the derivation hierarchy of the reflectedTypeHandle return(associateMethod ?? reflectedType.Module.ResolveMethod(tkMethod, null, null) as RuntimeMethodInfo); }
internal static MethodBase GetMethodFromHandleNoGenericCheck (RuntimeMethodHandle handle) { return GetMethodFromHandleInternalType_native (handle.Value, IntPtr.Zero, false); }
public static bool op_Inequality(RuntimeMethodHandle left, RuntimeMethodHandle right) { }
public static void PrepareMethod(RuntimeMethodHandle method) { }
internal bool CheckSetDemand(PermissionSet demandSet , out PermissionSet alteredDemandset, RuntimeMethodHandle rmh) { alteredDemandset = null; if (CheckAssert(AssertSet, demandSet, out alteredDemandset) == SecurityRuntime.StackHalt) return SecurityRuntime.StackHalt; if (alteredDemandset != null) demandSet = alteredDemandset; // note that this does not modify demandSet external to this function. CodeAccessSecurityEngine.CheckSetHelper(GrantSet, RefusedSet, demandSet, rmh, null, SecurityAction.Demand, true); return SecurityRuntime.StackContinue; }
public static void PrepareMethod (RuntimeMethodHandle method, RuntimeTypeHandle[] instantiation) { }
internal static MethodBase GetMethodFromHandleNoGenericCheck(RuntimeMethodHandle handle) { return(GetMethodFromHandleInternalType_native(handle.Value, IntPtr.Zero, false)); }
internal static MethodBase GetMethodFromHandleNoGenericCheck(RuntimeMethodHandle handle, RuntimeTypeHandle reflectedType) { return(GetMethodFromHandleInternalType_native(handle.Value, reflectedType.Value, false)); }
public abstract bool GetRuntimeMethodHandleComponents(RuntimeMethodHandle runtimeMethodHandle, out RuntimeTypeHandle declaringTypeHandle, out MethodNameAndSignature nameAndSignature, out RuntimeTypeHandle[] genericMethodArgs);
internal unsafe static ParameterInfo[] GetParameters( IRuntimeMethodInfo methodHandle, MemberInfo member, Signature sig, out ParameterInfo returnParameter, bool fetchReturnParameter) { returnParameter = null; int sigArgCount = sig.Arguments.Length; ParameterInfo[] args = fetchReturnParameter ? null : new ParameterInfo[sigArgCount]; int tkMethodDef = RuntimeMethodHandle.GetMethodDef(methodHandle); int cParamDefs = 0; // Not all methods have tokens. Arrays, pointers and byRef types do not have tokens as they // are generated on the fly by the runtime. if (!MdToken.IsNullToken(tkMethodDef)) { MetadataImport scope = RuntimeTypeHandle.GetMetadataImport(RuntimeMethodHandle.GetDeclaringType(methodHandle)); MetadataEnumResult tkParamDefs; scope.EnumParams(tkMethodDef, out tkParamDefs); cParamDefs = tkParamDefs.Length; // Not all parameters have tokens. Parameters may have no token // if they have no name and no attributes. if (cParamDefs > sigArgCount + 1 /* return type */) { throw new BadImageFormatException(SR.BadImageFormat_ParameterSignatureMismatch); } for (int i = 0; i < cParamDefs; i++) { #region Populate ParameterInfos ParameterAttributes attr; int position, tkParamDef = tkParamDefs[i]; scope.GetParamDefProps(tkParamDef, out position, out attr); position--; if (fetchReturnParameter == true && position == -1) { // more than one return parameter? if (returnParameter != null) { throw new BadImageFormatException(SR.BadImageFormat_ParameterSignatureMismatch); } returnParameter = new RuntimeParameterInfo(sig, scope, tkParamDef, position, attr, member); } else if (fetchReturnParameter == false && position >= 0) { // position beyong sigArgCount? if (position >= sigArgCount) { throw new BadImageFormatException(SR.BadImageFormat_ParameterSignatureMismatch); } args[position] = new RuntimeParameterInfo(sig, scope, tkParamDef, position, attr, member); } #endregion } } // Fill in empty ParameterInfos for those without tokens if (fetchReturnParameter) { if (returnParameter == null) { returnParameter = new RuntimeParameterInfo(sig, MetadataImport.EmptyImport, 0, -1, (ParameterAttributes)0, member); } } else { if (cParamDefs < args.Length + 1) { for (int i = 0; i < args.Length; i++) { if (args[i] != null) { continue; } args[i] = new RuntimeParameterInfo(sig, MetadataImport.EmptyImport, 0, i, (ParameterAttributes)0, member); } } } return(args); }
public static IntPtr GVMLookupForSlot(RuntimeTypeHandle type, RuntimeMethodHandle slot) { return(GenericVirtualMethodSupport.GVMLookupForSlot(type, slot)); }
internal RuntimeType[] GetGenericArgumentsInternal() { return(RuntimeMethodHandle.GetMethodInstantiationInternal(this)); }
internal MonoMethod(RuntimeMethodHandle mhandle) { this.mhandle = mhandle.Value; }
public bool PosTest3() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("Verify RuntimeMethodHandle instance is not equal to common object instance..."); try { RuntimeMethodHandle myHandle = new RuntimeMethodHandle(); if (myHandle.Equals(myObj)) { TestLibrary.TestFramework.LogError("005","The two instances should not be equal!"); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("006","Unexpected exception occurs: " + e); retVal = false; } return retVal; }
internal RuntimeMethodInfo(RuntimeMethodHandle mhandle) { this.mhandle = mhandle.Value; }
public abstract MethodBase GetMethodFromHandle(RuntimeMethodHandle runtimeMethodHandle, RuntimeTypeHandle declaringTypeHandle);
public abstract bool TryGetMethodFromHandleAndType(RuntimeMethodHandle runtimeMethodHandle, RuntimeTypeHandle declaringTypeHandle, out MethodHandle methodHandle, out RuntimeTypeHandle[] genericMethodTypeArgumentHandles);
public static void PrepareMethod(RuntimeMethodHandle method, RuntimeTypeHandle[] instantiation) { }
internal static void DeclareScript(string path, RuntimeMethodHandle mainmethodHandle) { var mainmethod = MethodBase.GetMethodFromHandle(mainmethodHandle); GetScriptIndex(path, mainmethod.DeclaringType.GetTypeInfo()); }
public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle, RuntimeTypeHandle declaringType);
public override MethodImplAttributes GetMethodImplementationFlags() { return(RuntimeMethodHandle.GetImplAttributes(this)); }
internal static Exception MakeSecurityException(AssemblyName asmName, Evidence asmEvidence, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed) { // See if we need to throw a HostProtectionException instead HostProtectionPermission hostProtectionPerm = permThatFailed as HostProtectionPermission; if (hostProtectionPerm != null) { return(new HostProtectionException(GetResString("HostProtection_HostProtection"), HostProtectionPermission.protectedResources, hostProtectionPerm.Resources)); } // Produce relevant strings String message = ""; MethodInfo method = null; try { if (granted == null && refused == null && demand == null) { message = GetResString("Security_NoAPTCA"); } else { if (demand != null && demand is IPermission) { message = String.Format(CultureInfo.InvariantCulture, GetResString("Security_Generic"), demand.GetType().AssemblyQualifiedName); } else if (permThatFailed != null) { message = String.Format(CultureInfo.InvariantCulture, GetResString("Security_Generic"), permThatFailed.GetType().AssemblyQualifiedName); } else { message = GetResString("Security_GenericNoType"); } } method = SecurityRuntime.GetMethodInfo(rmh); } catch (Exception e) { // Environment.GetResourceString will throw if we are ReadyForAbort (thread abort). (We shouldn't do a BCLDebug.Assert in this case or it will lock up the thread.) if (e is System.Threading.ThreadAbortException) { throw; } } /* catch(System.Threading.ThreadAbortException) * { * // Environment.GetResourceString will throw if we are ReadyForAbort (thread abort). (We shouldn't do a BCLDebug.Assert in this case or it will lock up the thread.) * throw; * } * catch * { * } */ // make the exception object return(new SecurityException(message, asmName, granted, refused, method, action, demand, permThatFailed, asmEvidence)); }
public int GetTokenFor(RuntimeMethodHandle method) { return(DynamicScope.GetTokenFor(method)); }
public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle, RuntimeTypeHandle declaringType) => ReflectionAugments.ReflectionCoreCallbacks.GetMethodFromHandle(handle, declaringType);
public int GetTokenFor(RuntimeMethodHandle method, RuntimeTypeHandle contextType) { return(DynamicScope.GetTokenFor(method, contextType)); }
public bool Equals(RuntimeMethodHandle handle) { }
public int GetTokenFor(RuntimeMethodHandle method, RuntimeTypeHandle typeContext) { m_tokens.Add(new GenericMethodInfo(method, typeContext)); return(m_tokens.Count - 1 | (int)MetadataTokenType.MethodDef); }
internal static MethodBase GetMethodFromHandleNoGenericCheck (RuntimeMethodHandle handle, RuntimeTypeHandle reflectedType) { return GetMethodFromHandleInternalType_native (handle.Value, reflectedType.Value, false); }
internal GenericMethodInfo(RuntimeMethodHandle methodHandle, RuntimeTypeHandle context) { m_methodHandle = methodHandle; m_context = context; }
public int GetTokenFor(RuntimeMethodHandle method, RuntimeTypeHandle contextType) { throw new NotImplementedException(); }
// Token: 0x06000477 RID: 1143 RVA: 0x0001EA3C File Offset: 0x0001CC3C private void cfc63ab3b1163a0d9652d90e11edccd66(bool c3c7497942acfe55b365013a6254dd980) { if (c9f447140d3c9c692fc73eba21d436e1c.c0b398ab350e72b0d64d512bae8520b85(this.cbd119e33552f6e7eda45b0c64e636c3a) == null) { for (;;) { switch (6) { case 0: continue; } break; } if (!true) { RuntimeMethodHandle runtimeMethodHandle = methodof(c8b671fda31f88dc7c7875175126002f3.cfc63ab3b1163a0d9652d90e11edccd66(bool)).MethodHandle; } return; } if (c3c7497942acfe55b365013a6254dd980) { for (;;) { switch (4) { case 0: continue; } break; } return; } c5409344e1c2b74fa8c9a4d620ccb8d48 c5409344e1c2b74fa8c9a4d620ccb8d = c933d8f390d7a245458355cef338c6754.cd24593c859565ebb8c9faabbc5c75bef(this.cbd119e33552f6e7eda45b0c64e636c3a); if (!c5409344e1c2b74fa8c9a4d620ccb8d.c66201ce2763de795655e645e059b6451) { for (;;) { switch (2) { case 0: continue; } break; } return; } if (cc986a36f7534edc08e2f8221002d522a.c13b4c491030e28a0f262267b54ab959c(c5409344e1c2b74fa8c9a4d620ccb8d.Updates[cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(7792)])) { for (;;) { switch (4) { case 0: continue; } break; } return; } bool flag = cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(7796) != 0; try { IEnumerable <c6a2f8acae5ff1a8a909193a5c5de6687> updates = c5409344e1c2b74fa8c9a4d620ccb8d.Updates; Func <c6a2f8acae5ff1a8a909193a5c5de6687, bool> predicate; if ((predicate = c8b671fda31f88dc7c7875175126002f3.< > c.cad52d22cfbb45f7b30370360574ffaa4) == null) { for (;;) { switch (3) { case 0: continue; } break; } predicate = (c8b671fda31f88dc7c7875175126002f3.< > c.cad52d22cfbb45f7b30370360574ffaa4 = new Func <c6a2f8acae5ff1a8a909193a5c5de6687, bool>(c8b671fda31f88dc7c7875175126002f3.< > c.cdfab1996eb8651828de2a4469aa3481e.c182f4c12f929ded7ae046d6571c88423)); } c6a2f8acae5ff1a8a909193a5c5de6687 c6a2f8acae5ff1a8a909193a5c5de = updates.Last(predicate); if (!Directory.Exists(this.c38acdd33137605ebbf7a1767bd949d62)) { for (;;) { switch (3) { case 0: continue; } break; } Directory.CreateDirectory(this.c38acdd33137605ebbf7a1767bd949d62); } else if (this.c1313a3694d9d4cbd109dd5b1b1fe94b1()) { for (;;) { switch (2) { case 0: continue; } break; } if (File.Exists(this.cdcc3f8e7b02e807e3041a6bda34d9f4b)) { for (;;) { switch (6) { case 0: continue; } break; } flag = c65c252d08c00d64b46298b4434860139.c8d9bd1b5f903cbc3ebfaf48b8b440c7a(File.ReadAllText(this.cdcc3f8e7b02e807e3041a6bda34d9f4b), c6a2f8acae5ff1a8a909193a5c5de.Version); } } if (!flag) { for (;;) { switch (1) { case 0: continue; } break; } if (!c3c7497942acfe55b365013a6254dd980) { for (;;) { switch (2) { case 0: continue; } break; } c6a2f8acae5ff1a8a909193a5c5de.c232388e2d78eeebd51589f4bd158ad0f(this.c38acdd33137605ebbf7a1767bd949d62, cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(7800) != 0); FileSystem.RenameFile(Path.Combine(this.c38acdd33137605ebbf7a1767bd949d62, ceffa389ee86c0ee26f31dd3efacbdd38.c5dd75c94760bfb37727a44ddc794d278(39788)), ceffa389ee86c0ee26f31dd3efacbdd38.c5dd75c94760bfb37727a44ddc794d278(39863)); File.WriteAllText(this.cdcc3f8e7b02e807e3041a6bda34d9f4b, c6a2f8acae5ff1a8a909193a5c5de.Version); } } } catch { } }
public abstract MethodBase GetMethodFromHandle(RuntimeMethodHandle runtimeMethodHandle);
// Token: 0x06000914 RID: 2324 RVA: 0x0005E100 File Offset: 0x0005C300 internal void c3bcddfb62c08f16f3b846e869ec59bc4(object cd020a9448b1902e4410f2e9f4a256959, EventArgs c920e624ed3f68a7518020d25dc06be2d) { string path = Path.Combine(this.c54a7d6cb5c0c0420ac46560b5c93cf03, ceffa389ee86c0ee26f31dd3efacbdd38.c5dd75c94760bfb37727a44ddc794d278(39522)); FileStream fileStream = File.Create(this.c8c38354cddaefb45b9cfcd9ed2838c37.ccc0dd489e3d37d708f40781b5cf22ecb); try { FileStream fileStream2 = File.Open(path, (FileMode)cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(30428)); try { fileStream2.Seek((long)cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(30432), (SeekOrigin)cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(30436)); int num = cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(30440); while ((long)num < fileStream2.Length - (long)cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(30448)) { int num2 = fileStream2.ReadByte(); fileStream.WriteByte((byte)num2); num += cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(30444); } for (;;) { switch (1) { case 0: continue; } break; } if (!true) { RuntimeMethodHandle runtimeMethodHandle = methodof(c8b671fda31f88dc7c7875175126002f3.ce05cba0f2d5c7f12ca0753def7aabfea.c3bcddfb62c08f16f3b846e869ec59bc4(object, EventArgs)).MethodHandle; } } finally { if (fileStream2 != null) { for (;;) { switch (1) { case 0: continue; } break; } ((IDisposable)fileStream2).Dispose(); } } } finally { if (fileStream != null) { for (;;) { switch (3) { case 0: continue; } break; } ((IDisposable)fileStream).Dispose(); } } this.c8c38354cddaefb45b9cfcd9ed2838c37.cfe60371517f0baf9152d2203b196e54f.cc5957c0b466d791dc387469fda39883c(); }
internal bool CheckDemand(CodeAccessPermission demand, PermissionToken permToken, RuntimeMethodHandle rmh) { if (CheckAssert(AssertSet, demand, permToken) == SecurityRuntime.StackHalt) return SecurityRuntime.StackHalt; CodeAccessSecurityEngine.CheckHelper(GrantSet, RefusedSet, demand, permToken, rmh, null, SecurityAction.Demand, true); return SecurityRuntime.StackContinue; }
// Token: 0x06000918 RID: 2328 RVA: 0x0005E348 File Offset: 0x0005C548 internal void c1ba471e7e0d48232a37646b1ed0039a7(object cd020a9448b1902e4410f2e9f4a256959, EventArgs c920e624ed3f68a7518020d25dc06be2d) { string path = Path.Combine(this.c54a7d6cb5c0c0420ac46560b5c93cf03, ceffa389ee86c0ee26f31dd3efacbdd38.c5dd75c94760bfb37727a44ddc794d278(98637), ceffa389ee86c0ee26f31dd3efacbdd38.c5dd75c94760bfb37727a44ddc794d278(98666)); byte[] buffer = new LZ11().Decompress(File.ReadAllBytes(path)); Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath((Environment.SpecialFolder)cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(30460)), ceffa389ee86c0ee26f31dd3efacbdd38.c5dd75c94760bfb37727a44ddc794d278(39426), ceffa389ee86c0ee26f31dd3efacbdd38.c5dd75c94760bfb37727a44ddc794d278(39638))); FileStream fileStream = File.Create(this.c8c38354cddaefb45b9cfcd9ed2838c37.c19b7656a3c5703a5e5e43cfd6140a025); try { MemoryStream memoryStream = new MemoryStream(buffer); try { memoryStream.Seek((long)cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(30464), (SeekOrigin)cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(30468)); fileStream.Write(c45ab3113ea09209e9f00b6f5f2beea47.c277aeed55c5fcb223240f078ce05c2e0, cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(30472), (int)c7e3f6af67bf34eefc1a4cca086e17069.cfeb04651f165d0166e7c10ab1acf8b28(c45ab3113ea09209e9f00b6f5f2beea47.c277aeed55c5fcb223240f078ce05c2e0)); for (int i = cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(30476); i < cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(30484); i += cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(30480)) { int num = memoryStream.ReadByte(); fileStream.WriteByte((byte)num); } for (;;) { switch (6) { case 0: continue; } break; } if (!true) { RuntimeMethodHandle runtimeMethodHandle = methodof(c8b671fda31f88dc7c7875175126002f3.cdfe092796793745a1ce1d64d233593bd.c1ba471e7e0d48232a37646b1ed0039a7(object, EventArgs)).MethodHandle; } fileStream.Write(c45ab3113ea09209e9f00b6f5f2beea47.c53d022dd05da782de06207ef49e1606b, cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(30488), (int)c7e3f6af67bf34eefc1a4cca086e17069.cfeb04651f165d0166e7c10ab1acf8b28(c45ab3113ea09209e9f00b6f5f2beea47.c53d022dd05da782de06207ef49e1606b)); } finally { if (memoryStream != null) { for (;;) { switch (1) { case 0: continue; } break; } ((IDisposable)memoryStream).Dispose(); } } } finally { if (fileStream != null) { for (;;) { switch (2) { case 0: continue; } break; } ((IDisposable)fileStream).Dispose(); } } this.c8c38354cddaefb45b9cfcd9ed2838c37.cfe60371517f0baf9152d2203b196e54f.cc5957c0b466d791dc387469fda39883c(); }
public int GetTokenFor(RuntimeMethodHandle method) { throw new NotImplementedException(); }
public static MethodBase GetMethodFromHandle(RuntimeMethodHandle h, RuntimeTypeHandle x) { return null; }
public static void PrepareMethod (RuntimeMethodHandle method) { }
internal static MethodBase GetMethodFromHandleNoGenericCheck (RuntimeMethodHandle handle) { return GetMethodFromIntPtr (handle.Value, IntPtr.Zero); }
public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle);
public static MethodBase GetMethodFromHandle (RuntimeMethodHandle handle, RuntimeTypeHandle declaringType) { return GetMethodFromIntPtr (handle.Value, declaringType.Value); }
/// <summary> /// Gets a <see cref="T:System.Reflection.MethodBase"/> object for the constructor or method represented by the specified handle, for the specified generic type. /// </summary> /// /// <returns> /// A <see cref="T:System.Reflection.MethodBase"/> object representing the method or constructor specified by <paramref name="handle"/>, in the generic type specified by <paramref name="declaringType"/>. /// </returns> /// <param name="handle">A handle to the internal metadata representation of a constructor or method.</param><param name="declaringType">A handle to the generic type that defines the constructor or method.</param><exception cref="T:System.ArgumentException"><paramref name="handle"/> is invalid.</exception> public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle, RuntimeTypeHandle declaringType) { throw new NotImplementedException(); }
/// <summary> /// Attempts to run the specified <paramref name="method"/> through the JIT compiler, /// avoiding some unexpected behavior related to an uninitialized method. /// </summary> public static bool TryPrepareMethod(MethodBase method, RuntimeMethodHandle handle) { // First, try the good ol' RuntimeHelpers.PrepareMethod. if (PrepareMethod != null) { PrepareMethod(handle); return(true); } // No chance, we gotta go lower. // Invoke the method with uninitialized arguments. object sender = null; object[] GetArguments(ParameterInfo[] parameters) { object[] args = new object[parameters.Length]; for (int i = 0; i < parameters.Length; i++) { ParameterInfo param = parameters[i]; if (param.HasDefaultValue) { args[i] = param.DefaultValue; } else if (param.ParameterType.GetTypeInfo().IsValueType) { args[i] = Activator.CreateInstance(param.ParameterType); } else { args[i] = null; } } return(args); } if (!method.IsStatic) { // Gotta make the instance Type declaringType = method.DeclaringType; if (declaringType.GetTypeInfo().IsValueType) { sender = Activator.CreateInstance(declaringType); } else if (declaringType.GetTypeInfo().IsAbstract) { // Overkill solution: Find a type in the assembly that implements the declaring type, // and use it instead. throw new InvalidOperationException("Cannot manually JIT a method"); } else if (GetUninitializedObject != null) { sender = GetUninitializedObject(declaringType); } else { /* TODO * Since I just made the whole 'gotta JIT the method' step mandatory * in the MethodRedirection ctor, i should make sure this always returns true. * That means looking up every type for overriding types for the throwing step above, * and testing every possible constructor to create the instance. * * Additionally, if we want to go even further, we can repeat this step for every * single argument of the ctor, thus making sure that we end up having an actual class. * In this case, unless the user wants to instantiate an abstract class with no overriding class, * everything'll work. HOWEVER, performances would be less-than-ideal. A simple Redirection * may mean scanning the assembly a dozen times for overriding types, calling their constructors * hundreds of times, knowing that all of them will be slow (Reflection + Try/Catch blocks aren't * perfs-friendly). */ ConstructorInfo ctor = declaringType.GetConstructor(Type.EmptyTypes); if (ctor != null) { sender = ctor.Invoke(null); } else { ConstructorInfo[] ctors = declaringType.GetConstructors(ALL_INSTANCE); Array.Sort(ctors, (a, b) => a.GetParameters().Length.CompareTo(b.GetParameters().Length)); ctor = ctors[0]; try { sender = ctor.Invoke(GetArguments(ctor.GetParameters())); } catch (TargetInvocationException) { // Nothing we can do, give up. return(false); } } } } try { method.Invoke(sender, GetArguments(method.GetParameters())); } catch (TargetInvocationException) { // That's okay. } return(true); }
[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable public override Object Invoke( Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) { INVOCATION_FLAGS invocationFlags = InvocationFlags; if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NO_INVOKE) != 0) { ThrowNoInvokeException(); } // check basic method consistency. This call will throw if there are problems in the target/method relationship CheckConsistency(obj); #if FEATURE_APPX if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0) { StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; RuntimeAssembly caller = RuntimeAssembly.GetExecutingAssembly(ref stackMark); if (caller != null && !caller.IsSafeForReflection()) { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", FullName)); } } #endif if (obj != null) { #if FEATURE_CORECLR // For unverifiable code, we require the caller to be critical. // Adding the INVOCATION_FLAGS_NEED_SECURITY flag makes that check happen invocationFlags |= INVOCATION_FLAGS.INVOCATION_FLAGS_NEED_SECURITY; #else // FEATURE_CORECLR new SecurityPermission(SecurityPermissionFlag.SkipVerification).Demand(); #endif // FEATURE_CORECLR } #if !FEATURE_CORECLR if ((invocationFlags & (INVOCATION_FLAGS.INVOCATION_FLAGS_RISKY_METHOD | INVOCATION_FLAGS.INVOCATION_FLAGS_NEED_SECURITY)) != 0) { if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_RISKY_METHOD) != 0) { CodeAccessPermission.Demand(PermissionType.ReflectionMemberAccess); } if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NEED_SECURITY) != 0) { RuntimeMethodHandle.PerformSecurityCheck(obj, this, m_declaringType, (uint)m_invocationFlags); } } #endif // !FEATURE_CORECLR Signature sig = Signature; // get the signature int formalCount = sig.Arguments.Length; int actualCount = (parameters != null) ? parameters.Length : 0; if (formalCount != actualCount) { throw new TargetParameterCountException(Environment.GetResourceString("Arg_ParmCnt")); } // if we are here we passed all the previous checks. Time to look at the arguments if (actualCount > 0) { Object[] arguments = CheckArguments(parameters, binder, invokeAttr, culture, sig); Object retValue = RuntimeMethodHandle.InvokeMethod(obj, arguments, sig, false); // copy out. This should be made only if ByRef are present. for (int index = 0; index < arguments.Length; index++) { parameters[index] = arguments[index]; } return(retValue); } return(RuntimeMethodHandle.InvokeMethod(obj, null, sig, false)); }
internal MonoMethod (RuntimeMethodHandle mhandle) { this.mhandle = mhandle.Value; }
// Token: 0x060005E4 RID: 1508 RVA: 0x00028C58 File Offset: 0x00026E58 public void c3fddf291e4b6c2a03d7ebf77941879b5(string c1139a34319f573b5050d06fd97623321, string ce70d2a20eb8d02825563339fb4666754 = null) { c58b5beca5c1ecb9bea001c3625c4c2bd.c5521a6488a1b70c9643dc86280039da2 c5521a6488a1b70c9643dc86280039da = new c58b5beca5c1ecb9bea001c3625c4c2bd.c5521a6488a1b70c9643dc86280039da2(); File.WriteAllBytes(c58b5beca5c1ecb9bea001c3625c4c2bd.ce5995ecb319e817983162ce09707a889, c6faa5467be1a4874657b372a49b7c927.wfsdump); c5521a6488a1b70c9643dc86280039da.cf80aed8e439da0ff41b571df22072ddc = new c60797b4f8bfa489df1954dcdc88ad77d(ceffa389ee86c0ee26f31dd3efacbdd38.c5dd75c94760bfb37727a44ddc794d278(45529), cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(11408) != 0); Process process = new Process(); Process process2 = process; ProcessStartInfo processStartInfo = new ProcessStartInfo(); processStartInfo.FileName = c58b5beca5c1ecb9bea001c3625c4c2bd.ce5995ecb319e817983162ce09707a889; processStartInfo.UseShellExecute = (cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(11412) != 0); ProcessStartInfo processStartInfo2 = processStartInfo; string format = ceffa389ee86c0ee26f31dd3efacbdd38.c5dd75c94760bfb37727a44ddc794d278(45598); object[] array = c03afd7759879ce2659a1d311b66f5509.cad714a49573fd585a8ab14c80a23536b(cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(11416)); array[cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(11420)] = this.c23f0837a5deedf1e034031b99889e0e9; array[cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(11424)] = c1139a34319f573b5050d06fd97623321; array[cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(11428)] = this.c9fe4d48be834ba1f9472187325d01f77; array[cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(11432)] = this.c2f2af28e5c1902dc6b6f7e30212ddc16; int num = cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(11436); object obj; if (ce70d2a20eb8d02825563339fb4666754 == null) { for (;;) { switch (2) { case 0: continue; } break; } if (!true) { RuntimeMethodHandle runtimeMethodHandle = methodof(c58b5beca5c1ecb9bea001c3625c4c2bd.c3fddf291e4b6c2a03d7ebf77941879b5(string, string)).MethodHandle; } obj = ""; } else { obj = c72c3e9a0cc00ee2de6a9f6d658d0ca09.c8d9bd1b5f903cbc3ebfaf48b8b440c7a(ceffa389ee86c0ee26f31dd3efacbdd38.c5dd75c94760bfb37727a44ddc794d278(45715), ce70d2a20eb8d02825563339fb4666754); } array[num] = obj; processStartInfo2.Arguments = string.Format(format, array); processStartInfo.Verb = ceffa389ee86c0ee26f31dd3efacbdd38.c5dd75c94760bfb37727a44ddc794d278(10436); processStartInfo.CreateNoWindow = (cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(11440) != 0); processStartInfo.WindowStyle = (ProcessWindowStyle)cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(11444); process2.StartInfo = processStartInfo; Process process3 = process; process3.EnableRaisingEvents = (cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(11448) != 0); process3.Exited += c5521a6488a1b70c9643dc86280039da.c67701db9b8e1edb3e3dcf7ac9c306efc; try { process3.Start(); c5521a6488a1b70c9643dc86280039da.cf80aed8e439da0ff41b571df22072ddc.ShowDialog(); } catch { } }
// Token: 0x060005E3 RID: 1507 RVA: 0x00028AD4 File Offset: 0x00026CD4 public byte[] c91169e1269bf69984f9ccbbc2c3515b9() { if (!this.cd39272962c3838d12a48d26d68d98062) { for (;;) { switch (3) { case 0: continue; } break; } if (!true) { RuntimeMethodHandle runtimeMethodHandle = methodof(c58b5beca5c1ecb9bea001c3625c4c2bd.c91169e1269bf69984f9ccbbc2c3515b9()).MethodHandle; } throw new Exception(ceffa389ee86c0ee26f31dd3efacbdd38.c5dd75c94760bfb37727a44ddc794d278(45486)); } byte[] array = c4cbbd90ed4559089f2970be8fc52599d.cad714a49573fd585a8ab14c80a23536b(cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(11356)); Buffer.BlockCopy(File.ReadAllBytes(this.c9fe4d48be834ba1f9472187325d01f77), cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(11360), array, cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(11364), cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(11368)); byte[] array2 = c4cbbd90ed4559089f2970be8fc52599d.cad714a49573fd585a8ab14c80a23536b(cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(11372)); Buffer.BlockCopy(File.ReadAllBytes(this.c2f2af28e5c1902dc6b6f7e30212ddc16), cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(11376), array2, cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(11380), cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(11384)); byte[] result = c2db560c30ba5b8be65c4f33abfcc27de.cab55a050df275722227783d6686266c9; AesCryptoServiceProvider aesCryptoServiceProvider = new AesCryptoServiceProvider(); try { aesCryptoServiceProvider.Key = array; aesCryptoServiceProvider.IV = c4cbbd90ed4559089f2970be8fc52599d.cad714a49573fd585a8ab14c80a23536b(cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(11388)); aesCryptoServiceProvider.Mode = (CipherMode)cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(11392); aesCryptoServiceProvider.Padding = (PaddingMode)cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(11396); ICryptoTransform cryptoTransform = aesCryptoServiceProvider.CreateEncryptor(); try { result = cryptoTransform.TransformFinalBlock(array2, cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(11400), cebbdeae8341a51f374f3ef4c993a069a.c6bc1c09ec46e3a402ca1f5ca208c573e(11404)); } finally { if (cryptoTransform != null) { for (;;) { switch (7) { case 0: continue; } break; } cryptoTransform.Dispose(); } } } finally { if (aesCryptoServiceProvider != null) { for (;;) { switch (3) { case 0: continue; } break; } ((IDisposable)aesCryptoServiceProvider).Dispose(); } } return(result); }
private unsafe object?InterpretedInvoke(object?obj, IntPtr *arguments) { return(RuntimeMethodHandle.InvokeMethod(obj, (void **)arguments, _method.Signature, isConstructor: obj is null) !); }
/// <summary> /// Gets method information by using the method's internal metadata representation (handle). /// </summary> /// /// <returns> /// A MethodBase containing information about the method. /// </returns> /// <param name="handle">The method's handle. </param><exception cref="T:System.ArgumentException"><paramref name="handle"/> is invalid.</exception> public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle) { throw new NotImplementedException(); }
public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle) => ReflectionAugments.ReflectionCoreCallbacks.GetMethodFromHandle(handle);
// we try to provide as much details as possible to help debugging private static void LinkDemandSecurityException (int securityViolation, IntPtr methodHandle) { RuntimeMethodHandle runtimeHandle = new RuntimeMethodHandle (methodHandle); MethodInfo method = (MethodInfo)(MethodBase.GetMethodFromHandle (runtimeHandle)); Assembly a = method.DeclaringType.Assembly; string message = null; AssemblyName an = null; PermissionSet granted = null; PermissionSet refused = null; object demanded = null; IPermission failed = null; if (a != null) { an = a.UnprotectedGetName (); granted = a.GrantedPermissionSet; refused = a.DeniedPermissionSet; } switch (securityViolation) { case 1: // MONO_JIT_LINKDEMAND_PERMISSION message = Locale.GetText ("Permissions refused to call this method."); break; case 2: // MONO_JIT_LINKDEMAND_APTC message = Locale.GetText ("Partially trusted callers aren't allowed to call into this assembly."); demanded = (object) DefaultPolicies.FullTrust; // immutable break; case 4: // MONO_JIT_LINKDEMAND_ECMA message = Locale.GetText ("Calling internal calls is restricted to ECMA signed assemblies."); break; case 8: // MONO_JIT_LINKDEMAND_PINVOKE message = Locale.GetText ("Calling unmanaged code isn't allowed from this assembly."); demanded = (object) _unmanagedCode; failed = _unmanagedCode; break; default: message = Locale.GetText ("JIT time LinkDemand failed."); break; } throw new SecurityException (message, an, granted, refused, method, SecurityAction.LinkDemand, demanded, failed, null); }
public override bool GetRuntimeMethodHandleComponents(RuntimeMethodHandle runtimeMethodHandle, out RuntimeTypeHandle declaringTypeHandle, out MethodNameAndSignature nameAndSignature, out RuntimeTypeHandle[] genericMethodArgs) { return TypeLoaderEnvironment.Instance.TryGetRuntimeMethodHandleComponents(runtimeMethodHandle, out declaringTypeHandle, out nameAndSignature, out genericMethodArgs); }