Skip to content

Commit dd5d092

Browse files
committed
chore(win32.js): add more comments
Helping explain the changes made in #2.
1 parent cd14338 commit dd5d092

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/process/native/win32.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const psapi = koffi.load('psapi.dll');
55
const kernel32 = koffi.load('kernel32.dll');
66
const ntdll = koffi.load('ntdll.dll');
77

8-
// Define Alias
8+
// Define aliases for native data types
99
const DWORD = koffi.alias('DWORD', 'uint32_t');
1010
const BOOL = koffi.alias('BOOL', 'int32_t');
1111
const HANDLE = koffi.pointer('HANDLE', koffi.opaque())
@@ -23,8 +23,10 @@ const SYSTEM_PROCESS_ID_INFORMATION = koffi.struct('SYSTEM_PROCESS_ID_INFORMATIO
2323

2424
const EnumProcesses = psapi.func('BOOL __stdcall EnumProcesses(_Out_ DWORD *lpidProcess, DWORD cb, _Out_ DWORD *lpcbNeeded)')
2525
const GetLastError = kernel32.func('DWORD GetLastError()')
26+
// Define native functions
2627
const NtQuerySystemInformation = ntdll.func('NtQuerySystemInformation', 'int32', ['int32', 'SYSTEM_PROCESS_ID_INFORMATION*', 'uint32', HANDLE]);
2728

29+
// Define constants and helper functions
2830
const SystemProcessIdInformation = 88; // SYSTEM_INFORMATION_CLASS enum value for SystemProcessIdInformation
2931

3032
const STATUS_INFO_LENGTH_MISMATCH = 0xC0000004;
@@ -67,6 +69,8 @@ const getProcessImageName = (pid) => {
6769

6870
export 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

Comments
 (0)