Skip to content

Commit c99753d

Browse files
committed
minor fixes
use READ_CONTROL instead of GENERIC_READ
1 parent 32375a8 commit c99753d

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

ObjExp/ObjExp.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ int Run(LPTSTR /*lpstrCmdLine*/ = nullptr, int nCmdShow = SW_SHOWDEFAULT) {
3333

3434
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow) {
3535
SecurityHelper::EnablePrivilege(SE_DEBUG_NAME, true);
36+
SecurityHelper::EnablePrivilege(SE_SECURITY_NAME, true);
3637

3738
HRESULT hRes = ::CoInitialize(nullptr);
3839
ATLASSERT(SUCCEEDED(hRes));

ObjExp/ObjectManager.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

368371
CString 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);

ObjExp/ObjectManager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ class ObjectManager {
192192

193193
const std::vector<std::shared_ptr<ObjectInfo>>& GetObjects() const;
194194

195-
static HANDLE DupHandle(HANDLE h, DWORD pid, ACCESS_MASK access = GENERIC_READ, DWORD flags = 0);
196-
static NTSTATUS OpenObject(PCWSTR path, PCWSTR type, HANDLE& handle, DWORD access = GENERIC_READ);
195+
static HANDLE DupHandle(HANDLE h, DWORD pid, ACCESS_MASK access = READ_CONTROL, DWORD flags = 0);
196+
static NTSTATUS OpenObject(PCWSTR path, PCWSTR type, HANDLE& handle, DWORD access = READ_CONTROL);
197197
static std::pair<HANDLE, DWORD> FindFirstHandle(PCWSTR name, USHORT index, DWORD pid = 0);
198198

199199
enum class ChangeType {

0 commit comments

Comments
 (0)