📄 romdumpdlg.cpp
字号:
// ROMDumpDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ROMDump.h"
#include "ROMDumpDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CROMDumpDlg dialog
CROMDumpDlg::CROMDumpDlg(CWnd* pParent /*=NULL*/)
: CDialog(CROMDumpDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CROMDumpDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CROMDumpDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CROMDumpDlg)
DDX_Control(pDX, IDC_EDIT1, m_FileName);
DDX_Control(pDX, IDC_PROGRESS1, m_Progress);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CROMDumpDlg, CDialog)
//{{AFX_MSG_MAP(CROMDumpDlg)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CROMDumpDlg message handlers
BOOL CROMDumpDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
CenterWindow(GetDesktopWindow()); // center to the hpc screen
// TODO: Add extra initialization here
m_FileName.SetWindowText(L"\\Storage Card\\romdump.bin");
return TRUE; // return TRUE unless you set the focus to a control
}
extern "C" BOOL VirtualCopy(
LPVOID lpvDest,
LPVOID lpvSrc,
DWORD cbSize,
DWORD fdwProtect
);
void CROMDumpDlg::OnButton1()
{
m_Progress.SetRange( 0, 100 );
m_Progress.SetPos(0);
CString S;
m_FileName.GetWindowText(S);
HANDLE H=CreateFile(S,GENERIC_WRITE,0,0,CREATE_ALWAYS,FILE_FLAG_WRITE_THROUGH,0);
if(H==INVALID_HANDLE_VALUE)
{
MessageBox(L"Cannot create file!",L"Error",MB_OK);
PostQuitMessage(0);
return;
}
for(int i=0; i<64*1024*1024; i+=512*1024)
{
LPVOID Ptr=VirtualAlloc(
0,
512*1024,
MEM_RESERVE,
PAGE_READONLY
);
if(Ptr==0)
{
wchar_t Buff[1024];
wsprintf(Buff,L"Cannot allocate %08X",i);
MessageBox(Buff,L"Error",MB_OK);
PostQuitMessage(0);
return;
}
m_Progress.SetPos(i/(64*1024*1024/100));
UpdateWindow();
if(!VirtualCopy(Ptr,(void*)(i/256),512*1024,PAGE_READONLY|PAGE_PHYSICAL))
{
wchar_t Buff[1024];
wsprintf(Buff,L"Cannot map %08X",i);
MessageBox(Buff,L"Error",MB_OK);
PostQuitMessage(0);
return;
}
DWORD W=0;
WriteFile(H,Ptr,512*1024,&W,0);
if(W!=512*1024)
{
MessageBox(L"Error on WriteFile. Card full?",L"Error");
PostQuitMessage(0);
return;
}
VirtualFree(Ptr,0,MEM_RELEASE);
}
CloseHandle(H);
MessageBox(L"Successfully dumped ROM!",L"Done");
PostQuitMessage(0);
}
void CROMDumpDlg::OnButton2()
{
static wchar_t szFilter[] = L"*.bin|*.bin|*.*|*.*||";
CFileDialog F(FALSE,L"BIN",L"*.bin",OFN_HIDEREADONLY,szFilter,this);
if( F.DoModal ()==IDOK )
{
CString pathName = F.GetPathName();
m_FileName.SetWindowText(pathName);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -