31 lines
917 B
Plaintext
31 lines
917 B
Plaintext
read(fd int64, buffer *any, length int64) -> int64 {
|
|
fd = kernel32.GetStdHandle(-10 - fd)
|
|
kernel32.ReadConsole(fd, buffer, length, 0)
|
|
return length
|
|
}
|
|
|
|
write(fd int64, buffer *any, length int64) -> int64 {
|
|
fd = kernel32.GetStdHandle(-10 - fd)
|
|
kernel32.WriteConsoleA(fd, buffer, length, 0)
|
|
return length
|
|
}
|
|
|
|
mmap(address int, length int, protection int, flags int) -> *any {
|
|
return kernel32.VirtualAlloc(address, length, flags, protection)
|
|
}
|
|
|
|
munmap(address *any, length int) -> int {
|
|
return kernel32.VirtualFree(address, length, mem.decommit)
|
|
}
|
|
|
|
const mem {
|
|
decommit 0x4000
|
|
}
|
|
|
|
extern kernel32 {
|
|
GetStdHandle(handle int64) -> int64
|
|
ReadConsole(fd int64, buffer *any, length uint32, written *uint32) -> bool
|
|
VirtualAlloc(address int, length int, flags int, protection int)
|
|
VirtualFree(address *any, length int, type int) -> bool
|
|
WriteConsoleA(fd int64, buffer *any, length uint32, written *uint32) -> bool
|
|
} |