@@ -14,11 +14,16 @@ import { kernel32 } from './_lib.js'
14
14
*
15
15
* https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-openprocess
16
16
*/
17
- export const OpenProcess :koffi . KoffiFunc < (
17
+ /*@__NO_SIDE_EFFECTS__ */
18
+ export function OpenProcess (
18
19
dwDesiredAccess : number ,
19
20
bInheritHandle : boolean ,
20
21
dwProcessId : number
21
- ) => HANDLE < string > > = kernel32 ( 'OpenProcess' , cHANDLE , [ cDWORD , cBOOL , cDWORD ] )
22
+ ) : string | null {
23
+ const flag = bInheritHandle ? 1 : 0
24
+ return _OpenProcess ( dwDesiredAccess , flag , dwProcessId )
25
+ }
26
+ const _OpenProcess = kernel32 ( 'OpenProcess' , cHANDLE , [ cDWORD , cBOOL , cDWORD ] )
22
27
23
28
/**
24
29
* Get full Image Name of Process (A)
@@ -27,7 +32,7 @@ export const OpenProcess:koffi.KoffiFunc<(
27
32
*/
28
33
/*@__NO_SIDE_EFFECTS__ */
29
34
export function QueryFullProcessImageNameA (
30
- hProcess : HANDLE < '' > ,
35
+ hProcess : string ,
31
36
dwFlags : number
32
37
) : string | null {
33
38
const exeName = new Uint16Array ( 256 )
@@ -46,7 +51,7 @@ const _QueryFullProcessImageNameA = kernel32('QueryFullProcessImageNameW', cBOOL
46
51
*/
47
52
/*@__NO_SIDE_EFFECTS__ */
48
53
export function QueryFullProcessImageName (
49
- hProcess : HANDLE < string > ,
54
+ hProcess : string ,
50
55
dwFlags : number
51
56
) : string | null {
52
57
const exeName = new Uint16Array ( 256 )
@@ -65,7 +70,7 @@ const _QueryFullProcessImageName = kernel32('QueryFullProcessImageNameW', cBOOL,
65
70
*
66
71
*/
67
72
export const CloseHandle :koffi . KoffiFunc < (
68
- hObject : HANDLE < string >
73
+ hObject : string
69
74
) => boolean > = kernel32 ( 'CloseHandle' , cBOOL , [ cHANDLE ] )
70
75
71
- // #endregion
76
+ // #endregion
0 commit comments