mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
[os2/process]: Fill in basic functions
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
//+build windows
|
||||
package os2
|
||||
|
||||
import "core:sys/windows"
|
||||
|
||||
_exit :: proc "contextless" (code: int) -> ! {
|
||||
windows.ExitProcess(u32(code))
|
||||
}
|
||||
|
||||
_get_uid :: proc() -> int {
|
||||
return -1
|
||||
}
|
||||
|
||||
_get_euid :: proc() -> int {
|
||||
return -1
|
||||
}
|
||||
|
||||
_get_gid :: proc() -> int {
|
||||
return -1
|
||||
}
|
||||
|
||||
_get_egid :: proc() -> int {
|
||||
return -1
|
||||
}
|
||||
|
||||
_get_pid :: proc() -> int {
|
||||
return cast(int) windows.GetCurrentProcessId()
|
||||
}
|
||||
|
||||
_get_ppid :: proc() -> int {
|
||||
our_pid := windows.GetCurrentProcessId()
|
||||
snap := windows.CreateToolhelp32Snapshot(windows.TH32CS_SNAPPROCESS, 0)
|
||||
if snap == windows.INVALID_HANDLE_VALUE {
|
||||
return -1
|
||||
}
|
||||
defer windows.CloseHandle(snap)
|
||||
entry := windows.PROCESSENTRY32W { dwSize = size_of(windows.PROCESSENTRY32W) }
|
||||
status := windows.Process32FirstW(snap, &entry)
|
||||
for status {
|
||||
if entry.th32ProcessID == our_pid {
|
||||
return cast(int) entry.th32ParentProcessID
|
||||
}
|
||||
status = windows.Process32NextW(snap, &entry)
|
||||
}
|
||||
return -1
|
||||
}
|
||||
Reference in New Issue
Block a user