/*
* PROJECT: ReactOS Device Manager
* LICENSE: GPL - See COPYING in the top level directory
-* FILE: dll/win32/devmgr/devmgr/ClassNode.cpp
+* FILE: dll/win32/devmgr/devmgmt/ClassNode.cpp
* PURPOSE: Class object for
* COPYRIGHT: Copyright 2015 Ged Murphy <gedmurphy@reactos.org>
*
*/
-#include "stdafx.h"
+#include "precomp.h"
#include "devmgmt.h"
#include "DeviceNode.h"
ZeroMemory(&m_DevinfoData, sizeof(SP_DEVINFO_DATA));
}
+CDeviceNode::CDeviceNode(
+ _In_ const CDeviceNode &Node
+ ) :
+ CNode(Node)
+{
+ m_DevInst = Node.m_DevInst;
+ m_hDevInfo = Node.m_hDevInfo;
+ m_Status = Node.m_Status;
+ m_ProblemNumber = Node.m_ProblemNumber;
+ m_OverlayImage = Node.m_OverlayImage;
+ CopyMemory(&m_DevinfoData, &Node.m_DevinfoData, sizeof(SP_DEVINFO_DATA));
+
+ size_t size = wcslen(Node.m_DeviceId) + 1;
+ m_DeviceId = new WCHAR[size];
+ StringCbCopyW(m_DeviceId, size * sizeof(WCHAR), Node.m_DeviceId);
+
+}
+
CDeviceNode::~CDeviceNode()
{
Cleanup();
m_DeviceId,
ulLength + 1,
0);
- if (cr != CR_SUCCESS)
+ if (cr != CR_SUCCESS || wcscmp(m_DeviceId, L"HTREE\\ROOT\\0") == 0)
{
delete[] m_DeviceId;
m_DeviceId = NULL;
}
- // Set the overlay if the device has a problem
+ // Check if the device has a problem
if (HasProblem())
{
- m_OverlayImage = 1;
+ if (IsDisabled())
+ {
+ m_OverlayImage = OverlayDisabled;
+ }
+ else
+ {
+ m_OverlayImage = OverlayProblem;
+ }
}
- // The disabled overlay takes precidence over the problem overlay
- if (IsDisabled())
- {
- m_OverlayImage = 2;
- }
+
// Get the class guid for this device
&m_ClassGuid,
&m_ClassImage);
+
// Get the description for the device
ulLength = DISPLAY_NAME_LEN * sizeof(WCHAR);
cr = CM_Get_DevNode_Registry_PropertyW(m_DevInst,
}
- // Cleanup if something failed
if (cr != CR_SUCCESS)
{
- Cleanup();
- return false;
+ CAtlStringW str;
+ if (str.LoadStringW(g_hThisInstance, IDS_UNKNOWNDEVICE))
+ StringCchCopyW(m_DisplayName, MAX_PATH, str.GetBuffer());
}
return true;
NULL);
if (cr == CR_SUCCESS)
{
- return ((m_Status & DN_NO_SHOW_IN_DM) != 0);
+ if (m_Status & DN_NO_SHOW_IN_DM)
+ return true;
}
+ if (IsEqualGUID(*GetClassGuid(), GUID_DEVCLASS_LEGACYDRIVER) ||
+ IsEqualGUID(*GetClassGuid(), GUID_DEVCLASS_VOLUME))
+ return true;
+
return false;
}
NULL);
if (cr == CR_SUCCESS)
{
- return ((m_ProblemNumber & (CM_PROB_DISABLED | CM_PROB_HARDWARE_DISABLED)) != 0);
+ return ((m_ProblemNumber == CM_PROB_DISABLED) || (m_ProblemNumber == CM_PROB_HARDWARE_DISABLED));
}
return false;
for (int i = 0; i < 2; i++)
{
// Check globally first, then check config specific
- pcp.Scope = (i == 0) ? DICS_FLAG_GLOBAL : DICS_FLAG_CONFIGSPECIFIC;
+ pcp.Scope = (i == 0) ? DICS_FLAG_CONFIGGENERAL : DICS_FLAG_CONFIGSPECIFIC;
if (SetupDiSetClassInstallParamsW(m_hDevInfo,
&m_DevinfoData,
SetupDiChangeState(m_hDevInfo, &m_DevinfoData);
}
+
if (Enable)
{
// config specific enabling first, then global enabling.