@@ -14,6 +14,7 @@ import (
14
14
"path/filepath"
15
15
"reflect"
16
16
"strings"
17
+ "sync"
17
18
"text/tabwriter"
18
19
"time"
19
20
"unicode"
@@ -23,6 +24,50 @@ import (
23
24
"github.com/saferwall/pe/log"
24
25
)
25
26
27
+ var (
28
+ wg sync.WaitGroup
29
+ jobs chan string = make (chan string )
30
+ )
31
+
32
+ func loopFilesWorker (cfg config ) error {
33
+ for path := range jobs {
34
+ files , err := os .ReadDir (path )
35
+ if err != nil {
36
+ wg .Done ()
37
+ return err
38
+ }
39
+
40
+ for _ , file := range files {
41
+ if ! file .IsDir () {
42
+ fullpath := filepath .Join (path , file .Name ())
43
+ parse (fullpath , cfg )
44
+ }
45
+ }
46
+ wg .Done ()
47
+ }
48
+ return nil
49
+ }
50
+
51
+ func LoopDirsFiles (path string ) error {
52
+ files , err := os .ReadDir (path )
53
+ if err != nil {
54
+ return err
55
+ }
56
+ //Add this path as a job to the workers
57
+ //You must call it in a go routine, since if every worker is busy, then you have to wait for the channel to be free.
58
+ go func () {
59
+ wg .Add (1 )
60
+ jobs <- path
61
+ }()
62
+ for _ , file := range files {
63
+ if file .IsDir () {
64
+ //Recursively go further in the tree
65
+ LoopDirsFiles (filepath .Join (path , file .Name ()))
66
+ }
67
+ }
68
+ return nil
69
+ }
70
+
26
71
func prettyPrint (buff []byte ) string {
27
72
var prettyJSON bytes.Buffer
28
73
error := json .Indent (& prettyJSON , buff , "" , "\t " )
@@ -500,6 +545,12 @@ func parsePE(filename string, cfg config) {
500
545
501
546
fmt .Printf ("\n RESOURCES\n **********\n " )
502
547
printRsrcDir (pe .Resources )
548
+
549
+ r , err := pe .ParseVersionResources ()
550
+ if err == nil {
551
+ fmt .Print (r )
552
+ }
553
+ fmt .Print ()
503
554
}
504
555
505
556
if cfg .wantException && pe .FileInfo .HasException {
0 commit comments