📄 debugdialog.cpp
字号:
// DebugDialog.cpp : implementation file
//
/*******************************************************************************
* *
* This file is part of VPNDialer. *
* *
* VPNDialer is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* VPNDialer is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with VPNDialer; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
* *
* Copyright (c) 2003 Evidian GmbH, written by Thomas Kriener *
* *
*******************************************************************************/
#include "stdafx.h"
#include "VPNDialer.h"
#include "DebugDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDebugDialog dialog
CDebugDialog::CDebugDialog(CWnd* pParent /*=NULL*/)
: CDialog(CDebugDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CDebugDialog)
m_oakley = FALSE;
m_logDescription = _T("no logging");
m_syslog = 0;
//}}AFX_DATA_INIT
}
void CDebugDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDebugDialog)
DDX_Check(pDX, IDC_OAKLEY, m_oakley);
DDX_Text(pDX, IDC_LOGDESCRIPTION, m_logDescription);
DDX_CBIndex(pDX, IDC_COMBO_SYSLOG, m_syslog);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDebugDialog, CDialog)
//{{AFX_MSG_MAP(CDebugDialog)
ON_CBN_SELCHANGE(IDC_COMBO_SYSLOG, OnSelchangeComboSyslog)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDebugDialog message handlers
void CDebugDialog::OnOK()
{
UpdateData();
SetOakleyParameter(m_oakley);
SetSyslogParameter(m_syslog);
CDialog::OnOK();
}
void CDebugDialog::OnSelchangeComboSyslog()
{
UpdateData();
m_logDescription=GetSyslogDescription(m_syslog);
UpdateData(FALSE);
}
BOOL CDebugDialog::OnInitDialog()
{
CDialog::OnInitDialog();
m_oakley=GetOakleyParameter();
m_syslog=GetSyslogParameter();
m_logDescription=GetSyslogDescription(m_syslog);
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CDebugDialog::GetOakleyParameter()
{
HKEY hKey;
DWORD valueSize;
DWORD valueType;
LONG regRetVal;
int intValue;
int i=0;
CString key;
key="SYSTEM\\CurrentControlSet\\Services\\PolicyAgent\\Oakley";
// get Last Date from Registry
regRetVal=RegOpenKeyEx(HKEY_LOCAL_MACHINE,
key,
0,
KEY_QUERY_VALUE,
&hKey);
if(regRetVal==ERROR_SUCCESS)
{
// EnableLogging
valueType=REG_DWORD;
valueSize=sizeof(intValue);
if(RegQueryValueEx(hKey,
"EnableLogging",
NULL,
&valueType,
(LPBYTE)&intValue,
&valueSize)==ERROR_SUCCESS)
{
return intValue;
}
// Close Session-Key
RegCloseKey(hKey);
}
return FALSE;
}
int CDebugDialog::SetOakleyParameter(BOOL val)
{
HKEY hKey;
DWORD valueSize;
DWORD valueType;
CString key;
int intValue;
key="SYSTEM\\CurrentControlSet\\Services\\PolicyAgent\\Oakley";
// open Key with write-rights
if(RegCreateKeyEx(HKEY_LOCAL_MACHINE,
key,
0,
"CLASS",
REG_OPTION_NON_VOLATILE,
KEY_WRITE,
NULL,
&hKey,
NULL)==ERROR_SUCCESS)
{
// EnableLogging
valueType=REG_DWORD;
valueSize=sizeof(intValue);
intValue=val;
if(RegSetValueEx(hKey,
"EnableLogging",
NULL,
valueType,
(LPBYTE)&intValue,
valueSize)!=ERROR_SUCCESS)
{
return 1;
}
RegCloseKey(hKey);
}
return 0;
}
int CDebugDialog::GetSyslogParameter()
{
HKEY hKey;
DWORD valueSize;
DWORD valueType;
LONG regRetVal;
int intValue;
int i=0;
CString key;
key="System\\CurrentControlSet\\Services\\IPSec";
// get Last Date from Registry
regRetVal=RegOpenKeyEx(HKEY_LOCAL_MACHINE,
key,
0,
KEY_QUERY_VALUE,
&hKey);
if(regRetVal==ERROR_SUCCESS)
{
// EnableDiagnostics
valueType=REG_DWORD;
valueSize=sizeof(intValue);
if(RegQueryValueEx(hKey,
"EnableDiagnostics",
NULL,
&valueType,
(LPBYTE)&intValue,
&valueSize)==ERROR_SUCCESS)
{
return intValue;
}
// Close Session-Key
RegCloseKey(hKey);
}
return FALSE;
}
int CDebugDialog::SetSyslogParameter(int val)
{
HKEY hKey;
DWORD valueSize;
DWORD valueType;
CString key;
int intValue;
key="System\\CurrentControlSet\\Services\\IPSec";
// open Key with write-rights
if(RegCreateKeyEx(HKEY_LOCAL_MACHINE,
key,
0,
"CLASS",
REG_OPTION_NON_VOLATILE,
KEY_WRITE,
NULL,
&hKey,
NULL)==ERROR_SUCCESS)
{
// EnableDiagnostics
valueType=REG_DWORD;
valueSize=sizeof(intValue);
intValue=val;
if(RegSetValueEx(hKey,
"EnableDiagnostics",
NULL,
valueType,
(LPBYTE)&intValue,
valueSize)!=ERROR_SUCCESS)
{
return 1;
}
RegCloseKey(hKey);
}
return 0;
}
CString CDebugDialog::GetSyslogDescription(int level)
{
CString retVal;
switch(level)
{
case 0: retVal="no logging"; break;
case 1: retVal="get aggregated driver logs, bad SPI value, unauthenticated hash, except \"clear text received when should have been secured\""; break;
case 2: retVal="no aggregated driver logs, get inbound-only per packet drop events, including \"clear text received when should have been secured\""; break;
case 3: retVal="both level 1 and 2 logging turned on"; break;
case 4: retVal="no aggregated driver logs, get outbound-only per packet drop events"; break;
case 5: retVal="both level 1 and 4 logging turned on"; break;
case 6: retVal="both level 2 and 4 logging turned on"; break;
case 7: retVal="all logging enabled"; break;
default: retVal="UNKNOWN VALUE!!!!!";
}
return retVal;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -