简体   繁体   English

转到Windows以将标志传递给内存映射syscall

[英]Go Windows to pass Flag to memory map syscall

In Unix, Go can do this: 在Unix中,Go可以做到这一点:

// func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error)
syscall.Mmap(., ., ., ., syscall.MAP_SHARED|syscall.XXX)

In Windows, you can use this: 在Windows中,您可以使用以下命令:

https://github.com/golang/go/blob/master/src/syscall/zsyscall_windows.go#L970-L981 https://github.com/golang/go/blob/master/src/syscall/zsyscall_windows.go#L970-L981

// func CreateFileMapping(fhandle Handle, sa *SecurityAttributes, prot uint32, maxSizeHigh uint32, maxSizeLow uint32, name *uint16) (handle Handle, err error)
syscall.CreateFileMapping(., ., syscall.PAGE_READONLY, ., ., nil)

But I don't see any flag arguments to CreateFileMapping for Windows. 但是我看不到Windows的CreateFileMapping任何标志参数。

Does anybody know how to pass flags to CreateFileMapping function like syscall.MAP_SHARED|syscall.XXX ? 是否有人知道如何将标志传递给syscall.MAP_SHARED|syscall.XXX类的CreateFileMapping函数?

It looks like you can get the integer values for the protection flags from the Windows reference for that syscall . 看来您可以从Windows参考中获取该系统调用的保护标志的整数值。 There doesn't seem to be a one-to-one mapping with the Unix-y flags, eg rather than having a flag for shared maps, it appears you get a shared map by default when you pass the call a filename. 似乎不存在带有Unix-y标志的一对一映射,例如,没有为共享映射提供标志,而是在传递调用文件名时默认情况下会显示为共享映射。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM