@@ -196,7 +196,8 @@ NTSTATUS ObjectManager::OpenObject(PCWSTR path, PCWSTR typeName, HANDLE& hObject
196196 // special case: find a handle to this named object and duplicate the handle
197197 //
198198 auto [handle, pid] = FindFirstHandle (path, GetType (typeName)->TypeIndex );
199- hObject = DriverHelper::DupHandle (handle, pid, GENERIC_READ, 0 );
199+ if (handle)
200+ hObject = DriverHelper::DupHandle (handle, pid, access, 0 );
200201 }
201202 else if (type == L" Section" )
202203 status = NT::NtOpenSection (&hObject, access, &attr);
@@ -212,6 +213,8 @@ NTSTATUS ObjectManager::OpenObject(PCWSTR path, PCWSTR typeName, HANDLE& hObject
212213 status = NT::NtOpenKey (&hObject, access, &attr);
213214 else if (type == L" Job" )
214215 status = NT::NtOpenJobObject (&hObject, access, &attr);
216+ else if (type == L" Session" )
217+ status = NT::NtOpenSession (&hObject, access, &attr);
215218 else if (type == L" WindowStation" ) {
216219 hObject = NT::NtUserOpenWindowStation (&attr, access);
217220 status = hObject ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL;
@@ -366,7 +369,7 @@ std::shared_ptr<ObjectTypeInfo> ObjectManager::GetType(USHORT index) {
366369}
367370
368371CString ObjectManager::GetObjectName (HANDLE hObject, ULONG pid, USHORT type) {
369- HANDLE hDup = DriverHelper::DupHandle (hObject, pid, 0 );
372+ HANDLE hDup = DriverHelper::DupHandle (hObject, pid, READ_CONTROL );
370373 CString name;
371374 if (hDup) {
372375 name = GetObjectName (hDup, type);
0 commit comments