Improvements for /query request

This commit is contained in:
JKornev 2021-07-29 16:53:08 +03:00
parent 05bf7b55b8
commit 2ec973a008
3 changed files with 17 additions and 10 deletions

View File

@ -236,7 +236,7 @@ NTSTATUS GetPsObjectInfo(PHid_GetPsObjectInfoPacket Packet, USHORT Size, PHid_Ge
case PsProtectedObject:
status = GetProtectedProcessState((HANDLE)Packet->procId, &inheritType, &enable);
break;
case PsHiddenObject:
case PsActiveHiddenObject:
status = GetHiddenProcessState((HANDLE)Packet->procId, &inheritType, &enable);
break;
default:
@ -270,7 +270,7 @@ NTSTATUS SetPsObjectInfo(PHid_SetPsObjectInfoPacket Packet, USHORT Size)
case PsProtectedObject:
status = SetProtectedProcessState((HANDLE)Packet->procId, Packet->inheritType, (Packet->enable ? TRUE : FALSE));
break;
case PsHiddenObject:
case PsActiveHiddenObject:
status = SetHiddenProcessState((HANDLE)Packet->procId, Packet->inheritType, (Packet->enable ? TRUE : FALSE));
break;
default:

View File

@ -62,8 +62,8 @@ void CommandQuery::PerformCommand(Connection& connection)
}
else if (m_queryType == EQueryType::QueryProcess)
{
HidActiveState excludeState, protectedState;
HidPsInheritTypes excludedInherit, protectedInherit;
HidActiveState excludeState, protectedState, hiddenState;
HidPsInheritTypes excludedInherit, protectedInherit, hiddenInherit;
status = Hid_GetExcludedState(connection.GetContext(), m_targetProcId, &excludeState, &excludedInherit);
if (!HID_STATUS_SUCCESSFUL(status))
@ -73,13 +73,20 @@ void CommandQuery::PerformCommand(Connection& connection)
if (!HID_STATUS_SUCCESSFUL(status))
throw WException(HID_STATUS_CODE(status), L"Error, query protected state rejected");
status = Hid_GetHiddenState(connection.GetContext(), m_targetProcId, &hiddenState, &hiddenInherit);
if (!HID_STATUS_SUCCESSFUL(status))
throw WException(HID_STATUS_CODE(status), L"Error, query hidden state rejected");
g_stderr << L"Ignored state:" << (excludeState == HidActiveState::StateEnabled ? L"true" : L"false")
<< L", inherit:" << ConvertInheritTypeToUnicode(excludedInherit) << endl;
<< L", inherit:" << ConvertInheritTypeToUnicode(excludedInherit) << endl;
g_stderr << L"Protected state:" << (protectedState == HidActiveState::StateEnabled ? L"true" : L"false")
<< L", inherit:" << ConvertInheritTypeToUnicode(protectedInherit) << endl;
<< L", inherit:" << ConvertInheritTypeToUnicode(protectedInherit) << endl;
g_stderr << L"Hidden state:" << (hiddenState == HidActiveState::StateEnabled ? L"true" : L"false")
<< L", inherit:" << ConvertInheritTypeToUnicode(hiddenInherit) << endl;
g_stdout << L"ignored:" << static_cast<unsigned short>(excludeState) << L"," << static_cast<unsigned short>(excludedInherit)
<< L";protected:" << static_cast<unsigned short>(protectedState) << L"," << static_cast<unsigned short>(protectedInherit) << endl;
<< L";protected:" << static_cast<unsigned short>(protectedState) << L"," << static_cast<unsigned short>(protectedInherit)
<< L";hidden:" << static_cast<unsigned short>(hiddenState) << L"," << static_cast<unsigned short>(hiddenInherit) << endl;
}
}

View File

@ -776,17 +776,17 @@ HidStatus _API Hid_RemoveAllHiddenProcesses(HidContext context)
HidStatus _API Hid_GetHiddenState(HidContext context, HidProcId procId, HidActiveState* state, HidPsInheritTypes* inheritType)
{
return SendIoctl_GetPsStatePacket((PHidContextInternal)context, procId, PsHiddenObject, state, inheritType);
return SendIoctl_GetPsStatePacket((PHidContextInternal)context, procId, PsActiveHiddenObject, state, inheritType);
}
HidStatus _API Hid_AttachHiddenState(HidContext context, HidProcId procId, HidPsInheritTypes inheritType)
{
return SendIoctl_SetPsStatePacket((PHidContextInternal)context, procId, PsHiddenObject, HidActiveState::StateEnabled, inheritType);
return SendIoctl_SetPsStatePacket((PHidContextInternal)context, procId, PsActiveHiddenObject, HidActiveState::StateEnabled, inheritType);
}
HidStatus _API Hid_RemoveHiddenState(HidContext context, HidProcId procId)
{
return SendIoctl_SetPsStatePacket((PHidContextInternal)context, procId, PsHiddenObject, HidActiveState::StateDisabled, HidPsInheritTypes::WithoutInherit);
return SendIoctl_SetPsStatePacket((PHidContextInternal)context, procId, PsActiveHiddenObject, HidActiveState::StateDisabled, HidPsInheritTypes::WithoutInherit);
}
HidStatus _API Hid_NormalizeFilePath(const wchar_t* filePath, wchar_t* normalized, size_t normalizedLen)