ReactOS 0.4.17-dev-1133-gc25e4fd
IoDeviceProperty.c File Reference
#include <kmt_test.h>
#include <devpkey.h>
#include <debug.h>
Include dependency graph for IoDeviceProperty.c:

Go to the source code of this file.

Classes

struct  _PROPERTY_TARGET
 

Macros

#define NDEBUG
 
#define KMT_PROPERTY_FMTID   { 0x5F1E3C8A, 0x7D2B, 0x4E61, { 0x9A, 0x0C, 0x3B, 0x8D, 0x4F, 0x2E, 0x6A, 0x17 } }
 
#define LCID_EN_US   0x0409
 
#define LCID_DE_DE   0x0407
 
#define ADD_CASE(t, d, s, e)
 

Typedefs

typedef struct _PROPERTY_TARGET PROPERTY_TARGET
 
typedef struct _PROPERTY_TARGET * PPROPERTY_TARGET
 
typedef NTSTATUS(NTAPI * PSET_INTERFACE_PROPERTY_ROUTINE) (_In_ PUNICODE_STRING SymbolicLinkName, _In_ CONST DEVPROPKEY *PropertyKey, _In_ LCID Lcid, _In_ ULONG Flags, _In_ DEVPROPTYPE Type, _In_ ULONG Size, _In_reads_bytes_opt_(Size) PVOID Data)
 
typedef NTSTATUS(NTAPI * PGET_INTERFACE_PROPERTY_ROUTINE) (_In_ PUNICODE_STRING SymbolicLinkName, _In_ CONST DEVPROPKEY *PropertyKey, _In_ LCID Lcid, _Reserved_ ULONG Flags, _In_ ULONG Size, _Out_writes_bytes_to_opt_(Size, *RequiredSize) PVOID Data, _Out_ PULONG RequiredSize, _Out_ PDEVPROPTYPE Type)
 

Functions

static NTSTATUS SetProperty (_In_ PPROPERTY_TARGET Target, _In_ const DEVPROPKEY *Key, _In_ LCID Lcid, _In_ DEVPROPTYPE Type, _In_ ULONG Size, _In_reads_bytes_opt_(Size) PVOID Data)
 
static NTSTATUS GetProperty (_In_ PPROPERTY_TARGET Target, _In_ const DEVPROPKEY *Key, _In_ LCID Lcid, _In_ ULONG Size, _Out_writes_bytes_to_opt_(Size, *RequiredSize) PVOID Data, _Out_ PULONG RequiredSize, _Out_ PDEVPROPTYPE Type)
 
static VOID ExpectProperty (_In_ PPROPERTY_TARGET Target, _In_ const DEVPROPKEY *Key, _In_ LCID Lcid, _In_ DEVPROPTYPE ExpectedType, _In_reads_bytes_(ExpectedSize) PVOID ExpectedData, _In_ ULONG ExpectedSize)
 
static VOID ExpectNoProperty (_In_ PPROPERTY_TARGET Target, _In_ const DEVPROPKEY *Key, _In_ LCID Lcid)
 
static VOID Test_StoreRoundTrip (_In_ PPROPERTY_TARGET Target)
 
static VOID Test_LegacyLocales (_In_ PPROPERTY_TARGET Target)
 
static VOID Test_Locales (_In_ PPROPERTY_TARGET Target)
 
static VOID Test_Validation (_In_ PPROPERTY_TARGET Target)
 
static VOID Test_DeviceBuiltins (_In_ PPROPERTY_TARGET Target)
 
static VOID Test_InterfaceBuiltins (_In_ PPROPERTY_TARGET Target, _In_ const GUID *InterfaceClass)
 
static VOID Test_InterfaceParameters (VOID)
 
static PDEVICE_OBJECT ReferenceInterfacePdo (_In_ PUNICODE_STRING SymbolicLinkName)
 
static BOOLEAN FindTestInterface (_Out_ PUNICODE_STRING SymbolicLinkName, _Out_ PDEVICE_OBJECT *Pdo, _Out_ const GUID **InterfaceClass)
 
static PDEVICE_OBJECT GetRootPdo (_In_ PDEVICE_OBJECT Pdo)
 
static VOID Test_RootDevice (_In_ PDEVICE_OBJECT Pdo)
 
 START_TEST (IoDeviceProperty)
 

Variables

static const DEVPROPKEY TestKeyNumber = { KMT_PROPERTY_FMTID, 2 }
 
static const DEVPROPKEY TestKeyString = { KMT_PROPERTY_FMTID, 3 }
 
static const DEVPROPKEY TestKeyList = { KMT_PROPERTY_FMTID, 4 }
 
static const DEVPROPKEY TestKeyBinary = { KMT_PROPERTY_FMTID, 5 }
 
static const DEVPROPKEY TestKeyLocalized = { KMT_PROPERTY_FMTID, 6 }
 
static const DEVPROPKEY TestKeyWidePid = { KMT_PROPERTY_FMTID, 0x12345 }
 
static const DEVPROPKEY TestKeyInvalid = { KMT_PROPERTY_FMTID, 7 }
 
static const GUID KmtDiskInterface = { 0x53F56307, 0xB6BF, 0x11D0, { 0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B } }
 
static const GUID KmtCdromInterface = { 0x53F56308, 0xB6BF, 0x11D0, { 0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B } }
 
static const GUID KmtVolumeInterface = { 0x53F5630D, 0xB6BF, 0x11D0, { 0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B } }
 
static const GUID * CandidateClasses []
 
static PSET_INTERFACE_PROPERTY_ROUTINE pIoSetDeviceInterfacePropertyData
 
static PGET_INTERFACE_PROPERTY_ROUTINE pIoGetDeviceInterfacePropertyData
 
static BOOLEAN LegacyStore
 

Macro Definition Documentation

◆ ADD_CASE

#define ADD_CASE (   t,
  d,
  s,
  e 
)
Value:
do { ASSERT(Index < RTL_NUMBER_OF(Cases)); \
Cases[Index].Type = (t); Cases[Index].Data = (PVOID)(d); \
Cases[Index].Size = (s); Cases[Index].Expected = (e); Index++; } while (0)
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
GLdouble s
Definition: gl.h:2039
GLdouble GLdouble t
Definition: gl.h:2047
#define d
Definition: ke_i.h:81
#define e
Definition: ke_i.h:82
#define ASSERT(a)
Definition: mode.c:44
void * PVOID
Definition: typedefs.h:50
_In_ WDFCOLLECTION _In_ ULONG Index

◆ KMT_PROPERTY_FMTID

#define KMT_PROPERTY_FMTID   { 0x5F1E3C8A, 0x7D2B, 0x4E61, { 0x9A, 0x0C, 0x3B, 0x8D, 0x4F, 0x2E, 0x6A, 0x17 } }

Definition at line 14 of file IoDeviceProperty.c.

◆ LCID_DE_DE

#define LCID_DE_DE   0x0407

Definition at line 36 of file IoDeviceProperty.c.

◆ LCID_EN_US

#define LCID_EN_US   0x0409

Definition at line 35 of file IoDeviceProperty.c.

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file IoDeviceProperty.c.

Typedef Documentation

◆ PGET_INTERFACE_PROPERTY_ROUTINE

◆ PPROPERTY_TARGET

◆ PROPERTY_TARGET

◆ PSET_INTERFACE_PROPERTY_ROUTINE

Function Documentation

◆ ExpectNoProperty()

static VOID ExpectNoProperty ( _In_ PPROPERTY_TARGET  Target,
_In_ const DEVPROPKEY *  Key,
_In_ LCID  Lcid 
)
static

Definition at line 155 of file IoDeviceProperty.c.

159{
160 UCHAR Buffer[16];
161 ULONG Required = 0x55555555;
162 DEVPROPTYPE Type = 0x55555555;
164
167 if (LegacyStore)
168 {
169 ok_eq_ulong(Required, 0x55555555UL);
170 ok_eq_hex(Type, 0x55555555UL);
171 }
172 else
173 {
176 }
177}
static BOOLEAN LegacyStore
static NTSTATUS GetProperty(_In_ PPROPERTY_TARGET Target, _In_ const DEVPROPKEY *Key, _In_ LCID Lcid, _In_ ULONG Size, _Out_writes_bytes_to_opt_(Size, *RequiredSize) PVOID Data, _Out_ PULONG RequiredSize, _Out_ PDEVPROPTYPE Type)
Type
Definition: Type.h:7
#define ok_eq_hex(value, expected)
Definition: apitest.h:136
#define ok_eq_ulong(value, expected)
Definition: apitest.h:122
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
ULONG DEVPROPTYPE
Definition: devpropdef.h:24
#define DEVPROP_TYPE_EMPTY
Definition: devpropdef.h:29
Status
Definition: gdiplustypes.h:24
_Out_ PLCID Lcid
Definition: rtlfuncs.h:5207
_In_ PMEMORY_AREA _In_ PVOID _In_ BOOLEAN _Inout_ PMM_REQUIRED_RESOURCES Required
Definition: newmm.h:210
#define UL
Definition: tui.h:165
unsigned char UCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306

Referenced by Test_DeviceBuiltins(), Test_LegacyLocales(), Test_Locales(), Test_RootDevice(), Test_StoreRoundTrip(), and Test_Validation().

◆ ExpectProperty()

static VOID ExpectProperty ( _In_ PPROPERTY_TARGET  Target,
_In_ const DEVPROPKEY *  Key,
_In_ LCID  Lcid,
_In_ DEVPROPTYPE  ExpectedType,
_In_reads_bytes_(ExpectedSize) PVOID  ExpectedData,
_In_ ULONG  ExpectedSize 
)
static

Definition at line 110 of file IoDeviceProperty.c.

117{
118 UCHAR Buffer[128];
122
123 ASSERT(ExpectedSize < sizeof(Buffer));
124
125 Required = 0x55555555;
126 Type = 0x55555555;
129 ok_eq_ulong(Required, ExpectedSize);
130 ok_eq_hex(Type, ExpectedType);
131
132 if (ExpectedSize)
133 {
134 RtlFillMemory(Buffer, sizeof(Buffer), 0xAA);
135 Status = GetProperty(Target, Key, Lcid, ExpectedSize - 1, Buffer, &Required, &Type);
137 ok_eq_ulong(Required, ExpectedSize);
138 ok_eq_uint(Buffer[0], 0xAA);
139 }
140
141 RtlFillMemory(Buffer, sizeof(Buffer), 0xAA);
142 Required = 0x55555555;
143 Type = 0x55555555;
146 ok_eq_ulong(Required, ExpectedSize);
147 ok_eq_hex(Type, ExpectedType);
148 ok(RtlEqualMemory(Buffer, ExpectedData, ExpectedSize),
149 "%s: property data does not match\n", Target->Description);
150 ok_eq_uint(Buffer[ExpectedSize], 0xAA);
151}
#define ok_eq_uint(value, expected)
Definition: apitest.h:120
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define RtlEqualMemory(dst, src, len)
Definition: kdvm.h:18
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:603
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69

Referenced by Test_DeviceBuiltins(), Test_LegacyLocales(), Test_Locales(), Test_RootDevice(), Test_StoreRoundTrip(), and Test_Validation().

◆ FindTestInterface()

static BOOLEAN FindTestInterface ( _Out_ PUNICODE_STRING  SymbolicLinkName,
_Out_ PDEVICE_OBJECT *  Pdo,
_Out_ const GUID **  InterfaceClass 
)
static

Definition at line 672 of file IoDeviceProperty.c.

676{
680 ULONG i;
682
683 for (i = 0; i < RTL_NUMBER_OF(CandidateClasses); i++)
684 {
686 if (!NT_SUCCESS(Status))
687 continue;
688
692 {
694
696 if (!*Pdo)
697 continue;
698
700 {
702 continue;
703 }
704
707 return TRUE;
708 }
709
711 }
712
713 return FALSE;
714}
static PDEVICE_OBJECT ReferenceInterfacePdo(_In_ PUNICODE_STRING SymbolicLinkName)
static const GUID * CandidateClasses[]
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988
static const WCHAR SymbolicLink[]
Definition: interface.c:31
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_In_ PUNICODE_STRING SymbolicLinkName
Definition: hubucx.h:491
_In_ UCXUSBDEVICE _In_ PDEVICE_OBJECT Pdo
Definition: hubucx.h:280
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define UNICODE_NULL
_NullNull_terminated_ WCHAR * PZZWSTR
Definition: ntbasedef.h:432
NTSTATUS NTAPI IoGetDeviceInterfaces(IN CONST GUID *InterfaceClassGuid, IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, IN ULONG Flags, OUT PWSTR *SymbolicLinkList)
Definition: deviface.c:950
uint16_t * PWSTR
Definition: typedefs.h:56
_In_ PVOID _In_ LONG _In_ LONG _In_ LONG InterfaceClass
Definition: usbdlib.h:198
static int Link(const char **args)
Definition: vfdcmd.c:2414
_In_opt_ PDEVICE_OBJECT _In_ ULONG _Outptr_result_nullonfailure_ _At_ * SymbolicLinkList(return==0, __drv_allocatesMem(Mem))) PZZWSTR *SymbolicLinkList
#define ObDereferenceObject
Definition: obfuncs.h:203

Referenced by START_TEST().

◆ GetProperty()

static NTSTATUS GetProperty ( _In_ PPROPERTY_TARGET  Target,
_In_ const DEVPROPKEY *  Key,
_In_ LCID  Lcid,
_In_ ULONG  Size,
_Out_writes_bytes_to_opt_(Size, *RequiredSize) PVOID  Data,
_Out_ PULONG  RequiredSize,
_Out_ PDEVPROPTYPE  Type 
)
static

Definition at line 93 of file IoDeviceProperty.c.

101{
102 if (Target->Pdo)
103 return IoGetDevicePropertyData(Target->Pdo, Key, Lcid, 0, Size, Data, RequiredSize, Type);
104
105 return pIoGetDeviceInterfacePropertyData(Target->SymbolicLinkName, Key, Lcid, 0, Size, Data, RequiredSize, Type);
106}
static PGET_INTERFACE_PROPERTY_ROUTINE pIoGetDeviceInterfacePropertyData
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4445

Referenced by DECLARE_INTERFACE_(), DECLARE_INTERFACE_IID_(), ExpectNoProperty(), ExpectProperty(), SEALED_::IMsRdpClient2::get_ConnectedStatusText(), SEALED_::IMsRdpClient::get_ColorDepth(), SEALED_::IMsRdpClient::get_ExtendedDisconnectReason(), SEALED_::IMsRdpClient::get_FullScreen(), SEALED_::IMsRdpClientNonScriptable2::get_UIParentWindowHandle(), SEALED_::IMsTscAx::get_Connected(), SEALED_::IMsTscAx::get_ConnectingText(), SEALED_::IMsTscAx::get_DesktopHeight(), SEALED_::IMsTscAx::get_DesktopWidth(), SEALED_::IMsTscAx::get_DisconnectedText(), SEALED_::IMsTscAx::get_Domain(), SEALED_::IMsTscAx::get_SecuredSettingsEnabled(), SEALED_::IMsTscAx::get_Server(), SEALED_::IMsTscAx::get_StartConnected(), SEALED_::IMsTscAx::get_UserName(), Test_DeviceBuiltins(), and Test_InterfaceBuiltins().

◆ GetRootPdo()

static PDEVICE_OBJECT GetRootPdo ( _In_ PDEVICE_OBJECT  Pdo)
static

Definition at line 718 of file IoDeviceProperty.c.

720{
722 PDEVICE_NODE DeviceNode = Extension->DeviceNode;
723
724 if (!DeviceNode)
725 return NULL;
726
727 while (DeviceNode->Parent)
728 DeviceNode = DeviceNode->Parent;
729
730 return DeviceNode->PhysicalDeviceObject;
731}
@ DeviceNode
Definition: Node.h:9
_Inout_opt_ PUNICODE_STRING Extension
Definition: fltkernel.h:1092
if(dx< 0)
Definition: linetemp.h:194
struct _EXTENDED_DEVOBJ_EXTENSION * PEXTENDED_DEVOBJ_EXTENSION

Referenced by Test_RootDevice().

◆ ReferenceInterfacePdo()

static PDEVICE_OBJECT ReferenceInterfacePdo ( _In_ PUNICODE_STRING  SymbolicLinkName)
static

Definition at line 634 of file IoDeviceProperty.c.

636{
637 WCHAR NameBuffer[256];
638 PDEVICE_OBJECT TopDevice, DeviceObject;
642
645 &FileObject,
646 &TopDevice);
647 if (!NT_SUCCESS(Status))
648 {
649 trace("Cannot open %wZ, status 0x%08lx\n", SymbolicLinkName, Status);
650 return NULL;
651 }
652
655
658 sizeof(NameBuffer),
659 NameBuffer,
660 &Length);
662 {
664 return NULL;
665 }
666
667 return DeviceObject;
668}
#define trace
Definition: atltest.h:70
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
PDEVICE_OBJECT NTAPI IoGetDeviceAttachmentBaseRef(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1434
NTSTATUS NTAPI IoGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1455
short WCHAR
Definition: pedump.c:58
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
Definition: pnpmgr.c:1382
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2061
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
@ DevicePropertyPhysicalDeviceObjectName
Definition: iotypes.h:1206
* PFILE_OBJECT
Definition: iotypes.h:1998

Referenced by FindTestInterface().

◆ SetProperty()

◆ START_TEST()

START_TEST ( IoDeviceProperty  )

Definition at line 771 of file IoDeviceProperty.c.

772{
773 PROPERTY_TARGET DeviceTarget = { "device", NULL, NULL };
774 PROPERTY_TARGET InterfaceTarget = { "interface", NULL, NULL };
776 const GUID *InterfaceClass;
778 BOOLEAN HaveInterfaceRoutines;
779
781
782 pIoSetDeviceInterfacePropertyData = KmtGetSystemRoutineAddress(L"IoSetDeviceInterfacePropertyData");
783 pIoGetDeviceInterfacePropertyData = KmtGetSystemRoutineAddress(L"IoGetDeviceInterfacePropertyData");
785
786 if (!skip(HaveInterfaceRoutines, "Device interface property routines unavailable\n"))
788
790 "No device interface with a PnP PDO found\n"))
791 {
792 return;
793 }
794
795 trace("Using %wZ\n", &SymbolicLinkName);
796
797 DeviceTarget.Pdo = Pdo;
798 InterfaceTarget.SymbolicLinkName = &SymbolicLinkName;
799
800 Test_StoreRoundTrip(&DeviceTarget);
801 Test_Locales(&DeviceTarget);
802 Test_Validation(&DeviceTarget);
803 if (!skip(!LegacyStore, "No builtin or protected properties before NT 6.2\n"))
804 {
805 Test_DeviceBuiltins(&DeviceTarget);
807 }
808
809 if (!skip(HaveInterfaceRoutines, "Device interface property routines unavailable\n"))
810 {
811 Test_StoreRoundTrip(&InterfaceTarget);
812 Test_Locales(&InterfaceTarget);
813 Test_Validation(&InterfaceTarget);
814 Test_InterfaceBuiltins(&InterfaceTarget, InterfaceClass);
815 }
816
819}
static VOID Test_RootDevice(_In_ PDEVICE_OBJECT Pdo)
static VOID Test_InterfaceBuiltins(_In_ PPROPERTY_TARGET Target, _In_ const GUID *InterfaceClass)
static VOID Test_DeviceBuiltins(_In_ PPROPERTY_TARGET Target)
static VOID Test_Locales(_In_ PPROPERTY_TARGET Target)
static VOID Test_InterfaceParameters(VOID)
static VOID Test_Validation(_In_ PPROPERTY_TARGET Target)
static BOOLEAN FindTestInterface(_Out_ PUNICODE_STRING SymbolicLinkName, _Out_ PDEVICE_OBJECT *Pdo, _Out_ const GUID **InterfaceClass)
static VOID Test_StoreRoundTrip(_In_ PPROPERTY_TARGET Target)
unsigned char BOOLEAN
Definition: actypes.h:127
#define GetNTVersion()
Definition: apitest.h:17
#define skip(...)
Definition: atltest.h:64
#define L(x)
Definition: resources.c:13
#define is_reactos()
Definition: kmt_test.h:534
PVOID KmtGetSystemRoutineAddress(IN PCWSTR RoutineName)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define _WIN32_WINNT_WIN8
Definition: sdkddkver.h:29
PUNICODE_STRING SymbolicLinkName
PDEVICE_OBJECT Pdo

◆ Test_DeviceBuiltins()

static VOID Test_DeviceBuiltins ( _In_ PPROPERTY_TARGET  Target)
static

Definition at line 432 of file IoDeviceProperty.c.

434{
435 static const WCHAR FriendlyName[] = L"kmtest friendly name";
436 static UNICODE_STRING PnpManagerName = RTL_CONSTANT_STRING(L"\\Driver\\PnpManager");
437 WCHAR Expected[512], Actual[512], Saved[512];
438 ULONG ExpectedLength, Required, SavedSize = 0;
440 DEVPROP_BOOLEAN Boolean;
441 BOOLEAN HadFriendlyName;
444
445 trace("Device builtins\n");
446
448 sizeof(Expected), Expected, &ExpectedLength);
450 Status = GetProperty(Target, &DEVPKEY_Device_InstanceId, LOCALE_NEUTRAL,
451 sizeof(Actual), Actual, &Required, &Type);
454 if (NT_SUCCESS(Status))
455 {
456 SIZE_T EnumeratorChars = wcslen(Expected);
457
458 ok_eq_ulong(Required, (ULONG)((wcslen(Actual) + 1) * sizeof(WCHAR)));
459 ok(!_wcsnicmp(Actual, Expected, EnumeratorChars) && (Actual[EnumeratorChars] == L'\\'),
460 "Instance ID '%ls' does not start with enumerator '%ls'\n", Actual, Expected);
461 }
462
464 sizeof(Expected), Expected, &ExpectedLength);
466 Status = GetProperty(Target, &DEVPKEY_Device_PDOName, LOCALE_NEUTRAL,
467 sizeof(Actual), Actual, &Required, &Type);
470 if (NT_SUCCESS(Status))
471 ok_eq_wstr(Actual, Expected);
472
474 sizeof(Expected), Expected, &ExpectedLength);
475 if (!skip(NT_SUCCESS(Status), "No hardware IDs: 0x%08lx\n", Status))
476 {
477 Status = GetProperty(Target, &DEVPKEY_Device_HardwareIds, LOCALE_NEUTRAL,
478 sizeof(Actual), Actual, &Required, &Type);
481 if (NT_SUCCESS(Status))
482 ok_eq_wstr(Actual, Expected);
483
484 if (!RtlEqualUnicodeString(&Target->Pdo->DriverObject->DriverName, &PnpManagerName, TRUE))
485 {
486 Status = SetProperty(Target, &DEVPKEY_Device_HardwareIds, LOCALE_NEUTRAL,
489 }
490 }
491
492 Status = GetProperty(Target, &DEVPKEY_Device_DevNodeStatus, LOCALE_NEUTRAL,
493 sizeof(Number), &Number, &Required, &Type);
496 ok_eq_ulong(Required, (ULONG)sizeof(Number));
497
498 Status = GetProperty(Target, &DEVPKEY_Device_ProblemCode, LOCALE_NEUTRAL,
499 sizeof(Number), &Number, &Required, &Type);
502
503 Boolean = 0x55;
504 Status = GetProperty(Target, &DEVPKEY_Device_IsPresent, LOCALE_NEUTRAL,
505 sizeof(Boolean), &Boolean, &Required, &Type);
508 ok_eq_int(Boolean, DEVPROP_TRUE);
509
510 Status = GetProperty(Target, &DEVPKEY_Device_Parent, LOCALE_NEUTRAL,
511 sizeof(Actual), Actual, &Required, &Type);
514
515 Status = SetProperty(Target, &DEVPKEY_Device_InstanceId, LOCALE_NEUTRAL,
516 DEVPROP_TYPE_STRING, sizeof(FriendlyName), (PVOID)FriendlyName);
518 Status = SetProperty(Target, &DEVPKEY_Device_PDOName, LOCALE_NEUTRAL,
519 DEVPROP_TYPE_STRING, sizeof(FriendlyName), (PVOID)FriendlyName);
521
522 Status = GetProperty(Target, &DEVPKEY_Device_FriendlyName, LOCALE_NEUTRAL,
523 sizeof(Saved), Saved, &SavedSize, &Type);
524 HadFriendlyName = NT_SUCCESS(Status);
525 ok(HadFriendlyName || (Status == STATUS_OBJECT_NAME_NOT_FOUND),
526 "Unexpected status 0x%08lx reading the friendly name\n", Status);
527
528 Status = SetProperty(Target, &DEVPKEY_Device_FriendlyName, LOCALE_NEUTRAL,
529 DEVPROP_TYPE_STRING, sizeof(FriendlyName), (PVOID)FriendlyName);
531 ExpectProperty(Target, &DEVPKEY_Device_FriendlyName, LOCALE_NEUTRAL,
532 DEVPROP_TYPE_STRING, (PVOID)FriendlyName, sizeof(FriendlyName));
533
535 sizeof(Expected), Expected, &ExpectedLength);
537 if (NT_SUCCESS(Status))
538 ok_eq_wstr(Expected, FriendlyName);
539
540 Number = 1;
541 Status = SetProperty(Target, &DEVPKEY_Device_FriendlyName, LOCALE_NEUTRAL,
544
545 if (HadFriendlyName)
546 {
547 Status = SetProperty(Target, &DEVPKEY_Device_FriendlyName, LOCALE_NEUTRAL,
548 DEVPROP_TYPE_STRING, SavedSize, Saved);
550 }
551 else
552 {
553 Status = SetProperty(Target, &DEVPKEY_Device_FriendlyName, LOCALE_NEUTRAL,
556 ExpectNoProperty(Target, &DEVPKEY_Device_FriendlyName, LOCALE_NEUTRAL);
557 }
558}
BOOLEAN Expected
static NTSTATUS SetProperty(_In_ PPROPERTY_TARGET Target, _In_ const DEVPROPKEY *Key, _In_ LCID Lcid, _In_ DEVPROPTYPE Type, _In_ ULONG Size, _In_reads_bytes_opt_(Size) PVOID Data)
static VOID ExpectNoProperty(_In_ PPROPERTY_TARGET Target, _In_ const DEVPROPKEY *Key, _In_ LCID Lcid)
static VOID ExpectProperty(_In_ PPROPERTY_TARGET Target, _In_ const DEVPROPKEY *Key, _In_ LCID Lcid, _In_ DEVPROPTYPE ExpectedType, _In_reads_bytes_(ExpectedSize) PVOID ExpectedData, _In_ ULONG ExpectedSize)
#define ok_eq_wstr(value, expected)
Definition: apitest.h:143
#define ok_eq_int(value, expected)
Definition: apitest.h:119
CHAR DEVPROP_BOOLEAN
Definition: devpropdef.h:64
#define DEVPROP_TYPE_BOOLEAN
Definition: devpropdef.h:46
#define DEVPROP_TYPE_UINT32
Definition: devpropdef.h:36
#define DEVPROP_TYPE_STRING_LIST
Definition: devpropdef.h:48
#define DEVPROP_TRUE
Definition: devpropdef.h:66
#define DEVPROP_TYPE_STRING
Definition: devpropdef.h:47
#define RTL_CONSTANT_STRING(s)
Definition: combase.c:35
_ACRTIMP int __cdecl _wcsnicmp(const wchar_t *, const wchar_t *, size_t)
Definition: wcs.c:200
_In_ ULONG Number
Definition: haltypes.h:1940
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
#define LOCALE_NEUTRAL
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
@ DevicePropertyEnumeratorName
Definition: iotypes.h:1210
@ DevicePropertyFriendlyName
Definition: iotypes.h:1204
@ DevicePropertyHardwareID
Definition: iotypes.h:1196

Referenced by START_TEST().

◆ Test_InterfaceBuiltins()

static VOID Test_InterfaceBuiltins ( _In_ PPROPERTY_TARGET  Target,
_In_ const GUID *  InterfaceClass 
)
static

Definition at line 562 of file IoDeviceProperty.c.

565{
567 WCHAR InstanceId[256];
570 GUID ClassGuid;
572
573 trace("Interface builtins\n");
574
575 Status = GetProperty(Target, &DEVPKEY_DeviceInterface_ClassGuid, LOCALE_NEUTRAL,
576 sizeof(ClassGuid), &ClassGuid, &Required, &Type);
579 ok_eq_ulong(Required, (ULONG)sizeof(GUID));
580 ok(RtlEqualMemory(&ClassGuid, InterfaceClass, sizeof(GUID)), "Wrong interface class\n");
581
582 Status = GetProperty(Target, &DEVPKEY_DeviceInterface_Enabled, LOCALE_NEUTRAL,
583 sizeof(Enabled), &Enabled, &Required, &Type);
587
588 Status = GetProperty(Target, &DEVPKEY_Device_InstanceId, LOCALE_NEUTRAL,
589 sizeof(InstanceId), InstanceId, &Required, &Type);
592
593 Status = SetProperty(Target, &DEVPKEY_DeviceInterface_ClassGuid, LOCALE_NEUTRAL,
594 DEVPROP_TYPE_GUID, sizeof(ClassGuid), &ClassGuid);
596}
#define DEVPROP_TYPE_GUID
Definition: devpropdef.h:42
_Must_inspect_result_ _In_opt_ PVOID _In_opt_ PVOID InstanceId
Definition: fsrtlfuncs.h:908
@ Enabled
Definition: mountmgr.h:179

Referenced by START_TEST().

◆ Test_InterfaceParameters()

static VOID Test_InterfaceParameters ( VOID  )
static

Definition at line 600 of file IoDeviceProperty.c.

601{
602 UNICODE_STRING EmptyName = RTL_CONSTANT_STRING(L"");
603 UNICODE_STRING MissingName = RTL_CONSTANT_STRING(L"\\??\\KMTEST#NoSuchDevice#0#{5F1E3C8A-7D2B-4E61-9A0C-3B8D4F2E6A17}");
604 ULONG Number = 1, Required;
607
608 trace("Interface parameter checks\n");
609
614 sizeof(Number), &Number, &Required, &Type);
616
621 sizeof(Number), &Number, &Required, &Type);
623
626 ok(!NT_SUCCESS(Status), "Setting a property of a missing interface returned 0x%08lx\n", Status);
628 sizeof(Number), &Number, &Required, &Type);
629 ok(!NT_SUCCESS(Status), "Getting a property of a missing interface returned 0x%08lx\n", Status);
630}
static const DEVPROPKEY TestKeyNumber

Referenced by START_TEST().

◆ Test_LegacyLocales()

static VOID Test_LegacyLocales ( _In_ PPROPERTY_TARGET  Target)
static

Definition at line 257 of file IoDeviceProperty.c.

259{
260 static const WCHAR English[] = L"Hello";
261 static const WCHAR German[] = L"Hallo";
262 static const WCHAR Neutral[] = L"Neutral";
263 static const WCHAR Indirect[] = L"@machine.inf,%DeviceDesc%;Device";
265
266 trace("Legacy locales on %s\n", Target->Description);
267
273
278
279 /* A neutral write replaces every localized value and lookups fall back to it */
285
288
293
297
305}
static const DEVPROPKEY TestKeyLocalized
#define LCID_DE_DE
#define LCID_EN_US
#define DEVPROP_TYPE_STRING_INDIRECT
Definition: devpropdef.h:56

Referenced by Test_Locales().

◆ Test_Locales()

static VOID Test_Locales ( _In_ PPROPERTY_TARGET  Target)
static

Definition at line 309 of file IoDeviceProperty.c.

311{
312 static const WCHAR English[] = L"Hello";
313 static const WCHAR German[] = L"Hallo";
314 static const WCHAR Neutral[] = L"Neutral";
315 static const WCHAR Indirect[] = L"@machine.inf,%DeviceDesc%;Device";
317
318 if (LegacyStore)
319 {
321 return;
322 }
323
324 trace("Locales on %s\n", Target->Description);
325
331
336
340
346
352
359}
static VOID Test_LegacyLocales(_In_ PPROPERTY_TARGET Target)

Referenced by START_TEST().

◆ Test_RootDevice()

static VOID Test_RootDevice ( _In_ PDEVICE_OBJECT  Pdo)
static

Definition at line 735 of file IoDeviceProperty.c.

737{
738 static const WCHAR English[] = L"Root";
739 PROPERTY_TARGET Target = { "root", NULL, NULL };
740 ULONG Number = 1;
742
743 trace("Root device\n");
744
745 Target.Pdo = GetRootPdo(Pdo);
746 if (skip(Target.Pdo != NULL, "No root device\n"))
747 return;
748
752
753 Status = SetProperty(&Target, &DEVPKEY_Device_FriendlyName, LOCALE_NEUTRAL, DEVPROP_TYPE_STRING,
754 sizeof(English), (PVOID)English);
756
759
761 sizeof(English), (PVOID)English);
765
769}
static PDEVICE_OBJECT GetRootPdo(_In_ PDEVICE_OBJECT Pdo)

Referenced by START_TEST().

◆ Test_StoreRoundTrip()

static VOID Test_StoreRoundTrip ( _In_ PPROPERTY_TARGET  Target)
static

Definition at line 181 of file IoDeviceProperty.c.

183{
184 static const WCHAR String[] = L"ReactOS property store";
185 static const WCHAR List[] = L"First\0Second\0Third\0";
186 static const UCHAR Binary[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 };
187 static const ULONG Numbers[] = { 1, 2, 3 };
188 ULONG Number = 0x12345678;
190
191 trace("Store round trip on %s\n", Target->Description);
192
195
199
201 sizeof(Numbers), (PVOID)Numbers);
204 (PVOID)Numbers, sizeof(Numbers));
205
209
213
217
221
225
229
232
235 if (LegacyStore)
236 {
237 /* Only a NULL buffer deletes, the empty type gets stored as is */
241 }
243
253}
static const DEVPROPKEY TestKeyBinary
static const DEVPROPKEY TestKeyWidePid
static const DEVPROPKEY TestKeyString
static const DEVPROPKEY TestKeyList
#define DEVPROP_TYPEMOD_ARRAY
Definition: devpropdef.h:26
#define DEVPROP_TYPE_NULL
Definition: devpropdef.h:30
#define DEVPROP_TYPE_BINARY
Definition: devpropdef.h:53
@ Binary
Definition: stream.h:45
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2439
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550

Referenced by START_TEST().

◆ Test_Validation()

static VOID Test_Validation ( _In_ PPROPERTY_TARGET  Target)
static

Definition at line 363 of file IoDeviceProperty.c.

365{
366 static const WCHAR Unterminated[] = { L'a', L'b', L'c' };
367 static const WCHAR EmbeddedNul[] = { L'a', 0, L'b', 0 };
368 static const WCHAR UnterminatedList[] = { L'a', 0, L'b', 0 };
369 static const WCHAR DoubleNulOnly[] = { 0, 0 };
370 static const WCHAR EmptyList[] = { 0 };
371 static const WCHAR ValidString[] = L"x";
372 struct
373 {
375 PVOID Data;
376 ULONG Size;
378 } Cases[16];
379 UCHAR BadBoolean = 1, GoodBoolean = (UCHAR)DEVPROP_TRUE;
380 LARGE_INTEGER NegativeTime = { .QuadPart = -1 };
381 ULONG Number = 5;
382 ULONG Index = 0, i;
384
385 trace("Validation on %s\n", Target->Description);
386
387#define ADD_CASE(t, d, s, e) \
388 do { ASSERT(Index < RTL_NUMBER_OF(Cases)); \
389 Cases[Index].Type = (t); Cases[Index].Data = (PVOID)(d); \
390 Cases[Index].Size = (s); Cases[Index].Expected = (e); Index++; } while (0)
391
392 ADD_CASE(DEVPROP_TYPE_STRING, Unterminated, sizeof(Unterminated), STATUS_INVALID_PARAMETER);
393 ADD_CASE(DEVPROP_TYPE_STRING, EmbeddedNul, sizeof(EmbeddedNul), STATUS_INVALID_PARAMETER);
395 ADD_CASE(DEVPROP_TYPE_STRING_LIST, UnterminatedList, sizeof(UnterminatedList), STATUS_INVALID_PARAMETER);
396 ADD_CASE(DEVPROP_TYPE_STRING_LIST, DoubleNulOnly, sizeof(DoubleNulOnly), STATUS_INVALID_PARAMETER);
397 ADD_CASE(DEVPROP_TYPE_STRING_LIST, EmptyList, sizeof(EmptyList), STATUS_SUCCESS);
399 ADD_CASE(DEVPROP_TYPE_BOOLEAN, &BadBoolean, sizeof(BadBoolean), STATUS_INVALID_PARAMETER);
400 ADD_CASE(DEVPROP_TYPE_BOOLEAN, &GoodBoolean, sizeof(GoodBoolean), STATUS_SUCCESS);
401 ADD_CASE(DEVPROP_TYPE_FILETIME, &NegativeTime, sizeof(NegativeTime), STATUS_INVALID_PARAMETER);
408
409#undef ADD_CASE
410
411 for (i = 0; i < Index; i++)
412 {
413 /* The legacy store takes any type and size as is */
414 Expected = LegacyStore ? STATUS_SUCCESS : Cases[i].Expected;
415
416 Status = SetProperty(Target, &TestKeyInvalid, LOCALE_NEUTRAL, Cases[i].Type, Cases[i].Size, Cases[i].Data);
417 ok(Status == Expected,
418 "%s case %lu (type 0x%lx, size %lu): got 0x%08lx, expected 0x%08lx\n",
419 Target->Description, i, Cases[i].Type, Cases[i].Size, Status, Expected);
420
421 if (NT_SUCCESS(Expected))
422 ExpectProperty(Target, &TestKeyInvalid, LOCALE_NEUTRAL, Cases[i].Type, Cases[i].Data, Cases[i].Size);
423 else
425
427 }
428}
static const DEVPROPKEY TestKeyInvalid
#define ADD_CASE(t, d, s, e)
#define MAX_DEVPROP_TYPE
Definition: devpropdef.h:58
#define DEVPROP_TYPEMOD_LIST
Definition: devpropdef.h:27
#define DEVPROP_TYPE_FILETIME
Definition: devpropdef.h:45
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by START_TEST().

Variable Documentation

◆ CandidateClasses

const GUID* CandidateClasses[]
static
Initial value:
=
{
}
static const GUID KmtDiskInterface
static const GUID KmtVolumeInterface
static const GUID KmtCdromInterface

Definition at line 28 of file IoDeviceProperty.c.

Referenced by FindTestInterface().

◆ KmtCdromInterface

const GUID KmtCdromInterface = { 0x53F56308, 0xB6BF, 0x11D0, { 0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B } }
static

Definition at line 25 of file IoDeviceProperty.c.

◆ KmtDiskInterface

const GUID KmtDiskInterface = { 0x53F56307, 0xB6BF, 0x11D0, { 0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B } }
static

Definition at line 24 of file IoDeviceProperty.c.

◆ KmtVolumeInterface

const GUID KmtVolumeInterface = { 0x53F5630D, 0xB6BF, 0x11D0, { 0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B } }
static

Definition at line 26 of file IoDeviceProperty.c.

◆ LegacyStore

BOOLEAN LegacyStore
static

◆ pIoGetDeviceInterfacePropertyData

PGET_INTERFACE_PROPERTY_ROUTINE pIoGetDeviceInterfacePropertyData
static

Definition at line 70 of file IoDeviceProperty.c.

Referenced by GetProperty(), START_TEST(), and Test_InterfaceParameters().

◆ pIoSetDeviceInterfacePropertyData

PSET_INTERFACE_PROPERTY_ROUTINE pIoSetDeviceInterfacePropertyData
static

Definition at line 69 of file IoDeviceProperty.c.

Referenced by SetProperty(), START_TEST(), and Test_InterfaceParameters().

◆ TestKeyBinary

const DEVPROPKEY TestKeyBinary = { KMT_PROPERTY_FMTID, 5 }
static

Definition at line 19 of file IoDeviceProperty.c.

Referenced by Test_StoreRoundTrip().

◆ TestKeyInvalid

const DEVPROPKEY TestKeyInvalid = { KMT_PROPERTY_FMTID, 7 }
static

Definition at line 22 of file IoDeviceProperty.c.

Referenced by Test_Validation().

◆ TestKeyList

const DEVPROPKEY TestKeyList = { KMT_PROPERTY_FMTID, 4 }
static

Definition at line 18 of file IoDeviceProperty.c.

Referenced by Test_StoreRoundTrip().

◆ TestKeyLocalized

const DEVPROPKEY TestKeyLocalized = { KMT_PROPERTY_FMTID, 6 }
static

Definition at line 20 of file IoDeviceProperty.c.

Referenced by Test_LegacyLocales(), Test_Locales(), and Test_RootDevice().

◆ TestKeyNumber

const DEVPROPKEY TestKeyNumber = { KMT_PROPERTY_FMTID, 2 }
static

◆ TestKeyString

const DEVPROPKEY TestKeyString = { KMT_PROPERTY_FMTID, 3 }
static

Definition at line 17 of file IoDeviceProperty.c.

Referenced by Test_StoreRoundTrip().

◆ TestKeyWidePid

const DEVPROPKEY TestKeyWidePid = { KMT_PROPERTY_FMTID, 0x12345 }
static

Definition at line 21 of file IoDeviceProperty.c.

Referenced by Test_StoreRoundTrip().