AUT_TEXT support

This commit is contained in:
yo 2022-01-04 10:47:10 +01:00
parent 0c7c123fd9
commit 5970632c31

View File

@ -275,6 +275,12 @@ type Exit struct {
Ret uint32 Ret uint32
} }
type Text struct {
Length uint16
Text []byte
}
/* Utilities */ /* Utilities */
func PrintIpv6FromInt(ipv6int [4]uint32) string { func PrintIpv6FromInt(ipv6int [4]uint32) string {
//return fmt.Sprintf("%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x", //return fmt.Sprintf("%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x",
@ -1281,6 +1287,37 @@ func (e *Exit) Print(file *os.File, delimiter string, flags int) {
} }
} }
func NewText(t Text) *Text {
return &Text{
Length: t.Length,
Text: t.Text,
}
}
func (t *Text) GetType() uint8 {
return AUT_TEXT
}
func (t *Text) LoadFromBinary(file *os.File) error {
err := binary.Read(file, binary.BigEndian, &t.Length)
if err != nil { return fmt.Errorf("Unable to read Text.Length from file: %v", err) }
text := make([]byte, t.Length)
err = binary.Read(file, binary.BigEndian, &text)
if err != nil { return fmt.Errorf("Unable to read Text.Text from file: %v", err) }
t.Text = text
return nil
}
func (t *Text) Print(file *os.File, delimiter string, flags int) {
fmt.Fprintf(file, "text%s%s", delimiter, t.Text)
if 0 == (flags & PRT_ONELINE) {
fmt.Fprintf(file, "\n")
}
}
func readRecordToStruct(file *os.File) (Record, error) { func readRecordToStruct(file *os.File) (Record, error) {
var rec Record var rec Record
@ -1376,6 +1413,11 @@ func readRecordToStruct(file *os.File) (Record, error) {
err := p.LoadFromBinary(file) err := p.LoadFromBinary(file)
if err != nil { return rec, fmt.Errorf("Unable to read file: %v", err) } if err != nil { return rec, fmt.Errorf("Unable to read file: %v", err) }
return NewProcess64Ex(p), nil return NewProcess64Ex(p), nil
case AUT_TEXT:
var t Text
err := t.LoadFromBinary(file)
if err != nil { return rec, fmt.Errorf("Unable to read file: %v", err) }
return NewText(t), nil
} }
startOf, _ := file.Seek(0, io.SeekCurrent) startOf, _ := file.Seek(0, io.SeekCurrent)