ReactOS 0.4.15-dev-8413-gc1c91f2
ksuser.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: dll/directx/ksuser/ksuser.c
5 * PURPOSE: KS USER functions
6 * PROGRAMMER: Magnus Olsen and Dmitry Chapyshev and Johannes Anderwald
7 */
8
9#include "ksuser.h"
10#define NDEBUG
11#include <debug.h>
12
20 PHANDLE phHandle)
21{
24 SIZE_T TotalSize;
25 LPWSTR pStr;
29
30 /* get length of object type */
32
33 /* get length for request */
34 TotalSize = (Length * sizeof(WCHAR)) + BufferSize;
35
36 /* append space for '\\'*/
37 TotalSize += sizeof(WCHAR);
38
39 /* allocate buffer */
40 pStr = HeapAlloc(GetProcessHeap(), 0, TotalSize);
41 if (!pStr)
42 {
43 /* out of memory */
45 }
46
47 /* copy object type */
48 wcscpy(pStr, ObjectType);
49
50 /* append slash */
51 pStr[Length] = L'\\';
52
53 /* append parameters */
54 memcpy(&pStr[Length+1], Buffer, BufferSize);
55
56 /* initialize object name */
57 ObjectName.Buffer = pStr;
58 ObjectName.Length = ObjectName.MaximumLength = TotalSize;
59
60 /* initialize object attributes */
62
63 /* create the object */
65
66 /* free buffer */
67 HeapFree(GetProcessHeap(), 0, pStr);
68
69 /* check for success */
70 if (!NT_SUCCESS(Status))
71 {
72 /* failed zero handle */
73 *phHandle = INVALID_HANDLE_VALUE;
74
75 /* convert error code */
77 }
78
79 /* done */
80 return Status;
81}
82
83/*++
84* @name KsCreateAllocator
85* @implemented
86* The function KsCreateAllocator creates a handle to an allocator for the given sink connection handle
87*
88* @param HANDLE ConnectionHandle
89* Handle to the sink connection on which to create the allocator
90*
91* @param PKSALLOCATOR_FRAMING AllocatorFraming
92* the input param we using to alloc our framing
93*
94* @param PHANDLE AllocatorHandle
95* Our new handle that we have alloc
96*
97* @return
98* Return NTSTATUS error code or sussess code.
99*
100* @remarks.
101* none
102*
103*--*/
105DWORD
106NTAPI
110
111{
115 sizeof(KSALLOCATOR_FRAMING),
118}
119
120/*++
121* @name KsCreateClock
122* @implemented
123*
124* The function KsCreateClock creates handle to clock instance
125*
126* @param HANDLE ConnectionHandle
127* Handle to use to create the clock
128*
129* @param PKSCLOCK_CREATE ClockCreate
130* parameter to use to create the clock
131*
132* @param PHANDLE ClockHandle
133* The new handle
134*
135* @return
136* Return NTSTATUS error code or sussess code.
137*
138* @remarks.
139* none
140*
141*--*/
143DWORD
144NTAPI
148{
152 sizeof(KSCLOCK_CREATE),
155}
156
157/*++
158* @name KsCreatePin
159* @implemented
160*
161* The function KsCreatePin passes a connection request to device and create pin instance
162*
163* @param HANDLE FilterHandle
164* handle of the filter initiating the create request
165*
166* @param PKSPIN_CONNECT Connect
167* Pointer to a KSPIN_CONNECT structure that contains parameters for the requested connection.
168* This should be followed in memory by a KSDATAFORMAT data structure, describing the data format
169* requested for the connection.
170
171* @param ACCESS_MASK DesiredAccess
172* Desired access
173*
174* @param PHANDLE ConnectionHandle
175* connection handle passed
176*
177* @return
178* Return NTSTATUS error code or sussess code.
179*
180* @remarks.
181* The flag in PKSDATAFORMAT is not really document,
182* to find it u need api monitor allot api and figout
183* how it works, only flag I have found is the
184* KSDATAFORMAT_ATTRIBUTES flag, it doing a Align
185* of LONLONG size, it also round up it.
186*
187*--*/
188
190DWORD
191NTAPI
192KsCreatePin(HANDLE FilterHandle,
196{
199
200 BufferSize += DataFormat->FormatSize;
201
202 return KsiCreateObjectType(FilterHandle,
204 Connect,
208
209}
210
211/*++
212* @name KsCreateTopologyNode
213* @implemented
214*
215* The function KsCreateTopologyNode creates a handle to a topology node instance
216*
217* @param HANDLE ParentHandle
218* Handle to parent when want to use when we created the node on
219*
220*
221* @param PKSNODE_CREATE NodeCreate
222* topology node parameters to use when it is create
223*
224* @param ACCESS_MASK DesiredAccess
225* Desired access
226*
227* @param PHANDLE NodeHandle
228* Location for the topology node handle
229*
230* @return
231* Return NTSTATUS error code or sussess code.
232*
233* @remarks.
234* none
235*
236*--*/
238DWORD
239NTAPI
244{
245 return KsiCreateObjectType( ParentHandle,
248 sizeof(KSNODE_CREATE),
250 NodeHandle);
251}
252
253
254BOOL
256DllMain(HANDLE hModule, DWORD ulreason, LPVOID lpReserved)
257{
258 switch (ulreason)
259 {
264 break;
265 }
266
267 return TRUE;
268}
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define BufferSize
Definition: mmc.h:75
KSDATAFORMAT * PKSDATAFORMAT
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define APIENTRY
Definition: api.h:79
HMODULE hModule
Definition: animate.c:44
#define GetProcessHeap()
Definition: compat.h:736
#define DLL_THREAD_DETACH
Definition: compat.h:133
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define GENERIC_READ
Definition: compat.h:135
#define HeapFree(x, y, z)
Definition: compat.h:735
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define DLL_THREAD_ATTACH
Definition: compat.h:132
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
Status
Definition: gdiplustypes.h:25
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
_In_ PKSCLOCK_CREATE ClockCreate
Definition: ks.h:4527
#define KSSTRING_Allocator
Definition: ks.h:50
_In_ PKSNODE_CREATE NodeCreate
Definition: ks.h:4546
_In_ PKSNODE_CREATE _In_ ACCESS_MASK _Out_ PHANDLE NodeHandle
Definition: ks.h:4548
_In_ PKSALLOCATOR_FRAMING AllocatorFraming
Definition: ks.h:4518
#define KSSTRING_Pin
Definition: ks.h:48
#define KSSTRING_TopologyNode
Definition: ks.h:52
_In_ PKSPIN_CONNECT Connect
Definition: ks.h:4536
_In_ PKSCLOCK_CREATE _Out_ PHANDLE ClockHandle
Definition: ks.h:4528
#define KSSTRING_Clock
Definition: ks.h:49
#define KSDDKAPI
Definition: ks.h:40
_In_ PKSPIN_CONNECT _In_ ACCESS_MASK _Out_ PHANDLE ConnectionHandle
Definition: ks.h:4538
_In_ PKSALLOCATOR_FRAMING _Out_ PHANDLE AllocatorHandle
Definition: ks.h:4519
KSDDKAPI DWORD NTAPI KsCreatePin(HANDLE FilterHandle, PKSPIN_CONNECT Connect, ACCESS_MASK DesiredAccess, PHANDLE ConnectionHandle)
Definition: ksuser.c:192
KSDDKAPI DWORD NTAPI KsCreateTopologyNode(HANDLE ParentHandle, PKSNODE_CREATE NodeCreate, IN ACCESS_MASK DesiredAccess, OUT PHANDLE NodeHandle)
Definition: ksuser.c:240
KSDDKAPI DWORD NTAPI KsCreateClock(HANDLE ConnectionHandle, PKSCLOCK_CREATE ClockCreate, PHANDLE ClockHandle)
Definition: ksuser.c:145
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ulreason, LPVOID lpReserved)
Definition: ksuser.c:256
NTSTATUS NTAPI KsiCreateObjectType(HANDLE hHandle, LPWSTR ObjectType, PVOID Buffer, ULONG BufferSize, ACCESS_MASK DesiredAccess, PHANDLE phHandle)
Definition: ksuser.c:15
KSDDKAPI DWORD NTAPI KsCreateAllocator(HANDLE ConnectionHandle, PKSALLOCATOR_FRAMING AllocatorFraming, PHANDLE AllocatorHandle)
Definition: ksuser.c:107
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
ObjectType
Definition: metafile.c:81
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
ULONG ACCESS_MASK
Definition: nt_native.h:40
NTSTATUS NTAPI NtCreateFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER AllocationSize OPTIONAL, IN ULONG FileAttributes, IN ULONG ShareAccess, IN ULONG CreateDisposition, IN ULONG CreateOptions, IN PVOID EaBuffer OPTIONAL, IN ULONG EaLength)
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
#define L(x)
Definition: ntvdm.h:50
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define NTAPI
Definition: typedefs.h:36
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
_In_ PVOID _Out_opt_ PULONG_PTR _Outptr_opt_ PCUNICODE_STRING * ObjectName
Definition: cmfuncs.h:64
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184