mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-12 22:19:10 +00:00
Add win32 apis
This commit is contained in:
parent
afc986f741
commit
6330b6826e
7 changed files with 87 additions and 0 deletions
|
@ -381,6 +381,9 @@
|
||||||
#define _FILE_STREAM_INFORMATION NtFileStreamInformation
|
#define _FILE_STREAM_INFORMATION NtFileStreamInformation
|
||||||
#define FILE_STREAM_INFORMATION struct NtFileStreamInformation
|
#define FILE_STREAM_INFORMATION struct NtFileStreamInformation
|
||||||
#define PFILE_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 NtKernelUserTimes
|
||||||
#define KERNEL_USER_TIMES struct NtKernelUserTimes
|
#define KERNEL_USER_TIMES struct NtKernelUserTimes
|
||||||
#define PKERNEL_USER_TIMES struct NtKernelUserTimes*
|
#define PKERNEL_USER_TIMES struct NtKernelUserTimes*
|
||||||
|
@ -1361,6 +1364,9 @@
|
||||||
|
|
||||||
#define WSAEVENT HANDLE
|
#define WSAEVENT HANDLE
|
||||||
#define GROUP uint32_t
|
#define GROUP uint32_t
|
||||||
|
#define _OVERLAPPED NtOverlapped
|
||||||
|
#define OVERLAPPED struct NtOverlapped
|
||||||
|
#define LOVERLAPPED struct NtOverlapped*
|
||||||
#define WSAOVERLAPPED OVERLAPPED
|
#define WSAOVERLAPPED OVERLAPPED
|
||||||
#define INVALID_SOCKET -1ULL
|
#define INVALID_SOCKET -1ULL
|
||||||
#define SOCKET_ERROR -1
|
#define SOCKET_ERROR -1
|
||||||
|
|
39
libc/nt/base.h
Normal file
39
libc/nt/base.h
Normal file
|
@ -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_ */
|
|
@ -49,6 +49,7 @@ COSMOPOLITAN_C_START_
|
||||||
intptr_t LoadResource(int64_t hModule, int64_t hResInfo);
|
intptr_t LoadResource(int64_t hModule, int64_t hResInfo);
|
||||||
uint32_t SetHandleCount(uint32_t uNumber);
|
uint32_t SetHandleCount(uint32_t uNumber);
|
||||||
uint32_t GetLogicalDrives(void);
|
uint32_t GetLogicalDrives(void);
|
||||||
|
unsigned int GetDriveTypeA(const char *lpRootPathName);
|
||||||
uint32_t GetLogicalDriveStringsA(uint32_t nBufferLength, char *lpBuffer);
|
uint32_t GetLogicalDriveStringsA(uint32_t nBufferLength, char *lpBuffer);
|
||||||
bool32 FlushFileBuffers(int64_t hFile);
|
bool32 FlushFileBuffers(int64_t hFile);
|
||||||
|
|
||||||
|
|
20
libc/nt/kernel32/GetDriveTypeA.S
Normal file
20
libc/nt/kernel32/GetDriveTypeA.S
Normal file
|
@ -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
libc/nt/kernel32/ReadDirectoryChangesW.S
Normal file
18
libc/nt/kernel32/ReadDirectoryChangesW.S
Normal file
|
@ -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
|
|
@ -117,6 +117,7 @@ imp 'GetCurrentProcessorNumberEx' GetCurrentProcessorNumberEx kernel32 1
|
||||||
imp 'GetCurrentThread' GetCurrentThread kernel32 0
|
imp 'GetCurrentThread' GetCurrentThread kernel32 0
|
||||||
imp 'GetCurrentThreadId' GetCurrentThreadId kernel32 0
|
imp 'GetCurrentThreadId' GetCurrentThreadId kernel32 0
|
||||||
imp 'GetDynamicTimeZoneInformation' GetDynamicTimeZoneInformation kernel32 1
|
imp 'GetDynamicTimeZoneInformation' GetDynamicTimeZoneInformation kernel32 1
|
||||||
|
imp 'GetDriveTypeA' GetDriveTypeA kernel32 1
|
||||||
imp 'GetEnvironmentStrings' GetEnvironmentStringsW kernel32 1
|
imp 'GetEnvironmentStrings' GetEnvironmentStringsW kernel32 1
|
||||||
imp 'GetEnvironmentVariable' GetEnvironmentVariableW kernel32 3
|
imp 'GetEnvironmentVariable' GetEnvironmentVariableW kernel32 3
|
||||||
imp 'GetExitCodeThread' GetExitCodeThread kernel32 2
|
imp 'GetExitCodeThread' GetExitCodeThread kernel32 2
|
||||||
|
@ -239,6 +240,7 @@ imp 'ReadConsoleOutputCharacter' ReadConsoleOutputCharacterW kernel32 5
|
||||||
imp 'ReadFile' ReadFile kernel32 5
|
imp 'ReadFile' ReadFile kernel32 5
|
||||||
imp 'ReadFileEx' ReadFileEx kernel32 5
|
imp 'ReadFileEx' ReadFileEx kernel32 5
|
||||||
imp 'ReadFileScatter' ReadFileScatter kernel32 5
|
imp 'ReadFileScatter' ReadFileScatter kernel32 5
|
||||||
|
imp 'ReadDirectoryChanges' ReadDirectoryChangesW kernel32 8
|
||||||
imp 'RegisterWaitForSingleObject' RegisterWaitForSingleObject kernel32 6
|
imp 'RegisterWaitForSingleObject' RegisterWaitForSingleObject kernel32 6
|
||||||
imp 'ReleaseMutex' ReleaseMutex kernel32 1
|
imp 'ReleaseMutex' ReleaseMutex kernel32 1
|
||||||
imp 'ReleaseSRWLockExclusive' ReleaseSRWLockExclusive kernel32 1
|
imp 'ReleaseSRWLockExclusive' ReleaseSRWLockExclusive kernel32 1
|
||||||
|
|
|
@ -94,6 +94,7 @@ int WideCharToMultiByte(unsigned int CodePage, uint32_t dwFlags,
|
||||||
uint16_t *lpWideCharStr, int cchWideChar,
|
uint16_t *lpWideCharStr, int cchWideChar,
|
||||||
char *lpMultiByteStr, int cbMultiByte,
|
char *lpMultiByteStr, int cbMultiByte,
|
||||||
uint16_t *lpDefaultChar, int *lpUsedDefaultChar);
|
uint16_t *lpDefaultChar, int *lpUsedDefaultChar);
|
||||||
|
int MutliByteToWideChar(unsigned int CodePage, uint32_t dwFlags, const char *lpMultiByteStr, int cbMultiByte, uint16_t *lpWideCharStr, int cchWideChar);
|
||||||
|
|
||||||
COSMOPOLITAN_C_END_
|
COSMOPOLITAN_C_END_
|
||||||
#endif /* COSMOPOLITAN_LIBC_NT_WINDOWS_H_ */
|
#endif /* COSMOPOLITAN_LIBC_NT_WINDOWS_H_ */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue