MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / AddTcp4Connections

Method AddTcp4Connections

WinSysCore/ActiveConnectionTracker.cpp:128–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126}
127
128void ActiveConnectionTracker::AddTcp4Connections(PMIB_TCPTABLE_OWNER_MODULE table, ConnectionMap& map, ConnectionVec& local, bool first) {
129 auto count = table->dwNumEntries;
130 auto& items = table->table;
131
132 for (DWORD i = 0; i < count; i++) {
133 const auto& item = items[i];
134 std::shared_ptr<Connection> conn;
135 if (first) {
136 conn = std::make_shared<Connection>();
137 InitTcp4Connection(conn.get(),item);
138 _connections.push_back(conn);
139 _connectionMap.insert({ *conn,conn });
140 }
141 else {
142 Connection key;
143 key.LocalAddress = item.dwLocalAddr;
144 key.RemoteAddress = item.dwRemoteAddr;
145 key.LocalPort = item.dwLocalPort;
146 key.RemotePort = item.dwRemotePort;
147 key.Pid = item.dwOwningPid;
148 key.Type = ConnectionType::Tcp;
149
150 if (auto it = map.find(key); it != map.end()) {
151 conn = it->second;
152 map.erase(key);
153 }
154 else {
155 conn = std::make_shared<Connection>();
156 InitTcp4Connection(conn.get(), item);
157 _connectionMap.insert({ *conn,conn });
158 _newConnections.push_back(conn);
159 }
160 conn->State = (MIB_TCP_STATE)item.dwState;
161 local.push_back(conn);
162 }
163 }
164}
165
166void ActiveConnectionTracker::AddTcp6Connections(PMIB_TCP6TABLE_OWNER_MODULE table, ConnectionMap& map, ConnectionVec& local, bool first) {
167 auto count = table->dwNumEntries;

Callers

nothing calls this directly

Calls 2

push_backMethod · 0.80
endMethod · 0.45

Tested by

no test coverage detected