@@ -464,22 +464,22 @@ func parseDir(b []byte, p int, prefix string, addr uint32) []*resource {
464
464
// Iterate over all entries in the current directory record
465
465
for i := 0 ; i < n ; i ++ {
466
466
o := 8 * i + p + 16
467
- name := int ( le .Uint32 (b [o : o + 4 ]) )
468
- offsetToData := int ( le .Uint32 (b [o + 4 : o + 8 ]) )
467
+ name := le .Uint32 (b [o : o + 4 ])
468
+ offsetToData := le .Uint32 (b [o + 4 : o + 8 ])
469
469
path := prefix
470
- if name < 0 { // Named entry if the high bit is set in the name
471
- dirLen := name & 0x7FFFFFFF
472
- length := int (le .Uint16 (b [dirLen : dirLen + 2 ]))
470
+ if name & 0x80000000 > 0 { // Named entry if the high bit is set in the name
471
+ dirStr := int ( name & 0x7FFFFFFF )
472
+ length := int (le .Uint16 (b [dirStr : dirStr + 2 ]))
473
473
resID := make ([]uint16 , length )
474
- binary .Read (bytes .NewReader (b [dirLen + 2 :dirLen + 2 + length << 1 ]), le , resID )
474
+ binary .Read (bytes .NewReader (b [dirStr + 2 :dirStr + 2 + length << 1 ]), le , resID )
475
475
path += string (utf16 .Decode (resID ))
476
476
} else { // ID entry
477
- path += strconv .Itoa (name )
477
+ path += strconv .Itoa (int ( name ) )
478
478
}
479
479
480
- if offsetToData < 0 { // Ptr to other directory if high bit is set
480
+ if offsetToData & 0x80000000 > 0 { // Ptr to other directory if high bit is set
481
481
// Recursively get the res from the sub dirs
482
- l := parseDir (b , offsetToData & 0x7FFFFFFF , path + "/" , addr )
482
+ l := parseDir (b , int ( offsetToData & 0x7FFFFFFF ) , path + "/" , addr )
483
483
res = append (res , l ... )
484
484
continue
485
485
}
0 commit comments