1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
| #include <windows.h> #include <stdio.h> #define EXEC_FILE "C:\\...\\*.exe"; int main(){ PROCESS_INFORMATION pi={0}; STARTUPINFO si={0}; si.cb=sizeof(STARTUPINFO); BOOL bRet=CreateProcess(Exec_File,NULL,NULL,NULL,FALSE,NULL,NULL,NULL,&si,&pi); if(bRet==FALSE){ return -1; }; CloseHandle(pi.hThread); CloseHandle(pi.hProcess); return 0; };
#include <Windows.h> int main(int argc,char* argv[]){ HWND hNoteWnd=FindWindow(NULL,"无标题 - 记事本"); if(hNoteWnd==NULL) return -1; DWORD dwNotePid=0; GetWindowThreadProcessId(hNoteWnd,&dwNotePid); if(dwNotePid==0) return 0; HANDLE hNoteHandle=OpenProcess(PROCESS_ALL_ACCESS,FALSE,dwNotePid); if(hNoteHandle==NULL) return -1; BOOL bRet=TerminateProcess(hNoteHandle,0); if(bRet==TRUE){ }; CloseHandle(hNoteHandle); return 0; };
VOID CManageProcessDlg::ShowProcess(){ HANDLE hSnap=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); if(hSnap==INVALID_HANDLE_VALUE){ return -1; }; PROCESSENTRY32 Pe32={0}; Pe32.dwSize=sizeof(PROCESSENTRY32); BOOL bRet=Process32First(hSnap,&Pe32); int i=0; CString str; while(bRet){ i++; bRet=Process32Next(hSnap,&Pe32); } CloseHandle(hSnap); };
VOID CManageProcessDlg::ShowModule(){ MODULEENTRY32 Me32={0}; Me32.dwSize=sizeof(MODULEENTRY32); HANDLE hSnap=CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,nPid); if(hSnap==INVALID_HANDLE_VALUE){ return; }; BOOL bRet=Module32First(hSnap,&Me32); int i=0; CString str; while(bRet){ i++; bRet=Module32Next(hSnap,&Me32); }; CloseHandle(hSnap); };
VOID CManageProcessDlg::DebugPrivilege(){ HANDLE hToken=NULL; BOOl bRet=OpenProcessToken(GetCurrentProcess(),TOKEN_ALL_ACCESS,&hToken); if(bRet==TRUE){ TOKEN_PRIVILEGES tp; tp.PrivilegeCount=1; LookupPrivilegeValue(NULL,SE_DEBUG_NAME,&tp.Privileges[0].Luid); tp.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED; AdjustTokenPrivileges(hToken,FALSE,&tp,sizeof(tp),NULL,NULL); CloseHandle(hToken); }; };
void CManageProcessDlg::OnBtnStop(){ HANDLE hSnap=CreateToolhelp32Snapshot(TH32CS_SnapTHREAD,nPid); if(hSnap==INVALID_HANDLE_VALUE){ return; }; THREADENTRY32 Te32={0}; Te32.dwSize=sizeof(THREADENTRY32); BOOL bRet=Thread32First(hSnap,&Te32); while(bRet){ if(Te32.th32OwnerProcessID==nPid){ HANDLE hThread=OpenThread(THREAD_ALL_ACCESS,FALSE,Te32.th32ThreadID); SuspendThread(hThread); CloseHandle(hThread); }; bRet=Thread32Next(hSnap,&Te32); }; CloseHandle(hSnap); };
void CManageProcessDlg::OnBtnResume(){ HANDLE hSnap=CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD,nPid); if(hSnap==INVALID_HANDLE_VALUE){ return; }; THREADENTRY32 Te32={0}; Te32.dwSize=sizeof(THREADENTRY32); BOOL bRet=Thread32First(hSnap,&Te32); while(bRet){ if(Te32.th32OwnerProcessID==nPid){ HANDLE hThread=OpenThread(THREAD_ALL_ACCESS,FALSE,Te32.th32ThreadID); ResumeThread(hThread); CloseHandle(hThread); }; bRet=Thread32Next(hSnap,&Te32); }; CloseHandle(hSnap); }
|