ReactOS  0.4.13-dev-259-g5ca9c9c
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 
14 NTAPI
17  PVOID Buffer,
20  PHANDLE phHandle)
21 {
23  SIZE_T Length;
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 *--*/
104 KSDDKAPI
105 DWORD
106 NTAPI
110 
111 {
115  sizeof(KSALLOCATOR_FRAMING),
116  GENERIC_READ,
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 *--*/
142 KSDDKAPI
143 DWORD
144 NTAPI
148 {
151  (PVOID) ClockCreate,
152  sizeof(KSCLOCK_CREATE),
153  GENERIC_READ,
154  ClockHandle);
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 
189 KSDDKAPI
190 DWORD
191 NTAPI
192 KsCreatePin(HANDLE FilterHandle,
196 {
197  ULONG BufferSize = sizeof(KSPIN_CONNECT);
199 
200  BufferSize += DataFormat->FormatSize;
201 
202  return KsiCreateObjectType(FilterHandle,
203  KSSTRING_Pin,
204  Connect,
205  BufferSize,
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 *--*/
237 KSDDKAPI
238 DWORD
239 NTAPI
244 {
245  return KsiCreateObjectType( ParentHandle,
247  (PVOID) NodeCreate,
248  sizeof(KSNODE_CREATE),
250  NodeHandle);
251 }
252 
253 
254 BOOL
255 APIENTRY
256 DllMain(HANDLE hModule, DWORD ulreason, LPVOID lpReserved)
257 {
258  switch (ulreason)
259  {
260  case DLL_PROCESS_ATTACH:
261  case DLL_THREAD_ATTACH:
262  case DLL_THREAD_DETACH:
263  case DLL_PROCESS_DETACH:
264  break;
265  }
266 
267  return TRUE;
268 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
ObjectType
Definition: metafile.c:80
#define IN
Definition: typedefs.h:38
#define TRUE
Definition: types.h:120
#define KSSTRING_Allocator
Definition: ks.h:50
NTSTATUS NTAPI KsiCreateObjectType(HANDLE hHandle, LPWSTR ObjectType, PVOID Buffer, ULONG BufferSize, ACCESS_MASK DesiredAccess, PHANDLE phHandle)
Definition: ksuser.c:15
_In_ PKSPIN_CONNECT Connect
Definition: ks.h:4565
KSDDKAPI DWORD NTAPI KsCreatePin(HANDLE FilterHandle, PKSPIN_CONNECT Connect, ACCESS_MASK DesiredAccess, PHANDLE ConnectionHandle)
Definition: ksuser.c:192
_In_ PKSNODE_CREATE NodeCreate
Definition: ks.h:4575
#define DLL_THREAD_ATTACH
Definition: compat.h:121
_In_ PKSCLOCK_CREATE _Out_ PHANDLE ClockHandle
Definition: ks.h:4556
#define KSSTRING_Pin
Definition: ks.h:48
LONG NTSTATUS
Definition: precomp.h:26
_In_ PKSALLOCATOR_FRAMING AllocatorFraming
Definition: ks.h:4547
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
_In_ PKSNODE_CREATE _In_ ACCESS_MASK _Out_ PHANDLE NodeHandle
Definition: ks.h:4575
_In_ PVOID _Out_opt_ PULONG_PTR _Outptr_opt_ PCUNICODE_STRING * ObjectName
Definition: cmfuncs.h:62
#define KSDDKAPI
Definition: ks.h:40
#define DLL_THREAD_DETACH
Definition: compat.h:122
KSDDKAPI DWORD NTAPI KsCreateClock(HANDLE ConnectionHandle, PKSCLOCK_CREATE ClockCreate, PHANDLE ClockHandle)
Definition: ksuser.c:145
#define KSSTRING_Clock
Definition: ks.h:49
uint32_t ULONG_PTR
Definition: typedefs.h:63
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
KSDDKAPI DWORD NTAPI KsCreateAllocator(HANDLE ConnectionHandle, PKSALLOCATOR_FRAMING AllocatorFraming, PHANDLE AllocatorHandle)
Definition: ksuser.c:107
KSDDKAPI DWORD NTAPI KsCreateTopologyNode(HANDLE ParentHandle, PKSNODE_CREATE NodeCreate, IN ACCESS_MASK DesiredAccess, OUT PHANDLE NodeHandle)
Definition: ksuser.c:240
#define DLL_PROCESS_DETACH
Definition: compat.h:119
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
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)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define BufferSize
Definition: classpnp.h:419
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:414
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define GENERIC_READ
Definition: compat.h:124
Status
Definition: gdiplustypes.h:24
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ulreason, LPVOID lpReserved)
Definition: ksuser.c:256
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
ULONG_PTR SIZE_T
Definition: typedefs.h:78
_In_ PKSALLOCATOR_FRAMING _Out_ PHANDLE AllocatorHandle
Definition: ks.h:4547
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK DesiredAccess
Definition: create.c:4157
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define KSSTRING_TopologyNode
Definition: ks.h:52
_In_ PKSCLOCK_CREATE ClockCreate
Definition: ks.h:4556
#define OUT
Definition: typedefs.h:39
unsigned int ULONG
Definition: retypes.h:1
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_In_ PKSPIN_CONNECT _In_ ACCESS_MASK _Out_ PHANDLE ConnectionHandle
Definition: ks.h:4565
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:394
ULONG ACCESS_MASK
Definition: nt_native.h:40
#define APIENTRY
Definition: api.h:79
KSDATAFORMAT * PKSDATAFORMAT
HMODULE hModule
Definition: animate.c:44