MCPcopy Create free account
hub / github.com/dobin/RedEdr / getObject

Method getObject

RedEdrShared/process_resolver.cpp:71–98  ·  view source on GitHub ↗

Get an object from the cache

Source from the content-addressed store, hash-verified

69
70// Get an object from the cache
71Process* ProcessResolver::getObject(DWORD id) {
72 {
73 std::lock_guard<std::mutex> lock(cache_mutex);
74 auto it = cache.find(id);
75 if (it != cache.end()) {
76 return &it->second; // Return a pointer to the object
77 }
78 }
79
80 // Does not exist, create and add to cache
81 Process* process = MakeProcess(id, targetProcessNames);
82 if (process == nullptr) {
83 return nullptr;
84 }
85
86 {
87 std::lock_guard<std::mutex> lock(cache_mutex);
88 cache[id] = *process;
89 }
90
91 // Clean up the temporary process object
92 delete process;
93
94 {
95 std::lock_guard<std::mutex> lock(cache_mutex);
96 return &cache[id];
97 }
98}
99
100// Remove an object from the cache
101void ProcessResolver::removeObject(DWORD id) {

Callers 8

TEST_CLASSFunction · 0.80
event_callback_processFunction · 0.80
AnalyzeEventJsonMethod · 0.80
processinfoFunction · 0.80
event_callbackFunction · 0.80

Calls 2

MakeProcessFunction · 0.85
endMethod · 0.45

Tested by 2

TEST_CLASSFunction · 0.64
processinfoFunction · 0.64