mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 06:53:33 +00:00
Adds some NT functions
This commit is contained in:
parent
9f6bf6ea71
commit
4b11c2d832
10 changed files with 159 additions and 0 deletions
|
@ -1420,6 +1420,15 @@
|
|||
#define HKEY_CURRENT_CONFIG kNtHkeyCurrentConfig
|
||||
#define HKEY_DYN_DATA kNtHkeyDynData
|
||||
#define HKEY_CURRENT_USER_LOCAL_SETTINGS kNtHkeyCurrentUserLocalSettings
|
||||
#define KEY_QUERY_VALUE kNtKeyQueryValue
|
||||
#define KEY_SET_VALUE kNtKeySetValue
|
||||
#define KEY_CREATE_SUB_KEY kNtKeyCreateSubKey
|
||||
#define KEY_ENUMERATE_SUB_KEYS kNtKeyEnumerateSubKeys
|
||||
#define KEY_NOTIFY kNtKeyNotify
|
||||
#define KEY_CREATE_LINK kNtKeyCreateLink
|
||||
#define KEY_WOW64_32KEY kNtWow6432Key
|
||||
#define KEY_WOW64_64KEY kNtWow6464Key
|
||||
#define KEY_WOW64_RES kNtWow64Res
|
||||
#define KEY_READ kNtKeyRead
|
||||
#define KEY_WRITE kNtKeyWrite
|
||||
#define KEY_EXECUTE kNtKeyExecute
|
||||
|
@ -4291,6 +4300,13 @@
|
|||
#define MAKE_HRESULT(sev,fac,code) ((HRESULT) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) )
|
||||
#define MAKE_SCODE(sev,fac,code) ((SCODE) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) )
|
||||
|
||||
#define CP_ACP 0
|
||||
#define CP_OEMCP 1
|
||||
#define CP_MACCP 2
|
||||
#define CP_THREAD_ACP 3
|
||||
#define CP_SYMBOL 42
|
||||
|
||||
#define CP_UTF7 65000
|
||||
#define CP_UTF8 65001
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_COMPAT_INCLUDE_WINDOWS_H_ */
|
||||
|
|
18
libc/nt/advapi32/RegOpenKeyExA.S
Normal file
18
libc/nt/advapi32/RegOpenKeyExA.S
Normal file
|
@ -0,0 +1,18 @@
|
|||
#include "libc/nt/codegen.h"
|
||||
.imp advapi32,__imp_RegOpenKeyExA,RegOpenKeyExA
|
||||
|
||||
.text.windows
|
||||
.ftrace1
|
||||
RegOpenKeyExA:
|
||||
.ftrace2
|
||||
#ifdef __x86_64__
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
mov __imp_RegOpenKeyExA(%rip),%rax
|
||||
jmp __sysv2nt6
|
||||
#elif defined(__aarch64__)
|
||||
mov x0,#0
|
||||
ret
|
||||
#endif
|
||||
.endfn RegOpenKeyExA,globl
|
||||
.previous
|
|
@ -1,6 +1,16 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_NT_ENUM_KEYACCESS_H_
|
||||
#define COSMOPOLITAN_LIBC_NT_ENUM_KEYACCESS_H_
|
||||
|
||||
#define kNtKeyQueryValue 0x00000001
|
||||
#define kNtKeySetValue 0x00000002
|
||||
#define kNtKeyCreateSubKey 0x00000004
|
||||
#define kNtKeyEnumerateSubKeys 0x00000008
|
||||
#define kNtKeyNotify 0x00000010
|
||||
#define kNtKeyCreateLink 0x00000020
|
||||
#define kNtWow6432Key 0x00000200
|
||||
#define kNtWow6464Key 0x00000100
|
||||
#define kNtWow64Res 0x00000300
|
||||
|
||||
#define kNtKeyRead 0x00020019
|
||||
#define kNtKeyWrite 0x00020006
|
||||
#define kNtKeyExecute 0x00020019
|
||||
|
|
19
libc/nt/kernel32/GetACP.S
Normal file
19
libc/nt/kernel32/GetACP.S
Normal file
|
@ -0,0 +1,19 @@
|
|||
#include "libc/nt/codegen.h"
|
||||
.imp kernel32,__imp_GetACP,GetACP
|
||||
|
||||
.text.windows
|
||||
.ftrace1
|
||||
GetACP:
|
||||
.ftrace2
|
||||
#ifdef __x86_64__
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
sub $32,%rsp
|
||||
call *__imp_GetACP(%rip)
|
||||
leave
|
||||
#elif defined(__aarch64__)
|
||||
mov x0,#0
|
||||
#endif
|
||||
ret
|
||||
.endfn GetACP,globl
|
||||
.previous
|
18
libc/nt/kernel32/GetCPInfoExW.S
Normal file
18
libc/nt/kernel32/GetCPInfoExW.S
Normal file
|
@ -0,0 +1,18 @@
|
|||
#include "libc/nt/codegen.h"
|
||||
.imp kernel32,__imp_GetCPInfoExW,GetCPInfoExW
|
||||
|
||||
.text.windows
|
||||
.ftrace1
|
||||
GetCPInfoEx:
|
||||
.ftrace2
|
||||
#ifdef __x86_64__
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
mov __imp_GetCPInfoExW(%rip),%rax
|
||||
jmp __sysv2nt
|
||||
#elif defined(__aarch64__)
|
||||
mov x0,#0
|
||||
ret
|
||||
#endif
|
||||
.endfn GetCPInfoEx,globl
|
||||
.previous
|
18
libc/nt/kernel32/GetLogicalDriveStringsA.S
Normal file
18
libc/nt/kernel32/GetLogicalDriveStringsA.S
Normal file
|
@ -0,0 +1,18 @@
|
|||
#include "libc/nt/codegen.h"
|
||||
.imp kernel32,__imp_GetLogicalDriveStringsA,GetLogicalDriveStringsA
|
||||
|
||||
.text.windows
|
||||
.ftrace1
|
||||
GetLogicalDriveStringsA:
|
||||
.ftrace2
|
||||
#ifdef __x86_64__
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
mov __imp_GetLogicalDriveStringsA(%rip),%rax
|
||||
jmp __sysv2nt
|
||||
#elif defined(__aarch64__)
|
||||
mov x0,#0
|
||||
ret
|
||||
#endif
|
||||
.endfn GetLogicalDriveStringsA,globl
|
||||
.previous
|
19
libc/nt/kernel32/GetOEMCP.S
Normal file
19
libc/nt/kernel32/GetOEMCP.S
Normal file
|
@ -0,0 +1,19 @@
|
|||
#include "libc/nt/codegen.h"
|
||||
.imp kernel32,__imp_GetOEMCP,GetOEMCP
|
||||
|
||||
.text.windows
|
||||
.ftrace1
|
||||
GetOEMCP:
|
||||
.ftrace2
|
||||
#ifdef __x86_64__
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
sub $32,%rsp
|
||||
call *__imp_GetOEMCP(%rip)
|
||||
leave
|
||||
#elif defined(__aarch64__)
|
||||
mov x0,#0
|
||||
#endif
|
||||
ret
|
||||
.endfn GetOEMCP,globl
|
||||
.previous
|
18
libc/nt/kernel32/GetShortPathNameW.S
Normal file
18
libc/nt/kernel32/GetShortPathNameW.S
Normal file
|
@ -0,0 +1,18 @@
|
|||
#include "libc/nt/codegen.h"
|
||||
.imp kernel32,__imp_GetShortPathNameW,GetShortPathNameW
|
||||
|
||||
.text.windows
|
||||
.ftrace1
|
||||
GetShortPathName:
|
||||
.ftrace2
|
||||
#ifdef __x86_64__
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
mov __imp_GetShortPathNameW(%rip),%rax
|
||||
jmp __sysv2nt
|
||||
#elif defined(__aarch64__)
|
||||
mov x0,#0
|
||||
ret
|
||||
#endif
|
||||
.endfn GetShortPathName,globl
|
||||
.previous
|
|
@ -129,10 +129,12 @@ imp 'GetFileTime' GetFileTime kernel32 4
|
|||
imp 'GetFileType' GetFileType kernel32 1
|
||||
imp 'GetFinalPathNameByHandle' GetFinalPathNameByHandleW kernel32 4
|
||||
imp 'GetFullPathName' GetFullPathNameW kernel32 4
|
||||
imp 'GetShortPathName' GetShortPathNameW kernel32 3
|
||||
imp 'GetHandleInformation' GetHandleInformation kernel32 2
|
||||
imp 'GetLargestConsoleWindowSize' GetLargestConsoleWindowSize kernel32 1
|
||||
imp 'GetLastError' GetLastError kernel32 0
|
||||
imp 'GetLogicalDrives' GetLogicalDrives kernel32 0
|
||||
imp 'GetLogicalDriveStringsA' GetLogicalDriveStringsA kernel32 2
|
||||
imp 'GetMaximumProcessorCount' GetMaximumProcessorCount kernel32 1 # Windows 7+
|
||||
imp 'GetModuleFileName' GetModuleFileNameW kernel32 3
|
||||
imp 'GetModuleHandle' GetModuleHandleA kernel32 1
|
||||
|
@ -186,6 +188,9 @@ imp 'GetVolumeInformationByHandle' GetVolumeInformationByHandleW kernel32
|
|||
imp 'GetVolumePathName' GetVolumePathNameW kernel32 3
|
||||
imp 'GetWindowsDirectory' GetWindowsDirectoryW kernel32 2
|
||||
imp 'GetWindowsDirectoryA' GetWindowsDirectoryA kernel32 2
|
||||
imp 'GetOEMCP' GetOEMCP kernel32 0
|
||||
imp 'GetACP' GetACP kernel32 0
|
||||
imp 'GetCPInfoEx' GetCPInfoExW kernel32 3
|
||||
imp 'GlobalAlloc' GlobalAlloc kernel32 2
|
||||
imp 'GlobalFree' GlobalFree kernel32 1
|
||||
imp 'GlobalLock' GlobalLock kernel32 1
|
||||
|
@ -356,6 +361,7 @@ imp 'RegLoadKey' RegLoadKeyW advapi32 3
|
|||
imp 'RegNotifyChangeKeyValue' RegNotifyChangeKeyValue advapi32 5
|
||||
imp 'RegOpenCurrentUser' RegOpenCurrentUser advapi32 2
|
||||
imp 'RegOpenKeyEx' RegOpenKeyExW advapi32 5
|
||||
imp 'RegOpenKeyExA' RegOpenKeyExA advapi32 5
|
||||
imp 'RegOpenUserClassesRoot' RegOpenUserClassesRoot advapi32 4
|
||||
imp 'RegOverridePredefKey' RegOverridePredefKey advapi32 2
|
||||
imp 'RegQueryInfoKey' RegQueryInfoKeyW advapi32 12
|
||||
|
|
17
libc/nt/struct/cpinfoex.h
Normal file
17
libc/nt/struct/cpinfoex.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_NT_STRUCT_CPINFOEX_H_
|
||||
#define COSMOPOLITAN_LIBC_NT_STRUCT_CPINFOEX_H_
|
||||
|
||||
#define MAX_LEADBYTES 12
|
||||
#define MAX_DEFAULTCHAR 2
|
||||
#define MAX_PATH 260
|
||||
|
||||
struct NtCpInfoEx {
|
||||
uint32_t MaxCharSize;
|
||||
uint8_t DefaultChar[MAX_DEFAULTCHAR];
|
||||
uint8_t LeadByte[MAX_LEADBYTES];
|
||||
char16_t UnicodeDefaultChar;
|
||||
uint32_t CodePage;
|
||||
char16_t CodePageName[MAX_PATH]
|
||||
};
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_NT_STRUCT_CPINFOEX_H_ */
|
Loading…
Reference in a new issue