deny other users based on SessionId
| 171 | |
| 172 | // deny other users based on SessionId |
| 173 | static bool DenyOtherSession(const CryptContext* con, PDOKAN_FILE_INFO DokanFileInfo) |
| 174 | { |
| 175 | if (!con->m_denyOtherSessions && !con->m_denyServices) { |
| 176 | return false; |
| 177 | } else { |
| 178 | DWORD theirSessionId = 0xffffffff; |
| 179 | if (!GetSessionIdFromDokanFileInfo(DokanFileInfo, theirSessionId)) { |
| 180 | const DWORD lastErr = GetLastError(); |
| 181 | DbgPrint(L"Unable to get sessionId for remote process, LastErr = %u\n", lastErr); |
| 182 | return true; |
| 183 | } |
| 184 | |
| 185 | // session id 0 is for services like AV |
| 186 | if (theirSessionId == 0) { |
| 187 | const auto result = con->m_denyServices; |
| 188 | if (result) { |
| 189 | DbgPrint(L"Denied access by a service\n"); |
| 190 | } |
| 191 | return result; |
| 192 | } |
| 193 | |
| 194 | if (!con->m_denyOtherSessions) { |
| 195 | return false; |
| 196 | } |
| 197 | |
| 198 | if (g_GotSessionId) { |
| 199 | const auto result = theirSessionId != g_SessionId; |
| 200 | if (result) { |
| 201 | DbgPrint(L"Denied access by other session\n"); |
| 202 | } |
| 203 | return result; |
| 204 | } else { |
| 205 | DbgPrint(L"Denied access because deny other sessions in effect but were unable to obtain our session id\n"); |
| 206 | return true; |
| 207 | } |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | static void PrintUserName(PDOKAN_FILE_INFO DokanFileInfo) { |
| 212 |
no test coverage detected