ReactOS  0.4.14-dev-49-gfb4591c
netcfgx.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS Configuration of network devices
4  * FILE: dll/win32/netcfgx/netcfgx.c
5  * PURPOSE: Network devices installer
6  *
7  * PROGRAMMERS: Hervé Poussineau (hpoussin@reactos.org)
8  */
9 
10 #include "precomp.h"
11 
12 #include <olectl.h>
13 
14 
16 const GUID CLSID_TcpipConfigNotifyObject = {0xA907657F, 0x6FDF, 0x11D0, {0x8E, 0xFB, 0x00, 0xC0, 0x4F, 0xD9, 0x12, 0xB2}};
17 
19 {
20  {
23  },
24  {
27  },
28  {
29  NULL,
30  NULL
31  }
32 };
33 
34 BOOL
35 WINAPI
36 DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
37 {
38  switch (fdwReason)
39  {
40  case DLL_PROCESS_ATTACH:
41  netcfgx_hInstance = hinstDLL;
44  break;
45 
46  default:
47  break;
48  }
49 
50  return TRUE;
51 }
52 
53 HRESULT
54 WINAPI
56 {
57  return S_FALSE;
58 }
59 
60 STDAPI
62 {
63  HKEY hKey, hSubKey;
64  LPOLESTR pStr;
65  WCHAR szName[MAX_PATH] = L"CLSID\\";
66 
67  if (FAILED(StringFromCLSID(&CLSID_CNetCfg, &pStr)))
68  return SELFREG_E_CLASS;
69 
70  wcscpy(&szName[6], pStr);
71  CoTaskMemFree(pStr);
72 
74  return SELFREG_E_CLASS;
75 
76  if (RegCreateKeyExW(hKey, L"InProcServer32", 0, NULL, 0, KEY_WRITE, NULL, &hSubKey, NULL) == ERROR_SUCCESS)
77  {
78  if (!GetModuleFileNameW(netcfgx_hInstance, szName, sizeof(szName)/sizeof(WCHAR)))
79  {
80  RegCloseKey(hSubKey);
81  RegCloseKey(hKey);
82  return SELFREG_E_CLASS;
83  }
84  szName[(sizeof(szName)/sizeof(WCHAR))-1] = L'\0';
85  RegSetValueW(hSubKey, NULL, REG_SZ, szName, (wcslen(szName)+1) * sizeof(WCHAR));
86  RegSetValueExW(hSubKey, L"ThreadingModel", 0, REG_SZ, (LPBYTE)L"Both", 10);
87  RegCloseKey(hSubKey);
88  }
89 
90  RegCloseKey(hKey);
91  return S_OK;
92 }
93 
94 STDAPI
96 {
97  //FIXME
98  // implement unregistering services
99  //
100  return S_OK;
101 }
102 
103 STDAPI
105  REFCLSID rclsid,
106  REFIID riid,
107  LPVOID* ppv)
108 {
109  UINT i;
111  IClassFactory * pcf = NULL;
112 
113  if (!ppv)
114  return E_INVALIDARG;
115 
116  *ppv = NULL;
117 
118  for (i = 0; InterfaceTable[i].riid; i++)
119  {
120  if (IsEqualIID(InterfaceTable[i].riid, rclsid))
121  {
123  break;
124  }
125  }
126 
127  if (!pcf)
128  {
130  }
131 
132  hres = IClassFactory_QueryInterface(pcf, riid, ppv);
133  IClassFactory_Release(pcf);
134 
135  return hres;
136 }
#define STDAPI
Definition: basetyps.h:41
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:609
#define REFIID
Definition: guiddef.h:118
#define TRUE
Definition: types.h:120
HRESULT WINAPI INetCfg_Constructor(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppv)
Definition: netcfg_iface.c:818
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:422
#define ERROR_SUCCESS
Definition: deptool.c:10
REFIID riid
Definition: precomp.h:44
#define REFCLSID
Definition: guiddef.h:117
REFIID LPVOID * ppv
Definition: atlbase.h:39
LONG WINAPI RegSetValueW(HKEY hKeyOriginal, LPCWSTR lpSubKey, DWORD dwType, LPCWSTR lpData, DWORD cbData)
Definition: reg.c:5014
LPFNCREATEINSTANCE lpfnCI
Definition: shellole.c:61
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
static INTERFACE_TABLE InterfaceTable[]
Definition: netcfgx.c:18
HRESULT WINAPI DllCanUnloadNow(void)
Definition: netcfgx.c:55
static LPOLESTR
Definition: stg_prop.c:27
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
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
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
const GUID * riid
Definition: precomp.h:26
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
unsigned int BOOL
Definition: ntddk_ex.h:94
#define S_FALSE
Definition: winerror.h:2357
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
EXTERN_C const GUID CLSID_CNetCfg
Definition: netcfgx.h:299
HRESULT WINAPI TcpipConfigNotify_Constructor(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppv)
#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
HINSTANCE netcfgx_hInstance
Definition: netcfgx.c:15
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
#define WINAPI
Definition: msvc.h:8
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
Definition: netcfgx.c:36
_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
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: netcfgx.c:104
IClassFactory * IClassFactory_fnConstructor(LPFNCREATEINSTANCE lpfnCI, PLONG pcRefDll, REFIID riidInst)
Definition: classfactory.c:125
STDAPI DllRegisterServer(void)
Definition: netcfgx.c:61
const GUID CLSID_TcpipConfigNotifyObject
Definition: netcfgx.c:16
#define S_OK
Definition: intsafe.h:59
DWORD LPVOID fImpLoad
Definition: misc.cpp:155
STDAPI DllUnregisterServer(void)
Definition: netcfgx.c:95
unsigned int UINT
Definition: ndis.h:50
static const WCHAR szName[]
Definition: msipriv.h:1194
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:863
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define SELFREG_E_CLASS
Definition: olectl.h:261
HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
Definition: compobj.c:2321
#define REG_SZ
Definition: layer.c:22