@@ -20,6 +20,18 @@ package etw
2020import (
2121 "context"
2222 "fmt"
23+ "net"
24+ "net/http"
25+ "os"
26+ "os/exec"
27+ "path/filepath"
28+ "runtime"
29+ "strings"
30+ "syscall"
31+ "testing"
32+ "time"
33+ "unsafe"
34+
2335 "github.com/rabbitstack/fibratus/internal/evasion"
2436 "github.com/rabbitstack/fibratus/pkg/config"
2537 "github.com/rabbitstack/fibratus/pkg/event"
@@ -39,17 +51,6 @@ import (
3951 "github.com/stretchr/testify/require"
4052 "golang.org/x/sys/windows"
4153 "golang.org/x/sys/windows/registry"
42- "net"
43- "net/http"
44- "os"
45- "os/exec"
46- "path/filepath"
47- "runtime"
48- "strings"
49- "syscall"
50- "testing"
51- "time"
52- "unsafe"
5354)
5455
5556// MockListener receives the event and does nothing but indicating the event was processed.
@@ -626,30 +627,8 @@ func TestEventSourceAllEvents(t *testing.T) {
626627 {
627628 "duplicate handle" ,
628629 func () error {
629- var si windows.StartupInfo
630- var pi windows.ProcessInformation
631- argv , err := windows .UTF16PtrFromString (filepath .Join (os .Getenv ("windir" ), "notepad.exe" ))
632- if err != nil {
633- return err
634- }
635- err = windows .CreateProcess (
636- nil ,
637- argv ,
638- nil ,
639- nil ,
640- true ,
641- 0 ,
642- nil ,
643- nil ,
644- & si ,
645- & pi )
646- if err != nil {
647- return err
648- }
649- time .Sleep (time .Second )
650- defer windows .TerminateProcess (pi .Process , 0 )
651630 hs := handle .NewSnapshotter (& config.Config {EnumerateHandles : true }, nil )
652- handles , err := hs .FindHandles (pi . ProcessId )
631+ handles , err := hs .FindHandles (uint32 ( os . Getppid ()) )
653632 if err != nil {
654633 return err
655634 }
@@ -660,7 +639,7 @@ func TestEventSourceAllEvents(t *testing.T) {
660639 }
661640 }
662641 assert .False (t , dupHandleID == 0 )
663- dup , err := handle .Duplicate (dupHandleID , pi . ProcessId , windows . KEY_READ )
642+ dup , err := handle .Duplicate (dupHandleID , uint32 ( os . Getppid ()), 0 )
664643 if err != nil {
665644 return err
666645 }
0 commit comments