Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The fastest way to scan for processes is via NTDLL's NtQuerySystemInformation call. It provides you with a list of names and process IDs of all processes on the system with a single call (or more in rare cases, i.e. large # of processes). You can combine NtQuerySystemInformation and use a hash to do string comparisons instead of comparing each byte.</p> <pre><code>// headers @ http://pastebin.com/HWzJYpbv NtQuerySystemInformation = (_RT_NAPI_QUERYSYSINFO)GetProcAddress(GetModuleHandleA("NTDLL.DLL"), "NtQuerySystemInformation"); // Get process information buffer do { // Allocate buffer for process info pBuffer = HeapAlloc(hHeap, HEAP_ZERO_MEMORY, cbBuffer); if (pBuffer == NULL) { // Cannot allocate enough memory for buffer (CRITICAL ERROR) return 1; } // Obtain system process snapshot Status = NtQuerySystemInformation(5, pBuffer, cbBuffer, NULL); // Allocate bigger buffer for moar data if (Status == STATUS_INFO_LENGTH_MISMATCH) { HeapFree(hHeap, 0, pBuffer); cbBuffer *= 2; // Increase the size of the buffer :-) } else if ((Status) != 0x00) { // Can't query process information (probably rootkit or anti-virus) HeapFree(hHeap, 0, pBuffer); return 1; } } while (Status == STATUS_INFO_LENGTH_MISMATCH); // Get pointer to first system process info structure pInfo = (PSYSTEM_PROCESS_INFORMATION)pBuffer; // Loop over each process for (;;) { // Get process name pszProcessName = pInfo-&gt;ImageName.Buffer; // ... do work. For a fast string compare, calculate a 32-bit hash of the string, then compare to a static hash. if(CRC32(pszProcessName) == 0xDEADBEEF /* &lt;- hash of adobe reader process name goez here */) { // Found process } // Load next entry if (pInfo-&gt;NextEntryOffset == 0) break; pInfo = (PSYSTEM_PROCESS_INFORMATION)(((PUCHAR)pInfo)+ pInfo-&gt;NextEntryOffset); } </code></pre> <p><strong>Tested on Windows 2000 - Windows 7 English editions, x64/x86 (except Win XP x64)</strong> Note: It will return all processes to 32-bit WOW64 processes on 64-bit systems.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload