ReactOS  0.4.14-dev-1007-g90d795b
msdvbnp.cpp
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS Network Provider for MPEG2 based networks
4  * FILE: dll/directx/msdvbnp/msdvbnp.cpp
5  * PURPOSE: COM Initialization
6  *
7  * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@reactos.org)
8  */
9 
10 #include "precomp.h"
11 
12 #ifndef _MSC_VER
13 const GUID KSCATEGORY_BDA_NETWORK_PROVIDER = {0x71985f4b, 0x1ca1, 0x11d3, {0x9c, 0xc8, 0x0, 0xc0, 0x4f, 0x79, 0x71, 0xe0}};
14 #endif
15 
17 {
18  {&CLSID_DVBTNetworkProvider, CNetworkProvider_fnConstructor, L"ReactOS DVBT Network Provider"},
19  {NULL, NULL, NULL}
20 };
21 
22 extern "C"
23 BOOL
24 WINAPI
26  HINSTANCE hInstDLL,
27  DWORD fdwReason,
29 {
30  switch (fdwReason)
31  {
32  case DLL_PROCESS_ATTACH:
34 
35 #ifdef MSDVBNP_TRACE
36  OutputDebugStringW(L"MSDVBNP::DllMain()\n");
37 #endif
38 
39  DisableThreadLibraryCalls(hInstDLL);
40  break;
41  default:
42  break;
43  }
44 
45  return TRUE;
46 }
47 
48 
49 extern "C"
51 HRESULT
52 WINAPI
54 {
55  ULONG Index = 0;
56  LPOLESTR pStr;
57  HRESULT hr = S_OK;
58  HKEY hClass;
59 
60 
62  if (FAILED(hr))
63  return hr;
64 
65  if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_SET_VALUE, &hClass) != ERROR_SUCCESS)
66  {
67  CoTaskMemFree(pStr);
68  return E_FAIL;
69  }
70 
71  RegDeleteKeyW(hClass, pStr);
72  CoTaskMemFree(pStr);
73 
74  do
75  {
77  if (FAILED(hr))
78  break;
79 
80  RegDeleteKeyW(hClass, pStr);
81  CoTaskMemFree(pStr);
82  Index++;
83  }while(InterfaceTable[Index].lpfnCI != 0);
84 
85  RegCloseKey(hClass);
86  return hr;
87 }
88 
89 VOID
91  HKEY hFilter,
92  LPCWSTR ComponentClsid,
93  LPCWSTR ComponentName)
94 {
95  HKEY hComp;
96 
97  // create network provider filter key
98  if (RegCreateKeyExW(hFilter, ComponentClsid, 0, NULL, 0, KEY_WRITE, NULL, &hComp, NULL) == ERROR_SUCCESS)
99  {
100  // store class id
101  RegSetValueExW(hComp, L"CLSID", 0, REG_SZ, (const BYTE*)ComponentClsid, (wcslen(ComponentClsid)+1) * sizeof(WCHAR));
102  RegSetValueExW(hComp, L"FriendlyName", 0, REG_SZ, (const BYTE*)ComponentName, (wcslen(ComponentName)+1) * sizeof(WCHAR));
103  RegCloseKey(hComp);
104  }
105 }
106 
107 extern "C"
108 KSDDKAPI
109 HRESULT
110 WINAPI
112 {
113  ULONG Index = 0;
114  LPOLESTR pStr;
115  HRESULT hr = S_OK;
116  HKEY hClass, hKey, hSubKey, hProvider, hInstance, hFilter;
117  static LPCWSTR ModuleName = L"msdvbnp.ax";
118  static LPCWSTR ThreadingModel = L"Both";
119 
121  if (FAILED(hr))
122  return hr;
123 
124  if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_WRITE, &hClass) != ERROR_SUCCESS)
125  {
126  CoTaskMemFree(pStr);
127  return E_FAIL;
128  }
129 
130  if (RegCreateKeyExW(hClass, pStr, 0, NULL, 0, KEY_WRITE, NULL, &hProvider, NULL) != ERROR_SUCCESS)
131  {
132  RegCloseKey(hClass);
133  CoTaskMemFree(pStr);
134  return E_FAIL;
135  }
136 
137  CoTaskMemFree(pStr);
138 
139  if (RegCreateKeyExW(hProvider, L"Instance", 0, NULL, 0, KEY_WRITE, NULL, &hInstance, NULL) != ERROR_SUCCESS)
140  {
141  RegCloseKey(hClass);
142  return E_FAIL;
143  }
144  RegCloseKey(hProvider);
145 
146  /* open active movie filter category key */
147  if (RegCreateKeyExW(hClass, L"{da4e3da0-d07d-11d0-bd50-00a0c911ce86}\\Instance", 0, NULL, 0, KEY_WRITE, NULL, &hFilter, NULL) != ERROR_SUCCESS)
148  {
149  RegCloseKey(hClass);
151  return E_FAIL;
152  }
153 
154  RegisterBDAComponent(hFilter, L"{71985F4A-1CA1-11d3-9CC8-00C04F7971E0}", L"BDA Playback Filter");
155  RegisterBDAComponent(hFilter, L"{71985F4B-1CA1-11D3-9CC8-00C04F7971E0}", L"BDA Network Providers");
156  RegisterBDAComponent(hFilter, L"{71985F48-1CA1-11d3-9CC8-00C04F7971E0}", L"BDA Source Filter");
157  RegisterBDAComponent(hFilter, L"{A2E3074F-6C3D-11D3-B653-00C04F79498E}", L"BDA Transport Information Renderers");
158  RegisterBDAComponent(hFilter, L"{FD0A5AF4-B41D-11d2-9C95-00C04F7971E0}", L"BDA Receiver Component");
159  RegCloseKey(hKey);
160 
161  do
162  {
164  if (FAILED(hr))
165  break;
166 
167  if (RegCreateKeyExW(hClass, pStr, 0, 0, 0, KEY_WRITE, NULL, &hKey, 0) == ERROR_SUCCESS)
168  {
169  if (RegCreateKeyExW(hKey, L"InprocServer32", 0, 0, 0, KEY_WRITE, NULL, &hSubKey, 0) == ERROR_SUCCESS)
170  {
171  RegSetValueExW(hSubKey, 0, 0, REG_SZ, (const BYTE*)ModuleName, (wcslen(ModuleName) + 1) * sizeof(WCHAR));
172  RegSetValueExW(hSubKey, L"ThreadingModel", 0, REG_SZ, (const BYTE*)ThreadingModel, (wcslen(ThreadingModel) + 1) * sizeof(WCHAR));
173  RegCloseKey(hSubKey);
174  }
175  RegCloseKey(hKey);
176  }
177 
178  if (RegCreateKeyExW(hInstance, InterfaceTable[Index].ProviderName, 0, 0, 0, KEY_WRITE, NULL, &hKey, 0) == ERROR_SUCCESS)
179  {
180  //FIXME filterdata
181  RegSetValueExW(hKey, L"FriendlyName", 0, REG_SZ, (const BYTE*)InterfaceTable[Index].ProviderName, (wcslen(InterfaceTable[Index].ProviderName) + 1) * sizeof(WCHAR));
182  RegSetValueExW(hKey, L"CLSID", 0, REG_SZ, (const BYTE*)pStr, (wcslen(pStr)+1) * sizeof(WCHAR));
183  RegCloseKey(hKey);
184  }
185 
186 
187 
188 
189  CoTaskMemFree(pStr);
190  Index++;
191  }while(InterfaceTable[Index].lpfnCI != 0);
192 
193  RegCloseKey(hClass);
195  return hr;
196 }
197 
198 KSDDKAPI
199 HRESULT
200 WINAPI
202  REFCLSID rclsid,
203  REFIID riid,
204  LPVOID *ppv)
205 {
206  UINT i;
208  IClassFactory * pcf = NULL;
209 
210  if (!ppv)
211  return E_INVALIDARG;
212 
213  *ppv = NULL;
214 
215  for (i = 0; InterfaceTable[i].riid; i++)
216  {
217  if (IsEqualIID(*InterfaceTable[i].riid, rclsid))
218  {
220  break;
221  }
222  }
223 
224  if (!pcf)
225  {
227  }
228 
229  hres = pcf->QueryInterface(riid, ppv);
230  pcf->Release();
231 
232  return hres;
233 }
234 
235 KSDDKAPI
236 HRESULT
237 WINAPI
239 {
240  return S_OK;
241 }
#define REFIID
Definition: guiddef.h:118
#define TRUE
Definition: types.h:120
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:420
KSDDKAPI HRESULT WINAPI DllUnregisterServer(void)
Definition: msdvbnp.cpp:53
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
#define KEY_SET_VALUE
Definition: nt_native.h:1017
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
const GUID CLSID_DVBTNetworkProvider
REFIID riid
Definition: precomp.h:44
#define REFCLSID
Definition: guiddef.h:117
KSDDKAPI HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: msdvbnp.cpp:201
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1237
REFIID LPVOID * ppv
Definition: atlbase.h:39
LPFNCREATEINSTANCE lpfnCI
Definition: shellole.c:61
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char * ModuleName
Definition: acpixf.h:1274
static LPOLESTR
Definition: stg_prop.c:27
#define E_FAIL
Definition: ddrawi.h:102
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
#define KSDDKAPI
Definition: ks.h:40
static IN DWORD IN LPVOID lpvReserved
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
void WINAPI SHIM_OBJ_NAME() OutputDebugStringW(LPCWSTR lpOutputString)
Definition: ignoredbgout.c:23
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HINSTANCE hInstance
Definition: charmap.c:20
const GUID * riid
Definition: precomp.h:26
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
unsigned int BOOL
Definition: ntddk_ex.h:94
ULONG Release()
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
VOID RegisterBDAComponent(HKEY hFilter, LPCWSTR ComponentClsid, LPCWSTR ComponentName)
Definition: msdvbnp.cpp:90
#define KEY_WRITE
Definition: nt_native.h:1031
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
IClassFactory * CClassFactory_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, IID *riidInst)
HRESULT WINAPI CNetworkProvider_fnConstructor(IUnknown *pUnknown, REFIID riid, LPVOID *ppv)
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:78
const GUID KSCATEGORY_BDA_NETWORK_PROVIDER
Definition: msdvbnp.cpp:13
#define WINAPI
Definition: msvc.h:6
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
unsigned char BYTE
Definition: mem.h:68
KSDDKAPI HRESULT WINAPI DllRegisterServer(void)
Definition: msdvbnp.cpp:111
#define S_OK
Definition: intsafe.h:59
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
Definition: msdvbnp.cpp:25
KSDDKAPI HRESULT WINAPI DllCanUnloadNow(void)
Definition: msdvbnp.cpp:238
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
static INTERFACE_TABLE InterfaceTable[]
Definition: msdvbnp.cpp:16
unsigned int ULONG
Definition: retypes.h:1
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
Definition: compobj.c:2412
#define REG_SZ
Definition: layer.c:22