ReactOS 0.4.15-dev-7906-g1b85a5f
misc.c File Reference
#include "precomp.h"
#include <debug.h>
Include dependency graph for misc.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define TAG_KS   'ssKK'
 

Functions

VOID CompleteRequest (PIRP Irp, CCHAR PriorityBoost)
 
PVOID AllocateItem (IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
 
VOID FreeItem (IN PVOID Item)
 
NTSTATUS KspCopyCreateRequest (IN PIRP Irp, IN LPWSTR ObjectClass, IN OUT PULONG Size, OUT PVOID *Result)
 
KSDDKAPI PVOID NTAPI KsGetObjectFromFileObject (IN PFILE_OBJECT FileObject)
 
KSDDKAPI KSOBJECTTYPE NTAPI KsGetObjectTypeFromFileObject (IN PFILE_OBJECT FileObject)
 
KSOBJECTTYPE NTAPI KsGetObjectTypeFromIrp (IN PIRP Irp)
 
PUNKNOWN NTAPI KsGetOuterUnknown (IN PVOID Object)
 
KSDDKAPI PVOID NTAPI KsGetParent (IN PVOID Object)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file misc.c.

◆ TAG_KS

#define TAG_KS   'ssKK'

Definition at line 14 of file misc.c.

Function Documentation

◆ AllocateItem()

PVOID AllocateItem ( IN POOL_TYPE  PoolType,
IN SIZE_T  NumberOfBytes 
)

Definition at line 29 of file misc.c.

32{
33 return ExAllocatePoolZero(PoolType, NumberOfBytes, TAG_KS);
34}
#define TAG_KS
Definition: misc.c:14
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3815
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Inout_ PLARGE_INTEGER NumberOfBytes
Definition: iotypes.h:1036

Referenced by KspCopyCreateRequest(), USBSTOR_ClassRequest(), and USBSTOR_GetMaxLUN().

◆ CompleteRequest()

VOID CompleteRequest ( PIRP  Irp,
CCHAR  PriorityBoost 
)

Definition at line 17 of file misc.c.

20{
21 DPRINT("Completing IRP %p Status %x\n", Irp, Irp->IoStatus.Status);
22
23 ASSERT(Irp->IoStatus.Status != STATUS_PENDING);
24
26}
_In_ PIRP Irp
Definition: csq.h:116
#define ASSERT(a)
Definition: mode.c:44
#define IoCompleteRequest
Definition: irp.c:1240
#define STATUS_PENDING
Definition: ntstatus.h:82
#define DPRINT
Definition: sndvol32.h:71
_In_ WDFREQUEST _In_ NTSTATUS _In_ CCHAR PriorityBoost
Definition: wdfrequest.h:1016

◆ FreeItem()

VOID FreeItem ( IN PVOID  Item)

Definition at line 37 of file misc.c.

39{
41}
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
_In_ WDFCOLLECTION _In_ WDFOBJECT Item

Referenced by USBSTOR_ClassRequest(), and USBSTOR_GetMaxLUN().

◆ KsGetObjectFromFileObject()

KSDDKAPI PVOID NTAPI KsGetObjectFromFileObject ( IN PFILE_OBJECT  FileObject)

Definition at line 88 of file misc.c.

90{
91 PKSIOBJECT_HEADER ObjectHeader;
92
93 /* get object header */
94 ObjectHeader = (PKSIOBJECT_HEADER)FileObject->FsContext2;
95
96 /* return associated object */
97 return ObjectHeader->ObjectType;
98}
struct KSIOBJECT_HEADER * PKSIOBJECT_HEADER
PVOID ObjectType
Definition: kstypes.h:30
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550

◆ KsGetObjectTypeFromFileObject()

KSDDKAPI KSOBJECTTYPE NTAPI KsGetObjectTypeFromFileObject ( IN PFILE_OBJECT  FileObject)

Definition at line 106 of file misc.c.

108{
109 PKSIOBJECT_HEADER ObjectHeader;
110
111 /* get object header */
112 ObjectHeader = (PKSIOBJECT_HEADER)FileObject->FsContext2;
113 /* return type */
114 return ObjectHeader->Type;
115}
KSOBJECTTYPE Type
Definition: kstypes.h:23

◆ KsGetObjectTypeFromIrp()

KSOBJECTTYPE NTAPI KsGetObjectTypeFromIrp ( IN PIRP  Irp)

Definition at line 122 of file misc.c.

124{
125 PKSIOBJECT_HEADER ObjectHeader;
126 PIO_STACK_LOCATION IoStack;
127
128 /* get current irp stack */
130 /* get object header */
131 ObjectHeader = (PKSIOBJECT_HEADER)IoStack->FileObject->FsContext2;
132 /* return type */
133 return ObjectHeader->Type;
134}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
PFILE_OBJECT FileObject
Definition: iotypes.h:3169

◆ KsGetOuterUnknown()

PUNKNOWN NTAPI KsGetOuterUnknown ( IN PVOID  Object)

Definition at line 141 of file misc.c.

143{
145
146 /* sanity check */
147 ASSERT(BasicHeader->Type == KsObjectTypeDevice || BasicHeader->Type == KsObjectTypeFilterFactory ||
148 BasicHeader->Type == KsObjectTypeFilter || BasicHeader->Type == KsObjectTypePin);
149
150 /* return objects outer unknown */
151 return BasicHeader->OuterUnknown;
152}
@ KsObjectTypeFilter
Definition: ks.h:1210
@ KsObjectTypeDevice
Definition: ks.h:1208
@ KsObjectTypePin
Definition: ks.h:1211
@ KsObjectTypeFilterFactory
Definition: ks.h:1209
struct KSBASIC_HEADER * PKSBASIC_HEADER
PUNKNOWN OuterUnknown
Definition: kstypes.h:62
KSOBJECTTYPE Type
Definition: kstypes.h:56
uint32_t ULONG_PTR
Definition: typedefs.h:65
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object

◆ KsGetParent()

KSDDKAPI PVOID NTAPI KsGetParent ( IN PVOID  Object)

Definition at line 160 of file misc.c.

162{
164 /* sanity check */
165 ASSERT(BasicHeader->Parent.KsDevice != NULL);
166 /* return object type */
167 return (PVOID)BasicHeader->Parent.KsDevice;
168}
#define NULL
Definition: types.h:112
PKSDEVICE KsDevice
Definition: kstypes.h:57
union KSBASIC_HEADER::@973 Parent

Referenced by USBAudioFilterCreate().

◆ KspCopyCreateRequest()

NTSTATUS KspCopyCreateRequest ( IN PIRP  Irp,
IN LPWSTR  ObjectClass,
IN OUT PULONG  Size,
OUT PVOID Result 
)

Definition at line 44 of file misc.c.

49{
50 PIO_STACK_LOCATION IoStack;
51 SIZE_T ObjectLength, ParametersLength;
53
54 /* get current irp stack */
56
57 /* get object class length */
58 ObjectLength = (wcslen(ObjectClass) + 1) * sizeof(WCHAR);
59
60 /* check for minium length requirement */
61 if (ObjectLength + *Size > IoStack->FileObject->FileName.MaximumLength)
63
64 /* extract parameters length */
65 ParametersLength = IoStack->FileObject->FileName.MaximumLength - ObjectLength;
66
67 /* allocate buffer */
68 Buffer = AllocateItem(NonPagedPool, ParametersLength);
69 if (!Buffer)
71
72 /* copy parameters */
73 RtlMoveMemory(Buffer, &IoStack->FileObject->FileName.Buffer[ObjectLength / sizeof(WCHAR)], ParametersLength);
74
75 /* store result */
76 *Result = Buffer;
77 *Size = (ULONG)ParametersLength;
78
79 return STATUS_SUCCESS;
80}
Definition: bufpool.h:45
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:29
#define NonPagedPool
Definition: env_spec_w32.h:307
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by KspValidateConnectRequest(), KsValidateAllocatorCreateRequest(), KsValidateClockCreateRequest(), and KsValidateTopologyNodeCreateRequest().