本文整理匯總了Golang中github.com/mozilla/masche/process.Process.Handle方法的典型用法代碼示例。如果您正苦於以下問題:Golang Process.Handle方法的具體用法?Golang Process.Handle怎麽用?Golang Process.Handle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/mozilla/masche/process.Process
的用法示例。
在下文中一共展示了Process.Handle方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: copyMemory
func copyMemory(p process.Process, address uintptr, buffer []byte) (harderror error, softerrors []error) {
buf := unsafe.Pointer(&buffer[0])
n := len(buffer)
var bytesRead C.size_t
resp := C.copy_process_memory(
(C.process_handle_t)(p.Handle()),
C.memory_address_t(address),
C.size_t(n),
buf,
&bytesRead,
)
harderror, softerrors = cresponse.GetResponsesErrors(unsafe.Pointer(resp))
C.response_free(resp)
if harderror != nil {
harderror = fmt.Errorf("Error while copying %d bytes starting at %x: %s", n, address, harderror.Error())
return
}
if len(buffer) != int(bytesRead) {
harderror = fmt.Errorf("Could not copy %d bytes starting at %x, copyed %d", len(buffer), address, bytesRead)
}
return
}
示例2: listLoadedLibraries
func listLoadedLibraries(p process.Process) (libraries []string, harderror error, softerrors []error) {
r := C.getModules(C.process_handle_t(p.Handle()))
defer C.EnumProcessModulesResponse_Free(r)
if r.error != 0 {
return nil, fmt.Errorf("getModules failed with error: %d", r.error), nil
}
mods := make([]string, r.length)
// We use this to access C arrays without doing manual pointer arithmetic.
cmods := *(*[]C.ModuleInfo)(unsafe.Pointer(
&reflect.SliceHeader{
Data: uintptr(unsafe.Pointer(r.modules)),
Len: int(r.length),
Cap: int(r.length)}))
for i, _ := range mods {
mods[i] = C.GoString(cmods[i].filename)
}
return mods, nil, nil
}
示例3: listLoadedLibraries
func listLoadedLibraries(p process.Process) (libraries []string, harderror error, softerrors []error) {
var ptr uintptr
var sizeT C.size_t
clibs := (***C.char)(C.malloc(C.size_t(unsafe.Sizeof(ptr))))
count := (*C.size_t)(C.malloc(C.size_t(unsafe.Sizeof(sizeT))))
defer C.free_loaded_libraries_list(*clibs, *count)
defer C.free(unsafe.Pointer(clibs))
defer C.free(unsafe.Pointer(count))
response := C.list_loaded_libraries((C.process_handle_t)(p.Handle()), clibs, count)
harderror, softerrors = cresponse.GetResponsesErrors(unsafe.Pointer(response))
C.response_free(response)
if harderror != nil {
return
}
libraries = make([]string, 0, *count)
clibsSlice := *(*[]*C.char)(unsafe.Pointer(
&reflect.SliceHeader{
Data: uintptr(unsafe.Pointer(*clibs)),
Len: int(*count),
Cap: int(*count)}))
processName, harderror, softs := p.Name()
if harderror != nil {
return
}
softerrors = append(softerrors, softs...)
for i, _ := range clibsSlice {
if clibsSlice[i] == nil {
continue
}
str := C.GoString(clibsSlice[i])
if str == processName {
continue
}
libraries = append(libraries, str)
}
return
}
示例4: nextReadableMemoryRegion
func nextReadableMemoryRegion(p process.Process, address uintptr) (region MemoryRegion, harderror error,
softerrors []error) {
var isAvailable C.bool
var cRegion C.memory_region_t
response := C.get_next_readable_memory_region(
(C.process_handle_t)(p.Handle()),
C.memory_address_t(address),
&isAvailable,
&cRegion)
harderror, softerrors = cresponse.GetResponsesErrors(unsafe.Pointer(response))
C.response_free(response)
if harderror != nil || isAvailable == false {
return NoRegionAvailable, harderror, softerrors
}
return MemoryRegion{uintptr(cRegion.start_address), uint(cRegion.length)}, harderror, softerrors
}