Ejemplo n.º 1
0
		public void VisitCall(Call call)
		{				
			if (call.Target.ToString().Contains("System.Environment::Exit("))
			{
				Reporter.MethodFailed(m_method, CheckID, call.Untyped.Offset, string.Empty);
			}
		}
Ejemplo n.º 2
0
		public void VisitCall(Call call)
		{				
			if (call.Target.ToString().Contains("System.Windows.Forms.Application::Exit("))
			{
				Reporter.MethodFailed(m_method, CheckID, call.Untyped.Offset, string.Empty);
			}
		}
Ejemplo n.º 3
0
		public void VisitCall(Call call)
		{
			if (m_offset < 0)
			{				
				if (DoMatchProperty(call.Target))
				{
					DoCheck(call, call.Target, 0);
				}
				else if (DoMatchMethod(call.Target))
				{
					MethodDefinition method = DoFindMethod(call.Target);
					if (method != null)
					{
						Log.DebugLine(this, "found method call at {0:X2}", call.Untyped.Offset);				
						for (int i = 0; i < method.Parameters.Count && m_offset < 0; ++i)
						{
							ParameterDefinition p = method.Parameters[i];
							Log.DebugLine(this, "checking parameter{0}: {1}", i, p.Name);				
							if (DoIsValidArg(p))
							{
								Log.DebugLine(this, "found parameter at {0}", i);				
								int nth = method.Parameters.Count - i - 1;		
								DoCheck(call, call.Target, nth);
							}
						}
					}
				}
			}
		}
Ejemplo n.º 4
0
		public void VisitCall(Call call)
		{
			if (m_offset < 0)
			{
				if (call.Target.ToString().Contains("::Equals(") && call.Target.Parameters.Count == 1)
				{
					TypeReference t1 = DoGetType(call.Index, 0);
					TypeReference t2 = DoGetType(call.Index, 1);
		
					if (t1 != null && t2 != null)
					{	
						if (t1.FullName != "System.Object" && t2.FullName != "System.Object")
						{
							if (!t1.IsSubclassOf(t2, Cache) && !t2.IsSubclassOf(t1, Cache) && t1.FullName != t2.FullName)
							{
								TypeDefinition td1 = Cache.FindType(t1);
								TypeDefinition td2 = Cache.FindType(t2);
								
								if (td1 == null || !td1.TypeOrBaseImplements(t2.FullName, Cache))
								{
									if (td2 == null || !td2.TypeOrBaseImplements(t1.FullName, Cache))
									{					
										m_offset = call.Untyped.Offset;						
										Log.DebugLine(this, "Matched at {0:X2}", m_offset);				
									}
								}
							}
						}
					}
				}
			}
		}
		public void VisitCall(Call call)
		{				
			if (call.Target.ToString().Contains("System.GC::ReRegisterForFinalize("))
			{
				Reporter.MethodFailed(m_method, CheckID, call.Untyped.Offset, string.Empty);
			}
		}
Ejemplo n.º 6
0
		// ldarg.0  this
        // ldfld    System.String Smokey.Tests.WeakIdentityLockTest/Cases::m_string
        // stloc.0  V_0
        // ldloc.0  V_0
        // call     System.Void System.Threading.Monitor::Enter(System.Object)
        //
		// ldarg.0  this
        // ldfld    System.String Smokey.Tests.WeakIdentityLockTest/Cases::m_string
        // call     System.Void System.Threading.Monitor::Enter(System.Object)
		public void VisitCall(Call call)
		{
			if (m_offset < 0)
			{
				string name = call.Target.ToString();
				if (name.Contains("System.Threading.Monitor::Enter(System.Object)"))
				{
					Log.DebugLine(this, "found lock at {0:X2}", call.Untyped.Offset);
					
					int index = call.Index - 1;
					if (DoStoresLocal(index))
						index -= 2;
						
					FieldReference field = DoGetField(index);
					if (field != null)
					{
						if (Array.IndexOf(m_badTypes, field.FieldType.FullName) >= 0)
						{
							m_offset = call.Untyped.Offset;
							m_details = "Field: " + field.Name;
							Log.DebugLine(this, "lock on weak identity at: {0:X2}", m_offset);
						}
					}
				}
			}
		}
Ejemplo n.º 7
0
		public void VisitCall(Call call)
		{			
			if (call.Target.ToString().StartsWith("System.Void System.Threading.Thread::set_Name("))
			{
				Log.DebugLine(this, "   found set at: {0:X2}", call.Untyped.Offset);
				++m_setCount;
			}
		}
Ejemplo n.º 8
0
		public void VisitCall(Call call)
		{
			if (call.Target.ToString().Contains("System.Windows.Forms.MessageBox::Show"))
			{
				if (!call.ToString().Contains("System.Windows.Forms.MessageBoxOptions"))
				{
					Reporter.MethodFailed(m_method, CheckID, call.Untyped.Offset, string.Empty);
				}
			}
		}
Ejemplo n.º 9
0
		public void VisitCall(Call call)
		{
			if (m_offset < 0)
			{
				if (call.Target.ToString().Contains("System.String::ToString"))
				{
					m_offset = call.Untyped.Offset;
					Log.DebugLine(this, "found string ToString at {0:X2}", m_offset);				
				}
			}
		}
Ejemplo n.º 10
0
		public void VisitCall(Call call)
		{
			if (m_needsCheck && m_offset < 0)
			{
				if (call.Target.ToString() == m_info.Method.ToString())
				{
					m_offset = call.Untyped.Offset;						
					Log.DebugLine(this, "recursive at {0:X2}", m_offset);				
				}
			}
		}
Ejemplo n.º 11
0
		public void VisitCall(Call call)
		{
			if (m_entry != null && !m_entry.CallsUri)
			{
				if (call.Target == m_entry.Uri)
				{
					Log.DebugLine(this, "   call to uri method at {0:X2}", call.Untyped.Offset);											
					m_entry.CallsUri = true;
				}
			}
		}
Ejemplo n.º 12
0
		public void VisitCall(Call call)
		{
			if (m_offset < 0 && m_dispatcher.Looping)
			{
				if (call.Target.ToString().Contains("System.String::Concat("))
				{
					m_offset = call.Untyped.Offset;
					Log.DebugLine(this, "found concat at {0:X2}", m_offset);				
				}
			}
		}
Ejemplo n.º 13
0
		public void VisitCall(Call call)
		{
			if (m_offset < 0)
			{
				if (call.Target.ToString() == "System.Boolean System.WeakReference::get_IsAlive()")
				{
					m_offset = call.Untyped.Offset;						
					Log.DebugLine(this, "IsAlive at {0:X2}", m_offset);											
				}
			}
		}
Ejemplo n.º 14
0
		public void VisitCall(Call call)
		{
			if (m_offset < 0)
			{
				if (m_info.Method.MetadataToken == call.Target.MetadataToken)
				{
					m_offset = call.Untyped.Offset;
					Log.DebugLine(this, "found recursive call at {0}", m_offset);
				}
			}
		}
Ejemplo n.º 15
0
		public void VisitCall(Call call)
		{
			if (m_offset < 0)
			{
				if (call.Target.ToString().Contains("System.Void System.Security.CodeAccessPermission::Deny"))
					m_offset = call.Untyped.Offset;

				else if (call.Target.ToString().Contains("System.Void System.Security.CodeAccessPermission::PermitOnly"))
					m_offset = call.Untyped.Offset;
			}
		}
Ejemplo n.º 16
0
		public void VisitCall(Call call)
		{
			if (!m_foundLocale)
			{
				if (call.Target.ToString().Contains("System.Data.DataSet::set_Locale"))
					m_foundLocale = true;

				else if (call.Target.ToString().Contains("System.Data.DataTable::set_Locale"))
					m_foundLocale = true;
			}
		}
Ejemplo n.º 17
0
		public void VisitCall(Call call)
		{
			if (m_offset < 0 && m_needsCheck)
			{
				string name = call.Target.ToString();
				if (name.Contains("System.ValueType::GetHashCode()"))
				{	
					m_offset = call.Untyped.Offset;
					Log.DebugLine(this, "ValueType::GetHashCode call at {0:X2}", m_offset);	
				}
			}
		}
Ejemplo n.º 18
0
		public void VisitCall(Call call)
		{
			if (m_wasStatic && !m_hasLock)
			{
				string name = call.Target.ToString();
				if (name.Contains("System.Threading.Monitor::Enter(System.Object)"))
				{
					Log.DebugLine(this, "found lock at {0:X2}", call.Untyped.Offset);
					m_hasLock = true;
				}
			}
		}
Ejemplo n.º 19
0
		public void VisitCall(Call call)
		{
			if (m_offset < 0)
			{
				if (call.Target.Parameters.Count == 2)
					if (call.Target.ToString().IndexOf("System.Math::Min(") >= 0 ||
						call.Target.ToString().IndexOf("System.Math::Max(") >= 0 ||
						call.Target.ToString().IndexOf("System.Object::Equals(") >= 0 ||
						call.Target.ToString().IndexOf("System.Object::ReferenceEquals(") >= 0)
						DoCheck(call);
			}
		}
Ejemplo n.º 20
0
		public void VisitCall(Call call)
		{				
			if (call.Target.ToString().Contains("System.Windows.Forms.Application::Run("))
			{
				m_callsRun = true;
			}
			else if (call.Target.ToString().Contains("System.Environment::Exit("))
			{
				m_callsExit = true;
				m_details += m_method + " ";
			}
		}
Ejemplo n.º 21
0
		public void VisitCall(Call call)
		{
			if (m_offset < 0)
			{
				string name = call.Target.ToString();
				
				if (name == "System.Boolean System.Double::Equals(System.Double)" || name == "System.Boolean System.Single::Equals(System.Single)")
				{
					m_offset = call.Untyped.Offset;
					Log.DebugLine(this, "found equals at {0:X2}", m_offset);
				}
			}
		}
Ejemplo n.º 22
0
		public void VisitCall(Call call)
		{
			if (m_needsCheck && m_missingBaseCall)
			{
				Log.DebugLine(this, "checking {0}", call.Target);	
				
				string name = m_type.BaseType.Name;
				name += "::.ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)";
				
				if (call.Target.ToString().Contains(name))
					m_missingBaseCall = false;
			}
		}
Ejemplo n.º 23
0
		public void VisitCall(Call call)
		{	
			if (m_needsCheck && m_offset < 0)
			{
				string name = call.Target.ToString();
			
				if (name.Contains("System.Console::Write(") || name.Contains("System.Console::WriteLine("))
				{
					m_offset = call.Untyped.Offset;
					Log.DebugLine(this, "found call at {0:X2}", m_offset);
				}
			}
		}
Ejemplo n.º 24
0
		public void VisitCall(Call call)
		{				
			if (m_needsCheck)
			{
				if (call.Target.DeclaringType.MetadataToken == m_type.MetadataToken)
				{
					if (m_virtuals.IndexOf(call.Target.MetadataToken) >= 0)
					{
						Log.DebugLine(this, "found a self virtual at {0:X2}", call.Untyped.Offset);	
						m_numVirtuals += 1.0f;
					}
				}
			}
		}
Ejemplo n.º 25
0
		public void VisitCall(Call call)
		{
			if (m_needsCheck && !m_failed)
			{
				if (call.Target.Name == "Assert" && call.Target.Parameters.Count == 0)
				{					
					TypeReference type = call.Target.GetDeclaredIn(Cache);
					if (type != null && type.FullName == "System.Security.IStackWalk")
					{
						m_failed = true;
					}
				}
			}
		}
Ejemplo n.º 26
0
		public void VisitCall(Call call)
		{
			if (m_offset < 0 && call.Index > 0)
			{
				if (call.Target.ToString() == "System.Void System.Environment::Exit(System.Int32)")
				{					
					DoCheckLoad(call);
				}
				else if (call.Target.ToString() == "System.Void System.Environment::set_ExitCode(System.Int32)")
				{					
					DoCheckLoad(call);
				}
			}
		}
Ejemplo n.º 27
0
		public void VisitCall(Call call)
		{
			if (m_offset < 0)
			{
				if (call.Target.ToString() == "System.Void System.GC::Collect()")
				{	
					m_offset = call.Untyped.Offset;
				}
				else if (call.Target.ToString() == "System.Void System.GC::Collect(System.Int32)")
				{	
					m_offset = call.Untyped.Offset;
				}
			}
		}
Ejemplo n.º 28
0
		public void VisitCall(Call call)
		{
			if (m_offset < 0)
			{
				if (call.Target.ToString() == "System.Void System.Threading.Thread::Abort()")
				{	
					m_offset = call.Untyped.Offset;
				}
				else if (call.Target.ToString() == "System.Void System.Threading.Thread::Abort(System.Object)")
				{	
					m_offset = call.Untyped.Offset;
				}
			}
		}
Ejemplo n.º 29
0
		public void VisitCall(Call call)
		{
			if (m_offset < 0)
			{
				if (call.Target.ToString().StartsWith("System.Boolean System.Threading.Monitor::Wait(System.Object,"))
				{
					if (!DoFindBranch(call.Index + 1))
					{
						m_offset = call.Untyped.Offset;
						Log.DebugLine(this, "   missing backward branch at {0:X2}", m_offset);
					}
				}
			}
		}
Ejemplo n.º 30
0
		// ldloc.0  V_0
        // call     System.Void System.Threading.Monitor::Enter(System.Object)
		public void VisitCall(Call call)
		{
			if (m_needsCheck && m_offset < 0)
			{
				if (call.Target.ToString() == "System.Void System.Threading.Monitor::Enter(System.Object)")
				{
					LoadLocal local = m_info.Instructions[call.Index - 1] as LoadLocal;
					if (local != null && m_thisLocals.IndexOf(local.Variable) >= 0)
					{
						m_offset = call.Untyped.Offset;
						Log.DebugLine(this, "found lock(this) at {0:X2}", m_offset);
					}
				}
			}
		}