📄 lancardtypedlg.cpp
字号:
// LANCardTypeDlg.cpp : implementation file
//
#include "stdafx.h"
#include <Pkfuncs.h>
#include "LANCardType.h"
#include "LANCardTypeDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define PCMCIA_S1_ATTR_PHYSICAL 0x38000000
#define PCMCIA_S0_ATTR_PHYSICAL 0x28000000
#define ATTR_SIZE 0x200
#define strWaiting _T("Waiting for your plugging in")
#define strPreModify _T("Pre-CIS Modified Card")
#define strModify _T("CIS Modified Card")
int CIS_MODIFIED_DATA[] =
{
0x1c, 0x4, 0x3, 0xdc, 0, 0xff, 0x1d, 0x4,
0x3, 0x49, 0x0, 0xff, 0x15, 0x1b, 0x4, 0x1,
0x43, 0x46, 0x0, 0x31, 0x30, 0x42, 0x61, 0x73,
0x65, 0x2d, 0x45, 0x74, 0x68, 0x65, 0x72, 0x6e,
0x65, 0x74, 0, 0x31, 0x2e, 0x30, 0, 0,
0xff, 0x13, 0x3, 0x43, 0x49, 0x53, 0x21, 0x2,
0x6, 0, 0x1a, 0x5, 0x1, 0x23, 0xf8, 0x3,
0x3, 0x1b, 0x11, 0xe0, 0x81, 0x1d, 0x3f, 0x55,
0x4d, 0x5d, 0x6, 0x86, 0x46, 0x26, 0xfc, 0x24,
0x65, 0x30, 0xff, 0xff, 0x1b, 0x7, 0x20, 0x8,
0xca, 0x60, 0, 0x3, 0x1f, 0x1b, 0x7, 0x21,
0x8, 0xca, 0x60, 0x20, 0x3, 0x1f, 0x1b, 0x7,
0x22, 0x8, 0xca, 0x60, 0x40, 0x3, 0x1f, 0x1b,
0x7, 0x23, 0x8, 0xca, 0x60, 0x60, 0x3, 0x1f,
0xff, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
/////////////////////////////////////////////////////////////////////////////
// CLANCardTypeDlg dialog
CLANCardTypeDlg::CLANCardTypeDlg(CWnd* pParent /*=NULL*/)
: CDialog(CLANCardTypeDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CLANCardTypeDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_lpCISData = NULL;
}
void CLANCardTypeDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLANCardTypeDlg)
DDX_Control(pDX, IDC_STATIC_RESULT, m_staResult);
DDX_Control(pDX, IDC_STATIC_INDICATE, m_staIndicate);
DDX_Control(pDX, IDC_BUTTON_TEST, m_btnTest);
DDX_Control(pDX, IDC_BUTTON_EXIT, m_btnExit);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLANCardTypeDlg, CDialog)
//{{AFX_MSG_MAP(CLANCardTypeDlg)
ON_BN_CLICKED(IDC_BUTTON_TEST, OnButtonTest)
ON_BN_CLICKED(IDC_BUTTON_EXIT, OnButtonExit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLANCardTypeDlg message handlers
BOOL CLANCardTypeDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
CenterWindow(GetDesktopWindow()); // center to the hpc screen
m_staResult.SetWindowText(strWaiting);
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CLANCardTypeDlg::OnButtonTest()
{
// TODO: Add your control notification handler code here
GetDlgItem(IDC_STATIC_RESULT)->ShowWindow(SW_HIDE);
BOOL bCISModify = TRUE;
Sleep(1000);//wait for the initlization of the LAN card
m_lpCISData = VirtualAlloc(0, ATTR_SIZE, MEM_RESERVE, PAGE_NOACCESS);
if(m_lpCISData)
{
if(VirtualCopy(m_lpCISData, (LPVOID)(PCMCIA_S0_ATTR_PHYSICAL>>8), ATTR_SIZE, PAGE_READWRITE | PAGE_NOCACHE | PAGE_PHYSICAL))
{
BYTE* pData;
pData = (BYTE*)m_lpCISData;
int i =0;
while(i<2*(sizeof(CIS_MODIFIED_DATA)/sizeof(CIS_MODIFIED_DATA[0])))
{
if(pData[i] != CIS_MODIFIED_DATA[i/2])
{
bCISModify = FALSE;
break;
}
i += 2;
}
}
else
{
MessageBox(_T("Fata Error, Please restart the program!"));
}
}
else
{
MessageBox(_T("Fata Error, Please restart your unit!"));
return;
}
if(bCISModify)
MessageBox(strModify);
else
MessageBox(strPreModify);
m_btnTest.SetFocus();
GetDlgItem(IDC_STATIC_RESULT)->ShowWindow(SW_SHOW);
VirtualFree(m_lpCISData, ATTR_SIZE, MEM_DECOMMIT);
}
void CLANCardTypeDlg::OnButtonExit()
{
// TODO: Add your control notification handler code here
CDialog::OnCancel();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -