douyuan5600
2017-02-13 17:09
浏览 52
已采纳

如何通过go程序未分配的fmt.Println()内存?

I’d like to print the virtual memory content of the current program from 0x10000 to 0x50000 (an area containing a syscall trampoline on my system).

package main

import (
    "syscall"
    "unsafe"
)
func main() {
    syscall.Syscall(SYS_WRITE, uintptr(1), uintptr(unsafe.Pointer(0x10000)), uintptr(0x40000))
}

However when I tried to compile I’m getting that error :

cannot convert 65536 (type int) to type unsafe.Pointer

In my case,cgo is disabled (import "C" fails at compile time).
Also does syscall.Syscall(SYS_WRITE is the only way to do it ?

图片转代码服务由CSDN问答提供 功能建议

我想将当前程序的虚拟内存内容从 0x10000 打印到 0x50000 (我的系统上包含系统调用蹦床的区域)

 包主程序
 
import(
  “ syscall” 
“不安全” 
)
func main(){
 syscall.Syscall(SYS_WRITE,uintptr(1),uintptr(unsafe.Pointer(0x10000)),uintptr(0x40000))
} 
    
 
 

但是,当我尝试编译时遇到该错误:

 无法将65536(int型)转换为 键入unsafe.Pointer 
   
 
 

在我的情况下, cgo 被禁用了 import“ C”
syscall.Syscall(SYS_WRITE 是唯一的方法)

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题