IO redirection ᴾᴴᴾ - chung-leong/zigar GitHub Wiki
JavaScript | PHP
Hooks are install on the system functions listed below. Upon being called, a hook checks if the given file descriptor/handle points to a virtual file. If so, the call is redirected to PHP's stream wrapper sub-system. Otherwise it gets passed to the original function.
POSIX functions
- __fxstat
- __fxstat64
- __fxstatat
- __fxstatat64
- __getdirentries64
- __lxstat
- __lxstat64
- __xstat
- __xstat64
- access
- close
- closedir
- copy_file_range
- faccessat
- fallocate
- fchmod
- fchown
- fcntl
- fcntl64
- fdatasync
- flock
- fstat
- fstat64
- fstatat
- fstatat64
- fstatfs
- fstatfs64
- fsync
- ftruncate
- ftruncate64
- futimens
- futimes
- futimesat
- getenv
- isatty
- lseek
- lseek64
- lstat
- lstat64
- lutimes
- mkdir
- mkdirat
- mmap
- mmap64
- munmap
- open
- open64
- openat
- openat64
- opendir
- poll
- posix_fadvise
- posix_fallocate
- pread
- pread64
- preadv
- preadv64
- pthread_create
- pwrite
- pwrite64
- pwritev
- pwritev64
- read
- readdir
- readdir64
- readlink
- readlinkat
- readv
- rename
- renameat
- rewinddir
- rmdir
- seekdir
- sendfile
- sendfile64
- stat
- stat64
- symlink
- symlinkat
- telldir
- truncate
- truncate64
- ttyname
- ttyname_r
- unlink
- unlinkat
- utime
- utime64
- utimensat
- utimes
- write
- writev
Lib C functions:
- __fprintf_chk
- __isoc99_fscanf
- __isoc99_scanf
- __isoc99_vfscanf
- __isoc99_vscanf
- __printf_chk
- __vfprintf_chk
- __vprintf_chk
- clearerr
- fclose
- fdopen
- feof
- ferror
- fflush
- fgetc
- fgetpos
- fgets
- fileno
- fopen
- fprintf
- fputc
- fputs
- fread
- fscanf
- fseek
- fsetpos
- ftell
- fwrite
- getc
- getchar
- perror
- printf
- putc
- putchar
- puts
- realpath
- rewind
- scanf
- setbuf
- setvbuf
- ungetc
- vfprintf
- vfscanf
- vprintf
- vscanf
MSVC-specific functions
- __stdio_common_vfprintf
- __stdio_common_vfscanf
- _beginthread
- _beginthreadex
- _chsize
- _findclose
- _findfirst32
- _findfirst64
- _findnext32
- _findnext64
- _get_osfhandle
- _open_osfhandle
- futime
- futime64
- lseeki64
Windows API functions
- CloseHandle
- CreateDirectory
- CreateDirectoryW
- CreateFile
- CreateFileMapping
- CreateFileW
- CreateSymbolicLink
- CreateSymbolicLinkW
- CreateThread
- DeleteFile
- DeleteFileW
- FreeEnvironmentStrings
- FreeEnvironmentStringsW
- GetEnvironmentStrings
- GetEnvironmentStringsW
- GetEnvironmentVariable
- GetEnvironmentVariableW
- GetFileAttributes
- GetFileAttributesW
- GetFileInformationByHandle
- GetFileSize
- GetFileSizeEx
- GetHandleInformation
- LockFile
- LockFileEx
- MoveFile
- MoveFileEx
- MoveFileExW
- MoveFileW
- NtClose
- NtCreateFile
- NtFsControlFile
- NtLockFile
- NtQueryDirectoryFile
- NtQueryInformationFile
- NtQueryObject
- NtSetInformationFile
- NtUnlockFile
- ReadFile
- RemoveDirectory
- RemoveDirectoryW
- SetEndOfFile
- SetFilePointer
- SetFilePointerEx
- SetHandleInformation
- UnlockFile
- UnlockFileEx
- WriteFile
When the write target is stdout or stderr, output is redirect to the JavaScript console. You can
use __zigar.redirect() to redirect it to a stream of your choice.
By default, redirection only occurs for the code within the module's binary. Calls made by shared libraries that the module links to are unaffected. You have to use zigar.io.redirect() to manually activate redirection for individual libraries. This can be done safely only when library isn't actually shared.