久久福利_99r_国产日韩在线视频_直接看av的网站_中文欧美日韩_久久一

您的位置:首頁技術(shù)文章
文章詳情頁

Win 2000下的進(jìn)程枚舉

瀏覽:25日期:2023-09-20 15:05:02

進(jìn)程在每個(gè)系統(tǒng)中實(shí)現(xiàn)的方法是不一樣的,在 win 98 中,系統(tǒng)提供 TOOLHELP32 API 接口,在 win NT 中,系統(tǒng)提供 PSAPI 函數(shù), 2000而 win 2000 既支持 TOOLHELP 又支持 PSAPI,NT 系統(tǒng)還提供了 NATIVE API (NtQuerySystemInformation),這個(gè)函數(shù)功能十分強(qiáng)大,幾乎可以查詢所有的系統(tǒng)信息,調(diào)用此函數(shù)必須有SE_TCB_NAME特權(quán)。下面給出函數(shù)原型: NTSTATUS WINAPI NtQuerySystemInformation( int SystemInfoClass PVOID SystemInfoBuffer, ULONG SystemInfoBufferSize, PULONG BytesReturned);

當(dāng) SystemInfoClass 等于5時(shí)便可獲取進(jìn)程信息了。

關(guān)于 NT 系統(tǒng)下的特權(quán)(Privilege)及其描述見下表:

Privilege Constant Description SE_ASSIGNPRIMARYTOKEN_NAME Required to assign the primary token of a process. SE_AUDIT_NAME Required to generate audit-log entrIEs. Give this privilege to secure servers. SE_BACKUP_NAME Required to perform backup operations. SE_CHANGE_NOTIFY_NAME Required to receive notifications of changes to files or Directories. This privilege also causes the system to skip all traversal access checks. It is enabled by default for all users. SE_CREATE_PAGEFILE_NAME Required to create a paging file. SE_CREATE_PERMANENT_NAME Required to create a permanent object. SE_CREATE_TOKEN_NAME Required to create a primary token. SE_DEBUG_NAME Required to debug a process. SE_INC_BASE_PRIORITY_NAME Required to increase the base priority of a process. SE_INCREASE_QUOTA_NAME Required to increase the quota assigned to a process. SE_LOAD_DRIVER_NAME Required to load or unload a device driver. SE_LOCK_MEMORY_NAME Required to lock physical pages in memory. SE_PROF_SINGLE_PROCESS_NAME Required to gather profiling information for a single process. SE_REMOTE_SHUTDOWN_NAME Required to shut down a system using a network request. SE_RESTORE_NAME Required to perform restore operations. This privilege enables you to set any valid user or group SID as the owner of an object. SE_SECURITY_NAME Required to perform a number of security-related functions, such as controlling and viewing audit messages. This privilege identifies its holder as a security operator. SE_SHUTDOWN_NAME Required to shut down a local system. SE_SYSTEM_ENVIRONMENT_NAME Required to modify the nonvolatile RAM of systems that use this type of memory to store configuration information. SE_SYSTEM_PROFILE_NAME Required to gather profiling information for the entire system. SE_SYSTEMTIME_NAME Required to modify the system time. SE_TAKE_OWNERSHIP_NAME Required to take ownership of an object without being granted discretionary access. This privilege allows the owner value to be set only to those values that the holder may legitimately assign as the owner of an object. SE_TCB_NAME This privilege identifies its holder as part of the trusted computer base. Some trusted protected subsystems are granted this privilege. This privilege is required to call the LogonUser function. SE_UNSOLICITED_INPUT_NAME Required to read unsolicited input from a terminal device. SE_MacHINE_ACCOUNT_NAME Required to create a machine account.

關(guān)于定義可見下表,或察看 WINNT.H:

SE_CREATE_TOKEN_NAME SeCreateTokenPrivilegeSE_ASSIGNPRIMARYTOKEN_NAME SeAssignPrimaryTokenPrivilegeSE_LOCK_MEMORY_NAME SeLockMemoryPrivilegeSE_INCREASE_QUOTA_NAME SeIncreaseQuotaPrivilegeSE_UNSOLICITED_INPUT_NAME SeUnsolicitedInputPrivilegeSE_MACHINE_ACCOUNT_NAME SeMachineAccountPrivilegeSE_TCB_NAME SeTcbPrivilegeSE_SECURITY_NAME SeSecurityPrivilegeSE_TAKE_OWNERSHIP_NAME SeTakeOwnershipPrivilegeSE_LOAD_DRIVER_NAME SeLoadDriverPrivilegeSE_SYSTEM_PROFILE_NAME SeSystemProfilePrivilegeSE_SYSTEMTIME_NAME SeSystemtimePrivilegeSE_PROF_SINGLE_PROCESS_NAME SeProfileSingleProcessPrivilegeSE_INC_BASE_PRIORITY_NAME SeIncreaseBasePriorityPrivilegeSE_CREATE_PAGEFILE_NAME SeCreatePagefilePrivilegeSE_CREATE_PERMANENT_NAME SeCreatePermanentPrivilegeSE_BACKUP_NAME SeBackupPrivilegeSE_RESTORE_NAME SeRestorePrivilegeSE_SHUTDOWN_NAME SeShutdownPrivilegeSE_DEBUG_NAME SeDebugPrivilegeSE_AUDIT_NAME SeAuditPrivilegeSE_SYSTEM_ENVIRONMENT_NAME SeSystemEnvironmentPrivilegeSE_CHANGE_NOTIFY_NAME SeChangeNotifyPrivilegeSE_REMOTE_SHUTDOWN_NAME SeRemoteShutdownPrivilege

ADMINISTRATOR 被默認(rèn)授于以下這16個(gè)權(quán)限:

SeChangeNotifyPrivilege SeSecurityPrivilege SeBackupPrivilege SeRestorePrivilege SeSystemtimePrivilege SeShutdownPrivilege SeRemoteShutdownPrivilege SeTakeOwnershipPrivilege SeDebugPrivilege SeSystemEnvironmentPrivilege SeSystemProfilePrivilege SeProfileSingleProcessPrivilege SeIncreaseBasePriorityPrivilege SeLoadDriverPrivilege SeCreatePagefilePrivilege SeIncreaseQuotaPrivilege

可以用 OpenProcessToken 和 AdjustTokenPrivileges 這兩個(gè)函數(shù)來提升進(jìn)程的特權(quán)。

講了那么多,現(xiàn)在回到主題上來。到底使用哪個(gè)方法比較好呢?在 win 2000 下有3個(gè)方法可供選擇,我比較喜歡簡單的方法。NtQuerySystemInformation 功能固然強(qiáng)大,但使用比較麻煩。而 win 2000 的 TOOLHELP32 API 其本質(zhì)還是調(diào)用了 NtQuerySystemInformation 函數(shù),由于它發(fā)生錯(cuò)誤時(shí),可能不能正確返回返回值,所以不是很穩(wěn)定,使用起來也是很麻煩的,不符合我的懶人本性。還是采用 PSAPI 比較好,簡單又方便,只需要三個(gè)函數(shù),且沒有復(fù)雜的結(jié)構(gòu)體參數(shù)。

函數(shù)原型:

BOOLWINAPIEnumProcesses(DWord * lpidProcess,//指針指向存放進(jìn)程ID的數(shù)組DWORD cb, //數(shù)組大小DWORD * cbNeeded //返回的實(shí)際大小);

BOOLWINAPIEnumProcessModules(HANDLE hProcess, //進(jìn)程句柄HMODULE *lphModule, //指針指向存放模塊句柄的數(shù)組DWORD cb, //數(shù)組大小LPDWORD lpcbNeeded //返回的實(shí)際大小);

DWORDWINAPIGetModuleFileNameEx(HANDLE hProcess, //進(jìn)程句柄HMODULE hModule, //模塊句柄LPSTR lpFilename, //存放模塊文件名的字符串DWORD nSize //字符串大小);

 他們的作用分別是:枚舉進(jìn)程,枚舉進(jìn)程模塊,獲取模塊文件名(包含路徑)。詳細(xì)的源代碼如下:

// EnumProcess.cpp : Defines the entry point for the console application.// Code By : tabris17

#include 'stdafx.h'#include 'Psapi.h'

#pragma comment (lib,'Psapi.lib')

void PrintFileName(DWORD processID){char fn[MAX_PATH];HANDLE hProcess=OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ,FALSE,processID);if (hProcess){HMODULE hMod[1024];DWORD cbNeeded,size;unsigned int i;if (EnumProcessModules(hProcess,hMod,sizeof(hMod),&cbNeeded)){size=cbNeeded/sizeof(HMODULE);GetModuleFileNameEx(hProcess,hMod[0],fn,sizeof(fn));printf('n(%u)t%sn',processID,fn);for(i=1;i<size;i++){GetModuleFileNameEx(hProcess,hMod[i],fn,sizeof(fn));printf('t%sn',fn);}}}CloseHandle(hProcess);}

int plist(){DWORD Processesid[1024], cbNeeded,size;unsigned int i;if (!EnumProcesses(Processesid,sizeof(Processesid),&cbNeeded))return 0;

size=cbNeeded/sizeof(DWORD);

for (i=0;i<size;i++)PrintFileName(Processesid[i]);return 0;}

int main(int argc, char* argv[]){plist();return 0;}

標(biāo)簽: Windows系統(tǒng) Win2000
主站蜘蛛池模板: 成人免费黄色片 | 国产美女在线观看 | 久久亚洲一区二区 | 人人九九 | 欧美第一视频 | 欧美精品欧美极品欧美激情 | 国产成人毛片 | 国产欧美精品区一区二区三区 | 国产精品99一区二区三区 | 久久国产成人 | 成人午夜视频在线观看 | 日韩av成人 | 精品视频一区二区三区 | 亚洲97视频| 夜夜操天天操 | 免费爱爱视频 | 久久久av| 国产精品99久久久久久动医院 | 久久久久久久免费 | 亚洲免费网站在线观看 | 99精品国产高清一区二区麻豆 | 综合视频一区二区三区 | 欧美夜夜骑 | 欧美一级黄色片免费看 | 国内久久精品 | 成年人在线观看 | 免费黄色av | 国产精品自拍视频 | 亚洲视频精品一区 | 日韩经典一区 | 91社区在线播放 | 亚洲欧美日韩在线 | 亚洲精品成人 | 国产精品视频专区 | 视频成人免费 | 欧美日韩高清在线一区 | 99久久精品国产一区二区成人 | 免费国产一区 | 国产高清免费 | 欧美一区二区在线 | 国产大胆自拍 |