![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
NtQuerySystemInformation ;- Как получить PID ?
AlexRush © (2003-06-21 18:47:00)
Как получить ID процесса по имени(в частности WINLOGON.EXE) ?
AlexRush (2003-06-30 19:20:00) [1]
Удалено модератором
Примечание: Offtopic
AlexRush (2003-06-25 15:26:00) [2]
неРуль (23.06.03 10:49)
>> если что, могу расписать подробнее >>
Распиши, коли не трудо... ;)
неРуль (2003-06-23 14:53:00) [3]
ну не все, сервисы в основном без привилегий
ZZ (2003-06-23 14:26:00) [4]
кхе, кхе, могет я что то и путаю (иногда бывает :), но ОпенПроцесс так просто процесс не откроет даже под админом
И часто бывает?
неРуль (2003-06-23 10:49:00) [5]кхе, кхе, могет я что то и путаю (иногда бывает :), но ОпенПроцесс так просто процесс не откроет даже под админом
я делал так, может немного кривовато, но пашет
function GetFirstID(procname: string): longint;
var i: longint;
begin
@NtQuerySystemInformation:=GetProcAddress(GetModuleHandle("ntdll.dll"), "NtQuerySystemInformation");
if assigned(@NtQuerySystemInformation) then begin
GetMem(p, 30000);
proc:=p;
NtQuerySystemInformation(5, proc, 30000,i);
while true do begin
//в proc - все о процессе
if proc^.NextOffset=0 then break;
proc:=pointer(cardinal(proc)+proc^.NextOffset);
if proc.pModuleName=procname then begin
result:= proc.ProcessID;
break;
end;
end;
( p, 30000)кхе, кхе, могет я что то и путаю (иногда бывает :), но ОпенПроцесс так просто процесс не откроет даже под админом
я делал так, может немного кривовато, но пашет
function GetFirstID(procname: string): longint;
var i: longint;
begin
@NtQuerySystemInformation:=GetProcAddress(GetModuleHandle("ntdll.dll"), "NtQuerySystemInformation");
if assigned(@NtQuerySystemInformation) then begin
GetMem(p, 30000);
proc:=p;
NtQuerySystemInformation(5, proc, 30000,i);
while true do begin
//в proc - все о процессе
if proc^.NextOffset=0 then break;
proc:=pointer(cardinal(proc)+proc^.NextOffset);
if proc.pModuleName=procname then begin
result:= proc.ProcessID;
break;
end;
end;
FreeMem(p, 30000);
end;
end;
если что, могу расписать подробнее
ZZ (2003-06-21 21:01:00) [6]функция EnumProcesses и компания. Далее пример из MSDN
#include
#include
#include "psapi.h"
void PrintProcessNameAndID( DWORD processID )
{
char szProcessName[MAX_PATH] = "unknown";
// Get a handle to the process.
HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE, processID );
// Get the process name.
if ( hProcess )
{
HMODULE hMod;
DWORD cbNeeded;
if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod),
&cbNeeded) )
{
GetModuleBaseName( hProcess, hMod, szProcessName,
sizeof(szProcessName) );
}
}
// Print the process name and identifier.
printf( "%s (Process ID: %u)\n", szProcessName, processID );
CloseHandle( hProcess );
}
void main( )
{
// Get the list of process identifiers.
DWORD aProcesses[1024], cbNeeded, cProcesses;
unsigned int i;
if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
return;
// Calculate how many process identifiers were returned.
cProcesses = cbNeeded / sizeof(DWORD);
// Print the name and process identifier for each process.
for ( i = 0; i < cProcesses; i++ )
( aProcesses[i])
функция EnumProcesses и компания. Далее пример из MSDN
#include
#include
#include "psapi.h"
void PrintProcessNameAndID( DWORD processID )
{
char szProcessName[MAX_PATH] = "unknown";
// Get a handle to the process.
HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE, processID );
// Get the process name.
if ( hProcess )
{
HMODULE hMod;
DWORD cbNeeded;
if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod),
&cbNeeded) )
{
GetModuleBaseName( hProcess, hMod, szProcessName,
sizeof(szProcessName) );
}
}
// Print the process name and identifier.
printf( "%s (Process ID: %u)\n", szProcessName, processID );
CloseHandle( hProcess );
}
void main( )
{
// Get the list of process identifiers.
DWORD aProcesses[1024], cbNeeded, cProcesses;
unsigned int i;
if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
return;
// Calculate how many process identifiers were returned.
cProcesses = cbNeeded / sizeof(DWORD);
// Print the name and process identifier for each process.
for ( i = 0; i < cProcesses; i++ )
PrintProcessNameAndID( aProcesses[i] );
AlexRush (2003-06-21 20:54:00) [7]
Слушаю Ваши предложения...
ZZ (2003-06-21 20:51:00) [8]
Типа сам себе отвечаешь или как? В смысле - почему именно NtQuerySystemInformation ? Особенно для winlogon"а...
AlexRush (2003-06-21 20:17:00) [9]
или хотя бы линк на тему....