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.
This commit is contained in:
Bach Le 2024-10-28 12:10:32 +08:00 committed by GitHub
parent 4e44517c9c
commit baad1df71d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 618 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

18
libc/nt/user32/PtInRect.S Normal file
View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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