@@ -5,7 +5,7 @@ const psapi = koffi.load('psapi.dll');
55const kernel32 = koffi . load ( 'kernel32.dll' ) ;
66const ntdll = koffi . load ( 'ntdll.dll' ) ;
77
8- // Define Alias
8+ // Define aliases for native data types
99const DWORD = koffi . alias ( 'DWORD' , 'uint32_t' ) ;
1010const BOOL = koffi . alias ( 'BOOL' , 'int32_t' ) ;
1111const HANDLE = koffi . pointer ( 'HANDLE' , koffi . opaque ( ) )
@@ -23,8 +23,10 @@ const SYSTEM_PROCESS_ID_INFORMATION = koffi.struct('SYSTEM_PROCESS_ID_INFORMATIO
2323
2424const EnumProcesses = psapi . func ( 'BOOL __stdcall EnumProcesses(_Out_ DWORD *lpidProcess, DWORD cb, _Out_ DWORD *lpcbNeeded)' )
2525const GetLastError = kernel32 . func ( 'DWORD GetLastError()' )
26+ // Define native functions
2627const NtQuerySystemInformation = ntdll . func ( 'NtQuerySystemInformation' , 'int32' , [ 'int32' , 'SYSTEM_PROCESS_ID_INFORMATION*' , 'uint32' , HANDLE ] ) ;
2728
29+ // Define constants and helper functions
2830const SystemProcessIdInformation = 88 ; // SYSTEM_INFORMATION_CLASS enum value for SystemProcessIdInformation
2931
3032const STATUS_INFO_LENGTH_MISMATCH = 0xC0000004 ;
@@ -67,6 +69,8 @@ const getProcessImageName = (pid) => {
6769
6870export const getProcesses = ( ) => new Promise ( res => {
6971 const processIds = new Uint32Array ( 1024 ) ;
72+ // lists all running processes and retrieves their executable image names
73+ // (filename of an executable binary, e.g. "notepad.exe")
7074 const bytesNeeded = new Uint32Array ( 1 ) ;
7175 let out = [ ]
7276
0 commit comments