ReactOS 0.4.16-dev-250-g3ecd236
misc.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Kernel Streaming
4 * FILE: drivers/ksfilter/ks/misc.c
5 * PURPOSE: KS Allocator functions
6 * PROGRAMMER: Johannes Anderwald
7 */
8
9#include "precomp.h"
10
11#define NDEBUG
12#include <debug.h>
13
14#define TAG_KS 'ssKK'
15
16VOID
18 PIRP Irp,
20{
21 DPRINT("Completing IRP %p Status %x\n", Irp, Irp->IoStatus.Status);
22
23 ASSERT(Irp->IoStatus.Status != STATUS_PENDING);
24
26}
27
32{
34}
35
36VOID
39{
41}
42
45 IN PIRP Irp,
46 IN LPWSTR ObjectClass,
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}
81
82/*
83 @implemented
84*/
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}
99
100/*
101 @implemented
102*/
105NTAPI
108{
109 PKSIOBJECT_HEADER ObjectHeader;
110
111 /* get object header */
112 ObjectHeader = (PKSIOBJECT_HEADER)FileObject->FsContext2;
113 /* return type */
114 return ObjectHeader->Type;
115}
116
117/*
118 @implemented
119*/
121NTAPI
123 IN PIRP Irp)
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}
135
136/*
137 @implemented
138*/
140NTAPI
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}
153
154/*
155 @implemented
156*/
158PVOID
159NTAPI
162{
164 /* sanity check */
165 ASSERT(BasicHeader->Parent.KsDevice != NULL);
166 /* return object type */
167 return (PVOID)BasicHeader->Parent.KsDevice;
168}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_PENDING
Definition: d3dkmdt.h:43
#define NULL
Definition: types.h:112
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
Definition: misc.c:29
KSOBJECTTYPE NTAPI KsGetObjectTypeFromIrp(IN PIRP Irp)
Definition: misc.c:122
NTSTATUS KspCopyCreateRequest(IN PIRP Irp, IN LPWSTR ObjectClass, IN OUT PULONG Size, OUT PVOID *Result)
Definition: misc.c:44
KSDDKAPI PVOID NTAPI KsGetObjectFromFileObject(IN PFILE_OBJECT FileObject)
Definition: misc.c:88
KSDDKAPI PVOID NTAPI KsGetParent(IN PVOID Object)
Definition: misc.c:160
VOID CompleteRequest(PIRP Irp, CCHAR PriorityBoost)
Definition: misc.c:17
#define TAG_KS
Definition: misc.c:14
PUNKNOWN NTAPI KsGetOuterUnknown(IN PVOID Object)
Definition: misc.c:141
VOID FreeItem(IN PVOID Item)
Definition: misc.c:37
KSDDKAPI KSOBJECTTYPE NTAPI KsGetObjectTypeFromFileObject(IN PFILE_OBJECT FileObject)
Definition: misc.c:106
#define NonPagedPool
Definition: env_spec_w32.h:307
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
KSOBJECTTYPE
Definition: ks.h:1207
@ KsObjectTypeFilter
Definition: ks.h:1210
@ KsObjectTypeDevice
Definition: ks.h:1208
@ KsObjectTypePin
Definition: ks.h:1211
@ KsObjectTypeFilterFactory
Definition: ks.h:1209
#define KSDDKAPI
Definition: ks.h:40
struct KSBASIC_HEADER * PKSBASIC_HEADER
struct KSIOBJECT_HEADER * PKSIOBJECT_HEADER
#define ASSERT(a)
Definition: mode.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
FORCEINLINE PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
Definition: precomp.h:45
#define IoCompleteRequest
Definition: irp.c:1240
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
PUNKNOWN OuterUnknown
Definition: kstypes.h:62
PKSDEVICE KsDevice
Definition: kstypes.h:57
KSOBJECTTYPE Type
Definition: kstypes.h:56
union KSBASIC_HEADER::@982 Parent
PVOID ObjectType
Definition: kstypes.h:30
KSOBJECTTYPE Type
Definition: kstypes.h:23
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
uint32_t * PULONG
Definition: typedefs.h:59
INT POOL_TYPE
Definition: typedefs.h:78
#define NTAPI
Definition: typedefs.h:36
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
char CCHAR
Definition: typedefs.h:51
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
_In_ WDFCOLLECTION _In_ WDFOBJECT Item
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3815
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_In_ WDFREQUEST _In_ NTSTATUS _In_ CCHAR PriorityBoost
Definition: wdfrequest.h:1016
_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
* PFILE_OBJECT
Definition: iotypes.h:1998
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS _Inout_ PLARGE_INTEGER NumberOfBytes
Definition: iotypes.h:1036
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184