github.com/DataDog/datadog-agent/pkg/security/secl@v0.55.0-devel.0.20240517055856-10c4965fea94/model/process_cache_entry_windows.go (about)

     1  // Unless explicitly stated otherwise all files in this repository are licensed
     2  // under the Apache License Version 2.0.
     3  // This product includes software developed at Datadog (https://www.datadoghq.com/).
     4  // Copyright 2016-present Datadog, Inc.
     5  
     6  package model
     7  
     8  import "time"
     9  
    10  var processContextZero = ProcessCacheEntry{}
    11  
    12  // NewPlaceholderProcessCacheEntry returns an empty process cache entry for failed process resolutions
    13  func NewPlaceholderProcessCacheEntry(pid uint32) *ProcessCacheEntry {
    14  	return &ProcessCacheEntry{ProcessContext: ProcessContext{Process: Process{PIDContext: PIDContext{Pid: pid}}}}
    15  }
    16  
    17  // GetPlaceholderProcessCacheEntry returns an empty process cache entry for failed process resolutions
    18  func GetPlaceholderProcessCacheEntry(pid uint32) *ProcessCacheEntry {
    19  	processContextZero.Pid = pid
    20  	return &processContextZero
    21  }
    22  
    23  // SetAncestor sets the ancestor
    24  func (pc *ProcessCacheEntry) SetAncestor(parent *ProcessCacheEntry) {
    25  	if pc.Ancestor == parent {
    26  		return
    27  	}
    28  
    29  	if pc.Ancestor != nil {
    30  		pc.Ancestor.Release()
    31  	}
    32  
    33  	pc.Ancestor = parent
    34  	pc.Parent = &parent.Process
    35  	parent.Retain()
    36  }
    37  
    38  // Exit a process
    39  func (pc *ProcessCacheEntry) Exit(exitTime time.Time) {
    40  	pc.ExitTime = exitTime
    41  }