sys

package
v0.0.0-...-986f64f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2023 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

本包提供调用系统功能的封装

Index

Examples

Constants

View Source
const (
	//页面可读取
	READ = syscall.PROT_READ
	//页面可写入
	WRITE = syscall.PROT_WRITE
	RW    = READ | WRITE
)
View Source
const (
	//写入数据复制回文件内,允许其他映射该文件的进程共享
	SHARED = syscall.MAP_SHARED
	//写入时复制,写入操作会产生映射文件的复制,对此的任何修改都不会写入文件
	PRIVATE = syscall.MAP_PRIVATE
)
View Source
const (
	/*
		重定位是在依赖于实现的时间执行的,范围从 dlopen() 调用时间到对给定符号的第一次引用发生
		指定 RTLD_LAZY 应该会提高支持动态符号绑定的实现的性能,因为进程可能不会引用任何给定对象中的所有函数
		而且,对于支持正常流程执行的动态符号解析的系统,此行为模仿流程执行的正常处理。
	*/
	RTLD_LAZY = C.RTLD_LAZY
	/*
		加载对象时执行重定位。
		首次加载对象时会执行所有必要的重定位。
		如果对从未引用的函数执行重定位,这可能会浪费一些处理。
		对于需要在加载对象后立即知道执行期间引用的所有符号都可用的应用程序,此行为可能很有用。
	*/
	RTLD_NOW = C.RTLD_NOW
	/*
		所有符号都可用于其他模块的重定位处理。
		对象的符号可用于任何其他对象的重定位处理。
		此外,使用 dlopen ( 0, mode ) 和关联的 dlsym()进行符号查找允许搜索使用此模式 加载的对象 。
	*/
	RTLD_GLOBAL = C.RTLD_GLOBAL
	/*
		并非所有符号都可用于其他模块的重定位处理。
		对象的符号不可用于任何其他对象的重定位处理。
	*/
	RTLD_LOCAL = C.RTLD_LOCAL
)

Variables

View Source
var (
	Pagesize = os.Getpagesize()
)

Functions

func Dlclose

func Dlclose(handle unsafe.Pointer) int

C语言#include <dlfcn.h>提供的dlclose函数的go语言API

func Dlerror

func Dlerror() string

C语言#include <dlfcn.h>提供的dlerror函数的go语言API

func Dlopen

func Dlopen(file string, mode int) (ptr unsafe.Pointer)

C语言#include <dlfcn.h>提供的dlopen函数的go语言API

func Dlsym

func Dlsym(handle unsafe.Pointer, name string) (ptr unsafe.Pointer)

C语言#include <dlfcn.h>提供的dlsym函数的go语言API

Types

type DLL

type DLL struct {
	// contains filtered or unexported fields
}

动态链接库结构体

func NewDLL

func NewDLL(name string) (d *DLL, err error)

打开一个动态链接库

Example
name := "..."
//name=动态链接库路径
dll, err := NewDLL(name)
//判断是否存在错误
if err != nil {
	//错误处理
	//......
}
//用完后释放
defer dll.Close()
Output:

func NewDLLAll

func NewDLLAll(name string, mode int) (d *DLL, err error)

打开一个动态链接库,以指定的mode

func (*DLL) Close

func (d *DLL) Close() (errint int, err error)

关闭一个动态链接库

func (*DLL) FindProc

func (d *DLL) FindProc(name string) (proc uintptr, err error)

寻找一个动态链接库中导出的过程

func (*DLL) String

func (d *DLL) String() string

type Mmap

type Mmap struct {
	// contains filtered or unexported fields
}

内存映射的结构体

func NewMmap

func NewMmap(path string, length uint) (m *Mmap, err error)

以读写模式打开文件,0777权限位,可读可写可执行

Example
path := "文件路径"
//文件映射起始地址离开头偏移量
length := uint(0)
mmap, err := NewMmap(path, length)
//判断是否存在错误
if err != nil {
	//错误处理
	//......
}
//用完后释放
defer mmap.Close()
Output:

func NewMmapAll

func NewMmapAll(path string, osflag int, perm os.FileMode, length uint, prot int, fileflag int) (m *Mmap, err error)

以自定义模式与自定义权限位打开文件,自定义是否读写执行

func (*Mmap) Addr

func (m *Mmap) Addr() uintptr

返回内存映射的空间首地址

func (*Mmap) Close

func (m *Mmap) Close() (err error)

关闭内存映射

type VM

type VM = Virtual_memory

指定虚拟内存操作的结构体别名

func NewVM

func NewVM(addr, length uintptr) VM

创建指定虚拟内存操作的结构体

func (VM) Lock

func (v VM) Lock()

锁定指定虚拟内存操作,有错panic

func (VM) Lockerr

func (v VM) Lockerr() error

锁定指定虚拟内存操作,有错返回error

func (VM) Unlock

func (v VM) Unlock()

解锁指定虚拟内存操作,有错panic

func (VM) Unlockerr

func (v VM) Unlockerr() error

解锁指定虚拟内存操作,有错error

type Virtual_memory

type Virtual_memory struct {
	// contains filtered or unexported fields
}

指定虚拟内存操作的结构体

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL