Example #1
0
VOID EnumProcess()
{
  ULONG  uSystemAddress = (ULONG)pSystem;
  ULONG  i;
  ULONG  Address;
  ULONG  ret;

  DbgPrint("-------------------------------------------");
  DbgPrint("EProcess    PID    ImageFileName");
  DbgPrint("---------------------------------");
  
  
  for(i = 0x80000000; i < uSystemAddress; i += 4){//system进程的EPROCESS地址就是最大值了
    ret = VALIDpage(i); 
    if (ret == VALID){ 
      Address = *(PULONG)i;
      if (( Address & 0xFFFF0000) == pebAddress){//每个进程的PEB地址都是在差不多的地方,地址前半部分是相同的       
        if(IsaRealProcess(i)){ 
          ShowProcess(i - PEB_OFFSET);  
           i += EPROCESS_SIZE;                
        } 
      } 
    }else if(ret == PTE_INVALID){ 
      i -=4; 
      i += 0x1000;//4k 
    }else{ 
      i-=4; 
      i+= 0x400000;//4mb 
    } 
  }

  ShowProcess(uSystemAddress);//system的PEB总是零 上面的方法是枚举不到的 不过我们用PsGetCurrentProcess就能得到了
  DbgPrint("-------------------------------------------");
  
}
Example #2
0
int MyHideWindows()
{
	NOTIFYICONDATA nid;
	if (bHideWindows == 1)
	{
		if (sOP.bDisableSound == 1)
		{
			CVolumeOutMaster OM;
			dwOldVolume = OM.GetCurrentVolume();
			OM.SetCurrentVolume(0);
			
			CVolumeOutWave OW;
			dwOldWave = OW.GetCurrentVolume();
			OW.SetCurrentVolume(0);



			//waveOutGetVolume(0,&dwOldVolume);
			//waveOutSetVolume(0,0);
		}
		EnableWindow(hAll,FALSE);
		EnableWindow(hLV,FALSE);


		for(int i1 = 0;i1<iBaSW_dll;i1++)
		{
			if(sW_dll[i1].bReserved != sOP.bReserveSel)
			{
				//ShowWindow(sW_dll[i1].hWnd,SW_HIDE);
				if(sOP.bHideProcess == 1)
				{
					HideProcess(sW_dll[i1].lPID);
				}
				sW_dll[i1].bHide = 1;


				sW_dll[i1].iLink = i1; // Use this member save thread handle index

				g_arrayHide[i1] = (HANDLE)_beginthreadex(NULL,0,HideWindowProc,
					sW_dll + i1,0,NULL);
			
			}
		}

		HANDLE hMonitorHandle = (HANDLE)_beginthreadex(NULL,0,MonitorProc,
			g_arrayHide,0,NULL);
		if(hMonitorHandle == INVALID_HANDLE_VALUE)
		{
			hMonitorHandle = NULL;
		}
		else
		{
			CloseHandle(hMonitorHandle);
		}
		if(sOP.bCleanAfterHide == 1)
		{
			g_pCleanHistory();   
		}
		


		if(sOP.bHideAllTray == 1)
		{
			AllocResourceForTrayList();
			EnumAllVisibleTray_dll();
			HideAllTray();
		}
		dbview(L"enter sOP.bNeedStart == 1........................................");

		
		if(sOP.bNeedStart == 1)
		{
			ShellExecute(NULL,L"open",sOP.cTrailRun,NULL,NULL,SW_SHOWNORMAL);
		}
		
		g_pClearTipText();
		dbview(L"enter sOP.bUseMiddle........................................");
		if(sOP.bUseMiddle)
		{
			g_pAppendTipText(L"IDS_USAGETIP_RECLICKMIDDLESHOWWINDOW",
			L"再按鼠标中键可以重新显示窗口。");
		}
		else if(sOP.bUseMouse)
		{
			g_pAppendTipText(L"IDS_USAGETIP_RECLICKRIGHTLEFTSHOWWINDOW",
			L"再一齐按鼠标左右键可以重新显示窗口。");
		}
		else
		{
			g_pAppendTipText(L"IDS_USAGETIP_REPRESSHOTKEYTOSHOWWINDOW",
			L"再按下 隐藏窗口 快捷键可以重新显示窗口。");
		}

		if(sOP.bUseMiddle)
		{
			g_pSetTipText(L"IDS_USAGETIP_RECLICKMIDDLESHOWWINDOW",
			L"再按鼠标中键可以重新显示窗口。");
		}
		else if(sOP.bUseMouse)
		{
			g_pSetTipText(L"IDS_USAGETIP_RECLICKRIGHTLEFTSHOWWINDOW",
			L"再一齐按鼠标左右键可以重新显示窗口。");
		}
		else
		{
			g_pSetTipText(L"IDS_USAGETIP_REPRESSHOTKEYTOSHOWWINDOW",
			L"再按下 隐藏窗口 快捷键可以重新显示窗口。");
		}

		dbview(L"enter bHideWindows = 0;........................................");

		bHideWindows = 0;
	}
	else if (bHideWindows == 0)
	{
		if (sOP.bUsePassword == 1)
		{
			if(hDlg_Validate != NULL && IsWindow(hDlg_Validate))
			{
				return 1;
			}
			if (DialogBox(hInst,MAKEINTRESOURCE(IDD_DIALOG_VALIDATE),NULL,(DLGPROC)ValidateProc) == 0)
			{
				return 1;
			}
		}

		EnableWindow(hAll,TRUE);
		EnableWindow(hLV,TRUE);

		RestoreVolume();
		//2.2 method ///
		for (int i = 0;i < iBaSW_dll;i++)
		{
			if(sOP.bHideProcess == 1)
			{
				ShowProcess(sW_dll[i].lPID);
			}
			ShowWindow(sW_dll[i].hWnd,SW_SHOW);
			
			if(sW_dll[i].iHasTrayIcon == 1 && sW_dll[i].bHide == 1)
			{
				nid.cbSize           = sizeof(NOTIFYICONDATA);
				nid.uFlags           = NIF_ICON|NIF_TIP|NIF_MESSAGE;
				nid.uID              = sW_dll[i].trayicon.uID;
				nid.hIcon            = sW_dll[i].trayicon.hIcon;
				nid.hWnd             = sW_dll[i].trayicon.hwnd;
				wcscpy(nid.szTip,(const wchar_t *)sW_dll[i].cIconTip);
				nid.uCallbackMessage = sW_dll[i].trayicon.uCallbackMessage;
//				Shell_NotifyIcon(NIM_ADD,&nid);
				{
					int iCommandId = sW_dll[i].iCommandId;
					HWND g_TrayWnd = FindTrayToolbarWindow();
					SendMessageW(g_TrayWnd,TB_HIDEBUTTON,WPARAM(iCommandId),
					(LPARAM)MAKELONG(FALSE,0));
					NOTIFYICONDATA nid2;
					memset(&nid2,0,sizeof(nid2));
					nid2.cbSize=sizeof(nid2);
					nid2.hWnd=nid.hWnd;
					nid2.uID=nid.uID;
					nid2.uFlags=NIF_STATE;
					nid2.dwState=NIS_HIDDEN;
					::SendMessage(g_TrayWnd,WM_SETREDRAW,(WPARAM)FALSE,0);
					Shell_NotifyIcon(NIM_MODIFY,&nid2);
					SendMessage(g_TrayWnd,WM_SETREDRAW,(WPARAM)TRUE,0);
				}
//				HANDLE hHideWndHandle = (HANDLE)_beginthreadex(NULL,0,HideWindowProc,sW_dll + i1,0,NULL);
//				if(hHideWndHandle == INVALID_HANDLE_VALUE)
//				{
//					g_arrayHide[i1] = NULL;
//				}
//				else
//				{
//					g_arrayHide[i1] = hHideWndHandle;
//				}



			}
			sW_dll[i].bHide = 0;
		}
		

		if(sOP.bAutoHide_QH == 1 && iBaSW_QH > 0)
		{
			for(i = 0;i < iBaSW_QH;i++)
			{
				ShowWindow(pArr_dll[i],SW_SHOW);
			}
			iBaSW_QH = 0;
		}

		if(sOP.bHideAllTray == 1)
		{
			ShowAllTray();
			ReleaseResourceForTrayList_dll();

		}


		bHideWindows = 1;
		g_pClearTipText();
		if(sOP.bUseMiddle)
		{
			g_pAppendTipText(L"IDS_USAGETIP_CLICKMIDDLEHIDEWND",
			L"按鼠标中键可以隐藏窗口。");
		}
		else if(sOP.bUseMouse)
		{
			g_pAppendTipText(L"IDS_USAGETIP_CLICKLEFTRIGHTHIDEWND",
			L"一齐按下鼠标左右键可以隐藏窗口。");	
		}
		else
		{
			g_pAppendTipText(L"IDS_USAGETIP_PRESSHOTKEYTOHIDEWINDOW",
			L"按下 隐藏窗口 的快捷键,即可隐藏窗口。");	
		}
		if(sOP.bReserveSel)
		{
			g_pAppendTipText(L"IDS_USAGETIP_SELWNDLISTCANRESERVEWND",
			L"您还可以在下边窗口列表里选择不想隐藏的窗口。");
		}
		else
		{
			g_pAppendTipText(L"IDS_USAGETIP_HIDESELITEM",
			L"在 窗口列表 里被选择的窗口将被隐藏。");
		}
		if(sOP.bUseMiddle)
		{
			g_pSetTipText(L"IDS_USAGETIP_CLICKMIDDLEHIDEWND",
			L"按鼠标中键可以隐藏窗口。");
		}
		else if(sOP.bUseMouse)
		{
			g_pSetTipText(L"IDS_USAGETIP_CLICKLEFTRIGHTHIDEWND",
			L"一齐按下鼠标左右键可以隐藏窗口。");
		}
		else
		{
			g_pSetTipText(L"IDS_USAGETIP_PRESSHOTKEYTOHIDEWINDOW",
			L"按下 隐藏窗口 的快捷键,即可隐藏窗口。");
		}

		iHideComplete = 1;

	}
	return 1;
}
BOOL CTaskManagerDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	// 将“关于...”菜单项添加到系统菜单中。

	// IDM_ABOUTBOX 必须在系统命令范围内。
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		BOOL bNameValid;
		CString strAboutMenu;
		bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
		ASSERT(bNameValid);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// 设置此对话框的图标。  当应用程序主窗口不是对话框时,框架将自动
	//  执行此操作
	SetIcon(m_hIcon, TRUE);			// 设置大图标
	SetIcon(m_hIcon, FALSE);		// 设置小图标

	// TODO:  在此添加额外的初始化代码

	CRect  Rect;
	CString str;
	m_lstctrlprocess.GetWindowRect(&Rect);
	int wight = Rect.Width() / 3;
	for (int i = 0; i < 3; i++)
	{
		str.LoadString(IDS_NAME + i);
		m_lstctrlprocess.InsertColumn(i, str, LVCFMT_LEFT, wight);
	}

	m_lisresults.GetWindowRect(&Rect);
	wight = Rect.Width() / 3;
	for (int i = 0; i < 3; i++)
	{
		str.LoadString(IDS_NUM + i);
		m_lisresults.InsertColumn(i, str, LVCFMT_LEFT, wight);
	}
	////设置窗口大小
	//CRect  m_Rect;
	//CRect  g_Rect;
	//GetWindowRect(&m_Rect);//得到主窗口大小
	//GetDlgItem(IDC_Search)->GetClientRect(&g_Rect);	//获得groupbox句柄 得到groupbox大小
	//SetWindowPos(NULL, 0, 0, m_Rect.Width() - g_Rect.Width() - 20, m_Rect.Height(), SWP_NOMOVE);

	//显示所有进程
	ShowProcess();

	//设置样式
	m_lstctrlprocess.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
	m_lisresults.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);

	return TRUE;  // 除非将焦点设置到控件,否则返回 TRUE
}
//刷新
void CTaskManagerDlg::OnBnClickedButton2()
{
	ShowProcess();
}