Home | History | Annotate | Download | only in windows
      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 		virtualAllocSyscall:    target.SyscallMap["VirtualAlloc"],
     13 		MEM_COMMIT:             target.ConstMap["MEM_COMMIT"],
     14 		MEM_RESERVE:            target.ConstMap["MEM_RESERVE"],
     15 		PAGE_EXECUTE_READWRITE: target.ConstMap["PAGE_EXECUTE_READWRITE"],
     16 	}
     17 
     18 	target.MakeMmap = arch.makeMmap
     19 }
     20 
     21 type arch struct {
     22 	virtualAllocSyscall *prog.Syscall
     23 
     24 	MEM_COMMIT             uint64
     25 	MEM_RESERVE            uint64
     26 	PAGE_EXECUTE_READWRITE uint64
     27 }
     28 
     29 func (arch *arch) makeMmap(addr, size uint64) *prog.Call {
     30 	meta := arch.virtualAllocSyscall
     31 	return &prog.Call{
     32 		Meta: meta,
     33 		Args: []prog.Arg{
     34 			prog.MakeVmaPointerArg(meta.Args[0], addr, size),
     35 			prog.MakeConstArg(meta.Args[1], size),
     36 			prog.MakeConstArg(meta.Args[2], arch.MEM_COMMIT|arch.MEM_RESERVE),
     37 			prog.MakeConstArg(meta.Args[3], arch.PAGE_EXECUTE_READWRITE),
     38 		},
     39 		Ret: prog.MakeReturnArg(meta.Ret),
     40 	}
     41 }
     42