当前位置: 首页>>代码示例>>Golang>>正文


Golang syscall.GetProcAddress函数代码示例

本文整理汇总了Golang中syscall.GetProcAddress函数的典型用法代码示例。如果您正苦于以下问题:Golang GetProcAddress函数的具体用法?Golang GetProcAddress怎么用?Golang GetProcAddress使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetProcAddress函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: XAudio2Create

func XAudio2Create(ppXAudio2 **IXAudio2) (ret int32) {
	libole32, _ := syscall.LoadLibrary("ole32.dll")
	ptrcoInitializeEx, _ = syscall.GetProcAddress(syscall.Handle(libole32), "CoInitializeEx")
	ptrcoCreateInstance, _ = syscall.GetProcAddress(syscall.Handle(libole32), "CoCreateInstance")

	coInitializeEx(nil, 0)

	// XAudio 2.7 GUIDs
	clsid := guid{0x5a508685, 0xa254, 0x4fba, [8]byte{0x9b, 0x82, 0x9a, 0x24, 0xb0, 0x03, 0x06, 0xaf}}
	iid := guid{0x8bcf1f58, 0x9fe7, 0x4583, [8]byte{0x8a, 0xc6, 0xe2, 0xad, 0xc4, 0x65, 0xc8, 0xbb}}
	var com unsafe.Pointer
	ret = coCreateInstance(&clsid, nil, 1, &iid, &com)
	if ret < 0 {
		return
	}

	pXAudio2 := (*IXAudio2)(com)
	ret = pXAudio2.Initialize(0, 0xffffffff)
	if ret < 0 {
		pXAudio2.Release()
		return
	}

	*ppXAudio2 = pXAudio2
	return
}
开发者ID:ccherng,项目名称:go-xaudio2,代码行数:26,代码来源:xaudio2.go

示例2: init

func init() {
	var nStdHandle = -11
	kernel32, _ = syscall.LoadLibrary("Kernel32.dll")
	GetStdHandle, _ = syscall.GetProcAddress(syscall.Handle(kernel32), "GetStdHandle")
	SetConsoleTextAttribute, _ = syscall.GetProcAddress(syscall.Handle(kernel32), "SetConsoleTextAttribute")
	//	ReadConsoleOutputAttribute, _ := syscall.GetProcAddress(syscall.Handle(kernel32), "ReadConsoleOutputAttribute")
	GetConsoleScreenBufferInfo, _ = syscall.GetProcAddress(syscall.Handle(kernel32), "GetConsoleScreenBufferInfo")
	hnd, _, _ = syscall.Syscall(uintptr(GetStdHandle), 1, uintptr(nStdHandle), 0, 0)
}
开发者ID:CuberL,项目名称:ColorPrint,代码行数:9,代码来源:ColorPrint_windows.go

示例3: Initdriver

func (jst *TCFinger) Initdriver(pin *driverlayer.DriverArg) {
	var err error
	jst.stdll, err = syscall.LoadLibrary("third_party/teso/TesoLive.dll")
	if err != nil {
		panic("LoadLibrary " + err.Error())
	}
	jst.getRegisterImage, err = syscall.GetProcAddress(jst.stdll, "FPIGetTemplate")
	jst.getValidteImage, err = syscall.GetProcAddress(jst.stdll, "FPIGetFeature")
	jst.matchtz, err = syscall.GetProcAddress(jst.stdll, "FPIMatch")
}
开发者ID:kity-xu,项目名称:xuxiaodong,代码行数:10,代码来源:tcfinger.go

示例4: init

func init() {
	var err error
	if msvcrt, err = syscall.LoadLibrary("msvcrt.dll"); err != nil {
		abort("LoadLibrary", err)
	}
	if setlocale, err = syscall.GetProcAddress(msvcrt, "setlocale"); err != nil {
		abort("GetProcAddress", err)
	}
	if wcstombs, err = syscall.GetProcAddress(msvcrt, "wcstombs"); err != nil {
		abort("GetProcAddress", err)
	}
	if mbstowcs, err = syscall.GetProcAddress(msvcrt, "mbstowcs"); err != nil {
		abort("GetProcAddress", err)
	}
}
开发者ID:mattn,项目名称:go-mbcs,代码行数:15,代码来源:mbcs.go

示例5: DiskSpace

// Returns total and free bytes available in a directory.
// It returns free space available to the user (including quota limitations),
// so it can be lower than the free space of the disk.
func DiskSpace(path string) (total, free int64, err error) {
	kernel32, err := syscall.LoadLibrary("Kernel32.dll")
	if err != nil {
		return
	}
	defer syscall.FreeLibrary(kernel32)
	GetDiskFreeSpaceEx, err := syscall.GetProcAddress(
		syscall.Handle(kernel32), "GetDiskFreeSpaceExW")
	if err != nil {
		return
	}
	lpFreeBytesAvailable := int64(0)
	lpTotalNumberOfBytes := int64(0)
	lpTotalNumberOfFreeBytes := int64(0)
	r1, _, e1 := syscall.Syscall6(uintptr(GetDiskFreeSpaceEx), 4,
		uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(path))),
		uintptr(unsafe.Pointer(&lpFreeBytesAvailable)),
		uintptr(unsafe.Pointer(&lpTotalNumberOfBytes)),
		uintptr(unsafe.Pointer(&lpTotalNumberOfFreeBytes)), 0, 0)
	if r1 == 0 {
		if e1 != 0 {
			err = error(e1)
		} else {
			err = syscall.EINVAL
		}
		return
	}
	total = lpTotalNumberOfBytes
	free = lpFreeBytesAvailable
	return
}
开发者ID:YijinLiu,项目名称:usongs,代码行数:34,代码来源:disk_space_windows.go

示例6: getProcAddr

func getProcAddr(lib syscall.Handle, name string) uintptr {
	addr, err := syscall.GetProcAddress(lib, name)
	if err != nil {
		panic(name + " " + err.Error())
	}
	return addr
}
开发者ID:rasky,项目名称:go-serial,代码行数:7,代码来源:open_windows.go

示例7: InitalFunctions

func (p *Dll) InitalFunctions(funcNames ...string) error {
	if funcNames == nil {
		return nil
	}

	if !p.IsDllLoaded() {
		return errors.New("dll should loaded befor inital functions")
	}

	if p.funcProcs == nil {
		p.funcProcs = make(map[string]uintptr)
	}

	for _, funcName := range funcNames {
		funcName = strings.TrimSpace(funcName)
		if funcName == "" {
			return errors.New("function name could not be empty")
		}
		if proc, e := syscall.GetProcAddress(p.dllHandler, funcName); e != nil {
			return e
		} else {
			p.funcProcs[funcName] = proc
		}
	}
	return nil
}
开发者ID:easykoo,项目名称:dll_caller,代码行数:26,代码来源:dll_caller_windows.go

示例8: freeDiskSpaceBytes2

// *************************************************************************
// We can probably delete this, it is an alternative version in case we have
// problems with simpler version above
// *************************************************************************
func freeDiskSpaceBytes2(dir string) (uint64, error) {
	kernel32, err := syscall.LoadLibrary("Kernel32.dll")
	if err != nil {
		log.Panic(err)
	}
	defer syscall.FreeLibrary(kernel32)
	GetDiskFreeSpaceEx, err := syscall.GetProcAddress(syscall.Handle(kernel32), "GetDiskFreeSpaceExW")
	if err != nil {
		return 0, err
	}
	lpFreeBytesAvailable := int64(0)
	lpTotalNumberOfBytes := int64(0)
	lpTotalNumberOfFreeBytes := int64(0)
	r, a, b := syscall.Syscall6(
		uintptr(GetDiskFreeSpaceEx),
		4,
		uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr("C:"))),
		uintptr(unsafe.Pointer(&lpFreeBytesAvailable)),
		uintptr(unsafe.Pointer(&lpTotalNumberOfBytes)),
		uintptr(unsafe.Pointer(&lpTotalNumberOfFreeBytes)),
		0,
		0,
	)
	log.Print("Disk space:", r, a, b, lpFreeBytesAvailable, lpTotalNumberOfBytes, lpTotalNumberOfFreeBytes)
	return uint64(lpFreeBytesAvailable), nil
}
开发者ID:petemoore,项目名称:generic-worker,代码行数:30,代码来源:diskspace_windows.go

示例9: getSysProcAddr

func getSysProcAddr(m uint32, pname string) uintptr {
	p, e := syscall.GetProcAddress(m, pname)
	if e != 0 {
		panic("GetProcAddress failed on " + pname)
	}
	return uintptr(p)
}
开发者ID:sbinet,项目名称:fineline,代码行数:7,代码来源:windows.go

示例10: Initdriver

func (jst *IDCGeneral) Initdriver(pin *driverlayer.DriverArg) {
	var err error
	jst.termdll, err = syscall.LoadLibrary("third_party/general/sdtapi.dll")
	if err != nil {
		panic("load library error:" + err.Error())
	}

	f := func(n string, res *uintptr) bool {
		*res, err = syscall.GetProcAddress(jst.termdll, n)
		if err != nil {
			syscall.FreeLibrary(jst.termdll)
			panic("load proc " + n + " error:" + err.Error())
		}
		return true
	}

	//获得dll的各种handle
	if f("SDT_OpenPort", &jst.initcomm) &&
		f("SDT_ClosePort", &jst.closecomm) &&
		f("SDT_StartFindIDCard", &jst.findcard) &&
		f("SDT_SelectIDCard", &jst.selectcard) &&
		f("SDT_ReadBaseMsg", &jst.readbasemsg) {
	} else {
		utils.Error("Init shensi Driver error...%s", err.Error())
	}

}
开发者ID:kity-xu,项目名称:xuxiaodong,代码行数:27,代码来源:idcgeneral.go

示例11: testFail

func testFail() {
	h, err := syscall.LoadLibrary("msvcrt")
	if err != nil {
		fmt.Println(err)
		return
	}

	defer syscall.FreeLibrary(h)

	proc, err := syscall.GetProcAddress(h, "memcpy")
	if err != nil {
		fmt.Println(err)
		return
	}

	// dst := unsafe.Pointer(uintptr(1))
	// src := unsafe.Pointer(uintptr(2))
	// count := unsafe.Pointer(uintptr(4))
	dst := uintptr(1)
	src := uintptr(2)
	count := uintptr(3)

	fmt.Println("test memcpy error in go...")
	r, _, _ := syscall.Syscall(uintptr(proc), 3, dst, src, count)

	fmt.Println(r)
	fmt.Println("should not run here")

}
开发者ID:yuanlv,项目名称:learning-in-go,代码行数:29,代码来源:go_call_c.go

示例12: getProcAddr

func getProcAddr(lib syscall.Handle, name string) uintptr {
	addr, err := syscall.GetProcAddress(lib, name)
	if err != 0 {
		panic(name + " " + syscall.Errstr(err))
	}
	return addr
}
开发者ID:rwen,项目名称:goserial,代码行数:7,代码来源:serial_windows.go

示例13: Rename

func Rename(src, dst string) error {
	kernel32, err := syscall.LoadLibrary("kernel32.dll")
	if err != nil {
		return err
	}
	defer syscall.FreeLibrary(kernel32)
	moveFileExUnicode, err := syscall.GetProcAddress(kernel32, "MoveFileExW")
	if err != nil {
		return err
	}

	srcString, err := syscall.UTF16PtrFromString(src)
	if err != nil {
		return err
	}

	dstString, err := syscall.UTF16PtrFromString(dst)
	if err != nil {
		return err
	}

	srcPtr := uintptr(unsafe.Pointer(srcString))
	dstPtr := uintptr(unsafe.Pointer(dstString))

	MOVEFILE_REPLACE_EXISTING := 0x1
	flag := uintptr(MOVEFILE_REPLACE_EXISTING)

	_, _, callErr := syscall.Syscall(uintptr(moveFileExUnicode), 3, srcPtr, dstPtr, flag)
	if callErr != 0 {
		return callErr
	}

	return nil
}
开发者ID:andradeandrey,项目名称:go-ipfs,代码行数:34,代码来源:rename_windows.go

示例14: getSysProcAddr

func getSysProcAddr(m uint32, pname string) uintptr {
	p, e := syscall.GetProcAddress(m, pname)
	if e != 0 {
		abortf("GetProcAddress(%s) failed with err=%d.\n", pname, e)
	}
	return uintptr(p)
}
开发者ID:radhermit,项目名称:gcc,代码行数:7,代码来源:winapi.go

示例15: main

func main() {
	//首先,准备输入参数, GetDiskFreeSpaceEx需要4个参数, 可查MSDN
	// dir := "C:"
	lpFreeBytesAvailable := int64(0) //注意类型需要跟API的类型相符
	lpTotalNumberOfBytes := int64(0)
	lpTotalNumberOfFreeBytes := int64(0)

	//获取方法的引用
	kernel32, err := syscall.LoadLibrary("Kernel32.dll") // 严格来说需要加上 defer syscall.FreeLibrary(kernel32)
	if err != nil {
		log.Println(err.Error())
	}
	defer syscall.FreeLibrary(kernel32)
	GetDiskFreeSpaceEx, err := syscall.GetProcAddress(syscall.Handle(kernel32), "GetDiskFreeSpaceExW")

	//执行之. 因为有4个参数,故取Syscall6才能放得下. 最后2个参数,自然就是0了
	r, _, errno := syscall.Syscall6(uintptr(GetDiskFreeSpaceEx), 4,
		uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr("C:"))),
		uintptr(unsafe.Pointer(&lpFreeBytesAvailable)),
		uintptr(unsafe.Pointer(&lpTotalNumberOfBytes)),
		uintptr(unsafe.Pointer(&lpTotalNumberOfFreeBytes)), 0, 0)

	if errno != 0 {
		log.Println(errno)
	}
	// 注意, errno并非error接口的, 不可能是nil
	// 而且,根据MSDN的说明,返回值为0就fail, 不为0就是成功
	if r != 0 {
		log.Printf("Free %dmb", lpTotalNumberOfFreeBytes/1024/1024)
	}
}
开发者ID:bonly,项目名称:exercise,代码行数:31,代码来源:20120329_win_free_disk.go


注:本文中的syscall.GetProcAddress函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。