From baad1df71d1d3c20d61edf2490274f07b00999b0 Mon Sep 17 00:00:00 2001 From: Bach Le Date: Mon, 28 Oct 2024 12:10:32 +0800 Subject: [PATCH] Add several NT functions (#1318) With these addtions, I could build and run a [sokol](https://github.com/floooh/sokol) application (using OpenGL) on both Linux and Windows. --- Makefile | 1 + libc/nt/BUILD.mk | 21 +++++++++++++++ libc/nt/gdi32/DescribePixelFormat.S | 18 +++++++++++++ libc/nt/kernel32/GlobalLock.S | 20 ++++++++++++++ libc/nt/kernel32/GlobalUnlock.S | 20 ++++++++++++++ libc/nt/master.sh | 34 ++++++++++++++++++++++++ libc/nt/shell32/CommandLineToArgvW.S | 18 +++++++++++++ libc/nt/shell32/DragAcceptFiles.S | 18 +++++++++++++ libc/nt/shell32/DragFinish.S | 20 ++++++++++++++ libc/nt/shell32/DragQueryFileW.S | 18 +++++++++++++ libc/nt/user32/AdjustWindowRectEx.S | 18 +++++++++++++ libc/nt/user32/ClientToScreen.S | 18 +++++++++++++ libc/nt/user32/ClipCursor.S | 20 ++++++++++++++ libc/nt/user32/CloseClipboard.S | 19 +++++++++++++ libc/nt/user32/EmptyClipboard.S | 19 +++++++++++++ libc/nt/user32/GetAsyncKeyState.S | 20 ++++++++++++++ libc/nt/user32/GetClipboardData.S | 20 ++++++++++++++ libc/nt/user32/GetMonitorInfoW.S | 18 +++++++++++++ libc/nt/user32/GetRawInputData.S | 18 +++++++++++++ libc/nt/user32/GetSystemMetrics.S | 20 ++++++++++++++ libc/nt/user32/MonitorFromPoint.S | 18 +++++++++++++ libc/nt/user32/MonitorFromWindow.S | 18 +++++++++++++ libc/nt/user32/OpenClipboard.S | 20 ++++++++++++++ libc/nt/user32/PostMessageW.S | 18 +++++++++++++ libc/nt/user32/PtInRect.S | 18 +++++++++++++ libc/nt/user32/RegisterRawInputDevices.S | 18 +++++++++++++ libc/nt/user32/ScreenToClient.S | 18 +++++++++++++ libc/nt/user32/SetClipboardData.S | 18 +++++++++++++ libc/nt/user32/SetCursorPos.S | 18 +++++++++++++ libc/nt/user32/SetWindowLongPtrW.S | 18 +++++++++++++ libc/nt/user32/TrackMouseEvent.S | 20 ++++++++++++++ libc/nt/user32/UnregisterClassW.S | 18 +++++++++++++ libc/nt/user32/WindowFromPoint.S | 20 ++++++++++++++ 33 files changed, 618 insertions(+) create mode 100644 libc/nt/gdi32/DescribePixelFormat.S create mode 100644 libc/nt/kernel32/GlobalLock.S create mode 100644 libc/nt/kernel32/GlobalUnlock.S create mode 100644 libc/nt/shell32/CommandLineToArgvW.S create mode 100644 libc/nt/shell32/DragAcceptFiles.S create mode 100644 libc/nt/shell32/DragFinish.S create mode 100644 libc/nt/shell32/DragQueryFileW.S create mode 100644 libc/nt/user32/AdjustWindowRectEx.S create mode 100644 libc/nt/user32/ClientToScreen.S create mode 100644 libc/nt/user32/ClipCursor.S create mode 100644 libc/nt/user32/CloseClipboard.S create mode 100644 libc/nt/user32/EmptyClipboard.S create mode 100644 libc/nt/user32/GetAsyncKeyState.S create mode 100644 libc/nt/user32/GetClipboardData.S create mode 100644 libc/nt/user32/GetMonitorInfoW.S create mode 100644 libc/nt/user32/GetRawInputData.S create mode 100644 libc/nt/user32/GetSystemMetrics.S create mode 100644 libc/nt/user32/MonitorFromPoint.S create mode 100644 libc/nt/user32/MonitorFromWindow.S create mode 100644 libc/nt/user32/OpenClipboard.S create mode 100644 libc/nt/user32/PostMessageW.S create mode 100644 libc/nt/user32/PtInRect.S create mode 100644 libc/nt/user32/RegisterRawInputDevices.S create mode 100644 libc/nt/user32/ScreenToClient.S create mode 100644 libc/nt/user32/SetClipboardData.S create mode 100644 libc/nt/user32/SetCursorPos.S create mode 100644 libc/nt/user32/SetWindowLongPtrW.S create mode 100644 libc/nt/user32/TrackMouseEvent.S create mode 100644 libc/nt/user32/UnregisterClassW.S create mode 100644 libc/nt/user32/WindowFromPoint.S diff --git a/Makefile b/Makefile index 5395271c691..deae0312f29 100644 --- a/Makefile +++ b/Makefile @@ -449,6 +449,7 @@ COSMOPOLITAN = \ LIBC_NT_BCRYPTPRIMITIVES \ LIBC_NT_COMDLG32 \ LIBC_NT_GDI32 \ + LIBC_NT_SHELL32 \ LIBC_NT_IPHLPAPI \ LIBC_NT_KERNEL32 \ LIBC_NT_NTDLL \ diff --git a/libc/nt/BUILD.mk b/libc/nt/BUILD.mk index 7e96e946787..b5660d1be6a 100644 --- a/libc/nt/BUILD.mk +++ b/libc/nt/BUILD.mk @@ -91,6 +91,27 @@ $(LIBC_NT_COMDLG32_A).pkg: \ #─────────────────────────────────────────────────────────────────────────────── +LIBC_NT_ARTIFACTS += LIBC_NT_SHELL32_A +LIBC_NT_SHELL32 = $(LIBC_NT_SHELL32_A_DEPS) $(LIBC_NT_SHELL32_A) +LIBC_NT_SHELL32_A = o/$(MODE)/libc/nt/shell32.a +LIBC_NT_SHELL32_A_SRCS := $(wildcard libc/nt/shell32/*.S) +LIBC_NT_SHELL32_A_OBJS = $(LIBC_NT_SHELL32_A_SRCS:%.S=o/$(MODE)/%.o) +LIBC_NT_SHELL32_A_CHECKS = $(LIBC_NT_SHELL32_A).pkg +LIBC_NT_SHELL32_A_DIRECTDEPS = LIBC_NT_KERNEL32 +LIBC_NT_SHELL32_A_DEPS := \ + $(call uniq,$(foreach x,$(LIBC_NT_SHELL32_A_DIRECTDEPS),$($(x)))) + +$(LIBC_NT_SHELL32_A): \ + libc/nt/shell32/ \ + $(LIBC_NT_SHELL32_A).pkg \ + $(LIBC_NT_SHELL32_A_OBJS) + +$(LIBC_NT_SHELL32_A).pkg: \ + $(LIBC_NT_SHELL32_A_OBJS) \ + $(foreach x,$(LIBC_NT_SHELL32_A_DIRECTDEPS),$($(x)_A).pkg) + +#─────────────────────────────────────────────────────────────────────────────── + LIBC_NT_ARTIFACTS += LIBC_NT_GDI32_A LIBC_NT_GDI32 = $(LIBC_NT_GDI32_A_DEPS) $(LIBC_NT_GDI32_A) LIBC_NT_GDI32_A = o/$(MODE)/libc/nt/gdi32.a diff --git a/libc/nt/gdi32/DescribePixelFormat.S b/libc/nt/gdi32/DescribePixelFormat.S new file mode 100644 index 00000000000..44b3dc7463c --- /dev/null +++ b/libc/nt/gdi32/DescribePixelFormat.S @@ -0,0 +1,18 @@ +#include "libc/nt/codegen.h" +.imp gdi32,__imp_DescribePixelFormat,DescribePixelFormat + + .text.windows + .ftrace1 +DescribePixelFormat: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov __imp_DescribePixelFormat(%rip),%rax + jmp __sysv2nt +#elif defined(__aarch64__) + mov x0,#0 + ret +#endif + .endfn DescribePixelFormat,globl + .previous diff --git a/libc/nt/kernel32/GlobalLock.S b/libc/nt/kernel32/GlobalLock.S new file mode 100644 index 00000000000..1407a442732 --- /dev/null +++ b/libc/nt/kernel32/GlobalLock.S @@ -0,0 +1,20 @@ +#include "libc/nt/codegen.h" +.imp kernel32,__imp_GlobalLock,GlobalLock + + .text.windows + .ftrace1 +GlobalLock: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov %rdi,%rcx + sub $32,%rsp + call *__imp_GlobalLock(%rip) + leave +#elif defined(__aarch64__) + mov x0,#0 +#endif + ret + .endfn GlobalLock,globl + .previous diff --git a/libc/nt/kernel32/GlobalUnlock.S b/libc/nt/kernel32/GlobalUnlock.S new file mode 100644 index 00000000000..b9ba550f8a8 --- /dev/null +++ b/libc/nt/kernel32/GlobalUnlock.S @@ -0,0 +1,20 @@ +#include "libc/nt/codegen.h" +.imp kernel32,__imp_GlobalUnlock,GlobalUnlock + + .text.windows + .ftrace1 +GlobalUnlock: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov %rdi,%rcx + sub $32,%rsp + call *__imp_GlobalUnlock(%rip) + leave +#elif defined(__aarch64__) + mov x0,#0 +#endif + ret + .endfn GlobalUnlock,globl + .previous diff --git a/libc/nt/master.sh b/libc/nt/master.sh index 5a4fbf4025f..ce8d5ed515b 100755 --- a/libc/nt/master.sh +++ b/libc/nt/master.sh @@ -186,6 +186,8 @@ imp 'GetWindowsDirectoryA' GetWindowsDirectoryA kernel32 2 imp 'GlobalAlloc' GlobalAlloc kernel32 2 imp 'GlobalFree' GlobalFree kernel32 1 imp 'GlobalMemoryStatusEx' GlobalMemoryStatusEx kernel32 1 +imp 'GlobalLock' GlobalLock kernel32 1 +imp 'GlobalUnlock' GlobalUnlock kernel32 1 imp 'HeapAlloc' HeapAlloc kernel32 3 imp 'HeapCompact' HeapCompact kernel32 2 imp 'HeapCreate' HeapCreate kernel32 3 @@ -376,6 +378,7 @@ imp 'TraceSetInformation' TraceSetInformation advapi32 # Windows 7+ # # Name Actual DLL Arity imp 'AdjustWindowRect' AdjustWindowRect user32 3 +imp 'AdjustWindowRectEx' AdjustWindowRectEx user32 4 imp 'AnimateWindow' AnimateWindow user32 3 imp 'AppendMenuA' AppendMenuA user32 4 imp 'AppendMenu' AppendMenuW user32 4 @@ -383,6 +386,9 @@ imp 'BeginPaint' BeginPaint user32 2 imp 'BringWindowToTop' BringWindowToTop user32 1 imp 'CallNextHookEx' CallNextHookEx user32 4 imp 'CloseWindow' CloseWindow user32 1 +imp 'ClientToScreen' ClientToScreen user32 2 +imp 'ClipCursor' ClipCursor user32 1 +imp 'CloseClipboard' CloseClipboard user32 0 imp 'CreateIconIndirect' CreateIconIndirect user32 1 imp 'CreateMenu' CreateMenu user32 0 imp 'CreatePopupMenu' CreatePopupMenu user32 0 @@ -395,12 +401,15 @@ imp 'DestroyWindow' DestroyWindow user32 1 imp 'DispatchMessage' DispatchMessageW user32 1 imp 'DrawText' DrawTextW user32 5 imp 'DrawTextEx' DrawTextExW user32 6 +imp 'EmptyClipboard' EmptyClipboard user32 0 imp 'EndPaint' EndPaint user32 2 imp 'EnumChildWindows' EnumChildWindows user32 3 imp 'FillRect' FillRect user32 3 imp 'FindWindow' FindWindowW user32 2 imp 'FindWindowEx' FindWindowExW user32 4 +imp 'GetAsyncKeyState' GetAsyncKeyState user32 1 imp 'GetClientRect' GetClientRect user32 2 +imp 'GetClipboardData' GetClipboardData user32 1 imp 'GetCursor' GetCursor user32 0 imp 'GetCursorPos' GetCursorPos user32 1 imp 'GetDC' GetDC user32 1 @@ -409,9 +418,12 @@ imp 'GetKeyState' GetKeyState user32 1 imp 'GetKeyboardLayout' GetKeyboardLayout user32 1 imp 'GetMenu' GetMenu user32 1 imp 'GetMessage' GetMessageW user32 4 +imp 'GetMonitorInfo' GetMonitorInfoW user32 2 +imp 'GetRawInputData' GetRawInputData user32 5 imp 'GetParent' GetParent user32 1 imp 'GetShellWindow' GetShellWindow user32 0 imp 'GetSystemMenu' GetSystemMenu user32 2 +imp 'GetSystemMetrics' GetSystemMetrics user32 1 imp 'GetWindow' GetWindow user32 2 imp 'GetWindowPlacement' GetWindowPlacement user32 2 imp 'GetWindowRect' GetWindowRect user32 2 @@ -432,13 +444,22 @@ imp 'MapVirtualKeyEx' MapVirtualKeyExW user32 3 imp 'MessageBox' MessageBoxW user32 4 imp 'MessageBoxEx' MessageBoxExW user32 5 imp 'MoveWindow' MoveWindow user32 6 +imp 'MonitorFromPoint' MonitorFromPoint user32 2 +imp 'MonitorFromWindow' MonitorFromWindow user32 2 +imp 'OpenClipboard' OpenClipboard user32 1 imp 'PeekMessage' PeekMessageW user32 5 +imp 'PostMessage' PostMessageW user32 4 imp 'PostQuitMessage' PostQuitMessage user32 1 +imp 'PtInRect' PtInRect user32 2 imp 'RedrawWindow' RedrawWindow user32 4 imp 'RegisterClass' RegisterClassW user32 1 imp 'RegisterClassEx' RegisterClassExW user32 1 +imp 'RegisterRawInputDevices' RegisterRawInputDevices user32 3 imp 'ReleaseCapture' ReleaseCapture user32 0 imp 'ReleaseDC' ReleaseDC user32 2 +imp 'ScreenToClient' ScreenToClient user32 2 +imp 'SetClipboardData' SetClipboardData user32 2 +imp 'SetCursorPos' SetCursorPos user32 2 imp 'SendMessage' SendMessageW user32 4 imp 'SetCapture' SetCapture user32 1 imp 'SetClassLong' SetClassLongW user32 3 @@ -446,6 +467,7 @@ imp 'SetCursor' SetCursor user32 1 imp 'SetParent' SetParent user32 2 imp 'SetTimer' SetTimer user32 4 imp 'SetWindowLong' SetWindowLongW user32 3 +imp 'SetWindowLongPtr' SetWindowLongPtrW user32 3 imp 'SetWindowPlacement' SetWindowPlacement user32 2 imp 'SetWindowPos' SetWindowPos user32 7 imp 'SetWindowText' SetWindowTextW user32 2 @@ -454,12 +476,23 @@ imp 'SetWindowsHookEx' SetWindowsHookExW user32 4 imp 'ShowCaret' ShowCaret user32 1 imp 'ShowCursor' ShowCursor user32 1 imp 'ShowWindow' ShowWindow user32 2 +imp 'TrackMouseEvent' TrackMouseEvent user32 1 imp 'TrackPopupMenu' TrackPopupMenu user32 7 imp 'TranslateMessage' TranslateMessage user32 1 imp 'UnhookWindowsHook' UnhookWindowsHook user32 2 imp 'UnhookWindowsHookEx' UnhookWindowsHookEx user32 1 +imp 'UnregisterClass' UnregisterClassW user32 2 imp 'UpdateWindow' UpdateWindow user32 1 imp 'WaitForInputIdle' WaitForInputIdle user32 2 +imp 'WindowFromPoint' WindowFromPoint user32 1 + +# SHELL32.DLL +# +# Name Actual DLL Arity +imp 'CommandLineToArgv' CommandLineToArgvW shell32 2 +imp 'DragAcceptFiles' DragAcceptFiles shell32 2 +imp 'DragFinish' DragFinish shell32 1 +imp 'DragQueryFile' DragQueryFileW shell32 4 # GDI32.DLL # @@ -473,6 +506,7 @@ imp 'CreateDIBSection' CreateDIBSection gdi32 6 imp 'CreateRectRgn' CreateRectRgn gdi32 4 imp 'DeleteDC' DeleteDC gdi32 1 imp 'DeleteObject' DeleteObject gdi32 1 +imp 'DescribePixelFormat' DescribePixelFormat gdi32 4 imp 'GetPixel' GetPixel gdi32 3 imp 'RestoreDC' RestoreDC gdi32 2 imp 'SaveDC' SaveDC gdi32 1 diff --git a/libc/nt/shell32/CommandLineToArgvW.S b/libc/nt/shell32/CommandLineToArgvW.S new file mode 100644 index 00000000000..ef2f711002a --- /dev/null +++ b/libc/nt/shell32/CommandLineToArgvW.S @@ -0,0 +1,18 @@ +#include "libc/nt/codegen.h" +.imp shell32,__imp_CommandLineToArgvW,CommandLineToArgvW + + .text.windows + .ftrace1 +CommandLineToArgv: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov __imp_CommandLineToArgvW(%rip),%rax + jmp __sysv2nt +#elif defined(__aarch64__) + mov x0,#0 + ret +#endif + .endfn CommandLineToArgv,globl + .previous diff --git a/libc/nt/shell32/DragAcceptFiles.S b/libc/nt/shell32/DragAcceptFiles.S new file mode 100644 index 00000000000..2c3c78775e4 --- /dev/null +++ b/libc/nt/shell32/DragAcceptFiles.S @@ -0,0 +1,18 @@ +#include "libc/nt/codegen.h" +.imp shell32,__imp_DragAcceptFiles,DragAcceptFiles + + .text.windows + .ftrace1 +DragAcceptFiles: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov __imp_DragAcceptFiles(%rip),%rax + jmp __sysv2nt +#elif defined(__aarch64__) + mov x0,#0 + ret +#endif + .endfn DragAcceptFiles,globl + .previous diff --git a/libc/nt/shell32/DragFinish.S b/libc/nt/shell32/DragFinish.S new file mode 100644 index 00000000000..5bb00758e62 --- /dev/null +++ b/libc/nt/shell32/DragFinish.S @@ -0,0 +1,20 @@ +#include "libc/nt/codegen.h" +.imp shell32,__imp_DragFinish,DragFinish + + .text.windows + .ftrace1 +DragFinish: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov %rdi,%rcx + sub $32,%rsp + call *__imp_DragFinish(%rip) + leave +#elif defined(__aarch64__) + mov x0,#0 +#endif + ret + .endfn DragFinish,globl + .previous diff --git a/libc/nt/shell32/DragQueryFileW.S b/libc/nt/shell32/DragQueryFileW.S new file mode 100644 index 00000000000..efec6118d9c --- /dev/null +++ b/libc/nt/shell32/DragQueryFileW.S @@ -0,0 +1,18 @@ +#include "libc/nt/codegen.h" +.imp shell32,__imp_DragQueryFileW,DragQueryFileW + + .text.windows + .ftrace1 +DragQueryFile: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov __imp_DragQueryFileW(%rip),%rax + jmp __sysv2nt +#elif defined(__aarch64__) + mov x0,#0 + ret +#endif + .endfn DragQueryFile,globl + .previous diff --git a/libc/nt/user32/AdjustWindowRectEx.S b/libc/nt/user32/AdjustWindowRectEx.S new file mode 100644 index 00000000000..04416b2113f --- /dev/null +++ b/libc/nt/user32/AdjustWindowRectEx.S @@ -0,0 +1,18 @@ +#include "libc/nt/codegen.h" +.imp user32,__imp_AdjustWindowRectEx,AdjustWindowRectEx + + .text.windows + .ftrace1 +AdjustWindowRectEx: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov __imp_AdjustWindowRectEx(%rip),%rax + jmp __sysv2nt +#elif defined(__aarch64__) + mov x0,#0 + ret +#endif + .endfn AdjustWindowRectEx,globl + .previous diff --git a/libc/nt/user32/ClientToScreen.S b/libc/nt/user32/ClientToScreen.S new file mode 100644 index 00000000000..9bc45dee828 --- /dev/null +++ b/libc/nt/user32/ClientToScreen.S @@ -0,0 +1,18 @@ +#include "libc/nt/codegen.h" +.imp user32,__imp_ClientToScreen,ClientToScreen + + .text.windows + .ftrace1 +ClientToScreen: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov __imp_ClientToScreen(%rip),%rax + jmp __sysv2nt +#elif defined(__aarch64__) + mov x0,#0 + ret +#endif + .endfn ClientToScreen,globl + .previous diff --git a/libc/nt/user32/ClipCursor.S b/libc/nt/user32/ClipCursor.S new file mode 100644 index 00000000000..f2c7f19ec9a --- /dev/null +++ b/libc/nt/user32/ClipCursor.S @@ -0,0 +1,20 @@ +#include "libc/nt/codegen.h" +.imp user32,__imp_ClipCursor,ClipCursor + + .text.windows + .ftrace1 +ClipCursor: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov %rdi,%rcx + sub $32,%rsp + call *__imp_ClipCursor(%rip) + leave +#elif defined(__aarch64__) + mov x0,#0 +#endif + ret + .endfn ClipCursor,globl + .previous diff --git a/libc/nt/user32/CloseClipboard.S b/libc/nt/user32/CloseClipboard.S new file mode 100644 index 00000000000..b57e8202295 --- /dev/null +++ b/libc/nt/user32/CloseClipboard.S @@ -0,0 +1,19 @@ +#include "libc/nt/codegen.h" +.imp user32,__imp_CloseClipboard,CloseClipboard + + .text.windows + .ftrace1 +CloseClipboard: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + sub $32,%rsp + call *__imp_CloseClipboard(%rip) + leave +#elif defined(__aarch64__) + mov x0,#0 +#endif + ret + .endfn CloseClipboard,globl + .previous diff --git a/libc/nt/user32/EmptyClipboard.S b/libc/nt/user32/EmptyClipboard.S new file mode 100644 index 00000000000..6038d29daa6 --- /dev/null +++ b/libc/nt/user32/EmptyClipboard.S @@ -0,0 +1,19 @@ +#include "libc/nt/codegen.h" +.imp user32,__imp_EmptyClipboard,EmptyClipboard + + .text.windows + .ftrace1 +EmptyClipboard: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + sub $32,%rsp + call *__imp_EmptyClipboard(%rip) + leave +#elif defined(__aarch64__) + mov x0,#0 +#endif + ret + .endfn EmptyClipboard,globl + .previous diff --git a/libc/nt/user32/GetAsyncKeyState.S b/libc/nt/user32/GetAsyncKeyState.S new file mode 100644 index 00000000000..9b1d32e1db6 --- /dev/null +++ b/libc/nt/user32/GetAsyncKeyState.S @@ -0,0 +1,20 @@ +#include "libc/nt/codegen.h" +.imp user32,__imp_GetAsyncKeyState,GetAsyncKeyState + + .text.windows + .ftrace1 +GetAsyncKeyState: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov %rdi,%rcx + sub $32,%rsp + call *__imp_GetAsyncKeyState(%rip) + leave +#elif defined(__aarch64__) + mov x0,#0 +#endif + ret + .endfn GetAsyncKeyState,globl + .previous diff --git a/libc/nt/user32/GetClipboardData.S b/libc/nt/user32/GetClipboardData.S new file mode 100644 index 00000000000..b51af7d3a72 --- /dev/null +++ b/libc/nt/user32/GetClipboardData.S @@ -0,0 +1,20 @@ +#include "libc/nt/codegen.h" +.imp user32,__imp_GetClipboardData,GetClipboardData + + .text.windows + .ftrace1 +GetClipboardData: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov %rdi,%rcx + sub $32,%rsp + call *__imp_GetClipboardData(%rip) + leave +#elif defined(__aarch64__) + mov x0,#0 +#endif + ret + .endfn GetClipboardData,globl + .previous diff --git a/libc/nt/user32/GetMonitorInfoW.S b/libc/nt/user32/GetMonitorInfoW.S new file mode 100644 index 00000000000..2ec6986fe85 --- /dev/null +++ b/libc/nt/user32/GetMonitorInfoW.S @@ -0,0 +1,18 @@ +#include "libc/nt/codegen.h" +.imp user32,__imp_GetMonitorInfoW,GetMonitorInfoW + + .text.windows + .ftrace1 +GetMonitorInfo: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov __imp_GetMonitorInfoW(%rip),%rax + jmp __sysv2nt +#elif defined(__aarch64__) + mov x0,#0 + ret +#endif + .endfn GetMonitorInfo,globl + .previous diff --git a/libc/nt/user32/GetRawInputData.S b/libc/nt/user32/GetRawInputData.S new file mode 100644 index 00000000000..6324125ea6a --- /dev/null +++ b/libc/nt/user32/GetRawInputData.S @@ -0,0 +1,18 @@ +#include "libc/nt/codegen.h" +.imp user32,__imp_GetRawInputData,GetRawInputData + + .text.windows + .ftrace1 +GetRawInputData: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov __imp_GetRawInputData(%rip),%rax + jmp __sysv2nt6 +#elif defined(__aarch64__) + mov x0,#0 + ret +#endif + .endfn GetRawInputData,globl + .previous diff --git a/libc/nt/user32/GetSystemMetrics.S b/libc/nt/user32/GetSystemMetrics.S new file mode 100644 index 00000000000..4a92d3184ce --- /dev/null +++ b/libc/nt/user32/GetSystemMetrics.S @@ -0,0 +1,20 @@ +#include "libc/nt/codegen.h" +.imp user32,__imp_GetSystemMetrics,GetSystemMetrics + + .text.windows + .ftrace1 +GetSystemMetrics: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov %rdi,%rcx + sub $32,%rsp + call *__imp_GetSystemMetrics(%rip) + leave +#elif defined(__aarch64__) + mov x0,#0 +#endif + ret + .endfn GetSystemMetrics,globl + .previous diff --git a/libc/nt/user32/MonitorFromPoint.S b/libc/nt/user32/MonitorFromPoint.S new file mode 100644 index 00000000000..b27b7a8aaa0 --- /dev/null +++ b/libc/nt/user32/MonitorFromPoint.S @@ -0,0 +1,18 @@ +#include "libc/nt/codegen.h" +.imp user32,__imp_MonitorFromPoint,MonitorFromPoint + + .text.windows + .ftrace1 +MonitorFromPoint: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov __imp_MonitorFromPoint(%rip),%rax + jmp __sysv2nt +#elif defined(__aarch64__) + mov x0,#0 + ret +#endif + .endfn MonitorFromPoint,globl + .previous diff --git a/libc/nt/user32/MonitorFromWindow.S b/libc/nt/user32/MonitorFromWindow.S new file mode 100644 index 00000000000..ec49593a418 --- /dev/null +++ b/libc/nt/user32/MonitorFromWindow.S @@ -0,0 +1,18 @@ +#include "libc/nt/codegen.h" +.imp user32,__imp_MonitorFromWindow,MonitorFromWindow + + .text.windows + .ftrace1 +MonitorFromWindow: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov __imp_MonitorFromWindow(%rip),%rax + jmp __sysv2nt +#elif defined(__aarch64__) + mov x0,#0 + ret +#endif + .endfn MonitorFromWindow,globl + .previous diff --git a/libc/nt/user32/OpenClipboard.S b/libc/nt/user32/OpenClipboard.S new file mode 100644 index 00000000000..f6b8afb7e3c --- /dev/null +++ b/libc/nt/user32/OpenClipboard.S @@ -0,0 +1,20 @@ +#include "libc/nt/codegen.h" +.imp user32,__imp_OpenClipboard,OpenClipboard + + .text.windows + .ftrace1 +OpenClipboard: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov %rdi,%rcx + sub $32,%rsp + call *__imp_OpenClipboard(%rip) + leave +#elif defined(__aarch64__) + mov x0,#0 +#endif + ret + .endfn OpenClipboard,globl + .previous diff --git a/libc/nt/user32/PostMessageW.S b/libc/nt/user32/PostMessageW.S new file mode 100644 index 00000000000..5da8cf132c7 --- /dev/null +++ b/libc/nt/user32/PostMessageW.S @@ -0,0 +1,18 @@ +#include "libc/nt/codegen.h" +.imp user32,__imp_PostMessageW,PostMessageW + + .text.windows + .ftrace1 +PostMessage: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov __imp_PostMessageW(%rip),%rax + jmp __sysv2nt +#elif defined(__aarch64__) + mov x0,#0 + ret +#endif + .endfn PostMessage,globl + .previous diff --git a/libc/nt/user32/PtInRect.S b/libc/nt/user32/PtInRect.S new file mode 100644 index 00000000000..3a3ae8c38b2 --- /dev/null +++ b/libc/nt/user32/PtInRect.S @@ -0,0 +1,18 @@ +#include "libc/nt/codegen.h" +.imp user32,__imp_PtInRect,PtInRect + + .text.windows + .ftrace1 +PtInRect: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov __imp_PtInRect(%rip),%rax + jmp __sysv2nt +#elif defined(__aarch64__) + mov x0,#0 + ret +#endif + .endfn PtInRect,globl + .previous diff --git a/libc/nt/user32/RegisterRawInputDevices.S b/libc/nt/user32/RegisterRawInputDevices.S new file mode 100644 index 00000000000..9f100d2446a --- /dev/null +++ b/libc/nt/user32/RegisterRawInputDevices.S @@ -0,0 +1,18 @@ +#include "libc/nt/codegen.h" +.imp user32,__imp_RegisterRawInputDevices,RegisterRawInputDevices + + .text.windows + .ftrace1 +RegisterRawInputDevices: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov __imp_RegisterRawInputDevices(%rip),%rax + jmp __sysv2nt +#elif defined(__aarch64__) + mov x0,#0 + ret +#endif + .endfn RegisterRawInputDevices,globl + .previous diff --git a/libc/nt/user32/ScreenToClient.S b/libc/nt/user32/ScreenToClient.S new file mode 100644 index 00000000000..3c1d2ca54a6 --- /dev/null +++ b/libc/nt/user32/ScreenToClient.S @@ -0,0 +1,18 @@ +#include "libc/nt/codegen.h" +.imp user32,__imp_ScreenToClient,ScreenToClient + + .text.windows + .ftrace1 +ScreenToClient: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov __imp_ScreenToClient(%rip),%rax + jmp __sysv2nt +#elif defined(__aarch64__) + mov x0,#0 + ret +#endif + .endfn ScreenToClient,globl + .previous diff --git a/libc/nt/user32/SetClipboardData.S b/libc/nt/user32/SetClipboardData.S new file mode 100644 index 00000000000..ca8e59591d5 --- /dev/null +++ b/libc/nt/user32/SetClipboardData.S @@ -0,0 +1,18 @@ +#include "libc/nt/codegen.h" +.imp user32,__imp_SetClipboardData,SetClipboardData + + .text.windows + .ftrace1 +SetClipboardData: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov __imp_SetClipboardData(%rip),%rax + jmp __sysv2nt +#elif defined(__aarch64__) + mov x0,#0 + ret +#endif + .endfn SetClipboardData,globl + .previous diff --git a/libc/nt/user32/SetCursorPos.S b/libc/nt/user32/SetCursorPos.S new file mode 100644 index 00000000000..f2984788498 --- /dev/null +++ b/libc/nt/user32/SetCursorPos.S @@ -0,0 +1,18 @@ +#include "libc/nt/codegen.h" +.imp user32,__imp_SetCursorPos,SetCursorPos + + .text.windows + .ftrace1 +SetCursorPos: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov __imp_SetCursorPos(%rip),%rax + jmp __sysv2nt +#elif defined(__aarch64__) + mov x0,#0 + ret +#endif + .endfn SetCursorPos,globl + .previous diff --git a/libc/nt/user32/SetWindowLongPtrW.S b/libc/nt/user32/SetWindowLongPtrW.S new file mode 100644 index 00000000000..3ff044c0520 --- /dev/null +++ b/libc/nt/user32/SetWindowLongPtrW.S @@ -0,0 +1,18 @@ +#include "libc/nt/codegen.h" +.imp user32,__imp_SetWindowLongPtrW,SetWindowLongPtrW + + .text.windows + .ftrace1 +SetWindowLongPtr: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov __imp_SetWindowLongPtrW(%rip),%rax + jmp __sysv2nt +#elif defined(__aarch64__) + mov x0,#0 + ret +#endif + .endfn SetWindowLongPtr,globl + .previous diff --git a/libc/nt/user32/TrackMouseEvent.S b/libc/nt/user32/TrackMouseEvent.S new file mode 100644 index 00000000000..7220d178a20 --- /dev/null +++ b/libc/nt/user32/TrackMouseEvent.S @@ -0,0 +1,20 @@ +#include "libc/nt/codegen.h" +.imp user32,__imp_TrackMouseEvent,TrackMouseEvent + + .text.windows + .ftrace1 +TrackMouseEvent: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov %rdi,%rcx + sub $32,%rsp + call *__imp_TrackMouseEvent(%rip) + leave +#elif defined(__aarch64__) + mov x0,#0 +#endif + ret + .endfn TrackMouseEvent,globl + .previous diff --git a/libc/nt/user32/UnregisterClassW.S b/libc/nt/user32/UnregisterClassW.S new file mode 100644 index 00000000000..398af1b531b --- /dev/null +++ b/libc/nt/user32/UnregisterClassW.S @@ -0,0 +1,18 @@ +#include "libc/nt/codegen.h" +.imp user32,__imp_UnregisterClassW,UnregisterClassW + + .text.windows + .ftrace1 +UnregisterClass: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov __imp_UnregisterClassW(%rip),%rax + jmp __sysv2nt +#elif defined(__aarch64__) + mov x0,#0 + ret +#endif + .endfn UnregisterClass,globl + .previous diff --git a/libc/nt/user32/WindowFromPoint.S b/libc/nt/user32/WindowFromPoint.S new file mode 100644 index 00000000000..eaf6c041098 --- /dev/null +++ b/libc/nt/user32/WindowFromPoint.S @@ -0,0 +1,20 @@ +#include "libc/nt/codegen.h" +.imp user32,__imp_WindowFromPoint,WindowFromPoint + + .text.windows + .ftrace1 +WindowFromPoint: + .ftrace2 +#ifdef __x86_64__ + push %rbp + mov %rsp,%rbp + mov %rdi,%rcx + sub $32,%rsp + call *__imp_WindowFromPoint(%rip) + leave +#elif defined(__aarch64__) + mov x0,#0 +#endif + ret + .endfn WindowFromPoint,globl + .previous