github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/sys/windows/init.go (about) 1 // Copyright 2017 syzkaller project authors. All rights reserved. 2 // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. 3 4 package windows 5 6 import ( 7 "github.com/google/syzkaller/prog" 8 ) 9 10 func InitTarget(target *prog.Target) { 11 arch := &arch{ 12 target: target, 13 virtualAllocSyscall: target.SyscallMap["VirtualAlloc"], 14 MEM_COMMIT: target.GetConst("MEM_COMMIT"), 15 MEM_RESERVE: target.GetConst("MEM_RESERVE"), 16 PAGE_EXECUTE_READWRITE: target.GetConst("PAGE_EXECUTE_READWRITE"), 17 } 18 19 target.MakeDataMmap = arch.makeMmap 20 } 21 22 type arch struct { 23 target *prog.Target 24 virtualAllocSyscall *prog.Syscall 25 26 MEM_COMMIT uint64 27 MEM_RESERVE uint64 28 PAGE_EXECUTE_READWRITE uint64 29 } 30 31 func (arch *arch) makeMmap() []*prog.Call { 32 meta := arch.virtualAllocSyscall 33 size := arch.target.NumPages * arch.target.PageSize 34 return []*prog.Call{ 35 prog.MakeCall(meta, []prog.Arg{ 36 prog.MakeVmaPointerArg(meta.Args[0].Type, prog.DirIn, 0, size), 37 prog.MakeConstArg(meta.Args[1].Type, prog.DirIn, size), 38 prog.MakeConstArg(meta.Args[2].Type, prog.DirIn, arch.MEM_COMMIT|arch.MEM_RESERVE), 39 prog.MakeConstArg(meta.Args[3].Type, prog.DirIn, arch.PAGE_EXECUTE_READWRITE), 40 }), 41 } 42 }