Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions libc/isystem/windowsesque.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,9 @@
#define _FILE_STREAM_INFORMATION NtFileStreamInformation
#define FILE_STREAM_INFORMATION struct NtFileStreamInformation
#define PFILE_STREAM_INFORMATION struct NtFileStreamInformation*
#define _FILE_NOTIFY_INFORMATION NtFileNotifyInformation
#define FILE_NOTIFY_INFORMATION struct NtFileNotifyInformation
#define PFILE_NOTIFY_INFORMATION struct NtFileNotifyInformation*
#define _KERNEL_USER_TIMES NtKernelUserTimes
#define KERNEL_USER_TIMES struct NtKernelUserTimes
#define PKERNEL_USER_TIMES struct NtKernelUserTimes*
Expand Down Expand Up @@ -662,6 +665,16 @@
#define FILE_SHARE_WRITE kNtFileShareWrite
#define FILE_SHARE_DELETE kNtFileShareDelete

#include "libc/nt/enum/filenotify.h"
#define FILE_NOTIFY_CHANGE_FILE_NAME kNtFileNotifyChangeFileName
#define FILE_NOTIFY_CHANGE_DIR_NAME kNtFileNotifyChangeDirName
#define FILE_NOTIFY_CHANGE_ATTRIBUTES kNtFileNotifyChangeAttributes
#define FILE_NOTIFY_CHANGE_SIZE kNtFileNotifyChangeSize
#define FILE_NOTIFY_CHANGE_LAST_WRITE kNtFileNotifyChangeLastWrite
#define FILE_NOTIFY_CHANGE_LAST_ACCESS kNtFileNotifyChangeLastAccess
#define FILE_NOTIFY_CHANGE_CREATION kNtFileNotifyChangeCreation
#define FILE_NOTIFY_CHANGE_SECURITY kNtFileNotifyChangeSecurity

#include "libc/nt/runtime.h"
#define INVALID_HANDLE_VALUE kNtInvalidHandleValue
#define STD_INPUT_HANDLE kNtStdInputHandle
Expand Down Expand Up @@ -1361,6 +1374,9 @@

#define WSAEVENT HANDLE
#define GROUP uint32_t
#define _OVERLAPPED NtOverlapped
#define OVERLAPPED struct NtOverlapped
#define LOVERLAPPED struct NtOverlapped*
#define WSAOVERLAPPED OVERLAPPED
#define INVALID_SOCKET -1ULL
#define SOCKET_ERROR -1
Expand Down
39 changes: 39 additions & 0 deletions libc/nt/base.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#ifndef COSMOPOLITAN_LIBC_NT_BASE_H_
#define COSMOPOLITAN_LIBC_NT_BASE_H_
#include "struct/overlapped.h"
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » string ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
COSMOPOLITAN_C_START_

typedef void (*NtOverlappedCompletionRoutine)(
uint32_t dwErrorCode, uint32_t dwNumberOfBytesTransfered,
struct NtOverlapped *lpOverlapped);


uint32_t FormatMessageW(uint32_t dwFlags, const void* lpSource, uint32_t dwMessageId, uint32_t dwLanguageId, char16_t *lpBuffer, uint32_t nSize, va_list *Arguments);
bool32 ReadDirectoryChangesW(int64_t hDirectory, void *lpBuffer, uint32_t nBufferLength, bool32 bWatchSubtree, uint32_t dwNotifyFilter, uint32_t *lpBytesReturned, struct NtOverlapped *lpOverlapped, NtOverlappedCompletionRoutine lpCompletionRoutine);

COSMOPOLITAN_C_END_
#endif /* COSMOPOLITAN_LIBC_NT_BASE_H_ */
13 changes: 13 additions & 0 deletions libc/nt/enum/filenotify.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef COSMOPOLITAN_LIBC_NT_ENUM_FILENOTIFY_H_
#define COSMOPOLITAN_LIBC_NT_ENUM_FILENOTIFY_H_

#define kNtFileNotifyChangeFileName 0x00000001
#define kNtFileNotifyChangeDirName 0x00000002
#define kNtFileNotifyChangeAttributes 0x00000004
#define kNtFileNotifyChangeSize 0x00000008
#define kNtFileNotifyChangeLastWrite 0x00000010
#define kNtFileNotifyChangeLastAccess 0x00000020
#define kNtFileNotifyChangeCreation 0x00000040
#define kNtFileNotifyChangeSecurity 0x00000100

#endif /* COSMOPOLITAN_LIBC_NT_ENUM_FILENOTIFY_H_ */
1 change: 1 addition & 0 deletions libc/nt/files.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ COSMOPOLITAN_C_START_
intptr_t LoadResource(int64_t hModule, int64_t hResInfo);
uint32_t SetHandleCount(uint32_t uNumber);
uint32_t GetLogicalDrives(void);
unsigned int GetDriveTypeA(const char *lpRootPathName);
uint32_t GetLogicalDriveStringsA(uint32_t nBufferLength, char *lpBuffer);
bool32 FlushFileBuffers(int64_t hFile);

Expand Down
20 changes: 20 additions & 0 deletions libc/nt/kernel32/GetDriveTypeA.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "libc/nt/codegen.h"
.imp kernel32,__imp_GetDriveTypeA,GetDriveTypeA

.text.windows
.ftrace1
GetDriveTypeA:
.ftrace2
#ifdef __x86_64__
push %rbp
mov %rsp,%rbp
mov %rdi,%rcx
sub $32,%rsp
call *__imp_GetDriveTypeA(%rip)
leave
#elif defined(__aarch64__)
mov x0,#0
#endif
ret
.endfn GetDriveTypeA,globl
.previous
18 changes: 18 additions & 0 deletions libc/nt/kernel32/ReadDirectoryChangesW.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "libc/nt/codegen.h"
.imp kernel32,__imp_ReadDirectoryChangesW,ReadDirectoryChangesW

.text.windows
.ftrace1
ReadDirectoryChanges:
.ftrace2
#ifdef __x86_64__
push %rbp
mov %rsp,%rbp
mov __imp_ReadDirectoryChangesW(%rip),%rax
jmp __sysv2nt8
#elif defined(__aarch64__)
mov x0,#0
ret
#endif
.endfn ReadDirectoryChanges,globl
.previous
2 changes: 2 additions & 0 deletions libc/nt/master.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ imp 'GetCurrentProcessorNumberEx' GetCurrentProcessorNumberEx kernel32 1
imp 'GetCurrentThread' GetCurrentThread kernel32 0
imp 'GetCurrentThreadId' GetCurrentThreadId kernel32 0
imp 'GetDynamicTimeZoneInformation' GetDynamicTimeZoneInformation kernel32 1
imp 'GetDriveTypeA' GetDriveTypeA kernel32 1
imp 'GetEnvironmentStrings' GetEnvironmentStringsW kernel32 1
imp 'GetEnvironmentVariable' GetEnvironmentVariableW kernel32 3
imp 'GetExitCodeThread' GetExitCodeThread kernel32 2
Expand Down Expand Up @@ -239,6 +240,7 @@ imp 'ReadConsoleOutputCharacter' ReadConsoleOutputCharacterW kernel32 5
imp 'ReadFile' ReadFile kernel32 5
imp 'ReadFileEx' ReadFileEx kernel32 5
imp 'ReadFileScatter' ReadFileScatter kernel32 5
imp 'ReadDirectoryChanges' ReadDirectoryChangesW kernel32 8
imp 'RegisterWaitForSingleObject' RegisterWaitForSingleObject kernel32 6
imp 'ReleaseMutex' ReleaseMutex kernel32 1
imp 'ReleaseSRWLockExclusive' ReleaseSRWLockExclusive kernel32 1
Expand Down
1 change: 1 addition & 0 deletions libc/nt/windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ int WideCharToMultiByte(unsigned int CodePage, uint32_t dwFlags,
uint16_t *lpWideCharStr, int cchWideChar,
char *lpMultiByteStr, int cbMultiByte,
uint16_t *lpDefaultChar, int *lpUsedDefaultChar);
int MultiByteToWideChar(unsigned int CodePage, uint32_t dwFlags, const char *lpMultiByteStr, int cbMultiByte, uint16_t *lpWideCharStr, int cchWideChar);

COSMOPOLITAN_C_END_
#endif /* COSMOPOLITAN_LIBC_NT_WINDOWS_H_ */