Skip to content

Commit

Permalink
hunman readable ClassDescFlags
Browse files Browse the repository at this point in the history
  • Loading branch information
phith0n committed Aug 14, 2021
1 parent c5abf37 commit 3980e17
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tc_normalclassdesc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package javaserialize
import (
"encoding/binary"
"fmt"
"strings"
)

type TCClassDesc struct {
Expand Down Expand Up @@ -35,6 +36,7 @@ func (desc *TCClassDesc) ToBytes() []byte {

func (desc *TCClassDesc) ToString() string {
var b = NewPrinter()

b.Printf("TC_CLASSDESC - %s\n", Hexify(JAVA_TC_CLASSDESC))
b.IncreaseIndent()
b.Printf("@ClassName\n")
Expand All @@ -44,7 +46,7 @@ func (desc *TCClassDesc) ToString() string {
b.Printf("\n")
b.Printf("@SerialVersionUID - %v - %s\n", desc.SerialVersionUID, Hexify(desc.SerialVersionUID))
b.Printf("@Handler - %v\n", desc.Handler)
b.Printf("@ClassDescFlags - %s\n", Hexify(desc.ClassDescFlags))
b.Printf("@ClassDescFlags - %s - %s\n", desc.FlagString(), Hexify(desc.ClassDescFlags))
b.Printf("@FieldCount - %d - %s\n", len(desc.Fields), Hexify(uint16(len(desc.Fields))))
b.Printf("[]Fields \n")
b.IncreaseIndent()
Expand Down Expand Up @@ -79,6 +81,24 @@ func (desc *TCClassDesc) HasFlag(flag byte) bool {
return (desc.ClassDescFlags & flag) == flag
}

func (desc *TCClassDesc) FlagString() string {
var descFlags []string
if desc.HasFlag(JAVA_SC_SERIALIZABLE) {
descFlags = append(descFlags, "SC_SERIALIZABLE")
}
if desc.HasFlag(JAVA_SC_WRITE_METHOD) {
descFlags = append(descFlags, "SC_WRITE_METHOD")
}
if desc.HasFlag(JAVA_SC_EXTERNALIZABLE) {
descFlags = append(descFlags, "SC_EXTERNALIZABLE")
}
if desc.HasFlag(JAVA_SC_BLOCK_DATA) {
descFlags = append(descFlags, "SC_BLOCK_DATA")
}

return strings.Join(descFlags, "|")
}

func readTCNormalClassDesc(stream *ObjectStream) (*TCClassDesc, error) {
var err error
var classDesc = new(TCClassDesc)
Expand Down

0 comments on commit 3980e17

Please sign in to comment.