- Don't open registry keys with full access rights
- Replace OutputDebugString by DPRINT
svn path=/trunk/; revision=19698
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
* PROJECT: ReactOS Network Control Panel
* FILE: lib/cpl/system/ncpa.c
* PURPOSE: ReactOS Network Control Panel
* PROJECT: ReactOS Network Control Panel
* FILE: lib/cpl/system/ncpa.c
* PURPOSE: ReactOS Network Control Panel
#include <iphlpapi.h>
#include <commctrl.h>
#include <cpl.h>
#include <iphlpapi.h>
#include <commctrl.h>
#include <cpl.h>
-//#ifdef __REACTOS__
-//#include <Netcfgn.h>
-//#endif
#include "resource.h"
#include "ncpa.h"
#include "resource.h"
#include "ncpa.h"
TCHAR tpszName[MAX_PATH];
DWORD dwNameLen = sizeof(tpszName);
TCHAR tpszName[MAX_PATH];
DWORD dwNameLen = sizeof(tpszName);
- if(RegOpenKeyEx(hBaseKey,tpszRegPath,0,KEY_ALL_ACCESS,&hKey)!=ERROR_SUCCESS)
+ if(RegOpenKeyEx(hBaseKey,tpszRegPath,0,KEY_ENUMERATE_SUB_KEYS,&hKey)!=ERROR_SUCCESS)
- OutputDebugString(_T("EnumRegKeys failed (key not found)\r\n"));
- OutputDebugString(tpszRegPath);
- OutputDebugString(_T("\r\n"));
+ DPRINT("EnumRegKeys failed (key not found): %S\n", tpszRegPath);
ret = RegEnumKeyEx(hKey,i,tpszName,&dwNameLen,NULL,NULL,NULL,NULL);
if(ret != ERROR_SUCCESS)
{
ret = RegEnumKeyEx(hKey,i,tpszName,&dwNameLen,NULL,NULL,NULL,NULL);
if(ret != ERROR_SUCCESS)
{
- OutputDebugString(_T("EnumRegKeys: RegEnumKeyEx failed for\r\n"));
- OutputDebugString(tpszName);
- OutputDebugString(_T("\r\n"));
+ DPRINT("EnumRegKeys: RegEnumKeyEx failed for %S (rc 0x%lx)\n", tpszName, ret);
break;
}
_stprintf(pszNewPath,_T("%s\\%s"),tpszRegPath,tpszName);
break;
}
_stprintf(pszNewPath,_T("%s\\%s"),tpszRegPath,tpszName);
- OutputDebugString(_T("EnumRegKeys: Calling user supplied enum function\r\n"));
+ DPRINT("EnumRegKeys: Calling user supplied enum function\n");
pCallback(pCookie,hBaseKey,pszNewPath);
dwNameLen = sizeof(tpszName);
pCallback(pCookie,hBaseKey,pszNewPath);
dwNameLen = sizeof(tpszName);
for (i = 0; i < 100; i++)
{
_stprintf(tpszSubKey,_T("SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\%04d"),i);
for (i = 0; i < 100; i++)
{
_stprintf(tpszSubKey,_T("SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\%04d"),i);
- if(RegOpenKey(HKEY_LOCAL_MACHINE,tpszSubKey,&hKey)!=ERROR_SUCCESS)
+ if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,tpszSubKey,0,KEY_QUERY_VALUE,&hKey)!=ERROR_SUCCESS)
continue;
dwType = REG_SZ;
dwSize = sizeof(tpszCfgInst2);
continue;
dwType = REG_SZ;
dwSize = sizeof(tpszCfgInst2);
// INetCfgComponentPropertyUi *pNetCfgPropUI;
hwndDlg = (HWND)pCookie;
// INetCfgComponentPropertyUi *pNetCfgPropUI;
hwndDlg = (HWND)pCookie;
- if(RegOpenKey(HKEY_LOCAL_MACHINE,tpszSubKey,&hKey)!=ERROR_SUCCESS)
+ if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,tpszSubKey,0,KEY_QUERY_VALUE,&hKey)!=ERROR_SUCCESS)
return;
dwType = REG_DWORD;
return;
dwType = REG_DWORD;
if(RegQueryValueEx(hKey,_T("Description"),NULL,&dwType,(BYTE*)tpszDescription,&dwSize)!= ERROR_SUCCESS)
return;
if(RegQueryValueEx(hKey,_T("Description"),NULL,&dwType,(BYTE*)tpszDescription,&dwSize)!= ERROR_SUCCESS)
return;
- RegOpenKey(hKey,_T("Ndi"),&hNDIKey);
+ RegOpenKeyEx(hKey,_T("Ndi"),0,KEY_QUERY_VALUE,&hNDIKey);
dwType = REG_SZ;
dwSize = sizeof(tpszNotifyObjectCLSID);
if(RegQueryValueEx(hNDIKey,_T("ClsId"),NULL,&dwType,(BYTE*)tpszNotifyObjectCLSID,&dwSize)!= ERROR_SUCCESS)
dwType = REG_SZ;
dwSize = sizeof(tpszNotifyObjectCLSID);
if(RegQueryValueEx(hNDIKey,_T("ClsId"),NULL,&dwType,(BYTE*)tpszNotifyObjectCLSID,&dwSize)!= ERROR_SUCCESS)
MessageBox(hwndDlg,tpszCfgInstanceID,tpszSubKey,MB_ICONSTOP);
}
MessageBox(hwndDlg,tpszCfgInstanceID,tpszSubKey,MB_ICONSTOP);
}
- if(RegOpenKey(HKEY_LOCAL_MACHINE,tpszSubKey,&hKey)!=ERROR_SUCCESS)
+ if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,tpszSubKey,0,KEY_QUERY_VALUE,&hKey)!=ERROR_SUCCESS)
return 0;
dwType = REG_SZ;
dwSize = sizeof(tpszDisplayName);
return 0;
dwType = REG_SZ;
dwSize = sizeof(tpszDisplayName);
break;
_stprintf(tpszHelpKey,_T("%s\\Ndi"),tpszSubKey);
break;
_stprintf(tpszHelpKey,_T("%s\\Ndi"),tpszSubKey);
- RegOpenKey(HKEY_LOCAL_MACHINE,tpszHelpKey,&hNDIKey);
+ RegOpenKeyEx(HKEY_LOCAL_MACHINE,tpszHelpKey,0,KEY_QUERY_VALUE,&hNDIKey);
dwType = REG_SZ;
dwSize = sizeof(tpszHelpText);
if(RegQueryValueEx(hNDIKey,_T("HelpText"),NULL,&dwType,(BYTE*)tpszHelpText,&dwSize)!= ERROR_SUCCESS)
dwType = REG_SZ;
dwSize = sizeof(tpszHelpText);
if(RegQueryValueEx(hNDIKey,_T("HelpText"),NULL,&dwType,(BYTE*)tpszHelpText,&dwSize)!= ERROR_SUCCESS)
break;
_stprintf(tpszNDIKey,_T("%s\\Ndi"),tpszSubKey);
break;
_stprintf(tpszNDIKey,_T("%s\\Ndi"),tpszSubKey);
- RegOpenKey(HKEY_LOCAL_MACHINE,tpszNDIKey,&hNDIKey);
- dwType = REG_SZ;
+ RegOpenKeyEx(HKEY_LOCAL_MACHINE,tpszNDIKey,0,KEY_QUERY_VALUE,&hNDIKey);
dwSize = sizeof(tpszClsIDText);
dwSize = sizeof(tpszClsIDText);
- if(RegQueryValueEx(hNDIKey,_T("ClsId"),NULL,&dwType,(BYTE*)tpszClsIDText,&dwSize)!= ERROR_SUCCESS)
+ if(RegQueryValueEx(hNDIKey,_T("ClsId"),NULL,&dwType,(BYTE*)tpszClsIDText,&dwSize)!= ERROR_SUCCESS || dwType != REG_SZ)
;//return;
RegCloseKey(hNDIKey);
;//return;
RegCloseKey(hNDIKey);
{
TCHAR tpszAdatperName[MAX_PATH];
swprintf(tpszAdatperName,L"%S",pAdapter->AdapterName);
{
TCHAR tpszAdatperName[MAX_PATH];
swprintf(tpszAdatperName,L"%S",pAdapter->AdapterName);
- OutputDebugString(_T("IPHLPAPI returned:\r\n"));
- OutputDebugString(tpszAdatperName);
- OutputDebugString(_T("\r\n"));
+ DPRINT("IPHLPAPI returned: %S\n", tpszAdatperName);
if(_tcscmp(tpszAdatperName,tpszCfgInstanceID)==0)
{
DisplayTCPIPProperties(hwndDlg,pAdapter);
break;
} else
{
if(_tcscmp(tpszAdatperName,tpszCfgInstanceID)==0)
{
DisplayTCPIPProperties(hwndDlg,pAdapter);
break;
} else
{
- OutputDebugString(_T("... which is not the TCPIP property sheet\r\n"));
+ DPRINT("... which is not the TCPIP property sheet\n");
}
pAdapter = pAdapter->Next;
if(!pAdapter)
}
pAdapter = pAdapter->Next;
if(!pAdapter)
// Get the "Name" for this Connection
_stprintf(tpszSubKey,_T("System\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\%s\\Connection"),tpszCfgInstanceID);
// Get the "Name" for this Connection
_stprintf(tpszSubKey,_T("System\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\%s\\Connection"),tpszCfgInstanceID);
- if(RegOpenKey(HKEY_LOCAL_MACHINE,tpszSubKey,&hKey)!=ERROR_SUCCESS)
+ if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,tpszSubKey,0,KEY_QUERY_VALUE,&hKey)!=ERROR_SUCCESS)
return;
if(RegQueryValueEx(hKey,_T("Name"),NULL,&dwType,(BYTE*)tpszName,&dwSize)!=ERROR_SUCCESS)
_stprintf(tpszName,_T("[ERROR]"));
return;
if(RegQueryValueEx(hKey,_T("Name"),NULL,&dwType,(BYTE*)tpszName,&dwSize)!=ERROR_SUCCESS)
_stprintf(tpszName,_T("[ERROR]"));
// Get the "Name" for this Connection
_stprintf(tpszSubKey,_T("System\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\%s\\Connection"),tpszCfgInstanceID);
// Get the "Name" for this Connection
_stprintf(tpszSubKey,_T("System\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\%s\\Connection"),tpszCfgInstanceID);
- if (RegOpenKey(HKEY_LOCAL_MACHINE,tpszSubKey,&hKey)!=ERROR_SUCCESS)
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,tpszSubKey,0,KEY_QUERY_VALUE,&hKey)!=ERROR_SUCCESS)
return;
if (RegQueryValueEx(hKey,_T("Name"),NULL,&dwType,(BYTE*)tpszName,&dwSize)!=ERROR_SUCCESS)
return;
if (RegQueryValueEx(hKey,_T("Name"),NULL,&dwType,(BYTE*)tpszName,&dwSize)!=ERROR_SUCCESS)
HWND hwndDlg = (HWND)pCookie;
DWORD dwCharacteristics;
HWND hwndDlg = (HWND)pCookie;
DWORD dwCharacteristics;
- OutputDebugString(_T("NetAdapterCallback\r\n"));
- OutputDebugString(tpszSubKey);
- OutputDebugString(_T("\r\n"));
- if(RegOpenKeyEx(hBaseKey,tpszSubKey,0,KEY_ALL_ACCESS,&hKey)!=ERROR_SUCCESS)
+ DPRINT("NetAdapterCallback: %S\n", tpszSubKey);
+ if(RegOpenKeyEx(hBaseKey,tpszSubKey,0,KEY_QUERY_VALUE,&hKey)!=ERROR_SUCCESS)
- OutputDebugString(_T("NetAdapterCallback: Reading Characteristics\r\n"));
+ DPRINT("NetAdapterCallback: Reading Characteristics\n");
dwType = REG_DWORD;
dwSize = sizeof(dwCharacteristics);
if(RegQueryValueEx(hKey,_T("Characteristics"),NULL,&dwType,(BYTE*)&dwCharacteristics,&dwSize)!=ERROR_SUCCESS)
dwType = REG_DWORD;
dwSize = sizeof(dwCharacteristics);
if(RegQueryValueEx(hKey,_T("Characteristics"),NULL,&dwType,(BYTE*)&dwCharacteristics,&dwSize)!=ERROR_SUCCESS)
// if (!(dwCharacteristics & NCF_HAS_UI))
// return;
// if (!(dwCharacteristics & NCF_HAS_UI))
// return;
- OutputDebugString(_T("NetAdapterCallback: Reading DriverDesc\r\n"));
+ DPRINT("NetAdapterCallback: Reading DriverDesc\n");
dwType = REG_SZ;
dwSize = sizeof(tpszDisplayName);
if (RegQueryValueEx(hKey,_T("DriverDesc"),NULL,&dwType,(BYTE*)tpszDisplayName,&dwSize)!= ERROR_SUCCESS)
dwType = REG_SZ;
dwSize = sizeof(tpszDisplayName);
if (RegQueryValueEx(hKey,_T("DriverDesc"),NULL,&dwType,(BYTE*)tpszDisplayName,&dwSize)!= ERROR_SUCCESS)
extern HINSTANCE hApplet;
extern HINSTANCE hApplet;
+extern DWORD DbgPrint(PCHAR Fmt, ...);