非常教程

Go参考手册

调试 | debug

debug/pe

  • import "debug/pe"
  • 概述
  • 索引

概述

Package pe实现对 PE(Microsoft Windows Portable Executable)文件的访问。

索引

  • 常量
  • type COFFSymbol
  • func (sym *COFFSymbol) FullName(st StringTable) (string, error)
  • type DataDirectory
  • type File
  • func NewFile(r io.ReaderAt) (*File, error)
  • func Open(name string) (*File, error)
  • func (f *File) Close() error
  • func (f *File) DWARF() (*dwarf.Data, error)
  • func (f *File) ImportedLibraries() ([]string, error)
  • func (f *File) ImportedSymbols() ([]string, error)
  • func (f *File) Section(name string) *Section
  • type FileHeader
  • type FormatError
  • func (e *FormatError) Error() string
  • type ImportDirectory
  • type OptionalHeader32
  • type OptionalHeader64
  • type Reloc
  • type Section
  • func (s *Section) Data() ([]byte, error)
  • func (s *Section) Open() io.ReadSeeker
  • type SectionHeader
  • type SectionHeader32
  • type StringTable
  • func (st StringTable) String(start uint32) (string, error)
  • type Symbol

包文件

file.go pe.go section.go string.go symbol.go

常量

const (
        IMAGE_FILE_MACHINE_UNKNOWN   = 0x0
        IMAGE_FILE_MACHINE_AM33      = 0x1d3
        IMAGE_FILE_MACHINE_AMD64     = 0x8664
        IMAGE_FILE_MACHINE_ARM       = 0x1c0
        IMAGE_FILE_MACHINE_EBC       = 0xebc
        IMAGE_FILE_MACHINE_I386      = 0x14c
        IMAGE_FILE_MACHINE_IA64      = 0x200
        IMAGE_FILE_MACHINE_M32R      = 0x9041
        IMAGE_FILE_MACHINE_MIPS16    = 0x266
        IMAGE_FILE_MACHINE_MIPSFPU   = 0x366
        IMAGE_FILE_MACHINE_MIPSFPU16 = 0x466
        IMAGE_FILE_MACHINE_POWERPC   = 0x1f0
        IMAGE_FILE_MACHINE_POWERPCFP = 0x1f1
        IMAGE_FILE_MACHINE_R4000     = 0x166
        IMAGE_FILE_MACHINE_SH3       = 0x1a2
        IMAGE_FILE_MACHINE_SH3DSP    = 0x1a3
        IMAGE_FILE_MACHINE_SH4       = 0x1a6
        IMAGE_FILE_MACHINE_SH5       = 0x1a8
        IMAGE_FILE_MACHINE_THUMB     = 0x1c2
        IMAGE_FILE_MACHINE_WCEMIPSV2 = 0x169
)
const COFFSymbolSize = 18

type COFFSymbol(查看源代码)

COFFSymbol 表示单个 COFF 符号表记录。

type COFFSymbol struct {
        Name               [8]uint8
        Value              uint32
        SectionNumber      int16
        Type               uint16
        StorageClass       uint8
        NumberOfAuxSymbols uint8
}

func (*COFFSymbol) FullName(查看源代码)

func (sym *COFFSymbol) FullName(st StringTable) (string, error)

FullName 找到符号 sym 的真实名称。通常名称存储在 sym.Name 中,但如果长度超过8个字符,它将存储在 COFF 字符串表st中。

type DataDirectory(查看源代码)

type DataDirectory struct {
        VirtualAddress uint32
        Size           uint32
}

type File(查看源代码)

文件表示一个开放的 PE 文件。

type File struct {
        FileHeader
        OptionalHeader interface{} // *OptionalHeader32或 *OptionalHeader64 类型
        Sections       []*Section
        Symbols        []*Symbol    // 删除了辅助符号记录的COFF符号
        COFFSymbols    []COFFSymbol // 所有COFF符号(包括辅助符号记录)
        StringTable    StringTable
        // 包含已过滤或未导出的字段
}

func NewFile(查看源代码)

func NewFile(r io.ReaderAt) (*File, error)

NewFile 创建一个新的文件,用于访问底层阅读器中的 PE 二进制文件。

func Open(查看源代码)

func Open(name string) (*File, error)

打开使用 os.Open 打开命名文件,并准备将其用作 PE 二进制文件。

func (*File) Close(查看源代码)

func (f *File) Close() error

关闭文件。如果文件是直接使用 NewFile 而不是 Open 来创建的,则 Close 不起作用。

func (*File) DWARF(查看源代码)

func (f *File) DWARF() (*dwarf.Data, error)

func (*File) ImportedLibraries(查看源代码)

func (f *File) ImportedLibraries() ([]string, error)

ImportedLibraries 返回二进制文件 f 引用的所有库的名称,这些库在动态链接时期预计将与二进制文件链接。

func (*File) ImportedSymbols(查看源代码)

func (f *File) ImportedSymbols() ([]string, error)

ImportedSymbols 返回二进制文件f引用的所有符号的名称,动态加载时期望其他库会满足这些名称。它不会返回弱符号。

func (*File) Section(查看源代码)

func (f *File) Section(name string) *Section

Section 返回给定名称的第一部分,如果不存在这样的部分,则返回 nil。

type FileHeader(查看源代码)

type FileHeader struct {
        Machine              uint16
        NumberOfSections     uint16
        TimeDateStamp        uint32
        PointerToSymbolTable uint32
        NumberOfSymbols      uint32
        SizeOfOptionalHeader uint16
        Characteristics      uint16
}

type FormatError(查看源代码)

FormatError 未使用。该类型被保留以便兼容。

type FormatError struct {
}

func (*FormatError) Error(查看源代码)

func (e *FormatError) Error() string

type ImportDirectory(查看源代码)

type ImportDirectory struct {
        OriginalFirstThunk uint32
        TimeDateStamp      uint32
        ForwarderChain     uint32
        Name               uint32
        FirstThunk         uint32
        // 包含已过滤或未导出的字段
}

type OptionalHeader32(查看源代码)

type OptionalHeader32 struct {
        Magic                       uint16
        MajorLinkerVersion          uint8
        MinorLinkerVersion          uint8
        SizeOfCode                  uint32
        SizeOfInitializedData       uint32
        SizeOfUninitializedData     uint32
        AddressOfEntryPoint         uint32
        BaseOfCode                  uint32
        BaseOfData                  uint32
        ImageBase                   uint32
        SectionAlignment            uint32
        FileAlignment               uint32
        MajorOperatingSystemVersion uint16
        MinorOperatingSystemVersion uint16
        MajorImageVersion           uint16
        MinorImageVersion           uint16
        MajorSubsystemVersion       uint16
        MinorSubsystemVersion       uint16
        Win32VersionValue           uint32
        SizeOfImage                 uint32
        SizeOfHeaders               uint32
        CheckSum                    uint32
        Subsystem                   uint16
        DllCharacteristics          uint16
        SizeOfStackReserve          uint32
        SizeOfStackCommit           uint32
        SizeOfHeapReserve           uint32
        SizeOfHeapCommit            uint32
        LoaderFlags                 uint32
        NumberOfRvaAndSizes         uint32
        DataDirectory               [16]DataDirectory
}

type OptionalHeader64(查看源代码)

type OptionalHeader64 struct {
        Magic                       uint16
        MajorLinkerVersion          uint8
        MinorLinkerVersion          uint8
        SizeOfCode                  uint32
        SizeOfInitializedData       uint32
        SizeOfUninitializedData     uint32
        AddressOfEntryPoint         uint32
        BaseOfCode                  uint32
        ImageBase                   uint64
        SectionAlignment            uint32
        FileAlignment               uint32
        MajorOperatingSystemVersion uint16
        MinorOperatingSystemVersion uint16
        MajorImageVersion           uint16
        MinorImageVersion           uint16
        MajorSubsystemVersion       uint16
        MinorSubsystemVersion       uint16
        Win32VersionValue           uint32
        SizeOfImage                 uint32
        SizeOfHeaders               uint32
        CheckSum                    uint32
        Subsystem                   uint16
        DllCharacteristics          uint16
        SizeOfStackReserve          uint64
        SizeOfStackCommit           uint64
        SizeOfHeapReserve           uint64
        SizeOfHeapCommit            uint64
        LoaderFlags                 uint32
        NumberOfRvaAndSizes         uint32
        DataDirectory               [16]DataDirectory
}

type Reloc(查看源代码)

Reloc 代表 PE COFF 重新安置。每个部分都包含自己的重定位列表。

type Reloc struct {
        VirtualAddress   uint32
        SymbolTableIndex uint32
        Type             uint16
}

type Section(查看源代码)

部分提供对 PE COFF 部分的访问。

type Section struct {
        SectionHeader
        Relocs []Reloc

        // 为ReadAt方法嵌入ReaderAt。
        // 不要直接嵌入SectionReader
        // 避免阅读Read和寻求Seek。
        // 如果客户想要阅读和寻求它必须使用
        // Open()以避免争夺搜索偏移量
        // 与其他客户。
        io.ReaderAt
        // 包含已过滤或未导出的字段
}

func (*Section) Data(查看源代码)

func (s *Section) Data() ([]byte, error)

数据读取并返回 PE 部分的内容。

func (*Section) Open(查看源代码)

func (s *Section) Open() io.ReadSeeker

Open 返回一个新的 ReadSeeker 读取 PE 部分。

type SectionHeader(查看源代码)

SectionHeader 类似于 SectionHeader32,其中 Name 字段被 Go 字符串替换。

type SectionHeader struct {
        Name                 string
        VirtualSize          uint32
        VirtualAddress       uint32
        Size                 uint32
        Offset               uint32
        PointerToRelocations uint32
        PointerToLineNumbers uint32
        NumberOfRelocations  uint16
        NumberOfLineNumbers  uint16
        Characteristics      uint32
}

type SectionHeader32(查看源代码)

SectionHeader32 表示真实的 PE COFF 部分标题。

type SectionHeader32 struct {
        Name                 [8]uint8
        VirtualSize          uint32
        VirtualAddress       uint32
        SizeOfRawData        uint32
        PointerToRawData     uint32
        PointerToRelocations uint32
        PointerToLineNumbers uint32
        NumberOfRelocations  uint16
        NumberOfLineNumbers  uint16
        Characteristics      uint32
}

type StringTable(查看源代码)

StringTable 是一个 COFF 字符串表。

type StringTable []byte

func (StringTable) String(查看源代码)

func (st StringTable) String(start uint32) (string, error)

字符串从偏移量开始处的 COFF 字符串表st中提取字符串。

type Symbol(查看源代码)

符号与 COFFSymbol 类似,名称字段由 Go 字符串替换。Symbol 也没有 NumberOfAuxSymbols。

type Symbol struct {
        Name          string
        Value         uint32
        SectionNumber int16
        Type          uint16
        StorageClass  uint8
}
Go

Go 是一种编译型语言,它结合了解释型语言的游刃有余,动态类型语言的开发效率,以及静态类型的安全性。它也打算成为现代的,支持网络与多核计算的语言。要满足这些目标,需要解决一些语言上的问题:一个富有表达能力但轻量级的类型系统,并发与垃圾回收机制,严格的依赖规范等等。这些无法通过库或工具解决好,因此Go也就应运而生了。

主页 https://golang.org/
源码 https://go.googlesource.com/go
发布版本 1.9.2

Go目录

1.档案 | archive
2.缓冲区 | bufio
3.内置 | builtin
4.字节 | bytes
5.压缩 | compress
6.容器 | container
7.上下文 | context
8.加密 | crypto
9.数据库 | database
10.调试 | debug
11.编码 | encoding
12.错误 | errors
13. expvar
14.flag
15. fmt
16. go
17.散列 | hash
18.html
19.图像 | image
20.索引 | index
21.io
22.日志 | log
23.数学 | math
24. math/big
25.math/bits
26.math/cmplx
27.math/rand
28.拟态 | mime
29.net
30.net/http
31. net/mail
32. net/rpc
33.net/smtp
34. net/textproto
35. net/url
36.os
37.路径 | path
38.插件 | plugin
39.反射 | reflect
40.正则表达式 | regexp
41.运行时 | runtime
42.排序算法 | sort
43.转换 | strconv
44.字符串 | strings
45.同步 | sync
46.系统调用 | syscall
47.测试 | testing
48.文本 | text
49.时间戳 | time
50.unicode
51.不安全性 | unsafe
52.Go 语言数据类型
53.Go 语言基础语法
54.Go 语言结构
55.Go 语言 select 语句
56.Go 语言 switch 语句
57.Go 语言 if 语句嵌套
58.Go 语言 if…else 语句
59.Go 语言 if 语句
60.Go 语言运算符
61.Go 语言常量
62.Go 语言函数闭包
63.Go 语言函数作为实参
64.Go 语言函数引用传递值
65.Go 语言函数值传递值
66.Go 语言函数
67.Go 语言 goto 语句
68.Go 语言 continue 语句
69.Go 语言 break 语句
70.Go 语言循环嵌套
71.Go 语言 for 循环
72.Go 语言结构体
73.Go 语言指针作为函数参数
74.Go 语言指向指针的指针
75.Go 语言指针数组
76.Go 语言指针
77.Go 语言向函数传递数组
78.Go 语言多维数组
79.Go 语言变量作用域
80.Go 语言函数方法
81.Go 错误处理
82.Go 语言接口
83.Go 语言类型转换
84.Go 语言递归函数
85.Go 语言Map(集合)
86.Go 语言范围(Range)
87.Go 语言切片(Slice)
88.Go 并发
89.Go fmt.Sprintf 格式化字符串