📄 myindexdlg.cpp
字号:
// MyIndexDlg.cpp : implementation file
#include "stdafx.h"
#include "MyIndex.h"
#include "MyIndexDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
int nSortCol;
/////////////////////////////////////////////////////////////////////////////
// CMyIndexDlg dialog
CMyIndexDlg::CMyIndexDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMyIndexDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMyIndexDlg)
m_File = _T("");
m_Radio = 1;
m_Web = -1;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDI_ICON);
}
void CMyIndexDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMyIndexDlg)
DDX_Control(pDX, IDC_LIST, m_List);
DDX_Text(pDX, IDC_EDIT, m_File);
DDX_Radio(pDX, IDC_ByHash, m_Radio);
DDX_Radio(pDX, IDC_RADIO_Web, m_Web);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMyIndexDlg, CDialog)
//{{AFX_MSG_MAP(CMyIndexDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON_Search, OnBUTTONSearch)
ON_BN_CLICKED(IDC_BUTTON_File, OnBUTTONFile)
ON_BN_CLICKED(IDC_BUTTON_Save, OnBUTTONSave)
ON_NOTIFY(LVN_COLUMNCLICK, IDC_LIST, OnColumnclickList)
ON_NOTIFY(NM_DBLCLK, IDC_LIST, OnDblclkList)
ON_COMMAND(ID_ClipBoard, OnClipBoard)
ON_COMMAND(ID_Visit, OnVisit)
ON_COMMAND(ID_notepad, Onnotepad)
ON_NOTIFY(NM_RCLICK, IDC_LIST, OnRclickList)
ON_BN_CLICKED(IDC_RADIO_Web, OnRADIOWeb)
ON_BN_CLICKED(IDC_RADIO_History, OnRADIOHistory)
ON_BN_CLICKED(IDC_Radio_Cookies, OnRadioCookies)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyIndexDlg message handlers
BOOL CMyIndexDlg::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
//============初始化列表控件===================
m_List.InsertColumn(0,"No.",LVCFMT_LEFT,50,3);
m_List.InsertColumn(1,"类型",LVCFMT_LEFT,40,0);
m_List.InsertColumn(2,"访问时间",LVCFMT_LEFT,140,1);
m_List.InsertColumn(3,"URL",LVCFMT_LEFT,500,2);
m_List.SetTextBkColor(RGB(247,247,255));
CImageList m_imageList;
m_imageList.Create(1,10,ILC_COLOR24,1,1); //20是行高度,可调整
m_List.SetImageList(&m_imageList,LVSIL_SMALL);
m_List.DeleteAllItems(); nIndex=0;
LONG lStyle; //=====设置列表的显示方式为"详细"
lStyle = GetWindowLong(m_List.m_hWnd,GWL_STYLE);
lStyle &= ~LVS_TYPEMASK;
lStyle |= LVS_REPORT;
SetWindowLong(m_List.m_hWnd, GWL_STYLE, lStyle);
m_List.SetExtendedStyle(m_List.GetExtendedStyle()|LVS_EX_FULLROWSELECT);
m_File="E:\\index.dat"; UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
}
// 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 CMyIndexDlg::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 CMyIndexDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
//********************************************************************************************
void CMyIndexDlg::OnBUTTONSearch()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_List.DeleteAllItems();
nIndex=0;
if( m_File.IsEmpty() ) {MessageBox("Please Select a File!","Warn",MB_OK); return;}
if((fr=fopen(m_File,"rb"))==NULL)
{ str.Format("Open File [%s] Error!",m_File);
MessageBox(str,"Error",MB_OK);
return;
}
fseek(fr,0x1C,0); fread(&Flen,sizeof(char),4,fr);
fseek(fr,0x20,0); fread(&HashOffset,sizeof(char),4,fr);
UrlSum=0; nIndex=0;
if(m_Radio==0) while(HashOffset!=0) //==Check By Hash
{
fseek(fr, HashOffset+4, 0);
fread(&LenHash,sizeof(char),4,fr);
fread(&NextPos,sizeof(char),4,fr);
ReadHash(HashOffset);
HashOffset=NextPos;
}
else //================================Check All File
{
fseek(fr, HashOffset+4, 0);
fread(&LenHash,sizeof(char),4,fr);
fread(&NextPos,sizeof(char),4,fr);
fseek(fr,HashOffset+(LenHash*0x80),0);
long Len, NowPos;
NowPos=ftell(fr);
while(!feof(fr))
{
NowPos=ftell(fr);
fread(ch,4,sizeof(char),fr); ch[4]='\0';
if( ch[0]=='U' && ch[1]=='R' && ch[2]=='L' && ch[3]==' ' )
{ fread(&Len,4,sizeof(char),fr);
fseek(fr,-8,1);
NowPos=ftell(fr);
ReadURL(NowPos);
UrlSum++;
fseek(fr,NowPos+(Len*0x80),0);
continue;
}
if( ch[0]=='L' && ch[1]=='E' && ch[2]=='A' && ch[3]=='K' )
{ fread(&Len,4,sizeof(char),fr);
fseek(fr,-8,1);
NowPos=ftell(fr);
ReadLEAK(NowPos);
UrlSum++;
fseek(fr,NowPos+(Len*0x80),0);
continue;
}
if( ch[0]=='R' && ch[1]=='E' && ch[2]=='D' && ch[3]=='R' )
{ fread(&Len,4,sizeof(char),fr);
fseek(fr,-8,1);
NowPos=ftell(fr);
ReadREDR(NowPos);
UrlSum++;
fseek(fr,NowPos+(Len*0x80),0);
continue;
}
fseek(fr,12,1);
}
}
fclose(fr);
}
//******************************************************************************************
void CMyIndexDlg::OnBUTTONFile()
{
// TODO: Add your control notification handler code here
OPENFILENAME ofn;
TCHAR lpstrFilename[MAX_PATH] = ""; //设定文件的名称储存空间
ZeroMemory(&ofn, sizeof(ofn)); //清空OPENFILENAME
ofn.lStructSize = sizeof(OPENFILENAME); //lStructSize的返回值是是76
ofn.hwndOwner = this->m_hWnd; //设定父窗口
ofn.lpstrFilter = "DAT文件\0*.Dat\0所有的文件\0*.*\0"; //设定打开文件的类型
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFile=lpstrFilename;
ofn.lpstrInitialDir="C:\\";
if(GetOpenFileName(&ofn))
{ m_File=(CString)ofn.lpstrFile; m_Web=-1; UpdateData(FALSE); }
//else MessageBox("请选择文件文件!");
}
///////////////////////////////////////////////////////////////////////////////////////////
int CMyIndexDlg::ReadHash(long Pos)
{
long RecFlag, RecPos, RecDat=0, RecSum=0;
while(!feof(fr))
{ fseek(fr, Pos+16+(RecDat*8), 0);
fread(&RecFlag,sizeof(char),4,fr);
fread(&RecPos,sizeof(char),4,fr);
if(RecPos==0x03) { RecDat++; continue; }
if(RecPos==0x0badf00d) break;
if(RecFlag==1) { RecDat++; continue; }
if(RecPos!=0)
{ RecDat++;
fseek(fr,RecPos,0);
fread(ch,4,sizeof(char),fr);
if( ch[0]=='U' && ch[1]=='R' && ch[2]=='L' && ch[3]==' ' ) { ReadURL(RecPos); UrlSum++; }
else if( ch[0]=='L' && ch[1]=='E' && ch[2]=='A' && ch[3]=='K' ) { ReadLEAK(RecPos); UrlSum++; }
else if( ch[0]=='R' && ch[1]=='E' && ch[2]=='D' && ch[3]=='R' ) { ReadREDR(RecPos); UrlSum++; }
//if((RecFlag&0xf)==5) ReadREDR(RecPos);
//else ReadURL(RecPos);
RecSum++; //UrlSum++;
}
else break;
}
return(RecSum);
}
///////////////////////////////////////////////////////////////////////////////////////////
int CMyIndexDlg::ReadURL(long Pos)
{
long Length, UrlPos;
fseek(fr, Pos, 0);
fread(ch,sizeof(char),4,fr);
//在列表控件中添加记录
str.Format("%d",UrlSum+1);
nIndex=m_List.InsertItem(UrlSum,str);
m_List.SetItemText(nIndex,1,"URL");
fread(&Length,sizeof(char),4,fr);
fread(dat,sizeof(char),16,fr);
tm.dwLowDateTime = (dat[11]<<24) + (dat[10]<<16) + (dat[9]<<8) +dat[8];
tm.dwHighDateTime = (dat[15]<<24) + (dat[14]<<16) + (dat[13]<<8) +dat[12];
if(tm.dwHighDateTime!=0)
{ FileTimeToDosDateTime(&tm, &dosdate, &dostime);
str.Format("%4d.%02d.%02d-%02d:%02d:%02d ",((dosdate>>9)&0x7f)+1980, (dosdate>>5)&0xf, dosdate&0x1f,
(dostime>>11)&0x1f, (dostime>>5)&0x3f, dostime&0x1f);
}
else str.Format("Not Available");
m_List.SetItemText(nIndex,2,str);
fseek(fr,Pos+0x34,0);
fread(&UrlPos,sizeof(char),4,fr);
fseek(fr,Pos+0x38,0);
fread(dat,sizeof(char),1,fr);
if( (UrlPos==0xbadf00d)||(UrlPos==0) ) {UrlPos=0x68;}
fseek(fr,Pos+UrlPos,0);
for(i=0;;i++)
{ VisitedUrl[i]=fgetc(fr);
if(VisitedUrl[i]==0) break;
}
m_List.SetItemText(nIndex,3,VisitedUrl);
fseek(fr,Pos+Length,0);
return(0);
}
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
int CMyIndexDlg::ReadLEAK(long Pos)
{
long Length, UrlPos;
fseek(fr, Pos, 0);
fread(ch,sizeof(char),4,fr);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -