Chromium Code Reviews| Index: sandbox/src/handle_table.cc |
| =================================================================== |
| --- sandbox/src/handle_table.cc (revision 90713) |
| +++ sandbox/src/handle_table.cc (working copy) |
| @@ -17,6 +17,8 @@ |
| return a.ProcessId < b.ProcessId; |
| } |
| +static NtQueryObject QueryObject = NULL; |
| + |
| } // namespace |
| namespace sandbox { |
| @@ -84,7 +86,6 @@ |
| } |
| void HandleTable::HandleEntry::UpdateInfo(UpdateType flag) { |
| - static NtQueryObject QueryObject = NULL; |
| if (!QueryObject) |
| ResolveNTFunctionPtr("NtQueryObject", &QueryObject); |
| @@ -119,18 +120,8 @@ |
| switch (flag) { |
| case UPDATE_INFO_AND_NAME: |
| if (type_info_buffer_.size() && handle_name_.empty()) { |
| - ULONG size = MAX_PATH; |
| - scoped_ptr<UNICODE_STRING> name; |
| - do { |
| - name.reset(reinterpret_cast<UNICODE_STRING*>(new BYTE[size])); |
| - result = QueryObject(reinterpret_cast<HANDLE>( |
| - handle_entry_->Handle), ObjectNameInformation, name.get(), |
| - size, &size); |
| - } while (result == STATUS_INFO_LENGTH_MISMATCH); |
| - |
| - if (NT_SUCCESS(result)) { |
| - handle_name_.assign(name->Buffer, name->Length / sizeof(wchar_t)); |
| - } |
| + GetHandleName(reinterpret_cast<HANDLE>(handle_entry_->Handle), |
| + &handle_name_); |
| } |
| break; |
| @@ -144,6 +135,27 @@ |
| } |
| } |
| +// Returns the object manager's name associated with a handle |
| +NTSTATUS GetHandleName(HANDLE handle, string16* handle_name) { |
| + if (!QueryObject) |
| + ResolveNTFunctionPtr("NtQueryObject", &QueryObject); |
| + |
| + ULONG size = MAX_PATH; |
| + scoped_ptr<UNICODE_STRING> name; |
| + NTSTATUS result; |
| + |
| + do { |
| + name.reset(reinterpret_cast<UNICODE_STRING*>(new BYTE[size])); |
| + result = QueryObject(handle, ObjectNameInformation, name.get(), |
| + size, &size); |
|
nsylvain
2011/06/30 19:21:46
should you not align size with handle?
jschuh
2011/07/01 01:24:26
Done.
|
| + } while (result == STATUS_INFO_LENGTH_MISMATCH); |
| + |
| + if (NT_SUCCESS(result)) |
| + handle_name->assign(name->Buffer, name->Length / sizeof(wchar_t)); |
| + |
| + return result; |
|
cpu_(ooo_6.6-7.5)
2011/06/30 20:39:39
I would return a boolean. That reflects its curren
jschuh
2011/07/01 01:24:26
Done.
|
| +} |
| + |
| const OBJECT_TYPE_INFORMATION* HandleTable::HandleEntry::TypeInfo() { |
| UpdateInfo(UPDATE_INFO_ONLY); |
| return type_info_buffer_.empty() ? NULL : type_info_internal(); |