Skip to content

Commit d2fd6d2

Browse files
committed
fix(ps): Assign UUID from internal process state
1 parent 769dcdc commit d2fd6d2

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

pkg/ps/snapshotter_windows.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,11 @@ func (s *snapshotter) Write(e *event.Event) error {
186186
e.AppendParam(params.Exe, params.Path, ps.Exe)
187187
}
188188

189+
// if the process UUID has been initialized when
190+
// the internal event arrived, reassign it to the
191+
// current process state
192+
proc.AssignUUID(ps)
193+
189194
e.AppendParam(params.ProcessTokenIntegrityLevel, params.AnsiString, ps.TokenIntegrityLevel)
190195
e.AppendParam(params.ProcessTokenElevationType, params.AnsiString, ps.TokenElevationType)
191196
e.AppendParam(params.ProcessTokenIsElevated, params.Bool, ps.IsTokenElevated)

pkg/ps/types/types_windows.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,22 @@ package types
2121
import (
2222
"encoding/binary"
2323
"fmt"
24+
"path/filepath"
25+
"strings"
26+
"sync"
27+
2428
"github.com/rabbitstack/fibratus/pkg/sys"
2529
"github.com/rabbitstack/fibratus/pkg/util/cmdline"
2630
"github.com/rabbitstack/fibratus/pkg/util/va"
2731
"golang.org/x/sys/windows"
28-
"path/filepath"
29-
"strings"
30-
"sync"
3132

3233
"github.com/rabbitstack/fibratus/pkg/cap/section"
3334
htypes "github.com/rabbitstack/fibratus/pkg/handle/types"
3435
"github.com/rabbitstack/fibratus/pkg/pe"
3536

36-
"github.com/rabbitstack/fibratus/pkg/util/bootid"
3737
"time"
38+
39+
"github.com/rabbitstack/fibratus/pkg/util/bootid"
3840
)
3941

4042
// PS encapsulates process' state such as allocated resources and other metadata.
@@ -125,6 +127,14 @@ func (ps *PS) UUID() uint64 {
125127
return ps.uuid
126128
}
127129

130+
// AssignUUID assigns the UUID from the given
131+
// process if the UUID has been initialized.
132+
func (ps *PS) AssignUUID(proc *PS) {
133+
if proc.uuid != 0 {
134+
ps.uuid = proc.uuid
135+
}
136+
}
137+
128138
// ProcessSequenceNumber contains the unique process sequence number.
129139
type ProcessSequenceNumber struct {
130140
Seq [8]byte

0 commit comments

Comments
 (0)