📄 flasherdlg.cpp
字号:
// FlasherDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Flasher.h"
#include "FlasherDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
CString m_ID;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
m_ID = _T("");
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
DDX_Text(pDX, IDC_IDTEXT, m_ID);
DDV_MaxChars(pDX, m_ID, 30);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFlasherDlg dialog
CFlasherDlg::CFlasherDlg(CWnd* pParent /*=NULL*/)
: CDialog(CFlasherDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CFlasherDlg)
m_strtext = _T("");
m_option = -1;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CFlasherDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFlasherDlg)
DDX_Control(pDX, IDC_TEXT2, m_text1);
DDX_Control(pDX, IDC_TEXT3, m_text2);
DDX_Control(pDX, IDC_TEXT4, m_text3);
DDX_Control(pDX, IDC_TEXT5, m_text4);
DDX_Control(pDX, IDC_TEXT6, m_text5);
DDX_Control(pDX, IDC_TEXT, m_text);
DDX_Text(pDX, IDC_TEXT, m_strtext);
DDV_MaxChars(pDX, m_strtext, 500);
DDX_Radio(pDX, IDC_OPTION, m_option);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFlasherDlg, CDialog)
//{{AFX_MSG_MAP(CFlasherDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_TIMER()
ON_BN_CLICKED(IDC_AUTOUNLOCK, OnAutounlock)
ON_BN_CLICKED(IDC_ABOUT, OnAbout)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFlasherDlg message handlers
BOOL CFlasherDlg::OnInitDialog()
{
do
{
cal_bad = FALSE;
int cal1, cal2;
Calibrare();
cal1 = cal_factor;
Calibrare();
cal2 = cal_factor;
if (cal1>=cal2) cal1 = cal1*100/cal2;
else cal1 = cal2*100/cal1;
if (cal1>=102)
{
cal_bad = TRUE;
//AfxMessageBox("Calibrare aiurea");
}
}
while (cal_bad == TRUE);
cal_factor = 0x0fffffff / cal_factor;
CFile f;
if (f.Open("unlock.dat",CFile::modeRead))
f.Close();
else
{
AfxMessageBox("'unlock.dat' file is missing !!!");
PostQuitMessage(0);
}
CString avertisment;
avertisment = "Using unregistered copy of this program - YOU WILL DAMAGE YOUR PHONE !!!";
AfxMessageBox(avertisment,MB_OK|MB_ICONWARNING);
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// 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
m_option = 0;
UpdateData(FALSE);
SetTimer(0,200,NULL);
m_text.SetWindowText("Press UNLOCK");
_asm
{
mov dx,378h;
mov al, 0ffh;
out dx,al;
}
// TODO: Add extra initialization here
BYTE* tmp = GetSerialHDD();
memcpy(serialHDD,tmp,8);
delete [] tmp;
CDialog::OnInitDialog();
return TRUE; // return TRUE unless you set the focus to a control
}
void CFlasherDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CFlasherDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CFlasherDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void Textout(CString str)
{
LPTSTR buf = str.GetBuffer(100);
if (mesaj_curent>=6) mesaj_curent=0;
if (mesaj_curent<0) mesaj_curent=0;
text[mesaj_curent]->SetWindowText(buf);
mesaj_curent++;
}
void Status()
{
StatusDecodare();
return;
switch (b_msg)
{
case 0:
{
mesaj_curent--;
Textout("Loading Boot loader ... READY !");
break;
}
case 1:
{
CString str;
UINT x = dw_flashid_68bb;
UINT alias = 0;
_asm
{
mov eax,x
xchg al,ah
ror eax,010h
xchg al,ah
mov x,eax
}
CString tipfl,floader;
BOOL f = FindFlash(nrflashuri,x,alias, tipfl,floader);
str.Format("Nu s-a gasit loader-ul pt Flashul: %X",x);
if (!f)
{
AfxMessageBox(str);
dw_flashid_68bb = 0;
break;
}
if (!OpenLoader(floader))
{
AfxMessageBox("Nu s-a gasit fisierul loader!!!");
dw_flashid_68bb=0;
break;
}
if (alias!=0)
_asm
{
mov eax,alias
xchg al,ah
ror eax,010h
xchg al,ah
mov alias,eax
mov dw_flashid_68bb, eax
}
str = tipfl;
tipfl.Format("Flash: ID: %8x (%s)",x,str);
str.Format("Flash ID: %8X",x);
Textout(tipfl);
break;
}
case 2: Textout("Loading flash loader ...");
break;
case 3:
{
mesaj_curent--;
Textout("Loading flash loader ... READY !");
break;
}
case 4: Textout("Erasing flash ...");
break;
case 5:
{
mesaj_curent--;
Textout("Erasing flash ... READY !");
break;
}
case 6: Textout("Writting DONE !");
break;
case 7:
{
CString str;
str.Format("Reading phone ... Addr %X",dw_adresa_curenta);
mesaj_curent--;
Textout(str);
break;
}
case 8: Textout("Reading DONE! ");
break;
case 9:
{
CString str;
str.Format("Writting phone ... Addr %X",dw_adresa_curenta);
mesaj_curent--;
Textout(str);
break;
}
case 10: Textout("Loading boot loader...");
break;
case 11:
{
CString ver=" ";
CString type=" ";
CString data=" ";
CString ppm=" ";
CString text;
LPTSTR verbuf = ver.GetBuffer(5);
LPTSTR typebuf = type.GetBuffer(5);
LPTSTR databuf = data.GetBuffer(8);
LPTSTR ppmbuf = ppm.GetBuffer(3);
memcpy(verbuf,verbuff+6,5);
memcpy(typebuf,verbuff+21,5);
memcpy(databuf,verbuff+12,8);
memcpy(ppmbuf,verbuff,3);
ver.ReleaseBuffer();
data.ReleaseBuffer();
type.ReleaseBuffer();
ppm.ReleaseBuffer();
GetPhoneType(type); // transforma nse in model - 51,61...
if (1)//ppm.CompareNoCase("PPM")==0)
{
UINT stadr = GetStartAddress(type,ver);
if (b_read_or_write==2)
{
adr_start_590d = stadr;
adr_end_5911 = stadr + 0x10000;
dw_adresa_curenta = adr_start_590d;
}
text.Format("Phone: %s Ver: %s Data: %s",type,ver,data);
if (b_read_or_write!=2) Textout(text);
}
else
{
ver = "Versiunea nu se poate citi!";
Textout(ver);
}
break;
}
}
}
void Eroare()
{
switch (b_error)
{
case 0:
{
if (int_rutina_timeout==0x5ec4 || int_rutina_timeout==0x5ec5) exit_decod=2;
else exit_decod = 1;
CString str;
if (exit_decod==1) str.Format("Telefonul nu raspunde ! la rutina %X",int_rutina_timeout);
else str.Format("Parametrul %X ales gresit! ",b_921b);
//if (b_read_or_write!=2) AfxMessageBox(str);
//else AfxMessageBox("Check Hardware conections !");
// AfxMessageBox(str);
break;
}
case 1:
{
exit_decod=1;
//if (b_read_or_write!=2) AfxMessageBox("Eroare TX data !");
//else AfxMessageBox("Check phone type !");
// AfxMessageBox("Check connections ! (TX data)");
break;
}
case 2: // bad loader chk
exit_decod=3;
// if (b_read_or_write!=2) AfxMessageBox("Bad loader CHK !");
break;
case 3:
exit_decod=3;
// if (b_read_or_write!=2) AfxMessageBox("Loader init Error !");
break;
case 4:
{
exit_decod=4;
CString str;
str.Format("CMD error la rutina %X",int_rutina_timeout);
// if (b_read_or_write!=2) AfxMessageBox(str);
break;
}
case 5:
{
exit_decod=4;
CString str;
str.Format("Eroare scriere flash la rutina %X",int_rutina_timeout);
// if (b_read_or_write!=2) AfxMessageBox(str);
break;
}
case 6:
{
exit_decod=4;
CString str;
str.Format("Eroare stergere flash la rutina %X",int_rutina_timeout);
// if (b_read_or_write!=2) AfxMessageBox(str);
break;
}
case 7: //AfxMessageBox("Operatie reusita !!!");
break;
case 8: //AfxMessageBox("Decodare reusita !!!");
break;
case 9: AfxMessageBox("");
break;
case 10: //AfxMessageBox("Tip telefon ales incorect !");
break;
case 11: //AfxMessageBox("Versiune nesuportata !");
break;
case 14: break;// parametru 61 / 65 ales incorect !!!
case 15: break;// parametri found and fixed in b_921b/b_921c
}
if (b_error !=7 && b_error!= 11 && exit_decod!=4)
{
for (int i=0;i<6;i++)
{
mesaj_curent = i;
// Textout("");
}
mesaj_curent = 0;
// Textout("Press UNLOCK");
mesaj_curent = 0;
}
_asm
{
mov dx,378h
mov al,0ffh
out dx, al
}
b_5826 = 0xff;
}
void Flash()
{
_asm
{
mov stivaESP, esp // salvare stiva pt restaurare
mov dx,378h; // la iesirea cu eroare !!!
mov al, 0ffh;
out dx,al;
mov eax, 3
//div cal_factor
mov ecx, cal_factor; 0c350h
shr ecx,2
init_delay:
loop init_delay
mov b_msg,10
call Status
loc_5da2:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -