(e *event.Event)
| 238 | } |
| 239 | |
| 240 | func (s *snapshotter) AddModule(e *event.Event) error { |
| 241 | pid, err := e.Params.GetPid() |
| 242 | if err != nil { |
| 243 | return err |
| 244 | } |
| 245 | s.mu.Lock() |
| 246 | defer s.mu.Unlock() |
| 247 | |
| 248 | if pid == 0 && e.IsModuleRundown() { |
| 249 | // assume system process if pid is zero |
| 250 | pid = SystemPID |
| 251 | } |
| 252 | proc, ok := s.procs[pid] |
| 253 | if !ok { |
| 254 | return nil |
| 255 | } |
| 256 | |
| 257 | module := pstypes.Module{} |
| 258 | module.Size, _ = e.Params.GetUint64(params.ModuleSize) |
| 259 | module.Checksum, _ = e.Params.GetUint32(params.ModuleCheckSum) |
| 260 | module.Name = e.GetParamAsString(params.ModulePath) |
| 261 | module.BaseAddress = e.Params.TryGetAddress(params.ModuleBase) |
| 262 | module.DefaultBaseAddress = e.Params.TryGetAddress(params.ModuleDefaultBase) |
| 263 | |
| 264 | if e.IsLoadModuleInternal() { |
| 265 | proc.AddModule(module) |
| 266 | return nil |
| 267 | } |
| 268 | |
| 269 | moduleCount.Add(1) |
| 270 | |
| 271 | module.SignatureLevel, _ = e.Params.GetUint32(params.ModuleSignatureLevel) |
| 272 | module.SignatureType, _ = e.Params.GetUint32(params.ModuleSignatureType) |
| 273 | |
| 274 | if strings.EqualFold(proc.Name, filepath.Base(module.Name)) && len(proc.Exe) < len(module.Name) { |
| 275 | // if the module is loaded for the process executable, and |
| 276 | // we don't have the full executable path, override with |
| 277 | // the one from the Module path |
| 278 | proc.Exe = module.Name |
| 279 | } |
| 280 | |
| 281 | proc.AddModule(module) |
| 282 | |
| 283 | return nil |
| 284 | } |
| 285 | |
| 286 | func (s *snapshotter) RemoveThread(pid uint32, tid uint32) error { |
| 287 | s.mu.Lock() |
no test coverage detected