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 16 static INTERFACE_TABLE InterfaceTable[] = 17 { 18 {&CLSID_DVBTNetworkProvider, CNetworkProvider_fnConstructor, L"ReactOS DVBT Network Provider"}, 19 {NULL, NULL, NULL} 20 }; 21 22 extern "C" 23 BOOL 24 WINAPI 25 DllMain( 26 HINSTANCE hInstDLL, 27 DWORD fdwReason, 28 LPVOID lpvReserved) 29 { 30 switch (fdwReason) 31 { 32 case DLL_PROCESS_ATTACH: 33 CoInitialize(NULL); 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" 50 KSDDKAPI 51 HRESULT 52 WINAPI 53 DllUnregisterServer(void) 54 { 55 ULONG Index = 0; 56 LPOLESTR pStr; 57 HRESULT hr = S_OK; 58 HKEY hClass; 59 60 61 hr = StringFromCLSID(KSCATEGORY_BDA_NETWORK_PROVIDER, &pStr); 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 { 76 hr = StringFromCLSID(*InterfaceTable[Index].riid, &pStr); 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 90 RegisterBDAComponent( 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 111 DllRegisterServer(void) 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 120 hr = StringFromCLSID(KSCATEGORY_BDA_NETWORK_PROVIDER, &pStr); 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); 150 RegCloseKey(hInstance); 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 { 163 hr = StringFromCLSID(*InterfaceTable[Index].riid, &pStr); 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); 194 RegCloseKey(hInstance); 195 return hr; 196 } 197 198 KSDDKAPI 199 HRESULT 200 WINAPI 201 DllGetClassObject( 202 REFCLSID rclsid, 203 REFIID riid, 204 LPVOID *ppv) 205 { 206 UINT i; 207 HRESULT hres = E_OUTOFMEMORY; 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 { 219 pcf = CClassFactory_fnConstructor(InterfaceTable[i].lpfnCI, NULL, NULL); 220 break; 221 } 222 } 223 224 if (!pcf) 225 { 226 return CLASS_E_CLASSNOTAVAILABLE; 227 } 228 229 hres = pcf->QueryInterface(riid, ppv); 230 pcf->Release(); 231 232 return hres; 233 } 234 235 KSDDKAPI 236 HRESULT 237 WINAPI 238 DllCanUnloadNow(void) 239 { 240 return S_OK; 241 } 242