| #include <windows.h> |
| #include <nt.h> |
| //#include <errno.h> |
| #include <unistd.h> |
| |
| int read(int fd, void *buffer, size_t count) { |
| if(fd == STDOUT_FILENO || fd == STDERR_FILENO) { |
| //errno = EBADF; |
| return -1; |
| } |
| IO_STATUS_BLOCK io_status; |
| long int status = NtReadFile((void *)fd, NULL, NULL, NULL, &io_status, buffer, count, NULL, NULL); |
| //printf("nativelibc debug: read: status = 0x%lx\n", status); |
| //if(ntstatus_to_errno(status)) return -1; |
| if(status && status != STATUS_PENDING) return -1; // TODO: implemente the errno |
| return io_status.Information; |
| } |