MCPcopy Create free account
hub / github.com/rabbitstack/fibratus / testCallstackEnrichment

Function testCallstackEnrichment

internal/etw/source_test.go:842–1278  ·  view source on GitHub ↗
(t *testing.T, hsnap handle.Snapshotter, psnap ps.Snapshotter)

Source from the content-addressed store, hash-verified

840}
841
842func testCallstackEnrichment(t *testing.T, hsnap handle.Snapshotter, psnap ps.Snapshotter) {
843 event.DropCurrentProc = false
844
845 var procHandle windows.Handle
846
847 var tests = []*struct {
848 name string
849 gen func() error
850 want func(e *event.Event) bool
851 completed bool
852 }{
853 {
854 "create process callstack",
855 func() error {
856 var si windows.StartupInfo
857 var pi windows.ProcessInformation
858 argv, err := windows.UTF16PtrFromString(filepath.Join(os.Getenv("windir"), "notepad.exe"))
859 if err != nil {
860 return err
861 }
862 err = windows.CreateProcess(
863 nil,
864 argv,
865 nil,
866 nil,
867 true,
868 0,
869 nil,
870 nil,
871 &si,
872 &pi)
873 if err != nil {
874 return err
875 }
876 procHandle = pi.Process
877 return nil
878 },
879 func(e *event.Event) bool {
880 if e.IsCreateProcess() && e.Params.MustGetUint32(params.ProcessParentID) == uint32(os.Getpid()) &&
881 strings.EqualFold(e.GetParamAsString(params.ProcessName), "notepad.exe") {
882 callstack := e.Callstack.String()
883 log.Infof("create process event %s: %s", e.String(), callstack)
884 return callstackContainsTestExe(callstack) &&
885 strings.Contains(strings.ToLower(callstack), strings.ToLower("\\WINDOWS\\System32\\KERNELBASE.dll!CreateProcessW"))
886 }
887 return false
888 },
889 false,
890 },
891 {
892 "load Module callstack",
893 nil,
894 func(e *event.Event) bool {
895 if e.IsLoadModule() && filepath.Ext(e.GetParamAsString(params.FilePath)) == ".dll" {
896 callstack := e.Callstack.String()
897 return strings.Contains(strings.ToLower(callstack), strings.ToLower("\\WINDOWS\\System32\\KERNELBASE.dll!LoadLibraryExW")) &&
898 strings.Contains(strings.ToLower(callstack), strings.ToLower("\\WINDOWS\\system32\\ntoskrnl.exe!NtMapViewOfSection"))
899 }

Callers 1

TestCallstackEnrichmentFunction · 0.85

Calls 15

InitMethod · 0.95
CloseMethod · 0.95
RegisterEventListenerMethod · 0.95
OpenMethod · 0.95
CloseMethod · 0.95
EventsMethod · 0.95
ErrorsMethod · 0.95
NewSymbolizerFunction · 0.92
NewDebugHelpResolverFunction · 0.92
callstackContainsTestExeFunction · 0.85
regCreateKeyExFunction · 0.85
createTransactionFunction · 0.85

Tested by

no test coverage detected