Beispiel #1
0
				{
					if (profileeThread.ThreadState == System.Threading.ThreadState.Running || profileeThread.ThreadState == System.Threading.ThreadState.WaitSleepJoin)
					{
						try
						{
							profileeThread.Suspend();
						}
						catch { }
					}
				}

			}		
		}

		private void Configurator_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			if(configString=="READONLY")
			{
				return;
			}

			this.Enabled=false;
			Application.DoEvents(); 
			if(profileeThread!=null)
			{
				try
				{
					profileeThread.Resume(); 
				}
				catch{}
				try
				{
					profileeThread.Abort(); 					
				}
				catch{}
			}

			if(delegatorObj!=null)
			{
				System.Runtime.InteropServices.Marshal.ReleaseComObject(delegatorObj);						
			}

			delegatorObj =null;				
			//if(!IsDesktopApp)
			{
				if(defaultAttach.Checked)
				{
					SuspendKey=true;
					AutoAttach=true;

					try
					{
						if(functionDataObj!=null)
						{
							g_FunctionFlag=functionDataObj.m_iFunctionFlag;  
							g_ObjectFlag=0;
						}
						else if(objectDataObj!=null)
						{
							g_ObjectFlag=objectDataObj.m_iObjectsFlag;
							g_FunctionFlag=0;
						}
					}
					catch(Exception ex)
					{
						MessageBox.Show(ex.Message,"Error!",MessageBoxButtons.OK,MessageBoxIcon.Error);
						RestoreDefaultConfiguration();
					}					
					//Suspend and carry on with the settings									
				}
Beispiel #2
0
		private void ChangeLabelColor()
		{
			for (int i=0;i<5;i++)
			{
				label5.ForeColor=Color.Red;				 
				Application.DoEvents();
				System.Threading.Thread.Sleep(500);
				label5.ForeColor= Color.FromKnownColor(System.Drawing.KnownColor.HotTrack);				
				Application.DoEvents();		
				System.Threading.Thread.Sleep(500);
			}
		}

		private void selectNewTab()
		{
			if (tabConfig.SelectedTab == profileeTab)
			{
				acceptSettings.Text = "Accept";
				try
				{
					profileeView.Focus();
				}
				catch { }
				try
				{
					if(IsDesktopApp==false && label5.Visible==true && label5.ForeColor==Color.Red)
					{
						System.Threading.Thread threadColor=new System.Threading.Thread(new System.Threading.ThreadStart(ChangeLabelColor));
						threadColor.Start(); 
					}
				}catch{}
				Application.DoEvents();

				//Very important to profile a process from suspended state when object allocation profiling is active
				if (configString == "MEMORY_ANALYSIS" && IsDesktopApp == false)
				{
					if (objRuntimeObjectAllocation.Checked)
					{
						radioProfileeSuspended.Checked = true;
						profileeAlreadyRunning.Checked = false;
						profileeAlreadyRunning.Enabled = false;
					}
					else
					{
						profileeAlreadyRunning.Checked = true;
						profileeAlreadyRunning.Enabled = true;
						radioProfileeSuspended.Checked = false;
					}
					Application.DoEvents();
				}

				try
				{
					AcceptData();//V. Imp.
				}
				catch { }

				if (profileeThread == null)
				{
					if (IsDesktopApp == false)//IsDesktopApp is Only Required here
					{
						#region Spawn the thread

						this.Cursor = Cursors.WaitCursor;
						Application.DoEvents();
						try
						{
							if (System.Security.Principal.WindowsIdentity.GetCurrent().IsSystem)
							{
								throw new COMException(null, -2147023838);
							}

							if (delegatorObj == null)
							{
								delegatorObj = new SharpDelegatorClass();
								try
								{
									delegatorObj.profilerName = Application.StartupPath + @"\SoftProdigy.Core.dll";
								}
								catch (COMException _com_exc)
								{
									if (_com_exc.ErrorCode != -2147023649)
									{
										throw new COMException(_com_exc.Message, _com_exc.ErrorCode);
									}
								}
							}
						}
						catch (Exception exc)
						{
							int hr = System.Runtime.InteropServices.Marshal.GetHRForException(exc);
							if (hr == -2147023838 || hr == -2147221164)//SERVICE NOT AVAILABLE
							{
								SharpClientForm.scInstance.psStatusBar.Panels[0].Text = @"Profiling will be available only for desktop applications started by the profiler";
							}
							else
							{
								MessageBox.Show("Error initializing profiler settings.\n" + exc.Message, "Exception!", MessageBoxButtons.OK, MessageBoxIcon.Error);
							}
							this.Cursor = Cursors.Arrow;
							profileeView.Enabled = false;
							groupBox10.Enabled = true;
							radioProfileeSuspended.Enabled = false;
							profileeAlreadyRunning.Enabled = false;
							return;
						}

					Z: profileeThread = new System.Threading.Thread(new System.Threading.ThreadStart(RefreshProcessView));
						//profileeThread.ApartmentState =System.Threading.ApartmentState.MTA;   
						profileeView.Enabled = false;
						groupBox10.Enabled = false;
						profileeThread.Start();
						#endregion
					}
				}
				else
				{
					groupBox10.Enabled = true;
					if (profileeThread != null)
					{
						if ((profileeView.Visible == true) && (profileeThread.ThreadState == System.Threading.ThreadState.Suspended || (int)profileeThread.ThreadState == 96))   //96 is WaitSleepjoin and SuspendRequested
						{
							try
							{
								profileeThread.Resume();
							}
							catch { }
						}
					}

				}

			}
			else
			{
				acceptSettings.Text = "Next>>";