Mercurial > minori
diff dep/animone/src/fd/xnu.cc @ 270:0718f538c5f9
dep/animone: filter open files by access mode
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Fri, 12 Apr 2024 19:13:50 -0400 |
parents | 862d0d8619f6 |
children | 246017a7907a |
line wrap: on
line diff
--- a/dep/animone/src/fd/xnu.cc Fri Apr 12 05:23:45 2024 -0400 +++ b/dep/animone/src/fd/xnu.cc Fri Apr 12 19:13:50 2024 -0400 @@ -14,6 +14,18 @@ #include <sys/types.h> #include <sys/user.h> +/* you may be asking: WTF is FWRITE? + * well, from bsd/sys/fcntl.h in the XNU kernel: + * + * Kernel encoding of open mode; separate read and write bits that are + * independently testable: 1 greater than [O_RDONLY and O_WRONLY]. + * + * It's just how the kernel defines write mode. +*/ +#ifndef FWRITE +#define FWRITE 0x0002 +#endif + namespace animone::internal::xnu { bool EnumerateOpenProcesses(process_proc_t process_proc) { @@ -66,11 +78,9 @@ if (sz != PROC_PIDFDVNODEPATHINFO_SIZE) return false; - // This doesn't work (for unknown reasons). I assume somethings fucked up with - // my assumptions; I don't care enough to look into it tbh - // - // if (vnodeInfo.pfi.fi_openflags & O_WRONLY || vnodeInfo.pfi.fi_openflags & O_RDWR) - // continue; + /* why would a media player open a file in write mode? */ + if (vnodeInfo.pfi.fi_openflags & FWRITE) + continue; if (!open_file_proc({pid, vnodeInfo.pvip.vip_path})) return false;