本文整理匯總了Golang中github.com/quarnster/util/encoding/binary.BinaryReader.Uint8方法的典型用法代碼示例。如果您正苦於以下問題:Golang BinaryReader.Uint8方法的具體用法?Golang BinaryReader.Uint8怎麽用?Golang BinaryReader.Uint8使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/quarnster/util/encoding/binary.BinaryReader
的用法示例。
在下文中一共展示了BinaryReader.Uint8方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Read
func (l *SLEB128) Read(br *binary.BinaryReader) error {
var (
curr LEB128
shift LEB128
v uint8
err error
)
for {
v, err = br.Uint8()
if err != nil {
return err
}
br := v&0x80 == 0
v = v & 0x7f
curr |= LEB128(v) << shift
shift += 7
if br {
break
}
}
const size = 64
if (shift < size) && v&0x40 != 0 {
curr |= -(1 << shift)
}
*l = SLEB128(curr)
return nil
}
示例2: Read
func (ih *InfoHeader) Read(br *binary.BinaryReader) error {
err := br.ReadInterface(&ih.Header)
if err != nil {
return err
}
if ih.is64 {
ih.DebugAbbrevOffset, err = br.Int64()
} else {
var v uint32
v, err = br.Uint32()
ih.DebugAbbrevOffset = int64(v)
}
if err != nil {
return err
}
ih.AddressSize, err = br.Uint8()
return err
}
示例3: data
func (ie *InfoEntry) data(form DW_FORM, br binary.BinaryReader) interface{} {
if form == DW_FORM_ref_addr && ie.header.Version < 3 {
form = DW_FORM_addr
}
switch form {
case DW_FORM_flag_present:
return true
case DW_FORM_exprloc, DW_FORM_block:
var size LEB128
br.ReadInterface(&size)
r, _ := br.Read(int(size))
return r
case DW_FORM_block1:
size, _ := br.Uint8()
r, _ := br.Read(int(size))
return r
case DW_FORM_block2:
size, _ := br.Uint16()
r, _ := br.Read(int(size))
return r
case DW_FORM_block4:
size, _ := br.Uint32()
r, _ := br.Read(int(size))
return r
case DW_FORM_addr:
if ie.header.AddressSize == 8 {
v, _ := br.Uint64()
return v
} else {
v, _ := br.Uint32()
return uint64(v)
}
case DW_FORM_ref_addr, DW_FORM_strp, DW_FORM_sec_offset:
if ie.header.is64 {
v, _ := br.Uint64()
return v
} else {
v, _ := br.Uint32()
return uint64(v)
}
case DW_FORM_ref1, DW_FORM_flag, DW_FORM_data1:
v, _ := br.Uint8()
return uint64(v)
case DW_FORM_ref2, DW_FORM_data2:
v, _ := br.Uint16()
return uint64(v)
case DW_FORM_ref4, DW_FORM_data4:
v, _ := br.Uint32()
return uint64(v)
case DW_FORM_ref8, DW_FORM_data8:
v, _ := br.Uint64()
return v
case DW_FORM_sdata, DW_FORM_udata:
var r LEB128
br.ReadInterface(&r)
return uint64(r)
case DW_FORM_string:
buf := make([]byte, 4096)
for i := range buf {
if v, err := br.Uint8(); err != nil {
return err
} else if v == 0 {
buf = buf[:i]
break
} else {
buf[i] = byte(v)
}
}
return string(buf)
}
panic(fmt.Errorf("Unimplemented format: %s", form))
}
示例4: parseModelEntryVSET
func parseModelEntryVSET(entry *ModelEntry) error {
reader := binary.BinaryReader{Reader: entry.Data, Endianess: binary.LittleEndian}
var err error
unk, err := reader.Uint16()
count, err := reader.Uint16()
fmt.Printf("Count: %04x\n", count)
fmt.Printf("Unk: %04x\n", unk)
for i := uint16(0); i < count && err == nil; i++ {
var identifier uint16
identifier, err = reader.Uint16()
var data []uint8
if err != nil {
break
}
if identifier&0x8000 != 0 { // Size is fucked up
var sz, unk uint8
unk, err = reader.Uint8()
var size uint16
if unk == 0x10 {
size, err = reader.Uint16()
} else if unk == 0x08 {
sz, err = reader.Uint8()
size = uint16(sz)
} else {
return errors.New("Unknown size flag")
}
fmt.Printf("Oh %02x, %04x\n", unk, size)
x := 2
data = make([]uint8, x*int(size+1))
} else if identifier&0x0900 != 0 { // and 0x0900
data = make([]uint8, 4)
} else if identifier&0x0600 == 0x0600 { // and 0x0600
data = make([]uint8, 2)
} else if identifier&0xff00 != 0 {
fmt.Printf("what the fuck is %04x\n", identifier&0xff00)
//break
}
_, err = util.ReadN(entry.Data, data)
fmt.Printf("\t\t%04x (%08x): %x\n", identifier, len(data), data)
}
if _, err = entry.Data.Read(make([]uint8, 1)); err != io.EOF {
return errors.New("Expected EOF")
}
if err == io.EOF {
return nil
}
return err
}
示例5: Read
func (lh *lineHeader) Read(br *binary.BinaryReader) error {
start, _ := br.Seek(0, 1)
err := br.ReadInterface(&lh.Header)
if err != nil {
return err
}
if lh.is64 {
lh.header_length, err = br.Int64()
} else {
var v uint32
v, err = br.Uint32()
lh.header_length = int64(v)
}
if err != nil {
return err
}
if lh.minimum_instruction_length, err = br.Uint8(); err != nil {
return err
}
lh.maximum_operations_per_instruction = 1
// TODO:
// if lh.maximum_operations_per_instruction, err = br.Uint8(); err != nil {
// return err
// }
if err = br.ReadInterface(&lh.default_is_stmt); err != nil {
return err
} else if lh.line_base, err = br.Int8(); err != nil {
return err
} else if lh.line_range, err = br.Uint8(); err != nil {
return err
} else if lh.opcode_base, err = br.Uint8(); err != nil {
return err
}
lh.standard_opcode_lengths = make([]uint8, lh.opcode_base-1)
if err := br.ReadInterface(&lh.standard_opcode_lengths); err != nil {
return err
}
for {
var s string
if err := br.ReadInterface(&s); err != nil {
return err
} else if s == "" {
break
} else {
lh.include_directories = append(lh.include_directories, s)
}
}
for {
var f fileEntry
pos, _ := br.Seek(0, 1)
if v, err := br.Uint8(); err != nil {
return err
} else if v == '\u0000' {
break
} else {
br.Seek(pos, 0)
}
if err := br.ReadInterface(&f); err != nil {
return err
} else {
lh.file_names = append(lh.file_names, f)
}
}
var s state
s.header = lh
s.reset()
pos, _ := br.Seek(0, 1)
for (pos - 4 - start) < int64(lh.Length) {
var op DW_LNS
if err := br.ReadInterface(&op); err != nil {
return err
}
if op == 0 {
var length LEB128
if err := br.ReadInterface(&length); err != nil {
return err
}
var op2 DW_LNE
if err := br.ReadInterface(&op2); err != nil {
return err
}
s.executeLNE(op2, length-1, br)
} else {
s.execute(op, br)
}
pos, _ = br.Seek(0, 1)
}
return nil
}