ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

ksuser.c
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:       See COPYING in the top level directory
00003  * PROJECT:         ReactOS Kernel Streaming
00004  * FILE:            dll/directx/ksuser/ksuser.c
00005  * PURPOSE:         KS USER functions
00006  * PROGRAMMER:      Magnus Olsen and Dmitry Chapyshev and Johannes Anderwald
00007  */
00008 
00009 #include "ksuser.h"
00010 #define NDEBUG
00011 #include <debug.h>
00012 
00013 NTSTATUS
00014 NTAPI
00015 KsiCreateObjectType( HANDLE hHandle,
00016                      LPWSTR ObjectType,
00017                      PVOID Buffer,
00018                      ULONG BufferSize,
00019                      ACCESS_MASK DesiredAccess,
00020                      PHANDLE phHandle)
00021 {
00022     NTSTATUS Status;
00023     ULONG Length;
00024     ULONG TotalSize;
00025     LPWSTR pStr;
00026     UNICODE_STRING ObjectName;
00027     OBJECT_ATTRIBUTES ObjectAttributes;
00028     IO_STATUS_BLOCK IoStatusBlock;
00029 
00030     /* get length of object type */
00031     Length = wcslen(ObjectType);
00032 
00033     /* get length for request */
00034     TotalSize = (Length * sizeof(WCHAR)) + BufferSize;
00035 
00036     /* append space for '\\'*/
00037     TotalSize += sizeof(WCHAR);
00038 
00039     /* allocate buffer */
00040     pStr = HeapAlloc(GetProcessHeap(), 0, TotalSize);
00041     if (!pStr)
00042     {
00043         /* out of memory */
00044         return ERROR_NOT_ENOUGH_MEMORY;
00045     }
00046 
00047     /* copy object type */
00048     wcscpy(pStr, ObjectType);
00049 
00050     /* append slash */
00051     pStr[Length] = L'\\';
00052 
00053     /* append parameters */
00054     memcpy(&pStr[Length+1], Buffer, BufferSize);
00055 
00056     /* initialize object name */
00057     ObjectName.Buffer = pStr;
00058     ObjectName.Length = ObjectName.MaximumLength = TotalSize;
00059 
00060     /* initialize object attributes */
00061     InitializeObjectAttributes(&ObjectAttributes, &ObjectName, OBJ_CASE_INSENSITIVE, hHandle, NULL);
00062 
00063     /* create the object */
00064     Status = NtCreateFile(phHandle, DesiredAccess, &ObjectAttributes, &IoStatusBlock, NULL, FILE_ATTRIBUTE_NORMAL, 0, 1, 0, NULL, 0);
00065 
00066     /* free buffer */
00067     HeapFree(GetProcessHeap(), 0, pStr);
00068 
00069     /* check for success */
00070     if (!NT_SUCCESS(Status))
00071     {
00072         /* failed zero handle */
00073         *phHandle = INVALID_HANDLE_VALUE;
00074 
00075         /* convert error code */
00076         Status = RtlNtStatusToDosError(Status);
00077     }
00078 
00079     /* done */
00080     return Status;
00081 }
00082 
00083 /*++
00084 * @name KsCreateAllocator
00085 * @implemented
00086 * The function KsCreateAllocator creates a handle to an allocator for the given sink connection handle
00087 *
00088 * @param HANDLE ConnectionHandle
00089 * Handle to the sink connection on which to create the allocator
00090 *
00091 * @param PKSALLOCATOR_FRAMING AllocatorFraming
00092 * the input param we using to alloc our framing
00093 *
00094 * @param PHANDLE AllocatorHandle
00095 * Our new handle that we have alloc
00096 *
00097 * @return 
00098 * Return NTSTATUS error code or sussess code.
00099 *
00100 * @remarks.
00101 * none
00102 *
00103 *--*/
00104 KSDDKAPI
00105 DWORD
00106 NTAPI
00107 KsCreateAllocator(HANDLE ConnectionHandle,
00108                   PKSALLOCATOR_FRAMING AllocatorFraming,
00109                   PHANDLE AllocatorHandle)
00110 
00111 {
00112     return KsiCreateObjectType( ConnectionHandle,
00113                                 KSSTRING_Allocator,
00114                                 (PVOID) AllocatorFraming,
00115                                 sizeof(KSALLOCATOR_FRAMING),
00116                                 GENERIC_READ,
00117                                 AllocatorHandle);
00118 }
00119 
00120 /*++
00121 * @name KsCreateClock
00122 * @implemented
00123 *
00124 * The function KsCreateClock  creates handle to clock instance
00125 *
00126 * @param HANDLE ConnectionHandle
00127 * Handle to use to create the clock 
00128 *
00129 * @param PKSCLOCK_CREATE ClockCreate
00130 * paramenter to use to create the clock
00131 *
00132 * @param PHANDLE  ClockHandle
00133 * The new handle
00134 *
00135 * @return 
00136 * Return NTSTATUS error code or sussess code.
00137 *
00138 * @remarks.
00139 * none
00140 *
00141 *--*/
00142 KSDDKAPI
00143 DWORD
00144 NTAPI
00145 KsCreateClock(HANDLE ConnectionHandle,
00146               PKSCLOCK_CREATE ClockCreate,
00147               PHANDLE  ClockHandle)
00148 {
00149     return KsiCreateObjectType( ConnectionHandle,
00150                                 KSSTRING_Clock,
00151                                 (PVOID) ClockCreate,
00152                                 sizeof(KSCLOCK_CREATE),
00153                                 GENERIC_READ,
00154                                 ClockHandle);
00155 }
00156 
00157 /*++
00158 * @name KsCreatePin
00159 * @implemented
00160 *
00161 * The function KsCreatePin passes a connection request to device and create pin instance
00162 *
00163 * @param HANDLE FilterHandle
00164 * handle of the filter initiating the create request
00165 *
00166 * @param PKSPIN_CONNECT Connect
00167 * Pointer to a KSPIN_CONNECT structure that contains parameters for the requested connection. 
00168 * This should be followed in memory by a KSDATAFORMAT data structure, describing the data format
00169 * requested for the connection. 
00170 
00171 * @param ACCESS_MASK  DesiredAccess
00172 * Desrided access
00173 *
00174 * @param PHANDLE ConnectionHandle
00175 * connection handle passed
00176 *
00177 * @return 
00178 * Return NTSTATUS error code or sussess code.
00179 *
00180 * @remarks.
00181 * The flag in PKSDATAFORMAT is not really document, 
00182 * to find it u need api mointor allot api and figout
00183 * how it works, only flag I have found is the 
00184 * KSDATAFORMAT_ATTRIBUTES flag, it doing a Align
00185 * of LONLONG size, it also round up it.
00186 *
00187 *--*/
00188 
00189 KSDDKAPI
00190 DWORD
00191 NTAPI
00192 KsCreatePin(HANDLE FilterHandle,
00193             PKSPIN_CONNECT Connect,
00194             ACCESS_MASK DesiredAccess,
00195             PHANDLE  ConnectionHandle)
00196 {
00197     ULONG BufferSize = sizeof(KSPIN_CONNECT);
00198     PKSDATAFORMAT DataFormat = ((PKSDATAFORMAT) ((ULONG_PTR)Connect + sizeof(KSPIN_CONNECT)));
00199 
00200     BufferSize += DataFormat->FormatSize;
00201 
00202     return KsiCreateObjectType(FilterHandle,
00203                                KSSTRING_Pin,
00204                                Connect,
00205                                BufferSize,
00206                                DesiredAccess,
00207                                ConnectionHandle);
00208 
00209 }
00210 
00211 /*++
00212 * @name KsCreateTopologyNode
00213 * @implemented
00214 *
00215 * The function KsCreateTopologyNode  creates a handle to a topology node instance 
00216 *
00217 * @param HANDLE ParentHandle
00218 * Handle to parent when want to use when we created the node on
00219 * 
00220 *
00221 * @param PKSNODE_CREATE  NodeCreate
00222 * topology node parameters to use when it is create
00223 *
00224 * @param ACCESS_MASK  DesiredAccess
00225 * Desrided access
00226 *
00227 * @param PHANDLE  NodeHandle
00228 * Location for the topology node handle
00229 *
00230 * @return 
00231 * Return NTSTATUS error code or sussess code.
00232 *
00233 * @remarks.
00234 * none
00235 *
00236 *--*/
00237 KSDDKAPI
00238 DWORD
00239 NTAPI
00240 KsCreateTopologyNode(HANDLE ParentHandle,
00241                      PKSNODE_CREATE NodeCreate,
00242                      IN ACCESS_MASK DesiredAccess,
00243                      OUT PHANDLE NodeHandle)
00244 {
00245     return KsiCreateObjectType( ParentHandle,
00246                                 KSSTRING_TopologyNode,
00247                                 (PVOID) NodeCreate,
00248                                 sizeof(KSNODE_CREATE),
00249                                 DesiredAccess,
00250                                 NodeHandle);
00251 }
00252 
00253 
00254 BOOL 
00255 APIENTRY 
00256 DllMain(HANDLE hModule, DWORD ulreason, LPVOID lpReserved)
00257 {
00258     switch (ulreason)
00259     {
00260         case DLL_PROCESS_ATTACH:
00261         case DLL_THREAD_ATTACH:
00262         case DLL_THREAD_DETACH:
00263         case DLL_PROCESS_DETACH:
00264             break;
00265     }
00266 
00267     return TRUE;
00268 }

Generated on Sun May 27 2012 04:21:52 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.