Skip to content

Commit

Permalink
Update JOB_OBJECT_ALL_ACCESS and OpenJobObject (#2095)
Browse files Browse the repository at this point in the history
Update `JOB_OBJECT_ALL_ACCESS` value to the most recent one.
Update `winapi.OpenJobObject` to accept `inheritHandle` as
`bool`. The underlying syscall stays the same, but this allows
cleaner calls from go's perspective as it avoids `bool` to `uint32`
casting.

Signed-off-by: Maksim An <[email protected]>
(cherry picked from commit 42671b4)
Signed-off-by: Kirtana Ashok <[email protected]>
  • Loading branch information
anmaxvl authored and kiashok committed Oct 30, 2024
1 parent 1550628 commit 05636b9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion internal/jobobject/jobobject.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func Open(ctx context.Context, options *Options) (_ *JobObject, err error) {
return nil, winapi.RtlNtStatusToDosError(status)
}
} else {
jobHandle, err = winapi.OpenJobObject(winapi.JOB_OBJECT_ALL_ACCESS, 0, unicodeJobName.Buffer)
jobHandle, err = winapi.OpenJobObject(winapi.JOB_OBJECT_ALL_ACCESS, false, unicodeJobName.Buffer)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions internal/winapi/jobobject.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const (
// https://docs.microsoft.com/en-us/windows/win32/procthread/job-object-security-and-access-rights
const (
JOB_OBJECT_QUERY = 0x0004
JOB_OBJECT_ALL_ACCESS = 0x1F001F
JOB_OBJECT_ALL_ACCESS = 0x1F003F
)

// IO limit flags
Expand Down Expand Up @@ -199,7 +199,7 @@ type SILOOBJECT_BASIC_INFORMATION struct {
// LPCWSTR lpName
// );
//
//sys OpenJobObject(desiredAccess uint32, inheritHandle int32, lpName *uint16) (handle windows.Handle, err error) = kernel32.OpenJobObjectW
//sys OpenJobObject(desiredAccess uint32, inheritHandle bool, lpName *uint16) (handle windows.Handle, err error) = kernel32.OpenJobObjectW

// DWORD SetIoRateControlInformationJobObject(
// HANDLE hJob,
Expand Down
8 changes: 6 additions & 2 deletions internal/winapi/zsyscall_windows.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 05636b9

Please sign in to comment.