| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "sandbox/win/src/sync_policy.h" | 7 #include "sandbox/win/src/sync_policy.h" |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 if (!create.AddStringMatch(IF, NameBased::NAME, name, CASE_INSENSITIVE)) | 169 if (!create.AddStringMatch(IF, NameBased::NAME, name, CASE_INSENSITIVE)) |
| 170 return false; | 170 return false; |
| 171 | 171 |
| 172 if (!policy->AddRule(IPC_CREATEEVENT_TAG, &create)) | 172 if (!policy->AddRule(IPC_CREATEEVENT_TAG, &create)) |
| 173 return false; | 173 return false; |
| 174 } | 174 } |
| 175 | 175 |
| 176 return true; | 176 return true; |
| 177 } | 177 } |
| 178 | 178 |
| 179 DWORD SyncPolicy::CreateEventAction(EvalResult eval_result, | 179 NTSTATUS SyncPolicy::CreateEventAction(EvalResult eval_result, |
| 180 const ClientInfo& client_info, | 180 const ClientInfo& client_info, |
| 181 const base::string16 &event_name, | 181 const base::string16 &event_name, |
| 182 uint32 event_type, | 182 uint32 event_type, |
| 183 uint32 initial_state, | 183 uint32 initial_state, |
| 184 HANDLE *handle) { | 184 HANDLE *handle) { |
| 185 NtCreateEventFunction NtCreateEvent = NULL; | 185 NtCreateEventFunction NtCreateEvent = NULL; |
| 186 ResolveNTFunctionPtr("NtCreateEvent", &NtCreateEvent); | 186 ResolveNTFunctionPtr("NtCreateEvent", &NtCreateEvent); |
| 187 | 187 |
| 188 // The only action supported is ASK_BROKER which means create the requested | 188 // The only action supported is ASK_BROKER which means create the requested |
| 189 // file as specified. | 189 // file as specified. |
| 190 if (ASK_BROKER != eval_result) | 190 if (ASK_BROKER != eval_result) |
| 191 return false; | 191 return false; |
| 192 | 192 |
| 193 HANDLE object_directory = NULL; | 193 HANDLE object_directory = NULL; |
| 194 NTSTATUS status = GetBaseNamedObjectsDirectory(&object_directory); | 194 NTSTATUS status = GetBaseNamedObjectsDirectory(&object_directory); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 207 return status; | 207 return status; |
| 208 | 208 |
| 209 if (!::DuplicateHandle(::GetCurrentProcess(), local_handle, | 209 if (!::DuplicateHandle(::GetCurrentProcess(), local_handle, |
| 210 client_info.process, handle, 0, FALSE, | 210 client_info.process, handle, 0, FALSE, |
| 211 DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)) { | 211 DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)) { |
| 212 return STATUS_ACCESS_DENIED; | 212 return STATUS_ACCESS_DENIED; |
| 213 } | 213 } |
| 214 return status; | 214 return status; |
| 215 } | 215 } |
| 216 | 216 |
| 217 DWORD SyncPolicy::OpenEventAction(EvalResult eval_result, | 217 NTSTATUS SyncPolicy::OpenEventAction(EvalResult eval_result, |
| 218 const ClientInfo& client_info, | 218 const ClientInfo& client_info, |
| 219 const base::string16 &event_name, | 219 const base::string16 &event_name, |
| 220 uint32 desired_access, | 220 uint32 desired_access, |
| 221 HANDLE *handle) { | 221 HANDLE *handle) { |
| 222 NtOpenEventFunction NtOpenEvent = NULL; | 222 NtOpenEventFunction NtOpenEvent = NULL; |
| 223 ResolveNTFunctionPtr("NtOpenEvent", &NtOpenEvent); | 223 ResolveNTFunctionPtr("NtOpenEvent", &NtOpenEvent); |
| 224 | 224 |
| 225 // The only action supported is ASK_BROKER which means create the requested | 225 // The only action supported is ASK_BROKER which means create the requested |
| 226 // event as specified. | 226 // event as specified. |
| 227 if (ASK_BROKER != eval_result) | 227 if (ASK_BROKER != eval_result) |
| 228 return false; | 228 return false; |
| 229 | 229 |
| 230 HANDLE object_directory = NULL; | 230 HANDLE object_directory = NULL; |
| 231 NTSTATUS status = GetBaseNamedObjectsDirectory(&object_directory); | 231 NTSTATUS status = GetBaseNamedObjectsDirectory(&object_directory); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 244 | 244 |
| 245 if (!::DuplicateHandle(::GetCurrentProcess(), local_handle, | 245 if (!::DuplicateHandle(::GetCurrentProcess(), local_handle, |
| 246 client_info.process, handle, 0, FALSE, | 246 client_info.process, handle, 0, FALSE, |
| 247 DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)) { | 247 DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)) { |
| 248 return STATUS_ACCESS_DENIED; | 248 return STATUS_ACCESS_DENIED; |
| 249 } | 249 } |
| 250 return status; | 250 return status; |
| 251 } | 251 } |
| 252 | 252 |
| 253 } // namespace sandbox | 253 } // namespace sandbox |
| OLD | NEW |