We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I'm trying to get these to work, but don't know where to look if something is failing or working.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682453(v=vs.85).aspx
func CreateThread(attrib, stackSize, startAddress, parameter, createFlag, threadID uintptr) (uintptr, error) { hand, _, err := createThread.Call( attrib, stackSize, startAddress, parameter, createFlag, threadID) return hand, err }
http://msdn.microsoft.com/en-us/library/windows/desktop/ms687032(v=vs.85).aspx
func WaitForSingleObject(handle, milliSeconds uintptr) (uintptr, error) { value, _, err := waitForSingleObject.Call( handle, milliSeconds) return value, err }
var ( kernel32 = syscall.MustLoadDLL("kernel32.dll") VirtualAlloc = kernel32.MustFindProc("VirtualAlloc") moveMemory = kernel32.MustFindProc("RtlMoveMemory") createThread = kernel32.MustFindProc("CreateThread") waitForSingleObject = kernel32.MustFindProc("WaitForSingleObject") )
The text was updated successfully, but these errors were encountered:
package main import ( "C" "fmt" "syscall" "unsafe" ) var ( kernel32 = syscall.NewLazyDLL("kernel32.dll") createThread = kernel32.NewProc("CreateThread") waitForSingleObject = kernel32.NewProc("WaitForSingleObject") getExitCodeThread = kernel32.NewProc("GetExitCodeThread") ) func ThreadFunc(P uintptr) int64 { fmt.Printf("Hello from thread\n") return 0xAA // or your favorite number } func CreateThread(attrib, stackSize, startAddress, parameter, createFlag uintptr, threadID *uint) uintptr { hand, _, _ := createThread.Call( attrib, stackSize, startAddress, parameter, createFlag, uintptr(unsafe.Pointer(threadID))) return hand } func WaitForSingleObject(handle, milliSeconds uintptr) uintptr { value, _, _ := waitForSingleObject.Call( handle, milliSeconds) return value } func GetExitCodeThread(handle uintptr, exitCode *uint) bool { value, _, _ := getExitCodeThread.Call( handle, uintptr(unsafe.Pointer(exitCode))) return value != 0 } func main() { var threadId uint = 0 funcAddr := syscall.NewCallback(ThreadFunc) h := CreateThread(0, 0, funcAddr, 0, 0, &threadId) if h != 0 { fmt.Printf("threadId: %d h: %d\n", threadId, h) waitResult := WaitForSingleObject(h, 1000) if waitResult == 0 { var exitCode uint = 0 GetExitCodeThread(h, &exitCode) fmt.Printf("ThreadExitCode: %d\n", exitCode) } } }
Sorry, something went wrong.
This has been addressed, I assume?
No branches or pull requests
I'm trying to get these to work, but don't know where to look if something is failing or working.
CreateThread
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682453(v=vs.85).aspx
Current Code
WaitForSingleObject
http://msdn.microsoft.com/en-us/library/windows/desktop/ms687032(v=vs.85).aspx
Current Code
Vars at the top of the program
The text was updated successfully, but these errors were encountered: