Modified const and extern to always use blocks
This commit is contained in:
@ -1,13 +1,3 @@
|
||||
cp const {
|
||||
utf8 65001
|
||||
}
|
||||
|
||||
kernel32 extern {
|
||||
SetConsoleCP(cp uint)
|
||||
SetConsoleOutputCP(cp uint)
|
||||
ExitProcess(code uint)
|
||||
}
|
||||
|
||||
init() {
|
||||
kernel32.SetConsoleCP(cp.utf8)
|
||||
kernel32.SetConsoleOutputCP(cp.utf8)
|
||||
@ -21,4 +11,18 @@ exit() {
|
||||
|
||||
crash() {
|
||||
kernel32.ExitProcess(1)
|
||||
}
|
||||
|
||||
const {
|
||||
cp {
|
||||
utf8 65001
|
||||
}
|
||||
}
|
||||
|
||||
extern {
|
||||
kernel32 {
|
||||
SetConsoleCP(cp uint)
|
||||
SetConsoleOutputCP(cp uint)
|
||||
ExitProcess(code uint)
|
||||
}
|
||||
}
|
14
lib/io/io.q
14
lib/io/io.q
@ -1,11 +1,5 @@
|
||||
import sys
|
||||
|
||||
std const {
|
||||
in 0
|
||||
out 1
|
||||
err 2
|
||||
}
|
||||
|
||||
in(buffer []byte) -> int {
|
||||
return sys.read(std.in, buffer, len(buffer))
|
||||
}
|
||||
@ -24,4 +18,12 @@ read(fd int, buffer []byte) -> int {
|
||||
|
||||
write(fd int, buffer []byte) -> int {
|
||||
return sys.write(fd, buffer, len(buffer))
|
||||
}
|
||||
|
||||
const {
|
||||
std {
|
||||
in 0
|
||||
out 1
|
||||
err 2
|
||||
}
|
||||
}
|
@ -1,7 +1,3 @@
|
||||
kernel32 extern {
|
||||
VirtualAlloc(address int, size uint, flags uint32, protection uint32) -> *any
|
||||
}
|
||||
|
||||
alloc(length int) -> []byte {
|
||||
x := kernel32.VirtualAlloc(0, length+8, mem.commit|mem.reserve, page.readwrite)
|
||||
|
||||
@ -11,4 +7,10 @@ alloc(length int) -> []byte {
|
||||
|
||||
store(x, 8, length)
|
||||
return x + 8
|
||||
}
|
||||
|
||||
extern {
|
||||
kernel32 {
|
||||
VirtualAlloc(address int, size uint, flags uint32, protection uint32) -> *any
|
||||
}
|
||||
}
|
@ -1,9 +1,11 @@
|
||||
prot const {
|
||||
read 0x1
|
||||
write 0x2
|
||||
}
|
||||
const {
|
||||
prot {
|
||||
read 0x1
|
||||
write 0x2
|
||||
}
|
||||
|
||||
map const {
|
||||
private 0x02
|
||||
anonymous 0x20
|
||||
map {
|
||||
private 0x02
|
||||
anonymous 0x20
|
||||
}
|
||||
}
|
@ -1,9 +1,11 @@
|
||||
prot const {
|
||||
read 0x1
|
||||
write 0x2
|
||||
}
|
||||
const {
|
||||
prot {
|
||||
read 0x1
|
||||
write 0x2
|
||||
}
|
||||
|
||||
map const {
|
||||
private 0x02
|
||||
anonymous 0x1000
|
||||
map {
|
||||
private 0x02
|
||||
anonymous 0x1000
|
||||
}
|
||||
}
|
@ -1,9 +1,11 @@
|
||||
page const {
|
||||
readwrite 0x0004
|
||||
}
|
||||
const {
|
||||
page {
|
||||
readwrite 0x0004
|
||||
}
|
||||
|
||||
mem const {
|
||||
commit 0x1000
|
||||
reserve 0x2000
|
||||
decommit 0x4000
|
||||
mem {
|
||||
commit 0x1000
|
||||
reserve 0x2000
|
||||
decommit 0x4000
|
||||
}
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
kernel32 extern {
|
||||
VirtualFree(address *any, size uint, type uint32) -> bool
|
||||
}
|
||||
|
||||
free(address []any) {
|
||||
kernel32.VirtualFree(address-8, len(address)+8, mem.decommit)
|
||||
}
|
||||
|
||||
extern {
|
||||
kernel32 {
|
||||
VirtualFree(address *any, size uint, type uint32) -> bool
|
||||
}
|
||||
}
|
@ -10,8 +10,10 @@ write(fd int, buffer *byte, length int) -> int {
|
||||
return length
|
||||
}
|
||||
|
||||
kernel32 extern {
|
||||
GetStdHandle(handle int64) -> int64
|
||||
ReadConsole(fd int64, buffer *byte, length uint32, written *uint32) -> bool
|
||||
WriteConsoleA(fd int64, buffer *byte, length uint32, written *uint32) -> bool
|
||||
extern {
|
||||
kernel32 {
|
||||
GetStdHandle(handle int64) -> int64
|
||||
ReadConsole(fd int64, buffer *byte, length uint32, written *uint32) -> bool
|
||||
WriteConsoleA(fd int64, buffer *byte, length uint32, written *uint32) -> bool
|
||||
}
|
||||
}
|
@ -1,16 +1,6 @@
|
||||
import core
|
||||
import sys
|
||||
|
||||
clone const {
|
||||
vm 0x100
|
||||
fs 0x200
|
||||
files 0x400
|
||||
sighand 0x800
|
||||
parent 0x8000
|
||||
thread 0x10000
|
||||
io 0x80000000
|
||||
}
|
||||
|
||||
create(func *any) -> int {
|
||||
stack := sys.mmap(0, 4096, 0x1|0x2, 0x02|0x20|0x100)
|
||||
stack += 4096 - 8
|
||||
@ -18,4 +8,16 @@ create(func *any) -> int {
|
||||
stack -= 8
|
||||
store(stack, 8, func)
|
||||
return sys.clone(clone.vm|clone.fs|clone.files|clone.sighand|clone.parent|clone.thread|clone.io, stack, 0, 0, 0)
|
||||
}
|
||||
|
||||
const {
|
||||
clone {
|
||||
vm 0x100
|
||||
fs 0x200
|
||||
files 0x400
|
||||
sighand 0x800
|
||||
parent 0x8000
|
||||
thread 0x10000
|
||||
io 0x80000000
|
||||
}
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
kernel32 extern {
|
||||
CreateThread(attributes int, stackSize int, address *any, parameter int) -> int
|
||||
}
|
||||
|
||||
create(func *any) -> int {
|
||||
return kernel32.CreateThread(0, 4096, func, 0)
|
||||
}
|
||||
|
||||
extern {
|
||||
kernel32 {
|
||||
CreateThread(attributes int, stackSize int, address *any, parameter int) -> int
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user