diff --git a/Ext2Mgr/DelDeadLetter.cpp b/Ext2Mgr/DelDeadLetter.cpp index d89d91c..6e3666e 100644 --- a/Ext2Mgr/DelDeadLetter.cpp +++ b/Ext2Mgr/DelDeadLetter.cpp @@ -1,168 +1,168 @@ -// DelDeadLetter.cpp : implementation file -// - -#include "stdafx.h" -#include "ext2mgr.h" -#include "DelDeadLetter.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CDelDeadLetter dialog - - -CDelDeadLetter::CDelDeadLetter(CWnd* pParent /*=NULL*/) - : CDialog(CDelDeadLetter::IDD, pParent) -{ - //{{AFX_DATA_INIT(CDelDeadLetter) - m_sDrvLetter = _T(""); - m_bAutoRemoval = g_bAutoRemoveDeadLetters; - m_bKeepIt = TRUE; - //}}AFX_DATA_INIT -} - - -void CDelDeadLetter::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CDelDeadLetter) - DDX_CBString(pDX, IDC_DEAD_LETTER_LIST, m_sDrvLetter); - DDX_Check(pDX, IDC_AUTO_REMOVAL, m_bAutoRemoval); - DDX_Check(pDX, IDC_REMOVAL_CURRENT, m_bKeepIt); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CDelDeadLetter, CDialog) - //{{AFX_MSG_MAP(CDelDeadLetter) - ON_BN_CLICKED(ID_RELOAD_DL, OnReloadDl) - ON_BN_CLICKED(IDC_AUTO_REMOVAL, OnAutoRemoval) - ON_BN_CLICKED(IDC_AUTOREMOVALTEXT, OnAutoremovaltext) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CDelDeadLetter message handlers - -void CDelDeadLetter::OnOK() -{ - CHAR drvChar; - PEXT2_LETTER drvLetter = NULL; - UpdateData(TRUE); - - drvChar = m_sDrvLetter.GetAt(0); - - if ((drvChar >= '0') && (drvChar <= '9')) { - drvLetter = &drvDigits[drvChar - '0']; - } - - if ((drvChar >= 'A') && (drvChar <= 'Z')) { - drvLetter = &drvLetters[drvChar - 'A']; - } - - if (drvLetter) { - if (AfxMessageBox("Warning: the driver letter might be still used. Are you\r\n" - " sure that make it's a real dead driver letter ?", MB_YESNO) == IDYES) { - - Ext2RemoveMountPoint(drvLetter, !m_bKeepIt); - Ext2RemoveDosSymLink(drvLetter->Letter); - UpdateDeadLetterList(); - } - } -} - -BOOL CDelDeadLetter::OnInitDialog() -{ - CDialog::OnInitDialog(); - - UpdateDeadLetterList(); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -VOID -CDelDeadLetter::UpdateDeadLetterList() -{ - ULONGLONG LetterMask = -1; - DWORD i, j; - PEXT2_VOLUME volume; - PEXT2_DISK disk; - PEXT2_PARTITION part; - PEXT2_CDROM cdrom; - CString str; - - CComboBox *cbList = (CComboBox *)GetDlgItem(IDC_DEAD_LETTER_LIST); - - cbList->ResetContent(); - - for (volume = gVols; volume != NULL; volume = volume->Next) { - LetterMask &= ~(volume->DrvLetters); - } - - for (i = 0; i < g_nDisks; i++) { - disk = &gDisks[i]; - if (disk->DataParts == NULL) { - continue; - } - for (j=0; j < disk->NumParts; j++) { - part = &disk->DataParts[j]; - if (part) { - LetterMask &= ~(part->DrvLetters); - } - } - } - - for (i = 0; i < g_nCdroms; i++) { - cdrom = &gCdroms[i]; - LetterMask &= ~(cdrom->DrvLetters); - } - - for (i=0; i < 10; i++) { - if (drvDigits[i].bUsed && (drvDigits[i].Extent == NULL) && - (LetterMask & (((ULONGLONG) 1) << (i + 32)) ) ) { - str.Format("%c: ", drvDigits[i].Letter); - str += drvDigits[i].SymLink; - cbList->AddString(str); - } - } - - for (i=0; i <26; i++) { - if (drvLetters[i].bUsed && (drvLetters[i].Extent == NULL) && - (LetterMask & (((ULONGLONG) 1) << i)) ) { - str.Format("%c: ", drvLetters[i].Letter); - str += drvLetters[i].SymLink; - cbList->AddString(str); - } - } - -#if 0 - if (cbList->GetCount() == 0) { - AfxMessageBox("No dead driver letters exist :)", MB_OK|MB_ICONINFORMATION); - EndDialog(TRUE); - } -#endif - - cbList->SetCurSel(0); -} - -void CDelDeadLetter::OnReloadDl() -{ - // TODO: Add your control notification handler code here - UpdateDeadLetterList(); -} - -void CDelDeadLetter::OnAutoRemoval() -{ - // TODO: Add your control notification handler code here - UpdateData(TRUE); - g_bAutoRemoveDeadLetters = m_bAutoRemoval; -} - -void CDelDeadLetter::OnAutoremovaltext() -{ -} +// DelDeadLetter.cpp : implementation file +// + +#include "stdafx.h" +#include "ext2mgr.h" +#include "DelDeadLetter.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CDelDeadLetter dialog + + +CDelDeadLetter::CDelDeadLetter(CWnd* pParent /*=NULL*/) + : CDialog(CDelDeadLetter::IDD, pParent) +{ + //{{AFX_DATA_INIT(CDelDeadLetter) + m_sDrvLetter = _T(""); + m_bAutoRemoval = g_bAutoRemoveDeadLetters; + m_bKeepIt = TRUE; + //}}AFX_DATA_INIT +} + + +void CDelDeadLetter::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CDelDeadLetter) + DDX_CBString(pDX, IDC_DEAD_LETTER_LIST, m_sDrvLetter); + DDX_Check(pDX, IDC_AUTO_REMOVAL, m_bAutoRemoval); + DDX_Check(pDX, IDC_REMOVAL_CURRENT, m_bKeepIt); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CDelDeadLetter, CDialog) + //{{AFX_MSG_MAP(CDelDeadLetter) + ON_BN_CLICKED(ID_RELOAD_DL, OnReloadDl) + ON_BN_CLICKED(IDC_AUTO_REMOVAL, OnAutoRemoval) + ON_BN_CLICKED(IDC_AUTOREMOVALTEXT, OnAutoremovaltext) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CDelDeadLetter message handlers + +void CDelDeadLetter::OnOK() +{ + CHAR drvChar; + PEXT2_LETTER drvLetter = NULL; + UpdateData(TRUE); + + drvChar = m_sDrvLetter.GetAt(0); + + if ((drvChar >= '0') && (drvChar <= '9')) { + drvLetter = &drvDigits[drvChar - '0']; + } + + if ((drvChar >= 'A') && (drvChar <= 'Z')) { + drvLetter = &drvLetters[drvChar - 'A']; + } + + if (drvLetter) { + if (AfxMessageBox("Warning: the driver letter might be still used. Are you\r\n" + " sure that make it's a real dead driver letter ?", MB_YESNO) == IDYES) { + + Ext2RemoveMountPoint(drvLetter, !m_bKeepIt); + Ext2RemoveDosSymLink(drvLetter->Letter); + UpdateDeadLetterList(); + } + } +} + +BOOL CDelDeadLetter::OnInitDialog() +{ + CDialog::OnInitDialog(); + + UpdateDeadLetterList(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +VOID +CDelDeadLetter::UpdateDeadLetterList() +{ + ULONGLONG LetterMask = -1; + DWORD i, j; + PEXT2_VOLUME volume; + PEXT2_DISK disk; + PEXT2_PARTITION part; + PEXT2_CDROM cdrom; + CString str; + + CComboBox *cbList = (CComboBox *)GetDlgItem(IDC_DEAD_LETTER_LIST); + + cbList->ResetContent(); + + for (volume = gVols; volume != NULL; volume = volume->Next) { + LetterMask &= ~(volume->DrvLetters); + } + + for (i = 0; i < g_nDisks; i++) { + disk = &gDisks[i]; + if (disk->DataParts == NULL) { + continue; + } + for (j=0; j < disk->NumParts; j++) { + part = &disk->DataParts[j]; + if (part) { + LetterMask &= ~(part->DrvLetters); + } + } + } + + for (i = 0; i < g_nCdroms; i++) { + cdrom = &gCdroms[i]; + LetterMask &= ~(cdrom->DrvLetters); + } + + for (i=0; i < 10; i++) { + if (drvDigits[i].bUsed && (drvDigits[i].Extent == NULL) && + (LetterMask & (((ULONGLONG) 1) << (i + 32)) ) ) { + str.Format("%c: ", drvDigits[i].Letter); + str += drvDigits[i].SymLink; + cbList->AddString(str); + } + } + + for (i=0; i <26; i++) { + if (drvLetters[i].bUsed && (drvLetters[i].Extent == NULL) && + (LetterMask & (((ULONGLONG) 1) << i)) ) { + str.Format("%c: ", drvLetters[i].Letter); + str += drvLetters[i].SymLink; + cbList->AddString(str); + } + } + +#if 0 + if (cbList->GetCount() == 0) { + AfxMessageBox("No dead driver letters exist :)", MB_OK|MB_ICONINFORMATION); + EndDialog(TRUE); + } +#endif + + cbList->SetCurSel(0); +} + +void CDelDeadLetter::OnReloadDl() +{ + // TODO: Add your control notification handler code here + UpdateDeadLetterList(); +} + +void CDelDeadLetter::OnAutoRemoval() +{ + // TODO: Add your control notification handler code here + UpdateData(TRUE); + g_bAutoRemoveDeadLetters = m_bAutoRemoval; +} + +void CDelDeadLetter::OnAutoremovaltext() +{ +} diff --git a/Ext2Mgr/DelDeadLetter.h b/Ext2Mgr/DelDeadLetter.h index 3007568..648ffa8 100644 --- a/Ext2Mgr/DelDeadLetter.h +++ b/Ext2Mgr/DelDeadLetter.h @@ -1,54 +1,54 @@ -#if !defined(AFX_DELDEADLETTER_H__289C3418_93AB_43C7_9E64_60C382CCF93B__INCLUDED_) -#define AFX_DELDEADLETTER_H__289C3418_93AB_43C7_9E64_60C382CCF93B__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// DelDeadLetter.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// CDelDeadLetter dialog - -class CDelDeadLetter : public CDialog -{ -// Construction -public: - CDelDeadLetter(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CDelDeadLetter) - enum { IDD = IDD_REMOVE_DEADLETTER }; - CString m_sDrvLetter; - BOOL m_bAutoRemoval; - BOOL m_bKeepIt; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CDelDeadLetter) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - - VOID UpdateDeadLetterList(); - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CDelDeadLetter) - virtual void OnOK(); - virtual BOOL OnInitDialog(); - afx_msg void OnReloadDl(); - afx_msg void OnAutoRemoval(); - afx_msg void OnAutoremovaltext(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_DELDEADLETTER_H__289C3418_93AB_43C7_9E64_60C382CCF93B__INCLUDED_) +#if !defined(AFX_DELDEADLETTER_H__289C3418_93AB_43C7_9E64_60C382CCF93B__INCLUDED_) +#define AFX_DELDEADLETTER_H__289C3418_93AB_43C7_9E64_60C382CCF93B__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// DelDeadLetter.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CDelDeadLetter dialog + +class CDelDeadLetter : public CDialog +{ +// Construction +public: + CDelDeadLetter(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CDelDeadLetter) + enum { IDD = IDD_REMOVE_DEADLETTER }; + CString m_sDrvLetter; + BOOL m_bAutoRemoval; + BOOL m_bKeepIt; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CDelDeadLetter) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + VOID UpdateDeadLetterList(); + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CDelDeadLetter) + virtual void OnOK(); + virtual BOOL OnInitDialog(); + afx_msg void OnReloadDl(); + afx_msg void OnAutoRemoval(); + afx_msg void OnAutoremovaltext(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_DELDEADLETTER_H__289C3418_93AB_43C7_9E64_60C382CCF93B__INCLUDED_) diff --git a/Ext2Mgr/DiskBox.cpp b/Ext2Mgr/DiskBox.cpp index 2648b61..9a6f636 100644 --- a/Ext2Mgr/DiskBox.cpp +++ b/Ext2Mgr/DiskBox.cpp @@ -1,136 +1,136 @@ -// DiskBox.cpp : implementation file -// - -#include "stdafx.h" -#include "DiskBox.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CDiskBox - -CDiskBox::CDiskBox() -{ - m_nID = IDC_PROPERTY_DEVICE; - m_nLeft = 10; - m_nSize = 80; -} - -CDiskBox::~CDiskBox() -{ -} - -BEGIN_MESSAGE_MAP(CDiskBox, CButton) - //{{AFX_MSG_MAP(CDiskBox) - ON_WM_SETFOCUS() - ON_CBN_SELCHANGE(IDC_PROPERTY_DEVICE, OnSelectChanged) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CDiskBox message handlers - -void CDiskBox::OnSelectChanged() -{ - GetParent()->SendMessage(WM_GROUP_BOX_UPDATED, 'GB', 'DVLU'); -} - -void CDiskBox::PreSubclassWindow() -{ - // - // Make sure that this control has the BS_ICON style set. - // If not, it behaves very strangely: - // It erases itself if the user TABs to controls in the dialog, - // unless the user first clicks it. Very strange!! - // - - ModifyStyle(0, BS_ICON|WS_TABSTOP|WS_GROUP); - - CString strTitle; - GetWindowText(strTitle); - - int nWidth = AssemblingTitle(); - - CRect r; - GetWindowRect(&r); - ScreenToClient(r); - - r.OffsetRect(m_nLeft, 0); - r.bottom = r.top + m_nSize; - r.right = r.left + m_nSize + nWidth; - - m_ComboBox.Create(WS_CHILD | CBS_DROPDOWN | WS_VSCROLL | - CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST, - r, this, m_nID); - m_ComboBox.SetFont(GetFont(), true); - m_ComboBox.ShowWindow(SW_SHOW); - - SetListboxHeight(m_ComboBox.m_hWnd); -} - -void CDiskBox::SetListboxHeight(HWND hWnd) -{ - RECT rc; - - ::SendMessage(hWnd, LB_GETITEMRECT, 0, (LPARAM)&rc); - ::GetClientRect(hWnd, &rc); - int cyClient= rc.bottom - rc.top; - - ::GetWindowRect(hWnd, &rc); - int cxListbox = rc.right - rc.left; - int cyListbox = rc.bottom - rc.top; - - if (g_nDisks + g_nCdroms > 8) { - cyListbox = 18*8; - } else if (g_nDisks + g_nCdroms > 4) { - cyListbox = max(80, 18 * (g_nDisks + g_nCdroms)); - } else { - cyListbox = 80; - } - ::SetWindowPos(hWnd, NULL, 0, 0, - cxListbox, cyListbox, - SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCOPYBITS| - SWP_NOOWNERZORDER|SWP_NOZORDER - ); -} - -int CDiskBox::AssemblingTitle() -{ - // - // The group box title needs to be erased, but I need to keep - // the border away from the check box text. I create a string - // of spaces (' ') that is the same length as the title was - // plus the size of the checkbox. plus a little more. - // - - CString strOldTitle, strNewTitle; - GetWindowText(strOldTitle); - - CClientDC dc(this); - CFont* pOldFont = dc.SelectObject(GetFont()); - - CSize czText = dc.GetTextExtent(strOldTitle); - int nRet = czText.cx; - int nTarget = czText.cx + m_nSize; - - while(czText.cx < nTarget) - { - strNewTitle.Insert(0, ' '); - czText = dc.GetTextExtent(strNewTitle); - } - - dc.SelectObject(pOldFont); - - SetWindowText(strNewTitle); - return nRet; -} - -void CDiskBox::OnSetFocus(CWnd* pOldWnd) -{ - CButton::OnSetFocus(pOldWnd); - m_ComboBox.SetFocus(); -} +// DiskBox.cpp : implementation file +// + +#include "stdafx.h" +#include "DiskBox.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CDiskBox + +CDiskBox::CDiskBox() +{ + m_nID = IDC_PROPERTY_DEVICE; + m_nLeft = 10; + m_nSize = 80; +} + +CDiskBox::~CDiskBox() +{ +} + +BEGIN_MESSAGE_MAP(CDiskBox, CButton) + //{{AFX_MSG_MAP(CDiskBox) + ON_WM_SETFOCUS() + ON_CBN_SELCHANGE(IDC_PROPERTY_DEVICE, OnSelectChanged) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CDiskBox message handlers + +void CDiskBox::OnSelectChanged() +{ + GetParent()->SendMessage(WM_GROUP_BOX_UPDATED, 'GB', 'DVLU'); +} + +void CDiskBox::PreSubclassWindow() +{ + // + // Make sure that this control has the BS_ICON style set. + // If not, it behaves very strangely: + // It erases itself if the user TABs to controls in the dialog, + // unless the user first clicks it. Very strange!! + // + + ModifyStyle(0, BS_ICON|WS_TABSTOP|WS_GROUP); + + CString strTitle; + GetWindowText(strTitle); + + int nWidth = AssemblingTitle(); + + CRect r; + GetWindowRect(&r); + ScreenToClient(r); + + r.OffsetRect(m_nLeft, 0); + r.bottom = r.top + m_nSize; + r.right = r.left + m_nSize + nWidth; + + m_ComboBox.Create(WS_CHILD | CBS_DROPDOWN | WS_VSCROLL | + CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST, + r, this, m_nID); + m_ComboBox.SetFont(GetFont(), true); + m_ComboBox.ShowWindow(SW_SHOW); + + SetListboxHeight(m_ComboBox.m_hWnd); +} + +void CDiskBox::SetListboxHeight(HWND hWnd) +{ + RECT rc; + + ::SendMessage(hWnd, LB_GETITEMRECT, 0, (LPARAM)&rc); + ::GetClientRect(hWnd, &rc); + int cyClient= rc.bottom - rc.top; + + ::GetWindowRect(hWnd, &rc); + int cxListbox = rc.right - rc.left; + int cyListbox = rc.bottom - rc.top; + + if (g_nDisks + g_nCdroms > 8) { + cyListbox = 18*8; + } else if (g_nDisks + g_nCdroms > 4) { + cyListbox = max(80, 18 * (g_nDisks + g_nCdroms)); + } else { + cyListbox = 80; + } + ::SetWindowPos(hWnd, NULL, 0, 0, + cxListbox, cyListbox, + SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCOPYBITS| + SWP_NOOWNERZORDER|SWP_NOZORDER + ); +} + +int CDiskBox::AssemblingTitle() +{ + // + // The group box title needs to be erased, but I need to keep + // the border away from the check box text. I create a string + // of spaces (' ') that is the same length as the title was + // plus the size of the checkbox. plus a little more. + // + + CString strOldTitle, strNewTitle; + GetWindowText(strOldTitle); + + CClientDC dc(this); + CFont* pOldFont = dc.SelectObject(GetFont()); + + CSize czText = dc.GetTextExtent(strOldTitle); + int nRet = czText.cx; + int nTarget = czText.cx + m_nSize; + + while(czText.cx < nTarget) + { + strNewTitle.Insert(0, ' '); + czText = dc.GetTextExtent(strNewTitle); + } + + dc.SelectObject(pOldFont); + + SetWindowText(strNewTitle); + return nRet; +} + +void CDiskBox::OnSetFocus(CWnd* pOldWnd) +{ + CButton::OnSetFocus(pOldWnd); + m_ComboBox.SetFocus(); +} diff --git a/Ext2Mgr/DiskBox.h b/Ext2Mgr/DiskBox.h index 48c6006..bda3b8a 100644 --- a/Ext2Mgr/DiskBox.h +++ b/Ext2Mgr/DiskBox.h @@ -1,60 +1,60 @@ -#if !defined(AFX_DISK_BOX_H_) -#define AFX_DISK_BOX_H_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// DiskBox.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// CDiskBox window - -class CDiskBox : public CButton -{ -// Construction -public: - CDiskBox(); - -// Operations -public: - void SetListboxHeight(HWND); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CDiskBox) - protected: - virtual void PreSubclassWindow(); - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~CDiskBox(); - - // Generated message map functions -protected: - //{{AFX_MSG(CDiskBox) - afx_msg void OnSetFocus(CWnd* pOldWnd); - afx_msg void OnSelectChanged(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -public: - - int m_nID; - int m_nLeft; - int m_nSize; - - CComboBox m_ComboBox; - -private: - - int AssemblingTitle(); -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif +#if !defined(AFX_DISK_BOX_H_) +#define AFX_DISK_BOX_H_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// DiskBox.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CDiskBox window + +class CDiskBox : public CButton +{ +// Construction +public: + CDiskBox(); + +// Operations +public: + void SetListboxHeight(HWND); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CDiskBox) + protected: + virtual void PreSubclassWindow(); + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CDiskBox(); + + // Generated message map functions +protected: + //{{AFX_MSG(CDiskBox) + afx_msg void OnSetFocus(CWnd* pOldWnd); + afx_msg void OnSelectChanged(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + +public: + + int m_nID; + int m_nLeft; + int m_nSize; + + CComboBox m_ComboBox; + +private: + + int AssemblingTitle(); +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif diff --git a/Ext2Mgr/DlgView.cpp b/Ext2Mgr/DlgView.cpp index ee36920..a7df114 100644 --- a/Ext2Mgr/DlgView.cpp +++ b/Ext2Mgr/DlgView.cpp @@ -1,78 +1,78 @@ -// DlgView.cpp : implementation file -// - -#include "stdafx.h" -#include "DlgView.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CDlgView - -IMPLEMENT_DYNCREATE(CDlgView, CScrollView) - -CDlgView::CDlgView() -{ -} - -CDlgView::~CDlgView() -{ -} - - -BEGIN_MESSAGE_MAP(CDlgView, CScrollView) - //{{AFX_MSG_MAP(CDlgView) - // NOTE - the ClassWizard will add and remove mapping macros here. - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CDlgView drawing - -void CDlgView::OnDraw(CDC* pDC) -{ - CRect rectClient; - CSize size = GetTotalSize(); - - rectClient.left = 0; - rectClient.top = 0; - rectClient.bottom = size.cy; - rectClient.right = size.cx; - - rectClient.DeflateRect(15, 15); - pDC->DrawText(m_csText, rectClient, DT_LEFT); - - rectClient.InflateRect(5, 5); - pDC->Draw3dRect(rectClient, RGB(0, 0, 255), RGB(0, 0, 255)); - -} - -///////////////////////////////////////////////////////////////////////////// -// CDlgView diagnostics - -#ifdef _DEBUG -void CDlgView::AssertValid() const -{ - CScrollView::AssertValid(); -} - -void CDlgView::Dump(CDumpContext& dc) const -{ - CScrollView::Dump(dc); -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CDlgView message handlers - -void CDlgView::OnInitialUpdate() -{ - CScrollView::OnInitialUpdate(); - - // TODO: Add your specialized code here and/or call the base class - -} +// DlgView.cpp : implementation file +// + +#include "stdafx.h" +#include "DlgView.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CDlgView + +IMPLEMENT_DYNCREATE(CDlgView, CScrollView) + +CDlgView::CDlgView() +{ +} + +CDlgView::~CDlgView() +{ +} + + +BEGIN_MESSAGE_MAP(CDlgView, CScrollView) + //{{AFX_MSG_MAP(CDlgView) + // NOTE - the ClassWizard will add and remove mapping macros here. + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CDlgView drawing + +void CDlgView::OnDraw(CDC* pDC) +{ + CRect rectClient; + CSize size = GetTotalSize(); + + rectClient.left = 0; + rectClient.top = 0; + rectClient.bottom = size.cy; + rectClient.right = size.cx; + + rectClient.DeflateRect(15, 15); + pDC->DrawText(m_csText, rectClient, DT_LEFT); + + rectClient.InflateRect(5, 5); + pDC->Draw3dRect(rectClient, RGB(0, 0, 255), RGB(0, 0, 255)); + +} + +///////////////////////////////////////////////////////////////////////////// +// CDlgView diagnostics + +#ifdef _DEBUG +void CDlgView::AssertValid() const +{ + CScrollView::AssertValid(); +} + +void CDlgView::Dump(CDumpContext& dc) const +{ + CScrollView::Dump(dc); +} +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// CDlgView message handlers + +void CDlgView::OnInitialUpdate() +{ + CScrollView::OnInitialUpdate(); + + // TODO: Add your specialized code here and/or call the base class + +} diff --git a/Ext2Mgr/DlgView.h b/Ext2Mgr/DlgView.h index c715d39..fea8b1b 100644 --- a/Ext2Mgr/DlgView.h +++ b/Ext2Mgr/DlgView.h @@ -1,55 +1,55 @@ -#if !defined(AFX_DLGVIEW1_H__5E7226FD_BC8E_4B9C_9769_80E378804A93__INCLUDED_) -#define AFX_DLGVIEW1_H__5E7226FD_BC8E_4B9C_9769_80E378804A93__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// DlgView.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// CDlgView view - -class CDlgView : public CScrollView -{ -protected: - CDlgView(); // protected constructor used by dynamic creation - DECLARE_DYNCREATE(CDlgView) - -// Attributes -public: - -// Operations -public: - CString m_csText; -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CDlgView) - public: - virtual void OnInitialUpdate(); - protected: - virtual void OnDraw(CDC* pDC); // overridden to draw this view - //}}AFX_VIRTUAL - -// Implementation -protected: - virtual ~CDlgView(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - - // Generated message map functions -protected: - //{{AFX_MSG(CDlgView) - // NOTE - the ClassWizard will add and remove member functions here. - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_DLGVIEW1_H__5E7226FD_BC8E_4B9C_9769_80E378804A93__INCLUDED_) +#if !defined(AFX_DLGVIEW1_H__5E7226FD_BC8E_4B9C_9769_80E378804A93__INCLUDED_) +#define AFX_DLGVIEW1_H__5E7226FD_BC8E_4B9C_9769_80E378804A93__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// DlgView.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CDlgView view + +class CDlgView : public CScrollView +{ +protected: + CDlgView(); // protected constructor used by dynamic creation + DECLARE_DYNCREATE(CDlgView) + +// Attributes +public: + +// Operations +public: + CString m_csText; +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CDlgView) + public: + virtual void OnInitialUpdate(); + protected: + virtual void OnDraw(CDC* pDC); // overridden to draw this view + //}}AFX_VIRTUAL + +// Implementation +protected: + virtual ~CDlgView(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + + // Generated message map functions +protected: + //{{AFX_MSG(CDlgView) + // NOTE - the ClassWizard will add and remove member functions here. + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_DLGVIEW1_H__5E7226FD_BC8E_4B9C_9769_80E378804A93__INCLUDED_) diff --git a/Ext2Mgr/Donate.cpp b/Ext2Mgr/Donate.cpp index 477d24f..c344c37 100644 --- a/Ext2Mgr/Donate.cpp +++ b/Ext2Mgr/Donate.cpp @@ -1,95 +1,95 @@ -// Donate.cpp : implementation file -// - -#include "stdafx.h" -#include "ext2mgr.h" -#include "Donate.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CDonate dialog - - -CDonate::CDonate(CWnd* pParent /*=NULL*/) - : CDialog(CDonate::IDD, pParent) -{ - //{{AFX_DATA_INIT(CDonate) - //}}AFX_DATA_INIT -} - - -void CDonate::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CDonate) - DDX_Control(pDX, IDC_VIA_SOURCEFORGE, m_SF); - DDX_Control(pDX, IDC_VIA_PAYPAL, m_Paypal); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CDonate, CDialog) - //{{AFX_MSG_MAP(CDonate) - ON_WM_KEYDOWN() - ON_WM_KILLFOCUS() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CDonate message handlers - -BOOL CDonate::OnInitDialog() -{ - CDialog::OnInitDialog(); - - //Set the target URL - m_SF.SetLinkUrl("http://sourceforge.net/project/project_donations.php?group_id=43775"); - //Enable showing the Tooltip - m_SF.ActiveToolTip(TRUE); - //Set the Tooltiptext - m_SF.SetTootTipText("Donate to Ext2Fsd group via SourceForge."); - - - //Set the target URL - m_Paypal.SetLinkUrl("https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=m@ext2fsd.com&item_name=Donation&return=https://sourceforge.net/projects/ext2fsd"); - //Enable showing the Tooltip - m_Paypal.ActiveToolTip(TRUE); - //Set the Tooltiptext - m_Paypal.SetTootTipText("Donate to Ext2Fsd group via Paypal."); - -#if 0 - CHAR Declaration [] = - "\r\nExt2Fsd is an open source software. It acts as a bridge between Windows and Linux, making life easier to access Linux partitions under Windows systems.\r\n" - "\r\nCurrently there are still lots of jobs left to make a fully functional file system driver, such as complete ext3 support, Linux LVM, Windows Vista, Longhorn. Especially Vista and Longhorn will need driver signing.\r\n" - "\r\nNow I'm the only part-time developer. It needs about two full time developers to implement that job and also it needs some hardwares such SMP system, SCSI array for debugging and testing.\r\n" - "\r\nI'll try my best to make it out. I'm dreaming of that day.\r\n" - "\r\nAny help will be highly appreciated. Thanks and best wishes.\r\n" - "\r\n\r\nYours sincerely,\r\n" - "Matt"; -#endif - - CString Declaration; - Declaration.LoadString(IDS_DONATE_DECLARE); - - GetDlgItem(IDC_DECLARE)->SetWindowText(Declaration); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void CDonate::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) -{ - // TODO: Add your message handler code here and/or call default - CDialog::OnKeyDown(nChar, nRepCnt, nFlags); -} - -void CDonate::OnKillFocus(CWnd* pNewWnd) -{ - CDialog::OnKillFocus(pNewWnd); - -} +// Donate.cpp : implementation file +// + +#include "stdafx.h" +#include "ext2mgr.h" +#include "Donate.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CDonate dialog + + +CDonate::CDonate(CWnd* pParent /*=NULL*/) + : CDialog(CDonate::IDD, pParent) +{ + //{{AFX_DATA_INIT(CDonate) + //}}AFX_DATA_INIT +} + + +void CDonate::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CDonate) + DDX_Control(pDX, IDC_VIA_SOURCEFORGE, m_SF); + DDX_Control(pDX, IDC_VIA_PAYPAL, m_Paypal); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CDonate, CDialog) + //{{AFX_MSG_MAP(CDonate) + ON_WM_KEYDOWN() + ON_WM_KILLFOCUS() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CDonate message handlers + +BOOL CDonate::OnInitDialog() +{ + CDialog::OnInitDialog(); + + //Set the target URL + m_SF.SetLinkUrl("http://sourceforge.net/project/project_donations.php?group_id=43775"); + //Enable showing the Tooltip + m_SF.ActiveToolTip(TRUE); + //Set the Tooltiptext + m_SF.SetTootTipText("Donate to Ext2Fsd group via SourceForge."); + + + //Set the target URL + m_Paypal.SetLinkUrl("https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=m@ext2fsd.com&item_name=Donation&return=https://sourceforge.net/projects/ext2fsd"); + //Enable showing the Tooltip + m_Paypal.ActiveToolTip(TRUE); + //Set the Tooltiptext + m_Paypal.SetTootTipText("Donate to Ext2Fsd group via Paypal."); + +#if 0 + CHAR Declaration [] = + "\r\nExt2Fsd is an open source software. It acts as a bridge between Windows and Linux, making life easier to access Linux partitions under Windows systems.\r\n" + "\r\nCurrently there are still lots of jobs left to make a fully functional file system driver, such as complete ext3 support, Linux LVM, Windows Vista, Longhorn. Especially Vista and Longhorn will need driver signing.\r\n" + "\r\nNow I'm the only part-time developer. It needs about two full time developers to implement that job and also it needs some hardwares such SMP system, SCSI array for debugging and testing.\r\n" + "\r\nI'll try my best to make it out. I'm dreaming of that day.\r\n" + "\r\nAny help will be highly appreciated. Thanks and best wishes.\r\n" + "\r\n\r\nYours sincerely,\r\n" + "Matt"; +#endif + + CString Declaration; + Declaration.LoadString(IDS_DONATE_DECLARE); + + GetDlgItem(IDC_DECLARE)->SetWindowText(Declaration); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void CDonate::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) +{ + // TODO: Add your message handler code here and/or call default + CDialog::OnKeyDown(nChar, nRepCnt, nFlags); +} + +void CDonate::OnKillFocus(CWnd* pNewWnd) +{ + CDialog::OnKillFocus(pNewWnd); + +} diff --git a/Ext2Mgr/Donate.h b/Ext2Mgr/Donate.h index 46606bb..29c1bc9 100644 --- a/Ext2Mgr/Donate.h +++ b/Ext2Mgr/Donate.h @@ -1,50 +1,50 @@ -#if !defined(AFX_DONATE_H__40066CB2_EB28_4B9A_B51A_6CF889E4D5CB__INCLUDED_) -#define AFX_DONATE_H__40066CB2_EB28_4B9A_B51A_6CF889E4D5CB__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// Donate.h : header file -// -#include "HyperLink.h" - -///////////////////////////////////////////////////////////////////////////// -// CDonate dialog - -class CDonate : public CDialog -{ -// Construction -public: - CDonate(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CDonate) - enum { IDD = IDD_DONATE_DIALOG }; - CMyHyperLink m_SF; - CMyHyperLink m_Paypal; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CDonate) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CDonate) - virtual BOOL OnInitDialog(); - afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); - afx_msg void OnKillFocus(CWnd* pNewWnd); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_DONATE_H__40066CB2_EB28_4B9A_B51A_6CF889E4D5CB__INCLUDED_) +#if !defined(AFX_DONATE_H__40066CB2_EB28_4B9A_B51A_6CF889E4D5CB__INCLUDED_) +#define AFX_DONATE_H__40066CB2_EB28_4B9A_B51A_6CF889E4D5CB__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// Donate.h : header file +// +#include "HyperLink.h" + +///////////////////////////////////////////////////////////////////////////// +// CDonate dialog + +class CDonate : public CDialog +{ +// Construction +public: + CDonate(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CDonate) + enum { IDD = IDD_DONATE_DIALOG }; + CMyHyperLink m_SF; + CMyHyperLink m_Paypal; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CDonate) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CDonate) + virtual BOOL OnInitDialog(); + afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); + afx_msg void OnKillFocus(CWnd* pNewWnd); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_DONATE_H__40066CB2_EB28_4B9A_B51A_6CF889E4D5CB__INCLUDED_) diff --git a/Ext2Mgr/Ext2Attribute.cpp b/Ext2Mgr/Ext2Attribute.cpp index 6a0904f..8c580aa 100644 --- a/Ext2Mgr/Ext2Attribute.cpp +++ b/Ext2Mgr/Ext2Attribute.cpp @@ -1,447 +1,447 @@ -// Ext2Attribute.cpp : implementation file -// - -#include "stdafx.h" -#include "ext2mgr.h" -#include "Ext2Attribute.h" -#include "Ext2MgrDlg.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CExt2Attribute dialog - - -CExt2Attribute::CExt2Attribute(CWnd* pParent /*=NULL*/) - : CDialog(CExt2Attribute::IDD, pParent) -{ - //{{AFX_DATA_INIT(CExt2Attribute) - m_Codepage = _T(""); - m_bReadonly = FALSE; - m_FixedLetter = _T(""); - m_AutoLetter = _T(""); - m_sPrefix = _T(""); - m_sSuffix = _T(""); - m_bAutoMount = FALSE; - m_bFixMount = FALSE; - m_autoDrv = 0; - m_sUID = _T("----"); - m_sGID = _T("----"); - m_sEUID = _T("----"); - //}}AFX_DATA_INIT - - m_MainDlg = NULL; - m_EVP = NULL; - m_DevName = _T(""); - m_bCdrom = FALSE; - m_fixDrv = 0; -} - - -void CExt2Attribute::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CExt2Attribute) - DDX_CBString(pDX, IDC_COMBO_CODEPAGE, m_Codepage); - DDX_Check(pDX, IDC_READ_ONLY, m_bReadonly); - DDX_CBString(pDX, IDC_COMBO_DRVLETTER, m_FixedLetter); - DDX_Text(pDX, IDC_EXT2_PREFIX, m_sPrefix); - DDV_MaxChars(pDX, m_sPrefix, 31); - DDX_Text(pDX, IDC_EXT2_SUFFIX, m_sSuffix); - DDV_MaxChars(pDX, m_sSuffix, 31); - DDX_Check(pDX, IDC_AUTOMOUNT, m_bAutoMount); - DDX_Check(pDX, IDC_FIXMOUNT, m_bFixMount); - DDX_CBString(pDX, IDC_COMBO_AUTOMP, m_AutoLetter); - DDX_Text(pDX, IDC_EDIT_UID, m_sUID); - DDV_MaxChars(pDX, m_sUID, 8); - DDX_Text(pDX, IDC_EDIT_GID, m_sGID); - DDV_MaxChars(pDX, m_sGID, 8); - DDX_Text(pDX, IDC_EDIT_EUID, m_sEUID); - DDV_MaxChars(pDX, m_sEUID, 8); - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CExt2Attribute, CDialog) - //{{AFX_MSG_MAP(CExt2Attribute) - ON_BN_CLICKED(IDC_AUTOMOUNT, OnAutomount) - ON_BN_CLICKED(IDC_FIXMOUNT, OnFixmount) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CExt2Attribute message handlers - -BOOL CExt2Attribute::OnInitDialog() -{ - int i = 0; - CString s; - - CDialog::OnInitDialog(); - - m_Codepage = m_EVP->Codepage; - m_bReadonly = m_EVP->bReadonly || m_bCdrom; - if (m_bCdrom) { - SET_WIN(IDC_READ_ONLY, FALSE); - } - - if (m_bCdrom) { - m_fixDrv = Ext2QueryMountPoint( - m_DevName.GetBuffer(MAX_PATH)); - } else { - m_fixDrv = Ext2QueryRegistryMountPoint( - m_DevName.GetBuffer(MAX_PATH)); - } - - if (m_fixDrv) { - m_bAutoMount = FALSE; - m_bFixMount = TRUE; - m_FixedLetter.Format("%c:", m_fixDrv); - } else { - m_FixedLetter = " "; - } - - if (m_EVP->Flags2 & EXT2_VPROP3_USERIDS) { - m_sUID.Format("%u", m_EVP->uid); - m_sGID.Format("%u", m_EVP->gid); - if (m_EVP->EIDS) { - m_sEUID.Format("%u", m_EVP->euid); - } - } - - if (m_EVP->DrvLetter) { - - m_autoDrv = m_EVP->DrvLetter & 0x7F; - if (m_autoDrv >= 'a' && m_autoDrv <= 'z') - m_autoDrv = (CHAR)toupper(m_autoDrv); - else if (m_autoDrv >= 'A' && m_autoDrv <= 'Z') { - } else { - m_autoDrv = 0; - } - if (m_autoDrv == 0) - m_AutoLetter.Format(" "); - else - m_AutoLetter.Format("%C:", m_autoDrv); - m_bAutoMount = !m_bFixMount; - } - - m_sPrefix = m_EVP->sHidingPrefix; - m_sSuffix = m_EVP->sHidingSuffix; - - CComboBox *cbCodepage = (CComboBox *)GetDlgItem(IDC_COMBO_CODEPAGE); - if (cbCodepage) { - cbCodepage->ResetContent(); - i = 0; - while (gCodepages[i]) { - cbCodepage->AddString(gCodepages[i++]); - } - } - - { - CComboBox *cbDrvLetter = (CComboBox *)GetDlgItem(IDC_COMBO_DRVLETTER); - CComboBox *cbAutoLetter = (CComboBox *)GetDlgItem(IDC_COMBO_AUTOMP); - - PEXT2_LETTER drvLetter = NULL; - cbDrvLetter->AddString(" "); - cbAutoLetter->AddString(" "); - - if (m_autoDrv) { - m_AutoLetter.Format("%C:", m_autoDrv); - cbAutoLetter->AddString(m_AutoLetter); - } - - if (m_fixDrv) { - cbDrvLetter->AddString(m_FixedLetter); - } - for (i=2; i < 26; i++) { - drvLetter = &drvLetters[i]; - if (!drvLetter->bUsed) { - s.Format("%c:", drvLetter->Letter); - cbDrvLetter->AddString(s); - cbAutoLetter->AddString(s); - } - } -/* - for (i=0; i < 10; i++) { - drvLetter = &drvDigits[i]; - if (!drvLetter->bUsed) { - s.Format("%c:", drvLetter->Letter); - cbDrvLetter->AddString(s); - } - } -*/ - - } - - SET_CHECK(IDC_AUTOMOUNT, m_bAutoMount); - SET_CHECK(IDC_FIXMOUNT, m_bFixMount); - - SET_WIN(IDC_COMBO_DRVLETTER, m_bFixMount); - SET_WIN(IDC_COMBO_AUTOMP, m_bAutoMount); - - UpdateData(FALSE); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void CExt2Attribute::OnCancel() -{ - // TODO: Add extra cleanup here - - CDialog::OnCancel(); -} - -BOOL IsStringAllDigits(CString s) -{ - for (int i = 0; i < s.GetLength(); i++) { - if (!isdigit(s.GetAt(i))) - return FALSE; - } - - return TRUE; -} - - -void CExt2Attribute::OnOK() -{ - NT::NTSTATUS status; - HANDLE Handle = NULL; - CHAR DrvLetter = 0; - CString str; - BOOL rc = FALSE; - BOOL dc = FALSE; - - UpdateData(TRUE); - - if (m_Codepage.IsEmpty()) { - m_Codepage = "default"; - } - - CComboBox *cbCodepage = (CComboBox *)GetDlgItem(IDC_COMBO_CODEPAGE); - if (cbCodepage) { - int rc = cbCodepage->FindStringExact(-1, m_Codepage); - if (rc == CB_ERR) { - AfxMessageBox("Invalid codepage type: "+m_Codepage, MB_OK|MB_ICONWARNING); - return; - } - } - - if (m_EVP->bReadonly && m_EVP->bExt3 && !m_bReadonly) { - str = "Are you sure to enable writing support" - " on this EXT3 volume with Ext2Fsd ?"; - if (AfxMessageBox(str, MB_YESNO) != IDYES) { - m_EVP->bExt3Writable = FALSE; - } else { - m_EVP->bExt3Writable = TRUE; - } - } - - /* initialize structures to communicate with ext2fsd service*/ - m_EVP->Magic = EXT2_VOLUME_PROPERTY_MAGIC; - m_EVP->Command = APP_CMD_SET_PROPERTY3; - m_EVP->Flags = 0; - m_EVP->Flags2 = 0; - m_EVP->bReadonly = (BOOLEAN)m_bReadonly; - memset(m_EVP->Codepage, 0, CODEPAGE_MAXLEN); - strcpy((CHAR *)m_EVP->Codepage, m_Codepage.GetBuffer(CODEPAGE_MAXLEN)); - - /* initialize hiding filter patterns */ - if (m_sPrefix.IsEmpty()) { - m_EVP->bHidingPrefix = FALSE; - memset(m_EVP->sHidingPrefix, 0, HIDINGPAT_LEN); - } else { - strcpy( m_EVP->sHidingPrefix, - m_sPrefix.GetBuffer(m_sPrefix.GetLength())); - m_EVP->bHidingPrefix = TRUE; - } - - if (m_sSuffix.IsEmpty()) { - m_EVP->bHidingSuffix = FALSE; - memset(m_EVP->sHidingSuffix, 0, HIDINGPAT_LEN); - } else { - strcpy(m_EVP->sHidingSuffix, - m_sSuffix.GetBuffer(m_sSuffix.GetLength())); - m_EVP->bHidingSuffix = TRUE; - } - - if (m_bFixMount) { - - if (!m_FixedLetter.IsEmpty() && m_FixedLetter.GetAt(0) != ' ') { - DrvLetter = m_FixedLetter.GetAt(0); - } else { - DrvLetter = 0; - } - - if (DrvLetter != m_fixDrv) { - - if (m_fixDrv != 0) { - Ext2SetRegistryMountPoint(&m_fixDrv, NULL, FALSE); - Ext2RemoveDriveLetter(DrvLetter); - } - - if (DrvLetter != 0) { - Ext2SetRegistryMountPoint(&DrvLetter, m_DevName.GetBuffer(MAX_PATH), TRUE); - } - } - - if (DrvLetter && !m_fixDrv) { - Ext2MountVolumeAs(m_DevName.GetBuffer(MAX_PATH), DrvLetter); - dc = TRUE; - } - } else { - - if (m_fixDrv != 0) { - Ext2RemoveDriveLetter(m_fixDrv); - Ext2SetRegistryMountPoint(&m_fixDrv, NULL, FALSE); - } - } - - if (!m_sUID.IsEmpty() && !m_sGID.IsEmpty()) { - if (IsStringAllDigits(m_sUID) && - IsStringAllDigits(m_sGID)) { - m_EVP->Flags2 |= EXT2_VPROP3_USERIDS; - m_EVP->uid = (USHORT)atoi(m_sUID.GetBuffer(8)); - m_EVP->gid = (USHORT)atoi(m_sGID.GetBuffer(8)); - if (!m_sEUID.IsEmpty() && - IsStringAllDigits(m_sEUID)) { - m_EVP->EIDS = TRUE; - m_EVP->euid = (USHORT)atoi(m_sEUID.GetBuffer(8)); - } - } - } - - if (m_bAutoMount) { - - if (m_bCdrom) { - m_EVP->DrvLetter = 0; - Ext2StorePropertyinRegistry(m_EVP); - goto store_evp; - } - - if (!m_AutoLetter.IsEmpty() && m_AutoLetter.GetAt(0) != ' ') { - DrvLetter = m_AutoLetter.GetAt(0); - } else { - DrvLetter = 0; - } - - if (DrvLetter > 'Z' || DrvLetter < 'A') { - DrvLetter = 0; - } - m_EVP->DrvLetter = DrvLetter | 0x80; - m_EVP->Flags2 |= EXT2_VPROP3_AUTOMOUNT; - Ext2StorePropertyinRegistry(m_EVP); - - if (m_autoDrv) { - if (DrvLetter && Ext2IsDrvLetterAvailable(DrvLetter)) { - Ext2RemoveDriveLetter(m_autoDrv); - Ext2MountVolumeAs(m_DevName.GetBuffer(MAX_PATH), DrvLetter); - dc = TRUE; - } - } else { - if (DrvLetter && Ext2IsDrvLetterAvailable(DrvLetter)) { - Ext2MountVolumeAs(m_DevName.GetBuffer(MAX_PATH), DrvLetter); - dc = TRUE; - } else { - Ext2MountVolume(m_DevName.GetBuffer(MAX_PATH)); - dc = TRUE; - } - } - - } else { - - m_EVP->DrvLetter =0 ; - Ext2StorePropertyinRegistry(m_EVP); - - if (m_autoDrv && !Ext2IsDrvLetterAvailable(m_autoDrv)) { - Ext2RemoveDriveLetter(m_autoDrv); - dc = TRUE; - } - } - -store_evp: - - status = Ext2Open(m_DevName.GetBuffer(m_DevName.GetLength()), - &Handle, EXT2_DESIRED_ACCESS); - if (!NT_SUCCESS(status)) { - str.Format("Ext2Fsd service is not started.\n"); - AfxMessageBox(str, MB_OK | MB_ICONSTOP); - rc = TRUE; - goto errorout; - } - - rc = Ext2SetExt2Property(Handle, m_EVP); - - if (rc) { - /* don't bother user at all */ -#if 0 - str = "Ext2 volume settings updated successfully!"; - if (dc) { - str += "\r\n\r\nFixed mountpoint needs reboot to take into affect."; - } - AfxMessageBox(str, MB_OK | MB_ICONINFORMATION); -#endif - } else { - AfxMessageBox("Failed to save the Ext2 settings !", - MB_OK | MB_ICONWARNING); - } - -errorout: - - Ext2Close(&Handle); - - if (rc) { - CDialog::OnOK(); - } -} - -void CExt2Attribute::OnAutomount() -{ - UpdateData(TRUE); - SET_WIN(IDC_COMBO_AUTOMP, m_bAutoMount); -/* - if (m_bAutoMount) { - AfxMessageBox("This function is still in experiment. You'd better set a\r\n" - "fixed mountpoint for fixed disk or set partition type to\r\n" - "0x07 (NTFS) or FAT for non-bootable partition. For removable\r\n" - "disks like usb-disk it's better to use the second method."); - } -*/ - - if (m_bAutoMount) { -/* - CComboBox *cbAutoLetter = (CComboBox *)GetDlgItem(IDC_COMBO_AUTOMP); - if (cbAutoLetter && cbAutoLetter->GetCurSel() == CB_ERR) { - cbAutoLetter->SetCurSel(1); - } -*/ - m_bFixMount = FALSE; - SET_CHECK(IDC_FIXMOUNT, FALSE); - SET_WIN(IDC_COMBO_DRVLETTER, FALSE); - - UpdateData(FALSE); - } -} - -void CExt2Attribute::OnFixmount() -{ - UpdateData(TRUE); - SET_WIN(IDC_COMBO_DRVLETTER, m_bFixMount); - - if (m_bFixMount) { -/* - CComboBox *cbDrvLetter = (CComboBox *)GetDlgItem(IDC_COMBO_DRVLETTER); - if (cbDrvLetter && cbDrvLetter->GetCurSel() == CB_ERR) { - cbDrvLetter->SetCurSel(1); - } -*/ - m_bAutoMount = FALSE; - SET_CHECK(IDC_AUTOMOUNT, FALSE); - SET_WIN(IDC_COMBO_AUTOMP, FALSE); - - UpdateData(FALSE); - } +// Ext2Attribute.cpp : implementation file +// + +#include "stdafx.h" +#include "ext2mgr.h" +#include "Ext2Attribute.h" +#include "Ext2MgrDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CExt2Attribute dialog + + +CExt2Attribute::CExt2Attribute(CWnd* pParent /*=NULL*/) + : CDialog(CExt2Attribute::IDD, pParent) +{ + //{{AFX_DATA_INIT(CExt2Attribute) + m_Codepage = _T(""); + m_bReadonly = FALSE; + m_FixedLetter = _T(""); + m_AutoLetter = _T(""); + m_sPrefix = _T(""); + m_sSuffix = _T(""); + m_bAutoMount = FALSE; + m_bFixMount = FALSE; + m_autoDrv = 0; + m_sUID = _T("----"); + m_sGID = _T("----"); + m_sEUID = _T("----"); + //}}AFX_DATA_INIT + + m_MainDlg = NULL; + m_EVP = NULL; + m_DevName = _T(""); + m_bCdrom = FALSE; + m_fixDrv = 0; +} + + +void CExt2Attribute::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CExt2Attribute) + DDX_CBString(pDX, IDC_COMBO_CODEPAGE, m_Codepage); + DDX_Check(pDX, IDC_READ_ONLY, m_bReadonly); + DDX_CBString(pDX, IDC_COMBO_DRVLETTER, m_FixedLetter); + DDX_Text(pDX, IDC_EXT2_PREFIX, m_sPrefix); + DDV_MaxChars(pDX, m_sPrefix, 31); + DDX_Text(pDX, IDC_EXT2_SUFFIX, m_sSuffix); + DDV_MaxChars(pDX, m_sSuffix, 31); + DDX_Check(pDX, IDC_AUTOMOUNT, m_bAutoMount); + DDX_Check(pDX, IDC_FIXMOUNT, m_bFixMount); + DDX_CBString(pDX, IDC_COMBO_AUTOMP, m_AutoLetter); + DDX_Text(pDX, IDC_EDIT_UID, m_sUID); + DDV_MaxChars(pDX, m_sUID, 8); + DDX_Text(pDX, IDC_EDIT_GID, m_sGID); + DDV_MaxChars(pDX, m_sGID, 8); + DDX_Text(pDX, IDC_EDIT_EUID, m_sEUID); + DDV_MaxChars(pDX, m_sEUID, 8); + //}}AFX_DATA_MAP +} + +BEGIN_MESSAGE_MAP(CExt2Attribute, CDialog) + //{{AFX_MSG_MAP(CExt2Attribute) + ON_BN_CLICKED(IDC_AUTOMOUNT, OnAutomount) + ON_BN_CLICKED(IDC_FIXMOUNT, OnFixmount) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CExt2Attribute message handlers + +BOOL CExt2Attribute::OnInitDialog() +{ + int i = 0; + CString s; + + CDialog::OnInitDialog(); + + m_Codepage = m_EVP->Codepage; + m_bReadonly = m_EVP->bReadonly || m_bCdrom; + if (m_bCdrom) { + SET_WIN(IDC_READ_ONLY, FALSE); + } + + if (m_bCdrom) { + m_fixDrv = Ext2QueryMountPoint( + m_DevName.GetBuffer(MAX_PATH)); + } else { + m_fixDrv = Ext2QueryRegistryMountPoint( + m_DevName.GetBuffer(MAX_PATH)); + } + + if (m_fixDrv) { + m_bAutoMount = FALSE; + m_bFixMount = TRUE; + m_FixedLetter.Format("%c:", m_fixDrv); + } else { + m_FixedLetter = " "; + } + + if (m_EVP->Flags2 & EXT2_VPROP3_USERIDS) { + m_sUID.Format("%u", m_EVP->uid); + m_sGID.Format("%u", m_EVP->gid); + if (m_EVP->EIDS) { + m_sEUID.Format("%u", m_EVP->euid); + } + } + + if (m_EVP->DrvLetter) { + + m_autoDrv = m_EVP->DrvLetter & 0x7F; + if (m_autoDrv >= 'a' && m_autoDrv <= 'z') + m_autoDrv = (CHAR)toupper(m_autoDrv); + else if (m_autoDrv >= 'A' && m_autoDrv <= 'Z') { + } else { + m_autoDrv = 0; + } + if (m_autoDrv == 0) + m_AutoLetter.Format(" "); + else + m_AutoLetter.Format("%C:", m_autoDrv); + m_bAutoMount = !m_bFixMount; + } + + m_sPrefix = m_EVP->sHidingPrefix; + m_sSuffix = m_EVP->sHidingSuffix; + + CComboBox *cbCodepage = (CComboBox *)GetDlgItem(IDC_COMBO_CODEPAGE); + if (cbCodepage) { + cbCodepage->ResetContent(); + i = 0; + while (gCodepages[i]) { + cbCodepage->AddString(gCodepages[i++]); + } + } + + { + CComboBox *cbDrvLetter = (CComboBox *)GetDlgItem(IDC_COMBO_DRVLETTER); + CComboBox *cbAutoLetter = (CComboBox *)GetDlgItem(IDC_COMBO_AUTOMP); + + PEXT2_LETTER drvLetter = NULL; + cbDrvLetter->AddString(" "); + cbAutoLetter->AddString(" "); + + if (m_autoDrv) { + m_AutoLetter.Format("%C:", m_autoDrv); + cbAutoLetter->AddString(m_AutoLetter); + } + + if (m_fixDrv) { + cbDrvLetter->AddString(m_FixedLetter); + } + for (i=2; i < 26; i++) { + drvLetter = &drvLetters[i]; + if (!drvLetter->bUsed) { + s.Format("%c:", drvLetter->Letter); + cbDrvLetter->AddString(s); + cbAutoLetter->AddString(s); + } + } +/* + for (i=0; i < 10; i++) { + drvLetter = &drvDigits[i]; + if (!drvLetter->bUsed) { + s.Format("%c:", drvLetter->Letter); + cbDrvLetter->AddString(s); + } + } +*/ + + } + + SET_CHECK(IDC_AUTOMOUNT, m_bAutoMount); + SET_CHECK(IDC_FIXMOUNT, m_bFixMount); + + SET_WIN(IDC_COMBO_DRVLETTER, m_bFixMount); + SET_WIN(IDC_COMBO_AUTOMP, m_bAutoMount); + + UpdateData(FALSE); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void CExt2Attribute::OnCancel() +{ + // TODO: Add extra cleanup here + + CDialog::OnCancel(); +} + +BOOL IsStringAllDigits(CString s) +{ + for (int i = 0; i < s.GetLength(); i++) { + if (!isdigit(s.GetAt(i))) + return FALSE; + } + + return TRUE; +} + + +void CExt2Attribute::OnOK() +{ + NT::NTSTATUS status; + HANDLE Handle = NULL; + CHAR DrvLetter = 0; + CString str; + BOOL rc = FALSE; + BOOL dc = FALSE; + + UpdateData(TRUE); + + if (m_Codepage.IsEmpty()) { + m_Codepage = "default"; + } + + CComboBox *cbCodepage = (CComboBox *)GetDlgItem(IDC_COMBO_CODEPAGE); + if (cbCodepage) { + int rc = cbCodepage->FindStringExact(-1, m_Codepage); + if (rc == CB_ERR) { + AfxMessageBox("Invalid codepage type: "+m_Codepage, MB_OK|MB_ICONWARNING); + return; + } + } + + if (m_EVP->bReadonly && m_EVP->bExt3 && !m_bReadonly) { + str = "Are you sure to enable writing support" + " on this EXT3 volume with Ext2Fsd ?"; + if (AfxMessageBox(str, MB_YESNO) != IDYES) { + m_EVP->bExt3Writable = FALSE; + } else { + m_EVP->bExt3Writable = TRUE; + } + } + + /* initialize structures to communicate with ext2fsd service*/ + m_EVP->Magic = EXT2_VOLUME_PROPERTY_MAGIC; + m_EVP->Command = APP_CMD_SET_PROPERTY3; + m_EVP->Flags = 0; + m_EVP->Flags2 = 0; + m_EVP->bReadonly = (BOOLEAN)m_bReadonly; + memset(m_EVP->Codepage, 0, CODEPAGE_MAXLEN); + strcpy((CHAR *)m_EVP->Codepage, m_Codepage.GetBuffer(CODEPAGE_MAXLEN)); + + /* initialize hiding filter patterns */ + if (m_sPrefix.IsEmpty()) { + m_EVP->bHidingPrefix = FALSE; + memset(m_EVP->sHidingPrefix, 0, HIDINGPAT_LEN); + } else { + strcpy( m_EVP->sHidingPrefix, + m_sPrefix.GetBuffer(m_sPrefix.GetLength())); + m_EVP->bHidingPrefix = TRUE; + } + + if (m_sSuffix.IsEmpty()) { + m_EVP->bHidingSuffix = FALSE; + memset(m_EVP->sHidingSuffix, 0, HIDINGPAT_LEN); + } else { + strcpy(m_EVP->sHidingSuffix, + m_sSuffix.GetBuffer(m_sSuffix.GetLength())); + m_EVP->bHidingSuffix = TRUE; + } + + if (m_bFixMount) { + + if (!m_FixedLetter.IsEmpty() && m_FixedLetter.GetAt(0) != ' ') { + DrvLetter = m_FixedLetter.GetAt(0); + } else { + DrvLetter = 0; + } + + if (DrvLetter != m_fixDrv) { + + if (m_fixDrv != 0) { + Ext2SetRegistryMountPoint(&m_fixDrv, NULL, FALSE); + Ext2RemoveDriveLetter(DrvLetter); + } + + if (DrvLetter != 0) { + Ext2SetRegistryMountPoint(&DrvLetter, m_DevName.GetBuffer(MAX_PATH), TRUE); + } + } + + if (DrvLetter && !m_fixDrv) { + Ext2MountVolumeAs(m_DevName.GetBuffer(MAX_PATH), DrvLetter); + dc = TRUE; + } + } else { + + if (m_fixDrv != 0) { + Ext2RemoveDriveLetter(m_fixDrv); + Ext2SetRegistryMountPoint(&m_fixDrv, NULL, FALSE); + } + } + + if (!m_sUID.IsEmpty() && !m_sGID.IsEmpty()) { + if (IsStringAllDigits(m_sUID) && + IsStringAllDigits(m_sGID)) { + m_EVP->Flags2 |= EXT2_VPROP3_USERIDS; + m_EVP->uid = (USHORT)atoi(m_sUID.GetBuffer(8)); + m_EVP->gid = (USHORT)atoi(m_sGID.GetBuffer(8)); + if (!m_sEUID.IsEmpty() && + IsStringAllDigits(m_sEUID)) { + m_EVP->EIDS = TRUE; + m_EVP->euid = (USHORT)atoi(m_sEUID.GetBuffer(8)); + } + } + } + + if (m_bAutoMount) { + + if (m_bCdrom) { + m_EVP->DrvLetter = 0; + Ext2StorePropertyinRegistry(m_EVP); + goto store_evp; + } + + if (!m_AutoLetter.IsEmpty() && m_AutoLetter.GetAt(0) != ' ') { + DrvLetter = m_AutoLetter.GetAt(0); + } else { + DrvLetter = 0; + } + + if (DrvLetter > 'Z' || DrvLetter < 'A') { + DrvLetter = 0; + } + m_EVP->DrvLetter = DrvLetter | 0x80; + m_EVP->Flags2 |= EXT2_VPROP3_AUTOMOUNT; + Ext2StorePropertyinRegistry(m_EVP); + + if (m_autoDrv) { + if (DrvLetter && Ext2IsDrvLetterAvailable(DrvLetter)) { + Ext2RemoveDriveLetter(m_autoDrv); + Ext2MountVolumeAs(m_DevName.GetBuffer(MAX_PATH), DrvLetter); + dc = TRUE; + } + } else { + if (DrvLetter && Ext2IsDrvLetterAvailable(DrvLetter)) { + Ext2MountVolumeAs(m_DevName.GetBuffer(MAX_PATH), DrvLetter); + dc = TRUE; + } else { + Ext2MountVolume(m_DevName.GetBuffer(MAX_PATH)); + dc = TRUE; + } + } + + } else { + + m_EVP->DrvLetter =0 ; + Ext2StorePropertyinRegistry(m_EVP); + + if (m_autoDrv && !Ext2IsDrvLetterAvailable(m_autoDrv)) { + Ext2RemoveDriveLetter(m_autoDrv); + dc = TRUE; + } + } + +store_evp: + + status = Ext2Open(m_DevName.GetBuffer(m_DevName.GetLength()), + &Handle, EXT2_DESIRED_ACCESS); + if (!NT_SUCCESS(status)) { + str.Format("Ext2Fsd service is not started.\n"); + AfxMessageBox(str, MB_OK | MB_ICONSTOP); + rc = TRUE; + goto errorout; + } + + rc = Ext2SetExt2Property(Handle, m_EVP); + + if (rc) { + /* don't bother user at all */ +#if 0 + str = "Ext2 volume settings updated successfully!"; + if (dc) { + str += "\r\n\r\nFixed mountpoint needs reboot to take into affect."; + } + AfxMessageBox(str, MB_OK | MB_ICONINFORMATION); +#endif + } else { + AfxMessageBox("Failed to save the Ext2 settings !", + MB_OK | MB_ICONWARNING); + } + +errorout: + + Ext2Close(&Handle); + + if (rc) { + CDialog::OnOK(); + } +} + +void CExt2Attribute::OnAutomount() +{ + UpdateData(TRUE); + SET_WIN(IDC_COMBO_AUTOMP, m_bAutoMount); +/* + if (m_bAutoMount) { + AfxMessageBox("This function is still in experiment. You'd better set a\r\n" + "fixed mountpoint for fixed disk or set partition type to\r\n" + "0x07 (NTFS) or FAT for non-bootable partition. For removable\r\n" + "disks like usb-disk it's better to use the second method."); + } +*/ + + if (m_bAutoMount) { +/* + CComboBox *cbAutoLetter = (CComboBox *)GetDlgItem(IDC_COMBO_AUTOMP); + if (cbAutoLetter && cbAutoLetter->GetCurSel() == CB_ERR) { + cbAutoLetter->SetCurSel(1); + } +*/ + m_bFixMount = FALSE; + SET_CHECK(IDC_FIXMOUNT, FALSE); + SET_WIN(IDC_COMBO_DRVLETTER, FALSE); + + UpdateData(FALSE); + } +} + +void CExt2Attribute::OnFixmount() +{ + UpdateData(TRUE); + SET_WIN(IDC_COMBO_DRVLETTER, m_bFixMount); + + if (m_bFixMount) { +/* + CComboBox *cbDrvLetter = (CComboBox *)GetDlgItem(IDC_COMBO_DRVLETTER); + if (cbDrvLetter && cbDrvLetter->GetCurSel() == CB_ERR) { + cbDrvLetter->SetCurSel(1); + } +*/ + m_bAutoMount = FALSE; + SET_CHECK(IDC_AUTOMOUNT, FALSE); + SET_WIN(IDC_COMBO_AUTOMP, FALSE); + + UpdateData(FALSE); + } } \ No newline at end of file diff --git a/Ext2Mgr/Ext2Attribute.h b/Ext2Mgr/Ext2Attribute.h index b76bd70..1ae34aa 100644 --- a/Ext2Mgr/Ext2Attribute.h +++ b/Ext2Mgr/Ext2Attribute.h @@ -1,66 +1,66 @@ -#if !defined(AFX_EXT2ATTRIBUTE_H__59ED803F_08E4_4ADD_BDAE_E86EF7708DEF__INCLUDED_) -#define AFX_EXT2ATTRIBUTE_H__59ED803F_08E4_4ADD_BDAE_E86EF7708DEF__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// Ext2Attribute.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// CExt2Attribute dialog - -class CExt2Attribute : public CDialog -{ -// Construction -public: - CExt2Attribute(CWnd* pParent = NULL); // standard constructor - - CWnd * m_MainDlg; - PEXT2_VOLUME_PROPERTY3 m_EVP; - CString m_DevName; - BOOL m_bCdrom; - CHAR m_autoDrv; - CHAR m_fixDrv; - -// Dialog Data - //{{AFX_DATA(CExt2Attribute) - enum { IDD = IDD_EXT2_ATTR }; - CString m_Codepage; - BOOL m_bReadonly; - CString m_FixedLetter; - CString m_sPrefix; - CString m_sSuffix; - BOOL m_bAutoMount; - BOOL m_bFixMount; - CString m_AutoLetter; - CString m_sUID; - CString m_sGID; - CString m_sEUID; - //}}AFX_DATA - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CExt2Attribute) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CExt2Attribute) - virtual BOOL OnInitDialog(); - virtual void OnCancel(); - virtual void OnOK(); - afx_msg void OnAutomount(); - afx_msg void OnFixmount(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_EXT2ATTRIBUTE_H__59ED803F_08E4_4ADD_BDAE_E86EF7708DEF__INCLUDED_) +#if !defined(AFX_EXT2ATTRIBUTE_H__59ED803F_08E4_4ADD_BDAE_E86EF7708DEF__INCLUDED_) +#define AFX_EXT2ATTRIBUTE_H__59ED803F_08E4_4ADD_BDAE_E86EF7708DEF__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// Ext2Attribute.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CExt2Attribute dialog + +class CExt2Attribute : public CDialog +{ +// Construction +public: + CExt2Attribute(CWnd* pParent = NULL); // standard constructor + + CWnd * m_MainDlg; + PEXT2_VOLUME_PROPERTY3 m_EVP; + CString m_DevName; + BOOL m_bCdrom; + CHAR m_autoDrv; + CHAR m_fixDrv; + +// Dialog Data + //{{AFX_DATA(CExt2Attribute) + enum { IDD = IDD_EXT2_ATTR }; + CString m_Codepage; + BOOL m_bReadonly; + CString m_FixedLetter; + CString m_sPrefix; + CString m_sSuffix; + BOOL m_bAutoMount; + BOOL m_bFixMount; + CString m_AutoLetter; + CString m_sUID; + CString m_sGID; + CString m_sEUID; + //}}AFX_DATA + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CExt2Attribute) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CExt2Attribute) + virtual BOOL OnInitDialog(); + virtual void OnCancel(); + virtual void OnOK(); + afx_msg void OnAutomount(); + afx_msg void OnFixmount(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_EXT2ATTRIBUTE_H__59ED803F_08E4_4ADD_BDAE_E86EF7708DEF__INCLUDED_) diff --git a/Ext2Mgr/Ext2Mgr.cpp b/Ext2Mgr/Ext2Mgr.cpp index c555479..46cf868 100644 --- a/Ext2Mgr/Ext2Mgr.cpp +++ b/Ext2Mgr/Ext2Mgr.cpp @@ -1,301 +1,301 @@ -// Ext2Mgr.cpp : Defines the class behaviors for the application. -// - -#include "stdafx.h" -#include "Ext2Mgr.h" -#include "Ext2MgrDlg.h" -#include "Splash.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CExt2MgrApp - -BEGIN_MESSAGE_MAP(CExt2MgrApp, CWinApp) - //{{AFX_MSG_MAP(CExt2MgrApp) - // NOTE - the ClassWizard will add and remove mapping macros here. - // DO NOT EDIT what you see in these blocks of generated code! - //}}AFX_MSG - ON_COMMAND(ID_HELP, CWinApp::OnHelp) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CExt2MgrApp construction - -CExt2MgrApp::CExt2MgrApp() -{ - // TODO: add construction code here, - // Place all significant initialization in InitInstance -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only CExt2MgrApp object - -CExt2MgrApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// globals - -DWORD Checkpoint = 1; - -SERVICE_STATUS ServiceStatus; -SERVICE_STATUS_HANDLE ServiceHandle; - -///////////////////////////////////////////////////////////////////////////// -// CExt2MgrApp initialization - -#if 0 -void WINAPI ManagerServiceEntry(DWORD argc, char **argv); -void ManagerServiceThread(void *arg); -void ManagerStopService(); -void WINAPI ManagerServiceCtrl(DWORD ctrlcode); -#endif - - -BOOL -ManagerReportStatus( - SERVICE_STATUS_HANDLE Handle, - SERVICE_STATUS* Status, - DWORD State, - DWORD Exitcode, - DWORD Timeout - ) -{ - // If we're in the start state then we don't want the control manager - // sending us control messages because they'll confuse us. - if (State == SERVICE_START_PENDING) { - Status->dwControlsAccepted = 0; - } else { - Status->dwControlsAccepted = SERVICE_ACCEPT_STOP; - } - - // Save the new status we've been given - Status->dwCurrentState = State; - Status->dwWin32ExitCode = Exitcode; - Status->dwWaitHint = Timeout; - - // Update the checkpoint variable to let the SCM know that we - // haven't died if requests take a long time - if ((State == SERVICE_RUNNING) || (State == SERVICE_STOPPED)) { - Status->dwCheckPoint = 0; - } else { - Status->dwCheckPoint = Checkpoint++; - } - - // Tell the SCM our new status - return SetServiceStatus(Handle, Status); -} - -void ManagerStopService() -{ - ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING; - theApp.m_pMainWnd->SendMessage(WM_TERMINATE_PROGRAM, 0, 0x1234); -} - -void WINAPI ManagerCtrlService(DWORD ctrlcode) -{ - switch(ctrlcode) - { - - case SERVICE_CONTROL_STOP: - // STOP : The service must stop - ManagerStopService(); - break; - - case SERVICE_CONTROL_INTERROGATE: - // QUERY : Service control manager just wants to know our state - break; - - default: - // Control code not recognised - break; - - } - - // Tell the control manager what we're up to. - ManagerReportStatus( - ServiceHandle, - &ServiceStatus, - ServiceStatus.dwCurrentState, - NO_ERROR, 0); -} - -VOID __cdecl -ManagerStartMain(VOID * arg) -{ - BOOL isService = arg != 0; - CExt2MgrDlg* dlg = (CExt2MgrDlg*)theApp.m_pMainWnd; - - if (dlg) { - - /* always be quiet ! */ - if (0 && !dlg->m_bQuiet) { - CSplash* splash = new CSplash(IDB_ABOUT_SCREEN, RGB(128, 128, 128)); - splash->ShowSplash(); - dlg->m_splash = splash; - } - - if (isService) { - ManagerReportStatus( - ServiceHandle, - &ServiceStatus, - SERVICE_RUNNING, - NO_ERROR, 0 ); - } - - dlg->DoModal(); - - Ext2StopPipeSrv(); - } - - if (isService) { - ManagerReportStatus( - ServiceHandle, - &ServiceStatus, - SERVICE_STOPPED, - NO_ERROR, 0 ); - } -} - -void NTAPI -ManagerServiceEntry(DWORD argc, char**argv) -{ - // register the service control handler - ServiceHandle = - RegisterServiceCtrlHandler( - "Ext2Mgr", - ManagerCtrlService ); - - if (ServiceHandle == 0) { - return; - } - - // setup standard service state values - ServiceStatus.dwServiceType = SERVICE_WIN32 | SERVICE_INTERACTIVE_PROCESS; - ServiceStatus.dwServiceSpecificExitCode = 0; - - // report our status to the SCM - if (!ManagerReportStatus( - ServiceHandle, - &ServiceStatus, - SERVICE_START_PENDING, - NO_ERROR, - 600000 - )) - { - ManagerReportStatus( - ServiceHandle, - &ServiceStatus, - SERVICE_STOPPED, - NO_ERROR, - 0); - return; - } - - // Now start the service for real - _beginthread(ManagerStartMain, 0, (PVOID)TRUE); - return; -} - - -VOID -ManagerStartService(VOID *arg) -{ - SERVICE_TABLE_ENTRY ManagerSeriveTable[] = - { - {"Ext2Mgr", (LPSERVICE_MAIN_FUNCTION)ManagerServiceEntry}, - {NULL, NULL} - }; - - // let service control dispatcher start Ext2Mgr - StartServiceCtrlDispatcher(ManagerSeriveTable); -} - -BOOL CExt2MgrApp::InitInstance() -{ - AfxEnableControlContainer(); - - HWND hWnd = ::FindWindow(NULL, "Ext2 Volume Manager"); - if (hWnd) { - if (::GetWindowLongPtr(hWnd, DWLP_USER) == EXT2_DIALOG_MAGIC) { - ::ShowWindow(hWnd, SW_SHOW); - ::SetForegroundWindow(hWnd); - return FALSE; - } - } - - BOOL bHide = FALSE; - BOOL bQuiet = FALSE; - BOOL bService = FALSE; - BOOL bInstall = FALSE; - BOOL bRemove = FALSE; - BOOL bStat = FALSE; - - char * cmds = GetCommandLine(); - int i = (int)strlen(cmds); - while (--i > 0) { - if (cmds[i] == (char)' ') { - cmds[i] = 0; - if ( strlen(&cmds[i+1]) == 5 && - _stricmp(&cmds[i+2], "hide") == 0 && - (cmds[i+1] == '/' || cmds[i+1] == '-')) { - bHide = TRUE; - } else if (strlen(&cmds[i+1]) == 6 && - _stricmp(&cmds[i+2], "quiet") == 0 && - (cmds[i+1] == '/' || cmds[i+1] == '-')) { - bHide = bQuiet = TRUE; - } else if (strlen(&cmds[i+1]) == 8 && - _stricmp(&cmds[i+2], "install") == 0 && - (cmds[i+1] == '/' || cmds[i+1] == '-')) { - bInstall = TRUE; - } else if (strlen(&cmds[i+1]) == 7 && - _stricmp(&cmds[i+2], "remove") == 0 && - (cmds[i+1] == '/' || cmds[i+1] == '-')) { - bRemove = TRUE; - } else if (strlen(&cmds[i+1]) == 8 && - _stricmp(&cmds[i+2], "service") == 0 && - (cmds[i+1] == '/' || cmds[i+1] == '-')) { - bHide = bService = TRUE; - } else if (strlen(&cmds[i+1]) == 5 && - _stricmp(&cmds[i+2], "stat") == 0 && - (cmds[i+1] == '/' || cmds[i+1] == '-')) { - bHide = bStat = TRUE; - } - } - } - - if (bInstall) { - Ext2SetManagerAsService(TRUE); - return FALSE; - } - - if (bRemove) { - Ext2SetManagerAsService(FALSE); - return FALSE; - } - - Ext2IsX64System(); - - CExt2MgrDlg theDlg; - - theDlg.m_bHide = bHide; - theDlg.m_bQuiet = bQuiet = bHide; - theDlg.m_bService = bService; - theDlg.m_bStat = bStat; - - m_pMainWnd = &theDlg; - - if (bService) { - ManagerStartService(NULL); - } else { - ManagerStartMain(NULL); - } - - // Since the dialog has been closed, return FALSE so that we exit the - // application, rather than start the application's message pump. - return FALSE; -} +// Ext2Mgr.cpp : Defines the class behaviors for the application. +// + +#include "stdafx.h" +#include "Ext2Mgr.h" +#include "Ext2MgrDlg.h" +#include "Splash.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CExt2MgrApp + +BEGIN_MESSAGE_MAP(CExt2MgrApp, CWinApp) + //{{AFX_MSG_MAP(CExt2MgrApp) + // NOTE - the ClassWizard will add and remove mapping macros here. + // DO NOT EDIT what you see in these blocks of generated code! + //}}AFX_MSG + ON_COMMAND(ID_HELP, CWinApp::OnHelp) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CExt2MgrApp construction + +CExt2MgrApp::CExt2MgrApp() +{ + // TODO: add construction code here, + // Place all significant initialization in InitInstance +} + +///////////////////////////////////////////////////////////////////////////// +// The one and only CExt2MgrApp object + +CExt2MgrApp theApp; + +///////////////////////////////////////////////////////////////////////////// +// globals + +DWORD Checkpoint = 1; + +SERVICE_STATUS ServiceStatus; +SERVICE_STATUS_HANDLE ServiceHandle; + +///////////////////////////////////////////////////////////////////////////// +// CExt2MgrApp initialization + +#if 0 +void WINAPI ManagerServiceEntry(DWORD argc, char **argv); +void ManagerServiceThread(void *arg); +void ManagerStopService(); +void WINAPI ManagerServiceCtrl(DWORD ctrlcode); +#endif + + +BOOL +ManagerReportStatus( + SERVICE_STATUS_HANDLE Handle, + SERVICE_STATUS* Status, + DWORD State, + DWORD Exitcode, + DWORD Timeout + ) +{ + // If we're in the start state then we don't want the control manager + // sending us control messages because they'll confuse us. + if (State == SERVICE_START_PENDING) { + Status->dwControlsAccepted = 0; + } else { + Status->dwControlsAccepted = SERVICE_ACCEPT_STOP; + } + + // Save the new status we've been given + Status->dwCurrentState = State; + Status->dwWin32ExitCode = Exitcode; + Status->dwWaitHint = Timeout; + + // Update the checkpoint variable to let the SCM know that we + // haven't died if requests take a long time + if ((State == SERVICE_RUNNING) || (State == SERVICE_STOPPED)) { + Status->dwCheckPoint = 0; + } else { + Status->dwCheckPoint = Checkpoint++; + } + + // Tell the SCM our new status + return SetServiceStatus(Handle, Status); +} + +void ManagerStopService() +{ + ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING; + theApp.m_pMainWnd->SendMessage(WM_TERMINATE_PROGRAM, 0, 0x1234); +} + +void WINAPI ManagerCtrlService(DWORD ctrlcode) +{ + switch(ctrlcode) + { + + case SERVICE_CONTROL_STOP: + // STOP : The service must stop + ManagerStopService(); + break; + + case SERVICE_CONTROL_INTERROGATE: + // QUERY : Service control manager just wants to know our state + break; + + default: + // Control code not recognised + break; + + } + + // Tell the control manager what we're up to. + ManagerReportStatus( + ServiceHandle, + &ServiceStatus, + ServiceStatus.dwCurrentState, + NO_ERROR, 0); +} + +VOID __cdecl +ManagerStartMain(VOID * arg) +{ + BOOL isService = arg != 0; + CExt2MgrDlg* dlg = (CExt2MgrDlg*)theApp.m_pMainWnd; + + if (dlg) { + + /* always be quiet ! */ + if (0 && !dlg->m_bQuiet) { + CSplash* splash = new CSplash(IDB_ABOUT_SCREEN, RGB(128, 128, 128)); + splash->ShowSplash(); + dlg->m_splash = splash; + } + + if (isService) { + ManagerReportStatus( + ServiceHandle, + &ServiceStatus, + SERVICE_RUNNING, + NO_ERROR, 0 ); + } + + dlg->DoModal(); + + Ext2StopPipeSrv(); + } + + if (isService) { + ManagerReportStatus( + ServiceHandle, + &ServiceStatus, + SERVICE_STOPPED, + NO_ERROR, 0 ); + } +} + +void NTAPI +ManagerServiceEntry(DWORD argc, char**argv) +{ + // register the service control handler + ServiceHandle = + RegisterServiceCtrlHandler( + "Ext2Mgr", + ManagerCtrlService ); + + if (ServiceHandle == 0) { + return; + } + + // setup standard service state values + ServiceStatus.dwServiceType = SERVICE_WIN32 | SERVICE_INTERACTIVE_PROCESS; + ServiceStatus.dwServiceSpecificExitCode = 0; + + // report our status to the SCM + if (!ManagerReportStatus( + ServiceHandle, + &ServiceStatus, + SERVICE_START_PENDING, + NO_ERROR, + 600000 + )) + { + ManagerReportStatus( + ServiceHandle, + &ServiceStatus, + SERVICE_STOPPED, + NO_ERROR, + 0); + return; + } + + // Now start the service for real + _beginthread(ManagerStartMain, 0, (PVOID)TRUE); + return; +} + + +VOID +ManagerStartService(VOID *arg) +{ + SERVICE_TABLE_ENTRY ManagerSeriveTable[] = + { + {"Ext2Mgr", (LPSERVICE_MAIN_FUNCTION)ManagerServiceEntry}, + {NULL, NULL} + }; + + // let service control dispatcher start Ext2Mgr + StartServiceCtrlDispatcher(ManagerSeriveTable); +} + +BOOL CExt2MgrApp::InitInstance() +{ + AfxEnableControlContainer(); + + HWND hWnd = ::FindWindow(NULL, "Ext2 Volume Manager"); + if (hWnd) { + if (::GetWindowLongPtr(hWnd, DWLP_USER) == EXT2_DIALOG_MAGIC) { + ::ShowWindow(hWnd, SW_SHOW); + ::SetForegroundWindow(hWnd); + return FALSE; + } + } + + BOOL bHide = FALSE; + BOOL bQuiet = FALSE; + BOOL bService = FALSE; + BOOL bInstall = FALSE; + BOOL bRemove = FALSE; + BOOL bStat = FALSE; + + char * cmds = GetCommandLine(); + int i = (int)strlen(cmds); + while (--i > 0) { + if (cmds[i] == (char)' ') { + cmds[i] = 0; + if ( strlen(&cmds[i+1]) == 5 && + _stricmp(&cmds[i+2], "hide") == 0 && + (cmds[i+1] == '/' || cmds[i+1] == '-')) { + bHide = TRUE; + } else if (strlen(&cmds[i+1]) == 6 && + _stricmp(&cmds[i+2], "quiet") == 0 && + (cmds[i+1] == '/' || cmds[i+1] == '-')) { + bHide = bQuiet = TRUE; + } else if (strlen(&cmds[i+1]) == 8 && + _stricmp(&cmds[i+2], "install") == 0 && + (cmds[i+1] == '/' || cmds[i+1] == '-')) { + bInstall = TRUE; + } else if (strlen(&cmds[i+1]) == 7 && + _stricmp(&cmds[i+2], "remove") == 0 && + (cmds[i+1] == '/' || cmds[i+1] == '-')) { + bRemove = TRUE; + } else if (strlen(&cmds[i+1]) == 8 && + _stricmp(&cmds[i+2], "service") == 0 && + (cmds[i+1] == '/' || cmds[i+1] == '-')) { + bHide = bService = TRUE; + } else if (strlen(&cmds[i+1]) == 5 && + _stricmp(&cmds[i+2], "stat") == 0 && + (cmds[i+1] == '/' || cmds[i+1] == '-')) { + bHide = bStat = TRUE; + } + } + } + + if (bInstall) { + Ext2SetManagerAsService(TRUE); + return FALSE; + } + + if (bRemove) { + Ext2SetManagerAsService(FALSE); + return FALSE; + } + + Ext2IsX64System(); + + CExt2MgrDlg theDlg; + + theDlg.m_bHide = bHide; + theDlg.m_bQuiet = bQuiet = bHide; + theDlg.m_bService = bService; + theDlg.m_bStat = bStat; + + m_pMainWnd = &theDlg; + + if (bService) { + ManagerStartService(NULL); + } else { + ManagerStartMain(NULL); + } + + // Since the dialog has been closed, return FALSE so that we exit the + // application, rather than start the application's message pump. + return FALSE; +} diff --git a/Ext2Mgr/Ext2Mgr.h b/Ext2Mgr/Ext2Mgr.h index 73d1dde..2a1ddd7 100644 --- a/Ext2Mgr/Ext2Mgr.h +++ b/Ext2Mgr/Ext2Mgr.h @@ -1,49 +1,49 @@ -// Ext2Mgr.h : main header file for the EXT2MGR application -// - -#if !defined(AFX_EXT2MGR_H__6D13DACF_307A_4633_B268_5F4F4C2AD90E__INCLUDED_) -#define AFX_EXT2MGR_H__6D13DACF_307A_4633_B268_5F4F4C2AD90E__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -///////////////////////////////////////////////////////////////////////////// -// CExt2MgrApp: -// See Ext2Mgr.cpp for the implementation of this class -// - -class CExt2MgrApp : public CWinApp -{ -public: - CExt2MgrApp(); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CExt2MgrApp) - public: - virtual BOOL InitInstance(); - //}}AFX_VIRTUAL - -// Implementation - - //{{AFX_MSG(CExt2MgrApp) - // NOTE - the ClassWizard will add and remove member functions here. - // DO NOT EDIT what you see in these blocks of generated code ! - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_EXT2MGR_H__6D13DACF_307A_4633_B268_5F4F4C2AD90E__INCLUDED_) +// Ext2Mgr.h : main header file for the EXT2MGR application +// + +#if !defined(AFX_EXT2MGR_H__6D13DACF_307A_4633_B268_5F4F4C2AD90E__INCLUDED_) +#define AFX_EXT2MGR_H__6D13DACF_307A_4633_B268_5F4F4C2AD90E__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#ifndef __AFXWIN_H__ + #error include 'stdafx.h' before including this file for PCH +#endif + +#include "resource.h" // main symbols + +///////////////////////////////////////////////////////////////////////////// +// CExt2MgrApp: +// See Ext2Mgr.cpp for the implementation of this class +// + +class CExt2MgrApp : public CWinApp +{ +public: + CExt2MgrApp(); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CExt2MgrApp) + public: + virtual BOOL InitInstance(); + //}}AFX_VIRTUAL + +// Implementation + + //{{AFX_MSG(CExt2MgrApp) + // NOTE - the ClassWizard will add and remove member functions here. + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_EXT2MGR_H__6D13DACF_307A_4633_B268_5F4F4C2AD90E__INCLUDED_) diff --git a/Ext2Mgr/Ext2Mgr.rc b/Ext2Mgr/Ext2Mgr.rc index f4eef16..3558129 100644 --- a/Ext2Mgr/Ext2Mgr.rc +++ b/Ext2Mgr/Ext2Mgr.rc @@ -1,1161 +1,1161 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Chinese (P.R.C.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS) -#ifdef _WIN32 -LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED -#pragma code_page(936) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "#define _AFX_NO_SPLITTER_RESOURCES\r\n" - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\Ext2Mgr.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ABOUTBOX DIALOGEX 0, 0, 313, 222 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About Ext2 Volume Manager" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - DEFPUSHBUTTON "Í˳ö",IDOK,233,198,31,20,WS_GROUP - LTEXT "Ext2Mgr: 2.0",IDC_PROGRAM,50,207,171,11,SS_NOPREFIX - GROUPBOX "",IDC_ABOUT_SHOW,7,6,299,185,NOT WS_VISIBLE - DEFPUSHBUTTON "¾èÔù",ID_DONATE,269,198,31,20,WS_GROUP - LTEXT "Ext2Fsd: 0.44",IDC_DRIVER,50,197,171,11,SS_NOPREFIX - CONTROL 184,IDC_EXT2FSD,"Static",SS_BITMAP | SS_NOTIFY | SS_REALSIZEIMAGE | SS_SUNKEN,13,194,23,28,WS_EX_DLGMODALFRAME -END - -IDD_CHANGE_MOUNTPINT DIALOG 0, 0, 206, 129 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "·µ»Ø",IDOK,148,105,44,14 - GROUPBOX "¸ü¸ÄÅÌ·ûÉèÖãº",IDC_STATIC,7,0,192,126 - LTEXT "ÅÌ·ûÁбí:",IDC_STATIC,16,15,117,8 - CONTROL "List1",IDC_DRV_LETTER_LIST,"SysListView32",LVS_SMALLICON | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,14,28,128,93 - PUSHBUTTON "Ìí¼Ó",ID_ADD_MOUNTPOINT,149,30,44,14 - PUSHBUTTON "¸ü¸Ä",ID_CHANGE_MOUNTPOINT,149,52,43,14 - PUSHBUTTON "ɾ³ý",ID_REMOVE_MOUNTPOINT,149,74,43,14 -END - -IDD_DONATE_DIALOG DIALOGEX 0, 0, 268, 185 -STYLE DS_SETFONT | WS_POPUP | WS_CAPTION -CAPTION "Ö§³ÖExt2Fsd" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - DEFPUSHBUTTON "·µ»Ø",IDOK,223,141,32,36 - GROUPBOX "Ö£ÖØÉùÃ÷",IDC_STATIC,7,7,254,90 - EDITTEXT IDC_DECLARE,15,23,238,66,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | ES_WANTRETURN | WS_VSCROLL - GROUPBOX "¾èÔù·½Ê½",IDC_STATIC,7,103,254,78 - LTEXT "ͨ¹ýSourceForgeÍøÕ¾¾èÔù",IDC_VIA_SOURCEFORGE,15,145,101,12 - LTEXT "ͨ¹ýPayPal¾èÔù",IDC_VIA_PAYPAL,15,164,90,12 - LTEXT "ͨ¹ýTaobao¾èÔù: mattwu@163.com",IDC_VIA_TAOBAO,15,124,135,12 -END - -IDD_EXT2_ATTR DIALOG 0, 0, 251, 236 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "±£´æ²¢Í˳ö",IDOK,159,215,61,17 - CONTROL "ÉèÖÃΪֻ¶Á£¬²»¿Éд",IDC_READ_ONLY,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,27,39,134,10 - COMBOBOX IDC_COMBO_CODEPAGE,184,37,49,106,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP - CONTROL "×Ô¶¯¼ÓÔØÅÌ·û£ºÖ÷ÒªÕë¶Ô¿ÉÒÆ¶¯É豸",IDC_AUTOMOUNT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,27,79,147,10 - COMBOBOX IDC_COMBO_AUTOMP,196,76,36,96,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - CONTROL "¹Ì¶¨ÅÌ·û£º¶Ô¹Ì¶¨´ÅÅ̽¨Òé²ÉÓôËÖÖ·½Ê½",IDC_FIXMOUNT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,27,102,165,10 - COMBOBOX IDC_COMBO_DRVLETTER,196,100,36,107,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - EDITTEXT IDC_EXT2_PREFIX,109,138,108,14 - EDITTEXT IDC_EXT2_SUFFIX,109,157,108,14 - EDITTEXT IDC_EDIT_UID,53,192,25,12,ES_AUTOHSCROLL - EDITTEXT IDC_EDIT_GID,105,192,25,12,ES_AUTOHSCROLL - EDITTEXT IDC_EDIT_EUID,189,192,25,12,ES_AUTOHSCROLL - PUSHBUTTON "È¡ÏûËùÓи͝",IDCANCEL,25,215,60,17 - GROUPBOX "Ext2Îļþϵͳ¾íÉèÖãº",IDC_STATIC,7,7,237,205 - GROUPBOX "¾íÊôÐÔ",IDC_STATIC,15,22,149,37,WS_GROUP - GROUPBOX "ÓïÖÖ±àÂë",IDC_STATIC,173,22,64,37,WS_GROUP - LTEXT "ÎļþÃûÒÔ´ËΪ¿ªÍ·£º",IDC_STATIC,29,140,75,13 - LTEXT "ÎļþÃûÒÔ´ËΪ½áÊø£º",IDC_STATIC,29,159,74,13 - GROUPBOX "Òþ²ØÖ¸¶¨Îļþ",IDC_STATIC,13,123,224,52 - GROUPBOX "ÅÌ·ûÉèÖÃ",IDC_STATIC,14,64,223,55,WS_GROUP - GROUPBOX "",IDC_STATIC,14,90,223,29 - GROUPBOX "Ö¸¶¨¼ÓÔØÕʺÅ",IDC_STATIC,13,177,224,30 - LTEXT "UID:",IDC_STATIC,31,193,17,9 - LTEXT "GID:",IDC_STATIC,84,193,17,9 - LTEXT "EUID:",IDC_STATIC,164,193,21,9 -END - -IDD_EXT2MGR_DIALOG DIALOGEX 0, 0, 407, 277 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_APPWINDOW -CAPTION "Ext2 Volume Manager" -MENU IDR_MENU -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - CONTROL "List1",IDC_VOLUME_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_AUTOARRANGE | LVS_ALIGNLEFT | WS_BORDER | WS_GROUP | WS_TABSTOP,5,1,395,113,WS_EX_CLIENTEDGE - CONTROL "List1",IDC_DISK_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_OWNERDRAWFIXED | LVS_ALIGNLEFT | WS_BORDER | WS_GROUP | WS_TABSTOP,5,115,395,149,WS_EX_CLIENTEDGE -END - -IDD_NEW_MOUNTPOINT DIALOG 0, 0, 212, 158 -STYLE DS_SETFONT | WS_POPUP | WS_BORDER -FONT 9, "MS Sans Serif" -BEGIN - PUSHBUTTON "¼ÓÔØ²¢Í˳ö",IDOK,154,140,50,14 - LTEXT "Ñ¡ÔñÒªÌí¼ÓµÄÅÌ·û :",IDC_STATIC,6,16,97,8 - COMBOBOX IDC_DRVLETTERS_LIST,134,14,70,92,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP - CONTROL "ͨ¹ýDefineDosDevice£¬ÖØÆôºó»áʧЧ",IDC_DOSDEV_MP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,48,188,15 - DEFPUSHBUTTON "È¡Ïû²Ù×÷",IDCANCEL,66,140,50,14 - CONTROL "",IDC_PERMANENT_MP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,67,10,15 - CONTROL "",IDC_REGISTRY_MP,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,12,93,11,15 - GROUPBOX "Ìí¼Ó·½Ê½£º",IDC_STATIC,5,34,202,101 - LTEXT "ͨ¹ýMountMgr¼°Ext2MgrÀ´×Ô¶¯¼ÓÔØÅÌ·û£¬ÊÊÓÃÓÚÒÆ¶¯Ó²ÅÌ£¬ÐèÒªExt2MgrÒ»Ö±ÔËÐÐ",IDC_STATIC,24,69,166,20 - LTEXT "ͨ¹ýSession Manager×Ô¶¯¼ÓÔØ£¬ÊʺÏÓڹ̶¨´ÅÅÌ£¬±¾²Ù×÷»áÔÚ×¢²á±íÖд´½¨Ò»¸ö×Ö´®Ï\r\nHKLM\\System\\CurrentControlSet\\Control\\\r\nSession Manager\\DOS Devices",IDC_STATIC,24,94,169,36 -END - -IDD_PARTITION_TYPE DIALOG 0, 0, 149, 85 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION -CAPTION "¸ü¸Ä·ÖÇøÀàÐÍ" -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "¸ü¸Ä²¢Í˳ö",IDOK,91,61,45,18 - PUSHBUTTON "È¡Ïû²Ù×÷",IDCANCEL,10,62,46,17 - COMBOBOX IDC_PARTTION_TYPE_LIST,33,35,97,86,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - GROUPBOX "Ñ¡Ôñ·ÖÇøÀàÐÍ",IDC_STATIC,9,18,127,36 - LTEXT "Static",IDC_PARTITION_NAME,2,3,145,12 -END - -IDD_PERFSTAT_DIALOG DIALOGEX 0, 0, 286, 248 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Ext2Fsd ͳ¼ÆÐÅÏ¢" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - DEFPUSHBUTTON "·µ»Ø",IDOK,229,228,46,18 - GROUPBOX "ÄÚ´æ·ÖÅäͳ¼Æ",IDC_STATIC,1,2,283,117 - GROUPBOX "ÄÚºËIrpͳ¼Æ",IDC_STATIC,1,121,283,103 - LTEXT "×Ô¶¯Ë¢ÐÂʱ¼ä¼ä¸ô(Ãë):",IDC_STATIC,6,233,87,13 - EDITTEXT IDC_PERFSTAT_INTERVAL,97,231,36,12,ES_AUTOHSCROLL - GROUPBOX "",IDC_STATIC,1,223,137,23,0,WS_EX_TRANSPARENT - CONTROL "List1",IDC_MEMORY_LIST,"SysListView32",LVS_REPORT | WS_BORDER | WS_TABSTOP,1,12,283,107,WS_EX_CLIENTEDGE - CONTROL "List2",IDC_IRP_LIST,"SysListView32",LVS_REPORT | WS_BORDER | WS_TABSTOP,1,132,283,90,WS_EX_CLIENTEDGE - DEFPUSHBUTTON "ÊÖ¶¯Ë¢ÐÂ",ID_QUERYPERF,143,228,46,18 -END - -IDD_PROPERTY_DIALOG DIALOGEX 0, 0, 238, 209 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - DEFPUSHBUTTON "·µ»ØÖ÷´°¿Ú",IDOK,156,185,65,14 - GROUPBOX "DISK",IDC_PROPERTY_DEVICE,7,7,224,91 - LTEXT "Éú²úÉÌ:",IDC_STATIC,13,27,28,8 - EDITTEXT IDC_VENDOR_ID,48,25,71,12,ES_AUTOHSCROLL | ES_READONLY - LTEXT "ÐͺÅ:",IDC_STATIC,13,44,20,8 - EDITTEXT IDC_PRODUCT_ID,48,42,71,12,ES_AUTOHSCROLL | ES_READONLY - LTEXT "ÐòºÅ:",IDC_STATIC,13,59,27,8 - EDITTEXT IDC_SERIAL_NUMBER,48,58,71,12,ES_AUTOHSCROLL | ES_READONLY - LTEXT "×ÜÏß:",IDC_STATIC,130,28,20,8 - EDITTEXT IDC_BUS_TYPE,155,26,65,12,ES_AUTOHSCROLL | ES_READONLY - LTEXT "ÀàÐÍ:",IDC_STATIC,130,43,20,8 - EDITTEXT IDC_DEVICE_TYPE,155,42,65,12,ES_AUTOHSCROLL | ES_READONLY - LTEXT "½éÖÊ:",IDC_STATIC,129,59,22,8 - EDITTEXT IDC_MEDIA_TYPE,155,58,65,12,ES_AUTOHSCROLL | ES_READONLY - LTEXT "´ÅÅÌÈÝÁ¿ (×Ö½Ú):",IDC_STATIC,14,78,61,8 - EDITTEXT IDC_TOTAL_SIZE,82,77,138,12,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER - GROUPBOX "DISK",IDC_PROPERTY_SDEV,7,101,224,103 - LTEXT "״̬:",IDC_STATIC,14,123,51,8 - EDITTEXT IDC_SDEV_STATUS,70,121,151,12,ES_AUTOHSCROLL | ES_READONLY - LTEXT "ÅÌ·û:",IDC_STATIC,14,139,54,8 - EDITTEXT IDC_MOUNT_POINTS,70,138,83,12,ES_AUTOHSCROLL | ES_READONLY - PUSHBUTTON "¸ü¸ÄÅÌ·û",IDC_SDEV_CHANGE_MP,183,134,38,14,BS_LEFT,WS_EX_STATICEDGE - LTEXT "Îļþϵͳ:",IDC_STATIC,14,155,51,8 - EDITTEXT IDC_FILE_SYSTEM,69,152,83,12,ES_AUTOHSCROLL | ES_READONLY - PUSHBUTTON "¸ü¸ÄExt2¾íÉèÖÃ",IDC_SDEV_EXT2_INFO,156,152,66,14,BS_LEFT,WS_EX_STATICEDGE - LTEXT "·ÖÇøÈÝÁ¿:",IDC_STATIC,14,171,42,8 - EDITTEXT IDC_SDEV_SIZE,69,169,84,12,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER - LTEXT "¿ÉÓÿռä:",IDC_STATIC,14,187,49,8 - EDITTEXT IDC_SDEV_FREE_SIZE,69,186,84,12,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER - PUSHBUTTON "¹ÒÔØ",IDC_SDEV_QUICK_MOUNT,156,134,24,15,BS_LEFT,WS_EX_STATICEDGE -END - -IDD_REMOVE_DEADLETTER DIALOG 0, 0, 208, 122 -STYLE DS_SETFONT | WS_POPUP | WS_CAPTION -CAPTION "ɾ³ýÎÞЧÅÌ·û" -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "ɾ³ý",IDOK,161,105,43,14 - DEFPUSHBUTTON "ÖØÐÂËÑË÷",ID_RELOAD_DL,91,105,46,14 - PUSHBUTTON "·µ»Ø",IDCANCEL,2,105,50,14 - GROUPBOX "Ñ¡ÔñҪɾ³ýµÄÅÌ·û:",IDC_STATIC,2,8,204,52 - COMBOBOX IDC_DEAD_LETTER_LIST,20,25,175,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - GROUPBOX "×Ô¶¯É¾³ý:",IDC_STATIC,2,64,204,30 - CONTROL "",IDC_AUTO_REMOVAL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,78,9,10 - LTEXT "µ±Ext2Mgr¼ì²âµ½ÉèÖñ仯ʱ£¬×Ô¶¯É¾³ýÎÞЧÅÌ·û",IDC_AUTOREMOVALTEXT,23,79,177,12 - CONTROL "Ö»´Ó±¾´Î»á»°ÖÐÒÆ³ý£¬±£³ÖÖØÆôºóÒÀÈ»ÓÐЧ",IDC_REMOVAL_CURRENT,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,19,43,174,12 -END - -IDD_SERVICE_MANAGE DIALOG 0, 0, 238, 235 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "¸ü¸Ä²¢Í˳ö",IDOK,170,214,47,17 - GROUPBOX "Ext2Fsd Çý¶¯ÉèÖÃ",IDC_STATIC,7,7,224,203 - GROUPBOX "µ±Ç°×´Ì¬",IDC_STATIC,19,21,201,36,WS_GROUP - EDITTEXT IDC_SERVICE_STATUS,26,35,145,14,ES_READONLY - PUSHBUTTON "ÆôÓÃ",IDC_START_SERVICE,179,33,34,17 - GROUPBOX "Æô¶¯·½Ê½",IDC_STATIC,19,63,116,37 - COMBOBOX IDC_COMBO_STARTUP,29,80,101,88,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP - GROUPBOX "È«¾ÖÓïÑÔ±àÂë",IDC_STATIC,141,63,78,38 - COMBOBOX IDC_COMBO_CODEPAGE,149,81,60,111,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP - GROUPBOX "È«¾ÖĬÈϲÎÊýÉèÖÃ",IDC_STATIC,18,104,201,102,WS_GROUP - CONTROL "ÒÔÖ»¶Á·½Ê½¼ÓÔØ·ÖÇø£¨·ÖÇø¿ÉÒÔÓжÀÁ¢µÄÉèÖã©",IDC_READ_ONLY,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,32,120,181,10 - CONTROL "Ö§³ÖExt3µÄд²Ù×÷(ºöÂÔÈÕÖ¾¼°Ä¿Â¼Ë÷Òý)",IDC_EXT3_WRITABLE,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,32,136,170,10 - PUSHBUTTON "È¡Ïû",IDCANCEL,29,214,38,17 - EDITTEXT IDC_GLOBAL_PREFIX,100,167,107,14 - EDITTEXT IDC_GLOBAL_SUFFIX,99,187,108,14 - LTEXT "ÎļþÃûÒþ²ØÇ°×º:",IDC_STATIC,32,169,67,13 - LTEXT "ÎļþÃûÒþ²Øºó׺:",IDC_STATIC,32,188,62,13 - CONTROL "×Ô¶¯·ÖÅäÅÌ·û£¨ÔÚ´ÅÅ̲åÈëʱ£©",IDC_EXT3_AUTOMOUNT,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,32,151,170,10 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_ABOUTBOX, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 306 - TOPMARGIN, 7 - BOTTOMMARGIN, 221 - END - - IDD_CHANGE_MOUNTPINT, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 199 - BOTTOMMARGIN, 126 - END - - IDD_DONATE_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 261 - TOPMARGIN, 7 - END - - IDD_EXT2_ATTR, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 244 - TOPMARGIN, 7 - BOTTOMMARGIN, 232 - END - - IDD_EXT2MGR_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 5 - RIGHTMARGIN, 400 - TOPMARGIN, 1 - BOTTOMMARGIN, 273 - END - - IDD_NEW_MOUNTPOINT, DIALOG - BEGIN - LEFTMARGIN, 1 - RIGHTMARGIN, 211 - TOPMARGIN, 7 - BOTTOMMARGIN, 154 - END - - IDD_PARTITION_TYPE, DIALOG - BEGIN - LEFTMARGIN, 2 - RIGHTMARGIN, 147 - TOPMARGIN, 2 - END - - IDD_PERFSTAT_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 1 - RIGHTMARGIN, 284 - TOPMARGIN, 2 - BOTTOMMARGIN, 246 - END - - IDD_PROPERTY_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 231 - TOPMARGIN, 7 - END - - IDD_REMOVE_DEADLETTER, DIALOG - BEGIN - LEFTMARGIN, 2 - RIGHTMARGIN, 206 - TOPMARGIN, 2 - BOTTOMMARGIN, 119 - END - - IDD_SERVICE_MANAGE, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 231 - TOPMARGIN, 7 - BOTTOMMARGIN, 231 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,0,7,9 - PRODUCTVERSION 3,0,7,9 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "CompanyName", "Ext2Fsd Group (www.ext2fsd.com)" - VALUE "FileDescription", "Ext2 Volume Manager for Windows" - VALUE "FileVersion", "3.0.7.9" - VALUE "InternalName", "Ext2Mgr" - VALUE "LegalCopyright", "Copyright (C) 2016 Ext2Fsd Group" - VALUE "OriginalFilename", "Ext2Mgr.exe" - VALUE "ProductName", "Ext2 Volume Manager for Windows" - VALUE "ProductVersion", "3.0.7.9" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_MENU MENU -BEGIN - POPUP "Îļþ(&F)" - BEGIN - MENUITEM "ÉèÖÃΪ×Ô¶¯Æô¶¯(&E)", ID_ENABLE_AUTOSTART - MENUITEM "È¡Ïû×Ô¶¯Æô¶¯(&D)", ID_DISABLE_AUTOSTART - MENUITEM SEPARATOR - MENUITEM "Í˳ö±¾³ÌÐò(&x)", ID_EXIT - END - POPUP "±à¼­(&E)" - BEGIN - MENUITEM "¸´ÖÆËùÓÐÐÅÏ¢ÖÁ¼ôÌù°å(&C)", ID_COPYALL - END - POPUP "¹¤¾ßÓëÉèÖÃ(&T)" - BEGIN - MENUITEM "ÖØÐ¼ÓÔØÏµÍ³ÐÅÏ¢(&R)\tF5", ID_REFRESH - MENUITEM SEPARATOR - MENUITEM "ÅäÖÃÎļþϵͳÇý¶¯(&S)\tF7", ID_SERVICE - MENUITEM "ÐÔÄܼ°ÄÚ´æ·ÖÅäͳ¼Æ(&T)\tF8", ID_PERFSTAT - MENUITEM SEPARATOR - MENUITEM "ÅäÖÃExt2¾íÊôÐÔ(&E)\tF3", ID_CHANGE - MENUITEM "ÅÌ·û¹ÜÀí¼°ÉèÖÃ(&M)\tF10", ID_DRV_LETTER - MENUITEM "ɾ³ýÎÞЧÅÌ·û(&D)\tF7", ID_REMOVE_DEAD_LETTER - MENUITEM SEPARATOR - MENUITEM "Ç¿ÖÆ±£´æÏµÍ³»º³å(&F)\tF9", ID_FLUSH_BUFFER - MENUITEM "¸ü¸Ä·ÖÇøÀàÐÍID(&C)\tF11", ID_CHANGE_PARTTYPE - MENUITEM SEPARATOR - MENUITEM "ÏÔʾ´ÅÅÌ»ò·ÖÇøÊôÐÔ(&P)\tF12", ID_PROPERTY - END - POPUP "°ïÖú(&H)" - BEGIN - MENUITEM "°ïÖúÐÅÏ¢(&H)\tF1", ID_HELP - MENUITEM SEPARATOR - MENUITEM "¹ØÓÚ±¾³ÌÐò(&A)\tF2", ID_ABOUT - MENUITEM SEPARATOR - MENUITEM "Ö§³ÖÎÒÃÇ...(&D)", ID_DONATE - END -END - -IDR_TRAY MENU -BEGIN - POPUP "Tray" - BEGIN - MENUITEM "ÏÔʾÖ÷´°¿Ú", ID_SHOW_MAIN - MENUITEM SEPARATOR - MENUITEM "ÅäÖÃÎļþϵͳÇý¶¯", ID_SERVICE - MENUITEM "ÐÔÄܼ°ÄÚ´æ·ÖÅäͳ¼Æ", ID_PERFSTAT - MENUITEM SEPARATOR - MENUITEM "¹ØÓÚ Ext2Mgr", ID_ABOUT - MENUITEM SEPARATOR - MENUITEM "Í˳ö±¾³ÌÐò ...", ID_EXIT - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// RCDATA -// - -IDR_RCDAT_SRV RCDATA "Ext2Srv.exe" - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDS_ABOUTBOX "&About Ext2 Volume Manager ..." -END - -STRINGTABLE -BEGIN - ID_ABOUT "About Ext2 Volume Manger\tF2" - ID_NEW "create a new configuration file" - ID_CHANGE "Change the settings of the selected driver or volume" - ID_REFRESH "Refresh and reload the disks and volumes" - ID_EXIT "Quit ext2 volume manager ..." - ID_SERVICE "Manage the ext2fsd driver startup information" - ID_FORMAT "Format the selected volume or parititon" - ID_PROPERTY "Show the information and property of the selected volume or partition" - ID_COPY "Copy the only selected item to clipboard" - ID_SHOW_MAIN "Show the main window of Ext2Mgr" - ID_DRV_LETTER "Assign or change driver letters of selected volume or disk" - ID_DONATE "Donate to Ext2Fsd group" -END - -STRINGTABLE -BEGIN - ID_INSTALL_SERVICE "Install Ext2Mgr as a service (with autostart enabled)" - ID_REMOVE_SERVICE "Remove Ext2Mgr service (disable service autostart)" - ID_ENABLE_AUTOSTART "Let Ext2Mgr automatically start when system boots" - ID_DISABLE_AUTOSTART "Don't want Ext2Mgr automatically start when system boots" - ID_PERFSTAT "Statistics of memory allocations and Irp processing" - ID_COPYALL "Copy all disks/partitions/cdrom/volumes information to clipboard" - ID_FLUSH_BUFFER "Sync all dirty cache to disk" - ID_CHANGE_PARTTYPE "Change the partition type/id" - ID_REMOVE_DEAD_LETTER "Remove the dead driver letter" - ID_DRV_QUICK_MOUNT "Assign a driver letter to selected volume or disk" - ID_DRV_QUICK_REMOVE "Remove 1st driver letter of selected volume or disk" -END - -STRINGTABLE -BEGIN - ID_HELP "Help" - IDS_LISTITEM_FILESYSTEM "Îļþϵͳ" - IDS_LISTITEM_VOLUME "¾í" - IDS_LISTITEM_TYPE "ÀàÐÍ" - IDS_LISTITEM_TOTALSIZE "×ÜÈÝÁ¿" - IDS_LISTITEM_USEDSIZE "ÒÑʹÓÃ" - IDS_LISTITEM_CODEPAGE "ÓïÑÔ±àÂë" - IDS_LISTITEM_DEVOBJ "É豸Ãû" - IDS_LISTITEM_PARTID "·ÖÇøÀàÐÍ" - IDS_DISK_TYPE_BASIC "»ù±¾" -END - -STRINGTABLE -BEGIN - IDS_DISK_TYPE_DYN "¶¯Ì¬" - IDS_DONATE_DECLARE "\r\nÊÀ½çÐèÒªÈÈÐij¦£¬Ò»¼ÒÈËÒ²²»ËµÁ½¼Ò»°£º\r\n\r\nÓÐÇ®³öÇ®£¬ÓÐÁ¦³öÁ¦£¡£º-£©\r\n\r\nÆäʵ£¬½«Ê¹Óùý³ÌÖз¢ÏÖµÄÎÊÌâ»òÕߺõĽ¨ÒéÖ±½Ó·¢¸øÎÒ¾ÍÒÑÊǶÔExt2Fsd×îºÃµÄÖ§³ÖÁË¡£¼òÑÔÖ®£¬¶àÓö෴À¡¶àÐû´«£¡\r\n\r\nMatt Wu" - IDS_SHOW_PROPERTY "´ÅÅ̼°·ÖÇøÊôÐÔ\tF6" - IDS_COPY_ITEM_TO_CLIP "¸´ÖƵ±Ç°ÄÚÈÝ(&C)" - IDS_CHANGE_DRVLETTER "¸ü¸Ä×°ÅäµãÅÌ·û\tF10" - IDS_EXT2_MANAGEMENT "ÅäÖÃExt2¾íÊôÐÔ\tF3" - IDS_FLUSH_BUFFER "±£´æÏµÍ³»º³å\tF11" - IDS_CHANGE_PARTID "¸ü¸Ä·ÖÇøÀàÐÍ\tF12" - IDS_RELOAD_REFRESH "Ë¢ÐÂËùÓÐÄÚÈÝ\tF5" - IDS_PERFMEM_STAT "ÐÔÄܼ°ÄÚ´æÍ³¼Æ\tF8" - IDS_SERVICE_MANAGE "ÅäÖÃÎļþϵͳ\tF7" - IDS_REMOVE_DEAD_LETTER "ɾ³ýÎÞЧÅÌ·û\tF9" - IDS_PERFSTAT_NAME "Ãû³Æ" - IDS_PERFSTAT_UNIT "½á¹¹´óС" - IDS_PERFSTAT_CURRENT "ÒÑ·ÖÅä¸öÊý" - IDS_PERFSTAT_SIZE "Õ¼ÓÃÄÚ´æ´óС" -END - -STRINGTABLE -BEGIN - IDS_PERFSTAT_TOTAL "ÀúÊ·»ýÀÛ·ÖÅä´ÎÊý" - IDS_PERFSTAT_PROCESSING "ÕýÔÚ´¦Àí" - IDS_PERFSTAT_PROCESSED "ÒÑÍê³ÉµÄÇëÇó" - IDS_DRV_QUICK_MOUNT "¼ÓÔØ×°ÅäµãÅÌ·û\tF4" -END - -#endif // Chinese (P.R.C.) resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_DONATE_DIALOG DIALOGEX 0, 0, 268, 219 -STYLE DS_SETFONT | WS_POPUP | WS_CAPTION -CAPTION "Contribute to Ext2Fsd Group" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - DEFPUSHBUTTON "OK",IDOK,223,172,32,36 - GROUPBOX "Donation declaration",IDC_STATIC,7,7,254,149 - EDITTEXT IDC_DECLARE,15,23,238,126,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | ES_WANTRETURN | WS_VSCROLL - GROUPBOX "Click to donate",IDC_STATIC,7,163,254,51 - LTEXT "Donate via SourceForge.net",IDC_VIA_SOURCEFORGE,15,180,114,12 - LTEXT "Donate via PayPal.com",IDC_VIA_PAYPAL,15,198,90,12 -END - -IDD_ABOUTBOX DIALOGEX 0, 0, 313, 223 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About Ext2 Volume Manager" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - DEFPUSHBUTTON "Exit",IDOK,233,197,31,20,WS_GROUP - CONTROL 184,IDC_EXT2FSD,"Static",SS_BITMAP | SS_NOTIFY | SS_REALSIZEIMAGE | SS_SUNKEN,13,195,23,28,WS_EX_DLGMODALFRAME - LTEXT "Ext2Mgr: 2.0",IDC_PROGRAM,50,207,171,9,SS_NOPREFIX - GROUPBOX "",IDC_ABOUT_SHOW,7,4,299,185,NOT WS_VISIBLE - DEFPUSHBUTTON "Donate",ID_DONATE,269,197,31,20,WS_GROUP - LTEXT "Ext2Fsd: 0.44",IDC_DRIVER,50,197,171,9,SS_NOPREFIX -END - -IDD_EXT2MGR_DIALOG DIALOGEX 0, 0, 407, 277 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_APPWINDOW -CAPTION "Ext2 Volume Manager" -MENU IDR_MENU -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - CONTROL "List1",IDC_VOLUME_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_AUTOARRANGE | LVS_ALIGNLEFT | WS_BORDER | WS_GROUP | WS_TABSTOP,5,1,395,113,WS_EX_CLIENTEDGE - CONTROL "List1",IDC_DISK_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_OWNERDRAWFIXED | LVS_ALIGNLEFT | WS_BORDER | WS_GROUP | WS_TABSTOP,5,115,395,149,WS_EX_CLIENTEDGE -END - -IDD_SERVICE_MANAGE DIALOG 0, 0, 238, 233 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "Apply",IDOK,170,213,37,17 - GROUPBOX "Ext2Fsd Service Management",IDC_STATIC,7,7,224,203 - GROUPBOX "Service status",IDC_STATIC,19,21,201,36,WS_GROUP - EDITTEXT IDC_SERVICE_STATUS,26,35,145,14,ES_READONLY - PUSHBUTTON "Start",IDC_START_SERVICE,179,33,34,17 - GROUPBOX "Service startup mode",IDC_STATIC,19,63,130,37 - COMBOBOX IDC_COMBO_STARTUP,29,80,115,88,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP - GROUPBOX "Global Codepage",IDC_STATIC,153,63,66,38 - COMBOBOX IDC_COMBO_CODEPAGE,160,81,54,111,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP - GROUPBOX "Global Volume Settings",IDC_STATIC,18,104,201,100,WS_GROUP - CONTROL "Mount all volumes in read-only mode",IDC_READ_ONLY, - "Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,32,120,181,10 - CONTROL "Enable writing support for ext3 volumes",IDC_EXT3_WRITABLE, - "Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,32,136,170,10 - PUSHBUTTON "Cancel",IDCANCEL,29,213,38,17 - EDITTEXT IDC_GLOBAL_PREFIX,137,166,70,14 - EDITTEXT IDC_GLOBAL_SUFFIX,137,186,70,14 - LTEXT "Hiding files with prefix:",IDC_STATIC,32,168,102,13 - LTEXT "Hiding files with suffix:",IDC_STATIC,32,187,100,13 - CONTROL "Assign drive letter automatically",IDC_EXT3_AUTOMOUNT, - "Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,32,151,170,10 -END - -IDD_FORMAT DIALOG 0, 0, 203, 198 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "Start",IDOK,19,177,50,14 - PUSHBUTTON "Cancel",IDCANCEL,132,177,50,14 - CONTROL "Progress1",IDC_FORMAT_PROGRESS,"msctls_progress32",WS_BORDER,12,153,171,8 - COMBOBOX IDC_COMBO_FS,85,27,97,14,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP - LTEXT "File system:",IDC_STATIC,20,30,53,8 - GROUPBOX "Format",IDC_FORMAT_TITLE,7,7,183,161 - LTEXT "Volume label:",IDC_STATIC,21,77,54,10 - EDITTEXT IDC_EDIT_LABEL,85,73,95,14 - LTEXT "Cluster size:",IDC_STATIC,21,55,54,8 - COMBOBOX IDC_COMBO_CLUSTER,85,52,96,14,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP - GROUPBOX "",IDC_STATIC,14,20,170,23 - GROUPBOX "",IDC_STATIC,14,46,170,23 - GROUPBOX "",IDC_STATIC,13,67,170,23 - GROUPBOX "Options",IDC_STATIC,13,98,169,42 - CONTROL "Perform a quick format",IDC_QUICK_FORMAT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,32,112,138,10 - CONTROL "Enable volume compression",IDC_QUICK_COMPRESS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,32,125,112,10 -END - -IDD_EXT2_ATTR DIALOG 0, 0, 251, 233 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "Apply",IDOK,176,216,39,17 - CONTROL "Mount volume in readonly mode",IDC_READ_ONLY,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,27,39,134,10 - COMBOBOX IDC_COMBO_CODEPAGE,184,37,49,106,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP - CONTROL "Automatically mount via Ext2Mgr",IDC_AUTOMOUNT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,27,79,148,10 - COMBOBOX IDC_COMBO_AUTOMP,196,76,36,96,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - CONTROL "Mountpoint for fixed disk, need reboot",IDC_FIXMOUNT, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,27,102,165,10 - COMBOBOX IDC_COMBO_DRVLETTER,196,100,36,107,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - EDITTEXT IDC_EXT2_PREFIX,147,138,70,14 - EDITTEXT IDC_EXT2_SUFFIX,147,157,70,14 - EDITTEXT IDC_EDIT_UID,53,193,25,12,ES_AUTOHSCROLL - EDITTEXT IDC_EDIT_GID,105,193,25,12,ES_AUTOHSCROLL - EDITTEXT IDC_EDIT_EUID,189,193,25,12,ES_AUTOHSCROLL - PUSHBUTTON "Cancel",IDCANCEL,17,216,42,17 - GROUPBOX "Ext2/3 Volume Settings",IDC_STATIC,7,7,237,206 - GROUPBOX "Volume attribute",IDC_STATIC,15,22,149,37,WS_GROUP - GROUPBOX "Codepage",IDC_STATIC,173,22,64,37,WS_GROUP - LTEXT "Hiding files with prefix:",IDC_STATIC,29,140,102,13 - LTEXT "Hiding files with suffix:",IDC_STATIC,29,159,100,13 - GROUPBOX "Hiding filter patterns",IDC_STATIC,13,123,224,52 - GROUPBOX "Mount point && driver letter",IDC_STATIC,14,64,223,55,WS_GROUP - GROUPBOX "",IDC_STATIC,14,90,223,29 - GROUPBOX "Mounting as User",IDC_STATIC,13,179,224,30 - LTEXT "UID:",IDC_STATIC,31,195,17,9 - LTEXT "GID:",IDC_STATIC,84,195,17,9 - LTEXT "EUID:",IDC_STATIC,164,195,21,9 -END - -IDD_CHANGE_MOUNTPINT DIALOG 0, 0, 206, 129 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "Done",IDOK,148,105,44,14 - GROUPBOX "Change Drive Letters",IDC_STATIC,7,0,192,126 - LTEXT "Mountpoints:",IDC_STATIC,16,15,117,8 - CONTROL "List1",IDC_DRV_LETTER_LIST,"SysListView32",LVS_SMALLICON | LVS_SINGLESEL | LVS_SORTASCENDING | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,14,28,128,93 - PUSHBUTTON "Add...",ID_ADD_MOUNTPOINT,149,30,44,14 - PUSHBUTTON "Change",ID_CHANGE_MOUNTPOINT,149,52,43,14 - PUSHBUTTON "Remove",ID_REMOVE_MOUNTPOINT,149,74,43,14 -END - -IDD_NEW_MOUNTPOINT DIALOG 0, 0, 251, 181 -STYLE DS_SETFONT | WS_POPUP | WS_BORDER -FONT 9, "MS Sans Serif" -BEGIN - PUSHBUTTON "OK",IDOK,191,163,50,14 - LTEXT "Enter or select a new drive lettter :",IDC_STATIC,6,16,151,8 - COMBOBOX IDC_DRVLETTERS_LIST,173,14,70,92,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP - CONTROL "Mount via DefineDosDevice, will be lost after reboot",IDC_DOSDEV_MP, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,48,225,15 - DEFPUSHBUTTON "Cancel",IDCANCEL,110,163,50,14 - CONTROL "",IDC_PERMANENT_MP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,70,11,15 - CONTROL "",IDC_REGISTRY_MP,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,12,112,10,15 - GROUPBOX "Which way to mount:",IDC_STATIC,5,34,237,127 - LTEXT "Automatic mount via MountMgr. Ext2Mgr will assign or remove mountpoints when it detects disk changes. Must NOT close Ext2Mgr. Removable (like USB) disks are recommended to use this method.",IDC_STATIC,23,70,212,34 - LTEXT "Create a permanent MountPoint via Session Manager. It's better use this method for fixed disks. We need create a new item in registry:\r\nHKLM\\System\\CurrentControlSet\\Control\\\r\nSession Manager\\DOS Devices",IDC_STATIC,23,112,208,45 -END - -IDD_PROPERTY_DIALOG DIALOGEX 0, 0, 238, 209 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - DEFPUSHBUTTON "Exit",IDOK,156,185,64,14 - GROUPBOX "DISK",IDC_PROPERTY_DEVICE,7,7,224,91 - LTEXT "Vendor:",IDC_STATIC,13,27,28,8 - EDITTEXT IDC_VENDOR_ID,48,25,71,12,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Product:",IDC_STATIC,13,44,30,8 - EDITTEXT IDC_PRODUCT_ID,48,42,71,12,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Serial:",IDC_STATIC,13,59,27,8 - EDITTEXT IDC_SERIAL_NUMBER,48,58,71,12,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Bus:",IDC_STATIC,130,28,17,8 - EDITTEXT IDC_BUS_TYPE,155,26,65,12,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Type:",IDC_STATIC,130,43,20,8 - EDITTEXT IDC_DEVICE_TYPE,155,42,65,12,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Media:",IDC_STATIC,129,59,22,8 - EDITTEXT IDC_MEDIA_TYPE,155,58,65,12,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Capacity (bytes):",IDC_STATIC,14,78,68,8 - EDITTEXT IDC_TOTAL_SIZE,82,77,137,12,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER - GROUPBOX "DISK",IDC_PROPERTY_SDEV,7,101,224,103 - LTEXT "Status:",IDC_STATIC,14,123,33,8 - EDITTEXT IDC_SDEV_STATUS,70,121,149,12,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Mount points:",IDC_STATIC,14,139,53,8 - EDITTEXT IDC_MOUNT_POINTS,70,138,84,12,ES_AUTOHSCROLL | ES_READONLY - PUSHBUTTON "Change",IDC_SDEV_CHANGE_MP,188,135,32,14,BS_LEFT,WS_EX_STATICEDGE - LTEXT "File system:",IDC_STATIC,14,155,51,8 - EDITTEXT IDC_FILE_SYSTEM,69,152,85,12,ES_AUTOHSCROLL | ES_READONLY - PUSHBUTTON "Ext2 Properties",IDC_SDEV_EXT2_INFO,155,152,65,14,BS_LEFT,WS_EX_STATICEDGE - LTEXT "Capacity:",IDC_STATIC,14,171,42,8 - EDITTEXT IDC_SDEV_SIZE,69,169,85,12,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER - LTEXT "Free space:",IDC_STATIC,14,187,49,8 - EDITTEXT IDC_SDEV_FREE_SIZE,69,186,85,12,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER - PUSHBUTTON "Mount",IDC_SDEV_QUICK_MOUNT,155,135,26,14,BS_LEFT,WS_EX_STATICEDGE -END - -IDD_PERFSTAT_DIALOG DIALOGEX 0, 0, 286, 248 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Ext2Fsd Statistics" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - DEFPUSHBUTTON "Exit",IDOK,248,228,36,18 - GROUPBOX "Memory",IDC_STATIC,1,2,283,117 - GROUPBOX "Irp",IDC_STATIC,1,121,283,103 - LTEXT "Refresh interval (in seconds):",IDC_STATIC,6,233,123,13 - EDITTEXT IDC_PERFSTAT_INTERVAL,146,231,36,12,ES_AUTOHSCROLL - GROUPBOX "",IDC_STATIC,1,223,187,23,0,WS_EX_TRANSPARENT - CONTROL "List1",IDC_MEMORY_LIST,"SysListView32",LVS_REPORT | WS_BORDER | WS_TABSTOP,1,12,283,107,WS_EX_CLIENTEDGE - CONTROL "List2",IDC_IRP_LIST,"SysListView32",LVS_REPORT | WS_BORDER | WS_TABSTOP,1,132,283,90,WS_EX_CLIENTEDGE - DEFPUSHBUTTON "Refresh",ID_QUERYPERF,198,228,36,18 -END - -IDD_PARTITION_TYPE DIALOG 0, 0, 145, 81 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION -CAPTION "Change Partition Type" -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "Change",IDOK,97,60,39,17 - PUSHBUTTON "Cancel",IDCANCEL,10,60,41,17 - COMBOBOX IDC_PARTTION_TYPE_LIST,33,35,97,86,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - GROUPBOX "Partition Type",IDC_STATIC,9,18,127,36 - LTEXT "Static",IDC_PARTITION_NAME,2,3,141,12 -END - -IDD_REMOVE_DEADLETTER DIALOG 0, 0, 192, 139 -STYLE DS_SETFONT | WS_POPUP | WS_CAPTION -CAPTION "Remove Dead Driver Letter" -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "Remove",IDOK,147,122,43,14 - DEFPUSHBUTTON "Reload",ID_RELOAD_DL,95,122,42,14 - PUSHBUTTON "Exit",IDCANCEL,2,122,50,14 - GROUPBOX "Please select a driver letter to remove:",IDC_STATIC,2,8,188,55 - COMBOBOX IDC_DEAD_LETTER_LIST,10,25,170,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - GROUPBOX "Automatical removal:",IDC_STATIC,2,66,188,49 - CONTROL "",IDC_AUTO_REMOVAL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,80,9,10 - LTEXT "When Ext2Mgr detects device change, it will reload system settings and then remove dead driver letters for FIXED devices.",IDC_AUTOREMOVALTEXT,28,78,152,34 - CONTROL "Keep it for next reboot or device plug",IDC_REMOVAL_CURRENT, - "Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,9,46,168,11 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_DONATE_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 261 - TOPMARGIN, 7 - BOTTOMMARGIN, 217 - END - - IDD_ABOUTBOX, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 306 - TOPMARGIN, 7 - BOTTOMMARGIN, 222 - END - - IDD_EXT2MGR_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 5 - RIGHTMARGIN, 400 - TOPMARGIN, 1 - BOTTOMMARGIN, 273 - END - - IDD_SERVICE_MANAGE, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 231 - TOPMARGIN, 7 - BOTTOMMARGIN, 230 - END - - IDD_FORMAT, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 196 - TOPMARGIN, 7 - BOTTOMMARGIN, 191 - END - - IDD_EXT2_ATTR, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 244 - TOPMARGIN, 7 - END - - IDD_CHANGE_MOUNTPINT, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 199 - BOTTOMMARGIN, 126 - END - - IDD_NEW_MOUNTPOINT, DIALOG - BEGIN - LEFTMARGIN, 1 - RIGHTMARGIN, 247 - TOPMARGIN, 7 - BOTTOMMARGIN, 177 - END - - IDD_PROPERTY_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 231 - TOPMARGIN, 7 - END - - IDD_PERFSTAT_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 1 - RIGHTMARGIN, 284 - TOPMARGIN, 2 - BOTTOMMARGIN, 246 - END - - IDD_PARTITION_TYPE, DIALOG - BEGIN - LEFTMARGIN, 2 - RIGHTMARGIN, 143 - TOPMARGIN, 2 - END - - IDD_REMOVE_DEADLETTER, DIALOG - BEGIN - LEFTMARGIN, 2 - RIGHTMARGIN, 190 - TOPMARGIN, 2 - BOTTOMMARGIN, 136 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,0,7,9 - PRODUCTVERSION 3,0,7,9 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "CompanyName", "Ext2Fsd Group (www.ext2fsd.com)" - VALUE "FileDescription", "Ext2 Volume Manager for Windows" - VALUE "FileVersion", "3.0.7.9" - VALUE "InternalName", "Ext2Mgr" - VALUE "LegalCopyright", "Copyright (C) 2016 Ext2Fsd Group" - VALUE "OriginalFilename", "Ext2Mgr.exe" - VALUE "ProductName", "Ext2 Volume Manager for Windows" - VALUE "ProductVersion", "3.0.7.9" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_TRAY MENU -BEGIN - POPUP "Tray" - BEGIN - MENUITEM "Show Main Window", ID_SHOW_MAIN - MENUITEM SEPARATOR - MENUITEM "Service Management", ID_SERVICE - MENUITEM "Ext2Fsd Statistics", ID_PERFSTAT - MENUITEM SEPARATOR - MENUITEM "About Ext2Mgr", ID_ABOUT - MENUITEM SEPARATOR - MENUITEM "Exit ...", ID_EXIT - END -END - -IDR_MENU MENU -BEGIN - POPUP "&File" - BEGIN - MENUITEM "&Enable Ext2Mgr autostart ", ID_ENABLE_AUTOSTART - MENUITEM "&Disable Ext2Mgr autostart", ID_DISABLE_AUTOSTART - MENUITEM SEPARATOR - MENUITEM "E&xit", ID_EXIT - END - POPUP "&Edit" - BEGIN - MENUITEM "&Copy Everything to Clipboard", ID_COPYALL - END - POPUP "&Tools" - BEGIN - MENUITEM "&Reload and Refresh\tF5", ID_REFRESH - MENUITEM SEPARATOR - MENUITEM "&Service Management\tF7", ID_SERVICE - MENUITEM "Ext2Fsd S&tatistics\tF8", ID_PERFSTAT - MENUITEM SEPARATOR - MENUITEM "Remove &Dead Letters\tF9", ID_REMOVE_DEAD_LETTER - MENUITEM SEPARATOR - MENUITEM "&Ext2 Volume Management\tF3", ID_CHANGE - MENUITEM "&Mountpoint Management\tF10", ID_DRV_LETTER - MENUITEM SEPARATOR - MENUITEM "&Flush Cache to Disk\tF11", ID_FLUSH_BUFFER - MENUITEM "&Change Partition Type\tF12", ID_CHANGE_PARTTYPE - MENUITEM SEPARATOR - MENUITEM "Show &Properties\tF6", ID_PROPERTY - END - POPUP "&Help" - BEGIN - MENUITEM "&Help\tF1", ID_HELP - MENUITEM SEPARATOR - MENUITEM "&About\tF2", ID_ABOUT - MENUITEM SEPARATOR - MENUITEM "&Donate", ID_DONATE - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON "res\\Ext2Mgr.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDB_ABOUT_SCREEN BITMAP "res\\about.bmp" -IDI_FLOPPY BITMAP "res\\floppy.bmp" -IDI_CDROM BITMAP "res\\cdrom.bmp" -IDI_DISK BITMAP "res\\disk.bmp" -IDI_DVD BITMAP "res\\dvd.bmp" -IDI_DYNAMIC BITMAP "res\\dynamic.bmp" -IDR_STANDARDBAR BITMAP "res\\toolbar.bmp" -IDB_ABOUT_SMALL BITMAP "res\\abouts.bmp" -IDB_LINE_SEP BITMAP "res\\line.bmp" -IDB_SMALL_PENGUIN BITMAP "res\\images\\smallpenguin.bmp" -IDB_BIG_PENGUIN BITMAP "res\\images\\penguin.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDR_AKEY_EXT2MGR ACCELERATORS -BEGIN - VK_F1, ID_HELP, VIRTKEY, NOINVERT - VK_F10, ID_DRV_LETTER, VIRTKEY, NOINVERT - VK_F11, ID_FLUSH_BUFFER, VIRTKEY, NOINVERT - VK_F12, ID_CHANGE_PARTTYPE, VIRTKEY, NOINVERT - VK_F2, ID_ABOUT, VIRTKEY, NOINVERT - VK_F3, ID_CHANGE, VIRTKEY, NOINVERT - VK_F4, ID_DRV_QUICK_MOUNT, VIRTKEY, NOINVERT - VK_F5, ID_REFRESH, VIRTKEY, NOINVERT - VK_F6, ID_PROPERTY, VIRTKEY, NOINVERT - VK_F7, ID_SERVICE, VIRTKEY, NOINVERT - VK_F8, ID_PERFSTAT, VIRTKEY, NOINVERT - VK_F9, ID_REMOVE_DEAD_LETTER, VIRTKEY, NOINVERT -END - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDS_ABOUTBOX "&About Ext2 Volume Manager ..." -END - -STRINGTABLE -BEGIN - ID_ABOUT "About Ext2 Volume Manger\tF2" - ID_NEW "create a new configuration file" - ID_CHANGE "Change the settings of the selected driver or volume" - ID_REFRESH "Refresh and reload the disks and volumes" - ID_EXIT "Quit ext2 volume manager ..." - ID_SERVICE "Manage the ext2fsd driver startup information" - ID_FORMAT "Format the selected volume or parititon" - ID_PROPERTY "Show the information and property of the selected volume or partition" - ID_COPY "Copy the only selected item to clipboard" - ID_SHOW_MAIN "Show the main window of Ext2Mgr" - ID_DRV_LETTER "Assign or change driver letters of selected volume or disk" - ID_DONATE "Donate to Ext2Fsd group" -END - -STRINGTABLE -BEGIN - ID_INSTALL_SERVICE "Install Ext2Mgr as a service (with autostart enabled)" - ID_REMOVE_SERVICE "Remove Ext2Mgr service (disable service autostart)" - ID_ENABLE_AUTOSTART "Let Ext2Mgr automatically start when system boots" - ID_DISABLE_AUTOSTART "Don't want Ext2Mgr automatically start when system boots" - ID_PERFSTAT "Statistics of memory allocations and Irp processing" - ID_COPYALL "Copy all disks/partitions/cdrom/volumes information to clipboard" - ID_FLUSH_BUFFER "Sync all dirty cache to disk" - ID_CHANGE_PARTTYPE "Change the partition type/id" - ID_REMOVE_DEAD_LETTER "Remove the dead driver letter" - ID_DRV_QUICK_MOUNT "Assign a driver letter to selected volume or disk" -END - -STRINGTABLE -BEGIN - ID_HELP "Help" - IDS_LISTITEM_FILESYSTEM "File system" - IDS_LISTITEM_VOLUME "Volume" - IDS_LISTITEM_TYPE "Type" - IDS_LISTITEM_TOTALSIZE "Total size" - IDS_LISTITEM_USEDSIZE "Used size" - IDS_LISTITEM_CODEPAGE "Codepage" - IDS_LISTITEM_DEVOBJ "Physical object" - IDS_LISTITEM_PARTID "Partition type" - IDS_DISK_TYPE_BASIC "Basic" -END - -STRINGTABLE -BEGIN - IDS_DISK_TYPE_DYN "Dynamic" - IDS_DONATE_DECLARE "\r\nExt2Fsd is an open source software. It acts as a bridge between Windows and Linux, making life easier to access Linux partitions under Windows systems.\r\n\r\nCurrently there are still lots of jobs left to make a fully functional file system driver, such as complete ext3 support, Linux LVM, Windows Vista, Longhorn. Especially Vista and Longhorn will need driver signing.\r\n\r\nNow I'm the only part-time developer. It needs about two full time developers to implement that job and also it needs some hardwares such SMP system, SCSI array for debugging and testing.\r\n\r\nI'll try my best to make it out. I'm dreaming of that day.\r\n\r\nAny help will be highly appreciated. Thanks and best wishes.\r\n\r\n\r\nYours sincerely,\r\nMatt" - IDS_SHOW_PROPERTY "Show Properties\tF6" - IDS_COPY_ITEM_TO_CLIP "&Copy to Clipboard" - IDS_CHANGE_DRVLETTER "Change Drive Letter\tF10" - IDS_EXT2_MANAGEMENT "Ext2 Management\tF3" - IDS_FLUSH_BUFFER "Flush Cache to Disk\tF11" - IDS_CHANGE_PARTID "Change Partition Type\tF12" - IDS_RELOAD_REFRESH "Reload and Refresh\tF5" - IDS_PERFMEM_STAT "Ext2Fsd Statistics\tF8" - IDS_SERVICE_MANAGE "Service Management\tF7" - IDS_REMOVE_DEAD_LETTER "Remove Dead Letters\tF9" - IDS_PERFSTAT_NAME "Name" - IDS_PERFSTAT_UNIT "Unit" - IDS_PERFSTAT_CURRENT "Current" - IDS_PERFSTAT_SIZE "Memory size" -END - -STRINGTABLE -BEGIN - IDS_PERFSTAT_TOTAL "Total allocations" - IDS_PERFSTAT_PROCESSING "Being processed" - IDS_PERSTAT_PROCESSED "Ever processed" - IDS_DRV_QUICK_MOUNT "Assign Drive Letter\tF4" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_SPLITTER_RESOURCES -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\Ext2Mgr.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Chinese (P.R.C.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS) +#ifdef _WIN32 +LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED +#pragma code_page(936) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "#define _AFX_NO_SPLITTER_RESOURCES\r\n" + "#define _AFX_NO_OLE_RESOURCES\r\n" + "#define _AFX_NO_TRACKER_RESOURCES\r\n" + "#define _AFX_NO_PROPERTY_RESOURCES\r\n" + "\r\n" + "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" + "#ifdef _WIN32\r\n" + "LANGUAGE 9, 1\r\n" + "#pragma code_page(1252)\r\n" + "#endif //_WIN32\r\n" + "#include ""res\\Ext2Mgr.rc2"" // non-Microsoft Visual C++ edited resources\r\n" + "#include ""afxres.rc"" // Standard components\r\n" + "#endif\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ABOUTBOX DIALOGEX 0, 0, 313, 222 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "About Ext2 Volume Manager" +FONT 8, "MS Sans Serif", 0, 0, 0x1 +BEGIN + DEFPUSHBUTTON "Í˳ö",IDOK,233,198,31,20,WS_GROUP + LTEXT "Ext2Mgr: 2.0",IDC_PROGRAM,50,207,171,11,SS_NOPREFIX + GROUPBOX "",IDC_ABOUT_SHOW,7,6,299,185,NOT WS_VISIBLE + DEFPUSHBUTTON "¾èÔù",ID_DONATE,269,198,31,20,WS_GROUP + LTEXT "Ext2Fsd: 0.44",IDC_DRIVER,50,197,171,11,SS_NOPREFIX + CONTROL 184,IDC_EXT2FSD,"Static",SS_BITMAP | SS_NOTIFY | SS_REALSIZEIMAGE | SS_SUNKEN,13,194,23,28,WS_EX_DLGMODALFRAME +END + +IDD_CHANGE_MOUNTPINT DIALOG 0, 0, 206, 129 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "·µ»Ø",IDOK,148,105,44,14 + GROUPBOX "¸ü¸ÄÅÌ·ûÉèÖãº",IDC_STATIC,7,0,192,126 + LTEXT "ÅÌ·ûÁбí:",IDC_STATIC,16,15,117,8 + CONTROL "List1",IDC_DRV_LETTER_LIST,"SysListView32",LVS_SMALLICON | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,14,28,128,93 + PUSHBUTTON "Ìí¼Ó",ID_ADD_MOUNTPOINT,149,30,44,14 + PUSHBUTTON "¸ü¸Ä",ID_CHANGE_MOUNTPOINT,149,52,43,14 + PUSHBUTTON "ɾ³ý",ID_REMOVE_MOUNTPOINT,149,74,43,14 +END + +IDD_DONATE_DIALOG DIALOGEX 0, 0, 268, 185 +STYLE DS_SETFONT | WS_POPUP | WS_CAPTION +CAPTION "Ö§³ÖExt2Fsd" +FONT 8, "MS Sans Serif", 0, 0, 0x0 +BEGIN + DEFPUSHBUTTON "·µ»Ø",IDOK,223,141,32,36 + GROUPBOX "Ö£ÖØÉùÃ÷",IDC_STATIC,7,7,254,90 + EDITTEXT IDC_DECLARE,15,23,238,66,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | ES_WANTRETURN | WS_VSCROLL + GROUPBOX "¾èÔù·½Ê½",IDC_STATIC,7,103,254,78 + LTEXT "ͨ¹ýSourceForgeÍøÕ¾¾èÔù",IDC_VIA_SOURCEFORGE,15,145,101,12 + LTEXT "ͨ¹ýPayPal¾èÔù",IDC_VIA_PAYPAL,15,164,90,12 + LTEXT "ͨ¹ýTaobao¾èÔù: mattwu@163.com",IDC_VIA_TAOBAO,15,124,135,12 +END + +IDD_EXT2_ATTR DIALOG 0, 0, 251, 236 +STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "±£´æ²¢Í˳ö",IDOK,159,215,61,17 + CONTROL "ÉèÖÃΪֻ¶Á£¬²»¿Éд",IDC_READ_ONLY,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,27,39,134,10 + COMBOBOX IDC_COMBO_CODEPAGE,184,37,49,106,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + CONTROL "×Ô¶¯¼ÓÔØÅÌ·û£ºÖ÷ÒªÕë¶Ô¿ÉÒÆ¶¯É豸",IDC_AUTOMOUNT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,27,79,147,10 + COMBOBOX IDC_COMBO_AUTOMP,196,76,36,96,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + CONTROL "¹Ì¶¨ÅÌ·û£º¶Ô¹Ì¶¨´ÅÅ̽¨Òé²ÉÓôËÖÖ·½Ê½",IDC_FIXMOUNT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,27,102,165,10 + COMBOBOX IDC_COMBO_DRVLETTER,196,100,36,107,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + EDITTEXT IDC_EXT2_PREFIX,109,138,108,14 + EDITTEXT IDC_EXT2_SUFFIX,109,157,108,14 + EDITTEXT IDC_EDIT_UID,53,192,25,12,ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_GID,105,192,25,12,ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_EUID,189,192,25,12,ES_AUTOHSCROLL + PUSHBUTTON "È¡ÏûËùÓи͝",IDCANCEL,25,215,60,17 + GROUPBOX "Ext2Îļþϵͳ¾íÉèÖãº",IDC_STATIC,7,7,237,205 + GROUPBOX "¾íÊôÐÔ",IDC_STATIC,15,22,149,37,WS_GROUP + GROUPBOX "ÓïÖÖ±àÂë",IDC_STATIC,173,22,64,37,WS_GROUP + LTEXT "ÎļþÃûÒÔ´ËΪ¿ªÍ·£º",IDC_STATIC,29,140,75,13 + LTEXT "ÎļþÃûÒÔ´ËΪ½áÊø£º",IDC_STATIC,29,159,74,13 + GROUPBOX "Òþ²ØÖ¸¶¨Îļþ",IDC_STATIC,13,123,224,52 + GROUPBOX "ÅÌ·ûÉèÖÃ",IDC_STATIC,14,64,223,55,WS_GROUP + GROUPBOX "",IDC_STATIC,14,90,223,29 + GROUPBOX "Ö¸¶¨¼ÓÔØÕʺÅ",IDC_STATIC,13,177,224,30 + LTEXT "UID:",IDC_STATIC,31,193,17,9 + LTEXT "GID:",IDC_STATIC,84,193,17,9 + LTEXT "EUID:",IDC_STATIC,164,193,21,9 +END + +IDD_EXT2MGR_DIALOG DIALOGEX 0, 0, 407, 277 +STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_APPWINDOW +CAPTION "Ext2 Volume Manager" +MENU IDR_MENU +FONT 8, "MS Sans Serif", 0, 0, 0x1 +BEGIN + CONTROL "List1",IDC_VOLUME_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_AUTOARRANGE | LVS_ALIGNLEFT | WS_BORDER | WS_GROUP | WS_TABSTOP,5,1,395,113,WS_EX_CLIENTEDGE + CONTROL "List1",IDC_DISK_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_OWNERDRAWFIXED | LVS_ALIGNLEFT | WS_BORDER | WS_GROUP | WS_TABSTOP,5,115,395,149,WS_EX_CLIENTEDGE +END + +IDD_NEW_MOUNTPOINT DIALOG 0, 0, 212, 158 +STYLE DS_SETFONT | WS_POPUP | WS_BORDER +FONT 9, "MS Sans Serif" +BEGIN + PUSHBUTTON "¼ÓÔØ²¢Í˳ö",IDOK,154,140,50,14 + LTEXT "Ñ¡ÔñÒªÌí¼ÓµÄÅÌ·û :",IDC_STATIC,6,16,97,8 + COMBOBOX IDC_DRVLETTERS_LIST,134,14,70,92,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP + CONTROL "ͨ¹ýDefineDosDevice£¬ÖØÆôºó»áʧЧ",IDC_DOSDEV_MP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,48,188,15 + DEFPUSHBUTTON "È¡Ïû²Ù×÷",IDCANCEL,66,140,50,14 + CONTROL "",IDC_PERMANENT_MP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,67,10,15 + CONTROL "",IDC_REGISTRY_MP,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,12,93,11,15 + GROUPBOX "Ìí¼Ó·½Ê½£º",IDC_STATIC,5,34,202,101 + LTEXT "ͨ¹ýMountMgr¼°Ext2MgrÀ´×Ô¶¯¼ÓÔØÅÌ·û£¬ÊÊÓÃÓÚÒÆ¶¯Ó²ÅÌ£¬ÐèÒªExt2MgrÒ»Ö±ÔËÐÐ",IDC_STATIC,24,69,166,20 + LTEXT "ͨ¹ýSession Manager×Ô¶¯¼ÓÔØ£¬ÊʺÏÓڹ̶¨´ÅÅÌ£¬±¾²Ù×÷»áÔÚ×¢²á±íÖд´½¨Ò»¸ö×Ö´®Ï\r\nHKLM\\System\\CurrentControlSet\\Control\\\r\nSession Manager\\DOS Devices",IDC_STATIC,24,94,169,36 +END + +IDD_PARTITION_TYPE DIALOG 0, 0, 149, 85 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION +CAPTION "¸ü¸Ä·ÖÇøÀàÐÍ" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "¸ü¸Ä²¢Í˳ö",IDOK,91,61,45,18 + PUSHBUTTON "È¡Ïû²Ù×÷",IDCANCEL,10,62,46,17 + COMBOBOX IDC_PARTTION_TYPE_LIST,33,35,97,86,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + GROUPBOX "Ñ¡Ôñ·ÖÇøÀàÐÍ",IDC_STATIC,9,18,127,36 + LTEXT "Static",IDC_PARTITION_NAME,2,3,145,12 +END + +IDD_PERFSTAT_DIALOG DIALOGEX 0, 0, 286, 248 +STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Ext2Fsd ͳ¼ÆÐÅÏ¢" +FONT 8, "MS Sans Serif", 0, 0, 0x1 +BEGIN + DEFPUSHBUTTON "·µ»Ø",IDOK,229,228,46,18 + GROUPBOX "ÄÚ´æ·ÖÅäͳ¼Æ",IDC_STATIC,1,2,283,117 + GROUPBOX "ÄÚºËIrpͳ¼Æ",IDC_STATIC,1,121,283,103 + LTEXT "×Ô¶¯Ë¢ÐÂʱ¼ä¼ä¸ô(Ãë):",IDC_STATIC,6,233,87,13 + EDITTEXT IDC_PERFSTAT_INTERVAL,97,231,36,12,ES_AUTOHSCROLL + GROUPBOX "",IDC_STATIC,1,223,137,23,0,WS_EX_TRANSPARENT + CONTROL "List1",IDC_MEMORY_LIST,"SysListView32",LVS_REPORT | WS_BORDER | WS_TABSTOP,1,12,283,107,WS_EX_CLIENTEDGE + CONTROL "List2",IDC_IRP_LIST,"SysListView32",LVS_REPORT | WS_BORDER | WS_TABSTOP,1,132,283,90,WS_EX_CLIENTEDGE + DEFPUSHBUTTON "ÊÖ¶¯Ë¢ÐÂ",ID_QUERYPERF,143,228,46,18 +END + +IDD_PROPERTY_DIALOG DIALOGEX 0, 0, 238, 209 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP +FONT 8, "MS Sans Serif", 0, 0, 0x1 +BEGIN + DEFPUSHBUTTON "·µ»ØÖ÷´°¿Ú",IDOK,156,185,65,14 + GROUPBOX "DISK",IDC_PROPERTY_DEVICE,7,7,224,91 + LTEXT "Éú²úÉÌ:",IDC_STATIC,13,27,28,8 + EDITTEXT IDC_VENDOR_ID,48,25,71,12,ES_AUTOHSCROLL | ES_READONLY + LTEXT "ÐͺÅ:",IDC_STATIC,13,44,20,8 + EDITTEXT IDC_PRODUCT_ID,48,42,71,12,ES_AUTOHSCROLL | ES_READONLY + LTEXT "ÐòºÅ:",IDC_STATIC,13,59,27,8 + EDITTEXT IDC_SERIAL_NUMBER,48,58,71,12,ES_AUTOHSCROLL | ES_READONLY + LTEXT "×ÜÏß:",IDC_STATIC,130,28,20,8 + EDITTEXT IDC_BUS_TYPE,155,26,65,12,ES_AUTOHSCROLL | ES_READONLY + LTEXT "ÀàÐÍ:",IDC_STATIC,130,43,20,8 + EDITTEXT IDC_DEVICE_TYPE,155,42,65,12,ES_AUTOHSCROLL | ES_READONLY + LTEXT "½éÖÊ:",IDC_STATIC,129,59,22,8 + EDITTEXT IDC_MEDIA_TYPE,155,58,65,12,ES_AUTOHSCROLL | ES_READONLY + LTEXT "´ÅÅÌÈÝÁ¿ (×Ö½Ú):",IDC_STATIC,14,78,61,8 + EDITTEXT IDC_TOTAL_SIZE,82,77,138,12,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER + GROUPBOX "DISK",IDC_PROPERTY_SDEV,7,101,224,103 + LTEXT "״̬:",IDC_STATIC,14,123,51,8 + EDITTEXT IDC_SDEV_STATUS,70,121,151,12,ES_AUTOHSCROLL | ES_READONLY + LTEXT "ÅÌ·û:",IDC_STATIC,14,139,54,8 + EDITTEXT IDC_MOUNT_POINTS,70,138,83,12,ES_AUTOHSCROLL | ES_READONLY + PUSHBUTTON "¸ü¸ÄÅÌ·û",IDC_SDEV_CHANGE_MP,183,134,38,14,BS_LEFT,WS_EX_STATICEDGE + LTEXT "Îļþϵͳ:",IDC_STATIC,14,155,51,8 + EDITTEXT IDC_FILE_SYSTEM,69,152,83,12,ES_AUTOHSCROLL | ES_READONLY + PUSHBUTTON "¸ü¸ÄExt2¾íÉèÖÃ",IDC_SDEV_EXT2_INFO,156,152,66,14,BS_LEFT,WS_EX_STATICEDGE + LTEXT "·ÖÇøÈÝÁ¿:",IDC_STATIC,14,171,42,8 + EDITTEXT IDC_SDEV_SIZE,69,169,84,12,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER + LTEXT "¿ÉÓÿռä:",IDC_STATIC,14,187,49,8 + EDITTEXT IDC_SDEV_FREE_SIZE,69,186,84,12,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER + PUSHBUTTON "¹ÒÔØ",IDC_SDEV_QUICK_MOUNT,156,134,24,15,BS_LEFT,WS_EX_STATICEDGE +END + +IDD_REMOVE_DEADLETTER DIALOG 0, 0, 208, 122 +STYLE DS_SETFONT | WS_POPUP | WS_CAPTION +CAPTION "ɾ³ýÎÞЧÅÌ·û" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "ɾ³ý",IDOK,161,105,43,14 + DEFPUSHBUTTON "ÖØÐÂËÑË÷",ID_RELOAD_DL,91,105,46,14 + PUSHBUTTON "·µ»Ø",IDCANCEL,2,105,50,14 + GROUPBOX "Ñ¡ÔñҪɾ³ýµÄÅÌ·û:",IDC_STATIC,2,8,204,52 + COMBOBOX IDC_DEAD_LETTER_LIST,20,25,175,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + GROUPBOX "×Ô¶¯É¾³ý:",IDC_STATIC,2,64,204,30 + CONTROL "",IDC_AUTO_REMOVAL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,78,9,10 + LTEXT "µ±Ext2Mgr¼ì²âµ½ÉèÖñ仯ʱ£¬×Ô¶¯É¾³ýÎÞЧÅÌ·û",IDC_AUTOREMOVALTEXT,23,79,177,12 + CONTROL "Ö»´Ó±¾´Î»á»°ÖÐÒÆ³ý£¬±£³ÖÖØÆôºóÒÀÈ»ÓÐЧ",IDC_REMOVAL_CURRENT,"Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,19,43,174,12 +END + +IDD_SERVICE_MANAGE DIALOG 0, 0, 238, 235 +STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "¸ü¸Ä²¢Í˳ö",IDOK,170,214,47,17 + GROUPBOX "Ext2Fsd Çý¶¯ÉèÖÃ",IDC_STATIC,7,7,224,203 + GROUPBOX "µ±Ç°×´Ì¬",IDC_STATIC,19,21,201,36,WS_GROUP + EDITTEXT IDC_SERVICE_STATUS,26,35,145,14,ES_READONLY + PUSHBUTTON "ÆôÓÃ",IDC_START_SERVICE,179,33,34,17 + GROUPBOX "Æô¶¯·½Ê½",IDC_STATIC,19,63,116,37 + COMBOBOX IDC_COMBO_STARTUP,29,80,101,88,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + GROUPBOX "È«¾ÖÓïÑÔ±àÂë",IDC_STATIC,141,63,78,38 + COMBOBOX IDC_COMBO_CODEPAGE,149,81,60,111,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP + GROUPBOX "È«¾ÖĬÈϲÎÊýÉèÖÃ",IDC_STATIC,18,104,201,102,WS_GROUP + CONTROL "ÒÔÖ»¶Á·½Ê½¼ÓÔØ·ÖÇø£¨·ÖÇø¿ÉÒÔÓжÀÁ¢µÄÉèÖã©",IDC_READ_ONLY,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,32,120,181,10 + CONTROL "Ö§³ÖExt3µÄд²Ù×÷(ºöÂÔÈÕÖ¾¼°Ä¿Â¼Ë÷Òý)",IDC_EXT3_WRITABLE,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,32,136,170,10 + PUSHBUTTON "È¡Ïû",IDCANCEL,29,214,38,17 + EDITTEXT IDC_GLOBAL_PREFIX,100,167,107,14 + EDITTEXT IDC_GLOBAL_SUFFIX,99,187,108,14 + LTEXT "ÎļþÃûÒþ²ØÇ°×º:",IDC_STATIC,32,169,67,13 + LTEXT "ÎļþÃûÒþ²Øºó׺:",IDC_STATIC,32,188,62,13 + CONTROL "×Ô¶¯·ÖÅäÅÌ·û£¨ÔÚ´ÅÅ̲åÈëʱ£©",IDC_EXT3_AUTOMOUNT,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,32,151,170,10 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_ABOUTBOX, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 306 + TOPMARGIN, 7 + BOTTOMMARGIN, 221 + END + + IDD_CHANGE_MOUNTPINT, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 199 + BOTTOMMARGIN, 126 + END + + IDD_DONATE_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 261 + TOPMARGIN, 7 + END + + IDD_EXT2_ATTR, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 244 + TOPMARGIN, 7 + BOTTOMMARGIN, 232 + END + + IDD_EXT2MGR_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 400 + TOPMARGIN, 1 + BOTTOMMARGIN, 273 + END + + IDD_NEW_MOUNTPOINT, DIALOG + BEGIN + LEFTMARGIN, 1 + RIGHTMARGIN, 211 + TOPMARGIN, 7 + BOTTOMMARGIN, 154 + END + + IDD_PARTITION_TYPE, DIALOG + BEGIN + LEFTMARGIN, 2 + RIGHTMARGIN, 147 + TOPMARGIN, 2 + END + + IDD_PERFSTAT_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 1 + RIGHTMARGIN, 284 + TOPMARGIN, 2 + BOTTOMMARGIN, 246 + END + + IDD_PROPERTY_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 231 + TOPMARGIN, 7 + END + + IDD_REMOVE_DEADLETTER, DIALOG + BEGIN + LEFTMARGIN, 2 + RIGHTMARGIN, 206 + TOPMARGIN, 2 + BOTTOMMARGIN, 119 + END + + IDD_SERVICE_MANAGE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 231 + TOPMARGIN, 7 + BOTTOMMARGIN, 231 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 3,0,7,9 + PRODUCTVERSION 3,0,7,9 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "Ext2Fsd Group (www.ext2fsd.com)" + VALUE "FileDescription", "Ext2 Volume Manager for Windows" + VALUE "FileVersion", "3.0.7.9" + VALUE "InternalName", "Ext2Mgr" + VALUE "LegalCopyright", "Copyright (C) 2016 Ext2Fsd Group" + VALUE "OriginalFilename", "Ext2Mgr.exe" + VALUE "ProductName", "Ext2 Volume Manager for Windows" + VALUE "ProductVersion", "3.0.7.9" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDR_MENU MENU +BEGIN + POPUP "Îļþ(&F)" + BEGIN + MENUITEM "ÉèÖÃΪ×Ô¶¯Æô¶¯(&E)", ID_ENABLE_AUTOSTART + MENUITEM "È¡Ïû×Ô¶¯Æô¶¯(&D)", ID_DISABLE_AUTOSTART + MENUITEM SEPARATOR + MENUITEM "Í˳ö±¾³ÌÐò(&x)", ID_EXIT + END + POPUP "±à¼­(&E)" + BEGIN + MENUITEM "¸´ÖÆËùÓÐÐÅÏ¢ÖÁ¼ôÌù°å(&C)", ID_COPYALL + END + POPUP "¹¤¾ßÓëÉèÖÃ(&T)" + BEGIN + MENUITEM "ÖØÐ¼ÓÔØÏµÍ³ÐÅÏ¢(&R)\tF5", ID_REFRESH + MENUITEM SEPARATOR + MENUITEM "ÅäÖÃÎļþϵͳÇý¶¯(&S)\tF7", ID_SERVICE + MENUITEM "ÐÔÄܼ°ÄÚ´æ·ÖÅäͳ¼Æ(&T)\tF8", ID_PERFSTAT + MENUITEM SEPARATOR + MENUITEM "ÅäÖÃExt2¾íÊôÐÔ(&E)\tF3", ID_CHANGE + MENUITEM "ÅÌ·û¹ÜÀí¼°ÉèÖÃ(&M)\tF10", ID_DRV_LETTER + MENUITEM "ɾ³ýÎÞЧÅÌ·û(&D)\tF7", ID_REMOVE_DEAD_LETTER + MENUITEM SEPARATOR + MENUITEM "Ç¿ÖÆ±£´æÏµÍ³»º³å(&F)\tF9", ID_FLUSH_BUFFER + MENUITEM "¸ü¸Ä·ÖÇøÀàÐÍID(&C)\tF11", ID_CHANGE_PARTTYPE + MENUITEM SEPARATOR + MENUITEM "ÏÔʾ´ÅÅÌ»ò·ÖÇøÊôÐÔ(&P)\tF12", ID_PROPERTY + END + POPUP "°ïÖú(&H)" + BEGIN + MENUITEM "°ïÖúÐÅÏ¢(&H)\tF1", ID_HELP + MENUITEM SEPARATOR + MENUITEM "¹ØÓÚ±¾³ÌÐò(&A)\tF2", ID_ABOUT + MENUITEM SEPARATOR + MENUITEM "Ö§³ÖÎÒÃÇ...(&D)", ID_DONATE + END +END + +IDR_TRAY MENU +BEGIN + POPUP "Tray" + BEGIN + MENUITEM "ÏÔʾÖ÷´°¿Ú", ID_SHOW_MAIN + MENUITEM SEPARATOR + MENUITEM "ÅäÖÃÎļþϵͳÇý¶¯", ID_SERVICE + MENUITEM "ÐÔÄܼ°ÄÚ´æ·ÖÅäͳ¼Æ", ID_PERFSTAT + MENUITEM SEPARATOR + MENUITEM "¹ØÓÚ Ext2Mgr", ID_ABOUT + MENUITEM SEPARATOR + MENUITEM "Í˳ö±¾³ÌÐò ...", ID_EXIT + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// RCDATA +// + +IDR_RCDAT_SRV RCDATA "Ext2Srv.exe" + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE +BEGIN + IDS_ABOUTBOX "&About Ext2 Volume Manager ..." +END + +STRINGTABLE +BEGIN + ID_ABOUT "About Ext2 Volume Manger\tF2" + ID_NEW "create a new configuration file" + ID_CHANGE "Change the settings of the selected driver or volume" + ID_REFRESH "Refresh and reload the disks and volumes" + ID_EXIT "Quit ext2 volume manager ..." + ID_SERVICE "Manage the ext2fsd driver startup information" + ID_FORMAT "Format the selected volume or parititon" + ID_PROPERTY "Show the information and property of the selected volume or partition" + ID_COPY "Copy the only selected item to clipboard" + ID_SHOW_MAIN "Show the main window of Ext2Mgr" + ID_DRV_LETTER "Assign or change driver letters of selected volume or disk" + ID_DONATE "Donate to Ext2Fsd group" +END + +STRINGTABLE +BEGIN + ID_INSTALL_SERVICE "Install Ext2Mgr as a service (with autostart enabled)" + ID_REMOVE_SERVICE "Remove Ext2Mgr service (disable service autostart)" + ID_ENABLE_AUTOSTART "Let Ext2Mgr automatically start when system boots" + ID_DISABLE_AUTOSTART "Don't want Ext2Mgr automatically start when system boots" + ID_PERFSTAT "Statistics of memory allocations and Irp processing" + ID_COPYALL "Copy all disks/partitions/cdrom/volumes information to clipboard" + ID_FLUSH_BUFFER "Sync all dirty cache to disk" + ID_CHANGE_PARTTYPE "Change the partition type/id" + ID_REMOVE_DEAD_LETTER "Remove the dead driver letter" + ID_DRV_QUICK_MOUNT "Assign a driver letter to selected volume or disk" + ID_DRV_QUICK_REMOVE "Remove 1st driver letter of selected volume or disk" +END + +STRINGTABLE +BEGIN + ID_HELP "Help" + IDS_LISTITEM_FILESYSTEM "Îļþϵͳ" + IDS_LISTITEM_VOLUME "¾í" + IDS_LISTITEM_TYPE "ÀàÐÍ" + IDS_LISTITEM_TOTALSIZE "×ÜÈÝÁ¿" + IDS_LISTITEM_USEDSIZE "ÒÑʹÓÃ" + IDS_LISTITEM_CODEPAGE "ÓïÑÔ±àÂë" + IDS_LISTITEM_DEVOBJ "É豸Ãû" + IDS_LISTITEM_PARTID "·ÖÇøÀàÐÍ" + IDS_DISK_TYPE_BASIC "»ù±¾" +END + +STRINGTABLE +BEGIN + IDS_DISK_TYPE_DYN "¶¯Ì¬" + IDS_DONATE_DECLARE "\r\nÊÀ½çÐèÒªÈÈÐij¦£¬Ò»¼ÒÈËÒ²²»ËµÁ½¼Ò»°£º\r\n\r\nÓÐÇ®³öÇ®£¬ÓÐÁ¦³öÁ¦£¡£º-£©\r\n\r\nÆäʵ£¬½«Ê¹Óùý³ÌÖз¢ÏÖµÄÎÊÌâ»òÕߺõĽ¨ÒéÖ±½Ó·¢¸øÎÒ¾ÍÒÑÊǶÔExt2Fsd×îºÃµÄÖ§³ÖÁË¡£¼òÑÔÖ®£¬¶àÓö෴À¡¶àÐû´«£¡\r\n\r\nMatt Wu" + IDS_SHOW_PROPERTY "´ÅÅ̼°·ÖÇøÊôÐÔ\tF6" + IDS_COPY_ITEM_TO_CLIP "¸´ÖƵ±Ç°ÄÚÈÝ(&C)" + IDS_CHANGE_DRVLETTER "¸ü¸Ä×°ÅäµãÅÌ·û\tF10" + IDS_EXT2_MANAGEMENT "ÅäÖÃExt2¾íÊôÐÔ\tF3" + IDS_FLUSH_BUFFER "±£´æÏµÍ³»º³å\tF11" + IDS_CHANGE_PARTID "¸ü¸Ä·ÖÇøÀàÐÍ\tF12" + IDS_RELOAD_REFRESH "Ë¢ÐÂËùÓÐÄÚÈÝ\tF5" + IDS_PERFMEM_STAT "ÐÔÄܼ°ÄÚ´æÍ³¼Æ\tF8" + IDS_SERVICE_MANAGE "ÅäÖÃÎļþϵͳ\tF7" + IDS_REMOVE_DEAD_LETTER "ɾ³ýÎÞЧÅÌ·û\tF9" + IDS_PERFSTAT_NAME "Ãû³Æ" + IDS_PERFSTAT_UNIT "½á¹¹´óС" + IDS_PERFSTAT_CURRENT "ÒÑ·ÖÅä¸öÊý" + IDS_PERFSTAT_SIZE "Õ¼ÓÃÄÚ´æ´óС" +END + +STRINGTABLE +BEGIN + IDS_PERFSTAT_TOTAL "ÀúÊ·»ýÀÛ·ÖÅä´ÎÊý" + IDS_PERFSTAT_PROCESSING "ÕýÔÚ´¦Àí" + IDS_PERFSTAT_PROCESSED "ÒÑÍê³ÉµÄÇëÇó" + IDS_DRV_QUICK_MOUNT "¼ÓÔØ×°ÅäµãÅÌ·û\tF4" +END + +#endif // Chinese (P.R.C.) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_DONATE_DIALOG DIALOGEX 0, 0, 268, 219 +STYLE DS_SETFONT | WS_POPUP | WS_CAPTION +CAPTION "Contribute to Ext2Fsd Group" +FONT 8, "MS Sans Serif", 0, 0, 0x0 +BEGIN + DEFPUSHBUTTON "OK",IDOK,223,172,32,36 + GROUPBOX "Donation declaration",IDC_STATIC,7,7,254,149 + EDITTEXT IDC_DECLARE,15,23,238,126,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | ES_WANTRETURN | WS_VSCROLL + GROUPBOX "Click to donate",IDC_STATIC,7,163,254,51 + LTEXT "Donate via SourceForge.net",IDC_VIA_SOURCEFORGE,15,180,114,12 + LTEXT "Donate via PayPal.com",IDC_VIA_PAYPAL,15,198,90,12 +END + +IDD_ABOUTBOX DIALOGEX 0, 0, 313, 223 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "About Ext2 Volume Manager" +FONT 8, "MS Sans Serif", 0, 0, 0x1 +BEGIN + DEFPUSHBUTTON "Exit",IDOK,233,197,31,20,WS_GROUP + CONTROL 184,IDC_EXT2FSD,"Static",SS_BITMAP | SS_NOTIFY | SS_REALSIZEIMAGE | SS_SUNKEN,13,195,23,28,WS_EX_DLGMODALFRAME + LTEXT "Ext2Mgr: 2.0",IDC_PROGRAM,50,207,171,9,SS_NOPREFIX + GROUPBOX "",IDC_ABOUT_SHOW,7,4,299,185,NOT WS_VISIBLE + DEFPUSHBUTTON "Donate",ID_DONATE,269,197,31,20,WS_GROUP + LTEXT "Ext2Fsd: 0.44",IDC_DRIVER,50,197,171,9,SS_NOPREFIX +END + +IDD_EXT2MGR_DIALOG DIALOGEX 0, 0, 407, 277 +STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_APPWINDOW +CAPTION "Ext2 Volume Manager" +MENU IDR_MENU +FONT 8, "MS Sans Serif", 0, 0, 0x1 +BEGIN + CONTROL "List1",IDC_VOLUME_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_AUTOARRANGE | LVS_ALIGNLEFT | WS_BORDER | WS_GROUP | WS_TABSTOP,5,1,395,113,WS_EX_CLIENTEDGE + CONTROL "List1",IDC_DISK_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_OWNERDRAWFIXED | LVS_ALIGNLEFT | WS_BORDER | WS_GROUP | WS_TABSTOP,5,115,395,149,WS_EX_CLIENTEDGE +END + +IDD_SERVICE_MANAGE DIALOG 0, 0, 238, 233 +STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "Apply",IDOK,170,213,37,17 + GROUPBOX "Ext2Fsd Service Management",IDC_STATIC,7,7,224,203 + GROUPBOX "Service status",IDC_STATIC,19,21,201,36,WS_GROUP + EDITTEXT IDC_SERVICE_STATUS,26,35,145,14,ES_READONLY + PUSHBUTTON "Start",IDC_START_SERVICE,179,33,34,17 + GROUPBOX "Service startup mode",IDC_STATIC,19,63,130,37 + COMBOBOX IDC_COMBO_STARTUP,29,80,115,88,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + GROUPBOX "Global Codepage",IDC_STATIC,153,63,66,38 + COMBOBOX IDC_COMBO_CODEPAGE,160,81,54,111,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP + GROUPBOX "Global Volume Settings",IDC_STATIC,18,104,201,100,WS_GROUP + CONTROL "Mount all volumes in read-only mode",IDC_READ_ONLY, + "Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,32,120,181,10 + CONTROL "Enable writing support for ext3 volumes",IDC_EXT3_WRITABLE, + "Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,32,136,170,10 + PUSHBUTTON "Cancel",IDCANCEL,29,213,38,17 + EDITTEXT IDC_GLOBAL_PREFIX,137,166,70,14 + EDITTEXT IDC_GLOBAL_SUFFIX,137,186,70,14 + LTEXT "Hiding files with prefix:",IDC_STATIC,32,168,102,13 + LTEXT "Hiding files with suffix:",IDC_STATIC,32,187,100,13 + CONTROL "Assign drive letter automatically",IDC_EXT3_AUTOMOUNT, + "Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,32,151,170,10 +END + +IDD_FORMAT DIALOG 0, 0, 203, 198 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "Start",IDOK,19,177,50,14 + PUSHBUTTON "Cancel",IDCANCEL,132,177,50,14 + CONTROL "Progress1",IDC_FORMAT_PROGRESS,"msctls_progress32",WS_BORDER,12,153,171,8 + COMBOBOX IDC_COMBO_FS,85,27,97,14,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + LTEXT "File system:",IDC_STATIC,20,30,53,8 + GROUPBOX "Format",IDC_FORMAT_TITLE,7,7,183,161 + LTEXT "Volume label:",IDC_STATIC,21,77,54,10 + EDITTEXT IDC_EDIT_LABEL,85,73,95,14 + LTEXT "Cluster size:",IDC_STATIC,21,55,54,8 + COMBOBOX IDC_COMBO_CLUSTER,85,52,96,14,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + GROUPBOX "",IDC_STATIC,14,20,170,23 + GROUPBOX "",IDC_STATIC,14,46,170,23 + GROUPBOX "",IDC_STATIC,13,67,170,23 + GROUPBOX "Options",IDC_STATIC,13,98,169,42 + CONTROL "Perform a quick format",IDC_QUICK_FORMAT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,32,112,138,10 + CONTROL "Enable volume compression",IDC_QUICK_COMPRESS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,32,125,112,10 +END + +IDD_EXT2_ATTR DIALOG 0, 0, 251, 233 +STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "Apply",IDOK,176,216,39,17 + CONTROL "Mount volume in readonly mode",IDC_READ_ONLY,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,27,39,134,10 + COMBOBOX IDC_COMBO_CODEPAGE,184,37,49,106,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + CONTROL "Automatically mount via Ext2Mgr",IDC_AUTOMOUNT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,27,79,148,10 + COMBOBOX IDC_COMBO_AUTOMP,196,76,36,96,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + CONTROL "Mountpoint for fixed disk, need reboot",IDC_FIXMOUNT, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,27,102,165,10 + COMBOBOX IDC_COMBO_DRVLETTER,196,100,36,107,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + EDITTEXT IDC_EXT2_PREFIX,147,138,70,14 + EDITTEXT IDC_EXT2_SUFFIX,147,157,70,14 + EDITTEXT IDC_EDIT_UID,53,193,25,12,ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_GID,105,193,25,12,ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_EUID,189,193,25,12,ES_AUTOHSCROLL + PUSHBUTTON "Cancel",IDCANCEL,17,216,42,17 + GROUPBOX "Ext2/3 Volume Settings",IDC_STATIC,7,7,237,206 + GROUPBOX "Volume attribute",IDC_STATIC,15,22,149,37,WS_GROUP + GROUPBOX "Codepage",IDC_STATIC,173,22,64,37,WS_GROUP + LTEXT "Hiding files with prefix:",IDC_STATIC,29,140,102,13 + LTEXT "Hiding files with suffix:",IDC_STATIC,29,159,100,13 + GROUPBOX "Hiding filter patterns",IDC_STATIC,13,123,224,52 + GROUPBOX "Mount point && driver letter",IDC_STATIC,14,64,223,55,WS_GROUP + GROUPBOX "",IDC_STATIC,14,90,223,29 + GROUPBOX "Mounting as User",IDC_STATIC,13,179,224,30 + LTEXT "UID:",IDC_STATIC,31,195,17,9 + LTEXT "GID:",IDC_STATIC,84,195,17,9 + LTEXT "EUID:",IDC_STATIC,164,195,21,9 +END + +IDD_CHANGE_MOUNTPINT DIALOG 0, 0, 206, 129 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "Done",IDOK,148,105,44,14 + GROUPBOX "Change Drive Letters",IDC_STATIC,7,0,192,126 + LTEXT "Mountpoints:",IDC_STATIC,16,15,117,8 + CONTROL "List1",IDC_DRV_LETTER_LIST,"SysListView32",LVS_SMALLICON | LVS_SINGLESEL | LVS_SORTASCENDING | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,14,28,128,93 + PUSHBUTTON "Add...",ID_ADD_MOUNTPOINT,149,30,44,14 + PUSHBUTTON "Change",ID_CHANGE_MOUNTPOINT,149,52,43,14 + PUSHBUTTON "Remove",ID_REMOVE_MOUNTPOINT,149,74,43,14 +END + +IDD_NEW_MOUNTPOINT DIALOG 0, 0, 251, 181 +STYLE DS_SETFONT | WS_POPUP | WS_BORDER +FONT 9, "MS Sans Serif" +BEGIN + PUSHBUTTON "OK",IDOK,191,163,50,14 + LTEXT "Enter or select a new drive lettter :",IDC_STATIC,6,16,151,8 + COMBOBOX IDC_DRVLETTERS_LIST,173,14,70,92,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP + CONTROL "Mount via DefineDosDevice, will be lost after reboot",IDC_DOSDEV_MP, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,48,225,15 + DEFPUSHBUTTON "Cancel",IDCANCEL,110,163,50,14 + CONTROL "",IDC_PERMANENT_MP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,70,11,15 + CONTROL "",IDC_REGISTRY_MP,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,12,112,10,15 + GROUPBOX "Which way to mount:",IDC_STATIC,5,34,237,127 + LTEXT "Automatic mount via MountMgr. Ext2Mgr will assign or remove mountpoints when it detects disk changes. Must NOT close Ext2Mgr. Removable (like USB) disks are recommended to use this method.",IDC_STATIC,23,70,212,34 + LTEXT "Create a permanent MountPoint via Session Manager. It's better use this method for fixed disks. We need create a new item in registry:\r\nHKLM\\System\\CurrentControlSet\\Control\\\r\nSession Manager\\DOS Devices",IDC_STATIC,23,112,208,45 +END + +IDD_PROPERTY_DIALOG DIALOGEX 0, 0, 238, 209 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP +FONT 8, "MS Sans Serif", 0, 0, 0x1 +BEGIN + DEFPUSHBUTTON "Exit",IDOK,156,185,64,14 + GROUPBOX "DISK",IDC_PROPERTY_DEVICE,7,7,224,91 + LTEXT "Vendor:",IDC_STATIC,13,27,28,8 + EDITTEXT IDC_VENDOR_ID,48,25,71,12,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Product:",IDC_STATIC,13,44,30,8 + EDITTEXT IDC_PRODUCT_ID,48,42,71,12,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Serial:",IDC_STATIC,13,59,27,8 + EDITTEXT IDC_SERIAL_NUMBER,48,58,71,12,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Bus:",IDC_STATIC,130,28,17,8 + EDITTEXT IDC_BUS_TYPE,155,26,65,12,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Type:",IDC_STATIC,130,43,20,8 + EDITTEXT IDC_DEVICE_TYPE,155,42,65,12,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Media:",IDC_STATIC,129,59,22,8 + EDITTEXT IDC_MEDIA_TYPE,155,58,65,12,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Capacity (bytes):",IDC_STATIC,14,78,68,8 + EDITTEXT IDC_TOTAL_SIZE,82,77,137,12,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER + GROUPBOX "DISK",IDC_PROPERTY_SDEV,7,101,224,103 + LTEXT "Status:",IDC_STATIC,14,123,33,8 + EDITTEXT IDC_SDEV_STATUS,70,121,149,12,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Mount points:",IDC_STATIC,14,139,53,8 + EDITTEXT IDC_MOUNT_POINTS,70,138,84,12,ES_AUTOHSCROLL | ES_READONLY + PUSHBUTTON "Change",IDC_SDEV_CHANGE_MP,188,135,32,14,BS_LEFT,WS_EX_STATICEDGE + LTEXT "File system:",IDC_STATIC,14,155,51,8 + EDITTEXT IDC_FILE_SYSTEM,69,152,85,12,ES_AUTOHSCROLL | ES_READONLY + PUSHBUTTON "Ext2 Properties",IDC_SDEV_EXT2_INFO,155,152,65,14,BS_LEFT,WS_EX_STATICEDGE + LTEXT "Capacity:",IDC_STATIC,14,171,42,8 + EDITTEXT IDC_SDEV_SIZE,69,169,85,12,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER + LTEXT "Free space:",IDC_STATIC,14,187,49,8 + EDITTEXT IDC_SDEV_FREE_SIZE,69,186,85,12,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER + PUSHBUTTON "Mount",IDC_SDEV_QUICK_MOUNT,155,135,26,14,BS_LEFT,WS_EX_STATICEDGE +END + +IDD_PERFSTAT_DIALOG DIALOGEX 0, 0, 286, 248 +STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Ext2Fsd Statistics" +FONT 8, "MS Sans Serif", 0, 0, 0x1 +BEGIN + DEFPUSHBUTTON "Exit",IDOK,248,228,36,18 + GROUPBOX "Memory",IDC_STATIC,1,2,283,117 + GROUPBOX "Irp",IDC_STATIC,1,121,283,103 + LTEXT "Refresh interval (in seconds):",IDC_STATIC,6,233,123,13 + EDITTEXT IDC_PERFSTAT_INTERVAL,146,231,36,12,ES_AUTOHSCROLL + GROUPBOX "",IDC_STATIC,1,223,187,23,0,WS_EX_TRANSPARENT + CONTROL "List1",IDC_MEMORY_LIST,"SysListView32",LVS_REPORT | WS_BORDER | WS_TABSTOP,1,12,283,107,WS_EX_CLIENTEDGE + CONTROL "List2",IDC_IRP_LIST,"SysListView32",LVS_REPORT | WS_BORDER | WS_TABSTOP,1,132,283,90,WS_EX_CLIENTEDGE + DEFPUSHBUTTON "Refresh",ID_QUERYPERF,198,228,36,18 +END + +IDD_PARTITION_TYPE DIALOG 0, 0, 145, 81 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION +CAPTION "Change Partition Type" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "Change",IDOK,97,60,39,17 + PUSHBUTTON "Cancel",IDCANCEL,10,60,41,17 + COMBOBOX IDC_PARTTION_TYPE_LIST,33,35,97,86,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + GROUPBOX "Partition Type",IDC_STATIC,9,18,127,36 + LTEXT "Static",IDC_PARTITION_NAME,2,3,141,12 +END + +IDD_REMOVE_DEADLETTER DIALOG 0, 0, 192, 139 +STYLE DS_SETFONT | WS_POPUP | WS_CAPTION +CAPTION "Remove Dead Driver Letter" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "Remove",IDOK,147,122,43,14 + DEFPUSHBUTTON "Reload",ID_RELOAD_DL,95,122,42,14 + PUSHBUTTON "Exit",IDCANCEL,2,122,50,14 + GROUPBOX "Please select a driver letter to remove:",IDC_STATIC,2,8,188,55 + COMBOBOX IDC_DEAD_LETTER_LIST,10,25,170,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + GROUPBOX "Automatical removal:",IDC_STATIC,2,66,188,49 + CONTROL "",IDC_AUTO_REMOVAL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,80,9,10 + LTEXT "When Ext2Mgr detects device change, it will reload system settings and then remove dead driver letters for FIXED devices.",IDC_AUTOREMOVALTEXT,28,78,152,34 + CONTROL "Keep it for next reboot or device plug",IDC_REMOVAL_CURRENT, + "Button",BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,9,46,168,11 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_DONATE_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 261 + TOPMARGIN, 7 + BOTTOMMARGIN, 217 + END + + IDD_ABOUTBOX, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 306 + TOPMARGIN, 7 + BOTTOMMARGIN, 222 + END + + IDD_EXT2MGR_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 400 + TOPMARGIN, 1 + BOTTOMMARGIN, 273 + END + + IDD_SERVICE_MANAGE, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 231 + TOPMARGIN, 7 + BOTTOMMARGIN, 230 + END + + IDD_FORMAT, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 196 + TOPMARGIN, 7 + BOTTOMMARGIN, 191 + END + + IDD_EXT2_ATTR, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 244 + TOPMARGIN, 7 + END + + IDD_CHANGE_MOUNTPINT, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 199 + BOTTOMMARGIN, 126 + END + + IDD_NEW_MOUNTPOINT, DIALOG + BEGIN + LEFTMARGIN, 1 + RIGHTMARGIN, 247 + TOPMARGIN, 7 + BOTTOMMARGIN, 177 + END + + IDD_PROPERTY_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 231 + TOPMARGIN, 7 + END + + IDD_PERFSTAT_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 1 + RIGHTMARGIN, 284 + TOPMARGIN, 2 + BOTTOMMARGIN, 246 + END + + IDD_PARTITION_TYPE, DIALOG + BEGIN + LEFTMARGIN, 2 + RIGHTMARGIN, 143 + TOPMARGIN, 2 + END + + IDD_REMOVE_DEADLETTER, DIALOG + BEGIN + LEFTMARGIN, 2 + RIGHTMARGIN, 190 + TOPMARGIN, 2 + BOTTOMMARGIN, 136 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 3,0,7,9 + PRODUCTVERSION 3,0,7,9 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "Ext2Fsd Group (www.ext2fsd.com)" + VALUE "FileDescription", "Ext2 Volume Manager for Windows" + VALUE "FileVersion", "3.0.7.9" + VALUE "InternalName", "Ext2Mgr" + VALUE "LegalCopyright", "Copyright (C) 2016 Ext2Fsd Group" + VALUE "OriginalFilename", "Ext2Mgr.exe" + VALUE "ProductName", "Ext2 Volume Manager for Windows" + VALUE "ProductVersion", "3.0.7.9" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDR_TRAY MENU +BEGIN + POPUP "Tray" + BEGIN + MENUITEM "Show Main Window", ID_SHOW_MAIN + MENUITEM SEPARATOR + MENUITEM "Service Management", ID_SERVICE + MENUITEM "Ext2Fsd Statistics", ID_PERFSTAT + MENUITEM SEPARATOR + MENUITEM "About Ext2Mgr", ID_ABOUT + MENUITEM SEPARATOR + MENUITEM "Exit ...", ID_EXIT + END +END + +IDR_MENU MENU +BEGIN + POPUP "&File" + BEGIN + MENUITEM "&Enable Ext2Mgr autostart ", ID_ENABLE_AUTOSTART + MENUITEM "&Disable Ext2Mgr autostart", ID_DISABLE_AUTOSTART + MENUITEM SEPARATOR + MENUITEM "E&xit", ID_EXIT + END + POPUP "&Edit" + BEGIN + MENUITEM "&Copy Everything to Clipboard", ID_COPYALL + END + POPUP "&Tools" + BEGIN + MENUITEM "&Reload and Refresh\tF5", ID_REFRESH + MENUITEM SEPARATOR + MENUITEM "&Service Management\tF7", ID_SERVICE + MENUITEM "Ext2Fsd S&tatistics\tF8", ID_PERFSTAT + MENUITEM SEPARATOR + MENUITEM "Remove &Dead Letters\tF9", ID_REMOVE_DEAD_LETTER + MENUITEM SEPARATOR + MENUITEM "&Ext2 Volume Management\tF3", ID_CHANGE + MENUITEM "&Mountpoint Management\tF10", ID_DRV_LETTER + MENUITEM SEPARATOR + MENUITEM "&Flush Cache to Disk\tF11", ID_FLUSH_BUFFER + MENUITEM "&Change Partition Type\tF12", ID_CHANGE_PARTTYPE + MENUITEM SEPARATOR + MENUITEM "Show &Properties\tF6", ID_PROPERTY + END + POPUP "&Help" + BEGIN + MENUITEM "&Help\tF1", ID_HELP + MENUITEM SEPARATOR + MENUITEM "&About\tF2", ID_ABOUT + MENUITEM SEPARATOR + MENUITEM "&Donate", ID_DONATE + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDR_MAINFRAME ICON "res\\Ext2Mgr.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + +IDB_ABOUT_SCREEN BITMAP "res\\about.bmp" +IDI_FLOPPY BITMAP "res\\floppy.bmp" +IDI_CDROM BITMAP "res\\cdrom.bmp" +IDI_DISK BITMAP "res\\disk.bmp" +IDI_DVD BITMAP "res\\dvd.bmp" +IDI_DYNAMIC BITMAP "res\\dynamic.bmp" +IDR_STANDARDBAR BITMAP "res\\toolbar.bmp" +IDB_ABOUT_SMALL BITMAP "res\\abouts.bmp" +IDB_LINE_SEP BITMAP "res\\line.bmp" +IDB_SMALL_PENGUIN BITMAP "res\\images\\smallpenguin.bmp" +IDB_BIG_PENGUIN BITMAP "res\\images\\penguin.bmp" + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +IDR_AKEY_EXT2MGR ACCELERATORS +BEGIN + VK_F1, ID_HELP, VIRTKEY, NOINVERT + VK_F10, ID_DRV_LETTER, VIRTKEY, NOINVERT + VK_F11, ID_FLUSH_BUFFER, VIRTKEY, NOINVERT + VK_F12, ID_CHANGE_PARTTYPE, VIRTKEY, NOINVERT + VK_F2, ID_ABOUT, VIRTKEY, NOINVERT + VK_F3, ID_CHANGE, VIRTKEY, NOINVERT + VK_F4, ID_DRV_QUICK_MOUNT, VIRTKEY, NOINVERT + VK_F5, ID_REFRESH, VIRTKEY, NOINVERT + VK_F6, ID_PROPERTY, VIRTKEY, NOINVERT + VK_F7, ID_SERVICE, VIRTKEY, NOINVERT + VK_F8, ID_PERFSTAT, VIRTKEY, NOINVERT + VK_F9, ID_REMOVE_DEAD_LETTER, VIRTKEY, NOINVERT +END + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE +BEGIN + IDS_ABOUTBOX "&About Ext2 Volume Manager ..." +END + +STRINGTABLE +BEGIN + ID_ABOUT "About Ext2 Volume Manger\tF2" + ID_NEW "create a new configuration file" + ID_CHANGE "Change the settings of the selected driver or volume" + ID_REFRESH "Refresh and reload the disks and volumes" + ID_EXIT "Quit ext2 volume manager ..." + ID_SERVICE "Manage the ext2fsd driver startup information" + ID_FORMAT "Format the selected volume or parititon" + ID_PROPERTY "Show the information and property of the selected volume or partition" + ID_COPY "Copy the only selected item to clipboard" + ID_SHOW_MAIN "Show the main window of Ext2Mgr" + ID_DRV_LETTER "Assign or change driver letters of selected volume or disk" + ID_DONATE "Donate to Ext2Fsd group" +END + +STRINGTABLE +BEGIN + ID_INSTALL_SERVICE "Install Ext2Mgr as a service (with autostart enabled)" + ID_REMOVE_SERVICE "Remove Ext2Mgr service (disable service autostart)" + ID_ENABLE_AUTOSTART "Let Ext2Mgr automatically start when system boots" + ID_DISABLE_AUTOSTART "Don't want Ext2Mgr automatically start when system boots" + ID_PERFSTAT "Statistics of memory allocations and Irp processing" + ID_COPYALL "Copy all disks/partitions/cdrom/volumes information to clipboard" + ID_FLUSH_BUFFER "Sync all dirty cache to disk" + ID_CHANGE_PARTTYPE "Change the partition type/id" + ID_REMOVE_DEAD_LETTER "Remove the dead driver letter" + ID_DRV_QUICK_MOUNT "Assign a driver letter to selected volume or disk" +END + +STRINGTABLE +BEGIN + ID_HELP "Help" + IDS_LISTITEM_FILESYSTEM "File system" + IDS_LISTITEM_VOLUME "Volume" + IDS_LISTITEM_TYPE "Type" + IDS_LISTITEM_TOTALSIZE "Total size" + IDS_LISTITEM_USEDSIZE "Used size" + IDS_LISTITEM_CODEPAGE "Codepage" + IDS_LISTITEM_DEVOBJ "Physical object" + IDS_LISTITEM_PARTID "Partition type" + IDS_DISK_TYPE_BASIC "Basic" +END + +STRINGTABLE +BEGIN + IDS_DISK_TYPE_DYN "Dynamic" + IDS_DONATE_DECLARE "\r\nExt2Fsd is an open source software. It acts as a bridge between Windows and Linux, making life easier to access Linux partitions under Windows systems.\r\n\r\nCurrently there are still lots of jobs left to make a fully functional file system driver, such as complete ext3 support, Linux LVM, Windows Vista, Longhorn. Especially Vista and Longhorn will need driver signing.\r\n\r\nNow I'm the only part-time developer. It needs about two full time developers to implement that job and also it needs some hardwares such SMP system, SCSI array for debugging and testing.\r\n\r\nI'll try my best to make it out. I'm dreaming of that day.\r\n\r\nAny help will be highly appreciated. Thanks and best wishes.\r\n\r\n\r\nYours sincerely,\r\nMatt" + IDS_SHOW_PROPERTY "Show Properties\tF6" + IDS_COPY_ITEM_TO_CLIP "&Copy to Clipboard" + IDS_CHANGE_DRVLETTER "Change Drive Letter\tF10" + IDS_EXT2_MANAGEMENT "Ext2 Management\tF3" + IDS_FLUSH_BUFFER "Flush Cache to Disk\tF11" + IDS_CHANGE_PARTID "Change Partition Type\tF12" + IDS_RELOAD_REFRESH "Reload and Refresh\tF5" + IDS_PERFMEM_STAT "Ext2Fsd Statistics\tF8" + IDS_SERVICE_MANAGE "Service Management\tF7" + IDS_REMOVE_DEAD_LETTER "Remove Dead Letters\tF9" + IDS_PERFSTAT_NAME "Name" + IDS_PERFSTAT_UNIT "Unit" + IDS_PERFSTAT_CURRENT "Current" + IDS_PERFSTAT_SIZE "Memory size" +END + +STRINGTABLE +BEGIN + IDS_PERFSTAT_TOTAL "Total allocations" + IDS_PERFSTAT_PROCESSING "Being processed" + IDS_PERSTAT_PROCESSED "Ever processed" + IDS_DRV_QUICK_MOUNT "Assign Drive Letter\tF4" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +#define _AFX_NO_SPLITTER_RESOURCES +#define _AFX_NO_OLE_RESOURCES +#define _AFX_NO_TRACKER_RESOURCES +#define _AFX_NO_PROPERTY_RESOURCES + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE 9, 1 +#pragma code_page(1252) +#endif //_WIN32 +#include "res\Ext2Mgr.rc2" // non-Microsoft Visual C++ edited resources +#include "afxres.rc" // Standard components +#endif + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Ext2Mgr/Ext2MgrDlg.cpp b/Ext2Mgr/Ext2MgrDlg.cpp index efcbc6f..1ff2e02 100644 --- a/Ext2Mgr/Ext2MgrDlg.cpp +++ b/Ext2Mgr/Ext2MgrDlg.cpp @@ -1,2131 +1,2131 @@ -// Ext2MgrDlg.cpp : implementation file -// - -#include "stdafx.h" -#include "Ext2Mgr.h" -#include "PartitionType.h" -#include "DelDeadLetter.h" -#include "Ext2MgrDlg.h" -#include "DlgView.h" -#include - -#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(); - - HBITMAP m_hBitmap; - HDC m_hMemDC; - HBITMAP m_hOldBmp; - -// Dialog Data - //{{AFX_DATA(CAboutDlg) - enum { IDD = IDD_ABOUTBOX }; - // CMyHyperLink m_lMail; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAboutDlg) - public: - virtual BOOL DestroyWindow(); - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - //{{AFX_MSG(CAboutDlg) - virtual BOOL OnInitDialog(); - afx_msg void OnPaint(); - afx_msg void OnExt2fsd(); - afx_msg void OnDonate(); - afx_msg void OnTimer(UINT_PTR nIDEvent); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ - //{{AFX_DATA_INIT(CAboutDlg) - //}}AFX_DATA_INIT -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAboutDlg) - // DDX_Control(pDX, IDC_AUTHOR, m_lMail); - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) - //{{AFX_MSG_MAP(CAboutDlg) - ON_WM_PAINT() - ON_BN_CLICKED(IDC_EXT2FSD, OnExt2fsd) - ON_BN_CLICKED(ID_DONATE, OnDonate) - ON_WM_TIMER() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -BOOL CAboutDlg::DestroyWindow() -{ - // TODO: Add your specialized code here and/or call the base class - if (m_hBitmap) { - - if (m_hMemDC) { - ::SelectObject(m_hMemDC, m_hOldBmp); - ::DeleteDC(m_hMemDC); - } - - ::DeleteObject (m_hBitmap); - m_hBitmap = NULL; - } - - return CDialog::DestroyWindow(); -} - -BOOL CAboutDlg::OnInitDialog() -{ - CString s; - CHAR Version[0x20]; - CHAR Date[0x20]; - CHAR Time[0x20]; - - CDialog::OnInitDialog(); - - m_hBitmap = (HBITMAP)::LoadImage(GetModuleHandle(NULL), - MAKEINTRESOURCE(IDB_ABOUT_SMALL), - IMAGE_BITMAP, 0, 0, 0); - - if (m_hBitmap) { - m_hMemDC = ::CreateCompatibleDC(this->GetDC()->m_hDC); - m_hOldBmp = (HBITMAP)::SelectObject(m_hMemDC, m_hBitmap); - } - - INT rc = Ext2QueryDrvVersion(Version, Date, Time); - - if (rc < 0) { - s.Format("Ext2Fsd: NOT started !\0"); - } else if (rc > 0) { - s.Format("Ext2Fsd: %s (%s)\0", Version, Date); - } else { - s.Format("Ext2Fsd: < 0.42 (Dec 2007)\0"); - } - SET_TEXT(IDC_DRIVER, s); - s = "Ext2Mgr: 3.00 ("; - s += __DATE__; - s += ")\0"; - SET_TEXT(IDC_PROGRAM, s); - - // Set the target URL - // m_lMail.SetLinkUrl("mailto:Matt Wu?subject=Ext2Fsd Support"); - // Enable showing the Tooltip - // m_lMail.ActiveToolTip(TRUE); - // Set the Tooltiptext - // m_lMail.SetTootTipText("Write a mail to Ext2Fsd group."); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void CAboutDlg::OnPaint() -{ - CPaintDC dc(this); // device context for painting - - int rc; - BITMAP cs; - - rc = ::GetObject(m_hBitmap, sizeof(cs), &cs); - if (rc == 0) { - return; - } - - CRect rect; - CWnd *pAboutWnd = GetDlgItem(IDC_ABOUT_SHOW); - pAboutWnd->GetWindowRect(rect); - ScreenToClient(rect); - - ::StretchBlt(dc.m_hDC, rect.left, rect.top, rect.Width(), rect.Height(), - m_hMemDC, 0, 0, cs.bmWidth, cs.bmHeight, SRCCOPY); - - // Do not call CDialog::OnPaint() for painting messages -} - - -void CAboutDlg::OnExt2fsd() -{ - // TODO: Add your control notification handler code here - ShellExecute(this->GetSafeHwnd(), "open", - "http://www.ext2fsd.com", - NULL, NULL, SW_SHOW ); -} - -void CAboutDlg::OnDonate() -{ - // TODO: Add your control notification handler code here - GetParent()->SendMessage(WM_COMMAND, ID_DONATE); -} - -void CAboutDlg::OnTimer(UINT_PTR nIDEvent) -{ - // TODO: Add your message handler code here and/or call default - - CDialog::OnTimer(nIDEvent); -} - -///////////////////////////////////////////////////////////////////////////// -// CExt2List message handlers - -CExt2List::CExt2List() -{ -} - -CExt2List::~CExt2List() -{ -} - - -BEGIN_MESSAGE_MAP(CExt2List, CListCtrl) - //{{AFX_MSG_MAP(CExt2List) - ON_WM_RBUTTONDOWN() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -void CExt2List::OnRButtonDown(UINT nFlags, CPoint point) -{ - // TODO: Add your message handler code here and/or call default - m_Point = point; - CListCtrl::OnRButtonDown(nFlags, point); -} - -int CExt2List::QuerySubItemText(int item, CHAR *Data, int length) -{ - LV_COLUMN lvc; - LV_ITEM lvi; - int ncol; - CRect rect; - - ::ZeroMemory(&lvc, sizeof(lvc)); - lvc.mask = LVCF_WIDTH |LVCF_FMT; - - for (ncol=0; GetColumn(ncol, &lvc); ncol++) { - - if (ncol > 0) { - GetSubItemRect(item, ncol,LVIR_BOUNDS, rect); - } else { - GetItemRect(item, rect, LVIR_BOUNDS); - rect.right = GetColumnWidth(0); - rect.left = 0; - } - - if (rect.PtInRect(m_Point)) { - - ::ZeroMemory(Data, length); - ::ZeroMemory(&lvi, sizeof(lvi)); - - lvi.iItem = item; - lvi.mask = LVIF_TEXT; - lvi.iSubItem = ncol; - lvi.pszText = Data; - lvi.cchTextMax = length; - - return GetItem(&lvi); - break; - } - } - - return FALSE; -} - - -///////////////////////////////////////////////////////////////////////////// -// CExt2MgrDlg dialog - -CExt2MgrDlg::CExt2MgrDlg(CWnd* pParent /*=NULL*/) - : CDialog(CExt2MgrDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(CExt2MgrDlg) - // 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_bHide = FALSE; - m_bQuiet = FALSE; - m_bService = FALSE; - m_bStat = FALSE; - - m_splash = NULL; - - m_bFocusVolume = FALSE; - m_IndexVolume = 0; - m_bFocusDisk = FALSE; - m_IndexDisk = 0; - - m_type = 0; - m_sdev = NULL; - - m_PerfDlg = NULL; - - m_hUsbNotify = NULL; - m_bHandleChange = FALSE; - - m_hAccel = NULL; - m_bFsStarted = FALSE; - - m_nStartmode = 0; - m_bAutoMount = FALSE; - m_bExt3Writable = FALSE; - m_bReadonly = FALSE; -} - -void CExt2MgrDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CExt2MgrDlg) - DDX_Control(pDX, IDC_VOLUME_LIST, m_VolumeList); - DDX_Control(pDX, IDC_DISK_LIST, m_DiskView); - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CExt2MgrDlg, CDialog) - //{{AFX_MSG_MAP(CExt2MgrDlg) - ON_WM_WINDOWPOSCHANGING() - ON_WM_SYSCOMMAND() - ON_WM_DEVICECHANGE() - ON_WM_DESTROY() - ON_WM_PAINT() - ON_WM_QUERYDRAGICON() - ON_WM_SIZE() - ON_COMMAND(ID_CHANGE, OnChangeProperty) - ON_COMMAND(ID_REFRESH, OnRefresh) - ON_COMMAND(ID_FORMAT, OnFormat) - ON_COMMAND(ID_SERVICE, OnService) - ON_COMMAND(ID_ABOUT, OnAbout) - ON_COMMAND(ID_EXIT, OnExit) - ON_WM_MEASUREITEM() - ON_NOTIFY(NM_DBLCLK, IDC_DISK_LIST, OnDblclkDiskList) - ON_NOTIFY(NM_KILLFOCUS, IDC_DISK_LIST, OnKillfocusDiskList) - ON_NOTIFY(NM_RCLICK, IDC_DISK_LIST, OnRclickDiskList) - ON_NOTIFY(NM_DBLCLK, IDC_VOLUME_LIST, OnDblclkVolumeList) - ON_NOTIFY(NM_KILLFOCUS, IDC_VOLUME_LIST, OnKillfocusVolumeList) - ON_NOTIFY(NM_RCLICK, IDC_VOLUME_LIST, OnRclickVolumeList) - ON_NOTIFY(NM_CLICK, IDC_DISK_LIST, OnClickDiskList) - ON_NOTIFY(NM_CLICK, IDC_VOLUME_LIST, OnClickVolumeList) - ON_NOTIFY(NM_SETFOCUS, IDC_DISK_LIST, OnSetfocusDiskList) - ON_NOTIFY(NM_SETFOCUS, IDC_VOLUME_LIST, OnSetfocusVolumeList) - ON_COMMAND(ID_PROPERTY, OnProperty) - ON_COMMAND(ID_DONATE, OnDonate) - ON_COMMAND(ID_COPY, OnCopy) - ON_COMMAND(ID_COPYALL, OnCopyAll) - ON_WM_TIMER() - ON_COMMAND(ID_DRV_LETTER, OnDrvLetter) - ON_COMMAND(ID_DRV_QUICK_MOUNT, OnDrvQuickMount) - ON_COMMAND(ID_INSTALL_SERVICE, OnInstallService) - ON_COMMAND(ID_REMOVE_SERVICE, OnRemoveService) - ON_COMMAND(ID_ENABLE_AUTOSTART, OnEnableAutorun) - ON_COMMAND(ID_DISABLE_AUTOSTART, OnDisableAutorun) - ON_COMMAND(ID_SHOW_MAIN, OnShowMain) - ON_MESSAGE(WM_TRAY_ICON_NOTIFY, OnTrayNotification) - ON_MESSAGE(WM_TERMINATE_PROGRAM, OnTerminate) - ON_MESSAGE(WM_MOUNTPOINT_NOTIFY, OnMountPointNotify) - ON_COMMAND(ID_HELP, OnHelp) - ON_COMMAND(ID_PERFSTAT, OnPerfStat) - ON_COMMAND(ID_PERFSTOP, OnPerfStop) - ON_COMMAND(ID_FLUSH_BUFFER, OnFlush) - ON_COMMAND(ID_CHANGE_PARTTYPE, OnPartType) - ON_COMMAND(ID_REMOVE_DEAD_LETTER, OnRemoveDeadLetter) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CExt2MgrDlg message handlers - - -static UINT BASED_CODE indicators[] = -{ - ID_INDICATOR_MESSAGE, - ID_INDICATOR_TIME, - ID_INDICATOR_EXTRA, -}; - -/* A5DCBF10-6530-11D2-901F-00C04FB951ED */ -DEFINE_GUID(GUID_CLASS_USB_DEVICE, 0xA5DCBF10L, 0x6530, 0x11D2, 0x90, 0x1F, 0x00, \ - 0xC0, 0x4F, 0xB9, 0x51, 0xED); - - -BOOL CExt2MgrDlg::OnInitDialog() -{ - CString str; - LONG_PTR dwStyle = 0; - - CDialog::OnInitDialog(); - - /* set windows identifier */ - SetWindowLongPtr(this->GetSafeHwnd(), DWLP_USER, EXT2_DIALOG_MAGIC); - - /* minimize the dialog during startup */ - if (m_bHide) { - PostMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0); - } - - // 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); - } - } - - /* F1 - F12 key */ - m_hAccel = ::LoadAccelerators(AfxGetInstanceHandle(), - MAKEINTRESOURCE(IDR_AKEY_EXT2MGR)); - - // 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 large icon - SetIcon(m_hIcon, FALSE); // Set small icon - - /* create new font for views */ - m_MSSanS.CreatePointFont(80, "MS Sans Serif"); - m_DiskView.SetFont(&m_MSSanS); - m_VolumeList.SetFont(&m_MSSanS); - - /* initialize the disk view */ - dwStyle=GetWindowLongPtr(m_DiskView.GetSafeHwnd(),GWL_STYLE); - dwStyle&=~LVS_TYPEMASK; - dwStyle|=(LVS_REPORT | LVS_OWNERDRAWFIXED); - SetWindowLongPtr(m_DiskView.GetSafeHwnd(),GWL_STYLE,dwStyle); - - m_DiskView.InsertColumn(0, (LPCSTR)"", LVCFMT_CENTER, 80); - str.LoadString(IDS_LISTITEM_TYPE); - m_DiskView.InsertColumn(1, (LPCSTR)str, LVCFMT_LEFT, 60); - - str.LoadString(IDS_LISTITEM_FILESYSTEM); - m_DiskView.InsertColumn(2, (LPCSTR)str, LVCFMT_LEFT, 80); - - str.LoadString(IDS_LISTITEM_TOTALSIZE); - m_DiskView.InsertColumn(3, (LPCSTR)str, LVCFMT_RIGHT, 80); - - str.LoadString(IDS_LISTITEM_USEDSIZE); - m_DiskView.InsertColumn(4, (LPCSTR)str, LVCFMT_RIGHT, 70); - - str.LoadString(IDS_LISTITEM_CODEPAGE); - m_DiskView.InsertColumn(5, (LPCSTR)str, LVCFMT_LEFT, 70); - - str.LoadString(IDS_LISTITEM_PARTID); - m_DiskView.InsertColumn(6, (LPCSTR)str, LVCFMT_LEFT, 120); - - /* initialize volume list */ - dwStyle=GetWindowLongPtr(m_VolumeList.GetSafeHwnd(),GWL_STYLE); - dwStyle&=~LVS_TYPEMASK; - dwStyle|= (LVS_REPORT | LVS_AUTOARRANGE); - SetWindowLongPtr(m_VolumeList.GetSafeHwnd(),GWL_STYLE,dwStyle); - m_VolumeList.SetExtendedStyle(LVS_EX_GRIDLINES); - - m_VolumeList.InsertColumn(0, NULL, LVCFMT_CENTER, 20); - str.LoadString(IDS_LISTITEM_VOLUME); - m_VolumeList.InsertColumn(1, (LPCSTR)str, LVCFMT_LEFT, 60); - - str.LoadString(IDS_LISTITEM_TYPE); - m_VolumeList.InsertColumn(2, (LPCSTR)str, LVCFMT_LEFT, 60); - - str.LoadString(IDS_LISTITEM_FILESYSTEM); - m_VolumeList.InsertColumn(3, (LPCSTR)str, LVCFMT_LEFT, 80); - - str.LoadString(IDS_LISTITEM_TOTALSIZE); - m_VolumeList.InsertColumn(4, (LPCSTR)str, LVCFMT_RIGHT, 80); - - str.LoadString(IDS_LISTITEM_USEDSIZE); - m_VolumeList.InsertColumn(5, (LPCSTR)str, LVCFMT_RIGHT, 70); - - str.LoadString(IDS_LISTITEM_CODEPAGE); - m_VolumeList.InsertColumn(6, (LPCSTR)str, LVCFMT_LEFT, 70); - - str.LoadString(IDS_LISTITEM_DEVOBJ); - m_VolumeList.InsertColumn(7, (LPCSTR)str, LVCFMT_LEFT, 200); - - ListView_SetExtendedListViewStyleEx ( - m_VolumeList.GetSafeHwnd(), - LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT ); - - /* initialize ImageList */ - m_ImageList.Create(16, 16, ILC_COLOR8 | ILC_MASK, 5, 5); - for (UINT nID = IDI_FLOPPY; nID <= IDI_DYNAMIC; nID++) { - CBitmap bitmap; - if (bitmap.LoadBitmap(nID)) { - m_ImageList.Add(&bitmap, RGB(0,0,0)); - bitmap.DeleteObject(); - } - } - m_VolumeList.SetImageList(&m_ImageList, LVSIL_SMALL); - - /* Status Bar Initialization */ - m_bar.Create(this); //We create the status bar - m_bar.SetIndicators(indicators, 3); - - CRect rect; - GetClientRect(&rect); - m_bar.SetPaneInfo(0,ID_INDICATOR_MESSAGE, SBPS_NORMAL,rect.Width()-160); - m_bar.SetPaneInfo(1,ID_INDICATOR_TIME,SBPS_NORMAL ,132); - m_bar.SetPaneInfo(2,ID_INDICATOR_EXTRA,SBPS_STRETCH ,0); - /* m_bar.GetStatusBarCtrl().SetBkColor(RGB(180,180,180)); */ - RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST, - ID_INDICATOR_EXTRA); - - CTime t1; - t1 = CTime::GetCurrentTime(); - - CString s; - s.Format("%s", "Ready"); - m_bar.SetPaneText(0, s); - - s.Format(" %3.3s", t1.Format("%B")); - s += t1.Format(" %d,%Y %H:%M:%S"); - m_bar.SetPaneText(1, s); - - SetTimer(ID_INDICATOR_TIME,1000,NULL); - - /* close the splash window */ - PostMessage(WM_SYSCOMMAND, IDM_CLOSE_SPLASH, 0); - - /* loading system configurations */ - if (Ext2QuerySysConfig()) { - Ext2LoadDisks(); - Ext2LoadCdroms(); - if (Ext2LoadVolumes()) { - Ext2LoadRemovableVolumes(); - Ext2LoadDrvLetters(); - Ext2LoadCdromDrvLetters(); - Ext2LoadAllVolumeDrvLetters(); - Ext2LoadAllDiskPartitions(); - if (g_bAutoRemoveDeadLetters) { - Ext2AutoRemoveDeadLetters(); - } - if (Ext2ProcessExt2Volumes()) { - } - } - } else { - return FALSE; - } - - m_bHandleChange = TRUE; - - /* updating the volume list */ - Ext2RefreshVolumeList(&m_VolumeList); - - /* updating the disk list */ - Ext2RefreshDiskList(&m_DiskView); - - CMenu* pMenu = AfxGetMainWnd()->GetMenu(); - CMenu* pSubFile = pMenu->GetSubMenu(0); - if (pSubFile) { - if (Ext2RunMgrForCurrentUser()) { - pSubFile->EnableMenuItem(ID_ENABLE_AUTOSTART, MF_BYCOMMAND|MF_GRAYED|MF_DISABLED); - pSubFile->EnableMenuItem(ID_DISABLE_AUTOSTART, MF_BYCOMMAND|MF_ENABLED); - } else { - pSubFile->EnableMenuItem(ID_ENABLE_AUTOSTART, MF_BYCOMMAND|MF_ENABLED); - pSubFile->EnableMenuItem(ID_DISABLE_AUTOSTART, MF_BYCOMMAND|MF_GRAYED|MF_DISABLED); - } - } - - m_Menu.CreatePopupMenu(); - - HICON hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); - m_Tray.Create(this, WM_TRAY_ICON_NOTIFY,"Ext2 Volume Manager",hIcon, IDR_TRAY); - - /* start Ext2Fsd statistics window */ - if (m_bStat) { - PostMessage(WM_COMMAND, ID_PERFSTAT, 0); - } - - /* query global parameters */ - Ext2QueryGlobalProperty( - &m_nStartmode, - (BOOL *)&m_bReadonly, - (BOOL *)&m_bExt3Writable, - (CHAR *)m_Codepage.GetBuffer(CODEPAGE_MAXLEN), - (CHAR *)m_sPrefix.GetBuffer(HIDINGPAT_LEN), - (CHAR *)m_sSuffix.GetBuffer(HIDINGPAT_LEN), - (BOOL *)&m_bAutoMount - ); - g_bAutoMount = m_bAutoMount; - m_Codepage.ReleaseBuffer(-1); - m_sPrefix.ReleaseBuffer(-1); - m_sSuffix.ReleaseBuffer(-1); - - RegisterDeviceInterface(DiskClassGuid, &m_hUsbNotify); - - return TRUE; // return TRUE unless you set the focus to a control -} - -void CExt2MgrDlg::OnSysCommand(UINT nID, LPARAM lParam) -{ - if ((nID & 0xFFF0) == IDM_ABOUTBOX) { - CAboutDlg dlgAbout; - dlgAbout.DoModal(); - } else if ((nID & 0xFFF0) == SC_MINIMIZE) { - m_Tray.ShowIcon(); - ShowWindow(SW_HIDE); - } else if ((nID & 0xFFF0) == SC_CLOSE) { - SendMessage(WM_COMMAND, ID_EXIT, 0); - } else if ((nID & 0xFFF0) == IDM_CLOSE_SPLASH) { - if (m_splash) { - m_splash->CloseSplash(); - delete m_splash; - m_splash = NULL; - } - } else { - CDialog::OnSysCommand(nID, lParam); - } -} - -BOOL CExt2MgrDlg::OnDeviceChange(UINT nEventType, DWORD_PTR dwData) -{ - PDEV_BROADCAST_HDR lpdb = (PDEV_BROADCAST_HDR)dwData; - PDEV_BROADCAST_DEVICEINTERFACE pdbch = (PDEV_BROADCAST_DEVICEINTERFACE)dwData; - if (pdbch && pdbch->dbcc_devicetype == DBT_DEVTYP_DEVICEINTERFACE) { - - if (nEventType == DBT_DEVICEARRIVAL || DBT_DEVICEREMOVECOMPLETE) { - KillTimer('REFR'); - SetTimer('REFR', 1000, NULL); - } - - return TRUE; - } - - switch (nEventType) { - - case DBT_DEVICEARRIVAL: - - if (lpdb->dbch_devicetype == DBT_DEVTYP_VOLUME) { - PDEV_BROADCAST_VOLUME lpdbv = (PDEV_BROADCAST_VOLUME)lpdb; - DriversChangeNotify(lpdbv->dbcv_unitmask, TRUE); - Ext2AddLetterMask((ULONGLONG)(lpdbv->dbcv_unitmask)); - } - - break; - case DBT_DEVICEQUERYREMOVE: - break; - case DBT_DEVICEQUERYREMOVEFAILED: - break; - case DBT_DEVICEREMOVEPENDING: - break; - case DBT_DEVICEREMOVECOMPLETE: - if (lpdb->dbch_devicetype == DBT_DEVTYP_VOLUME) { - PDEV_BROADCAST_VOLUME lpdbv = (PDEV_BROADCAST_VOLUME)lpdb; - DriversChangeNotify(lpdbv->dbcv_unitmask, FALSE); - } - break; - case DBT_DEVICETYPESPECIFIC: - break; - case DBT_CONFIGCHANGED: - break; - default: - break; - } - - return TRUE; -} - -void CExt2MgrDlg::OnDestroy() -{ - KillTimer(ID_INDICATOR_TIME); - - Ext2CleanupDisks(); - Ext2CleanupCdroms(); - Ext2CleanupVolumes(); - Ext2CleanupDrvLetters(); - - OnPerfStop(); - - if (m_hUsbNotify) { - UnregisterDeviceNotification(m_hUsbNotify); - m_hUsbNotify = NULL; - } - - if (m_hAccel) { - DestroyAcceleratorTable(m_hAccel); - m_hAccel = NULL; - } - - CDialog::OnDestroy(); -} - -// 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 CExt2MgrDlg::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 CExt2MgrDlg::OnQueryDragIcon() -{ - return (HCURSOR) m_hIcon; -} - -void CExt2MgrDlg::OnSize(UINT nType, int cx, int cy) -{ - int i = 0; - int ctlId[] = {IDC_VOLUME_LIST, IDC_DISK_LIST, 0}; - - return; - - // create an instance of the CRect object - CRect crw, cri; - - do { - - CWnd *pWnd = GetDlgItem(ctlId[i]); - if (pWnd) { - pWnd->GetWindowRect(&cri); - ScreenToClient(&cri); - pWnd->SetWindowPos(pWnd, - cri.left * cx / crw.Width(), - cri.top * cy / crw.Height(), - cri.Width() * cx / crw.Width(), - cri.Height() * cy / crw.Height(), - SWP_NOZORDER | SWP_SHOWWINDOW); - } - - } while (ctlId[++i]); -} - -LRESULT CExt2MgrDlg::OnTrayNotification(WPARAM wParam,LPARAM lParam) -{ - switch(LOWORD(lParam)) - { - case WM_LBUTTONUP: - m_bHide = FALSE; - ShowWindow(SW_SHOW); - SendMessage(WM_SYSCOMMAND, SC_RESTORE); - break; - } - - return m_Tray.OnTrayNotification(wParam,lParam); -} - -void CExt2MgrDlg::OnAbout() -{ - // TODO: Add your command handler code here - SendMessage(WM_SYSCOMMAND, IDM_ABOUTBOX); -} - -void CExt2MgrDlg::OnExit() -{ - if (TRUE) { - /* AfxMessageBox("Are you sure to exit ? ",MB_YESNO,0) == IDYES */ - EndDialog(0); - } -} - -void CExt2MgrDlg::OnOK() -{ -} - -void CExt2MgrDlg::OnCancel() -{ -} - -void CExt2MgrDlg::OnRefresh() -{ - m_bHandleChange = FALSE; - m_bFocusVolume = FALSE; - m_bFocusDisk = FALSE; - - Ext2AutoRemoveDeadLetters(); - - /* cleanup all the disk/volume structures */ - Ext2CleanupDisks(); - Ext2CleanupCdroms(); - Ext2CleanupVolumes(); - Ext2CleanupDrvLetters(); - - /* loading system configurations */ - if (Ext2QuerySysConfig()) { - Ext2LoadDisks(); - Ext2LoadCdroms(); - if (Ext2LoadVolumes()) { - Ext2LoadRemovableVolumes(); - Ext2LoadDrvLetters(); - Ext2LoadCdromDrvLetters(); - Ext2LoadAllVolumeDrvLetters(); - Ext2LoadAllDiskPartitions(); - if (g_bAutoRemoveDeadLetters) { - Ext2AutoRemoveDeadLetters(); - } - if (Ext2ProcessExt2Volumes()) { - } - } - } else { - return; - } - - /* updating the volume list */ - Ext2RefreshVolumeList(&m_VolumeList); - - /* updating the disk list */ - Ext2RefreshDiskList(&m_DiskView); - - m_bHandleChange = TRUE; -} - -void CExt2MgrDlg::OnService() -{ - // TODO: Add your command handler code here - CServiceManage SrvDlg; - if (!SrvDlg.m_bInited) { - AfxMessageBox("Cannot query Ext2Fsd service !", MB_OK|MB_ICONSTOP); - return; - } - - /* query global parameters */ - Ext2QueryGlobalProperty( - &m_nStartmode, - (BOOL *)&m_bReadonly, - (BOOL *)&m_bExt3Writable, - (CHAR *)m_Codepage.GetBuffer(CODEPAGE_MAXLEN), - (CHAR *)m_sPrefix.GetBuffer(HIDINGPAT_LEN), - (CHAR *)m_sSuffix.GetBuffer(HIDINGPAT_LEN), - (BOOL *)&m_bAutoMount - ); - g_bAutoMount = m_bAutoMount; - m_Codepage.ReleaseBuffer(-1); - m_sPrefix.ReleaseBuffer(-1); - m_sSuffix.ReleaseBuffer(-1); - - SrvDlg.m_nStartmode = m_nStartmode; - SrvDlg.m_bReadonly = m_bReadonly; - SrvDlg.m_bExt3Writable = m_bExt3Writable; - SrvDlg.m_bAutoMount = m_bAutoMount; - SrvDlg.m_Codepage = m_Codepage; - SrvDlg.m_sPrefix = m_sPrefix; - SrvDlg.m_sSuffix = m_sSuffix; - if (IDOK == SrvDlg.DoModal()) { - /* query global parameters */ - Ext2QueryGlobalProperty( - &m_nStartmode, - (BOOL *)&m_bReadonly, - (BOOL *)&m_bExt3Writable, - (CHAR *)m_Codepage.GetBuffer(CODEPAGE_MAXLEN), - (CHAR *)m_sPrefix.GetBuffer(HIDINGPAT_LEN), - (CHAR *)m_sSuffix.GetBuffer(HIDINGPAT_LEN), - (BOOL *)&m_bAutoMount - ); - g_bAutoMount = m_bAutoMount; - } -} - - -void CExt2MgrDlg::OnChangeProperty() -{ - CExt2Attribute EA; - - PEXT2_VOLUME_PROPERTY3 EVP = NULL; - - PEXT2_VOLUME volume = NULL; - PEXT2_CDROM cdrom = NULL; - - if (m_bFocusVolume) { - if (m_type == EXT2_VOLUME_MAGIC) { - volume = (PEXT2_VOLUME) m_sdev; - EVP = &volume->EVP; - } else if (m_type == EXT2_CDROM_DEVICE_MAGIC) { - cdrom = (PEXT2_CDROM) m_sdev; - EVP = &cdrom->EVP; - } - } else { - if (m_type == EXT2_PART_MAGIC) { - PEXT2_PARTITION part = (PEXT2_PARTITION) m_sdev; - volume = part->Volume; - EVP = &volume->EVP; - } else if (m_type == EXT2_CDROM_VOLUME_MAGIC || - m_type == EXT2_CDROM_DEVICE_MAGIC ) { - cdrom = (PEXT2_CDROM) m_sdev; - EVP = &cdrom->EVP; - } - } - - if (EVP) { - - NT::NTSTATUS status; - HANDLE Handle = NULL; - CString s; - - EA.m_EVP = EVP; - if (volume) { - if (volume->Part) - EA.m_DevName = volume->Part->Name; - else - EA.m_DevName = volume->Name; - } else { - EA.m_bCdrom = TRUE; - EA.m_DevName = cdrom->Name; - } - - status = Ext2Open(EA.m_DevName.GetBuffer(EA.m_DevName.GetLength()), - &Handle, EXT2_DESIRED_ACCESS); - - if (!NT_SUCCESS(status)) { - - s.Format("Ext2Fsd service isn't started.\n"); - AfxMessageBox(s, MB_OK | MB_ICONSTOP); - - } else { - - if (!Ext2QueryExt2Property(Handle, EVP)) { - Ext2Close(&Handle); - return; - } - - Ext2Close(&Handle); - } - - EA.m_MainDlg = (CWnd *)this; - if (EA.DoModal() == IDOK) { - } - if (volume) { - UpdateVolume(volume); - } else if (cdrom) { - UpdateCdrom(cdrom); - } - } -} - -void CExt2MgrDlg::OnFormat() -{ - CString str; - // TODO: Add your command handler code here - if (m_bFocusVolume) { - str.Format("Formating volume item: %d", m_IndexVolume); - } - if (m_bFocusDisk) { - str.Format("Formating disk item: %d", m_IndexDisk); - } - - if (!str.IsEmpty()) - AfxMessageBox(str); -} - -void CExt2MgrDlg::OnWindowPosChanging(WINDOWPOS* lpwndpos) -{ - if(m_bHide) - lpwndpos->flags &= ~SWP_SHOWWINDOW; - - CDialog::OnWindowPosChanging(lpwndpos); -} - -BOOL CExt2MgrDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) -{ - // TODO: Add your specialized code here and/or call the base class - - LPNMHDR pNmhdr = (LPNMHDR)lParam; - - return CDialog::OnNotify(wParam, lParam, pResult); -} - -void CExt2MgrDlg::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct) -{ - if (nIDCtl == IDC_DISK_LIST) { - m_DiskView.MeasureItem(lpMeasureItemStruct); - } else { - CDialog::OnMeasureItem(nIDCtl, lpMeasureItemStruct); - } -} - -void CExt2MgrDlg::OnDblclkDiskList(NMHDR* pNMHDR, LRESULT* pResult) -{ - // TODO: Add your control notification handler code here - BOOL IsExt2 = FALSE; - m_bFocusVolume = FALSE; - m_bFocusDisk = TRUE; - m_IndexDisk = m_DiskView.GetSelectionMark(); - - if (!m_bFsStarted) { - m_bFsStarted = Ext2IsServiceStarted(); - } - - if (QuerySelectedItem(&IsExt2)) { - if (IsExt2 && m_bFsStarted) { - SendMessage(WM_COMMAND, ID_CHANGE, 0); - } else { - SendMessage(WM_COMMAND, ID_PROPERTY, 0); - } - } - - *pResult = 0; -} - -void CExt2MgrDlg::OnSetfocusDiskList(NMHDR* pNMHDR, LRESULT* pResult) -{ - // TODO: Add your control notification handler code here - m_bFocusDisk = TRUE; - m_bFocusVolume = FALSE; - // m_bar.SetPaneText(0, CString("Disk: Set Focus")); - - QuerySelectedItem(NULL); - *pResult = 0; -} - -void CExt2MgrDlg::OnKillfocusDiskList(NMHDR* pNMHDR, LRESULT* pResult) -{ - // TODO: Add your control notification handler code here - m_bFocusDisk = FALSE; - // m_bar.SetPaneText(0, CString("Disk: Focus Lost")); - - QuerySelectedItem(NULL); - *pResult = 0; -} - -void CExt2MgrDlg::OnRclickDiskList(NMHDR* pNMHDR, LRESULT* pResult) -{ - // TODO: Add your control notification handler code here - RECT rect; - CString s; - - m_bFocusVolume = FALSE; - m_bFocusDisk = TRUE; - m_IndexDisk = m_DiskView.GetSelectionMark(); - - if (!QuerySelectedItem(NULL)) { - return; - } - - while (m_Menu.DeleteMenu(0, MF_BYPOSITION)); - - if (m_bFocusDisk) { - - if (m_type == EXT2_CDROM_DEVICE_MAGIC || - m_type == EXT2_CDROM_VOLUME_MAGIC ) { - - PEXT2_CDROM cdrom = (PEXT2_CDROM) m_sdev; - - s.LoadString(IDS_DRV_QUICK_MOUNT); - if (0 == cdrom->DrvLetters) - m_Menu.AppendMenu(MF_STRING, ID_DRV_QUICK_MOUNT, (LPCTSTR)s); - - s.LoadString(IDS_CHANGE_DRVLETTER); - m_Menu.AppendMenu(MF_STRING, ID_DRV_LETTER, (LPCTSTR)s); - - m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); - if (cdrom->bLoaded && !cdrom->bEjected && - (cdrom->EVP.bExt2 || cdrom->EVP.bExt3)) { - - s.LoadString(IDS_EXT2_MANAGEMENT); - m_Menu.AppendMenu(MF_STRING, ID_CHANGE, (LPCTSTR)s); - } - - m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); - - s.LoadString(IDS_COPY_ITEM_TO_CLIP); - m_Menu.AppendMenu(MF_STRING, ID_COPY, (LPCTSTR)s); - m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); - - } else if (m_type == EXT2_PART_MAGIC) { - - PEXT2_PARTITION part = (PEXT2_PARTITION) m_sdev; - PEXT2_VOLUME volume = part->Volume; - - if (volume && !volume->bDynamic) { - s.LoadString(IDS_DRV_QUICK_MOUNT); - if (0 == volume->DrvLetters) - m_Menu.AppendMenu(MF_STRING, ID_DRV_QUICK_MOUNT, (LPCTSTR)s); - - s.LoadString(IDS_CHANGE_DRVLETTER); - m_Menu.AppendMenu(MF_STRING, ID_DRV_LETTER, (LPCTSTR)s); - m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); - } - - if (volume && volume->bRecognized && (volume->EVP.bExt2 || volume->EVP.bExt3)) { - s.LoadString(IDS_EXT2_MANAGEMENT); - m_Menu.AppendMenu(MF_STRING, ID_CHANGE, (LPCTSTR)s); - m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); - } - - if (part->Entry) { - s.LoadString(IDS_FLUSH_BUFFER); - m_Menu.AppendMenu(MF_STRING, ID_FLUSH_BUFFER, (LPCTSTR)s); - - if (part->PartType == PARTITION_STYLE_MBR) { - s.LoadString(IDS_CHANGE_PARTID); - m_Menu.AppendMenu(MF_STRING, ID_CHANGE_PARTTYPE, (LPCTSTR)s); - } - m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); - } - - s.LoadString(IDS_COPY_ITEM_TO_CLIP); - m_Menu.AppendMenu(MF_STRING, ID_COPY, (LPCTSTR)s); - - m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); - - } else { - ASSERT(m_type == EXT2_DISK_MAGIC); - } - } - - s.LoadString(IDS_RELOAD_REFRESH); - m_Menu.AppendMenu(MF_STRING, ID_REFRESH, (LPCTSTR)s); - m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); - - s.LoadString(IDS_SHOW_PROPERTY); - m_Menu.AppendMenu(MF_STRING, ID_PROPERTY, (LPCTSTR)s); - m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); - - s.LoadString(IDS_SERVICE_MANAGE); - m_Menu.AppendMenu(MF_STRING, ID_SERVICE, (LPCTSTR)s); - - s.LoadString(IDS_PERFMEM_STAT); - m_Menu.AppendMenu(MF_STRING, ID_PERFSTAT, (LPCTSTR)s); - - s.LoadString(IDS_REMOVE_DEAD_LETTER); - m_Menu.AppendMenu(MF_STRING, ID_REMOVE_DEAD_LETTER, (LPCTSTR)s); - - m_DiskView.GetWindowRect(&rect); - m_Menu.TrackPopupMenu( TPM_LEFTALIGN, - rect.left + m_DiskView.m_Point.x, - rect.top + m_DiskView.m_Point.y, - m_DiskView.GetSafeOwner(), - NULL); - - *pResult = 0; -} - - -void CExt2MgrDlg::OnClickDiskList(NMHDR* pNMHDR, LRESULT* pResult) -{ - // TODO: Add your control notification handler code here - m_bFocusVolume = FALSE; - m_bFocusDisk = TRUE; - m_IndexDisk = m_DiskView.GetSelectionMark(); - - QuerySelectedItem(NULL); - *pResult = 0; -} - -void CExt2MgrDlg::OnDblclkVolumeList(NMHDR* pNMHDR, LRESULT* pResult) -{ - // TODO: Add your control notification handler code here - BOOL bIsExt2 = FALSE; - - if (!m_bFsStarted) { - m_bFsStarted = Ext2IsServiceStarted(); - } - - m_bFocusVolume = TRUE; - m_IndexVolume = m_VolumeList.GetSelectionMark();; - m_bFocusDisk = FALSE; - if (QuerySelectedItem(&bIsExt2)) { - if (bIsExt2 && m_bFsStarted) { - SendMessage(WM_COMMAND, ID_CHANGE, 0); - } else { - SendMessage(WM_COMMAND, ID_PROPERTY, 0); - } - } - *pResult = 0; -} - -void CExt2MgrDlg::OnSetfocusVolumeList(NMHDR* pNMHDR, LRESULT* pResult) -{ - // TODO: Add your control notification handler code here - //m_bar.SetPaneText(0, CString("Volume: Set Focus")); - m_bFocusVolume = TRUE; - *pResult = 0; - QuerySelectedItem(NULL); -} - -void CExt2MgrDlg::OnKillfocusVolumeList(NMHDR* pNMHDR, LRESULT* pResult) -{ - m_bFocusVolume = FALSE; - //m_bar.SetPaneText(0, CString("Volume: Focus Lost")); - - // TODO: Add your control notification handler code here - *pResult = 0; - QuerySelectedItem(NULL); -} - -void CExt2MgrDlg::OnRclickVolumeList(NMHDR* pNMHDR, LRESULT* pResult) -{ - RECT rect; - CString s; - - m_bFocusVolume = TRUE; - m_IndexVolume = m_VolumeList.GetSelectionMark();; - m_bFocusDisk = FALSE; - - if (!QuerySelectedItem(NULL)) { - return; - } - - while (m_Menu.DeleteMenu(0, MF_BYPOSITION)); - - if (m_bFocusVolume) { - - if (m_type == EXT2_VOLUME_MAGIC) { - - PEXT2_VOLUME volume = (PEXT2_VOLUME) m_sdev; - PEXT2_PARTITION part; - - s.LoadString(IDS_DRV_QUICK_MOUNT); - if (0 == volume->DrvLetters) - m_Menu.AppendMenu(MF_STRING, ID_DRV_QUICK_MOUNT, (LPCTSTR)s); - - s.LoadString(IDS_CHANGE_DRVLETTER); - m_Menu.AppendMenu(MF_STRING, ID_DRV_LETTER, (LPCTSTR)s); - m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); - - if (volume->bRecognized && (volume->EVP.bExt2 || volume->EVP.bExt3)) { - s.LoadString(IDS_EXT2_MANAGEMENT); - m_Menu.AppendMenu(MF_STRING, ID_CHANGE, (LPCTSTR)s); - m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); - } - - s.LoadString(IDS_FLUSH_BUFFER); - m_Menu.AppendMenu(MF_STRING, ID_FLUSH_BUFFER, (LPCTSTR)s); - - part = Ext2QueryVolumePartition(volume); - if (part && part->PartType == PARTITION_STYLE_MBR) { - s.LoadString(IDS_CHANGE_PARTID); - m_Menu.AppendMenu(MF_STRING, ID_CHANGE_PARTTYPE, (LPCTSTR)s); - } - - } else if (m_type == EXT2_CDROM_DEVICE_MAGIC || - m_type == EXT2_CDROM_VOLUME_MAGIC ) { - - PEXT2_CDROM cdrom = (PEXT2_CDROM)m_sdev; - - s.LoadString(IDS_DRV_QUICK_MOUNT); - if (0 == cdrom->DrvLetters) - m_Menu.AppendMenu(MF_STRING, ID_DRV_QUICK_MOUNT, (LPCTSTR)s); - - s.LoadString(IDS_CHANGE_DRVLETTER); - m_Menu.AppendMenu(MF_STRING, ID_DRV_LETTER, (LPCTSTR)s); - - if (cdrom->bLoaded && !cdrom->bEjected && - (cdrom->EVP.bExt2 || cdrom->EVP.bExt3)) { - m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); - s.LoadString(IDS_EXT2_MANAGEMENT); - m_Menu.AppendMenu(MF_STRING, ID_CHANGE, (LPCTSTR)s); - } - } - - m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); - s.LoadString(IDS_COPY_ITEM_TO_CLIP); - m_Menu.AppendMenu(MF_STRING, ID_COPY, (LPCTSTR)s); - m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); - } - - s.LoadString(IDS_RELOAD_REFRESH); - m_Menu.AppendMenu(MF_STRING, ID_REFRESH, (LPCTSTR)s); - m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); - - s.LoadString(IDS_SHOW_PROPERTY); - m_Menu.AppendMenu(MF_STRING, ID_PROPERTY, (LPCTSTR)s); - m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); - - s.LoadString(IDS_SERVICE_MANAGE); - m_Menu.AppendMenu(MF_STRING, ID_SERVICE, (LPCTSTR)s); - - s.LoadString(IDS_PERFMEM_STAT); - m_Menu.AppendMenu(MF_STRING, ID_PERFSTAT, (LPCTSTR)s); - - s.LoadString(IDS_REMOVE_DEAD_LETTER); - m_Menu.AppendMenu(MF_STRING, ID_REMOVE_DEAD_LETTER, (LPCTSTR)s); - - m_VolumeList.GetWindowRect(&rect); - m_Menu.TrackPopupMenu(TPM_LEFTALIGN, - rect.left + m_VolumeList.m_Point.x , - rect.top + m_VolumeList.m_Point.y, - m_VolumeList.GetSafeOwner(), NULL); - - *pResult = 0; -} - - -void CExt2MgrDlg::OnClickVolumeList(NMHDR* pNMHDR, LRESULT* pResult) -{ - m_bFocusVolume = TRUE; - m_IndexVolume = m_VolumeList.GetSelectionMark();; - m_bFocusDisk = FALSE; - - QuerySelectedItem(NULL); - - *pResult = 0; -} - - -void CExt2MgrDlg::OnProperty() -{ - PVOID sdev = QuerySelectedItem(NULL); - if (sdev) { - CProperties PPD; - PPD.m_bdisk = m_bFocusDisk; - PPD.m_type = m_type; - PPD.m_sdev = sdev; - PPD.DoModal(); - } -} - -VOID -CExt2MgrDlg::DriversChangeNotify( - ULONG drvsMask, - BOOL bArrival - ) -{ - for (ULONG i=0; i < 26; i++) { - - PEXT2_LETTER drvLetter = &drvLetters[i]; - - if (drvsMask & (1 << i)) { - DriverChangeNotify(drvLetter, bArrival); - } - } -} - -VOID -CExt2MgrDlg::DriverLetterChangeNotify( - CHAR cLetter, - BOOL bArrival - ) -{ - PEXT2_LETTER drvLetter = NULL; - - if (cLetter >= '0' && cLetter <= '9') { - drvLetter = &drvDigits[cLetter - '0']; - } else if (cLetter >= 'A' && cLetter <= 'Z') { - drvLetter = &drvLetters[cLetter - 'A']; - } - - if (drvLetter) { - DriverChangeNotify(drvLetter, bArrival); - } -} - -VOID -CExt2MgrDlg::DriverChangeNotify( - PEXT2_LETTER drvLetter, - BOOL bArrival - ) -{ - ULONGLONG LetterMask = 0; - ULONG i; - - if (!m_bHandleChange) { - return; - } - - if (bArrival) { - if (!drvLetter->bUsed) { - Ext2CleanDrvLetter(drvLetter); - Ext2QueryDrvLetter(drvLetter); - } - } - - if (drvLetter->Letter >= '0' && drvLetter->Letter <= '9') { - LetterMask = ((ULONGLONG) 1) << (drvLetter->Letter - '0' + 32); - } else if (drvLetter->Letter >= 'A' && drvLetter->Letter <= 'Z') { - LetterMask = ((ULONGLONG) 1) << (drvLetter->Letter - 'A'); - } - - if (drvLetter->bUsed) { - - if (NULL != drvLetter->Extent) { - - PEXT2_VOLUME Volume = &gVols[0]; - for (i=0; i < g_nVols && Volume != NULL; i++) { - if (Ext2CompareExtents(drvLetter->Extent, Volume->Extent)) { - if (bArrival) { - Volume->DrvLetters |= LetterMask; - } else { - Volume->DrvLetters &= ~LetterMask; - } - UpdateVolume(Volume); - break; - } - Volume = Volume->Next; - } - } - - for (i=0; i < g_nCdroms; i++) { - PEXT2_CDROM Cdrom = &gCdroms[i]; - if (!_stricmp(drvLetters->SymLink, Cdrom->Name)) { - if (bArrival) { - Cdrom->DrvLetters |= LetterMask; - } else { - Cdrom->DrvLetters &= ~LetterMask; - } - UpdateCdrom(Cdrom); - break; - } - } - } - - if (!bArrival) { - - //Ext2SymLinkRemoval(drvLetter->Letter); - //Ext2RemoveDosSymLink(drvLetter->Letter); - - if (drvLetter->bUsed) { - //Ext2DismountVolume(drvLetter->SymLink); - Ext2RemoveMountPoint(drvLetter, FALSE); - } - } -} - -void CExt2MgrDlg::UpdateVolume(PEXT2_VOLUME volume) -{ - for (int i = 0; i < m_VolumeList.GetItemCount(); i++) { - PULONG data = (PULONG)m_VolumeList.GetItemData(i); - if (!data) { - continue; - } - if (*data == EXT2_VOLUME_MAGIC && - data == (PULONG)volume) { - Ext2RefreshVLVI(&m_VolumeList, volume, i); - } - } - - for (int i = 0; i < m_DiskView.GetItemCount(); i++) { - PEXT2_PARTITION part; - part = (PEXT2_PARTITION)m_DiskView.GetItemData(i); - if (!part) { - continue; - } - if (part->Magic == EXT2_PART_MAGIC && - part->Volume == volume) { - part->DrvLetters = volume->DrvLetters; - Ext2RefreshDVPT(&m_DiskView, part, i); - } - } -} - -void CExt2MgrDlg::UpdateCdrom(PEXT2_CDROM cdrom) -{ - for (int i = 0; i < m_VolumeList.GetItemCount(); i++) { - PULONG data = (PULONG)m_VolumeList.GetItemData(i); - if (!data) { - continue; - } - if (*data == EXT2_CDROM_DEVICE_MAGIC && - data == (PULONG)cdrom) { - Ext2RefreshVLCD(&m_VolumeList, cdrom, i); - } - } - - for (int i = 0; i < m_DiskView.GetItemCount(); i++) { - PULONG data = (PULONG)m_DiskView.GetItemData(i); - if (!data) { - continue; - } - if (*data == EXT2_CDROM_VOLUME_MAGIC && - (PUCHAR)data == ((PUCHAR)cdrom + 4)) { - Ext2RefreshDVCM(&m_DiskView, cdrom, i); - } - } -} - -void CExt2MgrDlg::UpdatePartition(PEXT2_PARTITION part) -{ - int i; - - if (part->Volume) { - part->Volume->DrvLetters = part->DrvLetters; - UpdateVolume(part->Volume); - return; - } - - for (i = 0; i < m_DiskView.GetItemCount(); i++) { - - PULONG data = (PULONG)m_DiskView.GetItemData(i); - if (!data) { - continue; - } - if (*data == EXT2_PART_MAGIC && - data == (PULONG)part) { - Ext2RefreshDVPT(&m_DiskView, part, i); - } - } -} - -void CExt2MgrDlg::OnDrvLetter() -{ - // TODO: Add your command handler code here - CMountPoints mntPoint; - if (m_bFocusVolume) { - if (m_type == EXT2_VOLUME_MAGIC) { - mntPoint.m_Volume = (PEXT2_VOLUME) m_sdev; - } else { - mntPoint.m_Cdrom = (PEXT2_CDROM) m_sdev; - } - } else { - if (m_type == EXT2_CDROM_DEVICE_MAGIC || - m_type == EXT2_CDROM_VOLUME_MAGIC ) { - mntPoint.m_Cdrom = (PEXT2_CDROM) m_sdev; - } else { - mntPoint.m_Part = (PEXT2_PARTITION) m_sdev; - } - } - - mntPoint.m_MainDlg = this; - mntPoint.DoModal(); - - /* to be done in OnDeviceChange */ - - /* - if (mntPoint.m_bUpdated) { - - if (mntPoint.m_Volume) { - UpdateVolume(mntPoint.m_Volume); - } - if (mntPoint.m_Cdrom) { - UpdateCdrom(mntPoint.m_Cdrom); - } - if (mntPoint.m_Part) { - UpdatePartition(mntPoint.m_Part); - } - } - */ -} - -void CExt2MgrDlg::OnDrvQuickMount() -{ - CHAR drv = 0; - - if (m_bFocusVolume) { - if (m_type == EXT2_VOLUME_MAGIC) { - PEXT2_VOLUME v = (PEXT2_VOLUME)m_sdev; - if (0 == v->DrvLetters) { - drv = Ext2MountVolume(v->Name); - if (drv) { - v->DrvLetters |= ((ULONGLONG) 1) << (drv - 'A'); - UpdateVolume(v); - } - } - } else { - PEXT2_CDROM c = (PEXT2_CDROM) m_sdev; - if (0 == c->DrvLetters) { - drv = Ext2MountVolume(c->Name); - if (drv) { - c->DrvLetters |= ((ULONGLONG) 1) << (drv - 'A'); - UpdateCdrom(c); - } - } - } - } else { - if (m_type == EXT2_CDROM_DEVICE_MAGIC || - m_type == EXT2_CDROM_VOLUME_MAGIC ) { - PEXT2_CDROM c = (PEXT2_CDROM) m_sdev; - if (0 == c->DrvLetters) { - drv = Ext2MountVolume(c->Name); - if (drv) { - c->DrvLetters |= ((ULONGLONG) 1) << (drv - 'A'); - UpdateCdrom(c); - } - } - } else { - PEXT2_PARTITION p = (PEXT2_PARTITION) m_sdev; - if (0 == p->DrvLetters) { - drv = Ext2MountVolume(p->Name); - if (drv) { - p->DrvLetters |= ((ULONGLONG) 1) << (drv - 'A'); - UpdatePartition(p); - } - } - } - } -} - - -void CExt2MgrDlg::OnDonate() -{ - // TODO: Add your command handler code here - CDonate Donate; - Donate.DoModal(); -} - -void CExt2MgrDlg::OnCopy() -{ - CHAR Data[256]; - BOOL rc = FALSE; - - // TODO: Add your command handler code here - if (m_bFocusVolume) { - rc = m_VolumeList.QuerySubItemText(m_IndexVolume, Data, 256); - } else if (m_bFocusDisk) { - rc = m_DiskView.QuerySubItemText(m_IndexDisk, Data, 256); - } - - if (rc && OpenClipboard()) { - - HGLOBAL clipbuffer; - char * buffer; - clipbuffer = GlobalAlloc(GMEM_DDESHARE, strlen(Data) + 1); - if (clipbuffer) { - buffer = (char*)GlobalLock(clipbuffer); - if (buffer) { - EmptyClipboard(); - memset(buffer, 0, strlen(Data) + 1); - memcpy(buffer, Data, strlen(Data) + 1); - GlobalUnlock(clipbuffer); - SetClipboardData(CF_TEXT,clipbuffer); - } else { - GlobalFree(clipbuffer); - } - } - CloseClipboard(); - } -} - -void CExt2MgrDlg::OnCopyAll() -{ - BOOL rc = FALSE; - CString s; - - s = Ext2SysInformation(); - - if (!s.IsEmpty() && OpenClipboard()) { - - HGLOBAL clipbuffer; - char * buffer; - clipbuffer = GlobalAlloc(GMEM_DDESHARE, s.GetLength() + 1); - if (clipbuffer) { - buffer = (char*)GlobalLock(clipbuffer); - if (buffer) { - EmptyClipboard(); - memcpy(buffer, (LPCSTR)s, s.GetLength() + 1); - GlobalUnlock(clipbuffer); - SetClipboardData(CF_TEXT,clipbuffer); - } else { - GlobalFree(clipbuffer); - } - } - CloseClipboard(); - } -} - -void CExt2MgrDlg::OnTimer(UINT_PTR nIDEvent) -{ - // TODO: Add your message handler code here and/or call default - - if (nIDEvent == ID_INDICATOR_TIME) { - CString s; - CTime t1; - t1 = CTime::GetCurrentTime(); - s.Format(" %3.3s", t1.Format("%B")); - s += t1.Format(" %d,%Y %H:%M:%S"); - m_bar.SetPaneText(1, s); - } else if (nIDEvent == 'REFR') { - if (m_bHandleChange) - PostMessage(WM_COMMAND, ID_REFRESH, 0); - KillTimer('REFR'); - } else if (nIDEvent == 'REFF') { - PostMessage(WM_COMMAND, ID_REFRESH, 0); - KillTimer('REFF'); - } - - CDialog::OnTimer(nIDEvent); -} - -PVOID CExt2MgrDlg::QuerySelectedItem(PBOOL bIsExt2) -{ - CString str = "Ready"; - PVOID List = NULL; - - PEXT2_CDROM Cdrom = NULL; - PEXT2_DISK Disk = NULL; - PEXT2_VOLUME Volume = NULL; - PEXT2_PARTITION Part = NULL; - - LVITEM lvItem; - memset(&lvItem, 0, sizeof(LVITEM)); - lvItem.mask = LVIF_PARAM | LVIF_IMAGE; - - m_sdev = NULL; - m_type = 0; - - CMenu* pMenu = AfxGetMainWnd()->GetMenu(); - CMenu* pTools = NULL; - pTools = pMenu->GetSubMenu(1); - - if (bIsExt2) { - *bIsExt2 = FALSE; - } - - pTools->EnableMenuItem(ID_DRV_LETTER, MF_BYCOMMAND|MF_GRAYED|MF_DISABLED); - pTools->EnableMenuItem(ID_CHANGE, MF_BYCOMMAND|MF_GRAYED|MF_DISABLED); - pTools->EnableMenuItem(ID_FORMAT, MF_BYCOMMAND|MF_GRAYED|MF_DISABLED); - pTools->EnableMenuItem(ID_PROPERTY, MF_BYCOMMAND|MF_GRAYED|MF_DISABLED); - - if (m_bFocusVolume) { - - if (m_IndexVolume == -1 || - m_IndexVolume >= m_VolumeList.GetItemCount()) { - goto errorout; - } - - lvItem.iItem = m_IndexVolume; - m_VolumeList.GetItem(&lvItem); - - PEXT2_VOLUME Volume = (PEXT2_VOLUME) lvItem.lParam; - if (!Volume) { - goto errorout; - } - Cdrom = (PEXT2_CDROM) Volume; - m_type = Volume->Magic; - - if (Volume->Magic == EXT2_VOLUME_MAGIC) { - str.Format("VOLUME: %s %s %s", - Ext2QueryVolumeLetterStrings( - Volume->DrvLetters, NULL), - Volume->FileSystem, Volume->Name); - m_sdev = (PVOID) Volume; - - if (Volume->bRecognized && (Volume->EVP.bExt2 || Volume->EVP.bExt3)) { - pTools->EnableMenuItem(ID_CHANGE, MF_BYCOMMAND|MF_ENABLED); - } - pTools->EnableMenuItem(ID_FORMAT, MF_BYCOMMAND|MF_ENABLED); - pTools->EnableMenuItem(ID_DRV_LETTER, MF_BYCOMMAND|MF_ENABLED); - pTools->EnableMenuItem(ID_PROPERTY, MF_BYCOMMAND|MF_ENABLED); - - if (bIsExt2 && Volume->bRecognized) { - *bIsExt2 = Volume->EVP.bExt2 || Volume->EVP.bExt3; - } - - } else if (Cdrom->Magic[0] == EXT2_CDROM_DEVICE_MAGIC) { - str.Format("CDROM %d: %s", Cdrom->OrderNo, - Ext2QueryVolumeLetterStrings( - Cdrom->DrvLetters, NULL)); - if (Cdrom->bIsDVD) { - str += " DVD"; - } - m_sdev = (PVOID) Cdrom; - - pTools->EnableMenuItem(ID_DRV_LETTER, MF_BYCOMMAND|MF_ENABLED); - pTools->EnableMenuItem(ID_PROPERTY, MF_BYCOMMAND|MF_ENABLED); - - if (bIsExt2) { - *bIsExt2 = Cdrom->EVP.bExt2 || Cdrom->EVP.bExt3; - } - - } else { - m_IndexVolume = -1; - } - } - - if (m_bFocusDisk) { - - if (m_IndexDisk == -1 || - m_IndexDisk >= m_DiskView.GetItemCount()) { - goto errorout; - } - - lvItem.iItem = m_IndexDisk; - m_DiskView.GetItem(&lvItem); - - PEXT2_DISK Disk = (PEXT2_DISK) lvItem.lParam; - if (!Disk) { - goto errorout; - } - - m_type = Disk->Magic; - - if (Disk->Magic == EXT2_DISK_MAGIC) { - str.Format("DISK %d: %s", Disk->OrderNo, Disk->Name); - m_sdev = (PVOID) Disk; - pTools->EnableMenuItem(ID_PROPERTY, MF_BYCOMMAND|MF_ENABLED); - } else if (Disk->Magic == EXT2_PART_MAGIC) { - BOOL bDynamic = FALSE; - Part = (PEXT2_PARTITION) Disk; - Disk = Part->Disk; - Volume = Part->Volume; - if (!Volume) { - if (Disk->SDD.RemovableMedia) { - if (Disk->bEjected) { - str.Format("DISK %d: No media", Disk->OrderNo); - } else { - str.Format("DISK %d: RAW", Disk->OrderNo); - } - } else { - if (Disk->Layout) { - str.Format("DISK %d: Not recognized", Disk->OrderNo); - } else { - str.Format("DISK %d: RAW", Disk->OrderNo); - } - } - } else { - str.Format("DISK %d PARTITION %d: %s %s", - Disk->OrderNo, Part->Number, - Ext2QueryVolumeLetterStrings( - Part->DrvLetters, NULL), - Part->Volume->FileSystem - ); - } - m_sdev = (PVOID) Part; - if (Volume) { - pTools->EnableMenuItem(ID_FORMAT, MF_BYCOMMAND|MF_ENABLED); - if (Volume->bRecognized && (Volume->EVP.bExt2 || Volume->EVP.bExt3)) - pTools->EnableMenuItem(ID_CHANGE, MF_BYCOMMAND|MF_ENABLED); - if (!Volume->bDynamic) { - pTools->EnableMenuItem(ID_DRV_LETTER, MF_BYCOMMAND|MF_ENABLED); - } - if (bIsExt2 && Volume->bRecognized) { - *bIsExt2 = Volume->EVP.bExt2 || Volume->EVP.bExt3; - } - } else { - if (Disk->SDD.RemovableMedia) { - pTools->EnableMenuItem(ID_DRV_LETTER, MF_BYCOMMAND|MF_ENABLED); - } - } - pTools->EnableMenuItem(ID_PROPERTY, MF_BYCOMMAND|MF_ENABLED); - } else if (Disk->Magic == EXT2_DISK_NULL_MAGIC) { - Disk = (PEXT2_DISK)((PUCHAR)Disk - sizeof(ULONG)); - str.Format("DISK %d: No media", Disk->OrderNo); - m_sdev = (PVOID) Disk; - pTools->EnableMenuItem(ID_PROPERTY, MF_BYCOMMAND|MF_ENABLED); - } else if (Disk->Magic == EXT2_CDROM_VOLUME_MAGIC) { - Cdrom = (PEXT2_CDROM)((PUCHAR)Disk - sizeof(ULONG)); - str.Format("CDROM %d: %s", Cdrom->OrderNo, - Ext2QueryVolumeLetterStrings( - Cdrom->DrvLetters, NULL)); - if (Cdrom->bIsDVD) { - str += " DVD"; - } - m_sdev = (PVOID) Cdrom; - pTools->EnableMenuItem(ID_DRV_LETTER, MF_BYCOMMAND|MF_ENABLED); - pTools->EnableMenuItem(ID_PROPERTY, MF_BYCOMMAND|MF_ENABLED); - } else if (Disk->Magic == EXT2_CDROM_DEVICE_MAGIC){ - Cdrom = (PEXT2_CDROM)Disk; - str.Format("CDROM %d: %s", Cdrom->OrderNo, Cdrom->Name); - pTools->EnableMenuItem(ID_DRV_LETTER, MF_BYCOMMAND|MF_ENABLED); - pTools->EnableMenuItem(ID_PROPERTY, MF_BYCOMMAND|MF_ENABLED); - m_sdev = (PVOID) Cdrom; - } else { - m_IndexDisk = -1; - } - } - -errorout: - - m_bar.SetPaneText(0, str); - - return m_sdev; -} - -void CExt2MgrDlg::OnKeyupVolumeList() -{ - m_bFocusDisk = FALSE; - m_bFocusVolume = TRUE; - - int item = m_VolumeList.GetSelectionMark(); - if (item != -1 && item != m_IndexVolume) { - m_IndexVolume = item; - QuerySelectedItem(NULL); - } -} - -void CExt2MgrDlg::OnKeyupDiskList() -{ - int item = m_DiskView.GetSelectionMark(); - - if (item != -1 && item != m_IndexDisk) { - m_DiskView.SetSelectionMark(item); - m_IndexDisk = item; - QuerySelectedItem(NULL); - } - - if (!m_bFocusDisk) { - m_DiskView.Redraw(); - } - - m_bFocusDisk = TRUE; - m_bFocusVolume = FALSE; -} - -BOOL CExt2MgrDlg::PreTranslateMessage(MSG* pMsg) -{ - // TODO: Add your specialized code here and/or call the base class - - if (pMsg->message==WM_KEYDOWN) { - if (pMsg->wParam == VK_ESCAPE) { - pMsg->wParam = NULL; - PostMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0); - } else if (pMsg->wParam == VK_RETURN) { - pMsg->wParam = NULL; - PostMessage(WM_COMMAND, ID_PROPERTY, 0); - } - } - - if (pMsg->message==WM_SYSKEYDOWN) { - if (pMsg->wParam == VK_RETURN) { - pMsg->wParam = NULL; - PostMessage(WM_COMMAND, ID_CHANGE, 0); - } - } - - if (m_hAccel != NULL) { - if (TranslateAccelerator(m_hWnd, m_hAccel, pMsg)) { - return TRUE; - } - } - - if (pMsg->message == WM_KEYUP) { - - if (GetFocus() == (CWnd *)&m_DiskView) { - OnKeyupDiskList(); - } - - if (GetFocus() == (CWnd *)&m_VolumeList) { - OnKeyupVolumeList(); - } - } - - return CDialog::PreTranslateMessage(pMsg); -} - -void CExt2MgrDlg::OnShowMain() -{ - // TODO: Add your command handler code here - m_bHide = FALSE; - ShowWindow(SW_SHOW); -} - -LRESULT CExt2MgrDlg::OnTerminate(WPARAM wParam,LPARAM lParam) -{ - if (lParam == 0x1234) { - EndDialog(0); - } - - return TRUE; -} - -LRESULT CExt2MgrDlg::OnMountPointNotify(WPARAM wParam,LPARAM lParam) -{ - if (wParam == 'DA') { - DriverLetterChangeNotify((CHAR)lParam, TRUE); - } else if (wParam == 'DR'){ - DriverLetterChangeNotify((CHAR)lParam, FALSE); - } - - return TRUE; -} - -void CExt2MgrDlg::OnHelp() -{ - // TODO: Add your command handler code here - CHAR szFullPathName [MAX_PATH]; - CHAR szDrive [MAX_PATH]; - CHAR szDir [MAX_PATH]; - - GetModuleFileName(NULL, szFullPathName, MAX_PATH); - _splitpath(szFullPathName, szDrive, szDir, NULL, NULL); - sprintf(szFullPathName, "%s%sDocuments\\FAQ.txt", szDrive, szDir); - - ShellExecute(this->GetSafeHwnd(), "open", szFullPathName, NULL, NULL, SW_SHOW); -} - -void CExt2MgrDlg::OnInstallService() -{ - Ext2SetManagerAsService(TRUE); -} - -void CExt2MgrDlg::OnRemoveService() -{ - Ext2SetManagerAsService(FALSE); -} - -void CExt2MgrDlg::OnEnableAutorun() -{ - Ext2SetAppAutorun(TRUE); - // Ext2SetManagerAsService(FALSE); - - CMenu* pMenu = AfxGetMainWnd()->GetMenu(); - CMenu* pSubFile = pMenu->GetSubMenu(0); - if (pSubFile) { - if (Ext2RunMgrForCurrentUser()) { - pSubFile->EnableMenuItem(ID_ENABLE_AUTOSTART, MF_BYCOMMAND|MF_GRAYED|MF_DISABLED); - pSubFile->EnableMenuItem(ID_DISABLE_AUTOSTART, MF_BYCOMMAND|MF_ENABLED); - } else { - pSubFile->EnableMenuItem(ID_ENABLE_AUTOSTART, MF_BYCOMMAND|MF_ENABLED); - pSubFile->EnableMenuItem(ID_DISABLE_AUTOSTART, MF_BYCOMMAND|MF_GRAYED|MF_DISABLED); - } - } - -} - -void CExt2MgrDlg::OnDisableAutorun() -{ - Ext2SetAppAutorun(FALSE); - - CMenu* pMenu = AfxGetMainWnd()->GetMenu(); - CMenu* pSubFile = pMenu->GetSubMenu(0); - if (pSubFile) { - if (Ext2RunMgrForCurrentUser()) { - pSubFile->EnableMenuItem(ID_ENABLE_AUTOSTART, MF_BYCOMMAND|MF_GRAYED|MF_DISABLED); - pSubFile->EnableMenuItem(ID_DISABLE_AUTOSTART, MF_BYCOMMAND|MF_ENABLED); - } else { - pSubFile->EnableMenuItem(ID_ENABLE_AUTOSTART, MF_BYCOMMAND|MF_ENABLED); - pSubFile->EnableMenuItem(ID_DISABLE_AUTOSTART, MF_BYCOMMAND|MF_GRAYED|MF_DISABLED); - } - } -} - -void CExt2MgrDlg::OnPerfStat() -{ - if (!m_PerfDlg) { - m_PerfDlg = new CPerfStatDlg; - if (m_PerfDlg) { - m_PerfDlg->Create(IDD_PERFSTAT_DIALOG, this); - } - } - - if (m_PerfDlg) { - m_PerfDlg->ShowWindow(SW_SHOW); - m_PerfDlg->SetForegroundWindow(); - } -} - -void CExt2MgrDlg::OnPerfStop() -{ - if (m_PerfDlg) { - Sleep(100); - delete m_PerfDlg; - m_PerfDlg = NULL; - } -} - - -void -CExt2MgrDlg::RegisterDeviceInterface( - GUID InterfaceClassGuid, - PHDEVNOTIFY hDevNotify - ) -{ - DEV_BROADCAST_DEVICEINTERFACE NotificationFilter; - - ZeroMemory (&NotificationFilter, sizeof(NotificationFilter)); - NotificationFilter.dbcc_size = - sizeof(DEV_BROADCAST_DEVICEINTERFACE); - NotificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; - NotificationFilter.dbcc_classguid = InterfaceClassGuid; - - *hDevNotify = RegisterDeviceNotification( - m_hWnd, - &NotificationFilter, - DEVICE_NOTIFY_WINDOW_HANDLE - ); -} - - -void CExt2MgrDlg::OnFlush() -{ - PEXT2_VOLUME volume = NULL; - PEXT2_PARTITION part = NULL; - - if (m_bFocusVolume) { - if (m_type == EXT2_VOLUME_MAGIC) { - volume = (PEXT2_VOLUME) m_sdev; - } - } else { - if (m_type == EXT2_PART_MAGIC) { - part = (PEXT2_PARTITION) m_sdev; - volume = part->Volume; - } - } - - if (volume) { - Ext2FlushVolume(volume->Name); - } -} - -void CExt2MgrDlg::OnPartType() -{ - CPartitionType PartType; - PEXT2_VOLUME volume = NULL; - PEXT2_PARTITION part = NULL; - CHAR devPath[MAX_PATH]; - - if (m_bFocusVolume) { - if (m_type == EXT2_VOLUME_MAGIC) { - volume = (PEXT2_VOLUME) m_sdev; - } - } else { - if (m_type == EXT2_PART_MAGIC) { - part = (PEXT2_PARTITION) m_sdev; - } - } - - if (volume) { - part = volume->Part; - if (!part) { - return; - } - strcpy(devPath, volume->Name); - } else if (part) { - sprintf(devPath, "\\Device\\Harddisk%u\\Partition%u", - part->Disk->OrderNo, part->Number); - } - - if (part && part->Entry && - part->Entry->PartitionStyle == PARTITION_STYLE_MBR) { - PartType.m_Part = part; - PartType.m_sDevice = devPath; - PartType.DoModal(); - - /* update new partition type */ - if (PartType.m_cPartType) { - - for (int i=0; i < m_DiskView.GetItemCount(); i++) { - if ((ULONG_PTR)part == m_DiskView.GetItemData(i)) { - Ext2RefreshDVPT(&m_DiskView, part, i); - break; - } - } - } - } -} - -void CExt2MgrDlg::OnRemoveDeadLetter() -{ - CDelDeadLetter DelDeadLetter; - DelDeadLetter.DoModal(); -} +// Ext2MgrDlg.cpp : implementation file +// + +#include "stdafx.h" +#include "Ext2Mgr.h" +#include "PartitionType.h" +#include "DelDeadLetter.h" +#include "Ext2MgrDlg.h" +#include "DlgView.h" +#include + +#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(); + + HBITMAP m_hBitmap; + HDC m_hMemDC; + HBITMAP m_hOldBmp; + +// Dialog Data + //{{AFX_DATA(CAboutDlg) + enum { IDD = IDD_ABOUTBOX }; + // CMyHyperLink m_lMail; + //}}AFX_DATA + + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CAboutDlg) + public: + virtual BOOL DestroyWindow(); + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + //{{AFX_MSG(CAboutDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnPaint(); + afx_msg void OnExt2fsd(); + afx_msg void OnDonate(); + afx_msg void OnTimer(UINT_PTR nIDEvent); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + +}; + +CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) +{ + //{{AFX_DATA_INIT(CAboutDlg) + //}}AFX_DATA_INIT +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CAboutDlg) + // DDX_Control(pDX, IDC_AUTHOR, m_lMail); + //}}AFX_DATA_MAP +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) + //{{AFX_MSG_MAP(CAboutDlg) + ON_WM_PAINT() + ON_BN_CLICKED(IDC_EXT2FSD, OnExt2fsd) + ON_BN_CLICKED(ID_DONATE, OnDonate) + ON_WM_TIMER() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +BOOL CAboutDlg::DestroyWindow() +{ + // TODO: Add your specialized code here and/or call the base class + if (m_hBitmap) { + + if (m_hMemDC) { + ::SelectObject(m_hMemDC, m_hOldBmp); + ::DeleteDC(m_hMemDC); + } + + ::DeleteObject (m_hBitmap); + m_hBitmap = NULL; + } + + return CDialog::DestroyWindow(); +} + +BOOL CAboutDlg::OnInitDialog() +{ + CString s; + CHAR Version[0x20]; + CHAR Date[0x20]; + CHAR Time[0x20]; + + CDialog::OnInitDialog(); + + m_hBitmap = (HBITMAP)::LoadImage(GetModuleHandle(NULL), + MAKEINTRESOURCE(IDB_ABOUT_SMALL), + IMAGE_BITMAP, 0, 0, 0); + + if (m_hBitmap) { + m_hMemDC = ::CreateCompatibleDC(this->GetDC()->m_hDC); + m_hOldBmp = (HBITMAP)::SelectObject(m_hMemDC, m_hBitmap); + } + + INT rc = Ext2QueryDrvVersion(Version, Date, Time); + + if (rc < 0) { + s.Format("Ext2Fsd: NOT started !\0"); + } else if (rc > 0) { + s.Format("Ext2Fsd: %s (%s)\0", Version, Date); + } else { + s.Format("Ext2Fsd: < 0.42 (Dec 2007)\0"); + } + SET_TEXT(IDC_DRIVER, s); + s = "Ext2Mgr: 3.00 ("; + s += __DATE__; + s += ")\0"; + SET_TEXT(IDC_PROGRAM, s); + + // Set the target URL + // m_lMail.SetLinkUrl("mailto:Matt Wu?subject=Ext2Fsd Support"); + // Enable showing the Tooltip + // m_lMail.ActiveToolTip(TRUE); + // Set the Tooltiptext + // m_lMail.SetTootTipText("Write a mail to Ext2Fsd group."); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void CAboutDlg::OnPaint() +{ + CPaintDC dc(this); // device context for painting + + int rc; + BITMAP cs; + + rc = ::GetObject(m_hBitmap, sizeof(cs), &cs); + if (rc == 0) { + return; + } + + CRect rect; + CWnd *pAboutWnd = GetDlgItem(IDC_ABOUT_SHOW); + pAboutWnd->GetWindowRect(rect); + ScreenToClient(rect); + + ::StretchBlt(dc.m_hDC, rect.left, rect.top, rect.Width(), rect.Height(), + m_hMemDC, 0, 0, cs.bmWidth, cs.bmHeight, SRCCOPY); + + // Do not call CDialog::OnPaint() for painting messages +} + + +void CAboutDlg::OnExt2fsd() +{ + // TODO: Add your control notification handler code here + ShellExecute(this->GetSafeHwnd(), "open", + "http://www.ext2fsd.com", + NULL, NULL, SW_SHOW ); +} + +void CAboutDlg::OnDonate() +{ + // TODO: Add your control notification handler code here + GetParent()->SendMessage(WM_COMMAND, ID_DONATE); +} + +void CAboutDlg::OnTimer(UINT_PTR nIDEvent) +{ + // TODO: Add your message handler code here and/or call default + + CDialog::OnTimer(nIDEvent); +} + +///////////////////////////////////////////////////////////////////////////// +// CExt2List message handlers + +CExt2List::CExt2List() +{ +} + +CExt2List::~CExt2List() +{ +} + + +BEGIN_MESSAGE_MAP(CExt2List, CListCtrl) + //{{AFX_MSG_MAP(CExt2List) + ON_WM_RBUTTONDOWN() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +void CExt2List::OnRButtonDown(UINT nFlags, CPoint point) +{ + // TODO: Add your message handler code here and/or call default + m_Point = point; + CListCtrl::OnRButtonDown(nFlags, point); +} + +int CExt2List::QuerySubItemText(int item, CHAR *Data, int length) +{ + LV_COLUMN lvc; + LV_ITEM lvi; + int ncol; + CRect rect; + + ::ZeroMemory(&lvc, sizeof(lvc)); + lvc.mask = LVCF_WIDTH |LVCF_FMT; + + for (ncol=0; GetColumn(ncol, &lvc); ncol++) { + + if (ncol > 0) { + GetSubItemRect(item, ncol,LVIR_BOUNDS, rect); + } else { + GetItemRect(item, rect, LVIR_BOUNDS); + rect.right = GetColumnWidth(0); + rect.left = 0; + } + + if (rect.PtInRect(m_Point)) { + + ::ZeroMemory(Data, length); + ::ZeroMemory(&lvi, sizeof(lvi)); + + lvi.iItem = item; + lvi.mask = LVIF_TEXT; + lvi.iSubItem = ncol; + lvi.pszText = Data; + lvi.cchTextMax = length; + + return GetItem(&lvi); + break; + } + } + + return FALSE; +} + + +///////////////////////////////////////////////////////////////////////////// +// CExt2MgrDlg dialog + +CExt2MgrDlg::CExt2MgrDlg(CWnd* pParent /*=NULL*/) + : CDialog(CExt2MgrDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(CExt2MgrDlg) + // 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_bHide = FALSE; + m_bQuiet = FALSE; + m_bService = FALSE; + m_bStat = FALSE; + + m_splash = NULL; + + m_bFocusVolume = FALSE; + m_IndexVolume = 0; + m_bFocusDisk = FALSE; + m_IndexDisk = 0; + + m_type = 0; + m_sdev = NULL; + + m_PerfDlg = NULL; + + m_hUsbNotify = NULL; + m_bHandleChange = FALSE; + + m_hAccel = NULL; + m_bFsStarted = FALSE; + + m_nStartmode = 0; + m_bAutoMount = FALSE; + m_bExt3Writable = FALSE; + m_bReadonly = FALSE; +} + +void CExt2MgrDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CExt2MgrDlg) + DDX_Control(pDX, IDC_VOLUME_LIST, m_VolumeList); + DDX_Control(pDX, IDC_DISK_LIST, m_DiskView); + //}}AFX_DATA_MAP +} + +BEGIN_MESSAGE_MAP(CExt2MgrDlg, CDialog) + //{{AFX_MSG_MAP(CExt2MgrDlg) + ON_WM_WINDOWPOSCHANGING() + ON_WM_SYSCOMMAND() + ON_WM_DEVICECHANGE() + ON_WM_DESTROY() + ON_WM_PAINT() + ON_WM_QUERYDRAGICON() + ON_WM_SIZE() + ON_COMMAND(ID_CHANGE, OnChangeProperty) + ON_COMMAND(ID_REFRESH, OnRefresh) + ON_COMMAND(ID_FORMAT, OnFormat) + ON_COMMAND(ID_SERVICE, OnService) + ON_COMMAND(ID_ABOUT, OnAbout) + ON_COMMAND(ID_EXIT, OnExit) + ON_WM_MEASUREITEM() + ON_NOTIFY(NM_DBLCLK, IDC_DISK_LIST, OnDblclkDiskList) + ON_NOTIFY(NM_KILLFOCUS, IDC_DISK_LIST, OnKillfocusDiskList) + ON_NOTIFY(NM_RCLICK, IDC_DISK_LIST, OnRclickDiskList) + ON_NOTIFY(NM_DBLCLK, IDC_VOLUME_LIST, OnDblclkVolumeList) + ON_NOTIFY(NM_KILLFOCUS, IDC_VOLUME_LIST, OnKillfocusVolumeList) + ON_NOTIFY(NM_RCLICK, IDC_VOLUME_LIST, OnRclickVolumeList) + ON_NOTIFY(NM_CLICK, IDC_DISK_LIST, OnClickDiskList) + ON_NOTIFY(NM_CLICK, IDC_VOLUME_LIST, OnClickVolumeList) + ON_NOTIFY(NM_SETFOCUS, IDC_DISK_LIST, OnSetfocusDiskList) + ON_NOTIFY(NM_SETFOCUS, IDC_VOLUME_LIST, OnSetfocusVolumeList) + ON_COMMAND(ID_PROPERTY, OnProperty) + ON_COMMAND(ID_DONATE, OnDonate) + ON_COMMAND(ID_COPY, OnCopy) + ON_COMMAND(ID_COPYALL, OnCopyAll) + ON_WM_TIMER() + ON_COMMAND(ID_DRV_LETTER, OnDrvLetter) + ON_COMMAND(ID_DRV_QUICK_MOUNT, OnDrvQuickMount) + ON_COMMAND(ID_INSTALL_SERVICE, OnInstallService) + ON_COMMAND(ID_REMOVE_SERVICE, OnRemoveService) + ON_COMMAND(ID_ENABLE_AUTOSTART, OnEnableAutorun) + ON_COMMAND(ID_DISABLE_AUTOSTART, OnDisableAutorun) + ON_COMMAND(ID_SHOW_MAIN, OnShowMain) + ON_MESSAGE(WM_TRAY_ICON_NOTIFY, OnTrayNotification) + ON_MESSAGE(WM_TERMINATE_PROGRAM, OnTerminate) + ON_MESSAGE(WM_MOUNTPOINT_NOTIFY, OnMountPointNotify) + ON_COMMAND(ID_HELP, OnHelp) + ON_COMMAND(ID_PERFSTAT, OnPerfStat) + ON_COMMAND(ID_PERFSTOP, OnPerfStop) + ON_COMMAND(ID_FLUSH_BUFFER, OnFlush) + ON_COMMAND(ID_CHANGE_PARTTYPE, OnPartType) + ON_COMMAND(ID_REMOVE_DEAD_LETTER, OnRemoveDeadLetter) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CExt2MgrDlg message handlers + + +static UINT BASED_CODE indicators[] = +{ + ID_INDICATOR_MESSAGE, + ID_INDICATOR_TIME, + ID_INDICATOR_EXTRA, +}; + +/* A5DCBF10-6530-11D2-901F-00C04FB951ED */ +DEFINE_GUID(GUID_CLASS_USB_DEVICE, 0xA5DCBF10L, 0x6530, 0x11D2, 0x90, 0x1F, 0x00, \ + 0xC0, 0x4F, 0xB9, 0x51, 0xED); + + +BOOL CExt2MgrDlg::OnInitDialog() +{ + CString str; + LONG_PTR dwStyle = 0; + + CDialog::OnInitDialog(); + + /* set windows identifier */ + SetWindowLongPtr(this->GetSafeHwnd(), DWLP_USER, EXT2_DIALOG_MAGIC); + + /* minimize the dialog during startup */ + if (m_bHide) { + PostMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0); + } + + // 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); + } + } + + /* F1 - F12 key */ + m_hAccel = ::LoadAccelerators(AfxGetInstanceHandle(), + MAKEINTRESOURCE(IDR_AKEY_EXT2MGR)); + + // 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 large icon + SetIcon(m_hIcon, FALSE); // Set small icon + + /* create new font for views */ + m_MSSanS.CreatePointFont(80, "MS Sans Serif"); + m_DiskView.SetFont(&m_MSSanS); + m_VolumeList.SetFont(&m_MSSanS); + + /* initialize the disk view */ + dwStyle=GetWindowLongPtr(m_DiskView.GetSafeHwnd(),GWL_STYLE); + dwStyle&=~LVS_TYPEMASK; + dwStyle|=(LVS_REPORT | LVS_OWNERDRAWFIXED); + SetWindowLongPtr(m_DiskView.GetSafeHwnd(),GWL_STYLE,dwStyle); + + m_DiskView.InsertColumn(0, (LPCSTR)"", LVCFMT_CENTER, 80); + str.LoadString(IDS_LISTITEM_TYPE); + m_DiskView.InsertColumn(1, (LPCSTR)str, LVCFMT_LEFT, 60); + + str.LoadString(IDS_LISTITEM_FILESYSTEM); + m_DiskView.InsertColumn(2, (LPCSTR)str, LVCFMT_LEFT, 80); + + str.LoadString(IDS_LISTITEM_TOTALSIZE); + m_DiskView.InsertColumn(3, (LPCSTR)str, LVCFMT_RIGHT, 80); + + str.LoadString(IDS_LISTITEM_USEDSIZE); + m_DiskView.InsertColumn(4, (LPCSTR)str, LVCFMT_RIGHT, 70); + + str.LoadString(IDS_LISTITEM_CODEPAGE); + m_DiskView.InsertColumn(5, (LPCSTR)str, LVCFMT_LEFT, 70); + + str.LoadString(IDS_LISTITEM_PARTID); + m_DiskView.InsertColumn(6, (LPCSTR)str, LVCFMT_LEFT, 120); + + /* initialize volume list */ + dwStyle=GetWindowLongPtr(m_VolumeList.GetSafeHwnd(),GWL_STYLE); + dwStyle&=~LVS_TYPEMASK; + dwStyle|= (LVS_REPORT | LVS_AUTOARRANGE); + SetWindowLongPtr(m_VolumeList.GetSafeHwnd(),GWL_STYLE,dwStyle); + m_VolumeList.SetExtendedStyle(LVS_EX_GRIDLINES); + + m_VolumeList.InsertColumn(0, NULL, LVCFMT_CENTER, 20); + str.LoadString(IDS_LISTITEM_VOLUME); + m_VolumeList.InsertColumn(1, (LPCSTR)str, LVCFMT_LEFT, 60); + + str.LoadString(IDS_LISTITEM_TYPE); + m_VolumeList.InsertColumn(2, (LPCSTR)str, LVCFMT_LEFT, 60); + + str.LoadString(IDS_LISTITEM_FILESYSTEM); + m_VolumeList.InsertColumn(3, (LPCSTR)str, LVCFMT_LEFT, 80); + + str.LoadString(IDS_LISTITEM_TOTALSIZE); + m_VolumeList.InsertColumn(4, (LPCSTR)str, LVCFMT_RIGHT, 80); + + str.LoadString(IDS_LISTITEM_USEDSIZE); + m_VolumeList.InsertColumn(5, (LPCSTR)str, LVCFMT_RIGHT, 70); + + str.LoadString(IDS_LISTITEM_CODEPAGE); + m_VolumeList.InsertColumn(6, (LPCSTR)str, LVCFMT_LEFT, 70); + + str.LoadString(IDS_LISTITEM_DEVOBJ); + m_VolumeList.InsertColumn(7, (LPCSTR)str, LVCFMT_LEFT, 200); + + ListView_SetExtendedListViewStyleEx ( + m_VolumeList.GetSafeHwnd(), + LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT ); + + /* initialize ImageList */ + m_ImageList.Create(16, 16, ILC_COLOR8 | ILC_MASK, 5, 5); + for (UINT nID = IDI_FLOPPY; nID <= IDI_DYNAMIC; nID++) { + CBitmap bitmap; + if (bitmap.LoadBitmap(nID)) { + m_ImageList.Add(&bitmap, RGB(0,0,0)); + bitmap.DeleteObject(); + } + } + m_VolumeList.SetImageList(&m_ImageList, LVSIL_SMALL); + + /* Status Bar Initialization */ + m_bar.Create(this); //We create the status bar + m_bar.SetIndicators(indicators, 3); + + CRect rect; + GetClientRect(&rect); + m_bar.SetPaneInfo(0,ID_INDICATOR_MESSAGE, SBPS_NORMAL,rect.Width()-160); + m_bar.SetPaneInfo(1,ID_INDICATOR_TIME,SBPS_NORMAL ,132); + m_bar.SetPaneInfo(2,ID_INDICATOR_EXTRA,SBPS_STRETCH ,0); + /* m_bar.GetStatusBarCtrl().SetBkColor(RGB(180,180,180)); */ + RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST, + ID_INDICATOR_EXTRA); + + CTime t1; + t1 = CTime::GetCurrentTime(); + + CString s; + s.Format("%s", "Ready"); + m_bar.SetPaneText(0, s); + + s.Format(" %3.3s", t1.Format("%B")); + s += t1.Format(" %d,%Y %H:%M:%S"); + m_bar.SetPaneText(1, s); + + SetTimer(ID_INDICATOR_TIME,1000,NULL); + + /* close the splash window */ + PostMessage(WM_SYSCOMMAND, IDM_CLOSE_SPLASH, 0); + + /* loading system configurations */ + if (Ext2QuerySysConfig()) { + Ext2LoadDisks(); + Ext2LoadCdroms(); + if (Ext2LoadVolumes()) { + Ext2LoadRemovableVolumes(); + Ext2LoadDrvLetters(); + Ext2LoadCdromDrvLetters(); + Ext2LoadAllVolumeDrvLetters(); + Ext2LoadAllDiskPartitions(); + if (g_bAutoRemoveDeadLetters) { + Ext2AutoRemoveDeadLetters(); + } + if (Ext2ProcessExt2Volumes()) { + } + } + } else { + return FALSE; + } + + m_bHandleChange = TRUE; + + /* updating the volume list */ + Ext2RefreshVolumeList(&m_VolumeList); + + /* updating the disk list */ + Ext2RefreshDiskList(&m_DiskView); + + CMenu* pMenu = AfxGetMainWnd()->GetMenu(); + CMenu* pSubFile = pMenu->GetSubMenu(0); + if (pSubFile) { + if (Ext2RunMgrForCurrentUser()) { + pSubFile->EnableMenuItem(ID_ENABLE_AUTOSTART, MF_BYCOMMAND|MF_GRAYED|MF_DISABLED); + pSubFile->EnableMenuItem(ID_DISABLE_AUTOSTART, MF_BYCOMMAND|MF_ENABLED); + } else { + pSubFile->EnableMenuItem(ID_ENABLE_AUTOSTART, MF_BYCOMMAND|MF_ENABLED); + pSubFile->EnableMenuItem(ID_DISABLE_AUTOSTART, MF_BYCOMMAND|MF_GRAYED|MF_DISABLED); + } + } + + m_Menu.CreatePopupMenu(); + + HICON hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); + m_Tray.Create(this, WM_TRAY_ICON_NOTIFY,"Ext2 Volume Manager",hIcon, IDR_TRAY); + + /* start Ext2Fsd statistics window */ + if (m_bStat) { + PostMessage(WM_COMMAND, ID_PERFSTAT, 0); + } + + /* query global parameters */ + Ext2QueryGlobalProperty( + &m_nStartmode, + (BOOL *)&m_bReadonly, + (BOOL *)&m_bExt3Writable, + (CHAR *)m_Codepage.GetBuffer(CODEPAGE_MAXLEN), + (CHAR *)m_sPrefix.GetBuffer(HIDINGPAT_LEN), + (CHAR *)m_sSuffix.GetBuffer(HIDINGPAT_LEN), + (BOOL *)&m_bAutoMount + ); + g_bAutoMount = m_bAutoMount; + m_Codepage.ReleaseBuffer(-1); + m_sPrefix.ReleaseBuffer(-1); + m_sSuffix.ReleaseBuffer(-1); + + RegisterDeviceInterface(DiskClassGuid, &m_hUsbNotify); + + return TRUE; // return TRUE unless you set the focus to a control +} + +void CExt2MgrDlg::OnSysCommand(UINT nID, LPARAM lParam) +{ + if ((nID & 0xFFF0) == IDM_ABOUTBOX) { + CAboutDlg dlgAbout; + dlgAbout.DoModal(); + } else if ((nID & 0xFFF0) == SC_MINIMIZE) { + m_Tray.ShowIcon(); + ShowWindow(SW_HIDE); + } else if ((nID & 0xFFF0) == SC_CLOSE) { + SendMessage(WM_COMMAND, ID_EXIT, 0); + } else if ((nID & 0xFFF0) == IDM_CLOSE_SPLASH) { + if (m_splash) { + m_splash->CloseSplash(); + delete m_splash; + m_splash = NULL; + } + } else { + CDialog::OnSysCommand(nID, lParam); + } +} + +BOOL CExt2MgrDlg::OnDeviceChange(UINT nEventType, DWORD_PTR dwData) +{ + PDEV_BROADCAST_HDR lpdb = (PDEV_BROADCAST_HDR)dwData; + PDEV_BROADCAST_DEVICEINTERFACE pdbch = (PDEV_BROADCAST_DEVICEINTERFACE)dwData; + if (pdbch && pdbch->dbcc_devicetype == DBT_DEVTYP_DEVICEINTERFACE) { + + if (nEventType == DBT_DEVICEARRIVAL || DBT_DEVICEREMOVECOMPLETE) { + KillTimer('REFR'); + SetTimer('REFR', 1000, NULL); + } + + return TRUE; + } + + switch (nEventType) { + + case DBT_DEVICEARRIVAL: + + if (lpdb->dbch_devicetype == DBT_DEVTYP_VOLUME) { + PDEV_BROADCAST_VOLUME lpdbv = (PDEV_BROADCAST_VOLUME)lpdb; + DriversChangeNotify(lpdbv->dbcv_unitmask, TRUE); + Ext2AddLetterMask((ULONGLONG)(lpdbv->dbcv_unitmask)); + } + + break; + case DBT_DEVICEQUERYREMOVE: + break; + case DBT_DEVICEQUERYREMOVEFAILED: + break; + case DBT_DEVICEREMOVEPENDING: + break; + case DBT_DEVICEREMOVECOMPLETE: + if (lpdb->dbch_devicetype == DBT_DEVTYP_VOLUME) { + PDEV_BROADCAST_VOLUME lpdbv = (PDEV_BROADCAST_VOLUME)lpdb; + DriversChangeNotify(lpdbv->dbcv_unitmask, FALSE); + } + break; + case DBT_DEVICETYPESPECIFIC: + break; + case DBT_CONFIGCHANGED: + break; + default: + break; + } + + return TRUE; +} + +void CExt2MgrDlg::OnDestroy() +{ + KillTimer(ID_INDICATOR_TIME); + + Ext2CleanupDisks(); + Ext2CleanupCdroms(); + Ext2CleanupVolumes(); + Ext2CleanupDrvLetters(); + + OnPerfStop(); + + if (m_hUsbNotify) { + UnregisterDeviceNotification(m_hUsbNotify); + m_hUsbNotify = NULL; + } + + if (m_hAccel) { + DestroyAcceleratorTable(m_hAccel); + m_hAccel = NULL; + } + + CDialog::OnDestroy(); +} + +// 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 CExt2MgrDlg::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 CExt2MgrDlg::OnQueryDragIcon() +{ + return (HCURSOR) m_hIcon; +} + +void CExt2MgrDlg::OnSize(UINT nType, int cx, int cy) +{ + int i = 0; + int ctlId[] = {IDC_VOLUME_LIST, IDC_DISK_LIST, 0}; + + return; + + // create an instance of the CRect object + CRect crw, cri; + + do { + + CWnd *pWnd = GetDlgItem(ctlId[i]); + if (pWnd) { + pWnd->GetWindowRect(&cri); + ScreenToClient(&cri); + pWnd->SetWindowPos(pWnd, + cri.left * cx / crw.Width(), + cri.top * cy / crw.Height(), + cri.Width() * cx / crw.Width(), + cri.Height() * cy / crw.Height(), + SWP_NOZORDER | SWP_SHOWWINDOW); + } + + } while (ctlId[++i]); +} + +LRESULT CExt2MgrDlg::OnTrayNotification(WPARAM wParam,LPARAM lParam) +{ + switch(LOWORD(lParam)) + { + case WM_LBUTTONUP: + m_bHide = FALSE; + ShowWindow(SW_SHOW); + SendMessage(WM_SYSCOMMAND, SC_RESTORE); + break; + } + + return m_Tray.OnTrayNotification(wParam,lParam); +} + +void CExt2MgrDlg::OnAbout() +{ + // TODO: Add your command handler code here + SendMessage(WM_SYSCOMMAND, IDM_ABOUTBOX); +} + +void CExt2MgrDlg::OnExit() +{ + if (TRUE) { + /* AfxMessageBox("Are you sure to exit ? ",MB_YESNO,0) == IDYES */ + EndDialog(0); + } +} + +void CExt2MgrDlg::OnOK() +{ +} + +void CExt2MgrDlg::OnCancel() +{ +} + +void CExt2MgrDlg::OnRefresh() +{ + m_bHandleChange = FALSE; + m_bFocusVolume = FALSE; + m_bFocusDisk = FALSE; + + Ext2AutoRemoveDeadLetters(); + + /* cleanup all the disk/volume structures */ + Ext2CleanupDisks(); + Ext2CleanupCdroms(); + Ext2CleanupVolumes(); + Ext2CleanupDrvLetters(); + + /* loading system configurations */ + if (Ext2QuerySysConfig()) { + Ext2LoadDisks(); + Ext2LoadCdroms(); + if (Ext2LoadVolumes()) { + Ext2LoadRemovableVolumes(); + Ext2LoadDrvLetters(); + Ext2LoadCdromDrvLetters(); + Ext2LoadAllVolumeDrvLetters(); + Ext2LoadAllDiskPartitions(); + if (g_bAutoRemoveDeadLetters) { + Ext2AutoRemoveDeadLetters(); + } + if (Ext2ProcessExt2Volumes()) { + } + } + } else { + return; + } + + /* updating the volume list */ + Ext2RefreshVolumeList(&m_VolumeList); + + /* updating the disk list */ + Ext2RefreshDiskList(&m_DiskView); + + m_bHandleChange = TRUE; +} + +void CExt2MgrDlg::OnService() +{ + // TODO: Add your command handler code here + CServiceManage SrvDlg; + if (!SrvDlg.m_bInited) { + AfxMessageBox("Cannot query Ext2Fsd service !", MB_OK|MB_ICONSTOP); + return; + } + + /* query global parameters */ + Ext2QueryGlobalProperty( + &m_nStartmode, + (BOOL *)&m_bReadonly, + (BOOL *)&m_bExt3Writable, + (CHAR *)m_Codepage.GetBuffer(CODEPAGE_MAXLEN), + (CHAR *)m_sPrefix.GetBuffer(HIDINGPAT_LEN), + (CHAR *)m_sSuffix.GetBuffer(HIDINGPAT_LEN), + (BOOL *)&m_bAutoMount + ); + g_bAutoMount = m_bAutoMount; + m_Codepage.ReleaseBuffer(-1); + m_sPrefix.ReleaseBuffer(-1); + m_sSuffix.ReleaseBuffer(-1); + + SrvDlg.m_nStartmode = m_nStartmode; + SrvDlg.m_bReadonly = m_bReadonly; + SrvDlg.m_bExt3Writable = m_bExt3Writable; + SrvDlg.m_bAutoMount = m_bAutoMount; + SrvDlg.m_Codepage = m_Codepage; + SrvDlg.m_sPrefix = m_sPrefix; + SrvDlg.m_sSuffix = m_sSuffix; + if (IDOK == SrvDlg.DoModal()) { + /* query global parameters */ + Ext2QueryGlobalProperty( + &m_nStartmode, + (BOOL *)&m_bReadonly, + (BOOL *)&m_bExt3Writable, + (CHAR *)m_Codepage.GetBuffer(CODEPAGE_MAXLEN), + (CHAR *)m_sPrefix.GetBuffer(HIDINGPAT_LEN), + (CHAR *)m_sSuffix.GetBuffer(HIDINGPAT_LEN), + (BOOL *)&m_bAutoMount + ); + g_bAutoMount = m_bAutoMount; + } +} + + +void CExt2MgrDlg::OnChangeProperty() +{ + CExt2Attribute EA; + + PEXT2_VOLUME_PROPERTY3 EVP = NULL; + + PEXT2_VOLUME volume = NULL; + PEXT2_CDROM cdrom = NULL; + + if (m_bFocusVolume) { + if (m_type == EXT2_VOLUME_MAGIC) { + volume = (PEXT2_VOLUME) m_sdev; + EVP = &volume->EVP; + } else if (m_type == EXT2_CDROM_DEVICE_MAGIC) { + cdrom = (PEXT2_CDROM) m_sdev; + EVP = &cdrom->EVP; + } + } else { + if (m_type == EXT2_PART_MAGIC) { + PEXT2_PARTITION part = (PEXT2_PARTITION) m_sdev; + volume = part->Volume; + EVP = &volume->EVP; + } else if (m_type == EXT2_CDROM_VOLUME_MAGIC || + m_type == EXT2_CDROM_DEVICE_MAGIC ) { + cdrom = (PEXT2_CDROM) m_sdev; + EVP = &cdrom->EVP; + } + } + + if (EVP) { + + NT::NTSTATUS status; + HANDLE Handle = NULL; + CString s; + + EA.m_EVP = EVP; + if (volume) { + if (volume->Part) + EA.m_DevName = volume->Part->Name; + else + EA.m_DevName = volume->Name; + } else { + EA.m_bCdrom = TRUE; + EA.m_DevName = cdrom->Name; + } + + status = Ext2Open(EA.m_DevName.GetBuffer(EA.m_DevName.GetLength()), + &Handle, EXT2_DESIRED_ACCESS); + + if (!NT_SUCCESS(status)) { + + s.Format("Ext2Fsd service isn't started.\n"); + AfxMessageBox(s, MB_OK | MB_ICONSTOP); + + } else { + + if (!Ext2QueryExt2Property(Handle, EVP)) { + Ext2Close(&Handle); + return; + } + + Ext2Close(&Handle); + } + + EA.m_MainDlg = (CWnd *)this; + if (EA.DoModal() == IDOK) { + } + if (volume) { + UpdateVolume(volume); + } else if (cdrom) { + UpdateCdrom(cdrom); + } + } +} + +void CExt2MgrDlg::OnFormat() +{ + CString str; + // TODO: Add your command handler code here + if (m_bFocusVolume) { + str.Format("Formating volume item: %d", m_IndexVolume); + } + if (m_bFocusDisk) { + str.Format("Formating disk item: %d", m_IndexDisk); + } + + if (!str.IsEmpty()) + AfxMessageBox(str); +} + +void CExt2MgrDlg::OnWindowPosChanging(WINDOWPOS* lpwndpos) +{ + if(m_bHide) + lpwndpos->flags &= ~SWP_SHOWWINDOW; + + CDialog::OnWindowPosChanging(lpwndpos); +} + +BOOL CExt2MgrDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) +{ + // TODO: Add your specialized code here and/or call the base class + + LPNMHDR pNmhdr = (LPNMHDR)lParam; + + return CDialog::OnNotify(wParam, lParam, pResult); +} + +void CExt2MgrDlg::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct) +{ + if (nIDCtl == IDC_DISK_LIST) { + m_DiskView.MeasureItem(lpMeasureItemStruct); + } else { + CDialog::OnMeasureItem(nIDCtl, lpMeasureItemStruct); + } +} + +void CExt2MgrDlg::OnDblclkDiskList(NMHDR* pNMHDR, LRESULT* pResult) +{ + // TODO: Add your control notification handler code here + BOOL IsExt2 = FALSE; + m_bFocusVolume = FALSE; + m_bFocusDisk = TRUE; + m_IndexDisk = m_DiskView.GetSelectionMark(); + + if (!m_bFsStarted) { + m_bFsStarted = Ext2IsServiceStarted(); + } + + if (QuerySelectedItem(&IsExt2)) { + if (IsExt2 && m_bFsStarted) { + SendMessage(WM_COMMAND, ID_CHANGE, 0); + } else { + SendMessage(WM_COMMAND, ID_PROPERTY, 0); + } + } + + *pResult = 0; +} + +void CExt2MgrDlg::OnSetfocusDiskList(NMHDR* pNMHDR, LRESULT* pResult) +{ + // TODO: Add your control notification handler code here + m_bFocusDisk = TRUE; + m_bFocusVolume = FALSE; + // m_bar.SetPaneText(0, CString("Disk: Set Focus")); + + QuerySelectedItem(NULL); + *pResult = 0; +} + +void CExt2MgrDlg::OnKillfocusDiskList(NMHDR* pNMHDR, LRESULT* pResult) +{ + // TODO: Add your control notification handler code here + m_bFocusDisk = FALSE; + // m_bar.SetPaneText(0, CString("Disk: Focus Lost")); + + QuerySelectedItem(NULL); + *pResult = 0; +} + +void CExt2MgrDlg::OnRclickDiskList(NMHDR* pNMHDR, LRESULT* pResult) +{ + // TODO: Add your control notification handler code here + RECT rect; + CString s; + + m_bFocusVolume = FALSE; + m_bFocusDisk = TRUE; + m_IndexDisk = m_DiskView.GetSelectionMark(); + + if (!QuerySelectedItem(NULL)) { + return; + } + + while (m_Menu.DeleteMenu(0, MF_BYPOSITION)); + + if (m_bFocusDisk) { + + if (m_type == EXT2_CDROM_DEVICE_MAGIC || + m_type == EXT2_CDROM_VOLUME_MAGIC ) { + + PEXT2_CDROM cdrom = (PEXT2_CDROM) m_sdev; + + s.LoadString(IDS_DRV_QUICK_MOUNT); + if (0 == cdrom->DrvLetters) + m_Menu.AppendMenu(MF_STRING, ID_DRV_QUICK_MOUNT, (LPCTSTR)s); + + s.LoadString(IDS_CHANGE_DRVLETTER); + m_Menu.AppendMenu(MF_STRING, ID_DRV_LETTER, (LPCTSTR)s); + + m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); + if (cdrom->bLoaded && !cdrom->bEjected && + (cdrom->EVP.bExt2 || cdrom->EVP.bExt3)) { + + s.LoadString(IDS_EXT2_MANAGEMENT); + m_Menu.AppendMenu(MF_STRING, ID_CHANGE, (LPCTSTR)s); + } + + m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); + + s.LoadString(IDS_COPY_ITEM_TO_CLIP); + m_Menu.AppendMenu(MF_STRING, ID_COPY, (LPCTSTR)s); + m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); + + } else if (m_type == EXT2_PART_MAGIC) { + + PEXT2_PARTITION part = (PEXT2_PARTITION) m_sdev; + PEXT2_VOLUME volume = part->Volume; + + if (volume && !volume->bDynamic) { + s.LoadString(IDS_DRV_QUICK_MOUNT); + if (0 == volume->DrvLetters) + m_Menu.AppendMenu(MF_STRING, ID_DRV_QUICK_MOUNT, (LPCTSTR)s); + + s.LoadString(IDS_CHANGE_DRVLETTER); + m_Menu.AppendMenu(MF_STRING, ID_DRV_LETTER, (LPCTSTR)s); + m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); + } + + if (volume && volume->bRecognized && (volume->EVP.bExt2 || volume->EVP.bExt3)) { + s.LoadString(IDS_EXT2_MANAGEMENT); + m_Menu.AppendMenu(MF_STRING, ID_CHANGE, (LPCTSTR)s); + m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); + } + + if (part->Entry) { + s.LoadString(IDS_FLUSH_BUFFER); + m_Menu.AppendMenu(MF_STRING, ID_FLUSH_BUFFER, (LPCTSTR)s); + + if (part->PartType == PARTITION_STYLE_MBR) { + s.LoadString(IDS_CHANGE_PARTID); + m_Menu.AppendMenu(MF_STRING, ID_CHANGE_PARTTYPE, (LPCTSTR)s); + } + m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); + } + + s.LoadString(IDS_COPY_ITEM_TO_CLIP); + m_Menu.AppendMenu(MF_STRING, ID_COPY, (LPCTSTR)s); + + m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); + + } else { + ASSERT(m_type == EXT2_DISK_MAGIC); + } + } + + s.LoadString(IDS_RELOAD_REFRESH); + m_Menu.AppendMenu(MF_STRING, ID_REFRESH, (LPCTSTR)s); + m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); + + s.LoadString(IDS_SHOW_PROPERTY); + m_Menu.AppendMenu(MF_STRING, ID_PROPERTY, (LPCTSTR)s); + m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); + + s.LoadString(IDS_SERVICE_MANAGE); + m_Menu.AppendMenu(MF_STRING, ID_SERVICE, (LPCTSTR)s); + + s.LoadString(IDS_PERFMEM_STAT); + m_Menu.AppendMenu(MF_STRING, ID_PERFSTAT, (LPCTSTR)s); + + s.LoadString(IDS_REMOVE_DEAD_LETTER); + m_Menu.AppendMenu(MF_STRING, ID_REMOVE_DEAD_LETTER, (LPCTSTR)s); + + m_DiskView.GetWindowRect(&rect); + m_Menu.TrackPopupMenu( TPM_LEFTALIGN, + rect.left + m_DiskView.m_Point.x, + rect.top + m_DiskView.m_Point.y, + m_DiskView.GetSafeOwner(), + NULL); + + *pResult = 0; +} + + +void CExt2MgrDlg::OnClickDiskList(NMHDR* pNMHDR, LRESULT* pResult) +{ + // TODO: Add your control notification handler code here + m_bFocusVolume = FALSE; + m_bFocusDisk = TRUE; + m_IndexDisk = m_DiskView.GetSelectionMark(); + + QuerySelectedItem(NULL); + *pResult = 0; +} + +void CExt2MgrDlg::OnDblclkVolumeList(NMHDR* pNMHDR, LRESULT* pResult) +{ + // TODO: Add your control notification handler code here + BOOL bIsExt2 = FALSE; + + if (!m_bFsStarted) { + m_bFsStarted = Ext2IsServiceStarted(); + } + + m_bFocusVolume = TRUE; + m_IndexVolume = m_VolumeList.GetSelectionMark();; + m_bFocusDisk = FALSE; + if (QuerySelectedItem(&bIsExt2)) { + if (bIsExt2 && m_bFsStarted) { + SendMessage(WM_COMMAND, ID_CHANGE, 0); + } else { + SendMessage(WM_COMMAND, ID_PROPERTY, 0); + } + } + *pResult = 0; +} + +void CExt2MgrDlg::OnSetfocusVolumeList(NMHDR* pNMHDR, LRESULT* pResult) +{ + // TODO: Add your control notification handler code here + //m_bar.SetPaneText(0, CString("Volume: Set Focus")); + m_bFocusVolume = TRUE; + *pResult = 0; + QuerySelectedItem(NULL); +} + +void CExt2MgrDlg::OnKillfocusVolumeList(NMHDR* pNMHDR, LRESULT* pResult) +{ + m_bFocusVolume = FALSE; + //m_bar.SetPaneText(0, CString("Volume: Focus Lost")); + + // TODO: Add your control notification handler code here + *pResult = 0; + QuerySelectedItem(NULL); +} + +void CExt2MgrDlg::OnRclickVolumeList(NMHDR* pNMHDR, LRESULT* pResult) +{ + RECT rect; + CString s; + + m_bFocusVolume = TRUE; + m_IndexVolume = m_VolumeList.GetSelectionMark();; + m_bFocusDisk = FALSE; + + if (!QuerySelectedItem(NULL)) { + return; + } + + while (m_Menu.DeleteMenu(0, MF_BYPOSITION)); + + if (m_bFocusVolume) { + + if (m_type == EXT2_VOLUME_MAGIC) { + + PEXT2_VOLUME volume = (PEXT2_VOLUME) m_sdev; + PEXT2_PARTITION part; + + s.LoadString(IDS_DRV_QUICK_MOUNT); + if (0 == volume->DrvLetters) + m_Menu.AppendMenu(MF_STRING, ID_DRV_QUICK_MOUNT, (LPCTSTR)s); + + s.LoadString(IDS_CHANGE_DRVLETTER); + m_Menu.AppendMenu(MF_STRING, ID_DRV_LETTER, (LPCTSTR)s); + m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); + + if (volume->bRecognized && (volume->EVP.bExt2 || volume->EVP.bExt3)) { + s.LoadString(IDS_EXT2_MANAGEMENT); + m_Menu.AppendMenu(MF_STRING, ID_CHANGE, (LPCTSTR)s); + m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); + } + + s.LoadString(IDS_FLUSH_BUFFER); + m_Menu.AppendMenu(MF_STRING, ID_FLUSH_BUFFER, (LPCTSTR)s); + + part = Ext2QueryVolumePartition(volume); + if (part && part->PartType == PARTITION_STYLE_MBR) { + s.LoadString(IDS_CHANGE_PARTID); + m_Menu.AppendMenu(MF_STRING, ID_CHANGE_PARTTYPE, (LPCTSTR)s); + } + + } else if (m_type == EXT2_CDROM_DEVICE_MAGIC || + m_type == EXT2_CDROM_VOLUME_MAGIC ) { + + PEXT2_CDROM cdrom = (PEXT2_CDROM)m_sdev; + + s.LoadString(IDS_DRV_QUICK_MOUNT); + if (0 == cdrom->DrvLetters) + m_Menu.AppendMenu(MF_STRING, ID_DRV_QUICK_MOUNT, (LPCTSTR)s); + + s.LoadString(IDS_CHANGE_DRVLETTER); + m_Menu.AppendMenu(MF_STRING, ID_DRV_LETTER, (LPCTSTR)s); + + if (cdrom->bLoaded && !cdrom->bEjected && + (cdrom->EVP.bExt2 || cdrom->EVP.bExt3)) { + m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); + s.LoadString(IDS_EXT2_MANAGEMENT); + m_Menu.AppendMenu(MF_STRING, ID_CHANGE, (LPCTSTR)s); + } + } + + m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); + s.LoadString(IDS_COPY_ITEM_TO_CLIP); + m_Menu.AppendMenu(MF_STRING, ID_COPY, (LPCTSTR)s); + m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); + } + + s.LoadString(IDS_RELOAD_REFRESH); + m_Menu.AppendMenu(MF_STRING, ID_REFRESH, (LPCTSTR)s); + m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); + + s.LoadString(IDS_SHOW_PROPERTY); + m_Menu.AppendMenu(MF_STRING, ID_PROPERTY, (LPCTSTR)s); + m_Menu.AppendMenu(MF_SEPARATOR, 0, ""); + + s.LoadString(IDS_SERVICE_MANAGE); + m_Menu.AppendMenu(MF_STRING, ID_SERVICE, (LPCTSTR)s); + + s.LoadString(IDS_PERFMEM_STAT); + m_Menu.AppendMenu(MF_STRING, ID_PERFSTAT, (LPCTSTR)s); + + s.LoadString(IDS_REMOVE_DEAD_LETTER); + m_Menu.AppendMenu(MF_STRING, ID_REMOVE_DEAD_LETTER, (LPCTSTR)s); + + m_VolumeList.GetWindowRect(&rect); + m_Menu.TrackPopupMenu(TPM_LEFTALIGN, + rect.left + m_VolumeList.m_Point.x , + rect.top + m_VolumeList.m_Point.y, + m_VolumeList.GetSafeOwner(), NULL); + + *pResult = 0; +} + + +void CExt2MgrDlg::OnClickVolumeList(NMHDR* pNMHDR, LRESULT* pResult) +{ + m_bFocusVolume = TRUE; + m_IndexVolume = m_VolumeList.GetSelectionMark();; + m_bFocusDisk = FALSE; + + QuerySelectedItem(NULL); + + *pResult = 0; +} + + +void CExt2MgrDlg::OnProperty() +{ + PVOID sdev = QuerySelectedItem(NULL); + if (sdev) { + CProperties PPD; + PPD.m_bdisk = m_bFocusDisk; + PPD.m_type = m_type; + PPD.m_sdev = sdev; + PPD.DoModal(); + } +} + +VOID +CExt2MgrDlg::DriversChangeNotify( + ULONG drvsMask, + BOOL bArrival + ) +{ + for (ULONG i=0; i < 26; i++) { + + PEXT2_LETTER drvLetter = &drvLetters[i]; + + if (drvsMask & (1 << i)) { + DriverChangeNotify(drvLetter, bArrival); + } + } +} + +VOID +CExt2MgrDlg::DriverLetterChangeNotify( + CHAR cLetter, + BOOL bArrival + ) +{ + PEXT2_LETTER drvLetter = NULL; + + if (cLetter >= '0' && cLetter <= '9') { + drvLetter = &drvDigits[cLetter - '0']; + } else if (cLetter >= 'A' && cLetter <= 'Z') { + drvLetter = &drvLetters[cLetter - 'A']; + } + + if (drvLetter) { + DriverChangeNotify(drvLetter, bArrival); + } +} + +VOID +CExt2MgrDlg::DriverChangeNotify( + PEXT2_LETTER drvLetter, + BOOL bArrival + ) +{ + ULONGLONG LetterMask = 0; + ULONG i; + + if (!m_bHandleChange) { + return; + } + + if (bArrival) { + if (!drvLetter->bUsed) { + Ext2CleanDrvLetter(drvLetter); + Ext2QueryDrvLetter(drvLetter); + } + } + + if (drvLetter->Letter >= '0' && drvLetter->Letter <= '9') { + LetterMask = ((ULONGLONG) 1) << (drvLetter->Letter - '0' + 32); + } else if (drvLetter->Letter >= 'A' && drvLetter->Letter <= 'Z') { + LetterMask = ((ULONGLONG) 1) << (drvLetter->Letter - 'A'); + } + + if (drvLetter->bUsed) { + + if (NULL != drvLetter->Extent) { + + PEXT2_VOLUME Volume = &gVols[0]; + for (i=0; i < g_nVols && Volume != NULL; i++) { + if (Ext2CompareExtents(drvLetter->Extent, Volume->Extent)) { + if (bArrival) { + Volume->DrvLetters |= LetterMask; + } else { + Volume->DrvLetters &= ~LetterMask; + } + UpdateVolume(Volume); + break; + } + Volume = Volume->Next; + } + } + + for (i=0; i < g_nCdroms; i++) { + PEXT2_CDROM Cdrom = &gCdroms[i]; + if (!_stricmp(drvLetters->SymLink, Cdrom->Name)) { + if (bArrival) { + Cdrom->DrvLetters |= LetterMask; + } else { + Cdrom->DrvLetters &= ~LetterMask; + } + UpdateCdrom(Cdrom); + break; + } + } + } + + if (!bArrival) { + + //Ext2SymLinkRemoval(drvLetter->Letter); + //Ext2RemoveDosSymLink(drvLetter->Letter); + + if (drvLetter->bUsed) { + //Ext2DismountVolume(drvLetter->SymLink); + Ext2RemoveMountPoint(drvLetter, FALSE); + } + } +} + +void CExt2MgrDlg::UpdateVolume(PEXT2_VOLUME volume) +{ + for (int i = 0; i < m_VolumeList.GetItemCount(); i++) { + PULONG data = (PULONG)m_VolumeList.GetItemData(i); + if (!data) { + continue; + } + if (*data == EXT2_VOLUME_MAGIC && + data == (PULONG)volume) { + Ext2RefreshVLVI(&m_VolumeList, volume, i); + } + } + + for (int i = 0; i < m_DiskView.GetItemCount(); i++) { + PEXT2_PARTITION part; + part = (PEXT2_PARTITION)m_DiskView.GetItemData(i); + if (!part) { + continue; + } + if (part->Magic == EXT2_PART_MAGIC && + part->Volume == volume) { + part->DrvLetters = volume->DrvLetters; + Ext2RefreshDVPT(&m_DiskView, part, i); + } + } +} + +void CExt2MgrDlg::UpdateCdrom(PEXT2_CDROM cdrom) +{ + for (int i = 0; i < m_VolumeList.GetItemCount(); i++) { + PULONG data = (PULONG)m_VolumeList.GetItemData(i); + if (!data) { + continue; + } + if (*data == EXT2_CDROM_DEVICE_MAGIC && + data == (PULONG)cdrom) { + Ext2RefreshVLCD(&m_VolumeList, cdrom, i); + } + } + + for (int i = 0; i < m_DiskView.GetItemCount(); i++) { + PULONG data = (PULONG)m_DiskView.GetItemData(i); + if (!data) { + continue; + } + if (*data == EXT2_CDROM_VOLUME_MAGIC && + (PUCHAR)data == ((PUCHAR)cdrom + 4)) { + Ext2RefreshDVCM(&m_DiskView, cdrom, i); + } + } +} + +void CExt2MgrDlg::UpdatePartition(PEXT2_PARTITION part) +{ + int i; + + if (part->Volume) { + part->Volume->DrvLetters = part->DrvLetters; + UpdateVolume(part->Volume); + return; + } + + for (i = 0; i < m_DiskView.GetItemCount(); i++) { + + PULONG data = (PULONG)m_DiskView.GetItemData(i); + if (!data) { + continue; + } + if (*data == EXT2_PART_MAGIC && + data == (PULONG)part) { + Ext2RefreshDVPT(&m_DiskView, part, i); + } + } +} + +void CExt2MgrDlg::OnDrvLetter() +{ + // TODO: Add your command handler code here + CMountPoints mntPoint; + if (m_bFocusVolume) { + if (m_type == EXT2_VOLUME_MAGIC) { + mntPoint.m_Volume = (PEXT2_VOLUME) m_sdev; + } else { + mntPoint.m_Cdrom = (PEXT2_CDROM) m_sdev; + } + } else { + if (m_type == EXT2_CDROM_DEVICE_MAGIC || + m_type == EXT2_CDROM_VOLUME_MAGIC ) { + mntPoint.m_Cdrom = (PEXT2_CDROM) m_sdev; + } else { + mntPoint.m_Part = (PEXT2_PARTITION) m_sdev; + } + } + + mntPoint.m_MainDlg = this; + mntPoint.DoModal(); + + /* to be done in OnDeviceChange */ + + /* + if (mntPoint.m_bUpdated) { + + if (mntPoint.m_Volume) { + UpdateVolume(mntPoint.m_Volume); + } + if (mntPoint.m_Cdrom) { + UpdateCdrom(mntPoint.m_Cdrom); + } + if (mntPoint.m_Part) { + UpdatePartition(mntPoint.m_Part); + } + } + */ +} + +void CExt2MgrDlg::OnDrvQuickMount() +{ + CHAR drv = 0; + + if (m_bFocusVolume) { + if (m_type == EXT2_VOLUME_MAGIC) { + PEXT2_VOLUME v = (PEXT2_VOLUME)m_sdev; + if (0 == v->DrvLetters) { + drv = Ext2MountVolume(v->Name); + if (drv) { + v->DrvLetters |= ((ULONGLONG) 1) << (drv - 'A'); + UpdateVolume(v); + } + } + } else { + PEXT2_CDROM c = (PEXT2_CDROM) m_sdev; + if (0 == c->DrvLetters) { + drv = Ext2MountVolume(c->Name); + if (drv) { + c->DrvLetters |= ((ULONGLONG) 1) << (drv - 'A'); + UpdateCdrom(c); + } + } + } + } else { + if (m_type == EXT2_CDROM_DEVICE_MAGIC || + m_type == EXT2_CDROM_VOLUME_MAGIC ) { + PEXT2_CDROM c = (PEXT2_CDROM) m_sdev; + if (0 == c->DrvLetters) { + drv = Ext2MountVolume(c->Name); + if (drv) { + c->DrvLetters |= ((ULONGLONG) 1) << (drv - 'A'); + UpdateCdrom(c); + } + } + } else { + PEXT2_PARTITION p = (PEXT2_PARTITION) m_sdev; + if (0 == p->DrvLetters) { + drv = Ext2MountVolume(p->Name); + if (drv) { + p->DrvLetters |= ((ULONGLONG) 1) << (drv - 'A'); + UpdatePartition(p); + } + } + } + } +} + + +void CExt2MgrDlg::OnDonate() +{ + // TODO: Add your command handler code here + CDonate Donate; + Donate.DoModal(); +} + +void CExt2MgrDlg::OnCopy() +{ + CHAR Data[256]; + BOOL rc = FALSE; + + // TODO: Add your command handler code here + if (m_bFocusVolume) { + rc = m_VolumeList.QuerySubItemText(m_IndexVolume, Data, 256); + } else if (m_bFocusDisk) { + rc = m_DiskView.QuerySubItemText(m_IndexDisk, Data, 256); + } + + if (rc && OpenClipboard()) { + + HGLOBAL clipbuffer; + char * buffer; + clipbuffer = GlobalAlloc(GMEM_DDESHARE, strlen(Data) + 1); + if (clipbuffer) { + buffer = (char*)GlobalLock(clipbuffer); + if (buffer) { + EmptyClipboard(); + memset(buffer, 0, strlen(Data) + 1); + memcpy(buffer, Data, strlen(Data) + 1); + GlobalUnlock(clipbuffer); + SetClipboardData(CF_TEXT,clipbuffer); + } else { + GlobalFree(clipbuffer); + } + } + CloseClipboard(); + } +} + +void CExt2MgrDlg::OnCopyAll() +{ + BOOL rc = FALSE; + CString s; + + s = Ext2SysInformation(); + + if (!s.IsEmpty() && OpenClipboard()) { + + HGLOBAL clipbuffer; + char * buffer; + clipbuffer = GlobalAlloc(GMEM_DDESHARE, s.GetLength() + 1); + if (clipbuffer) { + buffer = (char*)GlobalLock(clipbuffer); + if (buffer) { + EmptyClipboard(); + memcpy(buffer, (LPCSTR)s, s.GetLength() + 1); + GlobalUnlock(clipbuffer); + SetClipboardData(CF_TEXT,clipbuffer); + } else { + GlobalFree(clipbuffer); + } + } + CloseClipboard(); + } +} + +void CExt2MgrDlg::OnTimer(UINT_PTR nIDEvent) +{ + // TODO: Add your message handler code here and/or call default + + if (nIDEvent == ID_INDICATOR_TIME) { + CString s; + CTime t1; + t1 = CTime::GetCurrentTime(); + s.Format(" %3.3s", t1.Format("%B")); + s += t1.Format(" %d,%Y %H:%M:%S"); + m_bar.SetPaneText(1, s); + } else if (nIDEvent == 'REFR') { + if (m_bHandleChange) + PostMessage(WM_COMMAND, ID_REFRESH, 0); + KillTimer('REFR'); + } else if (nIDEvent == 'REFF') { + PostMessage(WM_COMMAND, ID_REFRESH, 0); + KillTimer('REFF'); + } + + CDialog::OnTimer(nIDEvent); +} + +PVOID CExt2MgrDlg::QuerySelectedItem(PBOOL bIsExt2) +{ + CString str = "Ready"; + PVOID List = NULL; + + PEXT2_CDROM Cdrom = NULL; + PEXT2_DISK Disk = NULL; + PEXT2_VOLUME Volume = NULL; + PEXT2_PARTITION Part = NULL; + + LVITEM lvItem; + memset(&lvItem, 0, sizeof(LVITEM)); + lvItem.mask = LVIF_PARAM | LVIF_IMAGE; + + m_sdev = NULL; + m_type = 0; + + CMenu* pMenu = AfxGetMainWnd()->GetMenu(); + CMenu* pTools = NULL; + pTools = pMenu->GetSubMenu(1); + + if (bIsExt2) { + *bIsExt2 = FALSE; + } + + pTools->EnableMenuItem(ID_DRV_LETTER, MF_BYCOMMAND|MF_GRAYED|MF_DISABLED); + pTools->EnableMenuItem(ID_CHANGE, MF_BYCOMMAND|MF_GRAYED|MF_DISABLED); + pTools->EnableMenuItem(ID_FORMAT, MF_BYCOMMAND|MF_GRAYED|MF_DISABLED); + pTools->EnableMenuItem(ID_PROPERTY, MF_BYCOMMAND|MF_GRAYED|MF_DISABLED); + + if (m_bFocusVolume) { + + if (m_IndexVolume == -1 || + m_IndexVolume >= m_VolumeList.GetItemCount()) { + goto errorout; + } + + lvItem.iItem = m_IndexVolume; + m_VolumeList.GetItem(&lvItem); + + PEXT2_VOLUME Volume = (PEXT2_VOLUME) lvItem.lParam; + if (!Volume) { + goto errorout; + } + Cdrom = (PEXT2_CDROM) Volume; + m_type = Volume->Magic; + + if (Volume->Magic == EXT2_VOLUME_MAGIC) { + str.Format("VOLUME: %s %s %s", + Ext2QueryVolumeLetterStrings( + Volume->DrvLetters, NULL), + Volume->FileSystem, Volume->Name); + m_sdev = (PVOID) Volume; + + if (Volume->bRecognized && (Volume->EVP.bExt2 || Volume->EVP.bExt3)) { + pTools->EnableMenuItem(ID_CHANGE, MF_BYCOMMAND|MF_ENABLED); + } + pTools->EnableMenuItem(ID_FORMAT, MF_BYCOMMAND|MF_ENABLED); + pTools->EnableMenuItem(ID_DRV_LETTER, MF_BYCOMMAND|MF_ENABLED); + pTools->EnableMenuItem(ID_PROPERTY, MF_BYCOMMAND|MF_ENABLED); + + if (bIsExt2 && Volume->bRecognized) { + *bIsExt2 = Volume->EVP.bExt2 || Volume->EVP.bExt3; + } + + } else if (Cdrom->Magic[0] == EXT2_CDROM_DEVICE_MAGIC) { + str.Format("CDROM %d: %s", Cdrom->OrderNo, + Ext2QueryVolumeLetterStrings( + Cdrom->DrvLetters, NULL)); + if (Cdrom->bIsDVD) { + str += " DVD"; + } + m_sdev = (PVOID) Cdrom; + + pTools->EnableMenuItem(ID_DRV_LETTER, MF_BYCOMMAND|MF_ENABLED); + pTools->EnableMenuItem(ID_PROPERTY, MF_BYCOMMAND|MF_ENABLED); + + if (bIsExt2) { + *bIsExt2 = Cdrom->EVP.bExt2 || Cdrom->EVP.bExt3; + } + + } else { + m_IndexVolume = -1; + } + } + + if (m_bFocusDisk) { + + if (m_IndexDisk == -1 || + m_IndexDisk >= m_DiskView.GetItemCount()) { + goto errorout; + } + + lvItem.iItem = m_IndexDisk; + m_DiskView.GetItem(&lvItem); + + PEXT2_DISK Disk = (PEXT2_DISK) lvItem.lParam; + if (!Disk) { + goto errorout; + } + + m_type = Disk->Magic; + + if (Disk->Magic == EXT2_DISK_MAGIC) { + str.Format("DISK %d: %s", Disk->OrderNo, Disk->Name); + m_sdev = (PVOID) Disk; + pTools->EnableMenuItem(ID_PROPERTY, MF_BYCOMMAND|MF_ENABLED); + } else if (Disk->Magic == EXT2_PART_MAGIC) { + BOOL bDynamic = FALSE; + Part = (PEXT2_PARTITION) Disk; + Disk = Part->Disk; + Volume = Part->Volume; + if (!Volume) { + if (Disk->SDD.RemovableMedia) { + if (Disk->bEjected) { + str.Format("DISK %d: No media", Disk->OrderNo); + } else { + str.Format("DISK %d: RAW", Disk->OrderNo); + } + } else { + if (Disk->Layout) { + str.Format("DISK %d: Not recognized", Disk->OrderNo); + } else { + str.Format("DISK %d: RAW", Disk->OrderNo); + } + } + } else { + str.Format("DISK %d PARTITION %d: %s %s", + Disk->OrderNo, Part->Number, + Ext2QueryVolumeLetterStrings( + Part->DrvLetters, NULL), + Part->Volume->FileSystem + ); + } + m_sdev = (PVOID) Part; + if (Volume) { + pTools->EnableMenuItem(ID_FORMAT, MF_BYCOMMAND|MF_ENABLED); + if (Volume->bRecognized && (Volume->EVP.bExt2 || Volume->EVP.bExt3)) + pTools->EnableMenuItem(ID_CHANGE, MF_BYCOMMAND|MF_ENABLED); + if (!Volume->bDynamic) { + pTools->EnableMenuItem(ID_DRV_LETTER, MF_BYCOMMAND|MF_ENABLED); + } + if (bIsExt2 && Volume->bRecognized) { + *bIsExt2 = Volume->EVP.bExt2 || Volume->EVP.bExt3; + } + } else { + if (Disk->SDD.RemovableMedia) { + pTools->EnableMenuItem(ID_DRV_LETTER, MF_BYCOMMAND|MF_ENABLED); + } + } + pTools->EnableMenuItem(ID_PROPERTY, MF_BYCOMMAND|MF_ENABLED); + } else if (Disk->Magic == EXT2_DISK_NULL_MAGIC) { + Disk = (PEXT2_DISK)((PUCHAR)Disk - sizeof(ULONG)); + str.Format("DISK %d: No media", Disk->OrderNo); + m_sdev = (PVOID) Disk; + pTools->EnableMenuItem(ID_PROPERTY, MF_BYCOMMAND|MF_ENABLED); + } else if (Disk->Magic == EXT2_CDROM_VOLUME_MAGIC) { + Cdrom = (PEXT2_CDROM)((PUCHAR)Disk - sizeof(ULONG)); + str.Format("CDROM %d: %s", Cdrom->OrderNo, + Ext2QueryVolumeLetterStrings( + Cdrom->DrvLetters, NULL)); + if (Cdrom->bIsDVD) { + str += " DVD"; + } + m_sdev = (PVOID) Cdrom; + pTools->EnableMenuItem(ID_DRV_LETTER, MF_BYCOMMAND|MF_ENABLED); + pTools->EnableMenuItem(ID_PROPERTY, MF_BYCOMMAND|MF_ENABLED); + } else if (Disk->Magic == EXT2_CDROM_DEVICE_MAGIC){ + Cdrom = (PEXT2_CDROM)Disk; + str.Format("CDROM %d: %s", Cdrom->OrderNo, Cdrom->Name); + pTools->EnableMenuItem(ID_DRV_LETTER, MF_BYCOMMAND|MF_ENABLED); + pTools->EnableMenuItem(ID_PROPERTY, MF_BYCOMMAND|MF_ENABLED); + m_sdev = (PVOID) Cdrom; + } else { + m_IndexDisk = -1; + } + } + +errorout: + + m_bar.SetPaneText(0, str); + + return m_sdev; +} + +void CExt2MgrDlg::OnKeyupVolumeList() +{ + m_bFocusDisk = FALSE; + m_bFocusVolume = TRUE; + + int item = m_VolumeList.GetSelectionMark(); + if (item != -1 && item != m_IndexVolume) { + m_IndexVolume = item; + QuerySelectedItem(NULL); + } +} + +void CExt2MgrDlg::OnKeyupDiskList() +{ + int item = m_DiskView.GetSelectionMark(); + + if (item != -1 && item != m_IndexDisk) { + m_DiskView.SetSelectionMark(item); + m_IndexDisk = item; + QuerySelectedItem(NULL); + } + + if (!m_bFocusDisk) { + m_DiskView.Redraw(); + } + + m_bFocusDisk = TRUE; + m_bFocusVolume = FALSE; +} + +BOOL CExt2MgrDlg::PreTranslateMessage(MSG* pMsg) +{ + // TODO: Add your specialized code here and/or call the base class + + if (pMsg->message==WM_KEYDOWN) { + if (pMsg->wParam == VK_ESCAPE) { + pMsg->wParam = NULL; + PostMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0); + } else if (pMsg->wParam == VK_RETURN) { + pMsg->wParam = NULL; + PostMessage(WM_COMMAND, ID_PROPERTY, 0); + } + } + + if (pMsg->message==WM_SYSKEYDOWN) { + if (pMsg->wParam == VK_RETURN) { + pMsg->wParam = NULL; + PostMessage(WM_COMMAND, ID_CHANGE, 0); + } + } + + if (m_hAccel != NULL) { + if (TranslateAccelerator(m_hWnd, m_hAccel, pMsg)) { + return TRUE; + } + } + + if (pMsg->message == WM_KEYUP) { + + if (GetFocus() == (CWnd *)&m_DiskView) { + OnKeyupDiskList(); + } + + if (GetFocus() == (CWnd *)&m_VolumeList) { + OnKeyupVolumeList(); + } + } + + return CDialog::PreTranslateMessage(pMsg); +} + +void CExt2MgrDlg::OnShowMain() +{ + // TODO: Add your command handler code here + m_bHide = FALSE; + ShowWindow(SW_SHOW); +} + +LRESULT CExt2MgrDlg::OnTerminate(WPARAM wParam,LPARAM lParam) +{ + if (lParam == 0x1234) { + EndDialog(0); + } + + return TRUE; +} + +LRESULT CExt2MgrDlg::OnMountPointNotify(WPARAM wParam,LPARAM lParam) +{ + if (wParam == 'DA') { + DriverLetterChangeNotify((CHAR)lParam, TRUE); + } else if (wParam == 'DR'){ + DriverLetterChangeNotify((CHAR)lParam, FALSE); + } + + return TRUE; +} + +void CExt2MgrDlg::OnHelp() +{ + // TODO: Add your command handler code here + CHAR szFullPathName [MAX_PATH]; + CHAR szDrive [MAX_PATH]; + CHAR szDir [MAX_PATH]; + + GetModuleFileName(NULL, szFullPathName, MAX_PATH); + _splitpath(szFullPathName, szDrive, szDir, NULL, NULL); + sprintf(szFullPathName, "%s%sDocuments\\FAQ.txt", szDrive, szDir); + + ShellExecute(this->GetSafeHwnd(), "open", szFullPathName, NULL, NULL, SW_SHOW); +} + +void CExt2MgrDlg::OnInstallService() +{ + Ext2SetManagerAsService(TRUE); +} + +void CExt2MgrDlg::OnRemoveService() +{ + Ext2SetManagerAsService(FALSE); +} + +void CExt2MgrDlg::OnEnableAutorun() +{ + Ext2SetAppAutorun(TRUE); + // Ext2SetManagerAsService(FALSE); + + CMenu* pMenu = AfxGetMainWnd()->GetMenu(); + CMenu* pSubFile = pMenu->GetSubMenu(0); + if (pSubFile) { + if (Ext2RunMgrForCurrentUser()) { + pSubFile->EnableMenuItem(ID_ENABLE_AUTOSTART, MF_BYCOMMAND|MF_GRAYED|MF_DISABLED); + pSubFile->EnableMenuItem(ID_DISABLE_AUTOSTART, MF_BYCOMMAND|MF_ENABLED); + } else { + pSubFile->EnableMenuItem(ID_ENABLE_AUTOSTART, MF_BYCOMMAND|MF_ENABLED); + pSubFile->EnableMenuItem(ID_DISABLE_AUTOSTART, MF_BYCOMMAND|MF_GRAYED|MF_DISABLED); + } + } + +} + +void CExt2MgrDlg::OnDisableAutorun() +{ + Ext2SetAppAutorun(FALSE); + + CMenu* pMenu = AfxGetMainWnd()->GetMenu(); + CMenu* pSubFile = pMenu->GetSubMenu(0); + if (pSubFile) { + if (Ext2RunMgrForCurrentUser()) { + pSubFile->EnableMenuItem(ID_ENABLE_AUTOSTART, MF_BYCOMMAND|MF_GRAYED|MF_DISABLED); + pSubFile->EnableMenuItem(ID_DISABLE_AUTOSTART, MF_BYCOMMAND|MF_ENABLED); + } else { + pSubFile->EnableMenuItem(ID_ENABLE_AUTOSTART, MF_BYCOMMAND|MF_ENABLED); + pSubFile->EnableMenuItem(ID_DISABLE_AUTOSTART, MF_BYCOMMAND|MF_GRAYED|MF_DISABLED); + } + } +} + +void CExt2MgrDlg::OnPerfStat() +{ + if (!m_PerfDlg) { + m_PerfDlg = new CPerfStatDlg; + if (m_PerfDlg) { + m_PerfDlg->Create(IDD_PERFSTAT_DIALOG, this); + } + } + + if (m_PerfDlg) { + m_PerfDlg->ShowWindow(SW_SHOW); + m_PerfDlg->SetForegroundWindow(); + } +} + +void CExt2MgrDlg::OnPerfStop() +{ + if (m_PerfDlg) { + Sleep(100); + delete m_PerfDlg; + m_PerfDlg = NULL; + } +} + + +void +CExt2MgrDlg::RegisterDeviceInterface( + GUID InterfaceClassGuid, + PHDEVNOTIFY hDevNotify + ) +{ + DEV_BROADCAST_DEVICEINTERFACE NotificationFilter; + + ZeroMemory (&NotificationFilter, sizeof(NotificationFilter)); + NotificationFilter.dbcc_size = + sizeof(DEV_BROADCAST_DEVICEINTERFACE); + NotificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; + NotificationFilter.dbcc_classguid = InterfaceClassGuid; + + *hDevNotify = RegisterDeviceNotification( + m_hWnd, + &NotificationFilter, + DEVICE_NOTIFY_WINDOW_HANDLE + ); +} + + +void CExt2MgrDlg::OnFlush() +{ + PEXT2_VOLUME volume = NULL; + PEXT2_PARTITION part = NULL; + + if (m_bFocusVolume) { + if (m_type == EXT2_VOLUME_MAGIC) { + volume = (PEXT2_VOLUME) m_sdev; + } + } else { + if (m_type == EXT2_PART_MAGIC) { + part = (PEXT2_PARTITION) m_sdev; + volume = part->Volume; + } + } + + if (volume) { + Ext2FlushVolume(volume->Name); + } +} + +void CExt2MgrDlg::OnPartType() +{ + CPartitionType PartType; + PEXT2_VOLUME volume = NULL; + PEXT2_PARTITION part = NULL; + CHAR devPath[MAX_PATH]; + + if (m_bFocusVolume) { + if (m_type == EXT2_VOLUME_MAGIC) { + volume = (PEXT2_VOLUME) m_sdev; + } + } else { + if (m_type == EXT2_PART_MAGIC) { + part = (PEXT2_PARTITION) m_sdev; + } + } + + if (volume) { + part = volume->Part; + if (!part) { + return; + } + strcpy(devPath, volume->Name); + } else if (part) { + sprintf(devPath, "\\Device\\Harddisk%u\\Partition%u", + part->Disk->OrderNo, part->Number); + } + + if (part && part->Entry && + part->Entry->PartitionStyle == PARTITION_STYLE_MBR) { + PartType.m_Part = part; + PartType.m_sDevice = devPath; + PartType.DoModal(); + + /* update new partition type */ + if (PartType.m_cPartType) { + + for (int i=0; i < m_DiskView.GetItemCount(); i++) { + if ((ULONG_PTR)part == m_DiskView.GetItemData(i)) { + Ext2RefreshDVPT(&m_DiskView, part, i); + break; + } + } + } + } +} + +void CExt2MgrDlg::OnRemoveDeadLetter() +{ + CDelDeadLetter DelDeadLetter; + DelDeadLetter.DoModal(); +} diff --git a/Ext2Mgr/Ext2MgrDlg.h b/Ext2Mgr/Ext2MgrDlg.h index fc7a9cb..bd5a323 100644 --- a/Ext2Mgr/Ext2MgrDlg.h +++ b/Ext2Mgr/Ext2MgrDlg.h @@ -1,206 +1,206 @@ -// Ext2MgrDlg.h : header file -// - -#if !defined(AFX_EXT2MGRDLG_H__EACC693E_C531_48BA_A0FD_4AFB090CCB29__INCLUDED_) -#define AFX_EXT2MGRDLG_H__EACC693E_C531_48BA_A0FD_4AFB090CCB29__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include "SysTray.h" -#include "Toolbar.h" -#include "splash.h" -#include "donate.h" -#include "TreeList.h" -#include "HyperLink.h" -#include "Mountpoints.h" -#include "Properties.h" -#include "ServiceManage.h" -#include "Ext2Attribute.h" -#include "PerfStatDlg.h" - -///////////////////////////////////////////////////////////////////////////// -// CExt2List window - -class CExt2List : public CListCtrl -{ -// Construction -public: - CExt2List(); - -// Attributes -public: - - CPoint m_Point; - -// Operations -public: - - int QuerySubItemText(int item, CHAR *Data, int length); - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CExt2List) - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~CExt2List(); - - // Generated message map functions -protected: - //{{AFX_MSG(CExt2List) - afx_msg void OnRButtonDown(UINT nFlags, CPoint point); - //}}AFX_MSG - - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// -// CExt2MgrDlg dialog - -class CDlgView; - -class CExt2MgrDlg : public CDialog -{ -// Construction -public: - CExt2MgrDlg(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CExt2MgrDlg) - enum { IDD = IDD_EXT2MGR_DIALOG }; - CTreeList m_DiskView; - CExt2List m_VolumeList; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CExt2MgrDlg) - public: - virtual BOOL PreTranslateMessage(MSG* pMsg); - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); - //}}AFX_VIRTUAL - -public: - - /* routines */ - PVOID QuerySelectedItem(PBOOL bIsExt2); - VOID DriversChangeNotify(ULONG, BOOL); - VOID DriverLetterChangeNotify(CHAR, BOOL); - - VOID DriverChangeNotify(PEXT2_LETTER, BOOL); - - VOID UpdateVolume(PEXT2_VOLUME volume); - VOID UpdateCdrom(PEXT2_CDROM cdrom) ; - VOID UpdatePartition(PEXT2_PARTITION part); - VOID RegisterDeviceInterface(GUID, PHDEVNOTIFY); - VOID OnFlush(); - VOID OnPartType(); - VOID OnRemoveDeadLetter(); - - VOID OnKeyupVolumeList(); - VOID OnKeyupDiskList(); - - ULONG m_type; - PVOID m_sdev; - - /* attributes */ - CSplash * m_splash; - CMenu m_Menu; - - CFont m_MSSanS; - BOOL m_bHide; - BOOL m_bQuiet; - BOOL m_bService; - BOOL m_bStat; - - CPerfStatDlg * m_PerfDlg; - -// Implementation -protected: - - HICON m_hIcon; - - CSystemTray m_Tray; - CStatusBar m_bar; - CImageList m_ImageList; - - BOOL m_bFsStarted; - BOOL m_bHandleChange; - BOOL m_bFocusVolume; - BOOL m_bFocusDisk; - LONG m_IndexVolume; - LONG m_IndexDisk; - - HACCEL m_hAccel; - HDEVNOTIFY m_hUsbNotify; - - /* global parameters */ - ULONG m_nStartmode; - CString m_Codepage; - BOOL m_bExt3Writable; - BOOL m_bReadonly; - CString m_srvStatus; - CString m_sPrefix; - CString m_sSuffix; - BOOL m_bAutoMount; - - // Generated message map functions - //{{AFX_MSG(CExt2MgrDlg) - virtual BOOL OnInitDialog(); - virtual void OnWindowPosChanging(WINDOWPOS* lpwndpos); - afx_msg void OnSysCommand(UINT nID, LPARAM lParam); - afx_msg BOOL OnDeviceChange(UINT nEventType, DWORD_PTR dwData); - afx_msg void OnDestroy(); - afx_msg void OnPaint(); - afx_msg HCURSOR OnQueryDragIcon(); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnChangeProperty(); - afx_msg void OnRefresh(); - afx_msg void OnFormat(); - afx_msg void OnService(); - virtual void OnCancel(); - afx_msg void OnAbout(); - afx_msg void OnExit(); - virtual void OnOK(); - afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct); - afx_msg void OnDblclkDiskList(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnKillfocusDiskList(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnRclickDiskList(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnDblclkVolumeList(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnKillfocusVolumeList(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnRclickVolumeList(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnClickDiskList(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnClickVolumeList(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnSetfocusDiskList(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnSetfocusVolumeList(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnProperty(); - afx_msg void OnDonate(); - afx_msg void OnCopy(); - afx_msg void OnInstallService(); - afx_msg void OnRemoveService(); - afx_msg void OnEnableAutorun(); - afx_msg void OnDisableAutorun(); - afx_msg void OnTimer(UINT_PTR nIDEvent); - afx_msg void OnDrvLetter(); - afx_msg void OnDrvQuickMount(); - afx_msg void OnShowMain(); - afx_msg void OnHelp(); - afx_msg void OnPerfStat(); - afx_msg void OnPerfStop(); - afx_msg void OnCopyAll(); - //}}AFX_MSG - afx_msg LRESULT OnTrayNotification(WPARAM wParam=0,LPARAM lParam=0); - afx_msg LRESULT OnTerminate(WPARAM wParam=0,LPARAM lParam=0); - afx_msg LRESULT OnMountPointNotify(WPARAM wParam=0,LPARAM lParam=0); - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_EXT2MGRDLG_H__EACC693E_C531_48BA_A0FD_4AFB090CCB29__INCLUDED_) +// Ext2MgrDlg.h : header file +// + +#if !defined(AFX_EXT2MGRDLG_H__EACC693E_C531_48BA_A0FD_4AFB090CCB29__INCLUDED_) +#define AFX_EXT2MGRDLG_H__EACC693E_C531_48BA_A0FD_4AFB090CCB29__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "SysTray.h" +#include "Toolbar.h" +#include "splash.h" +#include "donate.h" +#include "TreeList.h" +#include "HyperLink.h" +#include "Mountpoints.h" +#include "Properties.h" +#include "ServiceManage.h" +#include "Ext2Attribute.h" +#include "PerfStatDlg.h" + +///////////////////////////////////////////////////////////////////////////// +// CExt2List window + +class CExt2List : public CListCtrl +{ +// Construction +public: + CExt2List(); + +// Attributes +public: + + CPoint m_Point; + +// Operations +public: + + int QuerySubItemText(int item, CHAR *Data, int length); + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CExt2List) + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CExt2List(); + + // Generated message map functions +protected: + //{{AFX_MSG(CExt2List) + afx_msg void OnRButtonDown(UINT nFlags, CPoint point); + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// +// CExt2MgrDlg dialog + +class CDlgView; + +class CExt2MgrDlg : public CDialog +{ +// Construction +public: + CExt2MgrDlg(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CExt2MgrDlg) + enum { IDD = IDD_EXT2MGR_DIALOG }; + CTreeList m_DiskView; + CExt2List m_VolumeList; + //}}AFX_DATA + + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CExt2MgrDlg) + public: + virtual BOOL PreTranslateMessage(MSG* pMsg); + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); + //}}AFX_VIRTUAL + +public: + + /* routines */ + PVOID QuerySelectedItem(PBOOL bIsExt2); + VOID DriversChangeNotify(ULONG, BOOL); + VOID DriverLetterChangeNotify(CHAR, BOOL); + + VOID DriverChangeNotify(PEXT2_LETTER, BOOL); + + VOID UpdateVolume(PEXT2_VOLUME volume); + VOID UpdateCdrom(PEXT2_CDROM cdrom) ; + VOID UpdatePartition(PEXT2_PARTITION part); + VOID RegisterDeviceInterface(GUID, PHDEVNOTIFY); + VOID OnFlush(); + VOID OnPartType(); + VOID OnRemoveDeadLetter(); + + VOID OnKeyupVolumeList(); + VOID OnKeyupDiskList(); + + ULONG m_type; + PVOID m_sdev; + + /* attributes */ + CSplash * m_splash; + CMenu m_Menu; + + CFont m_MSSanS; + BOOL m_bHide; + BOOL m_bQuiet; + BOOL m_bService; + BOOL m_bStat; + + CPerfStatDlg * m_PerfDlg; + +// Implementation +protected: + + HICON m_hIcon; + + CSystemTray m_Tray; + CStatusBar m_bar; + CImageList m_ImageList; + + BOOL m_bFsStarted; + BOOL m_bHandleChange; + BOOL m_bFocusVolume; + BOOL m_bFocusDisk; + LONG m_IndexVolume; + LONG m_IndexDisk; + + HACCEL m_hAccel; + HDEVNOTIFY m_hUsbNotify; + + /* global parameters */ + ULONG m_nStartmode; + CString m_Codepage; + BOOL m_bExt3Writable; + BOOL m_bReadonly; + CString m_srvStatus; + CString m_sPrefix; + CString m_sSuffix; + BOOL m_bAutoMount; + + // Generated message map functions + //{{AFX_MSG(CExt2MgrDlg) + virtual BOOL OnInitDialog(); + virtual void OnWindowPosChanging(WINDOWPOS* lpwndpos); + afx_msg void OnSysCommand(UINT nID, LPARAM lParam); + afx_msg BOOL OnDeviceChange(UINT nEventType, DWORD_PTR dwData); + afx_msg void OnDestroy(); + afx_msg void OnPaint(); + afx_msg HCURSOR OnQueryDragIcon(); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnChangeProperty(); + afx_msg void OnRefresh(); + afx_msg void OnFormat(); + afx_msg void OnService(); + virtual void OnCancel(); + afx_msg void OnAbout(); + afx_msg void OnExit(); + virtual void OnOK(); + afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct); + afx_msg void OnDblclkDiskList(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnKillfocusDiskList(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnRclickDiskList(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnDblclkVolumeList(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnKillfocusVolumeList(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnRclickVolumeList(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnClickDiskList(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnClickVolumeList(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnSetfocusDiskList(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnSetfocusVolumeList(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnProperty(); + afx_msg void OnDonate(); + afx_msg void OnCopy(); + afx_msg void OnInstallService(); + afx_msg void OnRemoveService(); + afx_msg void OnEnableAutorun(); + afx_msg void OnDisableAutorun(); + afx_msg void OnTimer(UINT_PTR nIDEvent); + afx_msg void OnDrvLetter(); + afx_msg void OnDrvQuickMount(); + afx_msg void OnShowMain(); + afx_msg void OnHelp(); + afx_msg void OnPerfStat(); + afx_msg void OnPerfStop(); + afx_msg void OnCopyAll(); + //}}AFX_MSG + afx_msg LRESULT OnTrayNotification(WPARAM wParam=0,LPARAM lParam=0); + afx_msg LRESULT OnTerminate(WPARAM wParam=0,LPARAM lParam=0); + afx_msg LRESULT OnMountPointNotify(WPARAM wParam=0,LPARAM lParam=0); + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_EXT2MGRDLG_H__EACC693E_C531_48BA_A0FD_4AFB090CCB29__INCLUDED_) diff --git a/Ext2Mgr/HyperLink.cpp b/Ext2Mgr/HyperLink.cpp index 81a560a..754dba8 100644 --- a/Ext2Mgr/HyperLink.cpp +++ b/Ext2Mgr/HyperLink.cpp @@ -1,292 +1,292 @@ -// MyHyperLink.cpp : implementation file -// - -// Written By : Renjith.R -// Email : renji12renji@m2comsys.com -// Details :Derived from MFC CStatic -// Date :Nov 25 2002 - -#include "stdafx.h" -#include "HyperLink.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - - -///////////////////////////////////////////////////////////////////////////// -// CMyHyperLink - -CMyHyperLink::CMyHyperLink() -{ - m_sLinkColor = RGB(0, 0 ,255); - m_sHoverColor = RGB(255, 0, 0); - m_sVisitedColor = RGB(5, 34, 143); - - m_bFireChild = false; - m_bMouseOver = false; - m_bEnableToolTip = false; - m_bVisited = false; - - //Create Tooltip -} - -CMyHyperLink::~CMyHyperLink() -{ -} - - -BEGIN_MESSAGE_MAP(CMyHyperLink, CStatic) - //{{AFX_MSG_MAP(CMyHyperLink) - ON_WM_MOUSEMOVE() - ON_WM_SETCURSOR() - ON_CONTROL_REFLECT(BN_CLICKED, OnClicked) - - - ON_WM_CTLCOLOR_REFLECT() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CMyHyperLink message handlers - -//Sets the Link Color -void CMyHyperLink::SetLinkColor(COLORREF sLinkColor) -{ - m_sLinkColor = sLinkColor; - -} - -//open the URL by Windows ShellExecute() -bool CMyHyperLink::GoToLinkUrl(CString csLink) -{ - - HINSTANCE hInstance = (HINSTANCE)ShellExecute(NULL, _T("open"), csLink.operator LPCTSTR(), NULL, NULL, 2); - - if ((UINT_PTR)hInstance < HINSTANCE_ERROR){ - return false; - }else - return true; -} - -//User can Active/Inactive the Tooltip already they set -void CMyHyperLink::ActiveToolTip(int nFlag) -{ - if (nFlag) - m_bEnableToolTip = true; - else - m_bEnableToolTip = false; -} - -//change The Tooltip text -void CMyHyperLink::SetTootTipText(LPCSTR szToolTip) -{ - if (m_bEnableToolTip ) - { - m_ToolTip.UpdateTipText(szToolTip,this,1001); - } - -} - -//The Mouse Move Message -void CMyHyperLink::OnMouseMove(UINT nFlags, CPoint point) -{ - CStatic::OnMouseMove(nFlags, point); - if (m_bMouseOver) - { - CRect oRect; - GetClientRect(&oRect); - - //check if the mouse is in the rect - if (oRect.PtInRect(point) == false) - { - m_bMouseOver = false; - //Release the Mouse capture previously take - ReleaseCapture(); - RedrawWindow(); - return; - } - }else - { - m_bMouseOver = true; - RedrawWindow(); - //capture the mouse - SetCapture(); - } -} - -//before Subclassing -void CMyHyperLink::PreSubclassWindow() -{ - - //Enable the Static to send the Window Messages To its parent - DWORD dwStyle = GetStyle(); - SetWindowLongPtr(GetSafeHwnd() ,GWL_STYLE ,dwStyle | SS_NOTIFY); - - char szCurretText[MAX_PATH]; - GetWindowText(szCurretText, MAX_PATH); - if ((szCurretText) == NULL){ - SetWindowText(m_csLinkText.operator LPCTSTR()); - } - - LOGFONT sLogFont; - GetFont()->GetLogFont(&sLogFont); - //Set the Link UnderLined - sLogFont.lfUnderline = true; - //Set the Font to the Control - m_oTextFont.CreateFontIndirect(&sLogFont); - this->SetFont(&m_oTextFont, true); - - //Adjust the window - //IsValidURL(); - - //Set the Cursor Hand - //WinHlp32.exe in windows folder ResourceID 106 - //is a standard window HAND cursor - //courtesy www.codeguru.com - //you can use a custom Hand cursor resourse also - // i added that as a resourse in this project with - // ID - IDC_CURSOR_HAND - - char szWindowsDir[MAX_PATH*2]; - GetWindowsDirectory(szWindowsDir ,MAX_PATH*2); - strcat(szWindowsDir,"\\Winhlp32.exe"); - HMODULE hModule = LoadLibrary(szWindowsDir); - - if (hModule){ - m_hHyperCursor = ::LoadCursor(hModule, MAKEINTRESOURCE(106)); - } - - this->SetCursor(m_hHyperCursor); - - //free the module - if (hModule) - FreeLibrary(hModule); - - CStatic::PreSubclassWindow(); - this->SetCursor(m_hHyperCursor); - - m_ToolTip.Create(this,TTS_ALWAYSTIP); - CRect oRect; - GetClientRect(&oRect); - m_ToolTip.AddTool(this,"",oRect,1001); - m_ToolTip.ShowWindow(SW_HIDE); -} - -void CMyHyperLink::SetLinkText(CString csLinkText) -{ - m_csLinkText = csLinkText; - this->SetWindowText(csLinkText.operator LPCTSTR()); - -} - -BOOL CMyHyperLink::PreTranslateMessage(MSG* pMsg) -{ - m_ToolTip.RelayEvent(pMsg); - return CStatic::PreTranslateMessage(pMsg); -} - - -BOOL CMyHyperLink::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) -{ - - ::SetCursor(m_hHyperCursor); - return true; - //return CStatic::OnSetCursor(pWnd, nHitTest, message); -} - -//////////////////EVENT WILL GET HERE ////////////////////// - - -void CMyHyperLink::OnClicked() -{ - if (m_bFireChild){ - //Fire the Event to Parent Window - CWnd *pParent; - pParent = GetParent(); - int nCtrlID = GetDlgCtrlID(); - ::SendMessage(pParent->m_hWnd, _HYPERLINK_EVENT, (WPARAM)nCtrlID, 0); - //::PostMessage(pParent->m_hWnd, __EVENT_ID_, (WPARAM)nCtrlID, 0); - - }else - { - GoToLinkUrl(m_csUrl); - } - - m_bVisited = true; - //reddraw the control - this->Invalidate(true); -} - -HBRUSH CMyHyperLink::CtlColor(CDC* pDC, UINT nCtlColor) -{ - if (m_bMouseOver){ - if (m_bVisited) - pDC->SetTextColor(m_sVisitedColor); - else - pDC->SetTextColor(m_sHoverColor); - }else { - if (m_bVisited) - pDC->SetTextColor(m_sVisitedColor); - else - pDC->SetTextColor(m_sLinkColor); - } - pDC->SetBkMode(TRANSPARENT); - return((HBRUSH)GetStockObject(NULL_BRUSH)); -} - -void CMyHyperLink::SetToolTipTextColor(COLORREF sToolTipText) { - m_ToolTip.SetTipTextColor(sToolTipText); -} - -void CMyHyperLink::SetToolTipBgColor(COLORREF sToolTipBgColor) -{ - m_ToolTip.SetTipBkColor(sToolTipBgColor); - -} - -CString CMyHyperLink::GetLinkText() { - if (m_csLinkText.IsEmpty()) - return CString(""); - return m_csLinkText; -} - -void CMyHyperLink::SetLinkUrl(CString csUrl) { - m_csUrl= csUrl; -} - -CString CMyHyperLink::GetLinkUrl() { - return m_csUrl; -} - -void CMyHyperLink::SetVisitedColor(COLORREF sVisitedColor) { - m_sVisitedColor = sVisitedColor ; -} - -void CMyHyperLink::SetHoverColor(COLORREF cHoverColor) { - m_sHoverColor = cHoverColor; -} - -void CMyHyperLink::SetFireChild(int nFlag) { - if (nFlag) - m_bFireChild = true; - else - m_bFireChild = false; -} - -BOOL CMyHyperLink::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) -{ - NMHDR* pMsgHdr; - pMsgHdr = (NMHDR*) lParam; - - switch (pMsgHdr->code){ - case NM_RCLICK: - break; - default: - ; - } - - return CStatic::OnNotify(wParam, lParam, pResult); -} +// MyHyperLink.cpp : implementation file +// + +// Written By : Renjith.R +// Email : renji12renji@m2comsys.com +// Details :Derived from MFC CStatic +// Date :Nov 25 2002 + +#include "stdafx.h" +#include "HyperLink.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + + +///////////////////////////////////////////////////////////////////////////// +// CMyHyperLink + +CMyHyperLink::CMyHyperLink() +{ + m_sLinkColor = RGB(0, 0 ,255); + m_sHoverColor = RGB(255, 0, 0); + m_sVisitedColor = RGB(5, 34, 143); + + m_bFireChild = false; + m_bMouseOver = false; + m_bEnableToolTip = false; + m_bVisited = false; + + //Create Tooltip +} + +CMyHyperLink::~CMyHyperLink() +{ +} + + +BEGIN_MESSAGE_MAP(CMyHyperLink, CStatic) + //{{AFX_MSG_MAP(CMyHyperLink) + ON_WM_MOUSEMOVE() + ON_WM_SETCURSOR() + ON_CONTROL_REFLECT(BN_CLICKED, OnClicked) + + + ON_WM_CTLCOLOR_REFLECT() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CMyHyperLink message handlers + +//Sets the Link Color +void CMyHyperLink::SetLinkColor(COLORREF sLinkColor) +{ + m_sLinkColor = sLinkColor; + +} + +//open the URL by Windows ShellExecute() +bool CMyHyperLink::GoToLinkUrl(CString csLink) +{ + + HINSTANCE hInstance = (HINSTANCE)ShellExecute(NULL, _T("open"), csLink.operator LPCTSTR(), NULL, NULL, 2); + + if ((UINT_PTR)hInstance < HINSTANCE_ERROR){ + return false; + }else + return true; +} + +//User can Active/Inactive the Tooltip already they set +void CMyHyperLink::ActiveToolTip(int nFlag) +{ + if (nFlag) + m_bEnableToolTip = true; + else + m_bEnableToolTip = false; +} + +//change The Tooltip text +void CMyHyperLink::SetTootTipText(LPCSTR szToolTip) +{ + if (m_bEnableToolTip ) + { + m_ToolTip.UpdateTipText(szToolTip,this,1001); + } + +} + +//The Mouse Move Message +void CMyHyperLink::OnMouseMove(UINT nFlags, CPoint point) +{ + CStatic::OnMouseMove(nFlags, point); + if (m_bMouseOver) + { + CRect oRect; + GetClientRect(&oRect); + + //check if the mouse is in the rect + if (oRect.PtInRect(point) == false) + { + m_bMouseOver = false; + //Release the Mouse capture previously take + ReleaseCapture(); + RedrawWindow(); + return; + } + }else + { + m_bMouseOver = true; + RedrawWindow(); + //capture the mouse + SetCapture(); + } +} + +//before Subclassing +void CMyHyperLink::PreSubclassWindow() +{ + + //Enable the Static to send the Window Messages To its parent + DWORD dwStyle = GetStyle(); + SetWindowLongPtr(GetSafeHwnd() ,GWL_STYLE ,dwStyle | SS_NOTIFY); + + char szCurretText[MAX_PATH]; + GetWindowText(szCurretText, MAX_PATH); + if ((szCurretText) == NULL){ + SetWindowText(m_csLinkText.operator LPCTSTR()); + } + + LOGFONT sLogFont; + GetFont()->GetLogFont(&sLogFont); + //Set the Link UnderLined + sLogFont.lfUnderline = true; + //Set the Font to the Control + m_oTextFont.CreateFontIndirect(&sLogFont); + this->SetFont(&m_oTextFont, true); + + //Adjust the window + //IsValidURL(); + + //Set the Cursor Hand + //WinHlp32.exe in windows folder ResourceID 106 + //is a standard window HAND cursor + //courtesy www.codeguru.com + //you can use a custom Hand cursor resourse also + // i added that as a resourse in this project with + // ID - IDC_CURSOR_HAND + + char szWindowsDir[MAX_PATH*2]; + GetWindowsDirectory(szWindowsDir ,MAX_PATH*2); + strcat(szWindowsDir,"\\Winhlp32.exe"); + HMODULE hModule = LoadLibrary(szWindowsDir); + + if (hModule){ + m_hHyperCursor = ::LoadCursor(hModule, MAKEINTRESOURCE(106)); + } + + this->SetCursor(m_hHyperCursor); + + //free the module + if (hModule) + FreeLibrary(hModule); + + CStatic::PreSubclassWindow(); + this->SetCursor(m_hHyperCursor); + + m_ToolTip.Create(this,TTS_ALWAYSTIP); + CRect oRect; + GetClientRect(&oRect); + m_ToolTip.AddTool(this,"",oRect,1001); + m_ToolTip.ShowWindow(SW_HIDE); +} + +void CMyHyperLink::SetLinkText(CString csLinkText) +{ + m_csLinkText = csLinkText; + this->SetWindowText(csLinkText.operator LPCTSTR()); + +} + +BOOL CMyHyperLink::PreTranslateMessage(MSG* pMsg) +{ + m_ToolTip.RelayEvent(pMsg); + return CStatic::PreTranslateMessage(pMsg); +} + + +BOOL CMyHyperLink::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) +{ + + ::SetCursor(m_hHyperCursor); + return true; + //return CStatic::OnSetCursor(pWnd, nHitTest, message); +} + +//////////////////EVENT WILL GET HERE ////////////////////// + + +void CMyHyperLink::OnClicked() +{ + if (m_bFireChild){ + //Fire the Event to Parent Window + CWnd *pParent; + pParent = GetParent(); + int nCtrlID = GetDlgCtrlID(); + ::SendMessage(pParent->m_hWnd, _HYPERLINK_EVENT, (WPARAM)nCtrlID, 0); + //::PostMessage(pParent->m_hWnd, __EVENT_ID_, (WPARAM)nCtrlID, 0); + + }else + { + GoToLinkUrl(m_csUrl); + } + + m_bVisited = true; + //reddraw the control + this->Invalidate(true); +} + +HBRUSH CMyHyperLink::CtlColor(CDC* pDC, UINT nCtlColor) +{ + if (m_bMouseOver){ + if (m_bVisited) + pDC->SetTextColor(m_sVisitedColor); + else + pDC->SetTextColor(m_sHoverColor); + }else { + if (m_bVisited) + pDC->SetTextColor(m_sVisitedColor); + else + pDC->SetTextColor(m_sLinkColor); + } + pDC->SetBkMode(TRANSPARENT); + return((HBRUSH)GetStockObject(NULL_BRUSH)); +} + +void CMyHyperLink::SetToolTipTextColor(COLORREF sToolTipText) { + m_ToolTip.SetTipTextColor(sToolTipText); +} + +void CMyHyperLink::SetToolTipBgColor(COLORREF sToolTipBgColor) +{ + m_ToolTip.SetTipBkColor(sToolTipBgColor); + +} + +CString CMyHyperLink::GetLinkText() { + if (m_csLinkText.IsEmpty()) + return CString(""); + return m_csLinkText; +} + +void CMyHyperLink::SetLinkUrl(CString csUrl) { + m_csUrl= csUrl; +} + +CString CMyHyperLink::GetLinkUrl() { + return m_csUrl; +} + +void CMyHyperLink::SetVisitedColor(COLORREF sVisitedColor) { + m_sVisitedColor = sVisitedColor ; +} + +void CMyHyperLink::SetHoverColor(COLORREF cHoverColor) { + m_sHoverColor = cHoverColor; +} + +void CMyHyperLink::SetFireChild(int nFlag) { + if (nFlag) + m_bFireChild = true; + else + m_bFireChild = false; +} + +BOOL CMyHyperLink::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) +{ + NMHDR* pMsgHdr; + pMsgHdr = (NMHDR*) lParam; + + switch (pMsgHdr->code){ + case NM_RCLICK: + break; + default: + ; + } + + return CStatic::OnNotify(wParam, lParam, pResult); +} diff --git a/Ext2Mgr/HyperLink.h b/Ext2Mgr/HyperLink.h index d656776..eaa2dfe 100644 --- a/Ext2Mgr/HyperLink.h +++ b/Ext2Mgr/HyperLink.h @@ -1,108 +1,108 @@ -//////////////////////////////////////////////////////// -// Class Name : CMyHyperLink -// Written By : Renjith.R -// Email : renjith_sree@hotmail.com -// Details :Derived from MFC CStatic -// Date :Nov 25 2002 -// This can be used as a Hyperlink -//Feel free to use this class in your project - -/////////////////////////////////////////////////////////// - - -#if !defined(AFX_MYHYPERLINK_H__699B2FB4_0C03_4B12_B117_210A97860E0D__INCLUDED_) -#define AFX_MYHYPERLINK_H__699B2FB4_0C03_4B12_B117_210A97860E0D__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// MyHyperLink.h : header file -// - -//This is the EventID , Which Will send to the Parent -//by the hyperlink control - -# define _HYPERLINK_EVENT WM_USER + 101 - -///////////////////////////////////////////////////////////////////////////// -// CMyHyperLink window - -class CMyHyperLink : public CStatic -{ -// Construction -public: - CMyHyperLink(); - -// Attributes -public: - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CMyHyperLink) - public: - virtual BOOL PreTranslateMessage(MSG* pMsg); - protected: - virtual void PreSubclassWindow(); - virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); - //}}AFX_VIRTUAL - -// Implementation -public: - void SetFireChild(int nFlag); - CString GetLinkText(); - CString GetLinkUrl(); - - bool GoToLinkUrl(CString csLink); - - void SetHoverColor(COLORREF cHoverColor); - void SetVisitedColor(COLORREF sVisitedColor); - void SetLinkUrl(CString csUrl); - void SetToolTipBgColor(COLORREF sToolTipBgColor); - void SetToolTipTextColor(COLORREF sToolTipText); - void SetLinkText(CString csLinkText); - void SetTootTipText(LPCSTR szToolTip); - void ActiveToolTip(int nFlag); - void SetLinkColor(COLORREF sLinkColor); - - virtual ~CMyHyperLink(); - - // Generated message map functions -protected: - bool m_bFireChild; - - HCURSOR m_hHyperCursor; - - bool m_bEnableToolTip; - bool m_bMouseOver; - bool m_bVisited; - - CFont m_oTextFont; - CToolTipCtrl m_ToolTip; - - CString m_csToolTipText; - CString m_csLinkText; - CString m_csUrl; - - COLORREF m_sHoverColor; - COLORREF m_sLinkColor; - COLORREF m_sVisitedColor; - - //{{AFX_MSG(CMyHyperLink) - afx_msg void OnMouseMove(UINT nFlags, CPoint point); - afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); - afx_msg void OnClicked(); - afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor); - //}}AFX_MSG - - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_MYHYPERLINK_H__699B2FB4_0C03_4B12_B117_210A97860E0D__INCLUDED_) +//////////////////////////////////////////////////////// +// Class Name : CMyHyperLink +// Written By : Renjith.R +// Email : renjith_sree@hotmail.com +// Details :Derived from MFC CStatic +// Date :Nov 25 2002 +// This can be used as a Hyperlink +//Feel free to use this class in your project + +/////////////////////////////////////////////////////////// + + +#if !defined(AFX_MYHYPERLINK_H__699B2FB4_0C03_4B12_B117_210A97860E0D__INCLUDED_) +#define AFX_MYHYPERLINK_H__699B2FB4_0C03_4B12_B117_210A97860E0D__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// MyHyperLink.h : header file +// + +//This is the EventID , Which Will send to the Parent +//by the hyperlink control + +# define _HYPERLINK_EVENT WM_USER + 101 + +///////////////////////////////////////////////////////////////////////////// +// CMyHyperLink window + +class CMyHyperLink : public CStatic +{ +// Construction +public: + CMyHyperLink(); + +// Attributes +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CMyHyperLink) + public: + virtual BOOL PreTranslateMessage(MSG* pMsg); + protected: + virtual void PreSubclassWindow(); + virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); + //}}AFX_VIRTUAL + +// Implementation +public: + void SetFireChild(int nFlag); + CString GetLinkText(); + CString GetLinkUrl(); + + bool GoToLinkUrl(CString csLink); + + void SetHoverColor(COLORREF cHoverColor); + void SetVisitedColor(COLORREF sVisitedColor); + void SetLinkUrl(CString csUrl); + void SetToolTipBgColor(COLORREF sToolTipBgColor); + void SetToolTipTextColor(COLORREF sToolTipText); + void SetLinkText(CString csLinkText); + void SetTootTipText(LPCSTR szToolTip); + void ActiveToolTip(int nFlag); + void SetLinkColor(COLORREF sLinkColor); + + virtual ~CMyHyperLink(); + + // Generated message map functions +protected: + bool m_bFireChild; + + HCURSOR m_hHyperCursor; + + bool m_bEnableToolTip; + bool m_bMouseOver; + bool m_bVisited; + + CFont m_oTextFont; + CToolTipCtrl m_ToolTip; + + CString m_csToolTipText; + CString m_csLinkText; + CString m_csUrl; + + COLORREF m_sHoverColor; + COLORREF m_sLinkColor; + COLORREF m_sVisitedColor; + + //{{AFX_MSG(CMyHyperLink) + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); + afx_msg void OnClicked(); + afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor); + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_MYHYPERLINK_H__699B2FB4_0C03_4B12_B117_210A97860E0D__INCLUDED_) diff --git a/Ext2Mgr/MountPoints.cpp b/Ext2Mgr/MountPoints.cpp index fd4463e..7bd393b 100644 --- a/Ext2Mgr/MountPoints.cpp +++ b/Ext2Mgr/MountPoints.cpp @@ -1,499 +1,499 @@ -// MountPoints.cpp : implementation file -// - -#include "stdafx.h" -#include "ext2mgr.h" -#include "MountPoints.h" -#include "Ext2MgrDlg.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CMountPoints dialog - - -CMountPoints::CMountPoints(CWnd* pParent /*=NULL*/) - : CDialog(CMountPoints::IDD, pParent) -{ - //{{AFX_DATA_INIT(CMountPoints) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT - m_Cdrom = NULL; - m_Volume = NULL; - m_Part = NULL; - m_Letter = ""; - m_bUpdated = TRUE; - m_bMgrNoted = FALSE; - m_MainDlg = NULL; -} - -void CMountPoints::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CMountPoints) - DDX_Control(pDX, IDC_DRV_LETTER_LIST, m_drvList); - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CMountPoints, CDialog) - //{{AFX_MSG_MAP(CMountPoints) - ON_NOTIFY(NM_CLICK, IDC_DRV_LETTER_LIST, OnClickDrvLetterList) - ON_BN_CLICKED(ID_ADD_MOUNTPOINT, OnAddMountpoint) - ON_BN_CLICKED(ID_CHANGE_MOUNTPOINT, OnChangeMountpoint) - ON_BN_CLICKED(ID_REMOVE_MOUNTPOINT, OnRemoveMountpoint) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CMountPoints message handlers - -void CMountPoints::OnClickDrvLetterList(NMHDR* pNMHDR, LRESULT* pResult) -{ - // TODO: Add your control notification handler code here - int item = m_drvList.GetSelectionMark(); - if (item != -1) { - m_Letter = m_drvList.GetItemText(item, 0); - - if (!m_Letter.IsEmpty()) { - SET_WIN(ID_CHANGE_MOUNTPOINT, TRUE); - SET_WIN(ID_REMOVE_MOUNTPOINT, TRUE); - } - } - - if (pResult) { - *pResult = 0; - } -} - -BOOL -CMountPoints::AddMountPoint( - CHAR drvChar, - BOOL bRegistry, - BOOL bMountMgr - ) -{ - CHAR devPath[MAX_PATH]; - PEXT2_LETTER drvLetter = NULL; - ULONGLONG letterMask = 0; - BOOL rc = TRUE; - BOOL bMount = FALSE; - - PEXT2_VOLUME_PROPERTY3 EVP = NULL; - - memset(devPath, 0, MAX_PATH); - - if (drvChar >= '0' && drvChar <= '9') { - drvLetter = &drvDigits[drvChar - '0']; - letterMask = ((ULONGLONG) 1) << (drvChar - '0' + 32); - } else if (drvChar >= 'A' && drvChar <= 'Z') { - drvLetter = &drvLetters[drvChar - 'A']; - letterMask = ((ULONGLONG) 1) << (drvChar - 'A'); - } - - if (!drvLetter) { - return FALSE; - } - - if (m_Part) { - if (m_Part->Volume) { - strcpy(devPath, m_Part->Volume->Name); - } else { - sprintf(devPath, "\\Device\\Harddisk%u\\Partition%u", - m_Part->Disk->OrderNo, m_Part->Number); - } - } - - if (m_Volume) { - strcpy(devPath, m_Volume->Name); - EVP = &m_Volume->EVP; - } - - if (m_Cdrom) { - strcpy(devPath, m_Cdrom->Name); - EVP = &m_Cdrom->EVP; - } - - if (bRegistry) { - CString str; - - if (Ext2SetRegistryMountPoint(&drvChar, devPath, bRegistry)) { - Ext2AssignDrvLetter(drvLetter, devPath, FALSE); - EndDialog(0); - } else { - str.Format("Failed to modify registry: SYSTEM\\CurrentControlSet\\Control\\Session Manager\\DOS Devices\n"); - AfxMessageBox(str, MB_OK|MB_ICONWARNING); - return FALSE; - } - } - - if (drvLetter->bUsed) - return FALSE; - - if ((m_Volume != NULL) && (m_Volume->DrvLetters == 0) && - (m_Volume->EVP.bExt2 || m_Volume->EVP.bExt3) ) { - bMount = TRUE; - } else if (m_Part != NULL && m_Part->Volume && - (m_Part->Volume->DrvLetters == 0) && - (m_Part->Volume->EVP.bExt2 || m_Part->Volume->EVP.bExt3) ) { - EVP = &m_Part->Volume->EVP; - bMount = TRUE; - } - - if (EVP) { - if (Ext2IsNullUuid(&EVP->UUID[0])) { - AfxMessageBox("UUID is 0."); - } - if (!Ext2CheckVolumeRegistryProperty(EVP)) { - Ext2SetDefaultVolumeRegistryProperty(EVP); - } - } - - /* create an entry in regisgtry */ - { - - NT::NTSTATUS status; - HANDLE Handle = NULL; - CString str; - - status = Ext2Open(devPath, &Handle, EXT2_DESIRED_ACCESS); - if (!NT_SUCCESS(status)) { - str.Format("Ext2Fsd service is not started.\n"); - AfxMessageBox(str, MB_OK | MB_ICONSTOP); - return FALSE; - } - - rc = Ext2QueryExt2Property(Handle, EVP); - if (!rc) { - goto errorout; - } - - EVP->DrvLetter = drvLetter->Letter | 0x80; - EVP->Flags2 |= EXT2_VPROP3_AUTOMOUNT; - Ext2StorePropertyinRegistry(EVP); - - rc = Ext2SetExt2Property(Handle, EVP); - -errorout: - - Ext2Close(&Handle); - } - - if (bMount) - { - rc = Ext2AssignDrvLetter(drvLetter, devPath, bMountMgr); - if (!rc && !bMountMgr) { - CString str; - str.Format("Failed to assign new drive letter %c:\n", drvChar); - AfxMessageBox(str, MB_OK|MB_ICONWARNING); - return FALSE; - } - } else { - rc = FALSE; - } - - if (0 && bMountMgr) { - - Ext2UpdateDrvLetter(drvLetter, devPath); - - if (!bMount) { - Ext2RefreshVolumePoint(devPath, drvLetter->Letter); - } - - Sleep(500); - drvChar = Ext2QueryMountPoint(devPath); - - if (drvChar >= '0' && drvChar <= '9') { - drvLetter = &drvDigits[drvChar - '0']; - letterMask = ((ULONGLONG) 1) << (drvChar - '0' + 32); - } else if (drvChar >= 'A' && drvChar <= 'Z') { - drvLetter = &drvLetters[drvChar - 'A']; - letterMask = ((ULONGLONG) 1) << (drvChar - 'A'); - } else { - drvLetter = NULL; letterMask = 0; - } - - rc = drvLetter ? TRUE : FALSE; - } - - if (rc) { - - m_bUpdated = TRUE; - if (m_Part) { - m_Part->DrvLetters |= letterMask; - if (m_Part->Volume) { - m_Part->Volume->DrvLetters |= letterMask; - } - InitializeList(m_Part->DrvLetters); - } - if (m_Volume) { - m_Volume->DrvLetters |= letterMask; - InitializeList(m_Volume->DrvLetters); - } - if (m_Cdrom) { - m_Cdrom->DrvLetters |= letterMask; - InitializeList(m_Cdrom->DrvLetters); - } - - /* - ((CExt2MgrDlg *)m_MainDlg)->DriverLetterChangeNotify(drvLetter->Letter, TRUE); - */ - - m_MainDlg->SendMessage( - WM_MOUNTPOINT_NOTIFY, - 'DA', (LPARAM)drvLetter->Letter); - } - - return TRUE; -} - -void CMountPoints::OnAddMountpoint() -{ - CSelectDrvLetter drvSel; - STORAGE_BUS_TYPE busType = BusTypeAta; - - if (m_Part) { - busType = m_Part->Disk->SDD.BusType; - } - - if (m_Volume && m_Volume->Part) { - busType = m_Volume->Part->Disk->SDD.BusType; - } - -#if TRUE - drvSel.m_bDosDev = TRUE; - drvSel.m_bMountMgr = FALSE; - drvSel.m_bRegistry = FALSE; -#else - if (m_Cdrom || - busType == BusType1394 || - busType == BusTypeUsb ) { - - drvSel.m_bMountMgr = TRUE; - drvSel.m_bRegistry = FALSE; - drvSel.m_bDosDev = FALSE; - } -#endif - - if (drvSel.DoModal() != IDOK) { - return; - } - - AddMountPoint(drvSel.m_DrvLetter.GetAt(0), - drvSel.m_bRegistry, - drvSel.m_bMountMgr - ); - - OnOK(); -} - -void CMountPoints::OnChangeMountpoint() -{ - CHAR odrvChar = 0; - CHAR ndrvChar = 0; - - CSelectDrvLetter drvSel; - STORAGE_BUS_TYPE busType = BusTypeAta; - - if (m_Part) { - busType = m_Part->Disk->SDD.BusType; - } - - if (m_Volume && m_Volume->Part) { - busType = m_Volume->Part->Disk->SDD.BusType; - } - -#if TRUE - - drvSel.m_bMountMgr = FALSE; - drvSel.m_bRegistry = FALSE; - drvSel.m_bDosDev = TRUE; - -#else - if (m_Cdrom || - busType == BusType1394 || - busType == BusTypeUsb ) { - - drvSel.m_bMountMgr = TRUE; - drvSel.m_bRegistry = FALSE; - drvSel.m_bDosDev = FALSE; - } -#endif - - if (drvSel.DoModal() != IDOK) { - return; - } - - ndrvChar = drvSel.m_DrvLetter.GetAt(0); - odrvChar = m_Letter.GetAt(0); - - if (RemoveMountPoint(odrvChar)) { - AddMountPoint( - ndrvChar, - drvSel.m_bRegistry, - drvSel.m_bMountMgr - ); - } - - OnOK(); -} - -BOOL -CMountPoints::RemoveMountPoint(CHAR drvChar) -{ - PEXT2_LETTER drvLetter = NULL; - ULONGLONG letterMask = 0; - - if (drvChar >= '0' && drvChar <= '9') { - drvLetter = &drvDigits[drvChar - '0']; - letterMask = ((ULONGLONG) 1) << (drvChar - '0' + 32); - } else if (drvChar >= 'A' && drvChar <= 'Z') { - drvLetter = &drvLetters[drvChar - 'A']; - letterMask = ((ULONGLONG) 1) << (drvChar - 'A'); - } - - if (!drvLetter) { - return FALSE; - } - - Ext2SetRegistryMountPoint(&drvChar, NULL, FALSE); - if (Ext2RemoveDrvLetter(drvLetter)) { - - m_MainDlg->SendMessage(WM_MOUNTPOINT_NOTIFY, - 'DR', (LPARAM)drvLetter->Letter); - - } else { - - CString str; - str.Format("Failed to remove drive letter %c:\n", drvChar); - AfxMessageBox(str, MB_OK|MB_ICONWARNING); - return FALSE; - } - - if (m_Part) { - m_Part->DrvLetters &= (~letterMask); - if (m_Part->Volume) { - m_Part->Volume->DrvLetters &= ~letterMask; - } - InitializeList(m_Part->DrvLetters); - } - - if (m_Volume) { - PEXT2_PARTITION part = Ext2QueryVolumePartition(m_Volume); - m_Volume->DrvLetters &= ~letterMask; - if (part) { - part->DrvLetters &= ~letterMask; - } - InitializeList(m_Volume->DrvLetters); - } - - if (m_Cdrom) { - m_Cdrom->DrvLetters &= ~letterMask; - InitializeList(m_Cdrom->DrvLetters); - } - - return TRUE; -} - -void CMountPoints::OnRemoveMountpoint() -{ - CHAR drvChar = m_Letter.GetAt(0); - - if (RemoveMountPoint(drvChar)) { - SET_WIN(ID_CHANGE_MOUNTPOINT, FALSE); - SET_WIN(ID_REMOVE_MOUNTPOINT, FALSE); - if (m_drvList.GetItemCount() == 0) - OnOK(); - } -} - -void CMountPoints::OnOK() -{ - // TODO: Add extra validation here - - CDialog::OnOK(); -} - -void CMountPoints::OnCancel() -{ - CDialog::OnCancel(); -} - - -void CMountPoints::InitializeList(ULONGLONG letters) -{ - CHAR drvName[] = "C:\0"; - int i = 0; - ULONGLONG drive = 0; - - m_drvList.DeleteAllItems(); - - for (i=0; i < 10; i++) { - drive = ((ULONGLONG) 1) << (i + 32); - if (letters & drive) { - drvName[0] = '0' + i; - m_drvList.InsertItem( - m_drvList.GetItemCount(), - drvName); - } - } - - for (i=2; i < 26; i++) { - drive = ((ULONGLONG) 1) << (i); - if (letters & drive) { - drvName[0] = 'A' + i; - m_drvList.InsertItem( - m_drvList.GetItemCount(), - drvName); - } - } -} - -BOOL CMountPoints::OnInitDialog() -{ - CDialog::OnInitDialog(); - - // TODO: Add extra initialization here - ASSERT(m_Volume || m_Part); - - if (m_Part) { - InitializeList(m_Part->DrvLetters); - } else if (m_Volume) { - InitializeList(m_Volume->DrvLetters); - } else { - InitializeList(m_Cdrom->DrvLetters); - } - - m_drvList.SetSelectionMark(0); - m_drvList.SetFocus(); - m_Letter = m_drvList.GetItemText(0, 0); - - if (m_Letter.IsEmpty()) { - SET_WIN(ID_CHANGE_MOUNTPOINT, FALSE); - SET_WIN(ID_REMOVE_MOUNTPOINT, FALSE); - } else { - SET_WIN(ID_CHANGE_MOUNTPOINT, TRUE); - SET_WIN(ID_REMOVE_MOUNTPOINT, TRUE); - } - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -BOOL CMountPoints::PreTranslateMessage(MSG* pMsg) -{ - // TODO: Add your specialized code here and/or call the base class - -#if 0 - if (pMsg->message==WM_KEYDOWN) { - if (pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE) { - pMsg->wParam = NULL; - } - } -#endif - - return CDialog::PreTranslateMessage(pMsg); -} +// MountPoints.cpp : implementation file +// + +#include "stdafx.h" +#include "ext2mgr.h" +#include "MountPoints.h" +#include "Ext2MgrDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CMountPoints dialog + + +CMountPoints::CMountPoints(CWnd* pParent /*=NULL*/) + : CDialog(CMountPoints::IDD, pParent) +{ + //{{AFX_DATA_INIT(CMountPoints) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + m_Cdrom = NULL; + m_Volume = NULL; + m_Part = NULL; + m_Letter = ""; + m_bUpdated = TRUE; + m_bMgrNoted = FALSE; + m_MainDlg = NULL; +} + +void CMountPoints::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CMountPoints) + DDX_Control(pDX, IDC_DRV_LETTER_LIST, m_drvList); + //}}AFX_DATA_MAP +} + +BEGIN_MESSAGE_MAP(CMountPoints, CDialog) + //{{AFX_MSG_MAP(CMountPoints) + ON_NOTIFY(NM_CLICK, IDC_DRV_LETTER_LIST, OnClickDrvLetterList) + ON_BN_CLICKED(ID_ADD_MOUNTPOINT, OnAddMountpoint) + ON_BN_CLICKED(ID_CHANGE_MOUNTPOINT, OnChangeMountpoint) + ON_BN_CLICKED(ID_REMOVE_MOUNTPOINT, OnRemoveMountpoint) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CMountPoints message handlers + +void CMountPoints::OnClickDrvLetterList(NMHDR* pNMHDR, LRESULT* pResult) +{ + // TODO: Add your control notification handler code here + int item = m_drvList.GetSelectionMark(); + if (item != -1) { + m_Letter = m_drvList.GetItemText(item, 0); + + if (!m_Letter.IsEmpty()) { + SET_WIN(ID_CHANGE_MOUNTPOINT, TRUE); + SET_WIN(ID_REMOVE_MOUNTPOINT, TRUE); + } + } + + if (pResult) { + *pResult = 0; + } +} + +BOOL +CMountPoints::AddMountPoint( + CHAR drvChar, + BOOL bRegistry, + BOOL bMountMgr + ) +{ + CHAR devPath[MAX_PATH]; + PEXT2_LETTER drvLetter = NULL; + ULONGLONG letterMask = 0; + BOOL rc = TRUE; + BOOL bMount = FALSE; + + PEXT2_VOLUME_PROPERTY3 EVP = NULL; + + memset(devPath, 0, MAX_PATH); + + if (drvChar >= '0' && drvChar <= '9') { + drvLetter = &drvDigits[drvChar - '0']; + letterMask = ((ULONGLONG) 1) << (drvChar - '0' + 32); + } else if (drvChar >= 'A' && drvChar <= 'Z') { + drvLetter = &drvLetters[drvChar - 'A']; + letterMask = ((ULONGLONG) 1) << (drvChar - 'A'); + } + + if (!drvLetter) { + return FALSE; + } + + if (m_Part) { + if (m_Part->Volume) { + strcpy(devPath, m_Part->Volume->Name); + } else { + sprintf(devPath, "\\Device\\Harddisk%u\\Partition%u", + m_Part->Disk->OrderNo, m_Part->Number); + } + } + + if (m_Volume) { + strcpy(devPath, m_Volume->Name); + EVP = &m_Volume->EVP; + } + + if (m_Cdrom) { + strcpy(devPath, m_Cdrom->Name); + EVP = &m_Cdrom->EVP; + } + + if (bRegistry) { + CString str; + + if (Ext2SetRegistryMountPoint(&drvChar, devPath, bRegistry)) { + Ext2AssignDrvLetter(drvLetter, devPath, FALSE); + EndDialog(0); + } else { + str.Format("Failed to modify registry: SYSTEM\\CurrentControlSet\\Control\\Session Manager\\DOS Devices\n"); + AfxMessageBox(str, MB_OK|MB_ICONWARNING); + return FALSE; + } + } + + if (drvLetter->bUsed) + return FALSE; + + if ((m_Volume != NULL) && (m_Volume->DrvLetters == 0) && + (m_Volume->EVP.bExt2 || m_Volume->EVP.bExt3) ) { + bMount = TRUE; + } else if (m_Part != NULL && m_Part->Volume && + (m_Part->Volume->DrvLetters == 0) && + (m_Part->Volume->EVP.bExt2 || m_Part->Volume->EVP.bExt3) ) { + EVP = &m_Part->Volume->EVP; + bMount = TRUE; + } + + if (EVP) { + if (Ext2IsNullUuid(&EVP->UUID[0])) { + AfxMessageBox("UUID is 0."); + } + if (!Ext2CheckVolumeRegistryProperty(EVP)) { + Ext2SetDefaultVolumeRegistryProperty(EVP); + } + } + + /* create an entry in regisgtry */ + { + + NT::NTSTATUS status; + HANDLE Handle = NULL; + CString str; + + status = Ext2Open(devPath, &Handle, EXT2_DESIRED_ACCESS); + if (!NT_SUCCESS(status)) { + str.Format("Ext2Fsd service is not started.\n"); + AfxMessageBox(str, MB_OK | MB_ICONSTOP); + return FALSE; + } + + rc = Ext2QueryExt2Property(Handle, EVP); + if (!rc) { + goto errorout; + } + + EVP->DrvLetter = drvLetter->Letter | 0x80; + EVP->Flags2 |= EXT2_VPROP3_AUTOMOUNT; + Ext2StorePropertyinRegistry(EVP); + + rc = Ext2SetExt2Property(Handle, EVP); + +errorout: + + Ext2Close(&Handle); + } + + if (bMount) + { + rc = Ext2AssignDrvLetter(drvLetter, devPath, bMountMgr); + if (!rc && !bMountMgr) { + CString str; + str.Format("Failed to assign new drive letter %c:\n", drvChar); + AfxMessageBox(str, MB_OK|MB_ICONWARNING); + return FALSE; + } + } else { + rc = FALSE; + } + + if (0 && bMountMgr) { + + Ext2UpdateDrvLetter(drvLetter, devPath); + + if (!bMount) { + Ext2RefreshVolumePoint(devPath, drvLetter->Letter); + } + + Sleep(500); + drvChar = Ext2QueryMountPoint(devPath); + + if (drvChar >= '0' && drvChar <= '9') { + drvLetter = &drvDigits[drvChar - '0']; + letterMask = ((ULONGLONG) 1) << (drvChar - '0' + 32); + } else if (drvChar >= 'A' && drvChar <= 'Z') { + drvLetter = &drvLetters[drvChar - 'A']; + letterMask = ((ULONGLONG) 1) << (drvChar - 'A'); + } else { + drvLetter = NULL; letterMask = 0; + } + + rc = drvLetter ? TRUE : FALSE; + } + + if (rc) { + + m_bUpdated = TRUE; + if (m_Part) { + m_Part->DrvLetters |= letterMask; + if (m_Part->Volume) { + m_Part->Volume->DrvLetters |= letterMask; + } + InitializeList(m_Part->DrvLetters); + } + if (m_Volume) { + m_Volume->DrvLetters |= letterMask; + InitializeList(m_Volume->DrvLetters); + } + if (m_Cdrom) { + m_Cdrom->DrvLetters |= letterMask; + InitializeList(m_Cdrom->DrvLetters); + } + + /* + ((CExt2MgrDlg *)m_MainDlg)->DriverLetterChangeNotify(drvLetter->Letter, TRUE); + */ + + m_MainDlg->SendMessage( + WM_MOUNTPOINT_NOTIFY, + 'DA', (LPARAM)drvLetter->Letter); + } + + return TRUE; +} + +void CMountPoints::OnAddMountpoint() +{ + CSelectDrvLetter drvSel; + STORAGE_BUS_TYPE busType = BusTypeAta; + + if (m_Part) { + busType = m_Part->Disk->SDD.BusType; + } + + if (m_Volume && m_Volume->Part) { + busType = m_Volume->Part->Disk->SDD.BusType; + } + +#if TRUE + drvSel.m_bDosDev = TRUE; + drvSel.m_bMountMgr = FALSE; + drvSel.m_bRegistry = FALSE; +#else + if (m_Cdrom || + busType == BusType1394 || + busType == BusTypeUsb ) { + + drvSel.m_bMountMgr = TRUE; + drvSel.m_bRegistry = FALSE; + drvSel.m_bDosDev = FALSE; + } +#endif + + if (drvSel.DoModal() != IDOK) { + return; + } + + AddMountPoint(drvSel.m_DrvLetter.GetAt(0), + drvSel.m_bRegistry, + drvSel.m_bMountMgr + ); + + OnOK(); +} + +void CMountPoints::OnChangeMountpoint() +{ + CHAR odrvChar = 0; + CHAR ndrvChar = 0; + + CSelectDrvLetter drvSel; + STORAGE_BUS_TYPE busType = BusTypeAta; + + if (m_Part) { + busType = m_Part->Disk->SDD.BusType; + } + + if (m_Volume && m_Volume->Part) { + busType = m_Volume->Part->Disk->SDD.BusType; + } + +#if TRUE + + drvSel.m_bMountMgr = FALSE; + drvSel.m_bRegistry = FALSE; + drvSel.m_bDosDev = TRUE; + +#else + if (m_Cdrom || + busType == BusType1394 || + busType == BusTypeUsb ) { + + drvSel.m_bMountMgr = TRUE; + drvSel.m_bRegistry = FALSE; + drvSel.m_bDosDev = FALSE; + } +#endif + + if (drvSel.DoModal() != IDOK) { + return; + } + + ndrvChar = drvSel.m_DrvLetter.GetAt(0); + odrvChar = m_Letter.GetAt(0); + + if (RemoveMountPoint(odrvChar)) { + AddMountPoint( + ndrvChar, + drvSel.m_bRegistry, + drvSel.m_bMountMgr + ); + } + + OnOK(); +} + +BOOL +CMountPoints::RemoveMountPoint(CHAR drvChar) +{ + PEXT2_LETTER drvLetter = NULL; + ULONGLONG letterMask = 0; + + if (drvChar >= '0' && drvChar <= '9') { + drvLetter = &drvDigits[drvChar - '0']; + letterMask = ((ULONGLONG) 1) << (drvChar - '0' + 32); + } else if (drvChar >= 'A' && drvChar <= 'Z') { + drvLetter = &drvLetters[drvChar - 'A']; + letterMask = ((ULONGLONG) 1) << (drvChar - 'A'); + } + + if (!drvLetter) { + return FALSE; + } + + Ext2SetRegistryMountPoint(&drvChar, NULL, FALSE); + if (Ext2RemoveDrvLetter(drvLetter)) { + + m_MainDlg->SendMessage(WM_MOUNTPOINT_NOTIFY, + 'DR', (LPARAM)drvLetter->Letter); + + } else { + + CString str; + str.Format("Failed to remove drive letter %c:\n", drvChar); + AfxMessageBox(str, MB_OK|MB_ICONWARNING); + return FALSE; + } + + if (m_Part) { + m_Part->DrvLetters &= (~letterMask); + if (m_Part->Volume) { + m_Part->Volume->DrvLetters &= ~letterMask; + } + InitializeList(m_Part->DrvLetters); + } + + if (m_Volume) { + PEXT2_PARTITION part = Ext2QueryVolumePartition(m_Volume); + m_Volume->DrvLetters &= ~letterMask; + if (part) { + part->DrvLetters &= ~letterMask; + } + InitializeList(m_Volume->DrvLetters); + } + + if (m_Cdrom) { + m_Cdrom->DrvLetters &= ~letterMask; + InitializeList(m_Cdrom->DrvLetters); + } + + return TRUE; +} + +void CMountPoints::OnRemoveMountpoint() +{ + CHAR drvChar = m_Letter.GetAt(0); + + if (RemoveMountPoint(drvChar)) { + SET_WIN(ID_CHANGE_MOUNTPOINT, FALSE); + SET_WIN(ID_REMOVE_MOUNTPOINT, FALSE); + if (m_drvList.GetItemCount() == 0) + OnOK(); + } +} + +void CMountPoints::OnOK() +{ + // TODO: Add extra validation here + + CDialog::OnOK(); +} + +void CMountPoints::OnCancel() +{ + CDialog::OnCancel(); +} + + +void CMountPoints::InitializeList(ULONGLONG letters) +{ + CHAR drvName[] = "C:\0"; + int i = 0; + ULONGLONG drive = 0; + + m_drvList.DeleteAllItems(); + + for (i=0; i < 10; i++) { + drive = ((ULONGLONG) 1) << (i + 32); + if (letters & drive) { + drvName[0] = '0' + i; + m_drvList.InsertItem( + m_drvList.GetItemCount(), + drvName); + } + } + + for (i=2; i < 26; i++) { + drive = ((ULONGLONG) 1) << (i); + if (letters & drive) { + drvName[0] = 'A' + i; + m_drvList.InsertItem( + m_drvList.GetItemCount(), + drvName); + } + } +} + +BOOL CMountPoints::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // TODO: Add extra initialization here + ASSERT(m_Volume || m_Part); + + if (m_Part) { + InitializeList(m_Part->DrvLetters); + } else if (m_Volume) { + InitializeList(m_Volume->DrvLetters); + } else { + InitializeList(m_Cdrom->DrvLetters); + } + + m_drvList.SetSelectionMark(0); + m_drvList.SetFocus(); + m_Letter = m_drvList.GetItemText(0, 0); + + if (m_Letter.IsEmpty()) { + SET_WIN(ID_CHANGE_MOUNTPOINT, FALSE); + SET_WIN(ID_REMOVE_MOUNTPOINT, FALSE); + } else { + SET_WIN(ID_CHANGE_MOUNTPOINT, TRUE); + SET_WIN(ID_REMOVE_MOUNTPOINT, TRUE); + } + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +BOOL CMountPoints::PreTranslateMessage(MSG* pMsg) +{ + // TODO: Add your specialized code here and/or call the base class + +#if 0 + if (pMsg->message==WM_KEYDOWN) { + if (pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE) { + pMsg->wParam = NULL; + } + } +#endif + + return CDialog::PreTranslateMessage(pMsg); +} diff --git a/Ext2Mgr/MountPoints.h b/Ext2Mgr/MountPoints.h index a3ebda0..55fe42a 100644 --- a/Ext2Mgr/MountPoints.h +++ b/Ext2Mgr/MountPoints.h @@ -1,75 +1,75 @@ -#if !defined(AFX_MOUNTPOINTS_H__83141F47_96A4_4335_B42C_F2F7EB6F0ADD__INCLUDED_) -#define AFX_MOUNTPOINTS_H__83141F47_96A4_4335_B42C_F2F7EB6F0ADD__INCLUDED_ - -#include "SelectDrvLetter.h" - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// MountPoints.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// CMountPoints dialog - -class CMountPoints : public CDialog -{ -// Construction -public: - CMountPoints(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CMountPoints) - enum { IDD = IDD_CHANGE_MOUNTPINT }; - CListCtrl m_drvList; - //}}AFX_DATA - - void InitializeList(ULONGLONG letters); - -// Attributes -public: - - PEXT2_CDROM m_Cdrom; - PEXT2_VOLUME m_Volume; - PEXT2_PARTITION m_Part; - CString m_Letter; - BOOL m_bUpdated; - BOOL m_bMgrNoted; - - CWnd * m_MainDlg; - -BOOL -RemoveMountPoint(CHAR drvChar); - -BOOL -AddMountPoint(CHAR drvChar, BOOL bRegistry, BOOL bMountMgr); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CMountPoints) - public: - virtual BOOL PreTranslateMessage(MSG* pMsg); - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CMountPoints) - afx_msg void OnClickDrvLetterList(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnAddMountpoint(); - afx_msg void OnChangeMountpoint(); - afx_msg void OnRemoveMountpoint(); - virtual void OnOK(); - virtual void OnCancel(); - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_MOUNTPOINTS_H__83141F47_96A4_4335_B42C_F2F7EB6F0ADD__INCLUDED_) +#if !defined(AFX_MOUNTPOINTS_H__83141F47_96A4_4335_B42C_F2F7EB6F0ADD__INCLUDED_) +#define AFX_MOUNTPOINTS_H__83141F47_96A4_4335_B42C_F2F7EB6F0ADD__INCLUDED_ + +#include "SelectDrvLetter.h" + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// MountPoints.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CMountPoints dialog + +class CMountPoints : public CDialog +{ +// Construction +public: + CMountPoints(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CMountPoints) + enum { IDD = IDD_CHANGE_MOUNTPINT }; + CListCtrl m_drvList; + //}}AFX_DATA + + void InitializeList(ULONGLONG letters); + +// Attributes +public: + + PEXT2_CDROM m_Cdrom; + PEXT2_VOLUME m_Volume; + PEXT2_PARTITION m_Part; + CString m_Letter; + BOOL m_bUpdated; + BOOL m_bMgrNoted; + + CWnd * m_MainDlg; + +BOOL +RemoveMountPoint(CHAR drvChar); + +BOOL +AddMountPoint(CHAR drvChar, BOOL bRegistry, BOOL bMountMgr); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CMountPoints) + public: + virtual BOOL PreTranslateMessage(MSG* pMsg); + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CMountPoints) + afx_msg void OnClickDrvLetterList(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnAddMountpoint(); + afx_msg void OnChangeMountpoint(); + afx_msg void OnRemoveMountpoint(); + virtual void OnOK(); + virtual void OnCancel(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_MOUNTPOINTS_H__83141F47_96A4_4335_B42C_F2F7EB6F0ADD__INCLUDED_) diff --git a/Ext2Mgr/PartBox.cpp b/Ext2Mgr/PartBox.cpp index 6a6dc7f..3254d13 100644 --- a/Ext2Mgr/PartBox.cpp +++ b/Ext2Mgr/PartBox.cpp @@ -1,131 +1,131 @@ -// PartBox.cpp : implementation file -// - -#include "stdafx.h" -#include "PartBox.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CPartBox - -CPartBox::CPartBox() -{ - m_nID = IDC_PROPERTY_SDEV; - m_nLeft = 10; - m_nSize = 80; -} - -CPartBox::~CPartBox() -{ -} - -BEGIN_MESSAGE_MAP(CPartBox, CButton) - //{{AFX_MSG_MAP(CPartBox) - ON_WM_SETFOCUS() - ON_CBN_SELCHANGE(IDC_PROPERTY_SDEV, OnSelectChanged) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CPartBox message handlers - -void CPartBox::OnSelectChanged() -{ - GetParent()->SendMessage(WM_GROUP_BOX_UPDATED, 'GB', 'PVLU'); -} - -void CPartBox::PreSubclassWindow() -{ - // - // Make sure that this control has the BS_ICON style set. - // If not, it behaves very strangely: - // It erases itself if the user TABs to controls in the dialog, - // unless the user first clicks it. Very strange!! - // - - ModifyStyle(0, BS_ICON|WS_TABSTOP|WS_GROUP); - - CString strTitle; - GetWindowText(strTitle); - - int nWidth = AssemblingTitle(); - - CRect r; - GetWindowRect(&r); - ScreenToClient(r); - - r.OffsetRect(m_nLeft, 0); - r.bottom = r.top + m_nSize; - r.right = r.left + m_nSize + nWidth; - - m_ComboBox.Create(WS_CHILD | CBS_DROPDOWN | WS_VSCROLL | - CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST, - r, this, m_nID); - m_ComboBox.SetFont(GetFont(), true); - m_ComboBox.ShowWindow(SW_SHOW); - - SetListboxHeight(m_ComboBox.m_hWnd); -} - -int CPartBox::AssemblingTitle() -{ - // - // The group box title needs to be erased, but I need to keep - // the border away from the check box text. I create a string - // of spaces (' ') that is the same length as the title was - // plus the size of the checkbox. plus a little more. - // - - CString strOldTitle, strNewTitle; - GetWindowText(strOldTitle); - - CClientDC dc(this); - CFont* pOldFont = dc.SelectObject(GetFont()); - - CSize czText = dc.GetTextExtent(strOldTitle); - int nRet = czText.cx; - int nTarget = czText.cx + m_nSize; - - while(czText.cx < nTarget) - { - strNewTitle.Insert(0, ' '); - czText = dc.GetTextExtent(strNewTitle); - } - - dc.SelectObject(pOldFont); - - SetWindowText(strNewTitle); - return nRet; -} - -void CPartBox::OnSetFocus(CWnd* pOldWnd) -{ - CButton::OnSetFocus(pOldWnd); - m_ComboBox.SetFocus(); -} - - -void CPartBox::SetListboxHeight(HWND hWnd) -{ - RECT rc; - - ::SendMessage(hWnd, LB_GETITEMRECT, 0, (LPARAM)&rc); - ::GetClientRect(hWnd, &rc); - int cyClient= rc.bottom - rc.top; - - ::GetWindowRect(hWnd, &rc); - int cxListbox = rc.right - rc.left; - int cyListbox = rc.bottom - rc.top; - - cyListbox = 120; - ::SetWindowPos(hWnd, NULL, 0, 0, - cxListbox, cyListbox, - SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCOPYBITS| - SWP_NOOWNERZORDER|SWP_NOZORDER - ); -} +// PartBox.cpp : implementation file +// + +#include "stdafx.h" +#include "PartBox.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CPartBox + +CPartBox::CPartBox() +{ + m_nID = IDC_PROPERTY_SDEV; + m_nLeft = 10; + m_nSize = 80; +} + +CPartBox::~CPartBox() +{ +} + +BEGIN_MESSAGE_MAP(CPartBox, CButton) + //{{AFX_MSG_MAP(CPartBox) + ON_WM_SETFOCUS() + ON_CBN_SELCHANGE(IDC_PROPERTY_SDEV, OnSelectChanged) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CPartBox message handlers + +void CPartBox::OnSelectChanged() +{ + GetParent()->SendMessage(WM_GROUP_BOX_UPDATED, 'GB', 'PVLU'); +} + +void CPartBox::PreSubclassWindow() +{ + // + // Make sure that this control has the BS_ICON style set. + // If not, it behaves very strangely: + // It erases itself if the user TABs to controls in the dialog, + // unless the user first clicks it. Very strange!! + // + + ModifyStyle(0, BS_ICON|WS_TABSTOP|WS_GROUP); + + CString strTitle; + GetWindowText(strTitle); + + int nWidth = AssemblingTitle(); + + CRect r; + GetWindowRect(&r); + ScreenToClient(r); + + r.OffsetRect(m_nLeft, 0); + r.bottom = r.top + m_nSize; + r.right = r.left + m_nSize + nWidth; + + m_ComboBox.Create(WS_CHILD | CBS_DROPDOWN | WS_VSCROLL | + CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST, + r, this, m_nID); + m_ComboBox.SetFont(GetFont(), true); + m_ComboBox.ShowWindow(SW_SHOW); + + SetListboxHeight(m_ComboBox.m_hWnd); +} + +int CPartBox::AssemblingTitle() +{ + // + // The group box title needs to be erased, but I need to keep + // the border away from the check box text. I create a string + // of spaces (' ') that is the same length as the title was + // plus the size of the checkbox. plus a little more. + // + + CString strOldTitle, strNewTitle; + GetWindowText(strOldTitle); + + CClientDC dc(this); + CFont* pOldFont = dc.SelectObject(GetFont()); + + CSize czText = dc.GetTextExtent(strOldTitle); + int nRet = czText.cx; + int nTarget = czText.cx + m_nSize; + + while(czText.cx < nTarget) + { + strNewTitle.Insert(0, ' '); + czText = dc.GetTextExtent(strNewTitle); + } + + dc.SelectObject(pOldFont); + + SetWindowText(strNewTitle); + return nRet; +} + +void CPartBox::OnSetFocus(CWnd* pOldWnd) +{ + CButton::OnSetFocus(pOldWnd); + m_ComboBox.SetFocus(); +} + + +void CPartBox::SetListboxHeight(HWND hWnd) +{ + RECT rc; + + ::SendMessage(hWnd, LB_GETITEMRECT, 0, (LPARAM)&rc); + ::GetClientRect(hWnd, &rc); + int cyClient= rc.bottom - rc.top; + + ::GetWindowRect(hWnd, &rc); + int cxListbox = rc.right - rc.left; + int cyListbox = rc.bottom - rc.top; + + cyListbox = 120; + ::SetWindowPos(hWnd, NULL, 0, 0, + cxListbox, cyListbox, + SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCOPYBITS| + SWP_NOOWNERZORDER|SWP_NOZORDER + ); +} diff --git a/Ext2Mgr/PartBox.h b/Ext2Mgr/PartBox.h index 363746e..61036c2 100644 --- a/Ext2Mgr/PartBox.h +++ b/Ext2Mgr/PartBox.h @@ -1,61 +1,61 @@ -#if !defined(AFX_PART_BOX_H_) -#define AFX_PART_BOX_H_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// PartBox.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// CPartBox window - -class CPartBox : public CButton -{ -// Construction -public: - CPartBox(); - -// Operations -public: - - void SetListboxHeight(HWND hWnd); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CPartBox) - protected: - virtual void PreSubclassWindow(); - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~CPartBox(); - - // Generated message map functions -protected: - //{{AFX_MSG(CPartBox) - afx_msg void OnSetFocus(CWnd* pOldWnd); - afx_msg void OnSelectChanged(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -public: - - int m_nID; - int m_nLeft; - int m_nSize; - - CComboBox m_ComboBox; - -private: - - int AssemblingTitle(); -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif +#if !defined(AFX_PART_BOX_H_) +#define AFX_PART_BOX_H_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// PartBox.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CPartBox window + +class CPartBox : public CButton +{ +// Construction +public: + CPartBox(); + +// Operations +public: + + void SetListboxHeight(HWND hWnd); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CPartBox) + protected: + virtual void PreSubclassWindow(); + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CPartBox(); + + // Generated message map functions +protected: + //{{AFX_MSG(CPartBox) + afx_msg void OnSetFocus(CWnd* pOldWnd); + afx_msg void OnSelectChanged(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + +public: + + int m_nID; + int m_nLeft; + int m_nSize; + + CComboBox m_ComboBox; + +private: + + int AssemblingTitle(); +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif diff --git a/Ext2Mgr/PartitionType.cpp b/Ext2Mgr/PartitionType.cpp index 3f1f095..64be3ef 100644 --- a/Ext2Mgr/PartitionType.cpp +++ b/Ext2Mgr/PartitionType.cpp @@ -1,93 +1,93 @@ -// PartitionType.cpp : implementation file -// - -#include "stdafx.h" -#include "ext2mgr.h" -#include "PartitionType.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CPartitionType dialog - - -CPartitionType::CPartitionType(CWnd* pParent /*=NULL*/) - : CDialog(CPartitionType::IDD, pParent) -{ - //{{AFX_DATA_INIT(CPartitionType) - // NOTE: the ClassWizard will add member initialization here - m_Part = NULL; - m_cPartType = 0; - m_sDevice = _T(""); - m_sPartType = _T(""); - //}}AFX_DATA_INIT -} - - -void CPartitionType::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CPartitionType) - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CPartitionType, CDialog) - //{{AFX_MSG_MAP(CPartitionType) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CPartitionType message handlers - -void CPartitionType::OnOK() -{ - CString str; - CComboBox *cbList = (CComboBox *)GetDlgItem(IDC_PARTTION_TYPE_LIST); - m_cPartType = (UCHAR) cbList->GetCurSel(); - if (m_cPartType != m_Part->Entry->Mbr.PartitionType) { - if (Ext2SetPartitionType(m_Part, m_cPartType)) { - str.Format("Succeed to set partition type to %2.2X: %s", - m_cPartType, PartitionString(m_cPartType)); - AfxMessageBox(str, MB_OK | MB_ICONINFORMATION); - } else { - AfxMessageBox("Failed to set the partition type!", - MB_OK | MB_ICONWARNING); - m_cPartType = 0; - return; - } - } else { - AfxMessageBox("Same partition type to the previous. Nothing is changed !", - MB_OK | MB_ICONWARNING); - } - - CDialog::OnOK(); -} - -BOOL CPartitionType::OnInitDialog() -{ - CString str, type; - CDialog::OnInitDialog(); - - SET_TEXT(IDC_PARTITION_NAME, m_sDevice); - - CComboBox *cbList = (CComboBox *)GetDlgItem(IDC_PARTTION_TYPE_LIST); - for (unsigned int i=0; i < 0x100; i++) { - type = PartitionString(i); - str.Format("%2.2X ", i); - if (type.CompareNoCase("UNKNOWN")) { - str += type; - } - cbList->AddString(str); - } - - m_cPartType = m_Part->Entry->Mbr.PartitionType; - cbList->SetCurSel((int) m_cPartType); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} +// PartitionType.cpp : implementation file +// + +#include "stdafx.h" +#include "ext2mgr.h" +#include "PartitionType.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CPartitionType dialog + + +CPartitionType::CPartitionType(CWnd* pParent /*=NULL*/) + : CDialog(CPartitionType::IDD, pParent) +{ + //{{AFX_DATA_INIT(CPartitionType) + // NOTE: the ClassWizard will add member initialization here + m_Part = NULL; + m_cPartType = 0; + m_sDevice = _T(""); + m_sPartType = _T(""); + //}}AFX_DATA_INIT +} + + +void CPartitionType::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CPartitionType) + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CPartitionType, CDialog) + //{{AFX_MSG_MAP(CPartitionType) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CPartitionType message handlers + +void CPartitionType::OnOK() +{ + CString str; + CComboBox *cbList = (CComboBox *)GetDlgItem(IDC_PARTTION_TYPE_LIST); + m_cPartType = (UCHAR) cbList->GetCurSel(); + if (m_cPartType != m_Part->Entry->Mbr.PartitionType) { + if (Ext2SetPartitionType(m_Part, m_cPartType)) { + str.Format("Succeed to set partition type to %2.2X: %s", + m_cPartType, PartitionString(m_cPartType)); + AfxMessageBox(str, MB_OK | MB_ICONINFORMATION); + } else { + AfxMessageBox("Failed to set the partition type!", + MB_OK | MB_ICONWARNING); + m_cPartType = 0; + return; + } + } else { + AfxMessageBox("Same partition type to the previous. Nothing is changed !", + MB_OK | MB_ICONWARNING); + } + + CDialog::OnOK(); +} + +BOOL CPartitionType::OnInitDialog() +{ + CString str, type; + CDialog::OnInitDialog(); + + SET_TEXT(IDC_PARTITION_NAME, m_sDevice); + + CComboBox *cbList = (CComboBox *)GetDlgItem(IDC_PARTTION_TYPE_LIST); + for (unsigned int i=0; i < 0x100; i++) { + type = PartitionString(i); + str.Format("%2.2X ", i); + if (type.CompareNoCase("UNKNOWN")) { + str += type; + } + cbList->AddString(str); + } + + m_cPartType = m_Part->Entry->Mbr.PartitionType; + cbList->SetCurSel((int) m_cPartType); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} diff --git a/Ext2Mgr/PartitionType.h b/Ext2Mgr/PartitionType.h index f1818a0..84de275 100644 --- a/Ext2Mgr/PartitionType.h +++ b/Ext2Mgr/PartitionType.h @@ -1,57 +1,57 @@ -#if !defined(AFX_PARTITIONTYPE_H__7BBDDABB_64CE_4448_92DA_D57973E423A5__INCLUDED_) -#define AFX_PARTITIONTYPE_H__7BBDDABB_64CE_4448_92DA_D57973E423A5__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// PartitionType.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// CPartitionType dialog - -class CPartitionType : public CDialog -{ -// Construction -public: - CPartitionType(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CPartitionType) - enum { IDD = IDD_PARTITION_TYPE }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CPartitionType) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -protected: - - CString m_sPartType; - -public: - - PEXT2_PARTITION m_Part; - UCHAR m_cPartType; - CString m_sDevice; - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CPartitionType) - virtual void OnOK(); - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_PARTITIONTYPE_H__7BBDDABB_64CE_4448_92DA_D57973E423A5__INCLUDED_) +#if !defined(AFX_PARTITIONTYPE_H__7BBDDABB_64CE_4448_92DA_D57973E423A5__INCLUDED_) +#define AFX_PARTITIONTYPE_H__7BBDDABB_64CE_4448_92DA_D57973E423A5__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// PartitionType.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CPartitionType dialog + +class CPartitionType : public CDialog +{ +// Construction +public: + CPartitionType(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CPartitionType) + enum { IDD = IDD_PARTITION_TYPE }; + // NOTE: the ClassWizard will add data members here + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CPartitionType) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +protected: + + CString m_sPartType; + +public: + + PEXT2_PARTITION m_Part; + UCHAR m_cPartType; + CString m_sDevice; + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CPartitionType) + virtual void OnOK(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_PARTITIONTYPE_H__7BBDDABB_64CE_4448_92DA_D57973E423A5__INCLUDED_) diff --git a/Ext2Mgr/PerfStatDlg.cpp b/Ext2Mgr/PerfStatDlg.cpp index 3502c23..19935dc 100644 --- a/Ext2Mgr/PerfStatDlg.cpp +++ b/Ext2Mgr/PerfStatDlg.cpp @@ -1,267 +1,267 @@ -// PerfStatDlg.cpp : implementation file -// - -#include "stdafx.h" -#include "ext2mgr.h" -#include "PerfStatDlg.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CPerfStatDlg dialog - - -CPerfStatDlg::CPerfStatDlg(CWnd* pParent /*=NULL*/) - : CDialog(CPerfStatDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(CPerfStatDlg) - m_Interval = 30; - m_Handle = 0; - //}}AFX_DATA_INIT - m_IrpList = NULL; - m_MemList = NULL; -} - -void CPerfStatDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CPerfStatDlg) - DDX_Text(pDX, IDC_PERFSTAT_INTERVAL, m_Interval); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CPerfStatDlg, CDialog) - //{{AFX_MSG_MAP(CPerfStatDlg) - ON_WM_TIMER() - ON_WM_DESTROY() - ON_COMMAND(ID_QUERYPERF, OnQueryPerf) - ON_EN_CHANGE(IDC_PERFSTAT_INTERVAL, OnChangePerfstatInterval) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CPerfStatDlg message handlers - -BOOL CPerfStatDlg::OnInitDialog() -{ - LONG_PTR dwStyle = 0; - int i; - CString s; - - CDialog::OnInitDialog(); - - - m_IrpList = (CListCtrl *)GetDlgItem(IDC_IRP_LIST); - m_MemList = (CListCtrl *)GetDlgItem(IDC_MEMORY_LIST);; - - if (m_IrpList == NULL || m_MemList == NULL) { - return FALSE; - } - - /* initialize the memory list */ - dwStyle=GetWindowLongPtr(m_MemList->GetSafeHwnd(), GWL_STYLE); - dwStyle&=~LVS_TYPEMASK; - dwStyle|= (LVS_REPORT | LVS_AUTOARRANGE); - SetWindowLongPtr(m_MemList->GetSafeHwnd(),GWL_STYLE,dwStyle); - m_MemList->SetExtendedStyle(LVS_EX_GRIDLINES); - ListView_SetExtendedListViewStyleEx ( - m_MemList->GetSafeHwnd(), - LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT ); - - m_MemList->DeleteAllItems(); - - s.LoadString(IDS_PERFSTAT_NAME); - m_MemList->InsertColumn(0, (LPCSTR)s, LVCFMT_RIGHT, 100); - - s.LoadString(IDS_PERFSTAT_UNIT); - m_MemList->InsertColumn(1, (LPCSTR)s, LVCFMT_RIGHT, 40); - - s.LoadString(IDS_PERFSTAT_CURRENT); - m_MemList->InsertColumn(2, (LPCSTR)s, LVCFMT_RIGHT, 56); - - s.LoadString(IDS_PERFSTAT_SIZE); - m_MemList->InsertColumn(3, (LPCSTR)s, LVCFMT_RIGHT, 80); - - s.LoadString(IDS_PERFSTAT_TOTAL); - m_MemList->InsertColumn(4, (LPCSTR)s, LVCFMT_RIGHT, 120); - for (i = 0; PerfStatStrings[i] != NULL ; i++) { - m_MemList->InsertItem(i, PerfStatStrings[i]); - } - - /* initialize the irp list */ - dwStyle=GetWindowLongPtr(m_IrpList->GetSafeHwnd(), GWL_STYLE); - dwStyle&=~LVS_TYPEMASK; - dwStyle|= (LVS_REPORT | LVS_AUTOARRANGE); - SetWindowLongPtr(m_IrpList->GetSafeHwnd(),GWL_STYLE,dwStyle); - m_IrpList->SetExtendedStyle(LVS_EX_GRIDLINES); - ListView_SetExtendedListViewStyleEx ( - m_IrpList->GetSafeHwnd(), - LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT ); - - m_IrpList->DeleteAllItems(); - - s.LoadString(IDS_PERFSTAT_NAME); - m_IrpList->InsertColumn(0, (LPCSTR)s, LVCFMT_RIGHT, 180); - - s.LoadString(IDS_PERFSTAT_PROCESSING); - m_IrpList->InsertColumn(1, (LPCSTR)s, LVCFMT_RIGHT, 110); - - s.LoadString(IDS_PERFSTAT_PROCESSED); - m_IrpList->InsertColumn(2, (LPCSTR)s, LVCFMT_RIGHT, 100); - for (i=0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++) { - m_IrpList->InsertItem(i, IrpMjStrings[i]); - } - - RefreshPerfStat(); - - SetTimer('STAT', m_Interval * 1000, NULL); - UpdateData(FALSE); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void CPerfStatDlg::RefreshPerfStat() -{ - int i; - CString s; - - PEXT2_PERF_STATISTICS_V1 PerfV1 = NULL; - PEXT2_PERF_STATISTICS_V2 PerfV2 = NULL; - - NT::NTSTATUS status; - - if (m_Handle == 0) { - status = Ext2Open("\\DosDevices\\Ext2Fsd", &m_Handle, - EXT2_DESIRED_ACCESS ); - if (!NT_SUCCESS(status)) { - goto errorout; - } - } - - if (Ext2QueryPerfStat(m_Handle, &m_PerfStat, &PerfV1, &PerfV2)) { - - if (PerfV2) { - - if (m_MemList) { - for (i = 0; i < PS_MAX_TYPE_V2; i++) { - if (PerfV2->Unit.Slot[i] == 0) - break; - else if (PerfV2->Unit.Slot[i] == 1) - s = "*"; - else - s.Format("%u", PerfV2->Unit.Slot[i]); - m_MemList->SetItem(i, 1, LVIF_TEXT, (LPCSTR)s, 0, 0, 0, 0); - - s.Format("%u", PerfV2->Current.Slot[i]); - m_MemList->SetItem(i, 2, LVIF_TEXT, (LPCSTR)s, 0, 0, 0, 0); - - s.Format("%u", PerfV2->Size.Slot[i]); - m_MemList->SetItem(i, 3, LVIF_TEXT, (LPCSTR)s, 0, 0, 0, 0); - - s.Format("%u", PerfV2->Total.Slot[i]); - m_MemList->SetItem(i, 4, LVIF_TEXT, (LPCSTR)s, 0, 0, 0, 0); - } - } - - if (m_IrpList) { - for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++) { - s.Format("%u", PerfV2->Irps[i].Current); - m_IrpList->SetItem(i, 1, LVIF_TEXT, (LPCSTR)s, 0, 0, 0, 0); - s.Format("%u", PerfV2->Irps[i].Processed); - m_IrpList->SetItem(i, 2, LVIF_TEXT, (LPCSTR)s, 0, 0, 0, 0); - } - } - - } else if (PerfV1) { - - if (m_MemList) { - for (i = 0; i < PS_MAX_TYPE_V1; i++) { - - if (PerfV1->Unit.Slot[i] == 0) - s = "*"; - else - s.Format("%u", PerfV1->Unit.Slot[i]); - m_MemList->SetItem(i, 1, LVIF_TEXT, (LPCSTR)s, 0, 0, 0, 0); - - s.Format("%u", PerfV1->Current.Slot[i]); - m_MemList->SetItem(i, 2, LVIF_TEXT, (LPCSTR)s, 0, 0, 0, 0); - - s.Format("%u", PerfV1->Size.Slot[i]); - m_MemList->SetItem(i, 3, LVIF_TEXT, (LPCSTR)s, 0, 0, 0, 0); - - s.Format("%u", PerfV1->Total.Slot[i]); - m_MemList->SetItem(i, 4, LVIF_TEXT, (LPCSTR)s, 0, 0, 0, 0); - } - } - - if (m_IrpList) { - for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++) { - s.Format("%u", PerfV1->Irps[i].Current); - m_IrpList->SetItem(i, 1, LVIF_TEXT, (LPCSTR)s, 0, 0, 0, 0); - s.Format("%u", PerfV1->Irps[i].Processed); - m_IrpList->SetItem(i, 2, LVIF_TEXT, (LPCSTR)s, 0, 0, 0, 0); - } - } - } - - } else { - Ext2Close(&m_Handle); - } - -errorout: - - return; -} - -void CPerfStatDlg::OnTimer(UINT_PTR nIDEvent) -{ - RefreshPerfStat(); - - CDialog::OnTimer(nIDEvent); -} - -void CPerfStatDlg::OnDestroy() -{ - KillTimer('STAT'); - Ext2Close(&m_Handle); - CDialog::OnDestroy(); -} - -void CPerfStatDlg::OnChangePerfstatInterval() -{ - UpdateData(TRUE); - - if (m_Interval == 0) { - m_Interval = 1; - } - SetTimer('STAT', m_Interval * 1000, NULL); -} - -void CPerfStatDlg::OnOK() -{ - // TODO: Add extra validation here - KillTimer('STAT'); - Ext2Close(&m_Handle); - GetParent()->PostMessage(WM_COMMAND, ID_PERFSTOP, 0); - CDialog::OnOK(); -} - -void CPerfStatDlg::OnCancel() -{ - // TODO: Add extra validation here - KillTimer('STAT'); - Ext2Close(&m_Handle); - GetParent()->PostMessage(WM_COMMAND, ID_PERFSTOP, 0); - CDialog::OnCancel(); -} - -void CPerfStatDlg::OnQueryPerf() -{ - RefreshPerfStat(); -} +// PerfStatDlg.cpp : implementation file +// + +#include "stdafx.h" +#include "ext2mgr.h" +#include "PerfStatDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CPerfStatDlg dialog + + +CPerfStatDlg::CPerfStatDlg(CWnd* pParent /*=NULL*/) + : CDialog(CPerfStatDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(CPerfStatDlg) + m_Interval = 30; + m_Handle = 0; + //}}AFX_DATA_INIT + m_IrpList = NULL; + m_MemList = NULL; +} + +void CPerfStatDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CPerfStatDlg) + DDX_Text(pDX, IDC_PERFSTAT_INTERVAL, m_Interval); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CPerfStatDlg, CDialog) + //{{AFX_MSG_MAP(CPerfStatDlg) + ON_WM_TIMER() + ON_WM_DESTROY() + ON_COMMAND(ID_QUERYPERF, OnQueryPerf) + ON_EN_CHANGE(IDC_PERFSTAT_INTERVAL, OnChangePerfstatInterval) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CPerfStatDlg message handlers + +BOOL CPerfStatDlg::OnInitDialog() +{ + LONG_PTR dwStyle = 0; + int i; + CString s; + + CDialog::OnInitDialog(); + + + m_IrpList = (CListCtrl *)GetDlgItem(IDC_IRP_LIST); + m_MemList = (CListCtrl *)GetDlgItem(IDC_MEMORY_LIST);; + + if (m_IrpList == NULL || m_MemList == NULL) { + return FALSE; + } + + /* initialize the memory list */ + dwStyle=GetWindowLongPtr(m_MemList->GetSafeHwnd(), GWL_STYLE); + dwStyle&=~LVS_TYPEMASK; + dwStyle|= (LVS_REPORT | LVS_AUTOARRANGE); + SetWindowLongPtr(m_MemList->GetSafeHwnd(),GWL_STYLE,dwStyle); + m_MemList->SetExtendedStyle(LVS_EX_GRIDLINES); + ListView_SetExtendedListViewStyleEx ( + m_MemList->GetSafeHwnd(), + LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT ); + + m_MemList->DeleteAllItems(); + + s.LoadString(IDS_PERFSTAT_NAME); + m_MemList->InsertColumn(0, (LPCSTR)s, LVCFMT_RIGHT, 100); + + s.LoadString(IDS_PERFSTAT_UNIT); + m_MemList->InsertColumn(1, (LPCSTR)s, LVCFMT_RIGHT, 40); + + s.LoadString(IDS_PERFSTAT_CURRENT); + m_MemList->InsertColumn(2, (LPCSTR)s, LVCFMT_RIGHT, 56); + + s.LoadString(IDS_PERFSTAT_SIZE); + m_MemList->InsertColumn(3, (LPCSTR)s, LVCFMT_RIGHT, 80); + + s.LoadString(IDS_PERFSTAT_TOTAL); + m_MemList->InsertColumn(4, (LPCSTR)s, LVCFMT_RIGHT, 120); + for (i = 0; PerfStatStrings[i] != NULL ; i++) { + m_MemList->InsertItem(i, PerfStatStrings[i]); + } + + /* initialize the irp list */ + dwStyle=GetWindowLongPtr(m_IrpList->GetSafeHwnd(), GWL_STYLE); + dwStyle&=~LVS_TYPEMASK; + dwStyle|= (LVS_REPORT | LVS_AUTOARRANGE); + SetWindowLongPtr(m_IrpList->GetSafeHwnd(),GWL_STYLE,dwStyle); + m_IrpList->SetExtendedStyle(LVS_EX_GRIDLINES); + ListView_SetExtendedListViewStyleEx ( + m_IrpList->GetSafeHwnd(), + LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT ); + + m_IrpList->DeleteAllItems(); + + s.LoadString(IDS_PERFSTAT_NAME); + m_IrpList->InsertColumn(0, (LPCSTR)s, LVCFMT_RIGHT, 180); + + s.LoadString(IDS_PERFSTAT_PROCESSING); + m_IrpList->InsertColumn(1, (LPCSTR)s, LVCFMT_RIGHT, 110); + + s.LoadString(IDS_PERFSTAT_PROCESSED); + m_IrpList->InsertColumn(2, (LPCSTR)s, LVCFMT_RIGHT, 100); + for (i=0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++) { + m_IrpList->InsertItem(i, IrpMjStrings[i]); + } + + RefreshPerfStat(); + + SetTimer('STAT', m_Interval * 1000, NULL); + UpdateData(FALSE); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void CPerfStatDlg::RefreshPerfStat() +{ + int i; + CString s; + + PEXT2_PERF_STATISTICS_V1 PerfV1 = NULL; + PEXT2_PERF_STATISTICS_V2 PerfV2 = NULL; + + NT::NTSTATUS status; + + if (m_Handle == 0) { + status = Ext2Open("\\DosDevices\\Ext2Fsd", &m_Handle, + EXT2_DESIRED_ACCESS ); + if (!NT_SUCCESS(status)) { + goto errorout; + } + } + + if (Ext2QueryPerfStat(m_Handle, &m_PerfStat, &PerfV1, &PerfV2)) { + + if (PerfV2) { + + if (m_MemList) { + for (i = 0; i < PS_MAX_TYPE_V2; i++) { + if (PerfV2->Unit.Slot[i] == 0) + break; + else if (PerfV2->Unit.Slot[i] == 1) + s = "*"; + else + s.Format("%u", PerfV2->Unit.Slot[i]); + m_MemList->SetItem(i, 1, LVIF_TEXT, (LPCSTR)s, 0, 0, 0, 0); + + s.Format("%u", PerfV2->Current.Slot[i]); + m_MemList->SetItem(i, 2, LVIF_TEXT, (LPCSTR)s, 0, 0, 0, 0); + + s.Format("%u", PerfV2->Size.Slot[i]); + m_MemList->SetItem(i, 3, LVIF_TEXT, (LPCSTR)s, 0, 0, 0, 0); + + s.Format("%u", PerfV2->Total.Slot[i]); + m_MemList->SetItem(i, 4, LVIF_TEXT, (LPCSTR)s, 0, 0, 0, 0); + } + } + + if (m_IrpList) { + for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++) { + s.Format("%u", PerfV2->Irps[i].Current); + m_IrpList->SetItem(i, 1, LVIF_TEXT, (LPCSTR)s, 0, 0, 0, 0); + s.Format("%u", PerfV2->Irps[i].Processed); + m_IrpList->SetItem(i, 2, LVIF_TEXT, (LPCSTR)s, 0, 0, 0, 0); + } + } + + } else if (PerfV1) { + + if (m_MemList) { + for (i = 0; i < PS_MAX_TYPE_V1; i++) { + + if (PerfV1->Unit.Slot[i] == 0) + s = "*"; + else + s.Format("%u", PerfV1->Unit.Slot[i]); + m_MemList->SetItem(i, 1, LVIF_TEXT, (LPCSTR)s, 0, 0, 0, 0); + + s.Format("%u", PerfV1->Current.Slot[i]); + m_MemList->SetItem(i, 2, LVIF_TEXT, (LPCSTR)s, 0, 0, 0, 0); + + s.Format("%u", PerfV1->Size.Slot[i]); + m_MemList->SetItem(i, 3, LVIF_TEXT, (LPCSTR)s, 0, 0, 0, 0); + + s.Format("%u", PerfV1->Total.Slot[i]); + m_MemList->SetItem(i, 4, LVIF_TEXT, (LPCSTR)s, 0, 0, 0, 0); + } + } + + if (m_IrpList) { + for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++) { + s.Format("%u", PerfV1->Irps[i].Current); + m_IrpList->SetItem(i, 1, LVIF_TEXT, (LPCSTR)s, 0, 0, 0, 0); + s.Format("%u", PerfV1->Irps[i].Processed); + m_IrpList->SetItem(i, 2, LVIF_TEXT, (LPCSTR)s, 0, 0, 0, 0); + } + } + } + + } else { + Ext2Close(&m_Handle); + } + +errorout: + + return; +} + +void CPerfStatDlg::OnTimer(UINT_PTR nIDEvent) +{ + RefreshPerfStat(); + + CDialog::OnTimer(nIDEvent); +} + +void CPerfStatDlg::OnDestroy() +{ + KillTimer('STAT'); + Ext2Close(&m_Handle); + CDialog::OnDestroy(); +} + +void CPerfStatDlg::OnChangePerfstatInterval() +{ + UpdateData(TRUE); + + if (m_Interval == 0) { + m_Interval = 1; + } + SetTimer('STAT', m_Interval * 1000, NULL); +} + +void CPerfStatDlg::OnOK() +{ + // TODO: Add extra validation here + KillTimer('STAT'); + Ext2Close(&m_Handle); + GetParent()->PostMessage(WM_COMMAND, ID_PERFSTOP, 0); + CDialog::OnOK(); +} + +void CPerfStatDlg::OnCancel() +{ + // TODO: Add extra validation here + KillTimer('STAT'); + Ext2Close(&m_Handle); + GetParent()->PostMessage(WM_COMMAND, ID_PERFSTOP, 0); + CDialog::OnCancel(); +} + +void CPerfStatDlg::OnQueryPerf() +{ + RefreshPerfStat(); +} diff --git a/Ext2Mgr/PerfStatDlg.h b/Ext2Mgr/PerfStatDlg.h index ced6a26..7a16ebc 100644 --- a/Ext2Mgr/PerfStatDlg.h +++ b/Ext2Mgr/PerfStatDlg.h @@ -1,60 +1,60 @@ -#if !defined(AFX_PERFSTATDLG_H__E75F834E_0A81_4B82_BA17_D204EA1EC094__INCLUDED_) -#define AFX_PERFSTATDLG_H__E75F834E_0A81_4B82_BA17_D204EA1EC094__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// PerfStatDlg.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// CPerfStatDlg dialog - -class CPerfStatDlg : public CDialog -{ -// Construction -public: - CPerfStatDlg(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CPerfStatDlg) - enum { IDD = IDD_PERFSTAT_DIALOG }; - int m_Interval; - //}}AFX_DATA - - CListCtrl * m_IrpList; - CListCtrl * m_MemList; - - HANDLE m_Handle; - EXT2_QUERY_PERFSTAT m_PerfStat; - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CPerfStatDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CPerfStatDlg) - virtual BOOL OnInitDialog(); - afx_msg void OnTimer(UINT_PTR nIDEvent); - afx_msg void OnDestroy(); - afx_msg void OnChangePerfstatInterval(); - virtual void OnOK(); - virtual void OnCancel(); - - afx_msg void OnQueryPerf(); - - void RefreshPerfStat(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_PERFSTATDLG_H__E75F834E_0A81_4B82_BA17_D204EA1EC094__INCLUDED_) +#if !defined(AFX_PERFSTATDLG_H__E75F834E_0A81_4B82_BA17_D204EA1EC094__INCLUDED_) +#define AFX_PERFSTATDLG_H__E75F834E_0A81_4B82_BA17_D204EA1EC094__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// PerfStatDlg.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CPerfStatDlg dialog + +class CPerfStatDlg : public CDialog +{ +// Construction +public: + CPerfStatDlg(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CPerfStatDlg) + enum { IDD = IDD_PERFSTAT_DIALOG }; + int m_Interval; + //}}AFX_DATA + + CListCtrl * m_IrpList; + CListCtrl * m_MemList; + + HANDLE m_Handle; + EXT2_QUERY_PERFSTAT m_PerfStat; + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CPerfStatDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CPerfStatDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnTimer(UINT_PTR nIDEvent); + afx_msg void OnDestroy(); + afx_msg void OnChangePerfstatInterval(); + virtual void OnOK(); + virtual void OnCancel(); + + afx_msg void OnQueryPerf(); + + void RefreshPerfStat(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_PERFSTATDLG_H__E75F834E_0A81_4B82_BA17_D204EA1EC094__INCLUDED_) diff --git a/Ext2Mgr/Properties.cpp b/Ext2Mgr/Properties.cpp index 5bd9d1c..fc1082d 100644 --- a/Ext2Mgr/Properties.cpp +++ b/Ext2Mgr/Properties.cpp @@ -1,766 +1,766 @@ -// Properties.cpp : implementation file -// - -#include "stdafx.h" -#include "ext2mgr.h" -#include "Ext2MgrDlg.h" -#include "Properties.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -#include "SelectDrvLetter.h" - -///////////////////////////////////////////////////////////////////////////// -// CProperties dialog - - -CProperties::CProperties(CWnd* pParent /*=NULL*/) - : CDialog(CProperties::IDD, pParent) -{ - //{{AFX_DATA_INIT(CProperties) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT - m_bdisk = FALSE; - m_type = 0; - m_sdev = NULL; - - m_volume = NULL; - m_cdrom = NULL; - m_disk = NULL; - m_part = NULL; - - cbDiskBox = &m_DiskBox.m_ComboBox; - cbPartBox = &m_PartBox.m_ComboBox; -} - - -void CProperties::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CProperties) - // NOTE: the ClassWizard will add DDX and DDV calls here - DDX_Control(pDX, IDC_PROPERTY_DEVICE, m_DiskBox); - DDX_Control(pDX, IDC_PROPERTY_SDEV, m_PartBox); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CProperties, CDialog) - //{{AFX_MSG_MAP(CProperties) - ON_BN_CLICKED(IDC_SDEV_QUICK_MOUNT, OnSdevQuickMount) - ON_BN_CLICKED(IDC_SDEV_CHANGE_MP, OnSdevChangeMp) - ON_BN_CLICKED(IDC_SDEV_EXT2_INFO, OnSdevExt2Info) - ON_MESSAGE(WM_GROUP_BOX_UPDATED, OnGroupBoxUpdated) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CProperties message handlers - -void CProperties::ResetDiskGroup() -{ - CString s = ""; - - SET_TEXT(IDC_VENDOR_ID, s); - SET_TEXT(IDC_PRODUCT_ID, s); - SET_TEXT(IDC_SERIAL_NUMBER, s); - SET_TEXT(IDC_BUS_TYPE, s); - SET_TEXT(IDC_DEVICE_TYPE, s); - SET_TEXT(IDC_TOTAL_SIZE, s); - SET_TEXT(IDC_MEDIA_TYPE, s); -} - -void CProperties::ResetPartGroup() -{ - CString s = ""; - - SET_TEXT(IDC_MOUNT_POINTS, s); - SET_TEXT(IDC_SDEV_STATUS, s); - SET_TEXT(IDC_SDEV_SIZE, s); - SET_TEXT(IDC_SDEV_FREE_SIZE, s); - SET_TEXT(IDC_FILE_SYSTEM, s); - SET_WIN(IDC_SDEV_CHANGE_MP, FALSE); - SET_WIN(IDC_SDEV_QUICK_MOUNT, FALSE); - SET_WIN(IDC_SDEV_EXT2_INFO, FALSE); -} - -void CProperties::OnSdevChangeMp() -{ - CMountPoints mntPoint; - BOOL bInited = FALSE; - - if (m_cdrom) { - ASSERT(!bInited); - mntPoint.m_Cdrom = m_cdrom; - bInited = TRUE; - } - - if (m_part) { - ASSERT(!bInited); - mntPoint.m_Part = m_part; - bInited = TRUE; - } - - if (m_volume) { - ASSERT(!bInited); - mntPoint.m_Volume = m_volume; - bInited = TRUE; - } - - if (!bInited) { - return; - } - - mntPoint.m_MainDlg = GetParent(); - mntPoint.DoModal(); - - if (mntPoint.m_bUpdated) { - CExt2MgrDlg * Parent = (CExt2MgrDlg *)GetParent(); - - if (mntPoint.m_Volume) { - Parent->UpdateVolume(mntPoint.m_Volume); - } - if (mntPoint.m_Cdrom) { - Parent->UpdateCdrom(mntPoint.m_Cdrom); - } - if (mntPoint.m_Part) { - Parent->UpdatePartition(mntPoint.m_Part); - } - } - - OnOK(); -} - -void CProperties::OnSdevQuickMount() -{ - PCHAR dev = NULL; - - if (m_cdrom) { - dev = m_cdrom->Name; - } - - if (m_part) { - if (m_part->Volume) - dev = m_part->Volume->Name; - else - dev = m_part->Name; - } - - if (m_volume) { - dev = m_volume->Name; - } - - if (!dev) { - return; - } - - if (Ext2MountVolume(dev)) { - CExt2MgrDlg * Parent = (CExt2MgrDlg *)GetParent(); - if (m_cdrom) { - Parent->UpdateCdrom(m_cdrom); - } else if (m_volume) { - Parent->UpdateVolume(m_volume); - } else if (m_part) { - Parent->UpdateVolume(m_part->Volume); - } - } - - OnOK(); -} - -void CProperties::OnSdevExt2Info() -{ - NT::NTSTATUS status; - HANDLE Handle = NULL; - CString s; - - CExt2Attribute EA; - PEXT2_VOLUME_PROPERTY3 EVP = NULL; - - if (m_cdrom && (m_cdrom->EVP.bExt2 || m_cdrom->EVP.bExt3)) { - EVP = &m_cdrom->EVP; - EA.m_bCdrom = TRUE; - EA.m_DevName = m_cdrom->Name; - } else if (m_volume) { - EVP = &m_volume->EVP; - if (m_volume->Part) - EA.m_DevName = m_volume->Part->Name; - else - EA.m_DevName = m_volume->Name; - } else if (m_part) { - EVP = &m_part->Volume->EVP; - EA.m_DevName = m_part->Volume->Name; - } - - if (!EVP) { - return; - } - - EA.m_MainDlg = GetParent(); - EA.m_EVP = EVP; - - status = Ext2Open(EA.m_DevName.GetBuffer(EA.m_DevName.GetLength()), - &Handle, EXT2_DESIRED_ACCESS); - - if (!NT_SUCCESS(status)) { - - s.Format("Ext2Fsd service isn't started.\n"); - AfxMessageBox(s, MB_OK | MB_ICONSTOP); - - } else { - - if (!Ext2QueryExt2Property(Handle, EVP)) { - Ext2Close(&Handle); - return; - } - - Ext2Close(&Handle); - } - - - if (EA.DoModal() == IDOK) { - CExt2MgrDlg * Parent = (CExt2MgrDlg *)GetParent(); - if (m_cdrom) { - Parent->UpdateCdrom(m_cdrom); - } else if (m_volume) { - Parent->UpdateVolume(m_volume); - } else if (m_part) { - Parent->UpdateVolume(m_part->Volume); - } - } -} - -void CProperties::SetVolume(PEXT2_VOLUME vol) -{ - CString s; - - if (vol->Extent->NumberOfDiskExtents == 1) { - m_disk = &gDisks[vol->Extent->Extents[0].DiskNumber]; - m_part = NULL; - for (UCHAR i = 0; i < m_disk->NumParts; i++) { - if (m_disk->DataParts[i].Volume == vol) { - m_part = &m_disk->DataParts[i]; - break; - } - } - } else { - m_disk = NULL; - m_part = NULL; - } - - if (m_part) { - m_disk = NULL; - m_volume = NULL; - SetPartition(m_part); - if (0 == m_part->DrvLetters) - SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); - else - SET_WIN(IDC_SDEV_QUICK_MOUNT, FALSE); - return; - } else { - m_disk = NULL; - ResetDiskGroup(); - if (m_volume) { - if (0 == m_volume->DrvLetters) - SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); - else - SET_WIN(IDC_SDEV_QUICK_MOUNT, FALSE); - } - } - - cbDiskBox->SetCurSel(-1); - ResetDiskGroup(); - - cbPartBox->ResetContent(); - cbPartBox->AddString("Volume"); - cbPartBox->SetCurSel(0); - - /* set mount points */ - SET_TEXT(IDC_MOUNT_POINTS, - Ext2QueryVolumeLetterStrings( - vol->DrvLetters, NULL)); - - /* set volume status */ - s = "Online"; - if (vol->bRecognized && (vol->EVP.bExt2 || vol->EVP.bExt3)) { - s += ",codepage:"; - s += vol->EVP.Codepage; - if (vol->EVP.bReadonly) { - s += ",Readonly"; - } - } - SET_TEXT(IDC_SDEV_STATUS, s); - - { - ULONGLONG totalSize, freeSize; - totalSize = vol->FssInfo.TotalAllocationUnits.QuadPart; - freeSize = vol->FssInfo.AvailableAllocationUnits.QuadPart; - totalSize = totalSize * vol->FssInfo.BytesPerSector * - vol->FssInfo.SectorsPerAllocationUnit; - freeSize = freeSize * vol->FssInfo.BytesPerSector * - vol->FssInfo.SectorsPerAllocationUnit; - s.Format("%I64u", totalSize); - SET_TEXT(IDC_SDEV_SIZE, s); - s.Format("%I64u", freeSize); - SET_TEXT(IDC_SDEV_FREE_SIZE, s); - } - - SET_TEXT(IDC_FILE_SYSTEM, vol->FileSystem); - - SET_WIN(IDC_SDEV_CHANGE_MP, TRUE); - if (0 == vol->DrvLetters){ - SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); - } - - if (vol->bRecognized && (vol->EVP.bExt2 || vol->EVP.bExt3)) { - SET_WIN(IDC_SDEV_EXT2_INFO, TRUE); - } -} - -void CProperties::SetPartition(PEXT2_PARTITION part) -{ - CString s; - - ResetPartGroup(); - - if (m_disk != part->Disk) { - SetDisk(m_disk = part->Disk); - } - - if (!m_disk->bLoaded || m_disk->Layout == NULL) { - cbPartBox->SetCurSel(-1); - return; - } - - cbPartBox->SetCurSel(part->Number - 1); - - /* set mount points */ - SET_TEXT(IDC_MOUNT_POINTS, - Ext2QueryVolumeLetterStrings( - part->DrvLetters, NULL)); - - if (m_disk->SDD.RemovableMedia) { - SET_WIN(IDC_SDEV_CHANGE_MP, TRUE); - } - - if (part->Volume) { - if (!part->Volume->bDynamic) { - SET_WIN(IDC_SDEV_CHANGE_MP, TRUE); - } - if (0 == part->Volume->DrvLetters){ - SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); - } - } else { - s.Format("PARTITION %d", 0); - SET_TEXT(IDC_PROPERTY_SDEV, s); - - if (m_disk->SDD.RemovableMedia) { - if (m_disk->bEjected) { - s = "Media ejected"; - } else { - s = "Stopped"; - } - } else { - if (m_disk->Layout) { - s = "Not recognized"; - } else { - s = "RAW"; - } - } - - if (0 == part->DrvLetters){ - SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); - } - - SET_TEXT(IDC_SDEV_STATUS, s); - return; - } - - if (part->Volume->bRecognized && - (part->Volume->EVP.bExt2 || part->Volume->EVP.bExt3)) { - SET_WIN(IDC_SDEV_EXT2_INFO, TRUE); - } - - s = "Online,"; - if (part->Entry->PartitionStyle == PARTITION_STYLE_MBR) { - s += PartitionString(part->Entry->Mbr.PartitionType); - } else { - s += "GPT"; - } - if ( part->Volume->bRecognized && - (part->Volume->EVP.bExt2 || part->Volume->EVP.bExt3)) { - s += ",codepage:"; - s += part->Volume->EVP.Codepage; - if (part->Volume->EVP.bReadonly) { - s += ",Readonly"; - } - } - SET_TEXT(IDC_SDEV_STATUS, s); - - if (part->Volume->bRecognized) { - ULONGLONG totalSize, freeSize; - totalSize = part->Volume->FssInfo.TotalAllocationUnits.QuadPart; - freeSize = part->Volume->FssInfo.AvailableAllocationUnits.QuadPart; - totalSize = totalSize * part->Volume->FssInfo.BytesPerSector * - part->Volume->FssInfo.SectorsPerAllocationUnit; - freeSize = freeSize * part->Volume->FssInfo.BytesPerSector * - part->Volume->FssInfo.SectorsPerAllocationUnit; - s.Format("%I64u", totalSize); - SET_TEXT(IDC_SDEV_SIZE, s); - s.Format("%I64u", freeSize); - SET_TEXT(IDC_SDEV_FREE_SIZE, s); - } else { - s.Format("%I64u", part->Entry->PartitionLength.QuadPart); - SET_TEXT(IDC_SDEV_SIZE, s); - SET_TEXT(IDC_SDEV_FREE_SIZE, "0"); - } - - SET_TEXT(IDC_FILE_SYSTEM, part->Volume->FileSystem); -} - -void CProperties::SetDisk(PEXT2_DISK disk) -{ - CString s; - ULONGLONG size = 1; - - ResetPartGroup(); - cbPartBox->ResetContent(); - - if (!disk->bLoaded) { - ResetDiskGroup(); - return; - } else { - cbDiskBox->SetCurSel(disk->OrderNo); - } - - if (disk->Layout) { - for (UCHAR i=0; i < disk->NumParts; i++) { - s.Format("PARTITION %u", i+1); - cbPartBox->AddString(s.GetBuffer(s.GetLength())); - } - } - - if (disk->SDD.VendorIdOffset) { - s = (PCHAR)&disk->SDD + disk->SDD.VendorIdOffset; - } else { - s.Empty(); - } - SET_TEXT(IDC_VENDOR_ID, s); - - if (disk->SDD.ProductIdOffset) { - s = (PCHAR)&disk->SDD + disk->SDD.ProductIdOffset; - } else { - s.Empty(); - } - SET_TEXT(IDC_PRODUCT_ID, s); - - if (disk->SDD.SerialNumberOffset) { - s = (PCHAR)&disk->SDD + disk->SDD.SerialNumberOffset; - } else { - s.Empty(); - } - SET_TEXT(IDC_SERIAL_NUMBER, s); - - s = BusTypeString(disk->SDD.BusType); - SET_TEXT(IDC_BUS_TYPE, s); - - if (disk->SDD.RemovableMedia) { - s = "Removable"; - } else { - s = "RAW"; - if (disk->Layout) { - if (disk->Layout->PartitionStyle == PARTITION_STYLE_MBR) { - if (disk->Layout->PartitionEntry->Mbr.PartitionType - == PARTITION_LDM) { - s.LoadString(IDS_DISK_TYPE_DYN); - } else { - s.LoadString(IDS_DISK_TYPE_BASIC); - } - } else if (disk->Layout->PartitionStyle == PARTITION_STYLE_MBR) { - s = "GUID"; - } - } - } - SET_TEXT(IDC_DEVICE_TYPE, s); - - if (disk->bEjected) { - s = "No media"; - } else { - - /* set size */ - size = size * disk->DiskGeometry.BytesPerSector; - size = size * disk->DiskGeometry.SectorsPerTrack; - size = size * disk->DiskGeometry.TracksPerCylinder; - size = size * disk->DiskGeometry.Cylinders.QuadPart; - s.Format("%I64u", size); - SET_TEXT(IDC_TOTAL_SIZE, s); - - switch (disk->DiskGeometry.MediaType) { - case FixedMedia: s="Fixed"; break; - case RemovableMedia: s="Removable"; break; - case CD_ROM: s="CDROM"; break; - case CD_R: s="CDR"; break; - case CD_RW: s="CDRW"; break; - case DVD_ROM: s="DVD"; break; - case DVD_R: s="DVDR"; break; - case DVD_RW: s="DVDRW"; break; - default: s="Unkown"; - } - } - - SET_TEXT(IDC_MEDIA_TYPE, s); -} - - -void CProperties::SetCdrom(PEXT2_CDROM cdrom) -{ - CString s; - ULONGLONG size = 1; - - cbDiskBox->SetCurSel(cdrom->OrderNo + g_nDisks); - - ResetPartGroup(); - cbPartBox->ResetContent(); - cbPartBox->AddString("Media"); - cbPartBox->SetCurSel(0); - - SET_WIN(IDC_SDEV_CHANGE_MP, TRUE); - - if (0 == cdrom->DrvLetters) - SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); - - - if (cdrom->SDD.VendorIdOffset) { - s = (PCHAR)&cdrom->SDD + cdrom->SDD.VendorIdOffset; - } else { - s.Empty(); - } - SET_TEXT(IDC_VENDOR_ID, s); - - if (cdrom->SDD.ProductIdOffset) { - s = (PCHAR)&cdrom->SDD + cdrom->SDD.ProductIdOffset; - } else { - s.Empty(); - } - SET_TEXT(IDC_PRODUCT_ID, s); - - if (cdrom->SDD.SerialNumberOffset) { - s = (PCHAR)&cdrom->SDD + cdrom->SDD.SerialNumberOffset; - } else { - s.Empty(); - } - SET_TEXT(IDC_SERIAL_NUMBER, s); - - s = BusTypeString(cdrom->SDD.BusType); - SET_TEXT(IDC_BUS_TYPE, s); - - s.LoadString(IDS_DISK_TYPE_BASIC); - SET_TEXT(IDC_DEVICE_TYPE, s); - - if (cdrom->bLoaded) { - if (cdrom->bIsDVD) { - s = "DVD"; - } else { - s = "CDROM"; - } - size = size * cdrom->DiskGeometry.BytesPerSector; - size = size * cdrom->DiskGeometry.SectorsPerTrack; - size = size * cdrom->DiskGeometry.TracksPerCylinder; - size = size * cdrom->DiskGeometry.Cylinders.QuadPart; - } else { - s = "No media"; - size = 0; - } - SET_TEXT(IDC_MEDIA_TYPE, s); - - if (cdrom->bLoaded) { - if (cdrom->bEjected) { - s = "Media ejected"; - } else { - s.Format("%I64u", size); - SET_TEXT(IDC_TOTAL_SIZE, s); - SET_TEXT(IDC_SDEV_SIZE, s); - SET_TEXT(IDC_SDEV_FREE_SIZE, "0"); - - if (cdrom->EVP.bExt2) { - s = "EXT"; - s += (CHAR)('2' + cdrom->EVP.bExt3); - SET_WIN(IDC_SDEV_EXT2_INFO, TRUE); - } else { - s = "CDFS"; - } - SET_TEXT(IDC_FILE_SYSTEM, s); - - s = "Online,"; - switch (cdrom->DiskGeometry.MediaType) { - case FixedMedia: s +="Fixed"; break; - case RemovableMedia: s += "Media Removable"; break; - case CD_ROM: s +=" CDROM"; break; - case CD_R: s += "CDR"; break; - case CD_RW: s += "CDRW"; break; - case DVD_ROM: s += "DVD"; break; - case DVD_R: s += "DVDR"; break; - case DVD_RW: s += "DVDRW"; break; - default: s += "Unkown"; - } - } - } else { - s = "Device stopped"; - } - SET_TEXT(IDC_SDEV_STATUS, s); - - if (0 == cdrom->DrvLetters){ - SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); - } - - SET_TEXT(IDC_MOUNT_POINTS, - Ext2QueryVolumeLetterStrings( - cdrom->DrvLetters, NULL)); -} - -BOOL CProperties::OnInitDialog() -{ - CString str; - - CDialog::OnInitDialog(); - - for (ULONG i = 0; i < g_nDisks; i++) { - str.Format("DISK %u", i); - cbDiskBox->AddString(str.GetBuffer(str.GetLength())); - } - - for (ULONG i = 0; i < g_nCdroms; i++) { - str.Format("CDROM %u", i); - cbDiskBox->AddString(str.GetBuffer(str.GetLength())); - } - - SET_WIN(IDC_SDEV_CHANGE_MP, FALSE); - SET_WIN(IDC_SDEV_EXT2_INFO, FALSE); - SET_WIN(IDC_SDEV_QUICK_MOUNT, FALSE); - - if (m_bdisk) { - if (m_type == EXT2_DISK_MAGIC) { - m_disk = (PEXT2_DISK) m_sdev; - SetDisk(m_disk); - } else if (m_type == EXT2_PART_MAGIC) { - m_part = (PEXT2_PARTITION) m_sdev; - SetPartition(m_part); - if (0 == m_part->DrvLetters) - SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); - if (m_part->Volume && 0 == m_part->Volume->DrvLetters) - SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); - } else if (m_type == EXT2_DISK_NULL_MAGIC) { - m_disk = (PEXT2_DISK)m_sdev; - SetDisk(m_disk); - } else if (m_type == EXT2_CDROM_VOLUME_MAGIC) { - m_cdrom = (PEXT2_CDROM)m_sdev; - SetCdrom(m_cdrom); - if (0 == m_cdrom->DrvLetters) - SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); - } else if (m_type == EXT2_CDROM_DEVICE_MAGIC){ - m_cdrom = (PEXT2_CDROM)m_sdev; - SetCdrom(m_cdrom); - if (0 == m_cdrom->DrvLetters) - SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); - } - - if (m_disk && NULL == m_part) { - if (m_disk->bLoaded && m_disk->NumParts > 0) { - m_part = &m_disk->DataParts[0]; - SetPartition(m_part); - if (0 == m_part->DrvLetters) - SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); - if (m_part->Volume && 0 == m_part->Volume->DrvLetters) - SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); - } - } - - } else { - if (m_type == EXT2_VOLUME_MAGIC) { - m_volume = (PEXT2_VOLUME)m_sdev; - SetVolume(m_volume); - if (m_volume && 0 == m_volume->DrvLetters) { - SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); - } - } else { - ASSERT(m_type == EXT2_CDROM_DEVICE_MAGIC); - m_cdrom = (PEXT2_CDROM)m_sdev; - SetCdrom(m_cdrom); - if (0 == m_cdrom->DrvLetters) - SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); - } - } - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - - -LRESULT CProperties::OnGroupBoxUpdated(WPARAM wParam,LPARAM lParam) -{ - ULONG i; - BOOL bChanged = FALSE; - - if (wParam == 'GB') { - if (lParam == 'DVLU') { - i = (ULONG)cbDiskBox->GetCurSel(); - if (i >= g_nDisks) { - if (m_disk != NULL || (m_cdrom != NULL && - m_cdrom != &gCdroms[i - g_nDisks])) { - m_disk = NULL; - m_part = NULL; - m_volume = NULL; - m_cdrom = &gCdroms[i - g_nDisks]; - bChanged = TRUE; - } else if (m_volume) { - m_volume = NULL; - m_cdrom = &gCdroms[i - g_nDisks]; - bChanged = TRUE; - } - } else { - if (m_cdrom != NULL || (m_disk != NULL && - m_disk != &gDisks[i])) { - m_disk = &gDisks[i]; - m_cdrom = NULL; - m_volume = NULL; - m_part = NULL; - bChanged = TRUE; - } else if (m_volume){ - m_volume = NULL; - m_disk = &gDisks[i]; - bChanged = TRUE; - } - } - - if (bChanged) { - - if (m_cdrom) { - SetCdrom(m_cdrom); - } - if (m_disk) { - SetDisk(m_disk); - if (m_disk->bLoaded && m_disk->NumParts > 0) { - m_part = &m_disk->DataParts[0]; - SetPartition(m_part); - } else { - m_part = NULL; - } - } - } - } - - if (lParam == 'PVLU') { - i = cbPartBox->GetCurSel(); - if (m_part && ((i + 1) != m_part->Number)) { - m_part = &m_disk->DataParts[i]; - SetPartition(m_part); - } - } - } - - return TRUE; -} +// Properties.cpp : implementation file +// + +#include "stdafx.h" +#include "ext2mgr.h" +#include "Ext2MgrDlg.h" +#include "Properties.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +#include "SelectDrvLetter.h" + +///////////////////////////////////////////////////////////////////////////// +// CProperties dialog + + +CProperties::CProperties(CWnd* pParent /*=NULL*/) + : CDialog(CProperties::IDD, pParent) +{ + //{{AFX_DATA_INIT(CProperties) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + m_bdisk = FALSE; + m_type = 0; + m_sdev = NULL; + + m_volume = NULL; + m_cdrom = NULL; + m_disk = NULL; + m_part = NULL; + + cbDiskBox = &m_DiskBox.m_ComboBox; + cbPartBox = &m_PartBox.m_ComboBox; +} + + +void CProperties::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CProperties) + // NOTE: the ClassWizard will add DDX and DDV calls here + DDX_Control(pDX, IDC_PROPERTY_DEVICE, m_DiskBox); + DDX_Control(pDX, IDC_PROPERTY_SDEV, m_PartBox); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CProperties, CDialog) + //{{AFX_MSG_MAP(CProperties) + ON_BN_CLICKED(IDC_SDEV_QUICK_MOUNT, OnSdevQuickMount) + ON_BN_CLICKED(IDC_SDEV_CHANGE_MP, OnSdevChangeMp) + ON_BN_CLICKED(IDC_SDEV_EXT2_INFO, OnSdevExt2Info) + ON_MESSAGE(WM_GROUP_BOX_UPDATED, OnGroupBoxUpdated) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CProperties message handlers + +void CProperties::ResetDiskGroup() +{ + CString s = ""; + + SET_TEXT(IDC_VENDOR_ID, s); + SET_TEXT(IDC_PRODUCT_ID, s); + SET_TEXT(IDC_SERIAL_NUMBER, s); + SET_TEXT(IDC_BUS_TYPE, s); + SET_TEXT(IDC_DEVICE_TYPE, s); + SET_TEXT(IDC_TOTAL_SIZE, s); + SET_TEXT(IDC_MEDIA_TYPE, s); +} + +void CProperties::ResetPartGroup() +{ + CString s = ""; + + SET_TEXT(IDC_MOUNT_POINTS, s); + SET_TEXT(IDC_SDEV_STATUS, s); + SET_TEXT(IDC_SDEV_SIZE, s); + SET_TEXT(IDC_SDEV_FREE_SIZE, s); + SET_TEXT(IDC_FILE_SYSTEM, s); + SET_WIN(IDC_SDEV_CHANGE_MP, FALSE); + SET_WIN(IDC_SDEV_QUICK_MOUNT, FALSE); + SET_WIN(IDC_SDEV_EXT2_INFO, FALSE); +} + +void CProperties::OnSdevChangeMp() +{ + CMountPoints mntPoint; + BOOL bInited = FALSE; + + if (m_cdrom) { + ASSERT(!bInited); + mntPoint.m_Cdrom = m_cdrom; + bInited = TRUE; + } + + if (m_part) { + ASSERT(!bInited); + mntPoint.m_Part = m_part; + bInited = TRUE; + } + + if (m_volume) { + ASSERT(!bInited); + mntPoint.m_Volume = m_volume; + bInited = TRUE; + } + + if (!bInited) { + return; + } + + mntPoint.m_MainDlg = GetParent(); + mntPoint.DoModal(); + + if (mntPoint.m_bUpdated) { + CExt2MgrDlg * Parent = (CExt2MgrDlg *)GetParent(); + + if (mntPoint.m_Volume) { + Parent->UpdateVolume(mntPoint.m_Volume); + } + if (mntPoint.m_Cdrom) { + Parent->UpdateCdrom(mntPoint.m_Cdrom); + } + if (mntPoint.m_Part) { + Parent->UpdatePartition(mntPoint.m_Part); + } + } + + OnOK(); +} + +void CProperties::OnSdevQuickMount() +{ + PCHAR dev = NULL; + + if (m_cdrom) { + dev = m_cdrom->Name; + } + + if (m_part) { + if (m_part->Volume) + dev = m_part->Volume->Name; + else + dev = m_part->Name; + } + + if (m_volume) { + dev = m_volume->Name; + } + + if (!dev) { + return; + } + + if (Ext2MountVolume(dev)) { + CExt2MgrDlg * Parent = (CExt2MgrDlg *)GetParent(); + if (m_cdrom) { + Parent->UpdateCdrom(m_cdrom); + } else if (m_volume) { + Parent->UpdateVolume(m_volume); + } else if (m_part) { + Parent->UpdateVolume(m_part->Volume); + } + } + + OnOK(); +} + +void CProperties::OnSdevExt2Info() +{ + NT::NTSTATUS status; + HANDLE Handle = NULL; + CString s; + + CExt2Attribute EA; + PEXT2_VOLUME_PROPERTY3 EVP = NULL; + + if (m_cdrom && (m_cdrom->EVP.bExt2 || m_cdrom->EVP.bExt3)) { + EVP = &m_cdrom->EVP; + EA.m_bCdrom = TRUE; + EA.m_DevName = m_cdrom->Name; + } else if (m_volume) { + EVP = &m_volume->EVP; + if (m_volume->Part) + EA.m_DevName = m_volume->Part->Name; + else + EA.m_DevName = m_volume->Name; + } else if (m_part) { + EVP = &m_part->Volume->EVP; + EA.m_DevName = m_part->Volume->Name; + } + + if (!EVP) { + return; + } + + EA.m_MainDlg = GetParent(); + EA.m_EVP = EVP; + + status = Ext2Open(EA.m_DevName.GetBuffer(EA.m_DevName.GetLength()), + &Handle, EXT2_DESIRED_ACCESS); + + if (!NT_SUCCESS(status)) { + + s.Format("Ext2Fsd service isn't started.\n"); + AfxMessageBox(s, MB_OK | MB_ICONSTOP); + + } else { + + if (!Ext2QueryExt2Property(Handle, EVP)) { + Ext2Close(&Handle); + return; + } + + Ext2Close(&Handle); + } + + + if (EA.DoModal() == IDOK) { + CExt2MgrDlg * Parent = (CExt2MgrDlg *)GetParent(); + if (m_cdrom) { + Parent->UpdateCdrom(m_cdrom); + } else if (m_volume) { + Parent->UpdateVolume(m_volume); + } else if (m_part) { + Parent->UpdateVolume(m_part->Volume); + } + } +} + +void CProperties::SetVolume(PEXT2_VOLUME vol) +{ + CString s; + + if (vol->Extent->NumberOfDiskExtents == 1) { + m_disk = &gDisks[vol->Extent->Extents[0].DiskNumber]; + m_part = NULL; + for (UCHAR i = 0; i < m_disk->NumParts; i++) { + if (m_disk->DataParts[i].Volume == vol) { + m_part = &m_disk->DataParts[i]; + break; + } + } + } else { + m_disk = NULL; + m_part = NULL; + } + + if (m_part) { + m_disk = NULL; + m_volume = NULL; + SetPartition(m_part); + if (0 == m_part->DrvLetters) + SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); + else + SET_WIN(IDC_SDEV_QUICK_MOUNT, FALSE); + return; + } else { + m_disk = NULL; + ResetDiskGroup(); + if (m_volume) { + if (0 == m_volume->DrvLetters) + SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); + else + SET_WIN(IDC_SDEV_QUICK_MOUNT, FALSE); + } + } + + cbDiskBox->SetCurSel(-1); + ResetDiskGroup(); + + cbPartBox->ResetContent(); + cbPartBox->AddString("Volume"); + cbPartBox->SetCurSel(0); + + /* set mount points */ + SET_TEXT(IDC_MOUNT_POINTS, + Ext2QueryVolumeLetterStrings( + vol->DrvLetters, NULL)); + + /* set volume status */ + s = "Online"; + if (vol->bRecognized && (vol->EVP.bExt2 || vol->EVP.bExt3)) { + s += ",codepage:"; + s += vol->EVP.Codepage; + if (vol->EVP.bReadonly) { + s += ",Readonly"; + } + } + SET_TEXT(IDC_SDEV_STATUS, s); + + { + ULONGLONG totalSize, freeSize; + totalSize = vol->FssInfo.TotalAllocationUnits.QuadPart; + freeSize = vol->FssInfo.AvailableAllocationUnits.QuadPart; + totalSize = totalSize * vol->FssInfo.BytesPerSector * + vol->FssInfo.SectorsPerAllocationUnit; + freeSize = freeSize * vol->FssInfo.BytesPerSector * + vol->FssInfo.SectorsPerAllocationUnit; + s.Format("%I64u", totalSize); + SET_TEXT(IDC_SDEV_SIZE, s); + s.Format("%I64u", freeSize); + SET_TEXT(IDC_SDEV_FREE_SIZE, s); + } + + SET_TEXT(IDC_FILE_SYSTEM, vol->FileSystem); + + SET_WIN(IDC_SDEV_CHANGE_MP, TRUE); + if (0 == vol->DrvLetters){ + SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); + } + + if (vol->bRecognized && (vol->EVP.bExt2 || vol->EVP.bExt3)) { + SET_WIN(IDC_SDEV_EXT2_INFO, TRUE); + } +} + +void CProperties::SetPartition(PEXT2_PARTITION part) +{ + CString s; + + ResetPartGroup(); + + if (m_disk != part->Disk) { + SetDisk(m_disk = part->Disk); + } + + if (!m_disk->bLoaded || m_disk->Layout == NULL) { + cbPartBox->SetCurSel(-1); + return; + } + + cbPartBox->SetCurSel(part->Number - 1); + + /* set mount points */ + SET_TEXT(IDC_MOUNT_POINTS, + Ext2QueryVolumeLetterStrings( + part->DrvLetters, NULL)); + + if (m_disk->SDD.RemovableMedia) { + SET_WIN(IDC_SDEV_CHANGE_MP, TRUE); + } + + if (part->Volume) { + if (!part->Volume->bDynamic) { + SET_WIN(IDC_SDEV_CHANGE_MP, TRUE); + } + if (0 == part->Volume->DrvLetters){ + SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); + } + } else { + s.Format("PARTITION %d", 0); + SET_TEXT(IDC_PROPERTY_SDEV, s); + + if (m_disk->SDD.RemovableMedia) { + if (m_disk->bEjected) { + s = "Media ejected"; + } else { + s = "Stopped"; + } + } else { + if (m_disk->Layout) { + s = "Not recognized"; + } else { + s = "RAW"; + } + } + + if (0 == part->DrvLetters){ + SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); + } + + SET_TEXT(IDC_SDEV_STATUS, s); + return; + } + + if (part->Volume->bRecognized && + (part->Volume->EVP.bExt2 || part->Volume->EVP.bExt3)) { + SET_WIN(IDC_SDEV_EXT2_INFO, TRUE); + } + + s = "Online,"; + if (part->Entry->PartitionStyle == PARTITION_STYLE_MBR) { + s += PartitionString(part->Entry->Mbr.PartitionType); + } else { + s += "GPT"; + } + if ( part->Volume->bRecognized && + (part->Volume->EVP.bExt2 || part->Volume->EVP.bExt3)) { + s += ",codepage:"; + s += part->Volume->EVP.Codepage; + if (part->Volume->EVP.bReadonly) { + s += ",Readonly"; + } + } + SET_TEXT(IDC_SDEV_STATUS, s); + + if (part->Volume->bRecognized) { + ULONGLONG totalSize, freeSize; + totalSize = part->Volume->FssInfo.TotalAllocationUnits.QuadPart; + freeSize = part->Volume->FssInfo.AvailableAllocationUnits.QuadPart; + totalSize = totalSize * part->Volume->FssInfo.BytesPerSector * + part->Volume->FssInfo.SectorsPerAllocationUnit; + freeSize = freeSize * part->Volume->FssInfo.BytesPerSector * + part->Volume->FssInfo.SectorsPerAllocationUnit; + s.Format("%I64u", totalSize); + SET_TEXT(IDC_SDEV_SIZE, s); + s.Format("%I64u", freeSize); + SET_TEXT(IDC_SDEV_FREE_SIZE, s); + } else { + s.Format("%I64u", part->Entry->PartitionLength.QuadPart); + SET_TEXT(IDC_SDEV_SIZE, s); + SET_TEXT(IDC_SDEV_FREE_SIZE, "0"); + } + + SET_TEXT(IDC_FILE_SYSTEM, part->Volume->FileSystem); +} + +void CProperties::SetDisk(PEXT2_DISK disk) +{ + CString s; + ULONGLONG size = 1; + + ResetPartGroup(); + cbPartBox->ResetContent(); + + if (!disk->bLoaded) { + ResetDiskGroup(); + return; + } else { + cbDiskBox->SetCurSel(disk->OrderNo); + } + + if (disk->Layout) { + for (UCHAR i=0; i < disk->NumParts; i++) { + s.Format("PARTITION %u", i+1); + cbPartBox->AddString(s.GetBuffer(s.GetLength())); + } + } + + if (disk->SDD.VendorIdOffset) { + s = (PCHAR)&disk->SDD + disk->SDD.VendorIdOffset; + } else { + s.Empty(); + } + SET_TEXT(IDC_VENDOR_ID, s); + + if (disk->SDD.ProductIdOffset) { + s = (PCHAR)&disk->SDD + disk->SDD.ProductIdOffset; + } else { + s.Empty(); + } + SET_TEXT(IDC_PRODUCT_ID, s); + + if (disk->SDD.SerialNumberOffset) { + s = (PCHAR)&disk->SDD + disk->SDD.SerialNumberOffset; + } else { + s.Empty(); + } + SET_TEXT(IDC_SERIAL_NUMBER, s); + + s = BusTypeString(disk->SDD.BusType); + SET_TEXT(IDC_BUS_TYPE, s); + + if (disk->SDD.RemovableMedia) { + s = "Removable"; + } else { + s = "RAW"; + if (disk->Layout) { + if (disk->Layout->PartitionStyle == PARTITION_STYLE_MBR) { + if (disk->Layout->PartitionEntry->Mbr.PartitionType + == PARTITION_LDM) { + s.LoadString(IDS_DISK_TYPE_DYN); + } else { + s.LoadString(IDS_DISK_TYPE_BASIC); + } + } else if (disk->Layout->PartitionStyle == PARTITION_STYLE_MBR) { + s = "GUID"; + } + } + } + SET_TEXT(IDC_DEVICE_TYPE, s); + + if (disk->bEjected) { + s = "No media"; + } else { + + /* set size */ + size = size * disk->DiskGeometry.BytesPerSector; + size = size * disk->DiskGeometry.SectorsPerTrack; + size = size * disk->DiskGeometry.TracksPerCylinder; + size = size * disk->DiskGeometry.Cylinders.QuadPart; + s.Format("%I64u", size); + SET_TEXT(IDC_TOTAL_SIZE, s); + + switch (disk->DiskGeometry.MediaType) { + case FixedMedia: s="Fixed"; break; + case RemovableMedia: s="Removable"; break; + case CD_ROM: s="CDROM"; break; + case CD_R: s="CDR"; break; + case CD_RW: s="CDRW"; break; + case DVD_ROM: s="DVD"; break; + case DVD_R: s="DVDR"; break; + case DVD_RW: s="DVDRW"; break; + default: s="Unkown"; + } + } + + SET_TEXT(IDC_MEDIA_TYPE, s); +} + + +void CProperties::SetCdrom(PEXT2_CDROM cdrom) +{ + CString s; + ULONGLONG size = 1; + + cbDiskBox->SetCurSel(cdrom->OrderNo + g_nDisks); + + ResetPartGroup(); + cbPartBox->ResetContent(); + cbPartBox->AddString("Media"); + cbPartBox->SetCurSel(0); + + SET_WIN(IDC_SDEV_CHANGE_MP, TRUE); + + if (0 == cdrom->DrvLetters) + SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); + + + if (cdrom->SDD.VendorIdOffset) { + s = (PCHAR)&cdrom->SDD + cdrom->SDD.VendorIdOffset; + } else { + s.Empty(); + } + SET_TEXT(IDC_VENDOR_ID, s); + + if (cdrom->SDD.ProductIdOffset) { + s = (PCHAR)&cdrom->SDD + cdrom->SDD.ProductIdOffset; + } else { + s.Empty(); + } + SET_TEXT(IDC_PRODUCT_ID, s); + + if (cdrom->SDD.SerialNumberOffset) { + s = (PCHAR)&cdrom->SDD + cdrom->SDD.SerialNumberOffset; + } else { + s.Empty(); + } + SET_TEXT(IDC_SERIAL_NUMBER, s); + + s = BusTypeString(cdrom->SDD.BusType); + SET_TEXT(IDC_BUS_TYPE, s); + + s.LoadString(IDS_DISK_TYPE_BASIC); + SET_TEXT(IDC_DEVICE_TYPE, s); + + if (cdrom->bLoaded) { + if (cdrom->bIsDVD) { + s = "DVD"; + } else { + s = "CDROM"; + } + size = size * cdrom->DiskGeometry.BytesPerSector; + size = size * cdrom->DiskGeometry.SectorsPerTrack; + size = size * cdrom->DiskGeometry.TracksPerCylinder; + size = size * cdrom->DiskGeometry.Cylinders.QuadPart; + } else { + s = "No media"; + size = 0; + } + SET_TEXT(IDC_MEDIA_TYPE, s); + + if (cdrom->bLoaded) { + if (cdrom->bEjected) { + s = "Media ejected"; + } else { + s.Format("%I64u", size); + SET_TEXT(IDC_TOTAL_SIZE, s); + SET_TEXT(IDC_SDEV_SIZE, s); + SET_TEXT(IDC_SDEV_FREE_SIZE, "0"); + + if (cdrom->EVP.bExt2) { + s = "EXT"; + s += (CHAR)('2' + cdrom->EVP.bExt3); + SET_WIN(IDC_SDEV_EXT2_INFO, TRUE); + } else { + s = "CDFS"; + } + SET_TEXT(IDC_FILE_SYSTEM, s); + + s = "Online,"; + switch (cdrom->DiskGeometry.MediaType) { + case FixedMedia: s +="Fixed"; break; + case RemovableMedia: s += "Media Removable"; break; + case CD_ROM: s +=" CDROM"; break; + case CD_R: s += "CDR"; break; + case CD_RW: s += "CDRW"; break; + case DVD_ROM: s += "DVD"; break; + case DVD_R: s += "DVDR"; break; + case DVD_RW: s += "DVDRW"; break; + default: s += "Unkown"; + } + } + } else { + s = "Device stopped"; + } + SET_TEXT(IDC_SDEV_STATUS, s); + + if (0 == cdrom->DrvLetters){ + SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); + } + + SET_TEXT(IDC_MOUNT_POINTS, + Ext2QueryVolumeLetterStrings( + cdrom->DrvLetters, NULL)); +} + +BOOL CProperties::OnInitDialog() +{ + CString str; + + CDialog::OnInitDialog(); + + for (ULONG i = 0; i < g_nDisks; i++) { + str.Format("DISK %u", i); + cbDiskBox->AddString(str.GetBuffer(str.GetLength())); + } + + for (ULONG i = 0; i < g_nCdroms; i++) { + str.Format("CDROM %u", i); + cbDiskBox->AddString(str.GetBuffer(str.GetLength())); + } + + SET_WIN(IDC_SDEV_CHANGE_MP, FALSE); + SET_WIN(IDC_SDEV_EXT2_INFO, FALSE); + SET_WIN(IDC_SDEV_QUICK_MOUNT, FALSE); + + if (m_bdisk) { + if (m_type == EXT2_DISK_MAGIC) { + m_disk = (PEXT2_DISK) m_sdev; + SetDisk(m_disk); + } else if (m_type == EXT2_PART_MAGIC) { + m_part = (PEXT2_PARTITION) m_sdev; + SetPartition(m_part); + if (0 == m_part->DrvLetters) + SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); + if (m_part->Volume && 0 == m_part->Volume->DrvLetters) + SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); + } else if (m_type == EXT2_DISK_NULL_MAGIC) { + m_disk = (PEXT2_DISK)m_sdev; + SetDisk(m_disk); + } else if (m_type == EXT2_CDROM_VOLUME_MAGIC) { + m_cdrom = (PEXT2_CDROM)m_sdev; + SetCdrom(m_cdrom); + if (0 == m_cdrom->DrvLetters) + SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); + } else if (m_type == EXT2_CDROM_DEVICE_MAGIC){ + m_cdrom = (PEXT2_CDROM)m_sdev; + SetCdrom(m_cdrom); + if (0 == m_cdrom->DrvLetters) + SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); + } + + if (m_disk && NULL == m_part) { + if (m_disk->bLoaded && m_disk->NumParts > 0) { + m_part = &m_disk->DataParts[0]; + SetPartition(m_part); + if (0 == m_part->DrvLetters) + SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); + if (m_part->Volume && 0 == m_part->Volume->DrvLetters) + SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); + } + } + + } else { + if (m_type == EXT2_VOLUME_MAGIC) { + m_volume = (PEXT2_VOLUME)m_sdev; + SetVolume(m_volume); + if (m_volume && 0 == m_volume->DrvLetters) { + SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); + } + } else { + ASSERT(m_type == EXT2_CDROM_DEVICE_MAGIC); + m_cdrom = (PEXT2_CDROM)m_sdev; + SetCdrom(m_cdrom); + if (0 == m_cdrom->DrvLetters) + SET_WIN(IDC_SDEV_QUICK_MOUNT, TRUE); + } + } + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + + +LRESULT CProperties::OnGroupBoxUpdated(WPARAM wParam,LPARAM lParam) +{ + ULONG i; + BOOL bChanged = FALSE; + + if (wParam == 'GB') { + if (lParam == 'DVLU') { + i = (ULONG)cbDiskBox->GetCurSel(); + if (i >= g_nDisks) { + if (m_disk != NULL || (m_cdrom != NULL && + m_cdrom != &gCdroms[i - g_nDisks])) { + m_disk = NULL; + m_part = NULL; + m_volume = NULL; + m_cdrom = &gCdroms[i - g_nDisks]; + bChanged = TRUE; + } else if (m_volume) { + m_volume = NULL; + m_cdrom = &gCdroms[i - g_nDisks]; + bChanged = TRUE; + } + } else { + if (m_cdrom != NULL || (m_disk != NULL && + m_disk != &gDisks[i])) { + m_disk = &gDisks[i]; + m_cdrom = NULL; + m_volume = NULL; + m_part = NULL; + bChanged = TRUE; + } else if (m_volume){ + m_volume = NULL; + m_disk = &gDisks[i]; + bChanged = TRUE; + } + } + + if (bChanged) { + + if (m_cdrom) { + SetCdrom(m_cdrom); + } + if (m_disk) { + SetDisk(m_disk); + if (m_disk->bLoaded && m_disk->NumParts > 0) { + m_part = &m_disk->DataParts[0]; + SetPartition(m_part); + } else { + m_part = NULL; + } + } + } + } + + if (lParam == 'PVLU') { + i = cbPartBox->GetCurSel(); + if (m_part && ((i + 1) != m_part->Number)) { + m_part = &m_disk->DataParts[i]; + SetPartition(m_part); + } + } + } + + return TRUE; +} diff --git a/Ext2Mgr/Properties.h b/Ext2Mgr/Properties.h index b1ede31..7666588 100644 --- a/Ext2Mgr/Properties.h +++ b/Ext2Mgr/Properties.h @@ -1,76 +1,76 @@ -#if !defined(AFX_PROPERTIES_H__859C5D61_7EA7_4CC1_B69A_200D175C4ECE__INCLUDED_) -#define AFX_PROPERTIES_H__859C5D61_7EA7_4CC1_B69A_200D175C4ECE__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// Properties.h : header file -// - -#include "DiskBox.h" -#include "PartBox.h" - -///////////////////////////////////////////////////////////////////////////// -// CProperties dialog - -class CProperties : public CDialog -{ -// Construction -public: - CProperties(CWnd* pParent = NULL); // standard constructor - - BOOL m_bdisk; - ULONG m_type; - PVOID m_sdev; - -// Dialog Data - //{{AFX_DATA(CProperties) - enum { IDD = IDD_PROPERTY_DIALOG }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CProperties) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - PEXT2_VOLUME m_volume; - PEXT2_CDROM m_cdrom; - PEXT2_DISK m_disk; - PEXT2_PARTITION m_part; - - CDiskBox m_DiskBox; - CPartBox m_PartBox; - - CComboBox *cbDiskBox; - CComboBox *cbPartBox; - - // Generated message map functions - //{{AFX_MSG(CProperties) - afx_msg void OnSdevChangeMp(); - afx_msg void OnSdevQuickMount(); - afx_msg void OnSdevExt2Info(); - virtual BOOL OnInitDialog(); - LRESULT OnGroupBoxUpdated(WPARAM wParam,LPARAM lParam); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - - void ResetDiskGroup(); - void ResetPartGroup(); - - void SetDisk(PEXT2_DISK disk); - void SetCdrom(PEXT2_CDROM cdrom); - void SetVolume(PEXT2_VOLUME volume); - void SetPartition(PEXT2_PARTITION part); -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_PROPERTIES_H__859C5D61_7EA7_4CC1_B69A_200D175C4ECE__INCLUDED_) +#if !defined(AFX_PROPERTIES_H__859C5D61_7EA7_4CC1_B69A_200D175C4ECE__INCLUDED_) +#define AFX_PROPERTIES_H__859C5D61_7EA7_4CC1_B69A_200D175C4ECE__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// Properties.h : header file +// + +#include "DiskBox.h" +#include "PartBox.h" + +///////////////////////////////////////////////////////////////////////////// +// CProperties dialog + +class CProperties : public CDialog +{ +// Construction +public: + CProperties(CWnd* pParent = NULL); // standard constructor + + BOOL m_bdisk; + ULONG m_type; + PVOID m_sdev; + +// Dialog Data + //{{AFX_DATA(CProperties) + enum { IDD = IDD_PROPERTY_DIALOG }; + // NOTE: the ClassWizard will add data members here + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CProperties) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + PEXT2_VOLUME m_volume; + PEXT2_CDROM m_cdrom; + PEXT2_DISK m_disk; + PEXT2_PARTITION m_part; + + CDiskBox m_DiskBox; + CPartBox m_PartBox; + + CComboBox *cbDiskBox; + CComboBox *cbPartBox; + + // Generated message map functions + //{{AFX_MSG(CProperties) + afx_msg void OnSdevChangeMp(); + afx_msg void OnSdevQuickMount(); + afx_msg void OnSdevExt2Info(); + virtual BOOL OnInitDialog(); + LRESULT OnGroupBoxUpdated(WPARAM wParam,LPARAM lParam); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + + void ResetDiskGroup(); + void ResetPartGroup(); + + void SetDisk(PEXT2_DISK disk); + void SetCdrom(PEXT2_CDROM cdrom); + void SetVolume(PEXT2_VOLUME volume); + void SetPartition(PEXT2_PARTITION part); +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_PROPERTIES_H__859C5D61_7EA7_4CC1_B69A_200D175C4ECE__INCLUDED_) diff --git a/Ext2Mgr/SelectDrvLetter.cpp b/Ext2Mgr/SelectDrvLetter.cpp index 281b993..6d6ddc5 100644 --- a/Ext2Mgr/SelectDrvLetter.cpp +++ b/Ext2Mgr/SelectDrvLetter.cpp @@ -1,166 +1,166 @@ -// SelectDrvLetter.cpp : implementation file -// - -#include "stdafx.h" -#include "ext2mgr.h" -#include "SelectDrvLetter.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CSelectDrvLetter dialog - - -CSelectDrvLetter::CSelectDrvLetter(CWnd* pParent /*=NULL*/) - : CDialog(CSelectDrvLetter::IDD, pParent) -{ - //{{AFX_DATA_INIT(CSelectDrvLetter) - m_DrvLetter = _T(""); - //}}AFX_DATA_INIT - - m_bMountMgr = TRUE; - m_bRegistry = FALSE; - m_bDosDev = FALSE; -} - - -void CSelectDrvLetter::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CSelectDrvLetter) - DDX_CBString(pDX, IDC_DRVLETTERS_LIST, m_DrvLetter); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CSelectDrvLetter, CDialog) - //{{AFX_MSG_MAP(CSelectDrvLetter) - ON_BN_CLICKED(IDC_DOSDEV_MP, OnDosdevMount) - ON_BN_CLICKED(IDC_PERMANENT_MP, OnMMgrMount) - ON_BN_CLICKED(IDC_REGISTRY_MP, OnRegistryMount) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CSelectDrvLetter message handlers - -void CSelectDrvLetter::OnOK() -{ - // TODO: Add extra validation here - UpdateData(TRUE); - - if (m_DrvLetter.IsEmpty()) { - AfxMessageBox("You must select a drive letter.", MB_OK|MB_ICONWARNING); - return; - } - - CComboBox *cbDrvLetter = (CComboBox *)GetDlgItem(IDC_DRVLETTERS_LIST); - if (cbDrvLetter) { - int rc = cbDrvLetter->FindStringExact(-1, m_DrvLetter); - if (rc == CB_ERR) { - AfxMessageBox("Invalid driver letter: "+m_DrvLetter, MB_OK|MB_ICONWARNING); - return; - } - } - CDialog::OnOK(); -} - -void CSelectDrvLetter::OnCancel() -{ - // TODO: Add extra cleanup here - m_DrvLetter.Empty(); - CDialog::OnCancel(); -} - -BOOL CSelectDrvLetter::OnInitDialog() -{ - CDialog::OnInitDialog(); - - // TODO: Add extra initialization here - - CComboBox *cbDrvLetter = (CComboBox *)GetDlgItem(IDC_DRVLETTERS_LIST); - if (cbDrvLetter) { - int i; - CHAR drvPath[]="A:\0"; - cbDrvLetter->ResetContent(); - for (i=2; i < 26; i++) { - if (!drvLetters[i].bUsed) { - drvPath[0] = drvLetters[i].Letter; - cbDrvLetter->AddString(drvPath); - } - } -/* - for (i=0; i < 10; i++) { - if (!drvDigits[i].bUsed) { - drvPath[0] = drvDigits[i].Letter; - cbDrvLetter->AddString(drvPath); - } - } -*/ - cbDrvLetter->SetCurSel(0); - } - UpdateData(FALSE); - - SET_CHECK(IDC_DOSDEV_MP, m_bDosDev); - SET_WIN(IDC_PERMANENT_MP, FALSE); - SET_CHECK(IDC_PERMANENT_MP, 0); - SET_CHECK(IDC_REGISTRY_MP, m_bRegistry); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void CSelectDrvLetter::OnDosdevMount() -{ - if (!m_bDosDev) { - m_bDosDev = !m_bDosDev; - if (m_bDosDev) { - m_bMountMgr = FALSE; - m_bRegistry = FALSE; - } - } - - SET_CHECK(IDC_DOSDEV_MP, m_bDosDev); - SET_CHECK(IDC_PERMANENT_MP, m_bMountMgr); - SET_CHECK(IDC_REGISTRY_MP, m_bRegistry); - - OnOK(); -} - -void CSelectDrvLetter::OnMMgrMount() -{ - if (!m_bMountMgr) { - m_bMountMgr = !m_bMountMgr; - if (m_bMountMgr) { - m_bDosDev = FALSE; - m_bRegistry = FALSE; - } - } - - SET_CHECK(IDC_DOSDEV_MP, m_bDosDev); - SET_CHECK(IDC_PERMANENT_MP, m_bMountMgr); - SET_CHECK(IDC_REGISTRY_MP, m_bRegistry); - - OnOK(); -} - -void CSelectDrvLetter::OnRegistryMount() -{ - if (!m_bRegistry) { - m_bRegistry = !m_bRegistry; - if (m_bRegistry) { - m_bDosDev = FALSE; - m_bMountMgr = FALSE; - } - } - - SET_CHECK(IDC_DOSDEV_MP, m_bDosDev); - SET_CHECK(IDC_PERMANENT_MP, m_bMountMgr); - SET_CHECK(IDC_REGISTRY_MP, m_bRegistry); - - OnOK(); -} +// SelectDrvLetter.cpp : implementation file +// + +#include "stdafx.h" +#include "ext2mgr.h" +#include "SelectDrvLetter.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CSelectDrvLetter dialog + + +CSelectDrvLetter::CSelectDrvLetter(CWnd* pParent /*=NULL*/) + : CDialog(CSelectDrvLetter::IDD, pParent) +{ + //{{AFX_DATA_INIT(CSelectDrvLetter) + m_DrvLetter = _T(""); + //}}AFX_DATA_INIT + + m_bMountMgr = TRUE; + m_bRegistry = FALSE; + m_bDosDev = FALSE; +} + + +void CSelectDrvLetter::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CSelectDrvLetter) + DDX_CBString(pDX, IDC_DRVLETTERS_LIST, m_DrvLetter); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CSelectDrvLetter, CDialog) + //{{AFX_MSG_MAP(CSelectDrvLetter) + ON_BN_CLICKED(IDC_DOSDEV_MP, OnDosdevMount) + ON_BN_CLICKED(IDC_PERMANENT_MP, OnMMgrMount) + ON_BN_CLICKED(IDC_REGISTRY_MP, OnRegistryMount) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CSelectDrvLetter message handlers + +void CSelectDrvLetter::OnOK() +{ + // TODO: Add extra validation here + UpdateData(TRUE); + + if (m_DrvLetter.IsEmpty()) { + AfxMessageBox("You must select a drive letter.", MB_OK|MB_ICONWARNING); + return; + } + + CComboBox *cbDrvLetter = (CComboBox *)GetDlgItem(IDC_DRVLETTERS_LIST); + if (cbDrvLetter) { + int rc = cbDrvLetter->FindStringExact(-1, m_DrvLetter); + if (rc == CB_ERR) { + AfxMessageBox("Invalid driver letter: "+m_DrvLetter, MB_OK|MB_ICONWARNING); + return; + } + } + CDialog::OnOK(); +} + +void CSelectDrvLetter::OnCancel() +{ + // TODO: Add extra cleanup here + m_DrvLetter.Empty(); + CDialog::OnCancel(); +} + +BOOL CSelectDrvLetter::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // TODO: Add extra initialization here + + CComboBox *cbDrvLetter = (CComboBox *)GetDlgItem(IDC_DRVLETTERS_LIST); + if (cbDrvLetter) { + int i; + CHAR drvPath[]="A:\0"; + cbDrvLetter->ResetContent(); + for (i=2; i < 26; i++) { + if (!drvLetters[i].bUsed) { + drvPath[0] = drvLetters[i].Letter; + cbDrvLetter->AddString(drvPath); + } + } +/* + for (i=0; i < 10; i++) { + if (!drvDigits[i].bUsed) { + drvPath[0] = drvDigits[i].Letter; + cbDrvLetter->AddString(drvPath); + } + } +*/ + cbDrvLetter->SetCurSel(0); + } + UpdateData(FALSE); + + SET_CHECK(IDC_DOSDEV_MP, m_bDosDev); + SET_WIN(IDC_PERMANENT_MP, FALSE); + SET_CHECK(IDC_PERMANENT_MP, 0); + SET_CHECK(IDC_REGISTRY_MP, m_bRegistry); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void CSelectDrvLetter::OnDosdevMount() +{ + if (!m_bDosDev) { + m_bDosDev = !m_bDosDev; + if (m_bDosDev) { + m_bMountMgr = FALSE; + m_bRegistry = FALSE; + } + } + + SET_CHECK(IDC_DOSDEV_MP, m_bDosDev); + SET_CHECK(IDC_PERMANENT_MP, m_bMountMgr); + SET_CHECK(IDC_REGISTRY_MP, m_bRegistry); + + OnOK(); +} + +void CSelectDrvLetter::OnMMgrMount() +{ + if (!m_bMountMgr) { + m_bMountMgr = !m_bMountMgr; + if (m_bMountMgr) { + m_bDosDev = FALSE; + m_bRegistry = FALSE; + } + } + + SET_CHECK(IDC_DOSDEV_MP, m_bDosDev); + SET_CHECK(IDC_PERMANENT_MP, m_bMountMgr); + SET_CHECK(IDC_REGISTRY_MP, m_bRegistry); + + OnOK(); +} + +void CSelectDrvLetter::OnRegistryMount() +{ + if (!m_bRegistry) { + m_bRegistry = !m_bRegistry; + if (m_bRegistry) { + m_bDosDev = FALSE; + m_bMountMgr = FALSE; + } + } + + SET_CHECK(IDC_DOSDEV_MP, m_bDosDev); + SET_CHECK(IDC_PERMANENT_MP, m_bMountMgr); + SET_CHECK(IDC_REGISTRY_MP, m_bRegistry); + + OnOK(); +} diff --git a/Ext2Mgr/SelectDrvLetter.h b/Ext2Mgr/SelectDrvLetter.h index f277a67..910c732 100644 --- a/Ext2Mgr/SelectDrvLetter.h +++ b/Ext2Mgr/SelectDrvLetter.h @@ -1,54 +1,54 @@ -#if !defined(AFX_SELECTDRVLETTER_H__8FE3FD0E_B375_4956_B36F_733A7EEF2892__INCLUDED_) -#define AFX_SELECTDRVLETTER_H__8FE3FD0E_B375_4956_B36F_733A7EEF2892__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// SelectDrvLetter.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// CSelectDrvLetter dialog - -class CSelectDrvLetter : public CDialog -{ -// Construction -public: - CSelectDrvLetter(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CSelectDrvLetter) - enum { IDD = IDD_NEW_MOUNTPOINT }; - CString m_DrvLetter; - //}}AFX_DATA - - BOOL m_bMountMgr; - BOOL m_bRegistry; - BOOL m_bDosDev; - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CSelectDrvLetter) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CSelectDrvLetter) - virtual void OnOK(); - virtual void OnCancel(); - virtual BOOL OnInitDialog(); - afx_msg void OnDosdevMount(); - afx_msg void OnMMgrMount(); - afx_msg void OnRegistryMount(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_SELECTDRVLETTER_H__8FE3FD0E_B375_4956_B36F_733A7EEF2892__INCLUDED_) +#if !defined(AFX_SELECTDRVLETTER_H__8FE3FD0E_B375_4956_B36F_733A7EEF2892__INCLUDED_) +#define AFX_SELECTDRVLETTER_H__8FE3FD0E_B375_4956_B36F_733A7EEF2892__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// SelectDrvLetter.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CSelectDrvLetter dialog + +class CSelectDrvLetter : public CDialog +{ +// Construction +public: + CSelectDrvLetter(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CSelectDrvLetter) + enum { IDD = IDD_NEW_MOUNTPOINT }; + CString m_DrvLetter; + //}}AFX_DATA + + BOOL m_bMountMgr; + BOOL m_bRegistry; + BOOL m_bDosDev; + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CSelectDrvLetter) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CSelectDrvLetter) + virtual void OnOK(); + virtual void OnCancel(); + virtual BOOL OnInitDialog(); + afx_msg void OnDosdevMount(); + afx_msg void OnMMgrMount(); + afx_msg void OnRegistryMount(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_SELECTDRVLETTER_H__8FE3FD0E_B375_4956_B36F_733A7EEF2892__INCLUDED_) diff --git a/Ext2Mgr/ServiceManage.cpp b/Ext2Mgr/ServiceManage.cpp index a873f87..ee105bc 100644 --- a/Ext2Mgr/ServiceManage.cpp +++ b/Ext2Mgr/ServiceManage.cpp @@ -1,222 +1,222 @@ -// ServiceManage.cpp : implementation file -// - -#include "stdafx.h" -#include "ext2mgr.h" -#include "ServiceManage.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CServiceManage dialog - - -CServiceManage::CServiceManage(CWnd* pParent /*=NULL*/) - : CDialog(CServiceManage::IDD, pParent) -{ - //{{AFX_DATA_INIT(CServiceManage) - m_Codepage = _T(""); - m_bExt3Writable = FALSE; - m_bReadonly = FALSE; - m_srvStatus = _T(""); - m_sPrefix = _T(""); - m_sSuffix = _T(""); - m_bAutoMount = FALSE; - //}}AFX_DATA_INIT - - m_nStartmode = 0; - - m_bStarted = Ext2IsServiceStarted(); - - if (m_bStarted) { - m_srvStatus = _T("Ext2Fsd is already started."); - } else { - m_srvStatus = _T("Ext2Fsd is NOT started."); - } - - m_bInited = TRUE; -} - - -void CServiceManage::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CServiceManage) - DDX_CBString(pDX, IDC_COMBO_CODEPAGE, m_Codepage); - DDX_Check(pDX, IDC_EXT3_WRITABLE, m_bExt3Writable); - DDX_Check(pDX, IDC_READ_ONLY, m_bReadonly); - DDX_Text(pDX, IDC_SERVICE_STATUS, m_srvStatus); - DDX_Text(pDX, IDC_GLOBAL_PREFIX, m_sPrefix); - DDV_MaxChars(pDX, m_sPrefix, 31); - DDX_Text(pDX, IDC_GLOBAL_SUFFIX, m_sSuffix); - DDV_MaxChars(pDX, m_sSuffix, 31); - DDX_Check(pDX, IDC_EXT3_AUTOMOUNT, m_bAutoMount); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CServiceManage, CDialog) - //{{AFX_MSG_MAP(CServiceManage) - ON_BN_CLICKED(IDC_READ_ONLY, OnReadOnly) - ON_BN_CLICKED(IDC_EXT3_WRITABLE, OnExt3Writable) - ON_BN_CLICKED(IDC_START_SERVICE, OnStartService) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CServiceManage message handlers - -void CServiceManage::OnReadOnly() -{ - // TODO: Add your control notification handler code here - UpdateData(TRUE); - - if (m_bReadonly) { - m_bExt3Writable = FALSE; - } - SET_WIN(IDC_EXT3_WRITABLE, !m_bReadonly); - - UpdateData(FALSE); -} - -void CServiceManage::OnExt3Writable() -{ - // TODO: Add your control notification handler code here - -} - -void CServiceManage::OnCancel() -{ - // TODO: Add extra cleanup here - - CDialog::OnCancel(); -} - -void CServiceManage::OnOK() -{ - BOOL rc; - - // TODO: Add extra validation here - UpdateData(TRUE); - - CComboBox *cbStartup = (CComboBox *)GetDlgItem(IDC_COMBO_STARTUP); - if (cbStartup) { - m_nStartmode = cbStartup->GetCurSel(); - } else { - m_nStartmode = CB_ERR; - } - - if (m_nStartmode == CB_ERR) { - AfxMessageBox("Invalid startup mode !", MB_OK|MB_ICONWARNING); - return; - } - - if (m_Codepage.IsEmpty()) { - AfxMessageBox("You must select a codepage type.", MB_OK|MB_ICONWARNING); - return; - } - - CComboBox *cbCodepage = (CComboBox *)GetDlgItem(IDC_COMBO_CODEPAGE); - if (cbCodepage) { - int rc = cbCodepage->FindStringExact(-1, m_Codepage); - if (rc == CB_ERR) { - AfxMessageBox("Invalid codepage type: "+m_Codepage, MB_OK|MB_ICONWARNING); - return; - } - } - - if (AfxMessageBox("Current service settings will be overwritten,\ndo you want continue ?", - MB_YESNO | MB_ICONQUESTION) != IDYES) { - return; - } - - rc = Ext2SetGlobalProperty( - m_nStartmode, - (BOOLEAN)m_bReadonly, - (BOOLEAN)m_bExt3Writable, - m_Codepage.GetBuffer(CODEPAGE_MAXLEN), - m_sPrefix.GetBuffer(HIDINGPAT_LEN), - m_sSuffix.GetBuffer(HIDINGPAT_LEN), - (BOOLEAN)m_bAutoMount - ); - - if (rc) { -/* - AfxMessageBox("Ext2 service settings updated successfully !", - MB_OK | MB_ICONINFORMATION); -*/ - CDialog::OnOK(); - } else { - AfxMessageBox("Failed to save the service settings !", - MB_OK | MB_ICONWARNING); - } -} - -BOOL CServiceManage::OnInitDialog() -{ - CDialog::OnInitDialog(); - - CComboBox *cbStartup = (CComboBox *)GetDlgItem(IDC_COMBO_STARTUP); - if (cbStartup) { - cbStartup->ResetContent(); - cbStartup->AddString(_T("SERVICE_BOOT_START")); - cbStartup->AddString(_T("SERVICE_SYSTEM_START")); - cbStartup->AddString(_T("SERVICE_AUTO_START")); - cbStartup->AddString(_T("SERVICE_DEMAND_START")); - cbStartup->AddString(_T("SERVICE_DISABLED")); - cbStartup->SetCurSel(m_nStartmode); - } - - CComboBox *cbCodepage = (CComboBox *)GetDlgItem(IDC_COMBO_CODEPAGE); - if (cbCodepage) { - int i = 0, j = -1; - cbCodepage->ResetContent(); - while (gCodepages[i]) { - cbCodepage->AddString(gCodepages[i]); - if (!m_Codepage.IsEmpty()) { - CHAR *buffer = m_Codepage.GetBuffer(CODEPAGE_MAXLEN); - if (_stricmp(buffer, gCodepages[i]) == 0) { - j = i; - } - } - i++; - } - if (j == -1) { - m_Codepage = "default"; - } - } - - if (m_bReadonly) { - m_bExt3Writable = FALSE; - } - - SET_WIN(IDC_EXT3_WRITABLE, !m_bReadonly); - SET_WIN(IDC_START_SERVICE, !m_bStarted); - - UpdateData(FALSE); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void CServiceManage::OnStartService() -{ - // TODO: Add your control notification handler code here - - m_bStarted = Ext2StartExt2Fsd(); - - if (m_bStarted) { - m_srvStatus = _T("Ext2Fsd was just started."); - GetParent()->SetTimer('REFF', 500, NULL); - GetParent()->SetTimer('REFR', 3000, NULL); - } else { - m_srvStatus = _T("Ext2Fsd could NOT be started."); - } - - SET_WIN(IDC_START_SERVICE, !m_bStarted); - UpdateData(FALSE); -} +// ServiceManage.cpp : implementation file +// + +#include "stdafx.h" +#include "ext2mgr.h" +#include "ServiceManage.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CServiceManage dialog + + +CServiceManage::CServiceManage(CWnd* pParent /*=NULL*/) + : CDialog(CServiceManage::IDD, pParent) +{ + //{{AFX_DATA_INIT(CServiceManage) + m_Codepage = _T(""); + m_bExt3Writable = FALSE; + m_bReadonly = FALSE; + m_srvStatus = _T(""); + m_sPrefix = _T(""); + m_sSuffix = _T(""); + m_bAutoMount = FALSE; + //}}AFX_DATA_INIT + + m_nStartmode = 0; + + m_bStarted = Ext2IsServiceStarted(); + + if (m_bStarted) { + m_srvStatus = _T("Ext2Fsd is already started."); + } else { + m_srvStatus = _T("Ext2Fsd is NOT started."); + } + + m_bInited = TRUE; +} + + +void CServiceManage::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CServiceManage) + DDX_CBString(pDX, IDC_COMBO_CODEPAGE, m_Codepage); + DDX_Check(pDX, IDC_EXT3_WRITABLE, m_bExt3Writable); + DDX_Check(pDX, IDC_READ_ONLY, m_bReadonly); + DDX_Text(pDX, IDC_SERVICE_STATUS, m_srvStatus); + DDX_Text(pDX, IDC_GLOBAL_PREFIX, m_sPrefix); + DDV_MaxChars(pDX, m_sPrefix, 31); + DDX_Text(pDX, IDC_GLOBAL_SUFFIX, m_sSuffix); + DDV_MaxChars(pDX, m_sSuffix, 31); + DDX_Check(pDX, IDC_EXT3_AUTOMOUNT, m_bAutoMount); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CServiceManage, CDialog) + //{{AFX_MSG_MAP(CServiceManage) + ON_BN_CLICKED(IDC_READ_ONLY, OnReadOnly) + ON_BN_CLICKED(IDC_EXT3_WRITABLE, OnExt3Writable) + ON_BN_CLICKED(IDC_START_SERVICE, OnStartService) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CServiceManage message handlers + +void CServiceManage::OnReadOnly() +{ + // TODO: Add your control notification handler code here + UpdateData(TRUE); + + if (m_bReadonly) { + m_bExt3Writable = FALSE; + } + SET_WIN(IDC_EXT3_WRITABLE, !m_bReadonly); + + UpdateData(FALSE); +} + +void CServiceManage::OnExt3Writable() +{ + // TODO: Add your control notification handler code here + +} + +void CServiceManage::OnCancel() +{ + // TODO: Add extra cleanup here + + CDialog::OnCancel(); +} + +void CServiceManage::OnOK() +{ + BOOL rc; + + // TODO: Add extra validation here + UpdateData(TRUE); + + CComboBox *cbStartup = (CComboBox *)GetDlgItem(IDC_COMBO_STARTUP); + if (cbStartup) { + m_nStartmode = cbStartup->GetCurSel(); + } else { + m_nStartmode = CB_ERR; + } + + if (m_nStartmode == CB_ERR) { + AfxMessageBox("Invalid startup mode !", MB_OK|MB_ICONWARNING); + return; + } + + if (m_Codepage.IsEmpty()) { + AfxMessageBox("You must select a codepage type.", MB_OK|MB_ICONWARNING); + return; + } + + CComboBox *cbCodepage = (CComboBox *)GetDlgItem(IDC_COMBO_CODEPAGE); + if (cbCodepage) { + int rc = cbCodepage->FindStringExact(-1, m_Codepage); + if (rc == CB_ERR) { + AfxMessageBox("Invalid codepage type: "+m_Codepage, MB_OK|MB_ICONWARNING); + return; + } + } + + if (AfxMessageBox("Current service settings will be overwritten,\ndo you want continue ?", + MB_YESNO | MB_ICONQUESTION) != IDYES) { + return; + } + + rc = Ext2SetGlobalProperty( + m_nStartmode, + (BOOLEAN)m_bReadonly, + (BOOLEAN)m_bExt3Writable, + m_Codepage.GetBuffer(CODEPAGE_MAXLEN), + m_sPrefix.GetBuffer(HIDINGPAT_LEN), + m_sSuffix.GetBuffer(HIDINGPAT_LEN), + (BOOLEAN)m_bAutoMount + ); + + if (rc) { +/* + AfxMessageBox("Ext2 service settings updated successfully !", + MB_OK | MB_ICONINFORMATION); +*/ + CDialog::OnOK(); + } else { + AfxMessageBox("Failed to save the service settings !", + MB_OK | MB_ICONWARNING); + } +} + +BOOL CServiceManage::OnInitDialog() +{ + CDialog::OnInitDialog(); + + CComboBox *cbStartup = (CComboBox *)GetDlgItem(IDC_COMBO_STARTUP); + if (cbStartup) { + cbStartup->ResetContent(); + cbStartup->AddString(_T("SERVICE_BOOT_START")); + cbStartup->AddString(_T("SERVICE_SYSTEM_START")); + cbStartup->AddString(_T("SERVICE_AUTO_START")); + cbStartup->AddString(_T("SERVICE_DEMAND_START")); + cbStartup->AddString(_T("SERVICE_DISABLED")); + cbStartup->SetCurSel(m_nStartmode); + } + + CComboBox *cbCodepage = (CComboBox *)GetDlgItem(IDC_COMBO_CODEPAGE); + if (cbCodepage) { + int i = 0, j = -1; + cbCodepage->ResetContent(); + while (gCodepages[i]) { + cbCodepage->AddString(gCodepages[i]); + if (!m_Codepage.IsEmpty()) { + CHAR *buffer = m_Codepage.GetBuffer(CODEPAGE_MAXLEN); + if (_stricmp(buffer, gCodepages[i]) == 0) { + j = i; + } + } + i++; + } + if (j == -1) { + m_Codepage = "default"; + } + } + + if (m_bReadonly) { + m_bExt3Writable = FALSE; + } + + SET_WIN(IDC_EXT3_WRITABLE, !m_bReadonly); + SET_WIN(IDC_START_SERVICE, !m_bStarted); + + UpdateData(FALSE); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void CServiceManage::OnStartService() +{ + // TODO: Add your control notification handler code here + + m_bStarted = Ext2StartExt2Fsd(); + + if (m_bStarted) { + m_srvStatus = _T("Ext2Fsd was just started."); + GetParent()->SetTimer('REFF', 500, NULL); + GetParent()->SetTimer('REFR', 3000, NULL); + } else { + m_srvStatus = _T("Ext2Fsd could NOT be started."); + } + + SET_WIN(IDC_START_SERVICE, !m_bStarted); + UpdateData(FALSE); +} diff --git a/Ext2Mgr/ServiceManage.h b/Ext2Mgr/ServiceManage.h index ed07972..ef22a1d 100644 --- a/Ext2Mgr/ServiceManage.h +++ b/Ext2Mgr/ServiceManage.h @@ -1,59 +1,59 @@ -#if !defined(AFX_SERVICEMANAGE_H__1B7348C0_0EC3_43D1_8E39_25D5F1113B8E__INCLUDED_) -#define AFX_SERVICEMANAGE_H__1B7348C0_0EC3_43D1_8E39_25D5F1113B8E__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// ServiceManage.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// CServiceManage dialog - -class CServiceManage : public CDialog -{ -// Construction -public: - CServiceManage(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CServiceManage) - enum { IDD = IDD_SERVICE_MANAGE }; - CString m_Codepage; - BOOL m_bExt3Writable; - BOOL m_bReadonly; - CString m_srvStatus; - CString m_sPrefix; - CString m_sSuffix; - BOOL m_bAutoMount; - //}}AFX_DATA - ULONG m_nStartmode; - BOOL m_bInited; - BOOL m_bStarted; - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CServiceManage) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CServiceManage) - afx_msg void OnReadOnly(); - afx_msg void OnExt3Writable(); - virtual void OnCancel(); - virtual void OnOK(); - virtual BOOL OnInitDialog(); - afx_msg void OnStartService(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_SERVICEMANAGE_H__1B7348C0_0EC3_43D1_8E39_25D5F1113B8E__INCLUDED_) +#if !defined(AFX_SERVICEMANAGE_H__1B7348C0_0EC3_43D1_8E39_25D5F1113B8E__INCLUDED_) +#define AFX_SERVICEMANAGE_H__1B7348C0_0EC3_43D1_8E39_25D5F1113B8E__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// ServiceManage.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CServiceManage dialog + +class CServiceManage : public CDialog +{ +// Construction +public: + CServiceManage(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CServiceManage) + enum { IDD = IDD_SERVICE_MANAGE }; + CString m_Codepage; + BOOL m_bExt3Writable; + BOOL m_bReadonly; + CString m_srvStatus; + CString m_sPrefix; + CString m_sSuffix; + BOOL m_bAutoMount; + //}}AFX_DATA + ULONG m_nStartmode; + BOOL m_bInited; + BOOL m_bStarted; + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CServiceManage) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CServiceManage) + afx_msg void OnReadOnly(); + afx_msg void OnExt3Writable(); + virtual void OnCancel(); + virtual void OnOK(); + virtual BOOL OnInitDialog(); + afx_msg void OnStartService(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_SERVICEMANAGE_H__1B7348C0_0EC3_43D1_8E39_25D5F1113B8E__INCLUDED_) diff --git a/Ext2Mgr/Splash.cpp b/Ext2Mgr/Splash.cpp index 3af4fb9..8b3e64a 100644 --- a/Ext2Mgr/Splash.cpp +++ b/Ext2Mgr/Splash.cpp @@ -1,284 +1,284 @@ -// =========================================================================== -// File Splash.cpp -// Desc The implementation file for the CSplash class. -// =========================================================================== - -#include "stdafx.h" -#include "splash.h" -#include "windowsx.h" - -// =========================================================================== -// The following is used for layering support which is used in the -// splash screen for transparency. In VC 6 these are not defined in the headers -// for user32.dll and hence we use mechanisms so that it can work in VC 6. -// We define the flags here and write code so that we can load the function -// from User32.dll explicitely and use it. This code requires Win2k and above -// to work. -// =========================================================================== -typedef BOOL (WINAPI *lpfnSetLayeredWindowAttributes) - (HWND hWnd, COLORREF cr, BYTE bAlpha, DWORD dwFlags); - -lpfnSetLayeredWindowAttributes g_pSetLayeredWindowAttributes; - -#define WS_EX_LAYERED 0x00080000 - -// =========================================================================== -// Func ExtWndProc -// Desc The windows procedure that is used to forward messages to the -// CSplash class. CSplash sends the "this" pointer through the -// CreateWindowEx call and the pointer reaches here in the -// WM_CREATE message. We store it here and use it for message -// forwarding. -// =========================================================================== -static LRESULT CALLBACK ExtWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - static CSplash * spl = NULL; - if(uMsg == WM_CREATE) - { - spl = (CSplash*)((LPCREATESTRUCT)lParam)->lpCreateParams; - } - if(spl) - return spl->WindowProc(hwnd, uMsg, wParam, lParam); - else - return DefWindowProc (hwnd, uMsg, wParam, lParam); -} - -LRESULT CALLBACK CSplash::WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - // We need to handle on the WM_PAINT message - switch(uMsg) - { - HANDLE_MSG(hwnd, WM_PAINT, OnPaint); -#if 0 - // Stop flicker when splash screen appears - case WM_ERASEBKGND: - // stop the default processing of this message - // by returning 1 - return (LRESULT)1; // say we handled it -#endif - } - - return DefWindowProc (hwnd, uMsg, wParam, lParam) ; -} - -void CSplash:: OnPaint(HWND hwnd) -{ - if (!m_hBitmap) - return; - - // ======================================================================= - // Paint the background by BitBlting the bitmap - // ======================================================================= - PAINTSTRUCT ps ; - HDC hDC = BeginPaint (hwnd, &ps) ; - - RECT rect; - ::GetClientRect(m_hwnd, &rect); - - HDC hMemDC = ::CreateCompatibleDC(hDC); - HBITMAP hOldBmp = (HBITMAP)::SelectObject(hMemDC, m_hBitmap); - - BitBlt(hDC, 0, 0, m_dwWidth, m_dwHeight, hMemDC, 0, 0, SRCCOPY); - - ::SelectObject(hMemDC, hOldBmp); - - ::DeleteDC(hMemDC); - - EndPaint (hwnd, &ps) ; -} - -void CSplash::Init() -{ - // ======================================================================= - // Initialize the variables - // ======================================================================= - m_hwnd = NULL; - m_lpszClassName = TEXT("Ext2 Volume Manager Splash Screen"); - m_colTrans = 0; - - // ======================================================================= - // Keep the function pointer for the SetLayeredWindowAttributes function - // in User32.dll ready - // ======================================================================= - HMODULE hUser32 = GetModuleHandle(TEXT("USER32.DLL")); - - g_pSetLayeredWindowAttributes = (lpfnSetLayeredWindowAttributes) - GetProcAddress(hUser32, "SetLayeredWindowAttributes"); -} - -CSplash::CSplash() -{ - Init(); -} - -CSplash::CSplash(UINT id, COLORREF colTrans) -{ - Init(); - - SetBitmap(id); - SetTransparentColor(colTrans); -} - -CSplash::~CSplash() -{ - FreeResources(); -} - -HWND CSplash::RegAndCreateWindow() -{ - // ======================================================================= - // Register the window with ExtWndProc as the window procedure - // ======================================================================= - WNDCLASSEX wndclass; - wndclass.cbSize = sizeof (wndclass); - wndclass.style = CS_BYTEALIGNCLIENT | CS_BYTEALIGNWINDOW; - wndclass.lpfnWndProc = ExtWndProc; - wndclass.cbClsExtra = 0; - wndclass.cbWndExtra = DLGWINDOWEXTRA; - wndclass.hInstance = ::GetModuleHandle(NULL); - wndclass.hIcon = NULL; - wndclass.hCursor = ::LoadCursor( NULL, IDC_WAIT ); - wndclass.hbrBackground = (HBRUSH)::GetStockObject(LTGRAY_BRUSH); - wndclass.lpszMenuName = NULL; - wndclass.lpszClassName = m_lpszClassName; - wndclass.hIconSm = NULL; - - if(!RegisterClassEx (&wndclass)) - return NULL; - - // ======================================================================= - // Create the window of the application, passing the this pointer so that - // ExtWndProc can use that for message forwarding - // ======================================================================= - DWORD nScrWidth = ::GetSystemMetrics(SM_CXFULLSCREEN); - DWORD nScrHeight = ::GetSystemMetrics(SM_CYFULLSCREEN); - - int x = (nScrWidth - m_dwWidth) / 2; - int y = (nScrHeight - m_dwHeight) / 2; - m_hwnd = ::CreateWindowEx(WS_EX_TOPMOST|WS_EX_TOOLWINDOW, m_lpszClassName, - TEXT("Ext2 Volume Manager"), WS_POPUP, x, y, - m_dwWidth, m_dwHeight, NULL, NULL, NULL, this); - - // ======================================================================= - // Display the window - // ======================================================================= - if(m_hwnd) - { - MakeTransparent(); - ShowWindow (m_hwnd, SW_SHOW) ; - UpdateWindow (m_hwnd); - } - return m_hwnd; -} - -int CSplash::DoLoop() -{ - // ======================================================================= - // Show the window - // ======================================================================= - if(!m_hwnd) - ShowSplash(); - - // ======================================================================= - // Get into the modal loop - // ======================================================================= - MSG msg ; - while (GetMessage (&msg, NULL, 0, 0)) - { - TranslateMessage (&msg) ; - DispatchMessage (&msg) ; - } - - return (int)msg.wParam ; - -} - -void CSplash::ShowSplash() -{ - CloseSplash(); - RegAndCreateWindow(); -} - - -DWORD CSplash::SetBitmap(UINT id) -{ - // ======================================================================= - // load the bitmap - // ======================================================================= - HBITMAP hBitmap = NULL; - hBitmap = (HBITMAP)::LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(id), - IMAGE_BITMAP, 0, 0, 0); - return SetBitmap(hBitmap); -} - -DWORD CSplash::SetBitmap(HBITMAP hBitmap) -{ - int nRetValue; - BITMAP csBitmapSize; - - // ======================================================================= - // Free loaded resource - // ======================================================================= - FreeResources(); - - if (hBitmap) - { - m_hBitmap = hBitmap; - - // =================================================================== - // Get bitmap size - // =================================================================== - nRetValue = ::GetObject(hBitmap, sizeof(csBitmapSize), &csBitmapSize); - if (nRetValue == 0) - { - FreeResources(); - return 0; - } - m_dwWidth = (DWORD)csBitmapSize.bmWidth; - m_dwHeight = (DWORD)csBitmapSize.bmHeight; - } - - return 1; -} - -void CSplash::FreeResources() -{ - if (m_hBitmap) - ::DeleteObject (m_hBitmap); - m_hBitmap = NULL; -} - -int CSplash::CloseSplash() -{ - - if(m_hwnd) - { - DestroyWindow(m_hwnd); - m_hwnd = 0; - UnregisterClass(m_lpszClassName, ::GetModuleHandle(NULL)); - return 1; - } - return 0; -} - -bool CSplash::SetTransparentColor(COLORREF col) -{ - m_colTrans = col; - - return MakeTransparent(); -} - -bool CSplash::MakeTransparent() -{ - // ======================================================================= - // Set the layered window style and make the required color transparent - // ======================================================================= - if(m_hwnd && g_pSetLayeredWindowAttributes && m_colTrans ) - { - // set layered style for the window - SetWindowLongPtr(m_hwnd, GWL_EXSTYLE, GetWindowLongPtr(m_hwnd, GWL_EXSTYLE) | WS_EX_LAYERED); - // call it with 0 alpha for the given color - g_pSetLayeredWindowAttributes(m_hwnd, m_colTrans, 0, LWA_COLORKEY); - } - return TRUE; -} +// =========================================================================== +// File Splash.cpp +// Desc The implementation file for the CSplash class. +// =========================================================================== + +#include "stdafx.h" +#include "splash.h" +#include "windowsx.h" + +// =========================================================================== +// The following is used for layering support which is used in the +// splash screen for transparency. In VC 6 these are not defined in the headers +// for user32.dll and hence we use mechanisms so that it can work in VC 6. +// We define the flags here and write code so that we can load the function +// from User32.dll explicitely and use it. This code requires Win2k and above +// to work. +// =========================================================================== +typedef BOOL (WINAPI *lpfnSetLayeredWindowAttributes) + (HWND hWnd, COLORREF cr, BYTE bAlpha, DWORD dwFlags); + +lpfnSetLayeredWindowAttributes g_pSetLayeredWindowAttributes; + +#define WS_EX_LAYERED 0x00080000 + +// =========================================================================== +// Func ExtWndProc +// Desc The windows procedure that is used to forward messages to the +// CSplash class. CSplash sends the "this" pointer through the +// CreateWindowEx call and the pointer reaches here in the +// WM_CREATE message. We store it here and use it for message +// forwarding. +// =========================================================================== +static LRESULT CALLBACK ExtWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + static CSplash * spl = NULL; + if(uMsg == WM_CREATE) + { + spl = (CSplash*)((LPCREATESTRUCT)lParam)->lpCreateParams; + } + if(spl) + return spl->WindowProc(hwnd, uMsg, wParam, lParam); + else + return DefWindowProc (hwnd, uMsg, wParam, lParam); +} + +LRESULT CALLBACK CSplash::WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + // We need to handle on the WM_PAINT message + switch(uMsg) + { + HANDLE_MSG(hwnd, WM_PAINT, OnPaint); +#if 0 + // Stop flicker when splash screen appears + case WM_ERASEBKGND: + // stop the default processing of this message + // by returning 1 + return (LRESULT)1; // say we handled it +#endif + } + + return DefWindowProc (hwnd, uMsg, wParam, lParam) ; +} + +void CSplash:: OnPaint(HWND hwnd) +{ + if (!m_hBitmap) + return; + + // ======================================================================= + // Paint the background by BitBlting the bitmap + // ======================================================================= + PAINTSTRUCT ps ; + HDC hDC = BeginPaint (hwnd, &ps) ; + + RECT rect; + ::GetClientRect(m_hwnd, &rect); + + HDC hMemDC = ::CreateCompatibleDC(hDC); + HBITMAP hOldBmp = (HBITMAP)::SelectObject(hMemDC, m_hBitmap); + + BitBlt(hDC, 0, 0, m_dwWidth, m_dwHeight, hMemDC, 0, 0, SRCCOPY); + + ::SelectObject(hMemDC, hOldBmp); + + ::DeleteDC(hMemDC); + + EndPaint (hwnd, &ps) ; +} + +void CSplash::Init() +{ + // ======================================================================= + // Initialize the variables + // ======================================================================= + m_hwnd = NULL; + m_lpszClassName = TEXT("Ext2 Volume Manager Splash Screen"); + m_colTrans = 0; + + // ======================================================================= + // Keep the function pointer for the SetLayeredWindowAttributes function + // in User32.dll ready + // ======================================================================= + HMODULE hUser32 = GetModuleHandle(TEXT("USER32.DLL")); + + g_pSetLayeredWindowAttributes = (lpfnSetLayeredWindowAttributes) + GetProcAddress(hUser32, "SetLayeredWindowAttributes"); +} + +CSplash::CSplash() +{ + Init(); +} + +CSplash::CSplash(UINT id, COLORREF colTrans) +{ + Init(); + + SetBitmap(id); + SetTransparentColor(colTrans); +} + +CSplash::~CSplash() +{ + FreeResources(); +} + +HWND CSplash::RegAndCreateWindow() +{ + // ======================================================================= + // Register the window with ExtWndProc as the window procedure + // ======================================================================= + WNDCLASSEX wndclass; + wndclass.cbSize = sizeof (wndclass); + wndclass.style = CS_BYTEALIGNCLIENT | CS_BYTEALIGNWINDOW; + wndclass.lpfnWndProc = ExtWndProc; + wndclass.cbClsExtra = 0; + wndclass.cbWndExtra = DLGWINDOWEXTRA; + wndclass.hInstance = ::GetModuleHandle(NULL); + wndclass.hIcon = NULL; + wndclass.hCursor = ::LoadCursor( NULL, IDC_WAIT ); + wndclass.hbrBackground = (HBRUSH)::GetStockObject(LTGRAY_BRUSH); + wndclass.lpszMenuName = NULL; + wndclass.lpszClassName = m_lpszClassName; + wndclass.hIconSm = NULL; + + if(!RegisterClassEx (&wndclass)) + return NULL; + + // ======================================================================= + // Create the window of the application, passing the this pointer so that + // ExtWndProc can use that for message forwarding + // ======================================================================= + DWORD nScrWidth = ::GetSystemMetrics(SM_CXFULLSCREEN); + DWORD nScrHeight = ::GetSystemMetrics(SM_CYFULLSCREEN); + + int x = (nScrWidth - m_dwWidth) / 2; + int y = (nScrHeight - m_dwHeight) / 2; + m_hwnd = ::CreateWindowEx(WS_EX_TOPMOST|WS_EX_TOOLWINDOW, m_lpszClassName, + TEXT("Ext2 Volume Manager"), WS_POPUP, x, y, + m_dwWidth, m_dwHeight, NULL, NULL, NULL, this); + + // ======================================================================= + // Display the window + // ======================================================================= + if(m_hwnd) + { + MakeTransparent(); + ShowWindow (m_hwnd, SW_SHOW) ; + UpdateWindow (m_hwnd); + } + return m_hwnd; +} + +int CSplash::DoLoop() +{ + // ======================================================================= + // Show the window + // ======================================================================= + if(!m_hwnd) + ShowSplash(); + + // ======================================================================= + // Get into the modal loop + // ======================================================================= + MSG msg ; + while (GetMessage (&msg, NULL, 0, 0)) + { + TranslateMessage (&msg) ; + DispatchMessage (&msg) ; + } + + return (int)msg.wParam ; + +} + +void CSplash::ShowSplash() +{ + CloseSplash(); + RegAndCreateWindow(); +} + + +DWORD CSplash::SetBitmap(UINT id) +{ + // ======================================================================= + // load the bitmap + // ======================================================================= + HBITMAP hBitmap = NULL; + hBitmap = (HBITMAP)::LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(id), + IMAGE_BITMAP, 0, 0, 0); + return SetBitmap(hBitmap); +} + +DWORD CSplash::SetBitmap(HBITMAP hBitmap) +{ + int nRetValue; + BITMAP csBitmapSize; + + // ======================================================================= + // Free loaded resource + // ======================================================================= + FreeResources(); + + if (hBitmap) + { + m_hBitmap = hBitmap; + + // =================================================================== + // Get bitmap size + // =================================================================== + nRetValue = ::GetObject(hBitmap, sizeof(csBitmapSize), &csBitmapSize); + if (nRetValue == 0) + { + FreeResources(); + return 0; + } + m_dwWidth = (DWORD)csBitmapSize.bmWidth; + m_dwHeight = (DWORD)csBitmapSize.bmHeight; + } + + return 1; +} + +void CSplash::FreeResources() +{ + if (m_hBitmap) + ::DeleteObject (m_hBitmap); + m_hBitmap = NULL; +} + +int CSplash::CloseSplash() +{ + + if(m_hwnd) + { + DestroyWindow(m_hwnd); + m_hwnd = 0; + UnregisterClass(m_lpszClassName, ::GetModuleHandle(NULL)); + return 1; + } + return 0; +} + +bool CSplash::SetTransparentColor(COLORREF col) +{ + m_colTrans = col; + + return MakeTransparent(); +} + +bool CSplash::MakeTransparent() +{ + // ======================================================================= + // Set the layered window style and make the required color transparent + // ======================================================================= + if(m_hwnd && g_pSetLayeredWindowAttributes && m_colTrans ) + { + // set layered style for the window + SetWindowLongPtr(m_hwnd, GWL_EXSTYLE, GetWindowLongPtr(m_hwnd, GWL_EXSTYLE) | WS_EX_LAYERED); + // call it with 0 alpha for the given color + g_pSetLayeredWindowAttributes(m_hwnd, m_colTrans, 0, LWA_COLORKEY); + } + return TRUE; +} diff --git a/Ext2Mgr/Splash.h b/Ext2Mgr/Splash.h index 494f0b6..58e077b 100644 --- a/Ext2Mgr/Splash.h +++ b/Ext2Mgr/Splash.h @@ -1,98 +1,98 @@ -// =========================================================================== -// File Splash.h -// Desc The interface of the CSplash class -// =========================================================================== -#ifndef _ABHI_SPLASH_H_ -#define _ABHI_SPLASH_H_ - -#include "windows.h" - -// =========================================================================== -// Class CSplash -// Desc Use it for displaying splash screen for applications -// Works only on Win2000 , WinXP and later versions of Windows -// =========================================================================== -class CSplash -{ -public: - // ======================================================================= - // Func CSplash - // Desc Default constructor - // ======================================================================= - CSplash(); - - // ======================================================================= - // Func CSplash - // Desc Constructor - // Arg Path of the Bitmap that will be show on the splash screen - // Arg The color on the bitmap that will be made transparent - // ======================================================================= - CSplash(UINT id, COLORREF colTrans); - - // ======================================================================= - // Func ~CSplash - // Desc Desctructor - // ======================================================================= - virtual ~CSplash(); - - // ======================================================================= - // Func ShowSplash - // Desc Launches the non-modal splash screen - // Ret void - // ======================================================================= - void ShowSplash(); - - // ======================================================================= - // Func DoLoop - // Desc Launched the splash screen as a modal window. Not completely - // implemented. - // Ret int - // ======================================================================= - int DoLoop(); - - // ======================================================================= - // Func CloseSplash - // Desc Closes the splash screen started with ShowSplash - // Ret int - // ======================================================================= - int CloseSplash(); - - // ======================================================================= - // Func SetBitmap - // Desc Call this with the path of the bitmap. Not required to be used - // when the construcutor with the image path has been used. - // Ret 1 if succesfull - // Arg Either the file path or the handle to an already loaded bitmap - // ======================================================================= - DWORD SetBitmap(UINT id); - DWORD SetBitmap(HBITMAP hBitmap); - - // ======================================================================= - // Func SetTransparentColor - // Desc This is used to make one of the color transparent - // Ret 1 if succesfull - // Arg The colors RGB value. Not required if the color is specified - // using the constructor - // ======================================================================= - bool SetTransparentColor(COLORREF col); - - LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - - HWND m_hwnd; - -private: - void Init(); - void OnPaint(HWND hwnd); - bool MakeTransparent(); - HWND RegAndCreateWindow(); - COLORREF m_colTrans; - DWORD m_dwWidth; - DWORD m_dwHeight; - void FreeResources(); - HBITMAP m_hBitmap; - LPCTSTR m_lpszClassName; - -}; - - -#endif //_ABHI_SPLASH_H_ +// =========================================================================== +// File Splash.h +// Desc The interface of the CSplash class +// =========================================================================== +#ifndef _ABHI_SPLASH_H_ +#define _ABHI_SPLASH_H_ + +#include "windows.h" + +// =========================================================================== +// Class CSplash +// Desc Use it for displaying splash screen for applications +// Works only on Win2000 , WinXP and later versions of Windows +// =========================================================================== +class CSplash +{ +public: + // ======================================================================= + // Func CSplash + // Desc Default constructor + // ======================================================================= + CSplash(); + + // ======================================================================= + // Func CSplash + // Desc Constructor + // Arg Path of the Bitmap that will be show on the splash screen + // Arg The color on the bitmap that will be made transparent + // ======================================================================= + CSplash(UINT id, COLORREF colTrans); + + // ======================================================================= + // Func ~CSplash + // Desc Desctructor + // ======================================================================= + virtual ~CSplash(); + + // ======================================================================= + // Func ShowSplash + // Desc Launches the non-modal splash screen + // Ret void + // ======================================================================= + void ShowSplash(); + + // ======================================================================= + // Func DoLoop + // Desc Launched the splash screen as a modal window. Not completely + // implemented. + // Ret int + // ======================================================================= + int DoLoop(); + + // ======================================================================= + // Func CloseSplash + // Desc Closes the splash screen started with ShowSplash + // Ret int + // ======================================================================= + int CloseSplash(); + + // ======================================================================= + // Func SetBitmap + // Desc Call this with the path of the bitmap. Not required to be used + // when the construcutor with the image path has been used. + // Ret 1 if succesfull + // Arg Either the file path or the handle to an already loaded bitmap + // ======================================================================= + DWORD SetBitmap(UINT id); + DWORD SetBitmap(HBITMAP hBitmap); + + // ======================================================================= + // Func SetTransparentColor + // Desc This is used to make one of the color transparent + // Ret 1 if succesfull + // Arg The colors RGB value. Not required if the color is specified + // using the constructor + // ======================================================================= + bool SetTransparentColor(COLORREF col); + + LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); + + HWND m_hwnd; + +private: + void Init(); + void OnPaint(HWND hwnd); + bool MakeTransparent(); + HWND RegAndCreateWindow(); + COLORREF m_colTrans; + DWORD m_dwWidth; + DWORD m_dwHeight; + void FreeResources(); + HBITMAP m_hBitmap; + LPCTSTR m_lpszClassName; + +}; + + +#endif //_ABHI_SPLASH_H_ diff --git a/Ext2Mgr/StdAfx.cpp b/Ext2Mgr/StdAfx.cpp index f902db4..f222124 100644 --- a/Ext2Mgr/StdAfx.cpp +++ b/Ext2Mgr/StdAfx.cpp @@ -1,8 +1,8 @@ -// stdafx.cpp : source file that includes just the standard includes -// Ext2Mgr.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - - +// stdafx.cpp : source file that includes just the standard includes +// Ext2Mgr.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + + diff --git a/Ext2Mgr/StdAfx.h b/Ext2Mgr/StdAfx.h index 435c6f9..a8b999c 100644 --- a/Ext2Mgr/StdAfx.h +++ b/Ext2Mgr/StdAfx.h @@ -1,60 +1,60 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#if !defined(AFX_STDAFX_H__A7E6CA3E_7403_4367_BC73_C64644BB42F9__INCLUDED_) -#define AFX_STDAFX_H__A7E6CA3E_7403_4367_BC73_C64644BB42F9__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers - -#include // MFC core and standard components -#include // MFC extensions -#include // MFC Automation classes -#include // MFC support for Internet Explorer 4 Common Controls -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT -#include - -#include "AfxPriv.h" -#include "enumDisk.h" -#include -#include "resource.h" - -#define EXT2_DIALOG_MAGIC 'EXTM' - -#define SET_TEXT(id, s) ((CWnd *)GetDlgItem(id))->SetWindowText(s) -#define SET_WIN(id, t) ((CWnd *)GetDlgItem(id))->EnableWindow(t) -#define SET_CHECK(ID, V) ((CButton *)GetDlgItem(ID))->SetCheck(V) - -//--------------our own message----------------- -#define WM_TRAY_ICON_NOTIFY WM_USER + 0x1001 -#define WM_TERMINATE_PROGRAM WM_USER + 0x1002 -#define WM_GROUP_BOX_UPDATED WM_USER + 0x1003 -#define WM_MOUNTPOINT_NOTIFY WM_USER + 0x1004 -//---------------------------------------------- - -extern CHAR *IrpMjStrings[]; -extern CHAR *PerfStatStrings[]; - - - -/* - * Ext2Pipe.cpp - */ - -BOOL Ext2DefineDosDevice(DWORD flags, CHAR *dos, CHAR *symlink); -DWORD Ext2QueryDrive(CHAR drive, CHAR *symlink); - -BOOL Ext2StartPipeSrv(); -VOID Ext2StopPipeSrv(); - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__A7E6CA3E_7403_4367_BC73_C64644BB42F9__INCLUDED_) +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#if !defined(AFX_STDAFX_H__A7E6CA3E_7403_4367_BC73_C64644BB42F9__INCLUDED_) +#define AFX_STDAFX_H__A7E6CA3E_7403_4367_BC73_C64644BB42F9__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers + +#include // MFC core and standard components +#include // MFC extensions +#include // MFC Automation classes +#include // MFC support for Internet Explorer 4 Common Controls +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC support for Windows Common Controls +#endif // _AFX_NO_AFXCMN_SUPPORT +#include + +#include "AfxPriv.h" +#include "enumDisk.h" +#include +#include "resource.h" + +#define EXT2_DIALOG_MAGIC 'EXTM' + +#define SET_TEXT(id, s) ((CWnd *)GetDlgItem(id))->SetWindowText(s) +#define SET_WIN(id, t) ((CWnd *)GetDlgItem(id))->EnableWindow(t) +#define SET_CHECK(ID, V) ((CButton *)GetDlgItem(ID))->SetCheck(V) + +//--------------our own message----------------- +#define WM_TRAY_ICON_NOTIFY WM_USER + 0x1001 +#define WM_TERMINATE_PROGRAM WM_USER + 0x1002 +#define WM_GROUP_BOX_UPDATED WM_USER + 0x1003 +#define WM_MOUNTPOINT_NOTIFY WM_USER + 0x1004 +//---------------------------------------------- + +extern CHAR *IrpMjStrings[]; +extern CHAR *PerfStatStrings[]; + + + +/* + * Ext2Pipe.cpp + */ + +BOOL Ext2DefineDosDevice(DWORD flags, CHAR *dos, CHAR *symlink); +DWORD Ext2QueryDrive(CHAR drive, CHAR *symlink); + +BOOL Ext2StartPipeSrv(); +VOID Ext2StopPipeSrv(); + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__A7E6CA3E_7403_4367_BC73_C64644BB42F9__INCLUDED_) diff --git a/Ext2Mgr/SysTray.cpp b/Ext2Mgr/SysTray.cpp index 51dd029..5b9eedc 100644 --- a/Ext2Mgr/SysTray.cpp +++ b/Ext2Mgr/SysTray.cpp @@ -1,267 +1,267 @@ -///////////////////////////////////////////////////////////////////////////// -// SystemTray.cpp : implementation file -// -///////////////////////////////////////////////////////////////////////////// - -#include "stdafx.h" -#include "SysTray.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -IMPLEMENT_DYNAMIC(CSystemTray, CObject) - -///////////////////////////////////////////////////////////////////////////// -// CSystemTray construction/creation/destruction - -CSystemTray::CSystemTray() -{ - ZeroMemory(&m_tnd, sizeof(m_tnd)); - m_bEnabled = FALSE; - m_bHidden = FALSE; -} - -CSystemTray::CSystemTray(CWnd* pWnd, UINT uCallbackMessage, LPCTSTR szToolTip, - HICON icon, UINT uID) -{ - Create(pWnd, uCallbackMessage, szToolTip, icon, uID); - m_bHidden = FALSE; -} - -BOOL CSystemTray::Create(CWnd* pWnd, UINT uCallbackMessage, LPCTSTR szToolTip, - HICON icon, UINT uID) -{ - // this is only for Windows 95 (or higher) - m_bEnabled = ( GetVersion() & 0xff ); - ASSERT(m_bEnabled >= 4); - if (!m_bEnabled) - return FALSE; - - //Make sure Notification window is valid - m_bEnabled = (pWnd && ::IsWindow(pWnd->GetSafeHwnd())); - if (!m_bEnabled) return FALSE; - - //Make sure we avoid conflict with other messages - ASSERT(uCallbackMessage >= WM_USER); - - //Tray only supports tooltip text up to 64 characters - ASSERT(_tcslen(szToolTip) <= 64); - - // load up the NOTIFYICONDATA structure - m_tnd.cbSize = sizeof(NOTIFYICONDATA); - m_tnd.hWnd = pWnd->GetSafeHwnd(); - m_tnd.uID = uID ^ GetCurrentProcessId(); - m_tnd.hIcon = icon; - m_tnd.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; - m_tnd.uCallbackMessage = uCallbackMessage; - strcpy (m_tnd.szTip, szToolTip); - - // Set the tray icon - m_bEnabled = Shell_NotifyIcon(NIM_ADD, &m_tnd); - ASSERT(m_bEnabled); - return m_bEnabled; -} - -CSystemTray::~CSystemTray() -{ - RemoveIcon(); -} - - -///////////////////////////////////////////////////////////////////////////// -// CSystemTray icon manipulation - -void CSystemTray::MoveToRight() -{ - HideIcon(); - ShowIcon(); -} - -void CSystemTray::RemoveIcon() -{ - if (!m_bEnabled) return; - - m_tnd.uFlags = 0; - Shell_NotifyIcon(NIM_DELETE, &m_tnd); - m_bEnabled = FALSE; -} - -void CSystemTray::HideIcon() -{ - if (m_bEnabled && !m_bHidden) { - m_tnd.uFlags = NIF_ICON; - Shell_NotifyIcon (NIM_DELETE, &m_tnd); - m_bHidden = TRUE; - } -} - -void CSystemTray::ShowIcon() -{ - if (m_bEnabled && m_bHidden) { - m_tnd.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; - Shell_NotifyIcon(NIM_ADD, &m_tnd); - m_bHidden = FALSE; - } -} - -BOOL CSystemTray::SetIcon(HICON hIcon) -{ - if (!m_bEnabled) return FALSE; - - m_tnd.uFlags = NIF_ICON; - m_tnd.hIcon = hIcon; - - return Shell_NotifyIcon(NIM_MODIFY, &m_tnd); -} - -BOOL CSystemTray::SetIcon(LPCTSTR lpszIconName) -{ - HICON hIcon = AfxGetApp()->LoadIcon(lpszIconName); - - return SetIcon(hIcon); -} - -BOOL CSystemTray::SetIcon(UINT nIDResource) -{ - HICON hIcon = AfxGetApp()->LoadIcon(nIDResource); - - return SetIcon(hIcon); -} - -BOOL CSystemTray::SetStandardIcon(LPCTSTR lpIconName) -{ - HICON hIcon = LoadIcon(NULL, lpIconName); - - return SetIcon(hIcon); -} - -BOOL CSystemTray::SetStandardIcon(UINT nIDResource) -{ - HICON hIcon = LoadIcon(NULL, MAKEINTRESOURCE(nIDResource)); - - return SetIcon(hIcon); -} - -HICON CSystemTray::GetIcon() const -{ - HICON hIcon = NULL; - if (m_bEnabled) - hIcon = m_tnd.hIcon; - - return hIcon; -} - -///////////////////////////////////////////////////////////////////////////// -// CSystemTray tooltip text manipulation - -BOOL CSystemTray::SetTooltipText(LPCTSTR pszTip) -{ - if (!m_bEnabled) return FALSE; - - m_tnd.uFlags = NIF_TIP; - _tcscpy(m_tnd.szTip, pszTip); - - return Shell_NotifyIcon(NIM_MODIFY, &m_tnd); -} - -BOOL CSystemTray::SetTooltipText(UINT nID) -{ - CString strText; - strText.LoadString(nID); - - return SetTooltipText(strText); -} - -CString CSystemTray::GetTooltipText() const -{ - CString strText; - if (m_bEnabled) - strText = m_tnd.szTip; - - return strText; -} - -///////////////////////////////////////////////////////////////////////////// -// CSystemTray notification window stuff - -BOOL CSystemTray::SetNotificationWnd(CWnd* pWnd) -{ - if (!m_bEnabled) return FALSE; - - //Make sure Notification window is valid - ASSERT(pWnd && ::IsWindow(pWnd->GetSafeHwnd())); - - m_tnd.hWnd = pWnd->GetSafeHwnd(); - m_tnd.uFlags = 0; - - return Shell_NotifyIcon(NIM_MODIFY, &m_tnd); -} - -CWnd* CSystemTray::GetNotificationWnd() const -{ - return CWnd::FromHandle(m_tnd.hWnd); -} - -///////////////////////////////////////////////////////////////////////////// -// CSystemTray implentation of OnTrayNotification - -LRESULT CSystemTray::OnTrayNotification(WPARAM wParam, LPARAM lParam) -{ - //Return quickly if its not for this tray icon - if (wParam != m_tnd.uID) - return 0L; - - CMenu menu, *pSubMenu; - - // Clicking with right button brings up a context menu - switch(LOWORD(lParam)) - { - case WM_RBUTTONUP: - { - if (!menu.LoadMenu(m_tnd.uID ^ GetCurrentProcessId())) - return 0; - pSubMenu = menu.GetSubMenu(0); - if (!pSubMenu) - return 0; - - // Make first menu item the default (bold font) - ::SetMenuDefaultItem(pSubMenu->m_hMenu, 0, TRUE); - - //Display and track the popup menu - CPoint pos; - GetCursorPos(&pos); - - ::SetForegroundWindow(m_tnd.hWnd); - ::TrackPopupMenu(pSubMenu->m_hMenu, 0, pos.x, pos.y, 0, m_tnd.hWnd, NULL); - - // BUGFIX: See "PRB: Menus for Notification Icons Don't Work Correctly" - ::PostMessage(m_tnd.hWnd, WM_NULL, 0, 0); - - menu.DestroyMenu(); - } - break; - case WM_LBUTTONDBLCLK: - { - if (!menu.LoadMenu(m_tnd.uID ^ GetCurrentProcessId())) - return 0; - pSubMenu = menu.GetSubMenu(0); - if (!pSubMenu) - return 0; - - // double click received, the default action is to execute first menu item - ::SetForegroundWindow(m_tnd.hWnd); - ::SendMessage(m_tnd.hWnd, WM_COMMAND, pSubMenu->GetMenuItemID(0), 0); - - menu.DestroyMenu(); - } - break; - case WM_LBUTTONUP: - ::SetForegroundWindow(m_tnd.hWnd); - break; - } - - return 1; +///////////////////////////////////////////////////////////////////////////// +// SystemTray.cpp : implementation file +// +///////////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "SysTray.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +IMPLEMENT_DYNAMIC(CSystemTray, CObject) + +///////////////////////////////////////////////////////////////////////////// +// CSystemTray construction/creation/destruction + +CSystemTray::CSystemTray() +{ + ZeroMemory(&m_tnd, sizeof(m_tnd)); + m_bEnabled = FALSE; + m_bHidden = FALSE; +} + +CSystemTray::CSystemTray(CWnd* pWnd, UINT uCallbackMessage, LPCTSTR szToolTip, + HICON icon, UINT uID) +{ + Create(pWnd, uCallbackMessage, szToolTip, icon, uID); + m_bHidden = FALSE; +} + +BOOL CSystemTray::Create(CWnd* pWnd, UINT uCallbackMessage, LPCTSTR szToolTip, + HICON icon, UINT uID) +{ + // this is only for Windows 95 (or higher) + m_bEnabled = ( GetVersion() & 0xff ); + ASSERT(m_bEnabled >= 4); + if (!m_bEnabled) + return FALSE; + + //Make sure Notification window is valid + m_bEnabled = (pWnd && ::IsWindow(pWnd->GetSafeHwnd())); + if (!m_bEnabled) return FALSE; + + //Make sure we avoid conflict with other messages + ASSERT(uCallbackMessage >= WM_USER); + + //Tray only supports tooltip text up to 64 characters + ASSERT(_tcslen(szToolTip) <= 64); + + // load up the NOTIFYICONDATA structure + m_tnd.cbSize = sizeof(NOTIFYICONDATA); + m_tnd.hWnd = pWnd->GetSafeHwnd(); + m_tnd.uID = uID ^ GetCurrentProcessId(); + m_tnd.hIcon = icon; + m_tnd.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; + m_tnd.uCallbackMessage = uCallbackMessage; + strcpy (m_tnd.szTip, szToolTip); + + // Set the tray icon + m_bEnabled = Shell_NotifyIcon(NIM_ADD, &m_tnd); + ASSERT(m_bEnabled); + return m_bEnabled; +} + +CSystemTray::~CSystemTray() +{ + RemoveIcon(); +} + + +///////////////////////////////////////////////////////////////////////////// +// CSystemTray icon manipulation + +void CSystemTray::MoveToRight() +{ + HideIcon(); + ShowIcon(); +} + +void CSystemTray::RemoveIcon() +{ + if (!m_bEnabled) return; + + m_tnd.uFlags = 0; + Shell_NotifyIcon(NIM_DELETE, &m_tnd); + m_bEnabled = FALSE; +} + +void CSystemTray::HideIcon() +{ + if (m_bEnabled && !m_bHidden) { + m_tnd.uFlags = NIF_ICON; + Shell_NotifyIcon (NIM_DELETE, &m_tnd); + m_bHidden = TRUE; + } +} + +void CSystemTray::ShowIcon() +{ + if (m_bEnabled && m_bHidden) { + m_tnd.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; + Shell_NotifyIcon(NIM_ADD, &m_tnd); + m_bHidden = FALSE; + } +} + +BOOL CSystemTray::SetIcon(HICON hIcon) +{ + if (!m_bEnabled) return FALSE; + + m_tnd.uFlags = NIF_ICON; + m_tnd.hIcon = hIcon; + + return Shell_NotifyIcon(NIM_MODIFY, &m_tnd); +} + +BOOL CSystemTray::SetIcon(LPCTSTR lpszIconName) +{ + HICON hIcon = AfxGetApp()->LoadIcon(lpszIconName); + + return SetIcon(hIcon); +} + +BOOL CSystemTray::SetIcon(UINT nIDResource) +{ + HICON hIcon = AfxGetApp()->LoadIcon(nIDResource); + + return SetIcon(hIcon); +} + +BOOL CSystemTray::SetStandardIcon(LPCTSTR lpIconName) +{ + HICON hIcon = LoadIcon(NULL, lpIconName); + + return SetIcon(hIcon); +} + +BOOL CSystemTray::SetStandardIcon(UINT nIDResource) +{ + HICON hIcon = LoadIcon(NULL, MAKEINTRESOURCE(nIDResource)); + + return SetIcon(hIcon); +} + +HICON CSystemTray::GetIcon() const +{ + HICON hIcon = NULL; + if (m_bEnabled) + hIcon = m_tnd.hIcon; + + return hIcon; +} + +///////////////////////////////////////////////////////////////////////////// +// CSystemTray tooltip text manipulation + +BOOL CSystemTray::SetTooltipText(LPCTSTR pszTip) +{ + if (!m_bEnabled) return FALSE; + + m_tnd.uFlags = NIF_TIP; + _tcscpy(m_tnd.szTip, pszTip); + + return Shell_NotifyIcon(NIM_MODIFY, &m_tnd); +} + +BOOL CSystemTray::SetTooltipText(UINT nID) +{ + CString strText; + strText.LoadString(nID); + + return SetTooltipText(strText); +} + +CString CSystemTray::GetTooltipText() const +{ + CString strText; + if (m_bEnabled) + strText = m_tnd.szTip; + + return strText; +} + +///////////////////////////////////////////////////////////////////////////// +// CSystemTray notification window stuff + +BOOL CSystemTray::SetNotificationWnd(CWnd* pWnd) +{ + if (!m_bEnabled) return FALSE; + + //Make sure Notification window is valid + ASSERT(pWnd && ::IsWindow(pWnd->GetSafeHwnd())); + + m_tnd.hWnd = pWnd->GetSafeHwnd(); + m_tnd.uFlags = 0; + + return Shell_NotifyIcon(NIM_MODIFY, &m_tnd); +} + +CWnd* CSystemTray::GetNotificationWnd() const +{ + return CWnd::FromHandle(m_tnd.hWnd); +} + +///////////////////////////////////////////////////////////////////////////// +// CSystemTray implentation of OnTrayNotification + +LRESULT CSystemTray::OnTrayNotification(WPARAM wParam, LPARAM lParam) +{ + //Return quickly if its not for this tray icon + if (wParam != m_tnd.uID) + return 0L; + + CMenu menu, *pSubMenu; + + // Clicking with right button brings up a context menu + switch(LOWORD(lParam)) + { + case WM_RBUTTONUP: + { + if (!menu.LoadMenu(m_tnd.uID ^ GetCurrentProcessId())) + return 0; + pSubMenu = menu.GetSubMenu(0); + if (!pSubMenu) + return 0; + + // Make first menu item the default (bold font) + ::SetMenuDefaultItem(pSubMenu->m_hMenu, 0, TRUE); + + //Display and track the popup menu + CPoint pos; + GetCursorPos(&pos); + + ::SetForegroundWindow(m_tnd.hWnd); + ::TrackPopupMenu(pSubMenu->m_hMenu, 0, pos.x, pos.y, 0, m_tnd.hWnd, NULL); + + // BUGFIX: See "PRB: Menus for Notification Icons Don't Work Correctly" + ::PostMessage(m_tnd.hWnd, WM_NULL, 0, 0); + + menu.DestroyMenu(); + } + break; + case WM_LBUTTONDBLCLK: + { + if (!menu.LoadMenu(m_tnd.uID ^ GetCurrentProcessId())) + return 0; + pSubMenu = menu.GetSubMenu(0); + if (!pSubMenu) + return 0; + + // double click received, the default action is to execute first menu item + ::SetForegroundWindow(m_tnd.hWnd); + ::SendMessage(m_tnd.hWnd, WM_COMMAND, pSubMenu->GetMenuItemID(0), 0); + + menu.DestroyMenu(); + } + break; + case WM_LBUTTONUP: + ::SetForegroundWindow(m_tnd.hWnd); + break; + } + + return 1; } \ No newline at end of file diff --git a/Ext2Mgr/SysTray.h b/Ext2Mgr/SysTray.h index d4a0b65..cd29c38 100644 --- a/Ext2Mgr/SysTray.h +++ b/Ext2Mgr/SysTray.h @@ -1,89 +1,89 @@ -///////////////////////////////////////////////////////////////////////////// -// SystemTray.h : header file -// -// Written by Chris Maunder (Chris.Maunder@cbr.clw.csiro.au) -// Copyright (c) 1998. -// -// This code may be used in compiled form in any way you desire. This -// file may be redistributed unmodified by any means PROVIDING it is -// not sold for profit without the authors written consent, and -// providing that this notice and the authors name is included. If -// the source code in this file is used in any commercial application -// then acknowledgement must be made to the author of this file -// (in whatever form you wish). -// -// This file is provided "as is" with no expressed or implied warranty. -// The author accepts no liability if it causes any damage to your -// computer, causes your pet cat to fall ill, increases baldness or -// makes you car start emitting strange noises when you start it up. -// -// Expect bugs. -// -// Please use and enjoy. Please let me know of any bugs/mods/improvements -// that you have found/implemented and I will fix/incorporate them into this -// file. - -#ifndef _INCLUDED_SYSTEMTRAY_H_ -#define _INCLUDED_SYSTEMTRAY_H_ - -///////////////////////////////////////////////////////////////////////////// -// CSystemTray window - -class CSystemTray : public CObject -{ -// Construction/destruction -public: - CSystemTray(); - CSystemTray(CWnd* pWnd, UINT uCallbackMessage, LPCTSTR szTip, HICON icon, UINT uID); - virtual ~CSystemTray(); - -// Operations -public: - BOOL Enabled() { return m_bEnabled; } - BOOL Visible() { return !m_bHidden; } - - //Create the tray icon - int Create(CWnd* pWnd, UINT uCallbackMessage, LPCTSTR szTip, HICON icon, UINT uID); - - //Change or retrieve the Tooltip text - BOOL SetTooltipText(LPCTSTR pszTooltipText); - BOOL SetTooltipText(UINT nID); - CString GetTooltipText() const; - - //Change or retrieve the icon displayed - BOOL SetIcon(HICON hIcon); - BOOL SetIcon(LPCTSTR lpIconName); - BOOL SetIcon(UINT nIDResource); - BOOL SetStandardIcon(LPCTSTR lpIconName); - BOOL SetStandardIcon(UINT nIDResource); - HICON GetIcon() const; - void HideIcon(); - void ShowIcon(); - void RemoveIcon(); - void MoveToRight(); - - //Change or retrieve the window to send notification messages to - BOOL SetNotificationWnd(CWnd* pNotifyWnd); - CWnd* GetNotificationWnd() const; - - //Default handler for tray notification message - virtual LRESULT OnTrayNotification(WPARAM uID, LPARAM lEvent); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CSystemTray) - //}}AFX_VIRTUAL - -// Implementation -protected: - BOOL m_bEnabled; // does O/S support tray icon? - BOOL m_bHidden; // Has the icon been hidden? - NOTIFYICONDATA m_tnd; - - DECLARE_DYNAMIC(CSystemTray) -}; - - -#endif - -///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// +// SystemTray.h : header file +// +// Written by Chris Maunder (Chris.Maunder@cbr.clw.csiro.au) +// Copyright (c) 1998. +// +// This code may be used in compiled form in any way you desire. This +// file may be redistributed unmodified by any means PROVIDING it is +// not sold for profit without the authors written consent, and +// providing that this notice and the authors name is included. If +// the source code in this file is used in any commercial application +// then acknowledgement must be made to the author of this file +// (in whatever form you wish). +// +// This file is provided "as is" with no expressed or implied warranty. +// The author accepts no liability if it causes any damage to your +// computer, causes your pet cat to fall ill, increases baldness or +// makes you car start emitting strange noises when you start it up. +// +// Expect bugs. +// +// Please use and enjoy. Please let me know of any bugs/mods/improvements +// that you have found/implemented and I will fix/incorporate them into this +// file. + +#ifndef _INCLUDED_SYSTEMTRAY_H_ +#define _INCLUDED_SYSTEMTRAY_H_ + +///////////////////////////////////////////////////////////////////////////// +// CSystemTray window + +class CSystemTray : public CObject +{ +// Construction/destruction +public: + CSystemTray(); + CSystemTray(CWnd* pWnd, UINT uCallbackMessage, LPCTSTR szTip, HICON icon, UINT uID); + virtual ~CSystemTray(); + +// Operations +public: + BOOL Enabled() { return m_bEnabled; } + BOOL Visible() { return !m_bHidden; } + + //Create the tray icon + int Create(CWnd* pWnd, UINT uCallbackMessage, LPCTSTR szTip, HICON icon, UINT uID); + + //Change or retrieve the Tooltip text + BOOL SetTooltipText(LPCTSTR pszTooltipText); + BOOL SetTooltipText(UINT nID); + CString GetTooltipText() const; + + //Change or retrieve the icon displayed + BOOL SetIcon(HICON hIcon); + BOOL SetIcon(LPCTSTR lpIconName); + BOOL SetIcon(UINT nIDResource); + BOOL SetStandardIcon(LPCTSTR lpIconName); + BOOL SetStandardIcon(UINT nIDResource); + HICON GetIcon() const; + void HideIcon(); + void ShowIcon(); + void RemoveIcon(); + void MoveToRight(); + + //Change or retrieve the window to send notification messages to + BOOL SetNotificationWnd(CWnd* pNotifyWnd); + CWnd* GetNotificationWnd() const; + + //Default handler for tray notification message + virtual LRESULT OnTrayNotification(WPARAM uID, LPARAM lEvent); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CSystemTray) + //}}AFX_VIRTUAL + +// Implementation +protected: + BOOL m_bEnabled; // does O/S support tray icon? + BOOL m_bHidden; // Has the icon been hidden? + NOTIFYICONDATA m_tnd; + + DECLARE_DYNAMIC(CSystemTray) +}; + + +#endif + +///////////////////////////////////////////////////////////////////////////// diff --git a/Ext2Mgr/TreeList.cpp b/Ext2Mgr/TreeList.cpp index fa76768..6a27a80 100644 --- a/Ext2Mgr/TreeList.cpp +++ b/Ext2Mgr/TreeList.cpp @@ -1,357 +1,357 @@ -// TreeList.cpp : implementation file -// - -#include "stdafx.h" -#include "resource.h" -#include "TreeList.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CTreeList - -CTreeList::CTreeList() -{ - m_SelectionRect = CRect(0,0,0,0); - m_SelectionFlag = FALSE; - m_Point = CPoint(0, 0); - m_PrevItem = -1; - m_Rows = 0; - m_Columns = 1; - m_hBitmap = NULL; - m_hMemDC = NULL; - m_hOldBmp = NULL; - m_bFocus = FALSE; -} - -CTreeList::~CTreeList() -{ - if (m_hBitmap) { - - if (m_hMemDC) { - ::SelectObject(m_hMemDC, m_hOldBmp); - ::DeleteDC(m_hMemDC); - } - - ::DeleteObject (m_hBitmap); - m_hBitmap = NULL; - } -} - - -BEGIN_MESSAGE_MAP(CTreeList, CListCtrl) - //{{AFX_MSG_MAP(CTreeList) - ON_WM_LBUTTONDOWN() - ON_WM_RBUTTONDOWN() - ON_NOTIFY_REFLECT(NM_KILLFOCUS, OnKillfocus) - ON_NOTIFY_REFLECT(NM_SETFOCUS, OnSetfocus) - //}}AFX_MSG_MAP - ON_MESSAGE(WM_SETFONT, OnSetFont) - ON_WM_MEASUREITEM_REFLECT() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CTreeList message handlers - -void CTreeList::OnLButtonDown(UINT nFlags, CPoint point) -{ - // TODO: Add your message handler code here and/or call default - m_Point = point; - m_SelectionFlag = FALSE; - - Invalidate(); - - CListCtrl::OnLButtonDown(nFlags, point); -} - -BOOL CTreeList::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Add your specialized code here and/or call the base class - cs.style |= LVS_REPORT | LVS_OWNERDRAWFIXED| WS_BORDER; - return CListCtrl::PreCreateWindow(cs); -} - -LRESULT CTreeList::OnSetFont(WPARAM wParam, LPARAM) -{ - LRESULT res = Default(); - - CRect rc; - GetWindowRect( &rc ); - - WINDOWPOS wp; - wp.hwnd = m_hWnd; - wp.cx = rc.Width(); - wp.cy = rc.Height(); - wp.flags = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER; - SendMessage( WM_WINDOWPOSCHANGED, 0, (LPARAM)&wp ); - - return res; -} - -void CTreeList::MeasureItem( LPMEASUREITEMSTRUCT lpMeasureItemStruct ) -{ - lpMeasureItemStruct->itemHeight = 16; -} - -void CTreeList::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) -{ - PULONG pMagic = (PULONG) lpDrawItemStruct->itemData; - - TCHAR lpBuffer[256]; - LV_ITEM lvi; - LV_COLUMN lvc, lvcprev ; - - memset(lpBuffer, 0, 256); - lvi.mask = LVIF_TEXT | LVIF_PARAM ; - lvi.iItem = lpDrawItemStruct->itemID ; - lvi.iSubItem = 0; - lvi.pszText = lpBuffer ; - lvi.cchTextMax = sizeof(lpBuffer); - GetItem(&lvi); - ::ZeroMemory(&lvc, sizeof(lvc)); - ::ZeroMemory(&lvcprev, sizeof(lvcprev)); - lvc.mask = LVCF_WIDTH |LVCF_FMT; - lvcprev.mask = LVCF_WIDTH | LVCF_FMT; - - CDC* pDC; - pDC = CDC::FromHandle(lpDrawItemStruct->hDC); - int nCol; - CRect rcText = lpDrawItemStruct->rcItem; - - CFont Fnt, *pOldFont = NULL; - LOGFONT lf; - - int cyPixels = pDC->GetDeviceCaps(LOGPIXELSY); - memset(&lf, 0, sizeof(LOGFONT)); - - if (pMagic == NULL) { - return; - } - - if (*pMagic == EXT2_CDROM_DEVICE_MAGIC || *pMagic == EXT2_DISK_MAGIC) { - - if (IsVistaOrAbove()) { - lstrcpy(lf.lfFaceName, "MS Sans Serif"); /*Courier New*/ - lf.lfHeight = -MulDiv(8, cyPixels, 72); - lf.lfWeight = TRUE; - } else { - lstrcpy(lf.lfFaceName, "Arial Black"); /*Courier New*/ - lf.lfHeight = -MulDiv(8, cyPixels, 72); - lf.lfWeight = TRUE; - } - } else { - lstrcpy(lf.lfFaceName, "MS Sans Serif"); - lf.lfHeight = -MulDiv(8, cyPixels, 72); - } - - Fnt.CreateFontIndirect(&lf); - pOldFont = (CFont *) pDC->SelectObject(&Fnt); - - /* loading bitmap */ - if (m_hBitmap == NULL) { - m_hBitmap = (HBITMAP)::LoadImage(GetModuleHandle(NULL), - MAKEINTRESOURCE(IDB_LINE_SEP), - IMAGE_BITMAP, 0, 0, 0); - - if (m_hBitmap) { - m_hMemDC = ::CreateCompatibleDC(this->GetDC()->m_hDC); - m_hOldBmp = (HBITMAP)::SelectObject(m_hMemDC, m_hBitmap); - } - } - - if (TRUE) { - - if (!m_SelectionFlag) { - for (nCol=0; GetColumn(nCol, &lvc); nCol++) { - if (nCol > 0) { - GetSubItemRect(lpDrawItemStruct->itemID, - nCol,LVIR_BOUNDS, m_SelectionRect); - } else { - GetItemRect(lpDrawItemStruct->itemID, - m_SelectionRect,LVIR_BOUNDS); - m_SelectionRect.right = GetColumnWidth(0); - m_SelectionRect.left = 0; - } - - if (m_SelectionRect.PtInRect(m_Point)) { - m_SelectionFlag = TRUE; - break; - } else { - m_SelectionFlag = FALSE; - } - } - } - - if ((lpDrawItemStruct->itemState & ODS_SELECTED) && m_SelectionFlag ) { - - CRect rc = lpDrawItemStruct->rcItem; - rc.left += 4; rc.right -= 4; - rc.top += 1; rc.bottom -= 0; - if (*pMagic == EXT2_CDROM_DEVICE_MAGIC || *pMagic == EXT2_DISK_MAGIC) { - rc.bottom -= 3; rc.top -= 1; - rc.right = (rc.Width() * 7 / 8) + rc.left; - } - pDC->FillSolidRect(&rc, GetSysColor(m_bFocus ? COLOR_HIGHLIGHT : COLOR_INACTIVEBORDER)); - } else { - CRect rc = lpDrawItemStruct->rcItem; - pDC->FillSolidRect(&rc, GetSysColor(COLOR_WINDOW)) ; - pDC->SetTextColor(GetSysColor(COLOR_WINDOWTEXT)) ; - } - } - - for (nCol=0; GetColumn(nCol, &lvc); nCol++) { - - UINT uFormat = DT_LEFT ; - - if (*pMagic == EXT2_CDROM_DEVICE_MAGIC || *pMagic == EXT2_DISK_MAGIC) { - - rcText = lpDrawItemStruct->rcItem; - rcText.left += 4; - rcText.bottom += 1; - rcText.top = rcText.bottom - 6 + lf.lfHeight; - - ::DrawText(lpDrawItemStruct->hDC, lpBuffer, (int)strlen(lpBuffer), - &rcText, DT_LEFT) ; - - CRect rect = lpDrawItemStruct->rcItem; - int rc = 0; - BITMAP cs; - - - rect.top = rcText.bottom - 4; - rc = ::GetObject(m_hBitmap, sizeof(cs), &cs); - if (rc == 0) { - pDC->SelectObject(pOldFont); - return; - } - - ::StretchBlt(pDC->m_hDC, rect.left + 4, (rect.bottom + rect.top) / 2, - rect.Width() * 7 / 8, cs.bmHeight, - m_hMemDC, 0, 0, cs.bmWidth, cs.bmHeight, SRCCOPY); - - } else { - - if (nCol > 0) { - GetColumn(nCol, &lvcprev) ; - rcText.left = rcText.right; - rcText.right += lvcprev.cx; - rcText.left += 4; - - if (nCol == 3 || nCol == 4) { - uFormat = DT_RIGHT; - rcText.right -= 4; - } - - } else { - rcText = lpDrawItemStruct->rcItem; - rcText.top += (16 + lf.lfHeight) / 2; - rcText.right = rcText.left + GetColumnWidth(0); - rcText.left += 20; - } - - // Get and draw the text - memset(lpBuffer, 0, 256); - ::ZeroMemory(&lvi, sizeof(lvi)); - lvi.iItem = lpDrawItemStruct->itemID; - lvi.mask = LVIF_TEXT | LVIF_PARAM; - lvi.iSubItem = nCol; - lvi.pszText = lpBuffer; - lvi.cchTextMax = sizeof(lpBuffer); - GetItem(&lvi); - - ::DrawText(lpDrawItemStruct->hDC, lpBuffer, (int)strlen(lpBuffer), - &rcText, uFormat) ; - - if (nCol == 0) { - rcText.left -= 20; - } else { - rcText.left -= 4; - if (nCol == 3 || nCol == 4) { - rcText.right += 4; - } - } - } - } - - pDC->SelectObject(pOldFont); - - return; -} - -void CTreeList::OnRButtonDown(UINT nFlags, CPoint point) -{ - // TODO: Add your message handler code here and/or call default - m_Point = point; - m_SelectionFlag = FALSE; - - Invalidate(); - - CListCtrl::OnRButtonDown(nFlags, point); -} - -void CTreeList::OnKillfocus(NMHDR* pNMHDR, LRESULT* pResult) -{ - // TODO: Add your control notification handler code here - m_bFocus = FALSE; - Invalidate(); - *pResult = 0; -} - -void CTreeList::OnSetfocus(NMHDR* pNMHDR, LRESULT* pResult) -{ - // TODO: Add your control notification handler code here - m_bFocus = TRUE; - Invalidate(); - - *pResult = 0; -} - -int CTreeList::QuerySubItemText(int item, CHAR *Data, int length) -{ - LV_COLUMN lvc; - LV_ITEM lvi; - int ncol; - CRect rect; - - ::ZeroMemory(&lvc, sizeof(lvc)); - lvc.mask = LVCF_WIDTH |LVCF_FMT; - - for (ncol=0; GetColumn(ncol, &lvc); ncol++) { - - if (ncol > 0) { - GetSubItemRect(item, ncol,LVIR_BOUNDS, rect); - } else { - GetItemRect(item, rect, LVIR_BOUNDS); - rect.right = GetColumnWidth(0); - rect.left = 0; - } - - if (rect.PtInRect(m_Point)) { - - ::ZeroMemory(Data, length); - ::ZeroMemory(&lvi, sizeof(lvi)); - - lvi.iItem = item; - lvi.mask = LVIF_TEXT; - lvi.iSubItem = ncol; - lvi.pszText = Data; - lvi.cchTextMax = length; - - return GetItem(&lvi); - break; - } - } - - return FALSE; -} - -VOID CTreeList::Redraw() -{ - m_bFocus = TRUE; - m_SelectionFlag = TRUE; - Invalidate(); +// TreeList.cpp : implementation file +// + +#include "stdafx.h" +#include "resource.h" +#include "TreeList.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CTreeList + +CTreeList::CTreeList() +{ + m_SelectionRect = CRect(0,0,0,0); + m_SelectionFlag = FALSE; + m_Point = CPoint(0, 0); + m_PrevItem = -1; + m_Rows = 0; + m_Columns = 1; + m_hBitmap = NULL; + m_hMemDC = NULL; + m_hOldBmp = NULL; + m_bFocus = FALSE; +} + +CTreeList::~CTreeList() +{ + if (m_hBitmap) { + + if (m_hMemDC) { + ::SelectObject(m_hMemDC, m_hOldBmp); + ::DeleteDC(m_hMemDC); + } + + ::DeleteObject (m_hBitmap); + m_hBitmap = NULL; + } +} + + +BEGIN_MESSAGE_MAP(CTreeList, CListCtrl) + //{{AFX_MSG_MAP(CTreeList) + ON_WM_LBUTTONDOWN() + ON_WM_RBUTTONDOWN() + ON_NOTIFY_REFLECT(NM_KILLFOCUS, OnKillfocus) + ON_NOTIFY_REFLECT(NM_SETFOCUS, OnSetfocus) + //}}AFX_MSG_MAP + ON_MESSAGE(WM_SETFONT, OnSetFont) + ON_WM_MEASUREITEM_REFLECT() +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CTreeList message handlers + +void CTreeList::OnLButtonDown(UINT nFlags, CPoint point) +{ + // TODO: Add your message handler code here and/or call default + m_Point = point; + m_SelectionFlag = FALSE; + + Invalidate(); + + CListCtrl::OnLButtonDown(nFlags, point); +} + +BOOL CTreeList::PreCreateWindow(CREATESTRUCT& cs) +{ + // TODO: Add your specialized code here and/or call the base class + cs.style |= LVS_REPORT | LVS_OWNERDRAWFIXED| WS_BORDER; + return CListCtrl::PreCreateWindow(cs); +} + +LRESULT CTreeList::OnSetFont(WPARAM wParam, LPARAM) +{ + LRESULT res = Default(); + + CRect rc; + GetWindowRect( &rc ); + + WINDOWPOS wp; + wp.hwnd = m_hWnd; + wp.cx = rc.Width(); + wp.cy = rc.Height(); + wp.flags = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER; + SendMessage( WM_WINDOWPOSCHANGED, 0, (LPARAM)&wp ); + + return res; +} + +void CTreeList::MeasureItem( LPMEASUREITEMSTRUCT lpMeasureItemStruct ) +{ + lpMeasureItemStruct->itemHeight = 16; +} + +void CTreeList::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) +{ + PULONG pMagic = (PULONG) lpDrawItemStruct->itemData; + + TCHAR lpBuffer[256]; + LV_ITEM lvi; + LV_COLUMN lvc, lvcprev ; + + memset(lpBuffer, 0, 256); + lvi.mask = LVIF_TEXT | LVIF_PARAM ; + lvi.iItem = lpDrawItemStruct->itemID ; + lvi.iSubItem = 0; + lvi.pszText = lpBuffer ; + lvi.cchTextMax = sizeof(lpBuffer); + GetItem(&lvi); + ::ZeroMemory(&lvc, sizeof(lvc)); + ::ZeroMemory(&lvcprev, sizeof(lvcprev)); + lvc.mask = LVCF_WIDTH |LVCF_FMT; + lvcprev.mask = LVCF_WIDTH | LVCF_FMT; + + CDC* pDC; + pDC = CDC::FromHandle(lpDrawItemStruct->hDC); + int nCol; + CRect rcText = lpDrawItemStruct->rcItem; + + CFont Fnt, *pOldFont = NULL; + LOGFONT lf; + + int cyPixels = pDC->GetDeviceCaps(LOGPIXELSY); + memset(&lf, 0, sizeof(LOGFONT)); + + if (pMagic == NULL) { + return; + } + + if (*pMagic == EXT2_CDROM_DEVICE_MAGIC || *pMagic == EXT2_DISK_MAGIC) { + + if (IsVistaOrAbove()) { + lstrcpy(lf.lfFaceName, "MS Sans Serif"); /*Courier New*/ + lf.lfHeight = -MulDiv(8, cyPixels, 72); + lf.lfWeight = TRUE; + } else { + lstrcpy(lf.lfFaceName, "Arial Black"); /*Courier New*/ + lf.lfHeight = -MulDiv(8, cyPixels, 72); + lf.lfWeight = TRUE; + } + } else { + lstrcpy(lf.lfFaceName, "MS Sans Serif"); + lf.lfHeight = -MulDiv(8, cyPixels, 72); + } + + Fnt.CreateFontIndirect(&lf); + pOldFont = (CFont *) pDC->SelectObject(&Fnt); + + /* loading bitmap */ + if (m_hBitmap == NULL) { + m_hBitmap = (HBITMAP)::LoadImage(GetModuleHandle(NULL), + MAKEINTRESOURCE(IDB_LINE_SEP), + IMAGE_BITMAP, 0, 0, 0); + + if (m_hBitmap) { + m_hMemDC = ::CreateCompatibleDC(this->GetDC()->m_hDC); + m_hOldBmp = (HBITMAP)::SelectObject(m_hMemDC, m_hBitmap); + } + } + + if (TRUE) { + + if (!m_SelectionFlag) { + for (nCol=0; GetColumn(nCol, &lvc); nCol++) { + if (nCol > 0) { + GetSubItemRect(lpDrawItemStruct->itemID, + nCol,LVIR_BOUNDS, m_SelectionRect); + } else { + GetItemRect(lpDrawItemStruct->itemID, + m_SelectionRect,LVIR_BOUNDS); + m_SelectionRect.right = GetColumnWidth(0); + m_SelectionRect.left = 0; + } + + if (m_SelectionRect.PtInRect(m_Point)) { + m_SelectionFlag = TRUE; + break; + } else { + m_SelectionFlag = FALSE; + } + } + } + + if ((lpDrawItemStruct->itemState & ODS_SELECTED) && m_SelectionFlag ) { + + CRect rc = lpDrawItemStruct->rcItem; + rc.left += 4; rc.right -= 4; + rc.top += 1; rc.bottom -= 0; + if (*pMagic == EXT2_CDROM_DEVICE_MAGIC || *pMagic == EXT2_DISK_MAGIC) { + rc.bottom -= 3; rc.top -= 1; + rc.right = (rc.Width() * 7 / 8) + rc.left; + } + pDC->FillSolidRect(&rc, GetSysColor(m_bFocus ? COLOR_HIGHLIGHT : COLOR_INACTIVEBORDER)); + } else { + CRect rc = lpDrawItemStruct->rcItem; + pDC->FillSolidRect(&rc, GetSysColor(COLOR_WINDOW)) ; + pDC->SetTextColor(GetSysColor(COLOR_WINDOWTEXT)) ; + } + } + + for (nCol=0; GetColumn(nCol, &lvc); nCol++) { + + UINT uFormat = DT_LEFT ; + + if (*pMagic == EXT2_CDROM_DEVICE_MAGIC || *pMagic == EXT2_DISK_MAGIC) { + + rcText = lpDrawItemStruct->rcItem; + rcText.left += 4; + rcText.bottom += 1; + rcText.top = rcText.bottom - 6 + lf.lfHeight; + + ::DrawText(lpDrawItemStruct->hDC, lpBuffer, (int)strlen(lpBuffer), + &rcText, DT_LEFT) ; + + CRect rect = lpDrawItemStruct->rcItem; + int rc = 0; + BITMAP cs; + + + rect.top = rcText.bottom - 4; + rc = ::GetObject(m_hBitmap, sizeof(cs), &cs); + if (rc == 0) { + pDC->SelectObject(pOldFont); + return; + } + + ::StretchBlt(pDC->m_hDC, rect.left + 4, (rect.bottom + rect.top) / 2, + rect.Width() * 7 / 8, cs.bmHeight, + m_hMemDC, 0, 0, cs.bmWidth, cs.bmHeight, SRCCOPY); + + } else { + + if (nCol > 0) { + GetColumn(nCol, &lvcprev) ; + rcText.left = rcText.right; + rcText.right += lvcprev.cx; + rcText.left += 4; + + if (nCol == 3 || nCol == 4) { + uFormat = DT_RIGHT; + rcText.right -= 4; + } + + } else { + rcText = lpDrawItemStruct->rcItem; + rcText.top += (16 + lf.lfHeight) / 2; + rcText.right = rcText.left + GetColumnWidth(0); + rcText.left += 20; + } + + // Get and draw the text + memset(lpBuffer, 0, 256); + ::ZeroMemory(&lvi, sizeof(lvi)); + lvi.iItem = lpDrawItemStruct->itemID; + lvi.mask = LVIF_TEXT | LVIF_PARAM; + lvi.iSubItem = nCol; + lvi.pszText = lpBuffer; + lvi.cchTextMax = sizeof(lpBuffer); + GetItem(&lvi); + + ::DrawText(lpDrawItemStruct->hDC, lpBuffer, (int)strlen(lpBuffer), + &rcText, uFormat) ; + + if (nCol == 0) { + rcText.left -= 20; + } else { + rcText.left -= 4; + if (nCol == 3 || nCol == 4) { + rcText.right += 4; + } + } + } + } + + pDC->SelectObject(pOldFont); + + return; +} + +void CTreeList::OnRButtonDown(UINT nFlags, CPoint point) +{ + // TODO: Add your message handler code here and/or call default + m_Point = point; + m_SelectionFlag = FALSE; + + Invalidate(); + + CListCtrl::OnRButtonDown(nFlags, point); +} + +void CTreeList::OnKillfocus(NMHDR* pNMHDR, LRESULT* pResult) +{ + // TODO: Add your control notification handler code here + m_bFocus = FALSE; + Invalidate(); + *pResult = 0; +} + +void CTreeList::OnSetfocus(NMHDR* pNMHDR, LRESULT* pResult) +{ + // TODO: Add your control notification handler code here + m_bFocus = TRUE; + Invalidate(); + + *pResult = 0; +} + +int CTreeList::QuerySubItemText(int item, CHAR *Data, int length) +{ + LV_COLUMN lvc; + LV_ITEM lvi; + int ncol; + CRect rect; + + ::ZeroMemory(&lvc, sizeof(lvc)); + lvc.mask = LVCF_WIDTH |LVCF_FMT; + + for (ncol=0; GetColumn(ncol, &lvc); ncol++) { + + if (ncol > 0) { + GetSubItemRect(item, ncol,LVIR_BOUNDS, rect); + } else { + GetItemRect(item, rect, LVIR_BOUNDS); + rect.right = GetColumnWidth(0); + rect.left = 0; + } + + if (rect.PtInRect(m_Point)) { + + ::ZeroMemory(Data, length); + ::ZeroMemory(&lvi, sizeof(lvi)); + + lvi.iItem = item; + lvi.mask = LVIF_TEXT; + lvi.iSubItem = ncol; + lvi.pszText = Data; + lvi.cchTextMax = length; + + return GetItem(&lvi); + break; + } + } + + return FALSE; +} + +VOID CTreeList::Redraw() +{ + m_bFocus = TRUE; + m_SelectionFlag = TRUE; + Invalidate(); } \ No newline at end of file diff --git a/Ext2Mgr/TreeList.h b/Ext2Mgr/TreeList.h index 9c0052c..07c306b 100644 --- a/Ext2Mgr/TreeList.h +++ b/Ext2Mgr/TreeList.h @@ -1,74 +1,74 @@ -#if !defined(AFX_TREELIST_H__7C424B24_1578_47A5_8134_34901335977B__INCLUDED_) -#define AFX_TREELIST_H__7C424B24_1578_47A5_8134_34901335977B__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// TreeList.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// CTreeList window - -class CTreeList : public CListCtrl -{ -// Construction -public: - CTreeList(); - -// Attributes -public: - - /* Focus set or lost */ - BOOL m_bFocus; - - /* single item selection */ - CRect m_SelectionRect; - BOOL m_SelectionFlag; - CPoint m_Point; - int m_Rows; - int m_Columns; - int m_PrevItem; - - /* bitmap information */ - HBITMAP m_hBitmap; - HDC m_hMemDC; - HBITMAP m_hOldBmp; - -// Operations -public: - - VOID Redraw(); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CTreeList) - virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - //}}AFX_VIRTUAL - afx_msg LRESULT OnSetFont(WPARAM wParam, LPARAM); - afx_msg void MeasureItem ( LPMEASUREITEMSTRUCT lpMeasureItemStruct ); - -// Implementation -public: - virtual ~CTreeList(); - int QuerySubItemText(int item, CHAR *Data, int length); - - // Generated message map functions -protected: - //{{AFX_MSG(CTreeList) - afx_msg void OnLButtonDown(UINT nFlags, CPoint point); - afx_msg void OnRButtonDown(UINT nFlags, CPoint point); - afx_msg void OnKillfocus(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnSetfocus(NMHDR* pNMHDR, LRESULT* pResult); - //}}AFX_MSG - - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_TREELIST_H__7C424B24_1578_47A5_8134_34901335977B__INCLUDED_) +#if !defined(AFX_TREELIST_H__7C424B24_1578_47A5_8134_34901335977B__INCLUDED_) +#define AFX_TREELIST_H__7C424B24_1578_47A5_8134_34901335977B__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// TreeList.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CTreeList window + +class CTreeList : public CListCtrl +{ +// Construction +public: + CTreeList(); + +// Attributes +public: + + /* Focus set or lost */ + BOOL m_bFocus; + + /* single item selection */ + CRect m_SelectionRect; + BOOL m_SelectionFlag; + CPoint m_Point; + int m_Rows; + int m_Columns; + int m_PrevItem; + + /* bitmap information */ + HBITMAP m_hBitmap; + HDC m_hMemDC; + HBITMAP m_hOldBmp; + +// Operations +public: + + VOID Redraw(); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CTreeList) + virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + //}}AFX_VIRTUAL + afx_msg LRESULT OnSetFont(WPARAM wParam, LPARAM); + afx_msg void MeasureItem ( LPMEASUREITEMSTRUCT lpMeasureItemStruct ); + +// Implementation +public: + virtual ~CTreeList(); + int QuerySubItemText(int item, CHAR *Data, int length); + + // Generated message map functions +protected: + //{{AFX_MSG(CTreeList) + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg void OnRButtonDown(UINT nFlags, CPoint point); + afx_msg void OnKillfocus(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnSetfocus(NMHDR* pNMHDR, LRESULT* pResult); + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_TREELIST_H__7C424B24_1578_47A5_8134_34901335977B__INCLUDED_) diff --git a/Ext2Mgr/enumDisk.cpp b/Ext2Mgr/enumDisk.cpp index 677c726..7d2c8bc 100644 --- a/Ext2Mgr/enumDisk.cpp +++ b/Ext2Mgr/enumDisk.cpp @@ -1,5512 +1,5512 @@ - -#include "stdafx.h" -#include "mountmgr.h" - -/* global management information */ - -BOOL g_bAutoMount = 0; - -ULONG g_nFlps = 0; -ULONG g_nDisks = 0; -ULONG g_nCdroms = 0; -ULONG g_nVols = 0; - -EXT2_LETTER drvLetters[26]; -EXT2_LETTER drvDigits[10]; - -ULONGLONG Ext2DrvLetters[2] = {(ULONGLONG)-1, (ULONGLONG)-1}; - -PEXT2_DISK gDisks = NULL; -PEXT2_CDROM gCdroms = NULL; -PEXT2_VOLUME gVols = NULL; - -/* information string array */ - -typedef struct { - int PartitionType; - char *type; -} PARTITION_LIST; - -typedef struct { - UINT DriveType; - char *type; -} DRIVE_LIST; - -typedef struct { - DEVICE_TYPE DeviceType; - char *type; -} DEVICE_LIST; - -typedef struct { - STORAGE_BUS_TYPE BusType; - char *type; -} BUSTYPE_LIST; - -CHAR * -IrpMjStrings[] = { - "IRP_MJ_CREATE", - "IRP_MJ_CREATE_NAMED_PIPE", - "IRP_MJ_CLOSE", - "IRP_MJ_READ", - "IRP_MJ_WRITE", - "IRP_MJ_QUERY_INFORMATION", - "IRP_MJ_SET_INFORMATION", - "IRP_MJ_QUERY_EA", - "IRP_MJ_SET_EA", - "IRP_MJ_FLUSH_BUFFERS", - "IRP_MJ_QUERY_VOLUME_INFORMATION", - "IRP_MJ_SET_VOLUME_INFORMATION", - "IRP_MJ_DIRECTORY_CONTROL", - "IRP_MJ_FILE_SYSTEM_CONTROL", - "IRP_MJ_DEVICE_CONTROL", - "IRP_MJ_INTERNAL_DEVICE_CONTROL", - "IRP_MJ_SHUTDOWN", - "IRP_MJ_LOCK_CONTROL", - "IRP_MJ_CLEANUP", - "IRP_MJ_CREATE_MAILSLOT", - "IRP_MJ_QUERY_SECURITY", - "IRP_MJ_SET_SECURITY", - "IRP_MJ_POWER", - "IRP_MJ_SYSTEM_CONTROL", - "IRP_MJ_DEVICE_CHANGE", - "IRP_MJ_QUERY_QUOTA", - "IRP_MJ_SET_QUOTA", - "IRP_MJ_PNP" -}; - -CHAR * -PerfStatStrings[] = { - "IRP_CONTEXT", - "VCB", - "FCB", - "CCB", - "MCB", - "EXTENT", - "RW_CONTEXT", - "VPB", - "FCB_NAME", - "MCB_NAME", - "FILE_NAME", - "DIR_ENTRY", - "DIR_PATTERN", - "DISK_EVENT", - "DISK_BUFFER", - "BLOCK_DATA", - "inode", - "dentry", - "buffer head", - NULL - }; - -PARTITION_LIST PartitionList[] = { - {PARTITION_ENTRY_UNUSED , "Empty"}, - {PARTITION_FAT_12 , "FAT12"}, /* 01 */ - {PARTITION_XENIX_1 , "Xenix-1"}, /* 02 */ - {PARTITION_XENIX_2 , "Xenix-2"}, - {PARTITION_FAT_16 , "FAT16"}, /* 04 */ - {PARTITION_EXTENDED , "Extended"}, - {PARTITION_HUGE , "FAT16 HUGE"}, /* 06*/ - {PARTITION_IFS , "HPFS/NTFS"}, /* 07 */ - - {PARTITION_OS2BOOTMGR, "OS/2"}, /* 0A */ - {PARTITION_FAT32 , "FAT32"}, /* 0B */ - {PARTITION_FAT32_XINT13 , "FAT32X"}, /* 0C*/ - {PARTITION_XINT13 , "XINT13"}, /* 0E */ - {PARTITION_XINT13_EXTENDED ,"EXINT13"}, /* 0F */ - {0x11 , "Hidden FAT12"}, - {0x14 , "Hidden FAT16"}, - {0x16 , "Hidden FAT16"}, - {0x17 , "Hidden HPFS/NTFS"}, - - {0x1B , "Hidden FAT32"}, - {0x1C , "Hidden FAT32X"}, - - {PARTITION_PREP , "OS/2"}, /* 41 */ - {PARTITION_LDM , "LDM"}, /* 42 */ - - {0x52 , "CP/M"}, - - {PARTITION_UNIX , "UNIX"}, /* 63 */ - - {PARTITION_NTFT , "NTFT"}, /* 80 */ - {0x81, "Minix"}, - {0x82, "Linux swap"}, - {0x83, "Linux"}, - - {0x85, "Linux extend"}, - - {0x8e, "Linux LVM"}, - - {0xa5, "FreeBSD"}, - {0xa6, "OpenBSD"}, - - {0xa8, "Darwin UFS"}, - {0xa9, "NetBSD"}, - - {0xbe, "Solaris Boot"}, - {0xbf, "Solaris"}, - - {VALID_NTFT , "VNTFT"}, /* C0 */ - {-1 ,"UNKNOWN"} -}; - -DRIVE_LIST DriveList[] = { - {DRIVE_UNKNOWN, "Unkown"}, - {DRIVE_NO_ROOT_DIR, "NoRoot"}, - {DRIVE_REMOVABLE, "Removable"}, - {DRIVE_FIXED, "Fixed"}, - {DRIVE_REMOTE, "Remote"}, - {DRIVE_CDROM, "CDROM"}, - {DRIVE_RAMDISK, "RAMdisk"}, - {(UINT)-1, "Invalid"} -}; - -BUSTYPE_LIST BusTypeList[] = { - {BusTypeUnknown, "Unkown"}, - {BusTypeScsi, "SCSI"}, - {BusTypeAtapi, "ATAPI"}, - {BusTypeAta, "ATA"}, - {BusType1394, "1394"}, - {BusTypeSsa, "Ssa"}, - {BusTypeFibre, "Fibre"}, - {BusTypeUsb, "USB"}, - {BusTypeRAID, "RAID"}, - {(STORAGE_BUS_TYPE)-1, "Invalid"} -}; - - -DEVICE_LIST DeviceList[] = { - {FILE_DEVICE_8042_PORT ,"8042_PORT"}, - {FILE_DEVICE_ACPI ,"ACPI"}, - {FILE_DEVICE_BATTERY ,"BATTERY"}, - {FILE_DEVICE_BEEP ,"BEEP"}, - {FILE_DEVICE_BUS_EXTENDER ,"BUS_EXTENDER"}, - {FILE_DEVICE_CD_ROM ,"CD_ROM"}, - {FILE_DEVICE_CD_ROM_FILE_SYSTEM ,"CD_ROM_FILE_SYSTEM"}, - {FILE_DEVICE_CHANGER ,"CHANGER"}, - {FILE_DEVICE_CONTROLLER ,"CONTROLLER"}, - {FILE_DEVICE_DATALINK ,"DATALINK"}, - {FILE_DEVICE_DFS ,"DFS"}, - {FILE_DEVICE_DFS_FILE_SYSTEM ,"DFS_FILE_SYSTEM"}, - {FILE_DEVICE_DFS_VOLUME ,"DFS_VOLUME"}, - {FILE_DEVICE_DISK ,"DISK"}, - {FILE_DEVICE_DISK_FILE_SYSTEM ,"DISK_FILE_SYSTEM"}, - {FILE_DEVICE_DVD ,"DVD"}, - {FILE_DEVICE_FILE_SYSTEM ,"FILE_SYSTEM"}, - {0x0000003a /*FILE_DEVICE_FIPS*/ ,"FIPS"}, - {FILE_DEVICE_FULLSCREEN_VIDEO ,"FULLSCREEN_VIDEO"}, - {FILE_DEVICE_INPORT_PORT ,"INPORT_PORT"}, - {FILE_DEVICE_KEYBOARD ,"KEYBOARD"}, - {FILE_DEVICE_KS ,"KS"}, - {FILE_DEVICE_KSEC ,"KSEC"}, - {FILE_DEVICE_MAILSLOT ,"MAILSLOT"}, - {FILE_DEVICE_MASS_STORAGE ,"MASS_STORAGE"}, - {FILE_DEVICE_MIDI_IN ,"MIDI_IN"}, - {FILE_DEVICE_MIDI_OUT ,"MIDI_OUT"}, - {FILE_DEVICE_MODEM ,"MODEM"}, - {FILE_DEVICE_MOUSE ,"MOUSE"}, - {FILE_DEVICE_MULTI_UNC_PROVIDER ,"MULTI_UNC_PROVIDER"}, - {FILE_DEVICE_NAMED_PIPE ,"NAMED_PIPE"}, - {FILE_DEVICE_NETWORK ,"NETWORK"}, - {FILE_DEVICE_NETWORK_BROWSER ,"NETWORK_BROWSER"}, - {FILE_DEVICE_NETWORK_FILE_SYSTEM,"NETWORK_FILE_SYSTEM"}, - {FILE_DEVICE_NETWORK_REDIRECTOR ,"NETWORK_REDIRECTOR"}, - {FILE_DEVICE_NULL ,"NULL"}, - {FILE_DEVICE_PARALLEL_PORT ,"PARALLEL_PORT"}, - {FILE_DEVICE_PHYSICAL_NETCARD ,"PHYSICAL_NETCARD"}, - {FILE_DEVICE_PRINTER ,"PRINTER"}, - {FILE_DEVICE_SCANNER ,"SCANNER"}, - {FILE_DEVICE_SCREEN ,"SCREEN"}, - {FILE_DEVICE_SERENUM ,"SERENUM"}, - {FILE_DEVICE_SERIAL_MOUSE_PORT ,"SERIAL_MOUSE_PORT"}, - {FILE_DEVICE_SERIAL_PORT ,"SERIAL_PORT"}, - {FILE_DEVICE_SMARTCARD ,"SMARTCARD"}, - {FILE_DEVICE_SMB ,"SMB"}, - {FILE_DEVICE_SOUND ,"SOUND"}, - {FILE_DEVICE_STREAMS ,"STREAMS"}, - {FILE_DEVICE_TAPE ,"TAPE"}, - {FILE_DEVICE_TAPE_FILE_SYSTEM ,"TAPE_FILE_SYSTEM"}, - {FILE_DEVICE_TERMSRV ,"TERMSRV"}, - {FILE_DEVICE_TRANSPORT ,"TRANSPORT"}, - {FILE_DEVICE_UNKNOWN ,"UNKNOWN"}, - {FILE_DEVICE_VDM ,"VDM"}, - {FILE_DEVICE_VIDEO ,"VIDEO"}, - {FILE_DEVICE_VIRTUAL_DISK ,"VIRTUAL_DISK"}, - {FILE_DEVICE_WAVE_IN ,"WAVE_IN"}, - {FILE_DEVICE_WAVE_OUT ,"WAVE_OUT"}, - {(DEVICE_TYPE)-1 ,"UNKNOWN"} -}; - -char *PartitionString(int type) -{ - PARTITION_LIST *p = PartitionList; - - while ( p->PartitionType != -1 ) { - if ( type == p->PartitionType ) { - return p->type; - } - p++; - } - return p->type; -} - -char *DriveTypeString(UINT media) -{ - DRIVE_LIST *p = DriveList; - - while ( p->DriveType != (UINT)-1 ) { - if ( media == p->DriveType ) { - return p->type; - } - p++; - } - return p->type; -} - -char *DeviceTypeString(DEVICE_TYPE media) -{ - DEVICE_LIST *p = DeviceList; - - while ( p->DeviceType != (DEVICE_TYPE)-1 ) { - if ( media == p->DeviceType ) { - return p->type; - } - p++; - } - return p->type; -} - -char *BusTypeString(STORAGE_BUS_TYPE BusType) -{ - BUSTYPE_LIST *p = BusTypeList; - - while ( p->BusType != (STORAGE_BUS_TYPE)-1 ) { - if ( BusType == p->BusType ) { - return p->type; - } - p++; - } - - return p->type; -} - -/* Ext2Fsd supported codepages */ - -CHAR * gCodepages[] = - { - "default", - "cp936", - "gb2312", - "utf8", - "cp1251", - "cp1255", - "cp437", - "cp737", - "cp775", - "cp850", - "cp852", - "cp855", - "cp857", - "cp860", - "cp861", - "cp862", - "cp863", - "cp864", - "cp865", - "cp866", - "cp869", - "cp874", - "tis-620", - "cp932", - "euc-jp", - "sjis", - "cp949", - "euc-kr", - "cp950", - "big5", - "iso8859-1", - "iso8859-13", - "iso8859-14", - "iso8859-15", - "iso8859-2", - "iso8859-3", - "iso8859-4", - "iso8859-5", - "iso8859-6", - "iso8859-7", - "iso8859-8", - "iso8859-9", - "koi8-r", - "koi8-u", - "koi8-ru", - "cp1250", - "acsii", - NULL - }; - -/* routines */ - -BOOL g_isWow64 = FALSE; -BOOL g_isX64 = FALSE; - -#define PROCESSOR_ARCHITECTURE_AMD64 9 - -typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); -LPFN_ISWOW64PROCESS fnIsWow64Process = NULL; - -typedef void (WINAPI *LPFN_GETNATIVESYSINFO)( - LPSYSTEM_INFO lpSystemInfo); - -LPFN_GETNATIVESYSINFO fnGetNativeSystemInfo = NULL; -BOOL Ext2IsWow64() -{ - if (NULL != fnIsWow64Process) { - if (!fnIsWow64Process(GetCurrentProcess(), &g_isWow64)) { - } - } - return g_isWow64; -} - - -BOOL Ext2IsX64System() -{ - SYSTEM_INFO sysInfo; - fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress( - GetModuleHandle("kernel32"), "IsWow64Process"); - - fnGetNativeSystemInfo = (LPFN_GETNATIVESYSINFO)GetProcAddress( - GetModuleHandle("kernel32"), "GetNativeSystemInfo"); - - if (fnGetNativeSystemInfo) { - fnGetNativeSystemInfo(&sysInfo); - - if (sysInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 && - Ext2IsWow64()) { - g_isWow64 = TRUE; - return TRUE; - } - } - - return FALSE; -} - -BOOL IsVistaOrAbove() -{ - OSVERSIONINFO OsVerInfo; - - OsVerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - - if (GetVersionEx(&OsVerInfo)) { - - if (OsVerInfo.dwMajorVersion == 6 && OsVerInfo.dwBuildNumber > 3790) - return TRUE; - - if (OsVerInfo.dwMajorVersion > 6) - return TRUE; - } - - return FALSE; -} - -BOOL CanDoLocalMount() -{ - return !IsWindowsVistaOrGreater(); -} - -BOOL -IsWindows2000() -{ - OSVERSIONINFO OsVer; - memset(&OsVer, 0, sizeof(OsVer)); - OsVer.dwOSVersionInfoSize = sizeof(OsVer); - - if (GetVersionEx(&OsVer)) { - if (OsVer.dwPlatformId == VER_PLATFORM_WIN32_NT && - OsVer.dwMajorVersion <= 5 && - OsVer.dwMinorVersion == 0) { - return TRUE; - } - } else { - return TRUE; - } - - return FALSE; -} - -BOOL Ext2DismountVolume(CHAR *voldev) -{ - - HANDLE device; - ULONG bytes; - BOOL rc = FALSE; - - device = CreateFile(voldev, GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - - if (device == INVALID_HANDLE_VALUE) { - goto errorout; - } - - if (!DeviceIoControl(device, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0, - &bytes, NULL)) { - } - - rc = DeviceIoControl(device, FSCTL_DISMOUNT_VOLUME, NULL, 0, NULL, 0, - &bytes, NULL); - CloseHandle(device); - -errorout: - - return rc; -} - -/* - * Ext2LockVolume - * Lock the volume ... - * - * ARGUMENTS: - * VolumeHandle: Volume handle. - * - * RETURNS: - * Success or Fail - * - * NOTES: - * N/A - */ - - -NT::NTSTATUS -Ext2LockVolume(HANDLE Handle) -{ - NT::NTSTATUS status; - NT::IO_STATUS_BLOCK ioSb; - - status = NT::ZwFsControlFile( - Handle, NULL, NULL, NULL, &ioSb, - FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0); - return status; -} - - -NT::NTSTATUS -Ext2UnLockVolume(HANDLE Handle) -{ - NT::NTSTATUS status; - NT::IO_STATUS_BLOCK ioSb; - - status = NT::ZwFsControlFile( - Handle, NULL, NULL, NULL, &ioSb, - FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0); - return status; -} - - -NT::NTSTATUS -Ext2DisMountVolume(HANDLE Handle) -{ - NT::NTSTATUS status; - NT::IO_STATUS_BLOCK ioSb; - - status = NT::ZwFsControlFile( - Handle, NULL, NULL, NULL, &ioSb, - FSCTL_DISMOUNT_VOLUME, NULL, 0, NULL, 0); - - return status; -} - -PDRIVE_LAYOUT_INFORMATION_EXT -Ext2QueryDriveLayout( - HANDLE Handle, - PUCHAR NumOfParts - ) -{ - NT::IO_STATUS_BLOCK ioSb; - NT::NTSTATUS status; - - PDRIVE_LAYOUT_INFORMATION_EXT driveLayout = NULL; - ULONG dataSize = 512; - ULONG retSize = 0; - -QueryDrive: - - status = STATUS_SUCCESS; - driveLayout = (PDRIVE_LAYOUT_INFORMATION_EXT) malloc(dataSize); - if(!driveLayout) { - goto errorout; - } - memset(driveLayout, 0, dataSize); - - if (IsWindows2000()) { - - PDRIVE_LAYOUT_INFORMATION oldLayout = - (PDRIVE_LAYOUT_INFORMATION ) malloc(dataSize); - if (!oldLayout) { - goto errorout; - } - - status = NT::ZwDeviceIoControlFile( - Handle, NULL, NULL, NULL, &ioSb, - IOCTL_DISK_GET_DRIVE_LAYOUT, - NULL, 0, (PVOID)oldLayout, dataSize - ); - - if (NT_SUCCESS(status)) { - - ULONG newLayoutSize = FIELD_OFFSET(DRIVE_LAYOUT_INFORMATION_EX, PartitionEntry); - newLayoutSize += sizeof(PARTITION_INFORMATION_EX) * oldLayout->PartitionCount; - - if (dataSize >= newLayoutSize) { - - driveLayout->PartitionStyle = PARTITION_STYLE_MBR; - driveLayout->PartitionCount = oldLayout->PartitionCount; - driveLayout->Mbr.Signature = oldLayout->Signature; - - for (DWORD i=0; i < oldLayout->PartitionCount; i++) { - driveLayout->PartitionEntry[i].PartitionStyle = PARTITION_STYLE_MBR; - - driveLayout->PartitionEntry[i].StartingOffset = - oldLayout->PartitionEntry[i].StartingOffset; - driveLayout->PartitionEntry[i].PartitionLength = - oldLayout->PartitionEntry[i].PartitionLength; - driveLayout->PartitionEntry[i].PartitionNumber = - oldLayout->PartitionEntry[i].PartitionNumber; - driveLayout->PartitionEntry[i].RewritePartition = - oldLayout->PartitionEntry[i].RewritePartition; - driveLayout->PartitionEntry[i].Mbr.PartitionType = - oldLayout->PartitionEntry[i].PartitionType; - driveLayout->PartitionEntry[i].Mbr.BootIndicator = - oldLayout->PartitionEntry[i].BootIndicator; - driveLayout->PartitionEntry[i].Mbr.RecognizedPartition = - oldLayout->PartitionEntry[i].RecognizedPartition; - driveLayout->PartitionEntry[i].Mbr.HiddenSectors = - oldLayout->PartitionEntry[i].HiddenSectors; - } - - } else { - dataSize = newLayoutSize; - status = STATUS_BUFFER_TOO_SMALL; - } - } - - free(oldLayout); - - } else { - - status = NT::ZwDeviceIoControlFile( - Handle, NULL, NULL, NULL, &ioSb, - IOCTL_DISK_GET_DRIVE_LAYOUT_EXT, - NULL, 0, (PVOID)driveLayout, dataSize - ); - } - - if (status == STATUS_BUFFER_TOO_SMALL) { - free(driveLayout); driveLayout = NULL; - dataSize *= 2; - goto QueryDrive; - } - - if (!NT_SUCCESS(status)) { - free(driveLayout); driveLayout = NULL; - goto errorout; - } - - retSize = FIELD_OFFSET(DRIVE_LAYOUT_INFORMATION_EXT, PartitionEntry); - retSize += sizeof(PARTITION_INFORMATION) * driveLayout->PartitionCount; - - if (driveLayout->PartitionStyle == PARTITION_STYLE_MBR) { - - PPARTITION_INFORMATION_EXT Part; - UCHAR i = 0, cnt = 0; - - /* Now walk the Drive_Layout to count the partitions */ - while (i < (UCHAR)driveLayout->PartitionCount) { - Part = &driveLayout->PartitionEntry[i++]; - if (Part->Mbr.PartitionType != PARTITION_ENTRY_UNUSED && - Part->Mbr.PartitionType != PARTITION_EXTENDED && - Part->Mbr.PartitionType != PARTITION_XINT13_EXTENDED) { - cnt++; - } - } - *NumOfParts = cnt; - } else if (driveLayout->PartitionStyle == PARTITION_STYLE_GPT) { - *NumOfParts = (UCHAR)driveLayout->PartitionCount; - } else { - *NumOfParts = 0; - free(driveLayout); driveLayout = NULL; - } - - if (*NumOfParts == 0) { - free(driveLayout); driveLayout = NULL; - } - - -errorout: - - return driveLayout; -} - -NT::NTSTATUS -Ext2SetDriveLayout( - HANDLE Handle, - PDRIVE_LAYOUT_INFORMATION_EXT Layout - ) -{ - NT::IO_STATUS_BLOCK ioSb; - NT::NTSTATUS status = STATUS_SUCCESS; - ULONG dataSize; - - dataSize = FIELD_OFFSET(DRIVE_LAYOUT_INFORMATION_EXT, PartitionEntry); - dataSize += sizeof(PARTITION_INFORMATION_EXT) * Layout->PartitionCount; - - if (IsWindows2000()) { - - if (Layout->PartitionStyle != PARTITION_STYLE_MBR) { - return STATUS_UNSUCCESSFUL; - } - - ULONG newLayoutSize = FIELD_OFFSET(DRIVE_LAYOUT_INFORMATION, PartitionEntry); - newLayoutSize += sizeof(PARTITION_INFORMATION) * Layout->PartitionCount; - - PDRIVE_LAYOUT_INFORMATION oldLayout = - (PDRIVE_LAYOUT_INFORMATION ) malloc(newLayoutSize); - if (!oldLayout) { - goto errorout; - } - - oldLayout->PartitionCount = Layout->PartitionCount; - oldLayout->Signature = Layout->Mbr.Signature; - - for (DWORD i=0; i < oldLayout->PartitionCount; i++) { - - oldLayout->PartitionEntry[i].StartingOffset = - Layout->PartitionEntry[i].StartingOffset; - oldLayout->PartitionEntry[i].PartitionLength = - Layout->PartitionEntry[i].PartitionLength; - oldLayout->PartitionEntry[i].PartitionNumber = - Layout->PartitionEntry[i].PartitionNumber; - oldLayout->PartitionEntry[i].RewritePartition = - Layout->PartitionEntry[i].RewritePartition; - oldLayout->PartitionEntry[i].PartitionType = - Layout->PartitionEntry[i].Mbr.PartitionType; - oldLayout->PartitionEntry[i].BootIndicator = - Layout->PartitionEntry[i].Mbr.BootIndicator; - oldLayout->PartitionEntry[i].RecognizedPartition = - Layout->PartitionEntry[i].Mbr.RecognizedPartition; - oldLayout->PartitionEntry[i].HiddenSectors = - Layout->PartitionEntry[i].Mbr.HiddenSectors; - } - - status = NT::ZwDeviceIoControlFile( - Handle, NULL, NULL, NULL, &ioSb, - IOCTL_DISK_SET_DRIVE_LAYOUT, - (PVOID)oldLayout, newLayoutSize, - NULL, 0 - ); - - free(oldLayout); - - } else { - - status = NT::ZwDeviceIoControlFile( - Handle, NULL, NULL, NULL, &ioSb, - IOCTL_DISK_SET_DRIVE_LAYOUT_EXT, - (PVOID)Layout, dataSize,NULL, 0 - ); - } - - return status; - -errorout: - - return STATUS_UNSUCCESSFUL; -} - -BOOL -Ext2IsDeviceValid(CHAR *Device) -{ - HANDLE handle = NULL; - NT::NTSTATUS status; - - status = Ext2Open(Device, &handle, EXT2_DESIRED_ACCESS); - if (!NT_SUCCESS(status)) { - goto errorout; - } - -errorout: - - if (handle) { - Ext2Close(&handle); - } - - return NT_SUCCESS(status); -} - - -BOOL -Ext2SetPartitionType( - PEXT2_PARTITION Part, - BYTE Type - ) -{ - BOOL rc = FALSE; - HANDLE Handle = NULL; - NT::NTSTATUS status; - - UCHAR NumParts = 0; - PDRIVE_LAYOUT_INFORMATION_EXT Layout = NULL; - - DWORD i; - - status = Ext2Open(Part->Disk->Name, &Handle, - EXT2_DESIRED_ACCESS | GENERIC_WRITE); - if (!NT_SUCCESS(status)) { - goto errorout; - } - - Layout = Part->Disk->Layout; - - if (!Layout) { - goto errorout; - } - - if (Layout->PartitionStyle != PARTITION_STYLE_MBR) { - goto errorout; - } - - for (i=0; i < Layout->PartitionCount; i++) { - - if ((Layout->PartitionEntry[i].StartingOffset.QuadPart == - Part->Entry->StartingOffset.QuadPart) && - (Layout->PartitionEntry[i].PartitionLength.QuadPart == - Part->Entry->PartitionLength.QuadPart) && - (Layout->PartitionEntry[i].PartitionNumber == - Part->Entry->PartitionNumber) ) { - - Layout->PartitionEntry[i].Mbr.PartitionType = Type; - Layout->PartitionEntry[i].RewritePartition = TRUE; - - rc = TRUE; - break; - } - } - - if (!rc) { - goto errorout; - } - - status = Ext2SetDriveLayout(Handle, Layout); - rc = NT_SUCCESS(status); - -errorout: - - Ext2Close(&Handle); - - return rc; -} - - -BOOL -Ext2FlushVolume(CHAR *Device) -{ - HANDLE handle = NULL; - NT::NTSTATUS status; - NT::IO_STATUS_BLOCK iosb; - - status = Ext2Open(Device, &handle, EXT2_DESIRED_ACCESS | GENERIC_WRITE); - if (!NT_SUCCESS(status)) { - goto errorout; - } - - status = NT::ZwFlushBuffersFile(handle, &iosb); - -errorout: - - if (handle) { - Ext2Close(&handle); - } - - return NT_SUCCESS(status); -} - -PEXT2_PARTITION -Ext2QueryVolumePartition( - PEXT2_VOLUME Volume - ) -{ - PEXT2_PARTITION Part = NULL; - DWORD i, j; - - for (i=0; i < g_nDisks; i++) { - for (j=0; j < (int)gDisks[i].NumParts; j++) { - if (gDisks[i].DataParts[j].Volume == Volume) { - Part = &gDisks[i].DataParts[j]; - break; - } - } - } - - return Part; -} - -NT::NTSTATUS -Ext2QueryProperty( - HANDLE Handle, - STORAGE_PROPERTY_ID Id, - PVOID DescBuf, - ULONG DescSize - ) -{ - STORAGE_PROPERTY_QUERY SPQ; - NT::NTSTATUS status; - NT::IO_STATUS_BLOCK ioSb; - - SPQ.PropertyId = Id; - SPQ.QueryType = PropertyStandardQuery; - - memset(DescBuf, 0, DescSize); - - status = NT::ZwDeviceIoControlFile( - Handle, NULL, NULL, NULL, &ioSb, - IOCTL_STORAGE_QUERY_PROPERTY, - &SPQ, sizeof(STORAGE_PROPERTY_QUERY), - DescBuf, DescSize - ); - - return status; -} - -/* - * Ext2QueryDisk - * Get volume gemmetry information ... - * - * ARGUMENTS: - * VolumeHandle: Volume handle. - * - * RETURNS: - * Success or Fail - * - * NOTES: - * N/A - */ - -NT::NTSTATUS -Ext2QueryDisk( - HANDLE Handle, - PDISK_GEOMETRY DiskGeometry - ) -{ - NT::NTSTATUS status; - NT::IO_STATUS_BLOCK ioSb; - - status = NT::ZwDeviceIoControlFile( - Handle, NULL, NULL, NULL, &ioSb, - IOCTL_DISK_GET_DRIVE_GEOMETRY, - DiskGeometry, sizeof(DISK_GEOMETRY), - DiskGeometry, sizeof(DISK_GEOMETRY)); - - - if (!NT_SUCCESS(status)) { - goto errorout; - } - -errorout: - - return status; -} - -PVOLUME_DISK_EXTENTS -Ext2QueryVolumeExtents(HANDLE hVolume) -{ - ULONG dataSize = 1024; - PVOLUME_DISK_EXTENTS dskExtents = NULL; - - NT::NTSTATUS status; - NT::IO_STATUS_BLOCK ioSb; - -QueryExtent: - - dskExtents = (PVOLUME_DISK_EXTENTS)malloc(dataSize); - if (NULL == dskExtents) { - goto errorout; - } - - status = NT::ZwDeviceIoControlFile( - hVolume, NULL, NULL, NULL, &ioSb, - IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, - NULL, 0, dskExtents, dataSize ); - - if (status == STATUS_BUFFER_TOO_SMALL) { - free(dskExtents); dskExtents = NULL; - dataSize += 1024; - goto QueryExtent; - } - - if (!NT_SUCCESS(status)) { - free(dskExtents); dskExtents = NULL; - goto errorout; - } - -errorout: - - return dskExtents; -} - -PSTORAGE_DEVICE_NUMBER -Ext2QueryDeviceNumber(HANDLE hVolume) -{ - ULONG dataSize; - PSTORAGE_DEVICE_NUMBER SDN = NULL; - - NT::NTSTATUS status; - NT::IO_STATUS_BLOCK ioSb; - - dataSize = sizeof(STORAGE_DEVICE_NUMBER); - -QuerySDN: - - SDN = (PSTORAGE_DEVICE_NUMBER)malloc(dataSize); - if (NULL == SDN) { - goto errorout; - } - memset(SDN, 0, dataSize); - - status = NT::ZwDeviceIoControlFile( - hVolume, NULL, NULL, NULL, &ioSb, - IOCTL_STORAGE_GET_DEVICE_NUMBER, - NULL, 0, SDN, dataSize ); - - if (status == STATUS_BUFFER_TOO_SMALL) { - free(SDN); SDN = NULL; - dataSize += sizeof(STORAGE_DEVICE_NUMBER); - goto QuerySDN; - } - - if (!NT_SUCCESS(status)) { - free(SDN); SDN = NULL; - goto errorout; - } - -errorout: - - return SDN; -} - -BOOL -Ext2QueryDrvLetter( - PEXT2_LETTER drvLetter - ) -{ - HANDLE hVolume; - NT::NTSTATUS status = STATUS_SUCCESS; - DWORD rc = 0; - - drvLetter->DrvType = Ext2QueryDrive(drvLetter->Letter, - drvLetter->SymLink); - - if (drvLetter->DrvType == DRIVE_NO_ROOT_DIR) { - drvLetter->bUsed = FALSE; - goto errorout; - } else { - drvLetter->bUsed = TRUE; - } - - if (drvLetter->Letter == 'A' || - drvLetter->Letter == 'B' ) { - drvLetter->bUsed = TRUE; - goto errorout; - } - - if (drvLetter->DrvType == DRIVE_REMOVABLE || - drvLetter->DrvType == DRIVE_FIXED) { - - status = Ext2Open(drvLetter->SymLink, &hVolume, EXT2_DESIRED_ACCESS); - if (!NT_SUCCESS(status) && status != STATUS_ACCESS_DENIED) { - drvLetter->bInvalid = TRUE; - goto errorout; - } - - drvLetter->Extent = Ext2QueryVolumeExtents(hVolume); - if (drvLetter->DrvType == DRIVE_REMOVABLE) { - drvLetter->SDN = Ext2QueryDeviceNumber(hVolume); - } - - Ext2Close(&hVolume); - } - -errorout: - - return NT_SUCCESS(status); -} - - -PEXT2_LETTER Ext2GetFirstUnusedDrvLetter() -{ - PEXT2_LETTER drvLetter = NULL; - CHAR devPath[] = "C:"; - int i; - - for (i = 5; i < 24; i++) { - drvLetter = &drvLetters[i]; - if (drvLetter->DrvType == DRIVE_NO_ROOT_DIR) { - drvLetter->DrvType = Ext2QueryDrive(drvLetter->Letter, - drvLetter->SymLink); - if (drvLetter->DrvType == DRIVE_NO_ROOT_DIR) { - /* we got it */ - break; - } else { - /* we need do a new refresh */ - } - } - drvLetter = NULL; - } - - return drvLetter; -} - - -CHAR Ext2MountVolume(CHAR *voldev) -{ - PEXT2_LETTER drvLetter; - CHAR rc = 0; - - /* query drive letter to check whether it's mounted */ - drvLetter = Ext2GetFirstUnusedDrvLetter(); - if (!drvLetter) { - goto errorout; - } - - if (Ext2AssignDrvLetter(drvLetter, voldev, FALSE)) { - rc = drvLetter->Letter; - } - -errorout: - - return rc; -} - -CHAR Ext2MountVolumeAs(CHAR *voldev, CHAR DrvLetter) -{ - PEXT2_LETTER drvLetter; - CHAR rc = 0; - - - if (DrvLetter >= '0' && DrvLetter <= '9') { - drvLetter = &drvDigits[DrvLetter - '0']; - } else if (DrvLetter >= 'A' && DrvLetter <= 'Z') { - drvLetter = &drvLetters[DrvLetter - 'A']; - } else if (DrvLetter >= 'a' && DrvLetter <= 'z') { - drvLetter = &drvLetters[DrvLetter - 'a']; - } - - if (!drvLetter || drvLetter->bUsed) { - goto errorout; - } - - if (Ext2AssignDrvLetter(drvLetter, voldev, FALSE)) { - rc = drvLetter->Letter; - } - -errorout: - - return rc; -} - -NT::NTSTATUS -Ext2QueryMediaType( - HANDLE Handle, - PDWORD MediaType - ) -{ - NT::NTSTATUS status; - NT::IO_STATUS_BLOCK ioSb; - PGET_MEDIA_TYPES mediaTypes; - UCHAR buffer[1024]; - - status = NT::ZwDeviceIoControlFile( - Handle, NULL, NULL, NULL, &ioSb, - IOCTL_STORAGE_GET_MEDIA_TYPES_EX, - NULL, 0, buffer, 1024 ); - - - if (!NT_SUCCESS(status)) { - goto errorout; - } - - mediaTypes = (PGET_MEDIA_TYPES) buffer; - *MediaType = mediaTypes->DeviceType; - -errorout: - - return status; -} - -/* - * Ext2Read - * Read data from disk or file ... - * - * ARGUMENTS: - * VolumeHandle: Volume Handle - * Offset : Disk Offset - * Length : Data Length to be read - * Buffer : ... - * - * RETURNS: - * Success: STATUS_SUCCESS - * Fail: ... - * - * NOTES: - * Both Length and Offset should be SECTOR_SIZE aligned. - */ -NT::NTSTATUS -Ext2Read( - IN HANDLE Handle, - IN BOOL IsFile, - IN ULONG SectorSize, - IN ULONGLONG Offset, - IN ULONG Length, - IN PVOID Buffer - ) -{ - NT::NTSTATUS status; - NT::IO_STATUS_BLOCK ioSb; - LARGE_INTEGER address; - ULONG aLength = 0; - PVOID aBuffer = NULL; - - if (SectorSize == 0 || SectorSize == 1) - IsFile = TRUE; - - ASSERT(Buffer != NULL); - - if (IsFile) { - - address.QuadPart = Offset; - status = NT::ZwReadFile( - Handle, 0, NULL, NULL, &ioSb, - Buffer, Length, &address, NULL - ); - } else { - - address.QuadPart = Offset & (~((ULONGLONG)SectorSize - 1)); - aLength = (Length + SectorSize - 1)&(~(SectorSize - 1)); - aLength += ((ULONG)(Offset - address.QuadPart) + SectorSize - 1) - & (~(SectorSize - 1)); - - aBuffer = malloc(aLength); - if (!aBuffer) { - status = STATUS_INSUFFICIENT_RESOURCES; - goto errorout; - } - - status = NT::ZwReadFile( - Handle, 0, NULL, NULL, &ioSb, - aBuffer, aLength, &address, NULL - ); - - if (!NT_SUCCESS(status)) { - goto errorout; - } - - memmove( Buffer, (PUCHAR)aBuffer + - (ULONG)(Offset - address.QuadPart), Length); - } - -errorout: - - if (aBuffer) - free(aBuffer); - - return status; -} - -/* - * Ext2Write - * Write data to disk or file ... - * - * ARGUMENTS: - * VolumeHandle: Volume Handle - * Offset : Disk Offset - * Length : Data Length to be written - * Buffer : Data to be written ... - * - * RETURNS: - * Success: STATUS_SUCCESS - * Fail: ... - * - * NOTES: - * Both Length and Offset should be SECTOR_SIZE aligned. - */ - -NT::NTSTATUS -Ext2WriteDisk( - HANDLE Handle, - BOOL IsFile, - ULONG SectorSize, - ULONGLONG Offset, - ULONG Length, - PVOID Buffer - ) -{ - LARGE_INTEGER address; - NT::NTSTATUS status; - NT::IO_STATUS_BLOCK ioSb; - - ULONG aLength = 0; - PVOID aBuffer = NULL; - - if (SectorSize == 0 || SectorSize == 1) - IsFile = TRUE; - - ASSERT(Buffer != NULL); - - if (IsFile) { - - address.QuadPart = Offset; - status = NT::ZwWriteFile( - Handle, 0, NULL, NULL, &ioSb, - Buffer, Length, &address, NULL - ); - } else { - - address.QuadPart = Offset & (~((ULONGLONG)SectorSize - 1)); - aLength = (Length + SectorSize - 1)&(~(SectorSize - 1)); - aLength += ((ULONG)(Offset - address.QuadPart) + SectorSize - 1) - & (~(SectorSize - 1)); - - aBuffer = malloc(aLength); - if (!aBuffer) { - status = STATUS_INSUFFICIENT_RESOURCES; - goto errorout; - } - - if ( (aLength != Length) || - (address.QuadPart != (LONGLONG)Offset)) { - status = NT::ZwReadFile( - Handle, 0, NULL, NULL, &ioSb, - aBuffer, aLength, &address, NULL - ); - - if (!NT_SUCCESS(status)) { - goto errorout; - } - } - - memmove((PUCHAR)aBuffer + (ULONG)(Offset - address.QuadPart), - Buffer, Length); - status = NT::ZwWriteFile( - Handle, 0, NULL, NULL, &ioSb, - aBuffer, aLength, &address, NULL - ); - } - -errorout: - - if (aBuffer) - free(aBuffer); - - return status; -} - -NT::NTSTATUS -Ext2Open( - PCHAR FileName, - PHANDLE Handle, - ULONG DesiredAccess - ) -{ - NT::IO_STATUS_BLOCK iosb; - NT::NTSTATUS status; - NT::ANSI_STRING AnsiFilespec; - NT::UNICODE_STRING UnicodeFilespec; - NT::OBJECT_ATTRIBUTES ObjectAttributes; - - SHORT UnicodeName[MAX_PATH]; - CHAR AnsiName[MAX_PATH]; - USHORT NameLength = 0; - - memset(UnicodeName, 0, sizeof(SHORT) * MAX_PATH); - memset(AnsiName, 0, sizeof(UCHAR) * MAX_PATH); - - NameLength = (USHORT)strlen(FileName); - ASSERT(NameLength < MAX_PATH); - - if (FileName[0] == '\\') { - memmove(AnsiName, FileName, NameLength); - } else { - memmove(&AnsiName[0], "\\DosDevices\\", 12); - memmove(&AnsiName[12], FileName, NameLength); - NameLength += 12; - } - - AnsiFilespec.MaximumLength = AnsiFilespec.Length = NameLength; - AnsiFilespec.Buffer = AnsiName; - - UnicodeFilespec.MaximumLength = MAX_PATH * 2; - UnicodeFilespec.Length = 0; - UnicodeFilespec.Buffer = (PWSTR)UnicodeName; - - NT::RtlAnsiStringToUnicodeString(&UnicodeFilespec, &AnsiFilespec, FALSE); - - // - // Setup the name in an object attributes structure. - // Note that we create a name that is case INsensitive - // - - ObjectAttributes.Length = sizeof(NT::OBJECT_ATTRIBUTES); - ObjectAttributes.RootDirectory = NULL; - ObjectAttributes.Attributes = 0; /*OBJ_CASE_INSENSITIVE;*/ - ObjectAttributes.ObjectName = &UnicodeFilespec; - ObjectAttributes.SecurityDescriptor = NULL; - ObjectAttributes.SecurityQualityOfService = NULL; - - // - // Do the create. In this particular case, we'll have the I/O Manager - // make our write requests syncrhonous for our convenience. - // - status = NT::ZwCreateFile( - Handle, // returned file handle - (DesiredAccess | SYNCHRONIZE), // desired access - &ObjectAttributes, // ptr to object attributes - &iosb, // ptr to I/O status block - 0, // allocation size - FILE_ATTRIBUTE_NORMAL, // file attributes - FILE_SHARE_WRITE | FILE_SHARE_READ, // share access - FILE_OPEN /*FILE_SUPERSEDE*/, // create disposition - FILE_SYNCHRONOUS_IO_NONALERT | // create options - ((DesiredAccess & GENERIC_WRITE) ? - FILE_NO_INTERMEDIATE_BUFFERING : 0), - NULL, // ptr to extended attributes - 0); // length of ea buffer - - // - // Check the system service status - // - if (!NT_SUCCESS(status)) { - return status; - } - - // - // Check the returned status too... - // - if (!NT_SUCCESS(iosb.Status)) { - return iosb.Status; - } - - return status; -} - -VOID -Ext2Close(HANDLE * Handle) -{ - NT::NTSTATUS status = 0; - if (Handle != NULL && *Handle != 0 && *Handle != INVALID_HANDLE_VALUE) { - status = NT::ZwClose(*Handle); - if (NT_SUCCESS(status)) { - *Handle = 0; - } else { - ::MessageBox(NULL, "Failed to close handle", "Ext2Close", MB_OK); - } - } -} - -BOOL -Ext2QuerySysConfig() -{ - NT::NTSTATUS status; - NT::_SYSTEM_CONFIGURATION_INFORMATION ConfigInfo; - - status = NT::ZwQuerySystemInformation( - NT::SystemConfigurationInformation, - &ConfigInfo, sizeof(ConfigInfo), 0); - if (NT_SUCCESS(status)) { - g_nDisks = ConfigInfo.DiskCount; - g_nFlps = ConfigInfo.FloppyCount; - g_nCdroms = ConfigInfo.CdRomCount; - return TRUE; - } - - return FALSE; -} - -BOOL -Ext2LoadDisks() -{ - ULONG i = 0, j = 0; - NT::NTSTATUS status; - CHAR drvName[MAX_PATH]; - - if (g_nDisks == 0) { - return FALSE; - } - - gDisks = (PEXT2_DISK) malloc(sizeof(EXT2_DISK) * g_nDisks); - if (gDisks == NULL) { - return FALSE; - } - memset(gDisks, 0, sizeof(EXT2_DISK) * g_nDisks); - - while (i < g_nDisks && j < 256) { - - HANDLE Handle = NULL; - - gDisks[i].Magic = EXT2_DISK_MAGIC; - gDisks[i].Null = EXT2_DISK_NULL_MAGIC; - gDisks[i].OrderNo = (UCHAR) j; - gDisks[i].bLoaded = FALSE; - sprintf(drvName, "PhysicalDrive%d\0", j); - if (QueryDosDevice(drvName, gDisks[i].Name, MAX_PATH) == 0) { - sprintf(gDisks[i].Name, "\\DosDevices\\PhysicalDrive%d\0", j); - } - j++; - - status = Ext2Open(gDisks[i].Name, &Handle, EXT2_DESIRED_ACCESS); - if (!NT_SUCCESS(status)) { - continue; - } - - status = Ext2QueryDisk(Handle, &gDisks[i].DiskGeometry); - if (NT_SUCCESS(status)) { - gDisks[i].bEjected = FALSE; - } else { - if (STATUS_NO_MEDIA_IN_DEVICE == status) { - gDisks[i].bEjected = TRUE; - } else { - goto Next; - } - } - - status = Ext2QueryProperty( Handle, StorageDeviceProperty, - (PVOID)&gDisks[i].SDD, - sizeof(STORAGE_DEVICE_DESCRIPTOR) - ); - if (!NT_SUCCESS(status)) { - goto Next; - } - - status = Ext2QueryProperty( Handle, StorageAdapterProperty, - (PVOID)&gDisks[i].SAD, - sizeof(STORAGE_ADAPTER_DESCRIPTOR) - ); - if (!NT_SUCCESS(status)) { - goto Next; - } - - if (!gDisks[i].bEjected) { - gDisks[i].Layout = Ext2QueryDriveLayout( - Handle, &gDisks[i].NumParts); - } - - gDisks[i].bLoaded = TRUE; - -Next: - - Ext2Close(&Handle); - i++; - } - - g_nDisks = i; - - return TRUE; -} - -CString -Ext2PartInformation(PEXT2_PARTITION part) -{ - CString s, ret=""; - - s.Format("\r\n Partition No: %d\r\n\r\n", part->Number); - if (!part->Entry) { - return ret; - } - - s = " Partition Type: "; - if (part->Entry->PartitionStyle == PARTITION_STYLE_MBR) { - s += PartitionString(part->Entry->Mbr.PartitionType); - } else if (part->Entry->PartitionStyle == PARTITION_STYLE_GPT){ - s += "GPT"; - if (part->Entry->Gpt.Name && wcslen(part->Entry->Gpt.Name)) { - s += ":"; - for (size_t i = 0; i < wcslen(part->Entry->Gpt.Name); i++) - s += (CHAR)part->Entry->Gpt.Name[i]; - } - } else { - s += "GPT"; - } - ret += s; - ret += "\r\n"; - - s.Format(" StartingOffset: %I64u\r\n", part->Entry->StartingOffset.QuadPart); - ret += s; - - s.Format(" PartitionLength: %I64u\r\n", part->Entry->PartitionLength.QuadPart); - ret += s; - - /* mount points */ - ret += " MountPoints: "; - ret += Ext2QueryVolumeLetterStrings(part->DrvLetters, NULL); - ret += "\r\n"; - - if (!part->Volume) { - return ret; - } - - if (part->Volume->bRecognized) { - - ULONGLONG totalSize, freeSize; - - s.Format(" Filesystem: %s\r\n", part->Volume->FileSystem); - ret += s; - - if ((part->Volume->EVP.bExt2 || part->Volume->EVP.bExt3)) { - s = " codepage:"; - s += part->Volume->EVP.Codepage; - if (part->Volume->EVP.bReadonly) { - s += ",Readonly"; - } - } - ret += s; - ret += "\r\n"; - - totalSize = part->Volume->FssInfo.TotalAllocationUnits.QuadPart; - freeSize = part->Volume->FssInfo.AvailableAllocationUnits.QuadPart; - totalSize = totalSize * part->Volume->FssInfo.BytesPerSector * - part->Volume->FssInfo.SectorsPerAllocationUnit; - freeSize = freeSize * part->Volume->FssInfo.BytesPerSector * - part->Volume->FssInfo.SectorsPerAllocationUnit; - s.Format(" Size: %I64u\r\n", totalSize); - ret += s; - - s.Format(" Free: %I64u\r\n", freeSize); - ret += s; - } - - return ret; -} - -CString -Ext2DiskInformation(PEXT2_DISK disk) -{ - CString s, ret=""; - - s.Format("\r\nDisk %d: %s\r\n\r\n", disk->OrderNo, disk->Name); - ret += s; - - if (disk->SDD.VendorIdOffset) { - ret += "\r\n VendorId: "; - ret += (PCHAR)&disk->SDD + disk->SDD.VendorIdOffset; - ret += "\r\n"; - } - - if (disk->SDD.ProductIdOffset) { - ret += " ProductId: "; - ret += (PCHAR)&disk->SDD + disk->SDD.ProductIdOffset; - ret += "\r\n"; - } - - if (disk->SDD.SerialNumberOffset) { - ret += " SerialNumber: "; - ret += (PCHAR)&disk->SDD + disk->SDD.SerialNumberOffset; - ret += "\r\n"; - } - - ret += " BusType: "; - ret += BusTypeString(disk->SDD.BusType); - ret += "\r\n"; - - ret += " Media Type: "; - if (disk->SDD.RemovableMedia) { - ret += " Removable\r\n"; - } else { - s = "RAW"; - if (disk->Layout) { - if (disk->Layout->PartitionStyle == PARTITION_STYLE_MBR) { - if (disk->Layout->PartitionEntry->Mbr.PartitionType - == PARTITION_LDM) { - s.LoadString(IDS_DISK_TYPE_DYN); - } else { - s.LoadString(IDS_DISK_TYPE_BASIC); - } - } else if (disk->Layout->PartitionStyle == PARTITION_STYLE_GPT) { - s = "GPT"; - } - } - s += "\r\n"; - ret += s; - } - - if (disk->bEjected) { - ret += " No media\r\n"; - } else { - /* geometry information */ - ret += " DiskGeometry Layout:\r\n"; - s.Format(" BytesPerSector = %u\r\n", disk->DiskGeometry.BytesPerSector); - ret += s; - s.Format(" SectorsPerTrack = %u\r\n", disk->DiskGeometry.SectorsPerTrack); - ret += s; - s.Format(" TracksPerCylinder = %u\r\n", disk->DiskGeometry.TracksPerCylinder); - ret += s; - s.Format(" Cylinderst = %I64u\r\n", disk->DiskGeometry.Cylinders.QuadPart); - ret += s; - - switch (disk->DiskGeometry.MediaType) { - case FixedMedia: s="Fixed"; break; - case RemovableMedia: s="Removable"; break; - case CD_ROM: s="CDROM"; break; - case CD_R: s="CDR"; break; - case CD_RW: s="CDRW"; break; - case DVD_ROM: s="DVD"; break; - case DVD_R: s="DVDR"; break; - case DVD_RW: s="DVDRW"; break; - default: s="Unkown"; - } - - ret += " MediaType: "; - ret += s; - ret += "\r\n"; - } - - ret += "\r\n"; - if (disk->Layout) { - s.Format(" Partition Numbers: %d\r\n", disk->NumParts); - ret += s; - - for (UCHAR i=0; i < disk->NumParts; i++) { - ret += Ext2PartInformation(&disk->DataParts[i]); - ret += "\r\n"; - } - } - - return ret; -} - -CString -Ext2CdromInformation(PEXT2_CDROM cdrom) -{ - CString s, ret=""; - - s.Format("\r\nCdrom %d: %s\r\n\r\n", cdrom->OrderNo, cdrom->Name); - ret += s; - - if (cdrom->SDD.VendorIdOffset) { - ret += " VendorId: "; - ret += (PCHAR)&cdrom->SDD + cdrom->SDD.VendorIdOffset; - ret += "\r\n"; - } - - if (cdrom->SDD.ProductIdOffset) { - ret += " ProductId: "; - ret += (PCHAR)&cdrom->SDD + cdrom->SDD.ProductIdOffset; - ret += "\r\n"; - } - - if (cdrom->SDD.SerialNumberOffset) { - ret += " SerialNumber: "; - ret += (PCHAR)&cdrom->SDD + cdrom->SDD.SerialNumberOffset; - ret += "\r\n"; - } - - ret += " BusType: "; - ret += BusTypeString(cdrom->SDD.BusType); - ret += "\r\n"; - - if (cdrom->bLoaded) { - ret += " Media Type: "; - if (cdrom->bIsDVD) { - s = "DVD\r\n"; - } else { - s = "CDROM\r\n"; - } - ret += s; - - ret += " DiskGeometry Layout:\r\n"; - s.Format(" BytesPerSector = %u\r\n", cdrom->DiskGeometry.BytesPerSector); - ret += s; - s.Format(" SectorsPerTrack = %u\r\n", cdrom->DiskGeometry.SectorsPerTrack); - ret += s; - s.Format(" TracksPerCylinder = %u\r\n", cdrom->DiskGeometry.TracksPerCylinder); - ret += s; - s.Format(" Cylinderst = %I64u\r\n", cdrom->DiskGeometry.Cylinders.QuadPart); - ret += s; - } else { - s = " No media\r\n"; - ret += s; - } - - if (cdrom->bLoaded) { - if (cdrom->bEjected) { - ret += " Media ejected\r\n"; - } else { - ret += " File system: "; - if (cdrom->EVP.bExt2) { - s = "EXT"; - s += (CHAR)('2' + cdrom->EVP.bExt3); - } else { - s = "CDFS"; - } - ret += s; - ret += "\r\n"; - - s = " Online,"; - switch (cdrom->DiskGeometry.MediaType) { - case FixedMedia: s +="Fixed"; break; - case RemovableMedia: s += "Media Removable"; break; - case CD_ROM: s +=" CDROM"; break; - case CD_R: s += "CDR"; break; - case CD_RW: s += "CDRW"; break; - case DVD_ROM: s += "DVD"; break; - case DVD_R: s += "DVDR"; break; - case DVD_RW: s += "DVDRW"; break; - default: s += "Unkown"; - } - ret += s; - ret += "\r\n"; - } - } else { - ret += " Device stopped\r\n"; - } - - ret += " Mountpoints: "; - ret += Ext2QueryVolumeLetterStrings(cdrom->DrvLetters, NULL); - ret += "\r\n"; - - return ret; -} - -CString -Ext2VolumeInformation(PEXT2_VOLUME vol) -{ - CString s, ret = ""; - - s.Format("\r\nVolume: %s:\r\n\r\n", vol->Name); - ret += s; - - ret += " Filesystem: "; - ret += vol->FileSystem; - ret += "\r\n"; - - /* mount points */ - ret += " Mountpoints: "; - ret += Ext2QueryVolumeLetterStrings(vol->DrvLetters, NULL); - ret += "\r\n"; - - /* set volume status */ - s = " Volume status: Online"; - if (vol->bRecognized && (vol->EVP.bExt2 || vol->EVP.bExt3)) { - s += ",codepage:"; - s += vol->EVP.Codepage; - if (vol->EVP.bReadonly) { - s += ",Readonly"; - } - } - ret += s; - ret += "\r\n"; - - { - ULONGLONG totalSize, freeSize; - totalSize = vol->FssInfo.TotalAllocationUnits.QuadPart; - freeSize = vol->FssInfo.AvailableAllocationUnits.QuadPart; - totalSize = totalSize * vol->FssInfo.BytesPerSector * - vol->FssInfo.SectorsPerAllocationUnit; - freeSize = freeSize * vol->FssInfo.BytesPerSector * - vol->FssInfo.SectorsPerAllocationUnit; - s.Format(" size: %I64u\r\n", totalSize); - ret += s; - - s.Format(" free space: %I64u\r\n", freeSize); - ret += s; - } - - if (vol->Extent) { - for (DWORD i=0; i < vol->Extent->NumberOfDiskExtents; i++) { - s.Format(" Extent: %d\r\n", i); - ret += s; - s.Format(" DiskNumber: %d\r\n", vol->Extent->Extents[i].DiskNumber); - ret += s; - s.Format(" StartingOffset: %I64u\r\n", vol->Extent->Extents[i].StartingOffset.QuadPart); - ret += s; - s.Format(" ExtentLength: %I64u\r\n", vol->Extent->Extents[i].ExtentLength.QuadPart); - ret += s; - } - } - - return ret; -} - - -CString -Ext2SysInformation() -{ - ULONG i = 0; - CString s; - PEXT2_VOLUME chain = gVols; - - s = "\r\nDisk devices:\r\n"; - for (i=0; i < g_nDisks; i++) { - s += Ext2DiskInformation(&gDisks[i]); - } - - s += "\r\nCdrom/DVD devices:\r\n"; - - for (i=0; i < g_nCdroms; i++) { - s += Ext2CdromInformation(&gCdroms[i]); - } - - while (chain) { - s += Ext2VolumeInformation(chain); - chain = chain->Next; - } - - return s; -} - -VOID -Ext2CleanupDisks() -{ - ULONG i = 0; - - for (i=0; i < g_nDisks; i++) { - if (gDisks[i].bLoaded) { - if (gDisks[i].Layout) { - free(gDisks[i].Layout); - gDisks[i].Layout = NULL; - } - gDisks[i].bLoaded = FALSE; - if (gDisks[i].DataParts) { - free(gDisks[i].DataParts); - } - } - } - - g_nDisks = 0; - if (gDisks) { - free(gDisks); gDisks = NULL; - } -} - -BOOL -Ext2LoadCdroms() -{ - ULONG i = 0, j = 0; - NT::NTSTATUS status; - DWORD mediaType; - - if (g_nCdroms == 0) { - return TRUE; - } - - gCdroms = (PEXT2_CDROM) malloc(sizeof(EXT2_CDROM) * g_nCdroms); - if (gCdroms == NULL) { - return FALSE; - } - memset(gCdroms, 0, sizeof(EXT2_CDROM) * g_nCdroms); - - while (i < g_nCdroms && j < 256) { - - HANDLE Handle = NULL; - - gCdroms[i].Magic[0] = EXT2_CDROM_DEVICE_MAGIC; - gCdroms[i].Magic[1] = EXT2_CDROM_VOLUME_MAGIC; - gCdroms[i].OrderNo = (UCHAR) j; - gCdroms[i].bLoaded = FALSE; - sprintf(gCdroms[i].Name, "\\Device\\Cdrom%d\0", j); - - j++; - - status = Ext2Open(gCdroms[i].Name, &Handle, EXT2_DESIRED_ACCESS); - if (!NT_SUCCESS(status)) { - continue; - } - - status = Ext2QueryProperty( Handle, StorageDeviceProperty, - (PVOID)&gCdroms[i].SDD, - sizeof(STORAGE_DEVICE_DESCRIPTOR) - ); - if (!NT_SUCCESS(status)) { - goto Next; - } - - status = Ext2QueryProperty( Handle, StorageAdapterProperty, - (PVOID)&gCdroms[i].SAD, - sizeof(STORAGE_ADAPTER_DESCRIPTOR) - ); - if (!NT_SUCCESS(status)) { - goto Next; - } - - status = Ext2QueryDisk(Handle, &gCdroms[i].DiskGeometry); - if (NT_SUCCESS(status)) { - gCdroms[i].bEjected = FALSE; - } else { - // (status == STATUS_NO_MEDIA_IN_DEVICE) { - gCdroms[i].bEjected = TRUE; - } - - status = Ext2QueryMediaType(Handle, &mediaType); - if (NT_SUCCESS(status) && mediaType == FILE_DEVICE_DVD) { - gCdroms[i].bIsDVD = TRUE; - } else { - gCdroms[i].bIsDVD = FALSE; - } - - if (!gCdroms[i].bEjected) { - Ext2QueryExt2Property(Handle, &gCdroms[i].EVP); - } - - gCdroms[i].bLoaded = TRUE; - -Next: - - Ext2Close(&Handle); - i++; - } - - g_nCdroms = i; - return TRUE; -} - -VOID -Ext2LoadCdromDrvLetters() -{ - for (ULONG i = 0; i < g_nCdroms; i++) { - gCdroms[i].DrvLetters = Ext2QueryCdromDrvLetters(&gCdroms[i]); - } -} - - -VOID -Ext2CleanupCdroms() -{ - ULONG i = 0; - - for (i=0; i < g_nCdroms; i++) { - if (gCdroms[i].bLoaded) { - gCdroms[i].bLoaded = FALSE; - } - } - - g_nCdroms = 0; - if (gCdroms) { - free(gCdroms); gCdroms = NULL; - } -} - -BOOL -Ext2CompareExtents( - PVOLUME_DISK_EXTENTS ext1, - PVOLUME_DISK_EXTENTS ext2 - ) -{ - DWORD nExt; - - if (ext1->NumberOfDiskExtents != ext2->NumberOfDiskExtents) { - return FALSE; - } - - for (nExt = 0; nExt < ext1->NumberOfDiskExtents; nExt++) { - if ((ext1->Extents[nExt].DiskNumber != ext2->Extents[nExt].DiskNumber) || - (ext1->Extents[nExt].StartingOffset.QuadPart != ext2->Extents[nExt].StartingOffset.QuadPart) || - (ext1->Extents[nExt].ExtentLength.QuadPart != ext2->Extents[nExt].ExtentLength.QuadPart) ) { - return FALSE; - } - } - return TRUE; -} - -ULONGLONG -Ext2EjectedDiskLetters( - PEXT2_DISK Disk - ) -{ - ULONGLONG letters = 0; - int i; - - /* checking the digits ltters */ - for (i=0; i < 10; i++) { - if (drvDigits[i].bUsed && drvDigits[i].SDN) { - if (drvDigits[i].SDN->DeviceNumber == Disk->OrderNo) { - letters |= (((ULONGLONG) 1) << (32 + i)); - } - } - } - - for (i=0; i <26; i++) { - if (drvLetters[i].bUsed && drvLetters[i].SDN) { - if (drvLetters[i].SDN->DeviceNumber == Disk->OrderNo) { - letters |= (((ULONGLONG) 1) << i); - } - } - } - - return letters; -} - -ULONGLONG -Ext2QueryVolumeDrvLetters(PEXT2_VOLUME Volume) -{ - ULONGLONG letters = 0; - int i; - - UCHAR drvChar = Ext2QueryMountPoint(Volume->Name); - if (drvChar) { - letters |= (((ULONGLONG) 1) << (drvChar - 'A')); - } - - if (!Volume->Extent) { - goto errorout; - } - - /* checking the digits ltters */ - for (i=0; i < 10; i++) { - if (drvDigits[i].bUsed && drvDigits[i].Extent) { - if (Ext2CompareExtents(drvDigits[i].Extent, Volume->Extent)) { - letters |= (((ULONGLONG) 1) << (32 + i)); - if (drvChar != drvDigits[i].Letter) { - drvDigits[i].bTemporary = TRUE; - } - } - } - } - - for (i=0; i <26; i++) { - if (drvLetters[i].bUsed && drvLetters[i].Extent) { - if (Ext2CompareExtents(drvLetters[i].Extent, Volume->Extent)) { - letters |= (((ULONGLONG) 1) << i); - if (drvChar != drvLetters[i].Letter) { - drvLetters[i].bTemporary = TRUE; - } - } - } - } - -errorout: - - return letters; -} - -ULONGLONG -Ext2QueryCdromDrvLetters(PEXT2_CDROM Cdrom) -{ - ULONGLONG letters = 0; - UCHAR drvChar; - int i; - - if (!Cdrom) { - goto errorout; - } - - drvChar = Ext2QueryMountPoint(Cdrom->Name); - if (drvChar) { - letters |= (((ULONGLONG) 1) << (drvChar - 'A')); - } - - /* checking the digits ltters */ - for (i=0; i < 10; i++) { - if (drvDigits[i].bUsed && drvDigits[i].DrvType == DRIVE_CDROM) { - if (!_stricmp(drvDigits[i].SymLink, Cdrom->Name)) { - letters |= (((ULONGLONG) 1) << (i + 32)); - } - } - } - - for (i=0; i <26; i++) { - if (drvLetters[i].bUsed && drvLetters[i].DrvType == DRIVE_CDROM) { - if (!_stricmp(drvLetters[i].SymLink, Cdrom->Name)) { - letters |= (((ULONGLONG) 1) << i); - } - } - } - -errorout: - - return letters; -} - -BOOL -Ext2QueryVolumeFS( - HANDLE Handle, - PEXT2_VOLUME volume - ) -{ - struct ext2_super_block *sb = NULL; - union swap_header* swap = NULL; - PUCHAR buffer = NULL; - - - NT::NTSTATUS status; - - buffer = (PUCHAR)malloc(PAGE_SIZE); - if (!buffer) { - return FALSE; - } - - swap = (union swap_header*)&buffer[SWAP_HEADER_OFFSET]; - sb = (struct ext2_super_block *)&buffer[SUPER_BLOCK_OFFSET]; - - status = Ext2Read( Handle, FALSE, volume->FssInfo.BytesPerSector, - (ULONGLONG)0,PAGE_SIZE, (PUCHAR) buffer); - - if (!NT_SUCCESS(status)) { - free(buffer); - return FALSE; - } - - if (sb->s_magic == EXT2_SUPER_MAGIC) { - - volume->FsaInfo.FileSystemNameLength = 8; - volume->FsaInfo.FileSystemName[0] = (WCHAR)'E'; - volume->FsaInfo.FileSystemName[1] = (WCHAR)'X'; - volume->FsaInfo.FileSystemName[2] = (WCHAR)'T'; - volume->FsaInfo.FileSystemName[4] = 0; - - if ((sb->s_feature_incompat & EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) || - (sb->s_feature_incompat & EXT3_FEATURE_INCOMPAT_RECOVER) || - (sb->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL) ) { - volume->FsaInfo.FileSystemName[3] = (WCHAR)'3'; - volume->EVP.bExt3 = TRUE; - } else { - volume->FsaInfo.FileSystemName[3] = (WCHAR)'2'; - volume->EVP.bExt2 = TRUE; - } - memcpy(&volume->EVP.UUID[0], &sb->s_uuid[0], 16); - goto errorout; - } - - if ((memcmp(swap->magic.magic, SWAP_HEADER_MAGIC_V1, 10) == 0) || - (memcmp(swap->magic.magic, SWAP_HEADER_MAGIC_V2, 10) == 0)) { - volume->FsaInfo.FileSystemNameLength = 8; - volume->FsaInfo.FileSystemName[0] = (WCHAR)'S'; - volume->FsaInfo.FileSystemName[1] = (WCHAR)'W'; - volume->FsaInfo.FileSystemName[2] = (WCHAR)'A'; - volume->FsaInfo.FileSystemName[3] = (WCHAR)'P'; - volume->FsaInfo.FileSystemName[4] = 0; - } - -errorout: - - free(buffer); - return (volume->EVP.bExt2 || volume->EVP.bExt3); -} - -BOOL -Ext2QueryExt2Property ( - HANDLE Handle, - PEXT2_VOLUME_PROPERTY3 EVP - ) -{ - NT::NTSTATUS status; - NT::IO_STATUS_BLOCK iosb; - - BOOLEAN bExt2, bExt3; - CHAR UUID[16]; - - if (!Ext2IsServiceStarted()) { - return FALSE; - } - - bExt2 = EVP->bExt2; - bExt3 = EVP->bExt3; - memcpy(&UUID[0], &EVP->UUID[0], 16); - memset(EVP, 0, sizeof(EXT2_VOLUME_PROPERTY2)); - memcpy(&EVP->UUID[0], &UUID[0], 16); - EVP->bExt2 = bExt2; - EVP->bExt3 = bExt3; - EVP->Magic = EXT2_VOLUME_PROPERTY_MAGIC; - EVP->Command = APP_CMD_QUERY_PROPERTY3; - - status = NT::ZwDeviceIoControlFile( - Handle, NULL, NULL, NULL, &iosb, - IOCTL_APP_VOLUME_PROPERTY, - EVP, sizeof(EXT2_VOLUME_PROPERTY3), - EVP, sizeof(EXT2_VOLUME_PROPERTY3) - ); - - return NT_SUCCESS(status); -} - - -BOOL -Ext2QueryPerfStat ( - HANDLE Handle, - PEXT2_QUERY_PERFSTAT Stat, - PEXT2_PERF_STATISTICS_V1 *PerfV1, - PEXT2_PERF_STATISTICS_V2 *PerfV2 - ) -{ - NT::NTSTATUS status; - NT::IO_STATUS_BLOCK iosb; - - memset(Stat, 0, sizeof(EXT2_QUERY_PERFSTAT)); - Stat->Magic = EXT2_VOLUME_PROPERTY_MAGIC; - Stat->Command = IOCTL_APP_QUERY_PERFSTAT; - - *PerfV1 = NULL; - *PerfV2 = NULL; - - status = NT::ZwDeviceIoControlFile( - Handle, NULL, NULL, NULL, &iosb, - IOCTL_APP_QUERY_PERFSTAT, - Stat, sizeof(EXT2_QUERY_PERFSTAT), - Stat, sizeof(EXT2_QUERY_PERFSTAT) - ); - if (!NT_SUCCESS(!status)) - return FALSE; - - if (iosb.Information == EXT2_QUERY_PERFSTAT_SZV2 && - (Stat->Flags & EXT2_QUERY_PERFSTAT_VER2) != 0) { - - if (Stat->PerfStatV2.Magic == EXT2_PERF_STAT_MAGIC && - Stat->PerfStatV2.Length == sizeof(EXT2_PERF_STATISTICS_V2) && - Stat->PerfStatV2.Version == EXT2_PERF_STAT_VER2) { - *PerfV2 = &Stat->PerfStatV2; - } - - } else if (iosb.Information >= EXT2_QUERY_PERFSTAT_SZV1) { - - *PerfV1 = &Stat->PerfStatV1; - } - - if (PerfV1 || PerfV2) - return TRUE; - - return FALSE; -} - -VOID -Ext2StorePropertyinRegistry(PEXT2_VOLUME_PROPERTY3 EVP) -{ - CHAR UUID[50], ID[16]; - HKEY hKey; - CHAR keyPath[MAX_PATH]; - LONG status; - CString data = ""; - - int i; - int len = 0; - - memset(UUID, 0, 50); - for (i=0; i < 16; i++) { - if (i == 0) { - sprintf(&UUID[len], "{%2.2X", EVP->UUID[i]); - len += 3; - } else if (i == 15) { - sprintf(&UUID[len], "-%2.2X}", EVP->UUID[i]); - len +=4; - } else { - sprintf(&UUID[len], "-%2.2X", EVP->UUID[i]); - len += 3; - } - } - - /* Create or open ext2fsd volumes key */ - strcpy (keyPath, "SYSTEM\\CurrentControlSet\\Services\\Ext2Fsd\\Volumes") ; - status = ::RegCreateKeyEx (HKEY_LOCAL_MACHINE, - keyPath, - 0, - 0, - REG_OPTION_NON_VOLATILE, - KEY_ALL_ACCESS, - NULL, - &hKey, - NULL); - if (status != ERROR_SUCCESS) { - return; - } - -#define READING_ONLY "Readonly" -#define WRITING_SUPPORT "WritingSupport" -#define EXT3_FORCEWRITING "Ext3ForceWriting" -#define CODEPAGE_NAME "CodePage" -#define HIDING_PREFIX "HidingPrefix" -#define HIDING_SUFFIX "HidingSuffix" -#define MOUNT_POINT "MountPoint" -#define UID "uid" -#define GID "gid" -#define EUID "euid" -#define EGID "egid" - - - if (EVP->bReadonly) { - data += READING_ONLY";"; - } else if (EVP->bExt3 && EVP->bExt3Writable) { - data += EXT3_FORCEWRITING";"; - } - - if (EVP->DrvLetter) { - if ((EVP->DrvLetter & 0x7F) == 0 || EVP->DrvLetter == 0xFF) { - data += MOUNT_POINT";"; - } else { - data += MOUNT_POINT"="; - data += (CHAR)(EVP->DrvLetter & 0x7F); - data += ":;"; - } - } - - if (strlen((CHAR*)EVP->Codepage) > 0) { - data += CODEPAGE_NAME"="; - data += &EVP->Codepage[0]; - data += ";"; - } - - if (EVP->bHidingPrefix) { - data += HIDING_PREFIX"="; - data += EVP->sHidingPrefix; - data += ";"; - } - - if (EVP->bHidingSuffix) { - data += HIDING_SUFFIX"="; - data += EVP->sHidingSuffix; - data += ";"; - } - - if (EVP->Flags2 & EXT2_VPROP3_USERIDS) { - sprintf(ID, "%u", EVP->uid); - data += UID"="; - data += ID; - data += ";"; - - sprintf(ID, "%u", EVP->gid); - data += GID"="; - data += ID; - data += ";"; - - if (EVP->EIDS) { - sprintf(ID, "%u", EVP->euid); - data += EUID"="; - data += ID; - data += ";"; - } - } - - /* set volume parameters */ - status = RegSetValueEx( hKey, UUID, 0, REG_SZ, (BYTE *) - data.GetBuffer(data.GetLength()), - data.GetLength()); - - RegCloseKey(hKey); -} - -BOOL Ext2IsNullUuid (__u8 * uuid) -{ - int i; - for (i = 0; i < 16; i++) { - if (uuid[i]) { - break; - } - } - - return (i >= 16); -} - -BOOL -Ext2CheckVolumeRegistryProperty(PEXT2_VOLUME_PROPERTY3 EVP) -{ - CHAR UUID[50]; - HKEY hKey; - CHAR keyPath[MAX_PATH]; - CHAR content[MAX_PATH]; - LONG status, type = 0; - - int i; - int len = 0; - BOOL rc = TRUE; - - if (Ext2IsNullUuid(&EVP->UUID[0])) { - return TRUE; - } - - memset(UUID, 0, 50); - for (i=0; i < 16; i++) { - if (i == 0) { - sprintf(&UUID[len], "{%2.2X", EVP->UUID[i]); - len += 3; - } else if (i == 15) { - sprintf(&UUID[len], "-%2.2X}", EVP->UUID[i]); - len +=4; - } else { - sprintf(&UUID[len], "-%2.2X", EVP->UUID[i]); - len += 3; - } - } - - /* Create or open ext2fsd volumes key */ - strcpy (keyPath, "SYSTEM\\CurrentControlSet\\Services\\Ext2Fsd\\Volumes") ; - status = ::RegOpenKeyEx (HKEY_LOCAL_MACHINE, - keyPath, - 0, - KEY_ALL_ACCESS, - &hKey) ; - if (status != ERROR_SUCCESS) { - rc = FALSE; - goto errorout; - } - - /* Query volume parameters */ - len = MAX_PATH; - status = RegQueryValueEx(hKey, - &UUID[0], - 0, - (LPDWORD)&type, - (BYTE *)&content[0], - (LPDWORD)&len); - if (status != ERROR_SUCCESS) { - rc = FALSE; - } - - RegCloseKey(hKey); - -errorout: - return rc; -} - -VOID -Ext2SetDefaultVolumeRegistryProperty(PEXT2_VOLUME_PROPERTY3 EVP) -{ - ULONG StartMode; - BOOL AutoMount = 0; - - if (Ext2IsNullUuid(&EVP->UUID[0])) { - return; - } - - /* query global parameters */ - Ext2QueryGlobalProperty( - &StartMode, - (BOOL *)&EVP->bReadonly, - (BOOL *)&EVP->bExt3Writable, - (CHAR *)EVP->Codepage, - (CHAR *)NULL, - (CHAR *)NULL, - (BOOL *)&AutoMount - ); - - if (EVP->bExt3 && !EVP->bExt3Writable) - EVP->bReadonly = TRUE; - - EVP->DrvLetter = 0x80; - EVP->Flags2 |= EXT2_VPROP3_AUTOMOUNT; - Ext2StorePropertyinRegistry(EVP); -} - -BOOL -Ext2SetExt2Property ( - HANDLE Handle, - PEXT2_VOLUME_PROPERTY3 EVP - ) -{ - NT::NTSTATUS status; - NT::IO_STATUS_BLOCK iosb; - - ASSERT(EVP->Magic == EXT2_VOLUME_PROPERTY_MAGIC); - EVP->Command = APP_CMD_SET_PROPERTY3; - - status = NT::ZwDeviceIoControlFile( - Handle, NULL, NULL, NULL, &iosb, - IOCTL_APP_VOLUME_PROPERTY, - EVP, sizeof(EXT2_VOLUME_PROPERTY3), - EVP, sizeof(EXT2_VOLUME_PROPERTY3) - ); - - if (NT_SUCCESS(status)) { - return TRUE; - } else { - CString s; - s.Format("Status = %xh\n", status); - AfxMessageBox(s); - } - - return FALSE; -} - - -BOOL -Ext2QueryGlobalProperty( - ULONG * ulStartup, - BOOL * bReadonly, - BOOL * bExt3Writable, - CHAR * Codepage, - CHAR * sPrefix, - CHAR * sSuffix, - BOOL * bAutoMount - ) -{ - int rc = TRUE; - HKEY hKey; - CHAR keyPath[MAX_PATH]; - DWORD data = 0; - LONG status, type, len; - - /* Open ext2fsd sevice key */ - strcpy (keyPath, "SYSTEM\\CurrentControlSet\\Services\\Ext2Fsd") ; - status = ::RegOpenKeyEx (HKEY_LOCAL_MACHINE, - keyPath, - 0, - KEY_ALL_ACCESS, - &hKey) ; - if (status != ERROR_SUCCESS) { - rc = FALSE; - goto errorout; - } - - /* Query Start type */ - len = sizeof(DWORD); - status = RegQueryValueEx( hKey, - "Start", - 0, - (LPDWORD)&type, - (BYTE *)&data, - (LPDWORD)&len); - if (status == ERROR_SUCCESS) { - *ulStartup = data; - } - - RegCloseKey(hKey); - - /* Open ext2fsd parameters key */ - strcpy (keyPath, "SYSTEM\\CurrentControlSet\\Services\\Ext2Fsd\\Parameters") ; - status = ::RegOpenKeyEx (HKEY_LOCAL_MACHINE, - keyPath, - 0, - KEY_ALL_ACCESS, - &hKey) ; - if (status != ERROR_SUCCESS) { - rc = FALSE; - goto errorout; - } - - /* Query WritingSupport */ - len = sizeof(DWORD); - status = RegQueryValueEx( hKey, - "WritingSupport", - 0, - (LPDWORD)&type, - (BYTE *)&data, - (LPDWORD)&len); - if (status == ERROR_SUCCESS) { - *bReadonly = (data == 0); - } - - /* query Ext3ForceWriting */ - len = sizeof(DWORD); - status = RegQueryValueEx( hKey, - "Ext3ForceWriting", - 0, - (LPDWORD)&type, - (BYTE *)&data, - (LPDWORD)&len); - - if (status == ERROR_SUCCESS) { - *bExt3Writable = (data != 0); - } - - /* query AutoMount */ - len = sizeof(DWORD); - status = RegQueryValueEx( hKey, - "AutoMount", - 0, - (LPDWORD)&type, - (BYTE *)&data, - (LPDWORD)&len); - - if (status == ERROR_SUCCESS) { - *bAutoMount = (data != 0); - } - - if (Codepage) { - /* query codepage */ - len = CODEPAGE_MAXLEN; - status = RegQueryValueEx( hKey, - "CodePage", - 0, - (LPDWORD)&type, - (BYTE *)Codepage, - (LPDWORD)&len); - } - - if (sPrefix) { - /* querying hidding filter patterns */ - len = CODEPAGE_MAXLEN; - status = RegQueryValueEx( hKey, - "HidingPrefix", - 0, - (LPDWORD)&type, - (BYTE *)sPrefix, - (LPDWORD)&len); - } - - if (sSuffix) { - len = CODEPAGE_MAXLEN; - status = RegQueryValueEx( hKey, - "HidingSuffix", - 0, - (LPDWORD)&type, - (BYTE *)sSuffix, - (LPDWORD)&len); - } - - RegCloseKey(hKey); - - -errorout: - - return rc; -} - -INT -Ext2QueryDrvVersion( - CHAR * Version, - CHAR * Date, - CHAR * Time - ) -{ - EXT2_VOLUME_PROPERTY_VERSION EVPV; - NT::NTSTATUS status; - HANDLE handle = NULL; - NT::IO_STATUS_BLOCK iosb; - INT rc = 0; - - memset(&EVPV, 0, sizeof(EXT2_VOLUME_PROPERTY_VERSION)); - EVPV.Magic = EXT2_VOLUME_PROPERTY_MAGIC; - EVPV.Command = APP_CMD_QUERY_VERSION; - EVPV.Flags |= EXT2_FLAG_VP_SET_GLOBAL; - - status = Ext2Open("\\DosDevices\\Ext2Fsd", - &handle, EXT2_DESIRED_ACCESS); - if (!NT_SUCCESS(status)) { - rc = -1; - goto errorout; - } - - status = NT::ZwDeviceIoControlFile( - handle, NULL, NULL, NULL, &iosb, - IOCTL_APP_VOLUME_PROPERTY, - &EVPV, sizeof(EXT2_VOLUME_PROPERTY_VERSION), - &EVPV, sizeof(EXT2_VOLUME_PROPERTY_VERSION) - ); - - if (NT_SUCCESS(status)) { - strncpy(Version, EVPV.Version, 0x1B); - strncpy(Date, EVPV.Date, 0x1F); - strncpy(Time, EVPV.Time, 0x1F); - } - - rc = NT_SUCCESS(status); - -errorout: - - Ext2Close(&handle); - - return rc; -} - -BOOL -Ext2SetGlobalProperty ( - ULONG ulStartup, - BOOLEAN bReadonly, - BOOLEAN bExt3Writable, - CHAR * Codepage, - CHAR * sPrefix, - CHAR * sSuffix, - BOOL bAutoMount - ) -{ - EXT2_VOLUME_PROPERTY3 EVP; - - NT::NTSTATUS status; - HANDLE Handle = NULL; - int rc = TRUE; - HKEY hKey; - CHAR keyPath[MAX_PATH] ; - - ULONG data = 0; - - memset(&EVP, 0, sizeof(EXT2_VOLUME_PROPERTY3)); - EVP.Magic = EXT2_VOLUME_PROPERTY_MAGIC; - EVP.Command = APP_CMD_SET_PROPERTY3; - EVP.Flags |= EXT2_FLAG_VP_SET_GLOBAL; - EVP.bReadonly = bReadonly; - EVP.bExt3Writable = bExt3Writable; - strcpy((CHAR *)EVP.Codepage, Codepage); - - if (strlen(sPrefix)) { - strcpy(EVP.sHidingPrefix, sPrefix); - EVP.bHidingPrefix = TRUE; - } - - if (strlen(sSuffix)) { - strcpy(EVP.sHidingSuffix, sSuffix); - EVP.bHidingSuffix = TRUE; - } - - strcpy (keyPath, "SYSTEM\\CurrentControlSet\\Services\\Ext2Fsd") ; - status = ::RegOpenKeyEx (HKEY_LOCAL_MACHINE, - keyPath, - 0, - KEY_ALL_ACCESS, - &hKey) ; - if (status != ERROR_SUCCESS) { - rc = FALSE; - goto errorout; - } - - /* set Start type */ - status = RegSetValueEx( hKey, - "Start", - 0, - REG_DWORD, - (BYTE *)&ulStartup, - sizeof(DWORD)); - RegCloseKey(hKey); - - strcpy (keyPath, "SYSTEM\\CurrentControlSet\\Services\\Ext2Fsd\\Parameters") ; - status = ::RegOpenKeyEx (HKEY_LOCAL_MACHINE, - keyPath, - 0, - KEY_ALL_ACCESS, - &hKey) ; - if (status != ERROR_SUCCESS) { - rc = FALSE; - goto errorout; - } - - /* set WritingSupport */ - data = !bReadonly; - status = RegSetValueEx( hKey, - "WritingSupport", - 0, - REG_DWORD, - (BYTE *)&data, - sizeof(ULONG)); - - /* set Ext3ForceWriting */ - data = bExt3Writable; - status = RegSetValueEx( hKey, - "Ext3ForceWriting", - 0, - REG_DWORD, - (BYTE *)&data, - sizeof(ULONG)); - /* set AutoMount */ - data = bAutoMount; - status = RegSetValueEx( hKey, - "AutoMount", - 0, - REG_DWORD, - (BYTE *)&data, - sizeof(ULONG)); - - - /* set codepage */ - status = RegSetValueEx( hKey, - "CodePage", - 0, - REG_SZ, - (BYTE *)Codepage, - (int)strlen(Codepage)); - - /* set hiding filter patterns */ - status = RegSetValueEx( hKey, - "HidingPrefix", - 0, - REG_SZ, - (BYTE *)sPrefix, - (int)strlen(sPrefix)); - - status = RegSetValueEx( hKey, - "HidingSuffix", - 0, - REG_SZ, - (BYTE *)sSuffix, - (int)strlen(sSuffix)); - - RegCloseKey(hKey); - - status = Ext2Open("\\DosDevices\\Ext2Fsd", &Handle, EXT2_DESIRED_ACCESS); - if (!NT_SUCCESS(status)) { - goto errorout; - } - - EVP.Flags2 = EXT2_VPROP3_AUTOMOUNT; - EVP.AutoMount = g_bAutoMount; - - rc = Ext2SetExt2Property(Handle, &EVP); - if (!rc) { - } - -errorout: - - Ext2Close(&Handle); - - return rc; -} - -BOOL -Ext2SetService(PCHAR Target, PCHAR Name, PCHAR Desc, BOOL bInstall) -{ - SC_HANDLE hService; - SC_HANDLE hManager; - - // open Service Control Manager - hManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); - if (hManager == NULL) { - // AfxMessageBox("Ext2Mgr: cannot open Service Control Manager", - // MB_ICONEXCLAMATION | MB_OK); - return FALSE; - } - - if (bInstall) { - - // now create service entry - hService = CreateService( - hManager, // SCManager database - Name, // name of service - Desc, // name to display - SERVICE_ALL_ACCESS, // desired access - SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS, - // service type - SERVICE_AUTO_START, // start type - SERVICE_ERROR_NORMAL, // error control type - Target, // service's binary - NULL, // no load ordering group - NULL, // no tag identifier - NULL, // dependencies - NULL, // LocalSystem account - NULL); // no password - - if (hService == NULL) { - DWORD error = GetLastError(); - if (error == ERROR_SERVICE_EXISTS) { - // AfxMessageBox("Service is already registered.", - // MB_ICONEXCLAMATION | MB_OK); - } else { - // AfxMessageBox("Service couldn't be registered.", - // MB_ICONEXCLAMATION | MB_OK); - } - } else { - - CloseServiceHandle(hService); - } - - } else { - - /* open the service */ - hService = OpenService( - hManager, - Name, - SERVICE_ALL_ACCESS - ); - - if (hService != NULL) { - - // remove the service from the SCM - if (DeleteService(hService)) { - } else { - DWORD error = GetLastError(); - if (error == ERROR_SERVICE_MARKED_FOR_DELETE) { - // AfxMessageBox("Service is already unregistered", - // MB_ICONEXCLAMATION | MB_OK); - } else { - // AfxMessageBox("Service could not be unregistered", - // MB_ICONEXCLAMATION | MB_OK); - } - } - - CloseServiceHandle(hService); - } - } - - CloseServiceHandle(hManager); - - return TRUE; -} - - -BOOL ExtSaveResourceToFile(UINT id, CHAR *target) -{ - HANDLE handle; - ULONG bytes = 0; - BOOL rc = FALSE; - - HRSRC hr = FindResource(NULL, MAKEINTRESOURCE(id), RT_RCDATA); - ULONG size = SizeofResource(NULL, hr); - HGLOBAL hg = LoadResource(NULL, hr); - PVOID data = LockResource(hg); - - if (!data) - goto errorout; - - handle = CreateFile(target, GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, - CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - if (handle == INVALID_HANDLE_VALUE) { - goto errorout; - } - - rc = WriteFile(handle, data, size, &bytes, NULL); - if (rc) - rc = (bytes == size); - - CloseHandle(handle); - -errorout: - - return rc; -} - -TCHAR *Ext2StrLastA(TCHAR *t, TCHAR *s); - -BOOL Ext2InstallExt2Srv() -{ - TCHAR cmd[512] = {0}, *p; - BOOL rc = FALSE; - - if (GetWindowsDirectory(cmd, 512)) { - if (g_isWow64) - strcat(cmd, "\\SysWOW64\\Ext2Srv.EXE"); - else - strcat(cmd, "\\System32\\Ext2Srv.EXE"); - rc = ExtSaveResourceToFile(IDR_RCDAT_SRV, cmd); - } - - if (!rc) { - GetModuleFileName(NULL, cmd, 510); - p = Ext2StrLastA(cmd, ".EXE"); - if (p && p > &cmd[3]) { - p[-3] = 'S'; - p[-2] = 'r'; - p[-1] = 'v'; - } else { - strcat(cmd, "-Srv.EXE"); - } - rc = ExtSaveResourceToFile(IDR_RCDAT_SRV, cmd); - } - - if (!rc) { - GetTempPath(50, cmd); - strcat(cmd, "\\Ext2Srv.EXE"); - rc = ExtSaveResourceToFile(IDR_RCDAT_SRV, cmd); - } - - if (!rc) { - return rc; - } - - rc = Ext2SetService(cmd, "Ext2Srv", "Ext2Fsd Service Manager", TRUE); - if (!rc) { - return rc; - } - - return Ext2StartService("Ext2Srv"); -} - - -BOOL -Ext2StartService(CHAR *service) -{ - BOOL rc = FALSE; - SC_HANDLE scmHandle = NULL; - SC_HANDLE drvHandle = NULL; - - scmHandle = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); - if (!scmHandle) { - goto errorout; - } - - drvHandle = OpenService(scmHandle, - service, - SERVICE_ALL_ACCESS); - if (!drvHandle) { - goto errorout; - } - - rc = (0 != StartService(drvHandle, 0, NULL)); - -errorout: - - if (drvHandle) - CloseServiceHandle(drvHandle); - - if (scmHandle) { - CloseServiceHandle(scmHandle); - } - - return rc; -} - -BOOL -Ext2StartExt2Srv() -{ - BOOL rc = Ext2StartService("Ext2Srv"); - if (!rc) - rc = Ext2InstallExt2Srv(); - - return rc; -} - - -BOOL -Ext2StartExt2Fsd() -{ - if (Ext2IsServiceStarted()) { - return TRUE; - } - - return Ext2StartService("ext2fsd"); -} - -BOOL -Ext2IsServiceStarted() -{ - NT::NTSTATUS status; - HANDLE Handle = NULL; - - status = Ext2Open("\\DosDevices\\Ext2Fsd", - &Handle, EXT2_DESIRED_ACCESS); - - Ext2Close(&Handle); - if (NT_SUCCESS(status)) { - return TRUE; - } - - return FALSE; -} - - -BOOL -Ext2IsRemovable(PEXT2_VOLUME volume) -{ - STORAGE_BUS_TYPE busType = BusTypeAta; - BOOL bRemovableMedia = FALSE; - - if (volume && volume->Part) { - busType = volume->Part->Disk->SDD.BusType; - bRemovableMedia = volume->Part->Disk->SDD.RemovableMedia; - } - - if (busType == BusType1394 || - busType == BusTypeUsb || - bRemovableMedia ) { - return TRUE; - } - - return FALSE; -} - -BOOL -Ext2RemoveDriveLetter(CHAR DrvLetter) -{ - PEXT2_LETTER drvLetter = NULL; - BOOL rc = FALSE; - - if (DrvLetter >= '0' && DrvLetter <= '9') { - drvLetter = &drvDigits[DrvLetter - '0']; - } else if (DrvLetter >= 'A' && DrvLetter <= 'Z') { - drvLetter = &drvLetters[DrvLetter - 'A']; - } else if (DrvLetter >= 'a' && DrvLetter <= 'z') { - drvLetter = &drvLetters[DrvLetter - 'a']; - } - - if (drvLetter && drvLetter->bUsed) { - rc = Ext2RemoveDrvLetter(drvLetter); - } - - return rc; -} - -BOOL -Ext2InitializeVolume( - PCHAR NameString, - PEXT2_VOLUME * Volume - ) -{ - BOOL rc = FALSE; - HANDLE hVolume = NULL; - NT::NTSTATUS status; - NT::IO_STATUS_BLOCK ioSb; - PEXT2_VOLUME volume = NULL; - - volume = (PEXT2_VOLUME) malloc(sizeof(EXT2_VOLUME)); - if (!volume) { - goto errorout; - } - - status = Ext2Open(NameString, &hVolume, EXT2_DESIRED_ACCESS); - if (!NT_SUCCESS(status)) { - free(volume); volume = NULL; - goto errorout; - } - - memset(volume, 0, sizeof(EXT2_VOLUME)); - volume->Magic = EXT2_VOLUME_MAGIC; - strcpy(volume->Name, NameString); - - status = NT::ZwQueryVolumeInformationFile( - hVolume, &ioSb, &volume->FsaInfo, - MAX_PATH, NT::FileFsAttributeInformation - ); - - if (NT_SUCCESS(status)) { - - NT::UNICODE_STRING uniString; - NT::ANSI_STRING aniString; - - NT::ZwQueryVolumeInformationFile( - hVolume, &ioSb, &volume->FsdInfo, - sizeof(NT::FILE_FS_DEVICE_INFORMATION), - NT::FileFsDeviceInformation - ); - - NT::ZwQueryVolumeInformationFile( - hVolume, &ioSb, &volume->FssInfo, - sizeof(NT::FILE_FS_SIZE_INFORMATION), - NT::FileFsSizeInformation - ); - - if (volume->FsaInfo.FileSystemNameLength == 6 && - (volume->FsaInfo.FileSystemName[0] == (WCHAR)'R' || - volume->FsaInfo.FileSystemName[0] == (WCHAR)'r') && - (volume->FsaInfo.FileSystemName[1] == (WCHAR)'A' || - volume->FsaInfo.FileSystemName[1] == (WCHAR)'a') && - (volume->FsaInfo.FileSystemName[2] == (WCHAR)'W' || - volume->FsaInfo.FileSystemName[2] == (WCHAR)'w')) { - if (!Ext2QueryVolumeFS(hVolume, volume)) { - /* memcpy(volume->Codepage, "N/A", 3); */ - } - - } else { - if (Ext2QueryExt2Property(hVolume, &volume->EVP)) { - volume->bRecognized = TRUE; - } - } - - /* convert the unicode file system name to mbs */ - - uniString.MaximumLength = uniString.Length = - (USHORT)volume->FsaInfo.FileSystemNameLength; - uniString.Buffer = volume->FsaInfo.FileSystemName; - - aniString.Buffer = volume->FileSystem; - aniString.Length = 0; - aniString.MaximumLength = 64; - - memset(volume->FileSystem, 0, 64); - NT::RtlUnicodeStringToAnsiString(&aniString, &uniString, FALSE); - } - - volume->Extent = Ext2QueryVolumeExtents(hVolume); - if (!volume->Extent) { - free(volume); volume = NULL; - goto errorout; - } - - *Volume = volume; rc = TRUE; - -errorout: - - Ext2Close(&hVolume); - return rc; -} - - -CHAR -Ext2ProcessExt2Property(PEXT2_VOLUME volume) -{ - HANDLE hVolume = NULL; - NT::NTSTATUS status; - CHAR rc = 0; - - status = Ext2Open(volume->Name, &hVolume, EXT2_DESIRED_ACCESS); - if (!NT_SUCCESS(status)) { - goto errorout; - } - - if (Ext2QueryExt2Property(hVolume, &volume->EVP)) { - if (volume->DrvLetters == 0 && volume->EVP.DrvLetter) { - CHAR DrvLetter = volume->EVP.DrvLetter & 0x7F; - if (DrvLetter && Ext2IsDrvLetterAvailable(DrvLetter)) { - rc = Ext2MountVolumeAs(volume->Name, DrvLetter); - } else { - rc = volume->EVP.DrvLetter = Ext2MountVolume(volume->Name); - volume->EVP.DrvLetter |= 0x80; - } - } - } - -errorout: - - Ext2Close(&hVolume); - return rc; -} - -BOOL Ext2ProcessExt2Volumes() -{ - PEXT2_VOLUME volume = gVols; - BOOL rc = FALSE; - - while (volume) { - if (Ext2ProcessExt2Property(volume)) { - rc = TRUE; - } - volume = volume->Next; - } - return rc; -} - -BOOL -Ext2IsPartitionExtent( - ULONG disk, - PPARTITION_INFORMATION_EXT part, - PVOLUME_DISK_EXTENTS extent - ) -{ - DWORD nExt = 0; - - for (nExt = 0; nExt < extent->NumberOfDiskExtents; nExt++) { - if ((extent->Extents[nExt].DiskNumber == disk) && - (extent->Extents[nExt].StartingOffset.QuadPart == - part->StartingOffset.QuadPart ) && - (extent->Extents[nExt].ExtentLength.QuadPart == - part->PartitionLength.QuadPart)) { - return TRUE; - } - } - return FALSE; -} - -/* should be called after volumes' initiaization */ -BOOL -Ext2LoadDiskPartitions(PEXT2_DISK Disk) -{ - UCHAR i = 0, cnt = 0; - ULONG j = 0; - - BOOL bDynamic = FALSE; - - if (Disk->NumParts == 0) { - Disk->NumParts = 1; - } - - Disk->DataParts = (PEXT2_PARTITION) malloc( - sizeof(EXT2_PARTITION) * Disk->NumParts); - if (!Disk->DataParts) { - return FALSE; - } - - memset(Disk->DataParts, 0, sizeof(EXT2_PARTITION) * Disk->NumParts); - - if (Disk->Layout) { - if (Disk->Layout->PartitionStyle == PARTITION_STYLE_MBR && - Disk->Layout->PartitionEntry->Mbr.PartitionType == PARTITION_LDM) { - bDynamic = TRUE; - } - - - /* Now walk through driveLayout and pack partitions */ - for (i = 0; (Disk->Layout != NULL) && - (i < (UCHAR)Disk->Layout->PartitionCount); i++) { - - PPARTITION_INFORMATION_EXT Part; - Part = &Disk->Layout->PartitionEntry[i]; - - if (Disk->Layout->PartitionStyle == PARTITION_STYLE_MBR) { - if (Part->Mbr.PartitionType == PARTITION_ENTRY_UNUSED || - Part->Mbr.PartitionType == PARTITION_EXTENDED || - Part->Mbr.PartitionType == PARTITION_XINT13_EXTENDED) { - continue; - } - } - - sprintf(&Disk->DataParts[cnt].Name[0], - "\\Device\\Harddisk%u\\Partition%u", - Disk->OrderNo, cnt + 1); - Disk->DataParts[cnt].Magic = EXT2_PART_MAGIC; - Disk->DataParts[cnt].PartType = Disk->Layout->PartitionStyle; - - Disk->DataParts[cnt].Disk = Disk; - Disk->DataParts[cnt].Number = cnt + 1; - Disk->DataParts[cnt++].Entry = Part; - } - - /* Search the volumes of the partition */ - for (i=0; i < cnt; i++) { - - PEXT2_VOLUME volume = gVols; - for (j=0; (ULONG)j < g_nVols; j++) { - if (Ext2IsPartitionExtent(Disk->OrderNo, - Disk->DataParts[i].Entry, - volume->Extent )) { - volume->bDynamic = bDynamic; - if (volume->Extent->NumberOfDiskExtents == 1) { - volume->Part = &Disk->DataParts[i]; - } - Disk->DataParts[i].Volume = volume; - Disk->DataParts[i].DrvLetters = volume->DrvLetters; - break; - } - volume = volume->Next; - } - } - } else { - Disk->DataParts[cnt].Magic = EXT2_PART_MAGIC; - Disk->DataParts[cnt].Disk = Disk; - Disk->DataParts[cnt].Number = cnt + 1; - Disk->DataParts[cnt].DrvLetters = Ext2EjectedDiskLetters(Disk); - } - - return TRUE; -} - - -VOID -Ext2LoadAllDiskPartitions() -{ - for (ULONG i=0; i < g_nDisks; i++) { - Ext2LoadDiskPartitions(&gDisks[i]); - } -} - -VOID -Ext2MountingVolumes() -{ - PEXT2_VOLUME volume = gVols; - int j; - - if (!Ext2IsServiceStarted()) { - return; - } - - for (j=0; (ULONG)j < g_nVols; j++) { - if ((volume->EVP.bExt2 || volume->EVP.bExt3) && !volume->bRecognized) { - if (Ext2IsRemovable(volume) || (volume->DrvLetters != 0) || g_bAutoMount) { - if (!Ext2CheckVolumeRegistryProperty(&volume->EVP)) { - Ext2SetDefaultVolumeRegistryProperty(&volume->EVP); - } - Ext2NotifyVolumePoint(volume, 0); - } - } - - volume = volume->Next; - } - -} - -/* - * Must initialize driver letter before loading volumes - */ - -BOOL -Ext2LoadVolumes() -{ - ULONG rc = TRUE; - - TCHAR *nameString = NULL; - ULONG nameLen = REGSTR_VAL_MAX_HCID_LEN; - - HMACHINE hMachine = NULL; - DEVNODE dnRoot, dnFirst; - - DEVINSTID devIds[] = { - "ROOT\\FTDISK\\0000", - "ROOT\\DMIO\\0000", - NULL, - "ROOT\\VOLMGR\\0000", - NULL - }; - - int i = 0; - - if (IsVistaOrAbove()) { - i = 3; - } - - nameString = new TCHAR [nameLen]; - if (nameString == NULL) { - goto errorout; - } - - while (devIds[i] != NULL) { - - rc = CM_Locate_DevNode_Ex(&dnRoot, devIds[i], - CM_LOCATE_DEVNODE_NORMAL , hMachine); - if (rc != CR_SUCCESS) { - break; - } - - rc = CM_Get_Child_Ex(&dnFirst, dnRoot, 0, hMachine); - if (rc != CR_SUCCESS) { - goto errorout; - } - - while (TRUE) { - - PEXT2_VOLUME volume = NULL; - - nameLen = REGSTR_VAL_MAX_HCID_LEN; - memset(nameString, 0, nameLen); - rc = CM_Get_DevNode_Registry_Property_Ex( - dnFirst, CM_DRP_PHYSICAL_DEVICE_OBJECT_NAME, - NULL, nameString, &nameLen, 0, hMachine); - if (rc != CR_SUCCESS) { - break; - } - - if (Ext2InitializeVolume(nameString, &volume)) { - - volume->bDynamic = 0; - - /* attach the volume to global list */ - if (gVols) { - PEXT2_VOLUME chain = gVols; - while (chain->Next) { - chain = chain->Next; - } - chain->Next = volume; - } else { - gVols = volume; - } - g_nVols++; - } - - rc = CM_Get_Sibling_Ex(&dnFirst, dnFirst, 0, hMachine); - if (rc != CR_SUCCESS) { - break; - } - } - - i++; - } - -errorout: - - if (nameString) { - delete []nameString; - } - - return TRUE; -} - -BOOL -Ext2LoadRemovableVolumes() -{ - BOOL rc = FALSE; - HDEVINFO devInfo = INVALID_HANDLE_VALUE; - PSP_DEVICE_INTERFACE_DETAIL_DATA ifDetail = NULL; - SP_DEVICE_INTERFACE_DATA ifData; - - PCHAR nameString; - int nInterface = 0; - - if (IsVistaOrAbove()) { - return TRUE; - } - - nameString = (PCHAR)malloc(REGSTR_VAL_MAX_HCID_LEN); - if (nameString == NULL) { - goto errorout; - } - - ifDetail = (PSP_DEVICE_INTERFACE_DETAIL_DATA)malloc(PAGE_SIZE); - if (ifDetail == NULL) { - goto errorout; - } - - devInfo = SetupDiGetClassDevs( - &VolumeClassGuid, NULL, NULL, - DIGCF_PRESENT | DIGCF_DEVICEINTERFACE - ); - if (devInfo == INVALID_HANDLE_VALUE) { - goto errorout; - } - - while (TRUE) { - - BOOL bFound = FALSE; - - ifData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); - bFound = SetupDiEnumDeviceInterfaces( - devInfo, - NULL, - &VolumeClassGuid, - (ULONG)nInterface++, - &ifData); - if (!bFound) { - break; - } - - memset(ifDetail, 0, PAGE_SIZE); - ifDetail->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); - if (SetupDiGetInterfaceDeviceDetail( - devInfo, - &ifData, - ifDetail, - PAGE_SIZE, - NULL, - NULL)) { - - PEXT2_VOLUME volume = NULL; - - memset(nameString, 0, REGSTR_VAL_MAX_HCID_LEN); - QueryDosDevice(&ifDetail->DevicePath[4], nameString, REGSTR_VAL_MAX_HCID_LEN); - - if (Ext2InitializeVolume(nameString, &volume)) { - - if (volume->FsdInfo.Characteristics & FILE_REMOVABLE_MEDIA) { - - /* attach the volume to global list */ - if (gVols) { - PEXT2_VOLUME chain = gVols; - while (chain->Next) { - chain = chain->Next; - } - chain->Next = volume; - } else { - gVols = volume; - } - g_nVols++; - } else { - if (volume->Extent) { - free(volume->Extent); - } - free(volume); - } - } - } - } - - rc = TRUE; - -errorout: - - if (nameString) { - free(nameString); - } - - if (ifDetail) { - free(ifDetail); - } - - if (devInfo != INVALID_HANDLE_VALUE) { - SetupDiDestroyDeviceInfoList(devInfo); - } - - return rc; -} - -VOID -Ext2LoadAllVolumeDrvLetters() -{ - PEXT2_VOLUME volume = gVols; - BOOL started = Ext2IsServiceStarted(); - - // Ext2DrvLetters[0] = Ext2DrvLetters[1]; - // Ext2DrvLetters[1] = 0; - - while (volume) { - volume->DrvLetters = Ext2QueryVolumeDrvLetters(volume); - if ( started && volume->bRecognized && - (volume->EVP.bExt2 || volume->EVP.bExt3)) { - Ext2DrvLetters[1] |= volume->DrvLetters; - } - volume = volume->Next; - } -} - - -CString -Ext2QueryVolumeLetterStrings( - ULONGLONG letters, - PEXT2_LETTER * first - ) -{ - CHAR drvName[] = "C:\0"; - CString str; - int i = 0; - BOOL bInserted = FALSE; - ULONGLONG drive = 0; - - str.Empty(); - - for (i=0; i < 10; i++) { - drive = ((ULONGLONG) 1) << (i + 32); - if (letters & drive) { - if (bInserted) { - str += ","; - } else { - str = "("; - if (first) { - *first = &drvDigits[i]; - } - } - drvName[0] = '0' + i; - str += drvName; - bInserted = TRUE; - } - } - - for (i=0; i < 26; i++) { - drive = ((ULONGLONG) 1) << (i); - if (letters & drive) { - if (bInserted) { - str += ","; - } else { - str = "("; - if (first) { - *first = &drvLetters[i]; - } - } - - drvName[0] = 'A' + i; - str += drvName; - bInserted = TRUE; - } - } - - if (bInserted) { - str += ")"; - } - - return str; -} - -VOID -Ext2RefreshVLVI( - CListCtrl *List, - PEXT2_VOLUME chain, - int nItem - ) -{ - ULONGLONG totalSize, usedSize; - CString sSize, sUnit, s; - - PEXT2_LETTER first = NULL; - CString Letters = Ext2QueryVolumeLetterStrings( - chain->DrvLetters, &first); - - List->SetItem( nItem, 1, LVIF_TEXT, (LPCSTR)Letters, 0, 0, 0,0); - - if (chain->bDynamic) { - s.LoadString(IDS_DISK_TYPE_DYN); - } else { - s.LoadString(IDS_DISK_TYPE_BASIC); - } - List->SetItem(nItem, 2, LVIF_TEXT, (LPCSTR)s, 0, 0, 0,0); - List->SetItem(nItem, 3, LVIF_TEXT, (LPCSTR)chain->FileSystem, 0, 0, 0,0); - - totalSize = chain->FssInfo.TotalAllocationUnits.QuadPart; - usedSize = totalSize - chain->FssInfo.AvailableAllocationUnits.QuadPart; - totalSize = totalSize * chain->FssInfo.BytesPerSector * - chain->FssInfo.SectorsPerAllocationUnit; - usedSize = usedSize * chain->FssInfo.BytesPerSector * - chain->FssInfo.SectorsPerAllocationUnit; - - if (totalSize > (ULONGLONG) 10 * 1024 * 1024 * 1024) { - totalSize = totalSize / ((ULONG)1024 * 1024 * 1024); - usedSize = usedSize / ((ULONG)1024 * 1024 * 1024); - sUnit = " GB"; - } else if (totalSize > 10 * 1024 * 1024){ - totalSize = totalSize / (1024 * 1024); - usedSize = usedSize / (1024 * 1024); - sUnit = " MB"; - } else if (totalSize > 10 * 1024){ - totalSize = totalSize / (1024); - usedSize = usedSize / (1024); - sUnit = " KB"; - } else { - sUnit = " B"; - } - - sSize.Format("%I64u", totalSize); - sSize += sUnit; - List->SetItem(nItem, 4, LVIF_TEXT, (LPCSTR)sSize, 0, 0, 0,0); - - if (chain->bRecognized) { - sSize.Format("%I64u", usedSize); - sSize += sUnit; - } - List->SetItem(nItem, 5, LVIF_TEXT, (LPCSTR)sSize, 0, 0, 0,0); - - List->SetItem(nItem, 6, LVIF_TEXT, (LPCSTR)chain->EVP.Codepage, 0, 0, 0,0); - List->SetItem(nItem, 7, LVIF_TEXT, (LPCSTR)chain->Name, 0, 0, 0,0); - -/* - List->SetItemState( nItem, LVIS_SELECTED | LVIS_FOCUSED , - LVIS_SELECTED | LVIS_FOCUSED); -*/ -} - - -VOID -Ext2InsertVolume( - CListCtrl *List, - PEXT2_VOLUME chain - ) -{ - int nItem = 0, nImage = 0; - - nItem = List->GetItemCount(); - nImage = 0; - - if (chain->FsdInfo.Characteristics & FILE_VIRTUAL_VOLUME) { - nImage = IDI_DYNAMIC - IDI_FLOPPY; - } else if (chain->FsdInfo.Characteristics & FILE_REMOVABLE_MEDIA) { - nImage = IDI_FLOPPY - IDI_FLOPPY; - } else { - nImage = IDI_DISK - IDI_FLOPPY; - } - - nItem = List->InsertItem( LVIF_PARAM|LVIF_IMAGE, nItem, NULL, - 0, 0, nImage, (LPARAM)chain); - - Ext2RefreshVLVI(List, chain, nItem); -} - -VOID -Ext2RefreshVLCD( - CListCtrl *List, - PEXT2_CDROM Cdrom, - int nItem - ) -{ - ULONGLONG totalSize; - CString sSize, sUnit, s; - - PEXT2_LETTER first = NULL; - - CString Letters = Ext2QueryVolumeLetterStrings( - Cdrom->DrvLetters, &first); - - List->SetItem( nItem, 1, LVIF_TEXT, (LPCSTR)Letters, 0, 0, 0,0); - - s.LoadString(IDS_DISK_TYPE_BASIC); - List->SetItem(nItem, 2, LVIF_TEXT, (LPCSTR)s, 0, 0, 0,0); - List->SetItem(nItem, 3, LVIF_TEXT, (LPCSTR)"CDFS", 0, 0, 0,0); - - - totalSize = (ULONGLONG)Cdrom->DiskGeometry.Cylinders.QuadPart; - totalSize = totalSize * Cdrom->DiskGeometry.TracksPerCylinder * - Cdrom->DiskGeometry.SectorsPerTrack * - Cdrom->DiskGeometry.BytesPerSector; - - if (totalSize > 1024 * 1024 * 1024) { - totalSize = totalSize / (1024 * 1024 * 1024); - sUnit = " GB"; - } else if (totalSize > 1024 * 1024){ - totalSize = totalSize / (1024 * 1024); - sUnit = " MB"; - } else if (totalSize > 1024){ - totalSize = totalSize / (1024); - sUnit = " KB"; - } else { - sUnit = " B"; - } - - sSize.Format("%I64u", totalSize); - sSize += sUnit; - List->SetItem(nItem, 4, LVIF_TEXT, (LPCSTR)sSize, 0, 0, 0,0); - - sSize.Format("%I64u", totalSize); - sSize += sUnit; - List->SetItem(nItem, 5, LVIF_TEXT, (LPCSTR)sSize, 0, 0, 0,0); - - List->SetItem(nItem, 8, LVIF_TEXT, (LPCSTR)Cdrom->Name, 0, 0, 0,0); -} - -VOID -Ext2InsertCdromAsVolume( - CListCtrl *List, - PEXT2_CDROM Cdrom - ) -{ - int nItem = 0, nImage = 0; - - nItem = List->GetItemCount(); - nImage = 0; - - if (Cdrom->bIsDVD) { - nImage = IDI_DVD - IDI_FLOPPY; - } else { - nImage = IDI_CDROM - IDI_FLOPPY; - } - - nItem = List->InsertItem( LVIF_PARAM|LVIF_IMAGE, nItem, NULL, - 0, 0, nImage, (LPARAM)Cdrom); - - Ext2RefreshVLCD(List, Cdrom, nItem); -} - -VOID -Ext2RefreshVolumeList(CListCtrl *List) -{ - List->DeleteAllItems(); - PEXT2_VOLUME chain = gVols; - - /* adding disk volumes */ - while (chain) { - Ext2InsertVolume(List, chain); - chain = chain->Next; - } - - /* adding cdroms */ - - ULONG i = 0; - - for (i=0; i < g_nCdroms; i++) { - - if (!gCdroms[i].bLoaded || gCdroms[i].bEjected) { - continue; - } - Ext2InsertCdromAsVolume(List, &gCdroms[i]); - } -} - -VOID -Ext2RefreshDVPT( - CListCtrl* List, - PEXT2_PARTITION Part, - int nItem - ) -{ - - ULONGLONG totalSize, usedSize; - CString sSize, sUnit, s; - - PEXT2_LETTER first = NULL; - PEXT2_VOLUME chain = NULL; - - CString Letters = Ext2QueryVolumeLetterStrings( - Part->DrvLetters, &first); - - List->SetItem( nItem, 0, LVIF_TEXT, (LPCSTR)Letters, 0, 0, 0,0); - - if (Part->Entry) { - CString PartType; - if (Part->Entry->PartitionStyle == PARTITION_STYLE_MBR) { - PartType = PartitionString(Part->Entry->Mbr.PartitionType); - } else if (Part->Entry->PartitionStyle == PARTITION_STYLE_GPT) { - PartType = ""; - if (Part->Entry->Gpt.Name && wcslen(Part->Entry->Gpt.Name)) { - for (size_t i = 0; i < wcslen(Part->Entry->Gpt.Name); i++) - PartType += (CHAR)Part->Entry->Gpt.Name[i]; - - } else { - PartType = "GPT"; - } - } else { - PartType = "RAW"; - } - - List->SetItem(nItem, 6, LVIF_TEXT, (LPCSTR) - PartType, 0, 0, 0,0); - } - - /* query the volume information of the partition */ - chain = Part->Volume; - if (!chain) { - PEXT2_DISK disk = Part->Disk; - CString s; - if (disk->SDD.RemovableMedia) { - s.LoadString(IDS_DISK_TYPE_BASIC); - } else if (disk->bLoaded){ - if (disk->Layout) { - if (disk->Layout->PartitionStyle == PARTITION_STYLE_MBR) { - if (disk->Layout->PartitionEntry->Mbr.PartitionType - == PARTITION_LDM) { - s.LoadString(IDS_DISK_TYPE_DYN); - } else { - s.LoadString(IDS_DISK_TYPE_BASIC); - } - } else if (disk->Layout->PartitionStyle == PARTITION_STYLE_GPT) { - s = "GPT"; - } - } else { - s = "RAW"; - } - } else { - s = "Stopped"; - } - - List->SetItem(nItem, 1, LVIF_TEXT, (LPCSTR)s, 0, 0, 0,0); - return; - } - - if (chain->bDynamic) { - s.LoadString(IDS_DISK_TYPE_DYN); - } else { - s.LoadString(IDS_DISK_TYPE_BASIC); - } - List->SetItem(nItem, 1, LVIF_TEXT, (LPCSTR)s, 0, 0, 0,0); - - List->SetItem(nItem, 2, LVIF_TEXT, (LPCSTR)chain->FileSystem, 0, 0, 0,0); - - totalSize = chain->FssInfo.TotalAllocationUnits.QuadPart; - usedSize = totalSize - chain->FssInfo.AvailableAllocationUnits.QuadPart; - totalSize = totalSize * chain->FssInfo.BytesPerSector * - chain->FssInfo.SectorsPerAllocationUnit; - usedSize = usedSize * chain->FssInfo.BytesPerSector * - chain->FssInfo.SectorsPerAllocationUnit; - - if (totalSize > (ULONGLONG) 10 * 1024 * 1024 * 1024) { - totalSize = totalSize / ((ULONG)1024 * 1024 * 1024); - usedSize = usedSize / ((ULONG)1024 * 1024 * 1024); - sUnit = " GB"; - } else if (totalSize > 10 * 1024 * 1024){ - totalSize = totalSize / (1024 * 1024); - usedSize = usedSize / (1024 * 1024); - sUnit = " MB"; - } else if (totalSize > 10 * 1024){ - totalSize = totalSize / (1024); - usedSize = usedSize / (1024); - sUnit = " KB"; - } else { - sUnit = " B"; - } - - sSize.Format("%I64u", totalSize); - sSize += sUnit; - List->SetItem(nItem, 3, LVIF_TEXT, (LPCSTR)sSize, 0, 0, 0,0); - - if (chain->bRecognized) { - sSize.Format("%I64u", usedSize); - sSize += sUnit; - } - List->SetItem(nItem, 4, LVIF_TEXT, (LPCSTR)sSize, 0, 0, 0,0); - - List->SetItem(nItem, 5, LVIF_TEXT, (LPCSTR)chain->EVP.Codepage, 0, 0, 0,0); -} - -VOID -Ext2InsertPartition( - CListCtrl* List, - PEXT2_DISK Disk, - PEXT2_PARTITION Part - ) -{ - int nItem = 0, nImage = 0; - - nItem = List->GetItemCount(); - nImage = 0; - - if (!Disk) { - nItem = List->InsertItem( LVIF_PARAM|LVIF_IMAGE, nItem, NULL, - 0, 0, nImage, (LPARAM)NULL); - return; - } - - if (!Part) { - nItem = List->InsertItem( LVIF_PARAM|LVIF_IMAGE, nItem, NULL, - 0, 0, nImage, (LPARAM)&Disk->Null); - List->SetItem( nItem, 1, LVIF_TEXT, (LPCSTR)"RAW", 0, 0, 0,0); - return; - } - - nItem = List->InsertItem( LVIF_PARAM| LVIF_IMAGE, nItem, NULL, - 0, 0, nImage, (LPARAM)Part); - - Ext2RefreshDVPT(List, Part, nItem); -} - -VOID -Ext2InsertDisk( - CListCtrl *List, - PEXT2_DISK Disk - ) -{ - UCHAR i; - CHAR devName[64]; - int nItem = 0, nImage = 0; - - sprintf(devName, "DISK %d", Disk->OrderNo); - nItem = List->GetItemCount(); - nItem = List->InsertItem( LVIF_PARAM|LVIF_IMAGE, nItem, NULL, - 0, 0, nImage, (LPARAM)Disk); - List->SetItem( nItem, 0, LVIF_TEXT, (LPCSTR)devName, 0, 0, 0,0); - - if (Disk->NumParts > 0) { - for (i=0; i < Disk->NumParts; i++) { - Ext2InsertPartition(List, Disk, &Disk->DataParts[i]); - } - } else { - Ext2InsertPartition(List, Disk, NULL); - } -} - - -VOID -Ext2RefreshDVCM( - CListCtrl *List, - PEXT2_CDROM Cdrom, - int nItem - ) -{ - ULONGLONG totalSize; - CString sSize, sUnit, s; - - PEXT2_LETTER first = NULL; - - CString Letters = Ext2QueryVolumeLetterStrings( - Cdrom->DrvLetters, &first); - - if (!Cdrom->bLoaded) { - List->SetItem( nItem, 1, LVIF_TEXT, (LPCSTR)"Stopped", 0, 0, 0,0); - return; - } - - List->SetItem( nItem, 0, LVIF_TEXT, (LPCSTR)Letters, 0, 0, 0,0); - - if (Cdrom->bEjected) { - return; - } - - s.LoadString(IDS_DISK_TYPE_BASIC); - List->SetItem(nItem, 1, LVIF_TEXT, (LPCSTR)s, 0, 0, 0,0); - List->SetItem(nItem, 2, LVIF_TEXT, (LPCSTR)"CDFS", 0, 0, 0,0); - - totalSize = (ULONGLONG)Cdrom->DiskGeometry.Cylinders.QuadPart; - totalSize = totalSize * Cdrom->DiskGeometry.TracksPerCylinder * - Cdrom->DiskGeometry.SectorsPerTrack * - Cdrom->DiskGeometry.BytesPerSector; - - if (totalSize > 1024 * 1024 * 1024) { - totalSize = totalSize / (1024 * 1024 * 1024); - sUnit = " GB"; - } else if (totalSize > 1024 * 1024){ - totalSize = totalSize / (1024 * 1024); - sUnit = " MB"; - } else if (totalSize > 1024){ - totalSize = totalSize / (1024); - sUnit = " KB"; - } else { - sUnit = " B"; - } - - sSize.Format("%I64u", totalSize); - sSize += sUnit; - List->SetItem(nItem, 3, LVIF_TEXT, (LPCSTR)sSize, 0, 0, 0,0); - - sSize.Format("%I64u", totalSize); - sSize += sUnit; - List->SetItem(nItem, 4, LVIF_TEXT, (LPCSTR)sSize, 0, 0, 0,0); - - List->SetItem(nItem, 5, LVIF_TEXT, (LPCSTR)"", 0, 0, 0,0); - List->SetItem(nItem, 6, LVIF_TEXT, (LPCSTR)"", 0, 0, 0,0); -} - -VOID -Ext2InsertCdromAsDisk( - CListCtrl *List, - PEXT2_CDROM Cdrom - ) -{ - CHAR devName[64]; - int nItem = 0, nImage = 0; - - sprintf(devName, "CDROM %d", Cdrom->OrderNo); - nItem = List->GetItemCount(); - nItem = List->InsertItem( LVIF_PARAM|LVIF_IMAGE, nItem, NULL, - 0, 0, nImage, (LPARAM)Cdrom); - List->SetItem( nItem, 0, LVIF_TEXT, (LPCSTR)devName, 0, 0, 0,0); - - nItem = List->GetItemCount(); - nImage = 0; - - if (Cdrom->bIsDVD) { - nImage = IDI_DVD - IDI_FLOPPY; - } else { - nImage = IDI_CDROM - IDI_FLOPPY; - } - - nItem = List->InsertItem( LVIF_PARAM|LVIF_IMAGE, nItem, NULL, - 0, 0, nImage, (LPARAM)(&Cdrom->Magic[1])); - - Ext2RefreshDVCM(List, Cdrom, nItem); -} - -VOID -Ext2RefreshDiskList(CListCtrl *List) -{ - List->DeleteAllItems(); - ULONG i = 0; - - /* adding disks */ - for (i=0; i < g_nDisks; i++) { - Ext2InsertDisk(List, &gDisks[i]); - Ext2InsertPartition(List, NULL, NULL); - } - - /* adding cdroms */ - for (i=0; i < g_nCdroms; i++) { - Ext2InsertCdromAsDisk(List, &gCdroms[i]); - Ext2InsertPartition(List, NULL, NULL); - } -} - - -VOID -Ext2CleanupVolumes() -{ - PEXT2_VOLUME chain = gVols, next = NULL; - - while (chain) { - next = chain->Next; - if (chain->Extent) { - free(chain->Extent); - } - free(chain); - g_nVols--; - chain = next; - } - - ASSERT(g_nVols == 0); - g_nVols = 0; gVols = NULL; -} - -VOID -Ext2LoadDrvLetter(PEXT2_LETTER drvLetter, CHAR cLetter) -{ - if (drvLetter->bUsed) { - return; - } - - if (cLetter >= 'a' && cLetter <= 'z') { - cLetter -= 0x20; - } - - memset(drvLetter, 0, sizeof(EXT2_LETTER)); - drvLetter->Letter = cLetter; - Ext2QueryDrvLetter(drvLetter); -} - -VOID -Ext2LoadDrvLetters() -{ - int i; - - for (i=0; i < 36; i++) { - - PEXT2_LETTER drvLetter = NULL; - CHAR cLetter = 0; - - if (i < 10) { - drvLetter = &drvDigits[i]; - cLetter = '0' + i; - } else { - drvLetter = &drvLetters[i-10]; - cLetter = 'A' + (i - 10); - } - - Ext2LoadDrvLetter(drvLetter, cLetter); - } -} - -VOID -Ext2CleanDrvLetter(PEXT2_LETTER drvLetter) -{ - if (drvLetter->Extent) { - free(drvLetter->Extent); - drvLetter->Extent = NULL; - } - - if (drvLetter->SDN) { - free(drvLetter->SDN); - drvLetter->SDN = NULL; - } - - drvLetter->bUsed = FALSE; - drvLetter->bTemporary = FALSE; - drvLetter->DrvType = DRIVE_NO_ROOT_DIR; - memset(drvLetter->SymLink, 0, MAX_PATH); -} - -VOID -Ext2CleanupDrvLetters() -{ - int i = 0; - - for (i=0; i < 10; i++) { - Ext2CleanDrvLetter(&drvDigits[i]); - } - - for (i=0; i < 26; i++) { - Ext2CleanDrvLetter(&drvLetters[i]); - } -} - -VOID -Ext2DrvNotify(UCHAR drive, int mount) -{ - DEV_BROADCAST_VOLUME dbv; - DWORD target = BSM_APPLICATIONS; - unsigned long drv = 0; - - if (drive >= 'A' && drive <= 'Z') - drv = drive - 'A'; - else if(drive >= 'a' && drive <= 'z') - drv = drive - 'a'; - else - return; - - dbv.dbcv_size = sizeof( dbv ); - dbv.dbcv_devicetype = DBT_DEVTYP_VOLUME; - dbv.dbcv_reserved = 0; - dbv.dbcv_unitmask = (1 << drv); - dbv.dbcv_flags = DBTF_NET; - BroadcastSystemMessage(BSF_IGNORECURRENTTASK | BSF_FORCEIFHUNG | - BSF_NOHANG | BSF_NOTIMEOUTIFNOTHUNG, - &target, WM_DEVICECHANGE, mount ? - DBT_DEVICEARRIVAL : DBT_DEVICEREMOVECOMPLETE, - (LPARAM)(DEV_BROADCAST_HDR *)&dbv ); -} - -BOOL -Ext2RemoveDrvLetter( - PEXT2_LETTER drvLetter - ) -{ - CHAR drvPath[] = "A:\\\0"; - CHAR dosPath[] = "A:\0"; - - BOOL rc = FALSE; - - if (!drvLetter->bUsed) { - return TRUE; - } - - dosPath[0] = drvPath[0] = drvLetter->Letter; - rc = Ext2DefineDosDevice ( - DDD_RAW_TARGET_PATH| - DDD_REMOVE_DEFINITION| - DDD_EXACT_MATCH_ON_REMOVE, - dosPath, drvLetter->SymLink); - DeleteVolumeMountPoint(drvPath); - - if (!rc) { - return FALSE; - } - - return TRUE; -} - -CHAR -Ext2QueryRegistryMountPoint ( - CHAR * devName - ) -{ - DWORD i = 0; - - LONG status; - HKEY hKey; - - DWORD drvSize; - DWORD dosSize; - DWORD valType; - - CHAR keyPath[MAX_PATH]; - CHAR drvPath[MAX_PATH]; - CHAR dosPath[64]; - - /* set dos deivce path */ - strcpy (keyPath, "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\DOS Devices"); - - /* open session manager\dos devices */ - status = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, - keyPath, - 0, - KEY_ALL_ACCESS, - &hKey) ; - if (status != ERROR_SUCCESS) { - return FALSE; - } - - - /* enum all values and compare devName ... */ - while (status != ERROR_NO_MORE_ITEMS && i < 1024) { - - valType = REG_SZ; - dosSize = 64; - drvSize = MAX_PATH; - - status = RegEnumValue(hKey, - i++, - &dosPath[0], - &dosSize, - NULL, - &valType, - (LPBYTE)&drvPath[0], - &drvSize); - - if (status == ERROR_SUCCESS) { - if (_stricmp(devName, drvPath) == 0) { - RegCloseKey(hKey); - return dosPath[0]; - } - } - } - - RegCloseKey(hKey); - - return 0; -} - -BOOL -Ext2SetRegistryMountPoint ( - CHAR * dosPath, - CHAR * devName, - BOOL bSet - ) -{ - LONG status; - HKEY hKey; - CHAR keyPath[MAX_PATH]; - CHAR drvPath[MAX_PATH]; - - /* set dos driver name */ - sprintf(drvPath, "%c:", dosPath[0]); - - /* set dos deivce path */ - strcpy (keyPath, "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\DOS Devices"); - - /* open session manager\dos devices */ - status = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, - keyPath, - 0, - KEY_ALL_ACCESS, - &hKey) ; - if (status != ERROR_SUCCESS) { - return FALSE; - } - - if (bSet) { - /* set value */ - status = RegSetValueEx( - hKey, drvPath, - 0, REG_SZ, - (BYTE *)devName, - (int)strlen(devName) - ); - } else { - /* delete key */ - status = RegDeleteValue( - hKey, drvPath - ); - } - - RegCloseKey(hKey); - - if (status != ERROR_SUCCESS) { - return FALSE; - } - - return TRUE; -} - -VOID -Ext2UpdateDrvLetter( - PEXT2_LETTER drvLetter, - PCHAR devPath - ) -{ - CHAR dosPath[] = "A:\0"; - BOOL rc = 0; - - if (drvLetter->bUsed) { - return; - } - - dosPath[0] = drvLetter->Letter; - rc = Ext2DefineDosDevice(DDD_RAW_TARGET_PATH, - dosPath, devPath); - - if (rc) { - Ext2DefineDosDevice ( - DDD_RAW_TARGET_PATH| - DDD_REMOVE_DEFINITION| - DDD_EXACT_MATCH_ON_REMOVE, - dosPath, devPath); - } -} - -BOOL -Ext2AssignDrvLetter( - PEXT2_LETTER drvLetter, - PCHAR devPath, - BOOL bMountMgr - ) -{ - CHAR dosPath[] = "A:\0"; - CHAR drvPath[] = "A:\\\0"; - CHAR volumeName[MAX_PATH]; - - BOOL rc = 0; - - if (drvLetter->bUsed) { - return FALSE; - } - - memset(volumeName, 0, MAX_PATH); - dosPath[0] = drvPath[0] = drvLetter->Letter; - - rc = Ext2DefineDosDevice(DDD_RAW_TARGET_PATH, - dosPath, devPath); - - if (rc) { - - /* Now it's done, since user only - needs a temporary mount point */ - if (!bMountMgr) { - goto DrvMounted; - } - - rc = GetVolumeNameForVolumeMountPoint ( - drvPath, volumeName, MAX_PATH); - - Ext2DefineDosDevice ( - DDD_RAW_TARGET_PATH| - DDD_REMOVE_DEFINITION| - DDD_EXACT_MATCH_ON_REMOVE, - dosPath, devPath); - - if (rc) { - rc = SetVolumeMountPoint(drvPath, volumeName); - } - } - - if (!rc) { - return FALSE; - } - -DrvMounted: - - drvLetter->bTemporary = !bMountMgr; - Ext2QueryDrvLetter(drvLetter); - - return TRUE; -} - -/* - * Mount Manager Support Routines - */ - -VOID -Ext2AnsiToUnicode( - CHAR * AnsiName, - WCHAR* UniName, - USHORT UniLength - ) -{ - USHORT NameLength = 0; - NT::ANSI_STRING AnsiFilespec; - NT::UNICODE_STRING UnicodeFilespec; - - memset(UniName, 0, sizeof(WCHAR) * UniLength); - - NameLength = (USHORT)strlen(AnsiName); - ASSERT(NameLength < UniLength); - - AnsiFilespec.MaximumLength = AnsiFilespec.Length = NameLength; - AnsiFilespec.Buffer = AnsiName; - - UnicodeFilespec.MaximumLength = UniLength * 2; - UnicodeFilespec.Length = 0; - UnicodeFilespec.Buffer = (PWSTR)UniName; - - NT::RtlAnsiStringToUnicodeString(&UnicodeFilespec, &AnsiFilespec, FALSE); -} - -BOOL -Ext2VolumeArrivalNotify(PCHAR VolumePath) -{ - HANDLE hMountMgr = NULL; - - NT::IO_STATUS_BLOCK iosb; - NT::NTSTATUS status; - DWORD rc = 0; - - WCHAR volPath[MAX_PATH + 2]; - PMOUNTMGR_TARGET_NAME target; - - target = (PMOUNTMGR_TARGET_NAME) volPath; - Ext2AnsiToUnicode(VolumePath, &target->DeviceName[0], MAX_PATH); - target->DeviceNameLength = (USHORT)wcslen(target->DeviceName) * 2; - - status = Ext2Open("\\Device\\MountPointManager", &hMountMgr, EXT2_DESIRED_ACCESS); - if (!NT_SUCCESS(status)) { - goto errorout; - } - - status = NT::ZwDeviceIoControlFile( - hMountMgr, NULL, NULL, NULL, &iosb, - IOCTL_MOUNTMGR_VOLUME_ARRIVAL_NOTIFICATION, - (PVOID)target, sizeof(USHORT) + - target->DeviceNameLength, NULL, 0 - ); - - if (!NT_SUCCESS(status)) { - goto errorout; - } - -errorout: - - Ext2Close(&hMountMgr); - return NT_SUCCESS(status); -} - - -BOOL -Ext2SymLinkRemoval(CHAR drvLetter) -{ - HANDLE hMountMgr = NULL; - - NT::IO_STATUS_BLOCK iosb; - NT::NTSTATUS status; - DWORD rc = 0; - - WCHAR buffer[MAX_PATH], *dosName; - PMOUNTMGR_MOUNT_POINT pmp = NULL; - PMOUNTMGR_MOUNT_POINTS pms = NULL; - - memset(buffer, 0, sizeof(WCHAR) * MAX_PATH); - pmp = (PMOUNTMGR_MOUNT_POINT) buffer; - pmp->SymbolicLinkNameOffset = sizeof(MOUNTMGR_MOUNT_POINT); - pmp->SymbolicLinkNameLength = 14 * sizeof(WCHAR); - - dosName = (WCHAR *) (pmp + 1); - swprintf_s(dosName, MAX_PATH - sizeof(MOUNTMGR_MOUNT_POINT), - L"\\DosDevices\\%c:\0", drvLetter); - - status = Ext2Open("\\Device\\MountPointManager", &hMountMgr, EXT2_DESIRED_ACCESS); - if (!NT_SUCCESS(status)) { - goto errorout; - } - - status = NT::ZwDeviceIoControlFile( - hMountMgr, NULL, NULL, NULL, &iosb, - IOCTL_MOUNTMGR_DELETE_POINTS, - (PVOID)pmp, sizeof(WCHAR) * MAX_PATH, - (PVOID)pmp, sizeof(WCHAR) * MAX_PATH - ); - - if (!NT_SUCCESS(status)) { - goto errorout; - } - -errorout: - - Ext2Close(&hMountMgr); - return NT_SUCCESS(status); -} - -BOOL -Ext2SetVolumeMountPoint ( - CHAR * dosPath, - CHAR * devName - ) -{ - HANDLE hMountMgr; - - NT::IO_STATUS_BLOCK iosb; - NT::NTSTATUS status; - DWORD rc = 0; - - CHAR dosDevice[MAX_PATH]; - WCHAR volPath[MAX_PATH]; - WCHAR devPath[MAX_PATH]; - - PMOUNTMGR_CREATE_POINT_INPUT mcpi = NULL; - - USHORT lmcpi = 0, lvolp = 0, ldevp = 0; - - memset(dosDevice, 0, MAX_PATH); - memset(volPath, 0, MAX_PATH * sizeof(WCHAR)); - memset(devPath, 0, MAX_PATH * sizeof(WCHAR)); - - /* covert names to unicode */ - sprintf(dosDevice, "\\DosDevices\\%c:", toupper(dosPath[0])); - Ext2AnsiToUnicode(dosDevice, volPath, MAX_PATH); - Ext2AnsiToUnicode(devName, devPath, MAX_PATH); - - ldevp = (USHORT)wcslen(devPath) * 2; - lvolp = (USHORT)wcslen(volPath) * 2; - lmcpi = sizeof(MOUNTMGR_CREATE_POINT_INPUT) + lvolp + ldevp; - - /* initialize MMGR_CREATE_MOUNT_POINT_INPUT */ - mcpi = (PMOUNTMGR_CREATE_POINT_INPUT) malloc(lmcpi); - if (mcpi == NULL) { - status = STATUS_UNSUCCESSFUL; - goto errorout; - } - - mcpi->SymbolicLinkNameOffset = sizeof(MOUNTMGR_CREATE_POINT_INPUT); - mcpi->SymbolicLinkNameLength = lvolp; - mcpi->DeviceNameOffset = mcpi->SymbolicLinkNameOffset + lvolp; - mcpi->DeviceNameLength = ldevp; - - memcpy((PCHAR)mcpi + mcpi->SymbolicLinkNameOffset, - volPath, lvolp); - memcpy((PCHAR)mcpi + mcpi->DeviceNameOffset, - devPath, ldevp); - - /* open MountMgr */ - status = Ext2Open("\\Device\\MountPointManager", &hMountMgr, EXT2_DESIRED_ACCESS); - if (!NT_SUCCESS(status)) { - goto errorout; - } - - /* ioctl .... */ - status = NT::ZwDeviceIoControlFile( - hMountMgr, NULL, NULL, NULL, &iosb, - IOCTL_MOUNTMGR_CREATE_POINT, - (PVOID)mcpi, lmcpi, NULL, 0 - ); - - if (!NT_SUCCESS(status)) { - goto errorout; - } - - Ext2Close(&hMountMgr); - -errorout: - if (mcpi) { - free(mcpi); - } - - return NT_SUCCESS(status); -} - - -UCHAR -Ext2QueryMountPoint( - CHAR * volume - ) -{ - NT::IO_STATUS_BLOCK iosb; - NT::NTSTATUS status; - ULONG lp, lps; - ULONG i; - HANDLE hMountMgr = 0; - - NT::UNICODE_STRING volPoint; - NT::UNICODE_STRING VolumeName; - WCHAR VolumeBuffer[MAX_PATH]; - - PMOUNTMGR_MOUNT_POINT point = NULL; - PMOUNTMGR_MOUNT_POINTS points = NULL; - UCHAR drvLetter = 0; - - memset(VolumeBuffer, 0, MAX_PATH * sizeof(WCHAR)); - Ext2AnsiToUnicode(volume, VolumeBuffer, MAX_PATH); - - VolumeName.MaximumLength = MAX_PATH; - VolumeName.Length = (USHORT)wcslen(VolumeBuffer) * 2; - VolumeName.Buffer = VolumeBuffer; - - status = Ext2Open("\\Device\\MountPointManager", &hMountMgr, EXT2_DESIRED_ACCESS); - if (!NT_SUCCESS(status)) { - goto errorout; - } - - lp = VolumeName.Length + sizeof(MOUNTMGR_MOUNT_POINT) + 2; - point = (PMOUNTMGR_MOUNT_POINT)malloc(lp); - if (point == NULL) { - goto errorout; - } - - /* initialize MountMgr ioctl input structure */ - memset(point, 0, lp); - point->DeviceNameOffset = sizeof(MOUNTMGR_MOUNT_POINT); - point->DeviceNameLength = VolumeName.Length; - RtlMoveMemory((PCHAR) point + point->DeviceNameOffset, - VolumeBuffer, VolumeName.Length); - lps = 1024; - -Again: - - /* allocate ioctl output structure */ - points = (PMOUNTMGR_MOUNT_POINTS)malloc(lps); - if (!points) { - goto errorout; - } - RtlZeroMemory(points, lps); - - /* could MoungMgr to create volume points for us ? */ - status = NT::ZwDeviceIoControlFile( - hMountMgr, NULL, NULL, NULL, &iosb, - IOCTL_MOUNTMGR_QUERY_POINTS, - point, lp, points, lps - ); - - if (status == STATUS_BUFFER_OVERFLOW) { - lps = (ULONG)iosb.Information + 2; - free(points); - points = NULL; - goto Again; - } - - for (i = 0; i < points->NumberOfMountPoints; i++) { - - volPoint.Length = volPoint.MaximumLength = - points->MountPoints[i].SymbolicLinkNameLength; - volPoint.Buffer = (PWSTR) ((PCHAR) points + - points->MountPoints[i].SymbolicLinkNameOffset); - -#if 0 - if (MOUNTMGR_IS_VOLUME_NAME(&volPoint)) { - if (length) { - if (*length >= volPoint.Length + 2) { - *length = volPoint.Length + 2; - memcpy(vp, volPoint.Buffer, volPoint.Length); - vp[1] = (WCHAR)'\\'; - vp[volPoint.Length / 2] = (WCHAR)'\\'; - vp[*length / 2] = 0; - } else { - *length = 0; - } - } - } -#endif - - if (MOUNTMGR_IS_DRIVE_LETTER(&volPoint)) { - drvLetter = (UCHAR)(volPoint.Buffer[12]); - break; - } - } - -errorout: - - if (points) { - free(points); - } - - if (point) { - free(point); - } - - if (hMountMgr) { - Ext2Close(&hMountMgr); - } - - return drvLetter; -} - -PEXT2_LETTER -Ext2GetDrvLetterPoint(CHAR drvChar) -{ - PEXT2_LETTER drvLetter = NULL; - - if (drvChar >= '0' && drvChar <= '9') { - drvLetter = &drvDigits[drvChar - '0']; - } else if (drvChar >= 'A' && drvChar <= 'Z') { - drvLetter = &drvLetters[drvChar - 'A']; - } else { - drvLetter = NULL; - } - - return drvLetter; -} - -BOOL -Ext2InsertMountPoint( - CHAR * volume, - UCHAR drvChar, - BOOL bGlobal - ) -{ - CHAR volumeName[MAX_PATH]; - - CHAR dosPath[] = "A:\0"; - CHAR drvPath[] = "A:\\\0"; - BOOL rc = FALSE; - - dosPath[0] = drvPath[0] = drvChar & 0x7F; - rc = Ext2DefineDosDevice(DDD_RAW_TARGET_PATH, - dosPath, volume); - - if (rc && bGlobal) { - rc = GetVolumeNameForVolumeMountPoint ( - drvPath, volumeName, MAX_PATH); - - Ext2DefineDosDevice ( - DDD_RAW_TARGET_PATH| - DDD_REMOVE_DEFINITION, - dosPath, volume); - if (rc) { - rc = SetVolumeMountPoint(drvPath, volumeName); - } - } - - return rc; -} - -VOID -Ext2RemoveMountPoint( - PEXT2_LETTER drvLetter, - BOOL bPermanent - ) -{ - CHAR drvPath[] = "A:\\\0"; - CHAR dosPath[] = "A:\0"; - - dosPath[0] = drvPath[0] = drvLetter->Letter; - - Ext2DefineDosDevice ( - DDD_RAW_TARGET_PATH| - DDD_REMOVE_DEFINITION| - DDD_EXACT_MATCH_ON_REMOVE, - dosPath, drvLetter->SymLink); - if (bPermanent) { - DeleteVolumeMountPoint(drvPath); - } - - Ext2CleanDrvLetter(drvLetter); - Ext2QueryDrvLetter(drvLetter); -} - -BOOL -Ext2RefreshVolumePoint( - CHAR * volume, - UCHAR drvChar - ) -{ - PEXT2_LETTER drvLetter = NULL; - BOOL rc = TRUE; - CHAR cLetter = 0; - - cLetter = Ext2QueryMountPoint(volume); - if (cLetter) { - goto errorout; - } else { - rc = FALSE; - } - - if (drvChar & 0x7F) { - if (Ext2InsertMountPoint(volume, drvChar & 0x7F, TRUE)) { - return TRUE; - } - } - - if (!rc) { - Ext2VolumeArrivalNotify(volume); - } - - cLetter = Ext2QueryMountPoint(volume); - if (!cLetter && (cLetter != (drvChar & 0x7F))) { - Ext2InsertMountPoint(volume, drvChar & 0x7F, TRUE); - } - - cLetter = Ext2QueryMountPoint(volume); - if (cLetter) { - Ext2InsertMountPoint(volume, cLetter, FALSE); - } - - rc = (cLetter > 0) ? TRUE: FALSE; - -errorout: - - return rc; -} - - -BOOL Ext2IsDrvLetterAvailable(CHAR drive) -{ - CHAR symLink[MAX_PATH] = {0}; - UINT drvType; - - drvType = Ext2QueryDrive(drive, symLink); - if (drvType == DRIVE_NO_ROOT_DIR) { - return TRUE; - } - - return FALSE; -} - - -CHAR Ext2GetFirstAvailableDrvLetter() -{ - int i; - - for (i = 2; i < 24; i++) { - if (Ext2IsDrvLetterAvailable('A' + i)) - return ('A' + i); - } - - return 0; -} - - -BOOL -Ext2NotifyVolumePoint( - PEXT2_VOLUME volume, - UCHAR drvChar - ) -{ - PEXT2_LETTER letter; - UCHAR mounted = 0; - BOOL rc = FALSE; - PCHAR Name = NULL; - - drvChar = (UCHAR)toupper(drvChar); - letter = &drvLetters[drvChar - 'A']; - - if (volume->Part) { - Name = &volume->Part->Name[0]; - } else { - Name = &volume->Name[0]; - } - - /* do drive update */ - if (Ext2IsDrvLetterAvailable(drvChar)) - Ext2UpdateDrvLetter(letter, Name); - - rc = Ext2VolumeArrivalNotify(Name); - - Sleep(500); - - mounted = Ext2QueryMountPoint(Name); - if (mounted) { - rc = TRUE; - goto errorout; - } - - if (!Ext2IsDrvLetterAvailable(drvChar)) { - drvChar = Ext2GetFirstAvailableDrvLetter(); - if ((drvChar|0x20) >= 'a' && (drvChar | 0x20) <= 'z') { - letter = &drvLetters[drvChar - 'A']; - } else { - letter = NULL; - } - } - - if (letter) { - rc = Ext2AssignDrvLetter(letter, Name, FALSE); - } - -errorout: - - return rc; -} - -#define EXT2_MANAGER_NAME "Ext2 Volume Manager" - -BOOL Ext2RunMgrForCurrentUserXP() -{ - HKEY key ; - CHAR keyPath[MAX_PATH] ; - LONG status ; - DWORD type, len = MAX_PATH; - BOOL rc = FALSE; - - CHAR appPath[MAX_PATH] ; - - GetModuleFileName(NULL, appPath, MAX_PATH - 6); - strcat(appPath, " -quiet"); - - strcpy (keyPath, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run") ; - status = RegOpenKeyEx (HKEY_LOCAL_MACHINE, - keyPath, - 0, - KEY_ALL_ACCESS, - &key) ; - - if (status != ERROR_SUCCESS) { - return FALSE; - } - - status = RegQueryValueEx( key, EXT2_MANAGER_NAME, 0, &type, - (BYTE *)appPath, &len); - if (status != ERROR_SUCCESS) { - goto errorout; - } - - rc = TRUE; - -errorout: - - RegCloseKey (key) ; - return rc; -} - -BOOL -Ext2SetAppAutorunXP(BOOL bInstall) -{ - BOOL rc = FALSE; - HKEY key ; - CHAR keyPath[MAX_PATH] ; - LONG status ; - - CHAR appPath[MAX_PATH] ; - - GetModuleFileName(NULL, appPath, MAX_PATH - 6); - strcat(appPath, " -quiet"); - - strcpy (keyPath, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run") ; - status = RegOpenKeyEx (HKEY_LOCAL_MACHINE, - keyPath, - 0, - KEY_ALL_ACCESS, - &key) ; - - if (status != ERROR_SUCCESS) { - return FALSE; - } - - if (!bInstall) { - status = RegDeleteValue (key, EXT2_MANAGER_NAME) ; - if (status != ERROR_SUCCESS) { - goto errorout; - } - } else { - status = RegSetValueEx( key, EXT2_MANAGER_NAME, 0, REG_SZ, - (BYTE *)appPath, (int)strlen(appPath)); - if (status != ERROR_SUCCESS) { - goto errorout; - } - } - - rc = TRUE; - -errorout: - - RegCloseKey (key) ; - return rc; -} - -CHAR *Ext2QueryAutoUserList() -{ - int rc = TRUE; - HKEY hKey; - CHAR keyPath[MAX_PATH]; - CHAR *userList = NULL; - LONG status, type, len; - - /* Open ext2fsd sevice key */ - strcpy (keyPath, "SYSTEM\\CurrentControlSet\\Services\\Ext2Fsd\\Parameters") ; - status = ::RegOpenKeyEx (HKEY_LOCAL_MACHINE, - keyPath, - 0, - KEY_ALL_ACCESS | KEY_WOW64_64KEY, - &hKey) ; - if (status != ERROR_SUCCESS) { - rc = FALSE; - goto errorout; - } - - /* query autorun user list */ - len = PAGE_SIZE - 1; - userList = new CHAR[len + 1]; - if (!userList) - goto errorout; - memset(userList, 0, len + 1); - status = RegQueryValueEx( hKey, - "AutorunUsers", - 0, - (LPDWORD)&type, - (BYTE *)userList, - (LPDWORD)&len); - -errorout: - - RegCloseKey(hKey); - - return userList; -} - -BOOL Ext2SetAutoRunUserList(CHAR *userList) -{ - HKEY key; - CHAR keyPath[MAX_PATH] ; - LONG status; - - strcpy (keyPath, "SYSTEM\\CurrentControlSet\\Services\\Ext2Fsd\\Parameters") ; - status = ::RegOpenKeyEx (HKEY_LOCAL_MACHINE, - keyPath, - 0, - KEY_ALL_ACCESS | KEY_WOW64_64KEY, - &key) ; - if (status != ERROR_SUCCESS) { - goto errorout; - } - - status = RegSetValueEx( key, "AutorunUsers", 0, REG_SZ, - (BYTE *)userList, (int)strlen(userList)); - if (status != ERROR_SUCCESS) { - goto errorout; - } - -errorout: - - RegCloseKey(key) ; - - return (status == ERROR_SUCCESS); -} - -TCHAR * -Ext2StrStr(TCHAR *s, TCHAR *t) -{ - int ls = (int)_tcslen(s), lt = (int)_tcslen(t), i; - for (i = 0; i + lt <= ls; i++) { - if (0 == _tcsnicmp(&s[i], t, lt)) - return &s[i]; - } - - return NULL; -} - - -BOOL Ext2RunMgrForCurrentUserVista() -{ - CHAR *userList = NULL, *user, e; - CHAR userName[256] = {0}; - DWORD userLen = 255; - BOOL rc = FALSE; - - if (!GetUserName(userName, &userLen)) - return FALSE; - - userList = Ext2QueryAutoUserList(); - if (!userList) - return FALSE; - - user = userList; - while (user = Ext2StrStr(user, userName)) { - if (user > userList) { - e = user[-1]; - if (e != ',' && e != ';') { - user = user + strlen(userName); - continue; - } - } - e = user[strlen(userName)]; - if (!e || e == ',' || e == ';') { - rc = TRUE; - goto errorout; - } - user = user + strlen(userName); - } - -errorout: - - if (userList) - delete [] userList; - - return rc; -} - -BOOL -Ext2SetAppAutorunVista(BOOL bAutorun) -{ - CHAR *userList = NULL, *user, *e; - CHAR userName[256] = {0}; - DWORD userLen = 255; - BOOL changed = FALSE; - - if (!GetUserName(userName, &userLen)) - return FALSE; - - userList = Ext2QueryAutoUserList(); - if (!userList) - return FALSE; - - if (bAutorun) { - - user = userList; - while (user = Ext2StrStr(user, userName)) { - if (user > userList) { - e = user-1; - if (*e != ',' && *e != ';') { - user = user + strlen(userName); - continue; - } - } - e = &user[strlen(userName)]; - if (!*e || *e == ',' || *e == ';') { - goto errorout; - } - user = user + strlen(userName); - } - - e = &userList[strlen(userList) - 1]; - if (e > userList && *e != ',' && *e != ';') { - strcat_s(userList, PAGE_SIZE - 1, ";"); - } - strcat_s(userList, PAGE_SIZE - 1, userName); - strcat_s(userList, PAGE_SIZE - 1, ";"); - changed = TRUE; - - } else { - user = userList; - while (user = Ext2StrStr(user, userName)) { - if (user > userList) { - e = user - 1; - if (*e != ',' && *e != ';') { - user = user + strlen(userName); - continue; - } - } - e = &user[strlen(userName)]; - if (!*e) { - memset(user, 0, strlen(userName) + 1); - changed = TRUE; - } else if (*e == ',' || *e == ';') { - memmove(user, e + 1, strlen(e)); - changed = TRUE; - } else { - user = user + strlen(userName); - } - } - } - - if (changed) - changed = Ext2SetAutoRunUserList(userList); - else - changed = TRUE; - -errorout: - - if (userList) - delete []userList; - - return TRUE; -} - -BOOL -Ext2SetAppAutorun(BOOL bAutorun) -{ - if (IsWindowsVistaOrGreater()) - return Ext2SetAppAutorunVista(bAutorun); - - return Ext2SetAppAutorunXP(bAutorun); -} - - -BOOL Ext2RunMgrForCurrentUser() -{ - if (IsWindowsVistaOrGreater()) - return Ext2RunMgrForCurrentUserVista(); - - return Ext2RunMgrForCurrentUserXP(); -} - - -#define SERVICE_CMD_LENGTH (MAX_PATH * 2) - -int -Ext2SetManagerAsService(BOOL bInstall) -{ - SC_HANDLE hService; - SC_HANDLE hManager; - - CHAR Target[SERVICE_CMD_LENGTH]; - - // get the filename of this executable - if (GetModuleFileName(NULL, Target, SERVICE_CMD_LENGTH - 20) == 0) { - AfxMessageBox("Unable to install Ext2Mgr as service", - MB_ICONEXCLAMATION | MB_OK); - return FALSE; - } - - // append parameters to the end of the path: - strcat(Target, " -service -hide"); - - // open Service Control Manager - hManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); - if (hManager == NULL) { - AfxMessageBox("Ext2Mgr: cannot open Service Control Manager", - MB_ICONEXCLAMATION | MB_OK); - return FALSE; - } - - if (bInstall) { - - // now create service entry for Ext2Mgr - hService = CreateService( - hManager, // SCManager database - "Ext2Mgr", // name of service - "Ext2 Volume Manger", // name to display - SERVICE_ALL_ACCESS, // desired access - SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS, - // service type - SERVICE_AUTO_START, // start type - SERVICE_ERROR_NORMAL, // error control type - Target, // service's binary - NULL, // no load ordering group - NULL, // no tag identifier - NULL, // dependencies - NULL, // LocalSystem account - NULL); // no password - - if (hService == NULL) { - DWORD error = GetLastError(); - if (error == ERROR_SERVICE_EXISTS) { - AfxMessageBox("Ext2Mgr service is already registered.", - MB_ICONEXCLAMATION | MB_OK); - } else { - AfxMessageBox("Ext2Mgr service couldn't be registered.", - MB_ICONEXCLAMATION | MB_OK); - } - } else { - - CloseServiceHandle(hService); - - // got Ext2Mgr installed as a service - AfxMessageBox( - "Ext2Mgr service was successfully registered. \n\n" - "You can modify the default settings and start/stop it from Control Panel.\n" - "The service will automatically run the next time when system is restarted.\n", - MB_ICONINFORMATION | MB_OK); - } - - Ext2SetAppAutorun(FALSE); - - } else { - - /* open the service of Ext2Mgr */ - hService = OpenService( - hManager, - "Ext2Mgr", - SERVICE_ALL_ACCESS - ); - - if (hService != NULL) { - -#if 0 - SERVICE_STATUS status; - - // stop the service - if (ControlService(hService, SERVICE_CONTROL_STOP, &status)) { - - while(QueryServiceStatus(hService, &status)) { - if (status.dwCurrentState == SERVICE_STOP_PENDING) { - Sleep(1000); - } else { - break; - } - } - - if (status.dwCurrentState != SERVICE_STOPPED) { - AfxMessageBox("Could not stop Ext2Mgr service !", - MB_ICONEXCLAMATION | MB_OK); - } - } -#endif - // remove the service from the SCM - if (DeleteService(hService)) { - AfxMessageBox("The Ext2Mgr service has been unregistered.", - MB_ICONINFORMATION | MB_OK); - } else { - DWORD error = GetLastError(); - if (error == ERROR_SERVICE_MARKED_FOR_DELETE) { - AfxMessageBox("Ext2Mgr service is already unregistered", - MB_ICONEXCLAMATION | MB_OK); - } else { - AfxMessageBox("Ext2Mgr service could not be unregistered", - MB_ICONEXCLAMATION | MB_OK); - } - } - - CloseServiceHandle(hService); - } - } - - CloseServiceHandle(hManager); - - return TRUE; -} - -BOOL g_bAutoRemoveDeadLetters = TRUE; - -VOID -Ext2AddLetterMask(ULONGLONG LetterMask) -{ - Ext2DrvLetters[1] |= LetterMask; -} - -VOID -Ext2AutoRemoveDeadLetters() -{ - ULONGLONG LetterMask = Ext2DrvLetters[0]; - DWORD i, j; - PEXT2_DISK disk; - PEXT2_PARTITION part; - PEXT2_CDROM cdrom; - - if (LetterMask != -1) { - AfxMessageBox("Different Mask"); - } - - for (i = 0; i < g_nDisks; i++) { - disk = &gDisks[i]; - if (disk->DataParts == NULL) { - continue; - } - for (j=0; j < disk->NumParts; j++) { - part = &disk->DataParts[j]; - if (part) { - LetterMask &= ~(part->DrvLetters); - } - } - } - - for (i = 0; i < g_nCdroms; i++) { - cdrom = &gCdroms[i]; - LetterMask &= ~(cdrom->DrvLetters); - } - - for (i=0; i < 10; i++) { - if (drvDigits[i].bUsed && (drvDigits[i].Extent == NULL) && - (LetterMask & (((ULONGLONG) 1) << (i + 32)) ) ) { - if (drvDigits[i].bInvalid && drvDigits[i].DrvType == DRIVE_FIXED) { - LetterMask &= (~(((ULONGLONG) 1) << (i + 32))); - Ext2RemoveMountPoint(&drvDigits[i], FALSE); - Ext2RemoveDosSymLink(drvDigits[i].Letter); - } - } - } - - for (i=2; i <26; i++) { - if (drvLetters[i].bUsed && (drvLetters[i].Extent == NULL) && - (LetterMask & (((ULONGLONG) 1) << i)) ) { - if (drvLetters[i].bInvalid && drvLetters[i].DrvType == DRIVE_FIXED) { - LetterMask &= (~(((ULONGLONG) 1) << i)); - Ext2RemoveMountPoint(&drvLetters[i], FALSE); - Ext2RemoveDosSymLink(drvLetters[i].Letter); - } - } - } - - // Ext2DrvLetters[0] = LetterMask; -} - -BOOL -Ext2RemoveDosSymLink(CHAR drvChar) -{ - EXT2_MOUNT_POINT E2MP; - NT::NTSTATUS status; - HANDLE handle = NULL; - NT::IO_STATUS_BLOCK iosb; - - Ext2SymLinkRemoval(drvChar); - - memset(&E2MP, 0, sizeof(EXT2_MOUNT_POINT)); - E2MP.Magic = EXT2_APP_MOUNTPOINT_MAGIC; - E2MP.Command = APP_CMD_DEL_DOS_SYMLINK; - E2MP.Link[0] = (USHORT) drvChar; - - status = Ext2Open("\\DosDevices\\Ext2Fsd", - &handle, EXT2_DESIRED_ACCESS); - if (!NT_SUCCESS(status)) { - goto errorout; - } - - status = NT::ZwDeviceIoControlFile( - handle, NULL, NULL, NULL, &iosb, - IOCTL_APP_MOUNT_POINT, - &E2MP, sizeof(EXT2_MOUNT_POINT), - &E2MP, sizeof(EXT2_MOUNT_POINT) - ); - -errorout: - - Ext2Close(&handle); - - return NT_SUCCESS(status); -} + +#include "stdafx.h" +#include "mountmgr.h" + +/* global management information */ + +BOOL g_bAutoMount = 0; + +ULONG g_nFlps = 0; +ULONG g_nDisks = 0; +ULONG g_nCdroms = 0; +ULONG g_nVols = 0; + +EXT2_LETTER drvLetters[26]; +EXT2_LETTER drvDigits[10]; + +ULONGLONG Ext2DrvLetters[2] = {(ULONGLONG)-1, (ULONGLONG)-1}; + +PEXT2_DISK gDisks = NULL; +PEXT2_CDROM gCdroms = NULL; +PEXT2_VOLUME gVols = NULL; + +/* information string array */ + +typedef struct { + int PartitionType; + char *type; +} PARTITION_LIST; + +typedef struct { + UINT DriveType; + char *type; +} DRIVE_LIST; + +typedef struct { + DEVICE_TYPE DeviceType; + char *type; +} DEVICE_LIST; + +typedef struct { + STORAGE_BUS_TYPE BusType; + char *type; +} BUSTYPE_LIST; + +CHAR * +IrpMjStrings[] = { + "IRP_MJ_CREATE", + "IRP_MJ_CREATE_NAMED_PIPE", + "IRP_MJ_CLOSE", + "IRP_MJ_READ", + "IRP_MJ_WRITE", + "IRP_MJ_QUERY_INFORMATION", + "IRP_MJ_SET_INFORMATION", + "IRP_MJ_QUERY_EA", + "IRP_MJ_SET_EA", + "IRP_MJ_FLUSH_BUFFERS", + "IRP_MJ_QUERY_VOLUME_INFORMATION", + "IRP_MJ_SET_VOLUME_INFORMATION", + "IRP_MJ_DIRECTORY_CONTROL", + "IRP_MJ_FILE_SYSTEM_CONTROL", + "IRP_MJ_DEVICE_CONTROL", + "IRP_MJ_INTERNAL_DEVICE_CONTROL", + "IRP_MJ_SHUTDOWN", + "IRP_MJ_LOCK_CONTROL", + "IRP_MJ_CLEANUP", + "IRP_MJ_CREATE_MAILSLOT", + "IRP_MJ_QUERY_SECURITY", + "IRP_MJ_SET_SECURITY", + "IRP_MJ_POWER", + "IRP_MJ_SYSTEM_CONTROL", + "IRP_MJ_DEVICE_CHANGE", + "IRP_MJ_QUERY_QUOTA", + "IRP_MJ_SET_QUOTA", + "IRP_MJ_PNP" +}; + +CHAR * +PerfStatStrings[] = { + "IRP_CONTEXT", + "VCB", + "FCB", + "CCB", + "MCB", + "EXTENT", + "RW_CONTEXT", + "VPB", + "FCB_NAME", + "MCB_NAME", + "FILE_NAME", + "DIR_ENTRY", + "DIR_PATTERN", + "DISK_EVENT", + "DISK_BUFFER", + "BLOCK_DATA", + "inode", + "dentry", + "buffer head", + NULL + }; + +PARTITION_LIST PartitionList[] = { + {PARTITION_ENTRY_UNUSED , "Empty"}, + {PARTITION_FAT_12 , "FAT12"}, /* 01 */ + {PARTITION_XENIX_1 , "Xenix-1"}, /* 02 */ + {PARTITION_XENIX_2 , "Xenix-2"}, + {PARTITION_FAT_16 , "FAT16"}, /* 04 */ + {PARTITION_EXTENDED , "Extended"}, + {PARTITION_HUGE , "FAT16 HUGE"}, /* 06*/ + {PARTITION_IFS , "HPFS/NTFS"}, /* 07 */ + + {PARTITION_OS2BOOTMGR, "OS/2"}, /* 0A */ + {PARTITION_FAT32 , "FAT32"}, /* 0B */ + {PARTITION_FAT32_XINT13 , "FAT32X"}, /* 0C*/ + {PARTITION_XINT13 , "XINT13"}, /* 0E */ + {PARTITION_XINT13_EXTENDED ,"EXINT13"}, /* 0F */ + {0x11 , "Hidden FAT12"}, + {0x14 , "Hidden FAT16"}, + {0x16 , "Hidden FAT16"}, + {0x17 , "Hidden HPFS/NTFS"}, + + {0x1B , "Hidden FAT32"}, + {0x1C , "Hidden FAT32X"}, + + {PARTITION_PREP , "OS/2"}, /* 41 */ + {PARTITION_LDM , "LDM"}, /* 42 */ + + {0x52 , "CP/M"}, + + {PARTITION_UNIX , "UNIX"}, /* 63 */ + + {PARTITION_NTFT , "NTFT"}, /* 80 */ + {0x81, "Minix"}, + {0x82, "Linux swap"}, + {0x83, "Linux"}, + + {0x85, "Linux extend"}, + + {0x8e, "Linux LVM"}, + + {0xa5, "FreeBSD"}, + {0xa6, "OpenBSD"}, + + {0xa8, "Darwin UFS"}, + {0xa9, "NetBSD"}, + + {0xbe, "Solaris Boot"}, + {0xbf, "Solaris"}, + + {VALID_NTFT , "VNTFT"}, /* C0 */ + {-1 ,"UNKNOWN"} +}; + +DRIVE_LIST DriveList[] = { + {DRIVE_UNKNOWN, "Unkown"}, + {DRIVE_NO_ROOT_DIR, "NoRoot"}, + {DRIVE_REMOVABLE, "Removable"}, + {DRIVE_FIXED, "Fixed"}, + {DRIVE_REMOTE, "Remote"}, + {DRIVE_CDROM, "CDROM"}, + {DRIVE_RAMDISK, "RAMdisk"}, + {(UINT)-1, "Invalid"} +}; + +BUSTYPE_LIST BusTypeList[] = { + {BusTypeUnknown, "Unkown"}, + {BusTypeScsi, "SCSI"}, + {BusTypeAtapi, "ATAPI"}, + {BusTypeAta, "ATA"}, + {BusType1394, "1394"}, + {BusTypeSsa, "Ssa"}, + {BusTypeFibre, "Fibre"}, + {BusTypeUsb, "USB"}, + {BusTypeRAID, "RAID"}, + {(STORAGE_BUS_TYPE)-1, "Invalid"} +}; + + +DEVICE_LIST DeviceList[] = { + {FILE_DEVICE_8042_PORT ,"8042_PORT"}, + {FILE_DEVICE_ACPI ,"ACPI"}, + {FILE_DEVICE_BATTERY ,"BATTERY"}, + {FILE_DEVICE_BEEP ,"BEEP"}, + {FILE_DEVICE_BUS_EXTENDER ,"BUS_EXTENDER"}, + {FILE_DEVICE_CD_ROM ,"CD_ROM"}, + {FILE_DEVICE_CD_ROM_FILE_SYSTEM ,"CD_ROM_FILE_SYSTEM"}, + {FILE_DEVICE_CHANGER ,"CHANGER"}, + {FILE_DEVICE_CONTROLLER ,"CONTROLLER"}, + {FILE_DEVICE_DATALINK ,"DATALINK"}, + {FILE_DEVICE_DFS ,"DFS"}, + {FILE_DEVICE_DFS_FILE_SYSTEM ,"DFS_FILE_SYSTEM"}, + {FILE_DEVICE_DFS_VOLUME ,"DFS_VOLUME"}, + {FILE_DEVICE_DISK ,"DISK"}, + {FILE_DEVICE_DISK_FILE_SYSTEM ,"DISK_FILE_SYSTEM"}, + {FILE_DEVICE_DVD ,"DVD"}, + {FILE_DEVICE_FILE_SYSTEM ,"FILE_SYSTEM"}, + {0x0000003a /*FILE_DEVICE_FIPS*/ ,"FIPS"}, + {FILE_DEVICE_FULLSCREEN_VIDEO ,"FULLSCREEN_VIDEO"}, + {FILE_DEVICE_INPORT_PORT ,"INPORT_PORT"}, + {FILE_DEVICE_KEYBOARD ,"KEYBOARD"}, + {FILE_DEVICE_KS ,"KS"}, + {FILE_DEVICE_KSEC ,"KSEC"}, + {FILE_DEVICE_MAILSLOT ,"MAILSLOT"}, + {FILE_DEVICE_MASS_STORAGE ,"MASS_STORAGE"}, + {FILE_DEVICE_MIDI_IN ,"MIDI_IN"}, + {FILE_DEVICE_MIDI_OUT ,"MIDI_OUT"}, + {FILE_DEVICE_MODEM ,"MODEM"}, + {FILE_DEVICE_MOUSE ,"MOUSE"}, + {FILE_DEVICE_MULTI_UNC_PROVIDER ,"MULTI_UNC_PROVIDER"}, + {FILE_DEVICE_NAMED_PIPE ,"NAMED_PIPE"}, + {FILE_DEVICE_NETWORK ,"NETWORK"}, + {FILE_DEVICE_NETWORK_BROWSER ,"NETWORK_BROWSER"}, + {FILE_DEVICE_NETWORK_FILE_SYSTEM,"NETWORK_FILE_SYSTEM"}, + {FILE_DEVICE_NETWORK_REDIRECTOR ,"NETWORK_REDIRECTOR"}, + {FILE_DEVICE_NULL ,"NULL"}, + {FILE_DEVICE_PARALLEL_PORT ,"PARALLEL_PORT"}, + {FILE_DEVICE_PHYSICAL_NETCARD ,"PHYSICAL_NETCARD"}, + {FILE_DEVICE_PRINTER ,"PRINTER"}, + {FILE_DEVICE_SCANNER ,"SCANNER"}, + {FILE_DEVICE_SCREEN ,"SCREEN"}, + {FILE_DEVICE_SERENUM ,"SERENUM"}, + {FILE_DEVICE_SERIAL_MOUSE_PORT ,"SERIAL_MOUSE_PORT"}, + {FILE_DEVICE_SERIAL_PORT ,"SERIAL_PORT"}, + {FILE_DEVICE_SMARTCARD ,"SMARTCARD"}, + {FILE_DEVICE_SMB ,"SMB"}, + {FILE_DEVICE_SOUND ,"SOUND"}, + {FILE_DEVICE_STREAMS ,"STREAMS"}, + {FILE_DEVICE_TAPE ,"TAPE"}, + {FILE_DEVICE_TAPE_FILE_SYSTEM ,"TAPE_FILE_SYSTEM"}, + {FILE_DEVICE_TERMSRV ,"TERMSRV"}, + {FILE_DEVICE_TRANSPORT ,"TRANSPORT"}, + {FILE_DEVICE_UNKNOWN ,"UNKNOWN"}, + {FILE_DEVICE_VDM ,"VDM"}, + {FILE_DEVICE_VIDEO ,"VIDEO"}, + {FILE_DEVICE_VIRTUAL_DISK ,"VIRTUAL_DISK"}, + {FILE_DEVICE_WAVE_IN ,"WAVE_IN"}, + {FILE_DEVICE_WAVE_OUT ,"WAVE_OUT"}, + {(DEVICE_TYPE)-1 ,"UNKNOWN"} +}; + +char *PartitionString(int type) +{ + PARTITION_LIST *p = PartitionList; + + while ( p->PartitionType != -1 ) { + if ( type == p->PartitionType ) { + return p->type; + } + p++; + } + return p->type; +} + +char *DriveTypeString(UINT media) +{ + DRIVE_LIST *p = DriveList; + + while ( p->DriveType != (UINT)-1 ) { + if ( media == p->DriveType ) { + return p->type; + } + p++; + } + return p->type; +} + +char *DeviceTypeString(DEVICE_TYPE media) +{ + DEVICE_LIST *p = DeviceList; + + while ( p->DeviceType != (DEVICE_TYPE)-1 ) { + if ( media == p->DeviceType ) { + return p->type; + } + p++; + } + return p->type; +} + +char *BusTypeString(STORAGE_BUS_TYPE BusType) +{ + BUSTYPE_LIST *p = BusTypeList; + + while ( p->BusType != (STORAGE_BUS_TYPE)-1 ) { + if ( BusType == p->BusType ) { + return p->type; + } + p++; + } + + return p->type; +} + +/* Ext2Fsd supported codepages */ + +CHAR * gCodepages[] = + { + "default", + "cp936", + "gb2312", + "utf8", + "cp1251", + "cp1255", + "cp437", + "cp737", + "cp775", + "cp850", + "cp852", + "cp855", + "cp857", + "cp860", + "cp861", + "cp862", + "cp863", + "cp864", + "cp865", + "cp866", + "cp869", + "cp874", + "tis-620", + "cp932", + "euc-jp", + "sjis", + "cp949", + "euc-kr", + "cp950", + "big5", + "iso8859-1", + "iso8859-13", + "iso8859-14", + "iso8859-15", + "iso8859-2", + "iso8859-3", + "iso8859-4", + "iso8859-5", + "iso8859-6", + "iso8859-7", + "iso8859-8", + "iso8859-9", + "koi8-r", + "koi8-u", + "koi8-ru", + "cp1250", + "acsii", + NULL + }; + +/* routines */ + +BOOL g_isWow64 = FALSE; +BOOL g_isX64 = FALSE; + +#define PROCESSOR_ARCHITECTURE_AMD64 9 + +typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); +LPFN_ISWOW64PROCESS fnIsWow64Process = NULL; + +typedef void (WINAPI *LPFN_GETNATIVESYSINFO)( + LPSYSTEM_INFO lpSystemInfo); + +LPFN_GETNATIVESYSINFO fnGetNativeSystemInfo = NULL; +BOOL Ext2IsWow64() +{ + if (NULL != fnIsWow64Process) { + if (!fnIsWow64Process(GetCurrentProcess(), &g_isWow64)) { + } + } + return g_isWow64; +} + + +BOOL Ext2IsX64System() +{ + SYSTEM_INFO sysInfo; + fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress( + GetModuleHandle("kernel32"), "IsWow64Process"); + + fnGetNativeSystemInfo = (LPFN_GETNATIVESYSINFO)GetProcAddress( + GetModuleHandle("kernel32"), "GetNativeSystemInfo"); + + if (fnGetNativeSystemInfo) { + fnGetNativeSystemInfo(&sysInfo); + + if (sysInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 && + Ext2IsWow64()) { + g_isWow64 = TRUE; + return TRUE; + } + } + + return FALSE; +} + +BOOL IsVistaOrAbove() +{ + OSVERSIONINFO OsVerInfo; + + OsVerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + + if (GetVersionEx(&OsVerInfo)) { + + if (OsVerInfo.dwMajorVersion == 6 && OsVerInfo.dwBuildNumber > 3790) + return TRUE; + + if (OsVerInfo.dwMajorVersion > 6) + return TRUE; + } + + return FALSE; +} + +BOOL CanDoLocalMount() +{ + return !IsWindowsVistaOrGreater(); +} + +BOOL +IsWindows2000() +{ + OSVERSIONINFO OsVer; + memset(&OsVer, 0, sizeof(OsVer)); + OsVer.dwOSVersionInfoSize = sizeof(OsVer); + + if (GetVersionEx(&OsVer)) { + if (OsVer.dwPlatformId == VER_PLATFORM_WIN32_NT && + OsVer.dwMajorVersion <= 5 && + OsVer.dwMinorVersion == 0) { + return TRUE; + } + } else { + return TRUE; + } + + return FALSE; +} + +BOOL Ext2DismountVolume(CHAR *voldev) +{ + + HANDLE device; + ULONG bytes; + BOOL rc = FALSE; + + device = CreateFile(voldev, GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + + if (device == INVALID_HANDLE_VALUE) { + goto errorout; + } + + if (!DeviceIoControl(device, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0, + &bytes, NULL)) { + } + + rc = DeviceIoControl(device, FSCTL_DISMOUNT_VOLUME, NULL, 0, NULL, 0, + &bytes, NULL); + CloseHandle(device); + +errorout: + + return rc; +} + +/* + * Ext2LockVolume + * Lock the volume ... + * + * ARGUMENTS: + * VolumeHandle: Volume handle. + * + * RETURNS: + * Success or Fail + * + * NOTES: + * N/A + */ + + +NT::NTSTATUS +Ext2LockVolume(HANDLE Handle) +{ + NT::NTSTATUS status; + NT::IO_STATUS_BLOCK ioSb; + + status = NT::ZwFsControlFile( + Handle, NULL, NULL, NULL, &ioSb, + FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0); + return status; +} + + +NT::NTSTATUS +Ext2UnLockVolume(HANDLE Handle) +{ + NT::NTSTATUS status; + NT::IO_STATUS_BLOCK ioSb; + + status = NT::ZwFsControlFile( + Handle, NULL, NULL, NULL, &ioSb, + FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0); + return status; +} + + +NT::NTSTATUS +Ext2DisMountVolume(HANDLE Handle) +{ + NT::NTSTATUS status; + NT::IO_STATUS_BLOCK ioSb; + + status = NT::ZwFsControlFile( + Handle, NULL, NULL, NULL, &ioSb, + FSCTL_DISMOUNT_VOLUME, NULL, 0, NULL, 0); + + return status; +} + +PDRIVE_LAYOUT_INFORMATION_EXT +Ext2QueryDriveLayout( + HANDLE Handle, + PUCHAR NumOfParts + ) +{ + NT::IO_STATUS_BLOCK ioSb; + NT::NTSTATUS status; + + PDRIVE_LAYOUT_INFORMATION_EXT driveLayout = NULL; + ULONG dataSize = 512; + ULONG retSize = 0; + +QueryDrive: + + status = STATUS_SUCCESS; + driveLayout = (PDRIVE_LAYOUT_INFORMATION_EXT) malloc(dataSize); + if(!driveLayout) { + goto errorout; + } + memset(driveLayout, 0, dataSize); + + if (IsWindows2000()) { + + PDRIVE_LAYOUT_INFORMATION oldLayout = + (PDRIVE_LAYOUT_INFORMATION ) malloc(dataSize); + if (!oldLayout) { + goto errorout; + } + + status = NT::ZwDeviceIoControlFile( + Handle, NULL, NULL, NULL, &ioSb, + IOCTL_DISK_GET_DRIVE_LAYOUT, + NULL, 0, (PVOID)oldLayout, dataSize + ); + + if (NT_SUCCESS(status)) { + + ULONG newLayoutSize = FIELD_OFFSET(DRIVE_LAYOUT_INFORMATION_EX, PartitionEntry); + newLayoutSize += sizeof(PARTITION_INFORMATION_EX) * oldLayout->PartitionCount; + + if (dataSize >= newLayoutSize) { + + driveLayout->PartitionStyle = PARTITION_STYLE_MBR; + driveLayout->PartitionCount = oldLayout->PartitionCount; + driveLayout->Mbr.Signature = oldLayout->Signature; + + for (DWORD i=0; i < oldLayout->PartitionCount; i++) { + driveLayout->PartitionEntry[i].PartitionStyle = PARTITION_STYLE_MBR; + + driveLayout->PartitionEntry[i].StartingOffset = + oldLayout->PartitionEntry[i].StartingOffset; + driveLayout->PartitionEntry[i].PartitionLength = + oldLayout->PartitionEntry[i].PartitionLength; + driveLayout->PartitionEntry[i].PartitionNumber = + oldLayout->PartitionEntry[i].PartitionNumber; + driveLayout->PartitionEntry[i].RewritePartition = + oldLayout->PartitionEntry[i].RewritePartition; + driveLayout->PartitionEntry[i].Mbr.PartitionType = + oldLayout->PartitionEntry[i].PartitionType; + driveLayout->PartitionEntry[i].Mbr.BootIndicator = + oldLayout->PartitionEntry[i].BootIndicator; + driveLayout->PartitionEntry[i].Mbr.RecognizedPartition = + oldLayout->PartitionEntry[i].RecognizedPartition; + driveLayout->PartitionEntry[i].Mbr.HiddenSectors = + oldLayout->PartitionEntry[i].HiddenSectors; + } + + } else { + dataSize = newLayoutSize; + status = STATUS_BUFFER_TOO_SMALL; + } + } + + free(oldLayout); + + } else { + + status = NT::ZwDeviceIoControlFile( + Handle, NULL, NULL, NULL, &ioSb, + IOCTL_DISK_GET_DRIVE_LAYOUT_EXT, + NULL, 0, (PVOID)driveLayout, dataSize + ); + } + + if (status == STATUS_BUFFER_TOO_SMALL) { + free(driveLayout); driveLayout = NULL; + dataSize *= 2; + goto QueryDrive; + } + + if (!NT_SUCCESS(status)) { + free(driveLayout); driveLayout = NULL; + goto errorout; + } + + retSize = FIELD_OFFSET(DRIVE_LAYOUT_INFORMATION_EXT, PartitionEntry); + retSize += sizeof(PARTITION_INFORMATION) * driveLayout->PartitionCount; + + if (driveLayout->PartitionStyle == PARTITION_STYLE_MBR) { + + PPARTITION_INFORMATION_EXT Part; + UCHAR i = 0, cnt = 0; + + /* Now walk the Drive_Layout to count the partitions */ + while (i < (UCHAR)driveLayout->PartitionCount) { + Part = &driveLayout->PartitionEntry[i++]; + if (Part->Mbr.PartitionType != PARTITION_ENTRY_UNUSED && + Part->Mbr.PartitionType != PARTITION_EXTENDED && + Part->Mbr.PartitionType != PARTITION_XINT13_EXTENDED) { + cnt++; + } + } + *NumOfParts = cnt; + } else if (driveLayout->PartitionStyle == PARTITION_STYLE_GPT) { + *NumOfParts = (UCHAR)driveLayout->PartitionCount; + } else { + *NumOfParts = 0; + free(driveLayout); driveLayout = NULL; + } + + if (*NumOfParts == 0) { + free(driveLayout); driveLayout = NULL; + } + + +errorout: + + return driveLayout; +} + +NT::NTSTATUS +Ext2SetDriveLayout( + HANDLE Handle, + PDRIVE_LAYOUT_INFORMATION_EXT Layout + ) +{ + NT::IO_STATUS_BLOCK ioSb; + NT::NTSTATUS status = STATUS_SUCCESS; + ULONG dataSize; + + dataSize = FIELD_OFFSET(DRIVE_LAYOUT_INFORMATION_EXT, PartitionEntry); + dataSize += sizeof(PARTITION_INFORMATION_EXT) * Layout->PartitionCount; + + if (IsWindows2000()) { + + if (Layout->PartitionStyle != PARTITION_STYLE_MBR) { + return STATUS_UNSUCCESSFUL; + } + + ULONG newLayoutSize = FIELD_OFFSET(DRIVE_LAYOUT_INFORMATION, PartitionEntry); + newLayoutSize += sizeof(PARTITION_INFORMATION) * Layout->PartitionCount; + + PDRIVE_LAYOUT_INFORMATION oldLayout = + (PDRIVE_LAYOUT_INFORMATION ) malloc(newLayoutSize); + if (!oldLayout) { + goto errorout; + } + + oldLayout->PartitionCount = Layout->PartitionCount; + oldLayout->Signature = Layout->Mbr.Signature; + + for (DWORD i=0; i < oldLayout->PartitionCount; i++) { + + oldLayout->PartitionEntry[i].StartingOffset = + Layout->PartitionEntry[i].StartingOffset; + oldLayout->PartitionEntry[i].PartitionLength = + Layout->PartitionEntry[i].PartitionLength; + oldLayout->PartitionEntry[i].PartitionNumber = + Layout->PartitionEntry[i].PartitionNumber; + oldLayout->PartitionEntry[i].RewritePartition = + Layout->PartitionEntry[i].RewritePartition; + oldLayout->PartitionEntry[i].PartitionType = + Layout->PartitionEntry[i].Mbr.PartitionType; + oldLayout->PartitionEntry[i].BootIndicator = + Layout->PartitionEntry[i].Mbr.BootIndicator; + oldLayout->PartitionEntry[i].RecognizedPartition = + Layout->PartitionEntry[i].Mbr.RecognizedPartition; + oldLayout->PartitionEntry[i].HiddenSectors = + Layout->PartitionEntry[i].Mbr.HiddenSectors; + } + + status = NT::ZwDeviceIoControlFile( + Handle, NULL, NULL, NULL, &ioSb, + IOCTL_DISK_SET_DRIVE_LAYOUT, + (PVOID)oldLayout, newLayoutSize, + NULL, 0 + ); + + free(oldLayout); + + } else { + + status = NT::ZwDeviceIoControlFile( + Handle, NULL, NULL, NULL, &ioSb, + IOCTL_DISK_SET_DRIVE_LAYOUT_EXT, + (PVOID)Layout, dataSize,NULL, 0 + ); + } + + return status; + +errorout: + + return STATUS_UNSUCCESSFUL; +} + +BOOL +Ext2IsDeviceValid(CHAR *Device) +{ + HANDLE handle = NULL; + NT::NTSTATUS status; + + status = Ext2Open(Device, &handle, EXT2_DESIRED_ACCESS); + if (!NT_SUCCESS(status)) { + goto errorout; + } + +errorout: + + if (handle) { + Ext2Close(&handle); + } + + return NT_SUCCESS(status); +} + + +BOOL +Ext2SetPartitionType( + PEXT2_PARTITION Part, + BYTE Type + ) +{ + BOOL rc = FALSE; + HANDLE Handle = NULL; + NT::NTSTATUS status; + + UCHAR NumParts = 0; + PDRIVE_LAYOUT_INFORMATION_EXT Layout = NULL; + + DWORD i; + + status = Ext2Open(Part->Disk->Name, &Handle, + EXT2_DESIRED_ACCESS | GENERIC_WRITE); + if (!NT_SUCCESS(status)) { + goto errorout; + } + + Layout = Part->Disk->Layout; + + if (!Layout) { + goto errorout; + } + + if (Layout->PartitionStyle != PARTITION_STYLE_MBR) { + goto errorout; + } + + for (i=0; i < Layout->PartitionCount; i++) { + + if ((Layout->PartitionEntry[i].StartingOffset.QuadPart == + Part->Entry->StartingOffset.QuadPart) && + (Layout->PartitionEntry[i].PartitionLength.QuadPart == + Part->Entry->PartitionLength.QuadPart) && + (Layout->PartitionEntry[i].PartitionNumber == + Part->Entry->PartitionNumber) ) { + + Layout->PartitionEntry[i].Mbr.PartitionType = Type; + Layout->PartitionEntry[i].RewritePartition = TRUE; + + rc = TRUE; + break; + } + } + + if (!rc) { + goto errorout; + } + + status = Ext2SetDriveLayout(Handle, Layout); + rc = NT_SUCCESS(status); + +errorout: + + Ext2Close(&Handle); + + return rc; +} + + +BOOL +Ext2FlushVolume(CHAR *Device) +{ + HANDLE handle = NULL; + NT::NTSTATUS status; + NT::IO_STATUS_BLOCK iosb; + + status = Ext2Open(Device, &handle, EXT2_DESIRED_ACCESS | GENERIC_WRITE); + if (!NT_SUCCESS(status)) { + goto errorout; + } + + status = NT::ZwFlushBuffersFile(handle, &iosb); + +errorout: + + if (handle) { + Ext2Close(&handle); + } + + return NT_SUCCESS(status); +} + +PEXT2_PARTITION +Ext2QueryVolumePartition( + PEXT2_VOLUME Volume + ) +{ + PEXT2_PARTITION Part = NULL; + DWORD i, j; + + for (i=0; i < g_nDisks; i++) { + for (j=0; j < (int)gDisks[i].NumParts; j++) { + if (gDisks[i].DataParts[j].Volume == Volume) { + Part = &gDisks[i].DataParts[j]; + break; + } + } + } + + return Part; +} + +NT::NTSTATUS +Ext2QueryProperty( + HANDLE Handle, + STORAGE_PROPERTY_ID Id, + PVOID DescBuf, + ULONG DescSize + ) +{ + STORAGE_PROPERTY_QUERY SPQ; + NT::NTSTATUS status; + NT::IO_STATUS_BLOCK ioSb; + + SPQ.PropertyId = Id; + SPQ.QueryType = PropertyStandardQuery; + + memset(DescBuf, 0, DescSize); + + status = NT::ZwDeviceIoControlFile( + Handle, NULL, NULL, NULL, &ioSb, + IOCTL_STORAGE_QUERY_PROPERTY, + &SPQ, sizeof(STORAGE_PROPERTY_QUERY), + DescBuf, DescSize + ); + + return status; +} + +/* + * Ext2QueryDisk + * Get volume gemmetry information ... + * + * ARGUMENTS: + * VolumeHandle: Volume handle. + * + * RETURNS: + * Success or Fail + * + * NOTES: + * N/A + */ + +NT::NTSTATUS +Ext2QueryDisk( + HANDLE Handle, + PDISK_GEOMETRY DiskGeometry + ) +{ + NT::NTSTATUS status; + NT::IO_STATUS_BLOCK ioSb; + + status = NT::ZwDeviceIoControlFile( + Handle, NULL, NULL, NULL, &ioSb, + IOCTL_DISK_GET_DRIVE_GEOMETRY, + DiskGeometry, sizeof(DISK_GEOMETRY), + DiskGeometry, sizeof(DISK_GEOMETRY)); + + + if (!NT_SUCCESS(status)) { + goto errorout; + } + +errorout: + + return status; +} + +PVOLUME_DISK_EXTENTS +Ext2QueryVolumeExtents(HANDLE hVolume) +{ + ULONG dataSize = 1024; + PVOLUME_DISK_EXTENTS dskExtents = NULL; + + NT::NTSTATUS status; + NT::IO_STATUS_BLOCK ioSb; + +QueryExtent: + + dskExtents = (PVOLUME_DISK_EXTENTS)malloc(dataSize); + if (NULL == dskExtents) { + goto errorout; + } + + status = NT::ZwDeviceIoControlFile( + hVolume, NULL, NULL, NULL, &ioSb, + IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, + NULL, 0, dskExtents, dataSize ); + + if (status == STATUS_BUFFER_TOO_SMALL) { + free(dskExtents); dskExtents = NULL; + dataSize += 1024; + goto QueryExtent; + } + + if (!NT_SUCCESS(status)) { + free(dskExtents); dskExtents = NULL; + goto errorout; + } + +errorout: + + return dskExtents; +} + +PSTORAGE_DEVICE_NUMBER +Ext2QueryDeviceNumber(HANDLE hVolume) +{ + ULONG dataSize; + PSTORAGE_DEVICE_NUMBER SDN = NULL; + + NT::NTSTATUS status; + NT::IO_STATUS_BLOCK ioSb; + + dataSize = sizeof(STORAGE_DEVICE_NUMBER); + +QuerySDN: + + SDN = (PSTORAGE_DEVICE_NUMBER)malloc(dataSize); + if (NULL == SDN) { + goto errorout; + } + memset(SDN, 0, dataSize); + + status = NT::ZwDeviceIoControlFile( + hVolume, NULL, NULL, NULL, &ioSb, + IOCTL_STORAGE_GET_DEVICE_NUMBER, + NULL, 0, SDN, dataSize ); + + if (status == STATUS_BUFFER_TOO_SMALL) { + free(SDN); SDN = NULL; + dataSize += sizeof(STORAGE_DEVICE_NUMBER); + goto QuerySDN; + } + + if (!NT_SUCCESS(status)) { + free(SDN); SDN = NULL; + goto errorout; + } + +errorout: + + return SDN; +} + +BOOL +Ext2QueryDrvLetter( + PEXT2_LETTER drvLetter + ) +{ + HANDLE hVolume; + NT::NTSTATUS status = STATUS_SUCCESS; + DWORD rc = 0; + + drvLetter->DrvType = Ext2QueryDrive(drvLetter->Letter, + drvLetter->SymLink); + + if (drvLetter->DrvType == DRIVE_NO_ROOT_DIR) { + drvLetter->bUsed = FALSE; + goto errorout; + } else { + drvLetter->bUsed = TRUE; + } + + if (drvLetter->Letter == 'A' || + drvLetter->Letter == 'B' ) { + drvLetter->bUsed = TRUE; + goto errorout; + } + + if (drvLetter->DrvType == DRIVE_REMOVABLE || + drvLetter->DrvType == DRIVE_FIXED) { + + status = Ext2Open(drvLetter->SymLink, &hVolume, EXT2_DESIRED_ACCESS); + if (!NT_SUCCESS(status) && status != STATUS_ACCESS_DENIED) { + drvLetter->bInvalid = TRUE; + goto errorout; + } + + drvLetter->Extent = Ext2QueryVolumeExtents(hVolume); + if (drvLetter->DrvType == DRIVE_REMOVABLE) { + drvLetter->SDN = Ext2QueryDeviceNumber(hVolume); + } + + Ext2Close(&hVolume); + } + +errorout: + + return NT_SUCCESS(status); +} + + +PEXT2_LETTER Ext2GetFirstUnusedDrvLetter() +{ + PEXT2_LETTER drvLetter = NULL; + CHAR devPath[] = "C:"; + int i; + + for (i = 5; i < 24; i++) { + drvLetter = &drvLetters[i]; + if (drvLetter->DrvType == DRIVE_NO_ROOT_DIR) { + drvLetter->DrvType = Ext2QueryDrive(drvLetter->Letter, + drvLetter->SymLink); + if (drvLetter->DrvType == DRIVE_NO_ROOT_DIR) { + /* we got it */ + break; + } else { + /* we need do a new refresh */ + } + } + drvLetter = NULL; + } + + return drvLetter; +} + + +CHAR Ext2MountVolume(CHAR *voldev) +{ + PEXT2_LETTER drvLetter; + CHAR rc = 0; + + /* query drive letter to check whether it's mounted */ + drvLetter = Ext2GetFirstUnusedDrvLetter(); + if (!drvLetter) { + goto errorout; + } + + if (Ext2AssignDrvLetter(drvLetter, voldev, FALSE)) { + rc = drvLetter->Letter; + } + +errorout: + + return rc; +} + +CHAR Ext2MountVolumeAs(CHAR *voldev, CHAR DrvLetter) +{ + PEXT2_LETTER drvLetter; + CHAR rc = 0; + + + if (DrvLetter >= '0' && DrvLetter <= '9') { + drvLetter = &drvDigits[DrvLetter - '0']; + } else if (DrvLetter >= 'A' && DrvLetter <= 'Z') { + drvLetter = &drvLetters[DrvLetter - 'A']; + } else if (DrvLetter >= 'a' && DrvLetter <= 'z') { + drvLetter = &drvLetters[DrvLetter - 'a']; + } + + if (!drvLetter || drvLetter->bUsed) { + goto errorout; + } + + if (Ext2AssignDrvLetter(drvLetter, voldev, FALSE)) { + rc = drvLetter->Letter; + } + +errorout: + + return rc; +} + +NT::NTSTATUS +Ext2QueryMediaType( + HANDLE Handle, + PDWORD MediaType + ) +{ + NT::NTSTATUS status; + NT::IO_STATUS_BLOCK ioSb; + PGET_MEDIA_TYPES mediaTypes; + UCHAR buffer[1024]; + + status = NT::ZwDeviceIoControlFile( + Handle, NULL, NULL, NULL, &ioSb, + IOCTL_STORAGE_GET_MEDIA_TYPES_EX, + NULL, 0, buffer, 1024 ); + + + if (!NT_SUCCESS(status)) { + goto errorout; + } + + mediaTypes = (PGET_MEDIA_TYPES) buffer; + *MediaType = mediaTypes->DeviceType; + +errorout: + + return status; +} + +/* + * Ext2Read + * Read data from disk or file ... + * + * ARGUMENTS: + * VolumeHandle: Volume Handle + * Offset : Disk Offset + * Length : Data Length to be read + * Buffer : ... + * + * RETURNS: + * Success: STATUS_SUCCESS + * Fail: ... + * + * NOTES: + * Both Length and Offset should be SECTOR_SIZE aligned. + */ +NT::NTSTATUS +Ext2Read( + IN HANDLE Handle, + IN BOOL IsFile, + IN ULONG SectorSize, + IN ULONGLONG Offset, + IN ULONG Length, + IN PVOID Buffer + ) +{ + NT::NTSTATUS status; + NT::IO_STATUS_BLOCK ioSb; + LARGE_INTEGER address; + ULONG aLength = 0; + PVOID aBuffer = NULL; + + if (SectorSize == 0 || SectorSize == 1) + IsFile = TRUE; + + ASSERT(Buffer != NULL); + + if (IsFile) { + + address.QuadPart = Offset; + status = NT::ZwReadFile( + Handle, 0, NULL, NULL, &ioSb, + Buffer, Length, &address, NULL + ); + } else { + + address.QuadPart = Offset & (~((ULONGLONG)SectorSize - 1)); + aLength = (Length + SectorSize - 1)&(~(SectorSize - 1)); + aLength += ((ULONG)(Offset - address.QuadPart) + SectorSize - 1) + & (~(SectorSize - 1)); + + aBuffer = malloc(aLength); + if (!aBuffer) { + status = STATUS_INSUFFICIENT_RESOURCES; + goto errorout; + } + + status = NT::ZwReadFile( + Handle, 0, NULL, NULL, &ioSb, + aBuffer, aLength, &address, NULL + ); + + if (!NT_SUCCESS(status)) { + goto errorout; + } + + memmove( Buffer, (PUCHAR)aBuffer + + (ULONG)(Offset - address.QuadPart), Length); + } + +errorout: + + if (aBuffer) + free(aBuffer); + + return status; +} + +/* + * Ext2Write + * Write data to disk or file ... + * + * ARGUMENTS: + * VolumeHandle: Volume Handle + * Offset : Disk Offset + * Length : Data Length to be written + * Buffer : Data to be written ... + * + * RETURNS: + * Success: STATUS_SUCCESS + * Fail: ... + * + * NOTES: + * Both Length and Offset should be SECTOR_SIZE aligned. + */ + +NT::NTSTATUS +Ext2WriteDisk( + HANDLE Handle, + BOOL IsFile, + ULONG SectorSize, + ULONGLONG Offset, + ULONG Length, + PVOID Buffer + ) +{ + LARGE_INTEGER address; + NT::NTSTATUS status; + NT::IO_STATUS_BLOCK ioSb; + + ULONG aLength = 0; + PVOID aBuffer = NULL; + + if (SectorSize == 0 || SectorSize == 1) + IsFile = TRUE; + + ASSERT(Buffer != NULL); + + if (IsFile) { + + address.QuadPart = Offset; + status = NT::ZwWriteFile( + Handle, 0, NULL, NULL, &ioSb, + Buffer, Length, &address, NULL + ); + } else { + + address.QuadPart = Offset & (~((ULONGLONG)SectorSize - 1)); + aLength = (Length + SectorSize - 1)&(~(SectorSize - 1)); + aLength += ((ULONG)(Offset - address.QuadPart) + SectorSize - 1) + & (~(SectorSize - 1)); + + aBuffer = malloc(aLength); + if (!aBuffer) { + status = STATUS_INSUFFICIENT_RESOURCES; + goto errorout; + } + + if ( (aLength != Length) || + (address.QuadPart != (LONGLONG)Offset)) { + status = NT::ZwReadFile( + Handle, 0, NULL, NULL, &ioSb, + aBuffer, aLength, &address, NULL + ); + + if (!NT_SUCCESS(status)) { + goto errorout; + } + } + + memmove((PUCHAR)aBuffer + (ULONG)(Offset - address.QuadPart), + Buffer, Length); + status = NT::ZwWriteFile( + Handle, 0, NULL, NULL, &ioSb, + aBuffer, aLength, &address, NULL + ); + } + +errorout: + + if (aBuffer) + free(aBuffer); + + return status; +} + +NT::NTSTATUS +Ext2Open( + PCHAR FileName, + PHANDLE Handle, + ULONG DesiredAccess + ) +{ + NT::IO_STATUS_BLOCK iosb; + NT::NTSTATUS status; + NT::ANSI_STRING AnsiFilespec; + NT::UNICODE_STRING UnicodeFilespec; + NT::OBJECT_ATTRIBUTES ObjectAttributes; + + SHORT UnicodeName[MAX_PATH]; + CHAR AnsiName[MAX_PATH]; + USHORT NameLength = 0; + + memset(UnicodeName, 0, sizeof(SHORT) * MAX_PATH); + memset(AnsiName, 0, sizeof(UCHAR) * MAX_PATH); + + NameLength = (USHORT)strlen(FileName); + ASSERT(NameLength < MAX_PATH); + + if (FileName[0] == '\\') { + memmove(AnsiName, FileName, NameLength); + } else { + memmove(&AnsiName[0], "\\DosDevices\\", 12); + memmove(&AnsiName[12], FileName, NameLength); + NameLength += 12; + } + + AnsiFilespec.MaximumLength = AnsiFilespec.Length = NameLength; + AnsiFilespec.Buffer = AnsiName; + + UnicodeFilespec.MaximumLength = MAX_PATH * 2; + UnicodeFilespec.Length = 0; + UnicodeFilespec.Buffer = (PWSTR)UnicodeName; + + NT::RtlAnsiStringToUnicodeString(&UnicodeFilespec, &AnsiFilespec, FALSE); + + // + // Setup the name in an object attributes structure. + // Note that we create a name that is case INsensitive + // + + ObjectAttributes.Length = sizeof(NT::OBJECT_ATTRIBUTES); + ObjectAttributes.RootDirectory = NULL; + ObjectAttributes.Attributes = 0; /*OBJ_CASE_INSENSITIVE;*/ + ObjectAttributes.ObjectName = &UnicodeFilespec; + ObjectAttributes.SecurityDescriptor = NULL; + ObjectAttributes.SecurityQualityOfService = NULL; + + // + // Do the create. In this particular case, we'll have the I/O Manager + // make our write requests syncrhonous for our convenience. + // + status = NT::ZwCreateFile( + Handle, // returned file handle + (DesiredAccess | SYNCHRONIZE), // desired access + &ObjectAttributes, // ptr to object attributes + &iosb, // ptr to I/O status block + 0, // allocation size + FILE_ATTRIBUTE_NORMAL, // file attributes + FILE_SHARE_WRITE | FILE_SHARE_READ, // share access + FILE_OPEN /*FILE_SUPERSEDE*/, // create disposition + FILE_SYNCHRONOUS_IO_NONALERT | // create options + ((DesiredAccess & GENERIC_WRITE) ? + FILE_NO_INTERMEDIATE_BUFFERING : 0), + NULL, // ptr to extended attributes + 0); // length of ea buffer + + // + // Check the system service status + // + if (!NT_SUCCESS(status)) { + return status; + } + + // + // Check the returned status too... + // + if (!NT_SUCCESS(iosb.Status)) { + return iosb.Status; + } + + return status; +} + +VOID +Ext2Close(HANDLE * Handle) +{ + NT::NTSTATUS status = 0; + if (Handle != NULL && *Handle != 0 && *Handle != INVALID_HANDLE_VALUE) { + status = NT::ZwClose(*Handle); + if (NT_SUCCESS(status)) { + *Handle = 0; + } else { + ::MessageBox(NULL, "Failed to close handle", "Ext2Close", MB_OK); + } + } +} + +BOOL +Ext2QuerySysConfig() +{ + NT::NTSTATUS status; + NT::_SYSTEM_CONFIGURATION_INFORMATION ConfigInfo; + + status = NT::ZwQuerySystemInformation( + NT::SystemConfigurationInformation, + &ConfigInfo, sizeof(ConfigInfo), 0); + if (NT_SUCCESS(status)) { + g_nDisks = ConfigInfo.DiskCount; + g_nFlps = ConfigInfo.FloppyCount; + g_nCdroms = ConfigInfo.CdRomCount; + return TRUE; + } + + return FALSE; +} + +BOOL +Ext2LoadDisks() +{ + ULONG i = 0, j = 0; + NT::NTSTATUS status; + CHAR drvName[MAX_PATH]; + + if (g_nDisks == 0) { + return FALSE; + } + + gDisks = (PEXT2_DISK) malloc(sizeof(EXT2_DISK) * g_nDisks); + if (gDisks == NULL) { + return FALSE; + } + memset(gDisks, 0, sizeof(EXT2_DISK) * g_nDisks); + + while (i < g_nDisks && j < 256) { + + HANDLE Handle = NULL; + + gDisks[i].Magic = EXT2_DISK_MAGIC; + gDisks[i].Null = EXT2_DISK_NULL_MAGIC; + gDisks[i].OrderNo = (UCHAR) j; + gDisks[i].bLoaded = FALSE; + sprintf(drvName, "PhysicalDrive%d\0", j); + if (QueryDosDevice(drvName, gDisks[i].Name, MAX_PATH) == 0) { + sprintf(gDisks[i].Name, "\\DosDevices\\PhysicalDrive%d\0", j); + } + j++; + + status = Ext2Open(gDisks[i].Name, &Handle, EXT2_DESIRED_ACCESS); + if (!NT_SUCCESS(status)) { + continue; + } + + status = Ext2QueryDisk(Handle, &gDisks[i].DiskGeometry); + if (NT_SUCCESS(status)) { + gDisks[i].bEjected = FALSE; + } else { + if (STATUS_NO_MEDIA_IN_DEVICE == status) { + gDisks[i].bEjected = TRUE; + } else { + goto Next; + } + } + + status = Ext2QueryProperty( Handle, StorageDeviceProperty, + (PVOID)&gDisks[i].SDD, + sizeof(STORAGE_DEVICE_DESCRIPTOR) + ); + if (!NT_SUCCESS(status)) { + goto Next; + } + + status = Ext2QueryProperty( Handle, StorageAdapterProperty, + (PVOID)&gDisks[i].SAD, + sizeof(STORAGE_ADAPTER_DESCRIPTOR) + ); + if (!NT_SUCCESS(status)) { + goto Next; + } + + if (!gDisks[i].bEjected) { + gDisks[i].Layout = Ext2QueryDriveLayout( + Handle, &gDisks[i].NumParts); + } + + gDisks[i].bLoaded = TRUE; + +Next: + + Ext2Close(&Handle); + i++; + } + + g_nDisks = i; + + return TRUE; +} + +CString +Ext2PartInformation(PEXT2_PARTITION part) +{ + CString s, ret=""; + + s.Format("\r\n Partition No: %d\r\n\r\n", part->Number); + if (!part->Entry) { + return ret; + } + + s = " Partition Type: "; + if (part->Entry->PartitionStyle == PARTITION_STYLE_MBR) { + s += PartitionString(part->Entry->Mbr.PartitionType); + } else if (part->Entry->PartitionStyle == PARTITION_STYLE_GPT){ + s += "GPT"; + if (part->Entry->Gpt.Name && wcslen(part->Entry->Gpt.Name)) { + s += ":"; + for (size_t i = 0; i < wcslen(part->Entry->Gpt.Name); i++) + s += (CHAR)part->Entry->Gpt.Name[i]; + } + } else { + s += "GPT"; + } + ret += s; + ret += "\r\n"; + + s.Format(" StartingOffset: %I64u\r\n", part->Entry->StartingOffset.QuadPart); + ret += s; + + s.Format(" PartitionLength: %I64u\r\n", part->Entry->PartitionLength.QuadPart); + ret += s; + + /* mount points */ + ret += " MountPoints: "; + ret += Ext2QueryVolumeLetterStrings(part->DrvLetters, NULL); + ret += "\r\n"; + + if (!part->Volume) { + return ret; + } + + if (part->Volume->bRecognized) { + + ULONGLONG totalSize, freeSize; + + s.Format(" Filesystem: %s\r\n", part->Volume->FileSystem); + ret += s; + + if ((part->Volume->EVP.bExt2 || part->Volume->EVP.bExt3)) { + s = " codepage:"; + s += part->Volume->EVP.Codepage; + if (part->Volume->EVP.bReadonly) { + s += ",Readonly"; + } + } + ret += s; + ret += "\r\n"; + + totalSize = part->Volume->FssInfo.TotalAllocationUnits.QuadPart; + freeSize = part->Volume->FssInfo.AvailableAllocationUnits.QuadPart; + totalSize = totalSize * part->Volume->FssInfo.BytesPerSector * + part->Volume->FssInfo.SectorsPerAllocationUnit; + freeSize = freeSize * part->Volume->FssInfo.BytesPerSector * + part->Volume->FssInfo.SectorsPerAllocationUnit; + s.Format(" Size: %I64u\r\n", totalSize); + ret += s; + + s.Format(" Free: %I64u\r\n", freeSize); + ret += s; + } + + return ret; +} + +CString +Ext2DiskInformation(PEXT2_DISK disk) +{ + CString s, ret=""; + + s.Format("\r\nDisk %d: %s\r\n\r\n", disk->OrderNo, disk->Name); + ret += s; + + if (disk->SDD.VendorIdOffset) { + ret += "\r\n VendorId: "; + ret += (PCHAR)&disk->SDD + disk->SDD.VendorIdOffset; + ret += "\r\n"; + } + + if (disk->SDD.ProductIdOffset) { + ret += " ProductId: "; + ret += (PCHAR)&disk->SDD + disk->SDD.ProductIdOffset; + ret += "\r\n"; + } + + if (disk->SDD.SerialNumberOffset) { + ret += " SerialNumber: "; + ret += (PCHAR)&disk->SDD + disk->SDD.SerialNumberOffset; + ret += "\r\n"; + } + + ret += " BusType: "; + ret += BusTypeString(disk->SDD.BusType); + ret += "\r\n"; + + ret += " Media Type: "; + if (disk->SDD.RemovableMedia) { + ret += " Removable\r\n"; + } else { + s = "RAW"; + if (disk->Layout) { + if (disk->Layout->PartitionStyle == PARTITION_STYLE_MBR) { + if (disk->Layout->PartitionEntry->Mbr.PartitionType + == PARTITION_LDM) { + s.LoadString(IDS_DISK_TYPE_DYN); + } else { + s.LoadString(IDS_DISK_TYPE_BASIC); + } + } else if (disk->Layout->PartitionStyle == PARTITION_STYLE_GPT) { + s = "GPT"; + } + } + s += "\r\n"; + ret += s; + } + + if (disk->bEjected) { + ret += " No media\r\n"; + } else { + /* geometry information */ + ret += " DiskGeometry Layout:\r\n"; + s.Format(" BytesPerSector = %u\r\n", disk->DiskGeometry.BytesPerSector); + ret += s; + s.Format(" SectorsPerTrack = %u\r\n", disk->DiskGeometry.SectorsPerTrack); + ret += s; + s.Format(" TracksPerCylinder = %u\r\n", disk->DiskGeometry.TracksPerCylinder); + ret += s; + s.Format(" Cylinderst = %I64u\r\n", disk->DiskGeometry.Cylinders.QuadPart); + ret += s; + + switch (disk->DiskGeometry.MediaType) { + case FixedMedia: s="Fixed"; break; + case RemovableMedia: s="Removable"; break; + case CD_ROM: s="CDROM"; break; + case CD_R: s="CDR"; break; + case CD_RW: s="CDRW"; break; + case DVD_ROM: s="DVD"; break; + case DVD_R: s="DVDR"; break; + case DVD_RW: s="DVDRW"; break; + default: s="Unkown"; + } + + ret += " MediaType: "; + ret += s; + ret += "\r\n"; + } + + ret += "\r\n"; + if (disk->Layout) { + s.Format(" Partition Numbers: %d\r\n", disk->NumParts); + ret += s; + + for (UCHAR i=0; i < disk->NumParts; i++) { + ret += Ext2PartInformation(&disk->DataParts[i]); + ret += "\r\n"; + } + } + + return ret; +} + +CString +Ext2CdromInformation(PEXT2_CDROM cdrom) +{ + CString s, ret=""; + + s.Format("\r\nCdrom %d: %s\r\n\r\n", cdrom->OrderNo, cdrom->Name); + ret += s; + + if (cdrom->SDD.VendorIdOffset) { + ret += " VendorId: "; + ret += (PCHAR)&cdrom->SDD + cdrom->SDD.VendorIdOffset; + ret += "\r\n"; + } + + if (cdrom->SDD.ProductIdOffset) { + ret += " ProductId: "; + ret += (PCHAR)&cdrom->SDD + cdrom->SDD.ProductIdOffset; + ret += "\r\n"; + } + + if (cdrom->SDD.SerialNumberOffset) { + ret += " SerialNumber: "; + ret += (PCHAR)&cdrom->SDD + cdrom->SDD.SerialNumberOffset; + ret += "\r\n"; + } + + ret += " BusType: "; + ret += BusTypeString(cdrom->SDD.BusType); + ret += "\r\n"; + + if (cdrom->bLoaded) { + ret += " Media Type: "; + if (cdrom->bIsDVD) { + s = "DVD\r\n"; + } else { + s = "CDROM\r\n"; + } + ret += s; + + ret += " DiskGeometry Layout:\r\n"; + s.Format(" BytesPerSector = %u\r\n", cdrom->DiskGeometry.BytesPerSector); + ret += s; + s.Format(" SectorsPerTrack = %u\r\n", cdrom->DiskGeometry.SectorsPerTrack); + ret += s; + s.Format(" TracksPerCylinder = %u\r\n", cdrom->DiskGeometry.TracksPerCylinder); + ret += s; + s.Format(" Cylinderst = %I64u\r\n", cdrom->DiskGeometry.Cylinders.QuadPart); + ret += s; + } else { + s = " No media\r\n"; + ret += s; + } + + if (cdrom->bLoaded) { + if (cdrom->bEjected) { + ret += " Media ejected\r\n"; + } else { + ret += " File system: "; + if (cdrom->EVP.bExt2) { + s = "EXT"; + s += (CHAR)('2' + cdrom->EVP.bExt3); + } else { + s = "CDFS"; + } + ret += s; + ret += "\r\n"; + + s = " Online,"; + switch (cdrom->DiskGeometry.MediaType) { + case FixedMedia: s +="Fixed"; break; + case RemovableMedia: s += "Media Removable"; break; + case CD_ROM: s +=" CDROM"; break; + case CD_R: s += "CDR"; break; + case CD_RW: s += "CDRW"; break; + case DVD_ROM: s += "DVD"; break; + case DVD_R: s += "DVDR"; break; + case DVD_RW: s += "DVDRW"; break; + default: s += "Unkown"; + } + ret += s; + ret += "\r\n"; + } + } else { + ret += " Device stopped\r\n"; + } + + ret += " Mountpoints: "; + ret += Ext2QueryVolumeLetterStrings(cdrom->DrvLetters, NULL); + ret += "\r\n"; + + return ret; +} + +CString +Ext2VolumeInformation(PEXT2_VOLUME vol) +{ + CString s, ret = ""; + + s.Format("\r\nVolume: %s:\r\n\r\n", vol->Name); + ret += s; + + ret += " Filesystem: "; + ret += vol->FileSystem; + ret += "\r\n"; + + /* mount points */ + ret += " Mountpoints: "; + ret += Ext2QueryVolumeLetterStrings(vol->DrvLetters, NULL); + ret += "\r\n"; + + /* set volume status */ + s = " Volume status: Online"; + if (vol->bRecognized && (vol->EVP.bExt2 || vol->EVP.bExt3)) { + s += ",codepage:"; + s += vol->EVP.Codepage; + if (vol->EVP.bReadonly) { + s += ",Readonly"; + } + } + ret += s; + ret += "\r\n"; + + { + ULONGLONG totalSize, freeSize; + totalSize = vol->FssInfo.TotalAllocationUnits.QuadPart; + freeSize = vol->FssInfo.AvailableAllocationUnits.QuadPart; + totalSize = totalSize * vol->FssInfo.BytesPerSector * + vol->FssInfo.SectorsPerAllocationUnit; + freeSize = freeSize * vol->FssInfo.BytesPerSector * + vol->FssInfo.SectorsPerAllocationUnit; + s.Format(" size: %I64u\r\n", totalSize); + ret += s; + + s.Format(" free space: %I64u\r\n", freeSize); + ret += s; + } + + if (vol->Extent) { + for (DWORD i=0; i < vol->Extent->NumberOfDiskExtents; i++) { + s.Format(" Extent: %d\r\n", i); + ret += s; + s.Format(" DiskNumber: %d\r\n", vol->Extent->Extents[i].DiskNumber); + ret += s; + s.Format(" StartingOffset: %I64u\r\n", vol->Extent->Extents[i].StartingOffset.QuadPart); + ret += s; + s.Format(" ExtentLength: %I64u\r\n", vol->Extent->Extents[i].ExtentLength.QuadPart); + ret += s; + } + } + + return ret; +} + + +CString +Ext2SysInformation() +{ + ULONG i = 0; + CString s; + PEXT2_VOLUME chain = gVols; + + s = "\r\nDisk devices:\r\n"; + for (i=0; i < g_nDisks; i++) { + s += Ext2DiskInformation(&gDisks[i]); + } + + s += "\r\nCdrom/DVD devices:\r\n"; + + for (i=0; i < g_nCdroms; i++) { + s += Ext2CdromInformation(&gCdroms[i]); + } + + while (chain) { + s += Ext2VolumeInformation(chain); + chain = chain->Next; + } + + return s; +} + +VOID +Ext2CleanupDisks() +{ + ULONG i = 0; + + for (i=0; i < g_nDisks; i++) { + if (gDisks[i].bLoaded) { + if (gDisks[i].Layout) { + free(gDisks[i].Layout); + gDisks[i].Layout = NULL; + } + gDisks[i].bLoaded = FALSE; + if (gDisks[i].DataParts) { + free(gDisks[i].DataParts); + } + } + } + + g_nDisks = 0; + if (gDisks) { + free(gDisks); gDisks = NULL; + } +} + +BOOL +Ext2LoadCdroms() +{ + ULONG i = 0, j = 0; + NT::NTSTATUS status; + DWORD mediaType; + + if (g_nCdroms == 0) { + return TRUE; + } + + gCdroms = (PEXT2_CDROM) malloc(sizeof(EXT2_CDROM) * g_nCdroms); + if (gCdroms == NULL) { + return FALSE; + } + memset(gCdroms, 0, sizeof(EXT2_CDROM) * g_nCdroms); + + while (i < g_nCdroms && j < 256) { + + HANDLE Handle = NULL; + + gCdroms[i].Magic[0] = EXT2_CDROM_DEVICE_MAGIC; + gCdroms[i].Magic[1] = EXT2_CDROM_VOLUME_MAGIC; + gCdroms[i].OrderNo = (UCHAR) j; + gCdroms[i].bLoaded = FALSE; + sprintf(gCdroms[i].Name, "\\Device\\Cdrom%d\0", j); + + j++; + + status = Ext2Open(gCdroms[i].Name, &Handle, EXT2_DESIRED_ACCESS); + if (!NT_SUCCESS(status)) { + continue; + } + + status = Ext2QueryProperty( Handle, StorageDeviceProperty, + (PVOID)&gCdroms[i].SDD, + sizeof(STORAGE_DEVICE_DESCRIPTOR) + ); + if (!NT_SUCCESS(status)) { + goto Next; + } + + status = Ext2QueryProperty( Handle, StorageAdapterProperty, + (PVOID)&gCdroms[i].SAD, + sizeof(STORAGE_ADAPTER_DESCRIPTOR) + ); + if (!NT_SUCCESS(status)) { + goto Next; + } + + status = Ext2QueryDisk(Handle, &gCdroms[i].DiskGeometry); + if (NT_SUCCESS(status)) { + gCdroms[i].bEjected = FALSE; + } else { + // (status == STATUS_NO_MEDIA_IN_DEVICE) { + gCdroms[i].bEjected = TRUE; + } + + status = Ext2QueryMediaType(Handle, &mediaType); + if (NT_SUCCESS(status) && mediaType == FILE_DEVICE_DVD) { + gCdroms[i].bIsDVD = TRUE; + } else { + gCdroms[i].bIsDVD = FALSE; + } + + if (!gCdroms[i].bEjected) { + Ext2QueryExt2Property(Handle, &gCdroms[i].EVP); + } + + gCdroms[i].bLoaded = TRUE; + +Next: + + Ext2Close(&Handle); + i++; + } + + g_nCdroms = i; + return TRUE; +} + +VOID +Ext2LoadCdromDrvLetters() +{ + for (ULONG i = 0; i < g_nCdroms; i++) { + gCdroms[i].DrvLetters = Ext2QueryCdromDrvLetters(&gCdroms[i]); + } +} + + +VOID +Ext2CleanupCdroms() +{ + ULONG i = 0; + + for (i=0; i < g_nCdroms; i++) { + if (gCdroms[i].bLoaded) { + gCdroms[i].bLoaded = FALSE; + } + } + + g_nCdroms = 0; + if (gCdroms) { + free(gCdroms); gCdroms = NULL; + } +} + +BOOL +Ext2CompareExtents( + PVOLUME_DISK_EXTENTS ext1, + PVOLUME_DISK_EXTENTS ext2 + ) +{ + DWORD nExt; + + if (ext1->NumberOfDiskExtents != ext2->NumberOfDiskExtents) { + return FALSE; + } + + for (nExt = 0; nExt < ext1->NumberOfDiskExtents; nExt++) { + if ((ext1->Extents[nExt].DiskNumber != ext2->Extents[nExt].DiskNumber) || + (ext1->Extents[nExt].StartingOffset.QuadPart != ext2->Extents[nExt].StartingOffset.QuadPart) || + (ext1->Extents[nExt].ExtentLength.QuadPart != ext2->Extents[nExt].ExtentLength.QuadPart) ) { + return FALSE; + } + } + return TRUE; +} + +ULONGLONG +Ext2EjectedDiskLetters( + PEXT2_DISK Disk + ) +{ + ULONGLONG letters = 0; + int i; + + /* checking the digits ltters */ + for (i=0; i < 10; i++) { + if (drvDigits[i].bUsed && drvDigits[i].SDN) { + if (drvDigits[i].SDN->DeviceNumber == Disk->OrderNo) { + letters |= (((ULONGLONG) 1) << (32 + i)); + } + } + } + + for (i=0; i <26; i++) { + if (drvLetters[i].bUsed && drvLetters[i].SDN) { + if (drvLetters[i].SDN->DeviceNumber == Disk->OrderNo) { + letters |= (((ULONGLONG) 1) << i); + } + } + } + + return letters; +} + +ULONGLONG +Ext2QueryVolumeDrvLetters(PEXT2_VOLUME Volume) +{ + ULONGLONG letters = 0; + int i; + + UCHAR drvChar = Ext2QueryMountPoint(Volume->Name); + if (drvChar) { + letters |= (((ULONGLONG) 1) << (drvChar - 'A')); + } + + if (!Volume->Extent) { + goto errorout; + } + + /* checking the digits ltters */ + for (i=0; i < 10; i++) { + if (drvDigits[i].bUsed && drvDigits[i].Extent) { + if (Ext2CompareExtents(drvDigits[i].Extent, Volume->Extent)) { + letters |= (((ULONGLONG) 1) << (32 + i)); + if (drvChar != drvDigits[i].Letter) { + drvDigits[i].bTemporary = TRUE; + } + } + } + } + + for (i=0; i <26; i++) { + if (drvLetters[i].bUsed && drvLetters[i].Extent) { + if (Ext2CompareExtents(drvLetters[i].Extent, Volume->Extent)) { + letters |= (((ULONGLONG) 1) << i); + if (drvChar != drvLetters[i].Letter) { + drvLetters[i].bTemporary = TRUE; + } + } + } + } + +errorout: + + return letters; +} + +ULONGLONG +Ext2QueryCdromDrvLetters(PEXT2_CDROM Cdrom) +{ + ULONGLONG letters = 0; + UCHAR drvChar; + int i; + + if (!Cdrom) { + goto errorout; + } + + drvChar = Ext2QueryMountPoint(Cdrom->Name); + if (drvChar) { + letters |= (((ULONGLONG) 1) << (drvChar - 'A')); + } + + /* checking the digits ltters */ + for (i=0; i < 10; i++) { + if (drvDigits[i].bUsed && drvDigits[i].DrvType == DRIVE_CDROM) { + if (!_stricmp(drvDigits[i].SymLink, Cdrom->Name)) { + letters |= (((ULONGLONG) 1) << (i + 32)); + } + } + } + + for (i=0; i <26; i++) { + if (drvLetters[i].bUsed && drvLetters[i].DrvType == DRIVE_CDROM) { + if (!_stricmp(drvLetters[i].SymLink, Cdrom->Name)) { + letters |= (((ULONGLONG) 1) << i); + } + } + } + +errorout: + + return letters; +} + +BOOL +Ext2QueryVolumeFS( + HANDLE Handle, + PEXT2_VOLUME volume + ) +{ + struct ext2_super_block *sb = NULL; + union swap_header* swap = NULL; + PUCHAR buffer = NULL; + + + NT::NTSTATUS status; + + buffer = (PUCHAR)malloc(PAGE_SIZE); + if (!buffer) { + return FALSE; + } + + swap = (union swap_header*)&buffer[SWAP_HEADER_OFFSET]; + sb = (struct ext2_super_block *)&buffer[SUPER_BLOCK_OFFSET]; + + status = Ext2Read( Handle, FALSE, volume->FssInfo.BytesPerSector, + (ULONGLONG)0,PAGE_SIZE, (PUCHAR) buffer); + + if (!NT_SUCCESS(status)) { + free(buffer); + return FALSE; + } + + if (sb->s_magic == EXT2_SUPER_MAGIC) { + + volume->FsaInfo.FileSystemNameLength = 8; + volume->FsaInfo.FileSystemName[0] = (WCHAR)'E'; + volume->FsaInfo.FileSystemName[1] = (WCHAR)'X'; + volume->FsaInfo.FileSystemName[2] = (WCHAR)'T'; + volume->FsaInfo.FileSystemName[4] = 0; + + if ((sb->s_feature_incompat & EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) || + (sb->s_feature_incompat & EXT3_FEATURE_INCOMPAT_RECOVER) || + (sb->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL) ) { + volume->FsaInfo.FileSystemName[3] = (WCHAR)'3'; + volume->EVP.bExt3 = TRUE; + } else { + volume->FsaInfo.FileSystemName[3] = (WCHAR)'2'; + volume->EVP.bExt2 = TRUE; + } + memcpy(&volume->EVP.UUID[0], &sb->s_uuid[0], 16); + goto errorout; + } + + if ((memcmp(swap->magic.magic, SWAP_HEADER_MAGIC_V1, 10) == 0) || + (memcmp(swap->magic.magic, SWAP_HEADER_MAGIC_V2, 10) == 0)) { + volume->FsaInfo.FileSystemNameLength = 8; + volume->FsaInfo.FileSystemName[0] = (WCHAR)'S'; + volume->FsaInfo.FileSystemName[1] = (WCHAR)'W'; + volume->FsaInfo.FileSystemName[2] = (WCHAR)'A'; + volume->FsaInfo.FileSystemName[3] = (WCHAR)'P'; + volume->FsaInfo.FileSystemName[4] = 0; + } + +errorout: + + free(buffer); + return (volume->EVP.bExt2 || volume->EVP.bExt3); +} + +BOOL +Ext2QueryExt2Property ( + HANDLE Handle, + PEXT2_VOLUME_PROPERTY3 EVP + ) +{ + NT::NTSTATUS status; + NT::IO_STATUS_BLOCK iosb; + + BOOLEAN bExt2, bExt3; + CHAR UUID[16]; + + if (!Ext2IsServiceStarted()) { + return FALSE; + } + + bExt2 = EVP->bExt2; + bExt3 = EVP->bExt3; + memcpy(&UUID[0], &EVP->UUID[0], 16); + memset(EVP, 0, sizeof(EXT2_VOLUME_PROPERTY2)); + memcpy(&EVP->UUID[0], &UUID[0], 16); + EVP->bExt2 = bExt2; + EVP->bExt3 = bExt3; + EVP->Magic = EXT2_VOLUME_PROPERTY_MAGIC; + EVP->Command = APP_CMD_QUERY_PROPERTY3; + + status = NT::ZwDeviceIoControlFile( + Handle, NULL, NULL, NULL, &iosb, + IOCTL_APP_VOLUME_PROPERTY, + EVP, sizeof(EXT2_VOLUME_PROPERTY3), + EVP, sizeof(EXT2_VOLUME_PROPERTY3) + ); + + return NT_SUCCESS(status); +} + + +BOOL +Ext2QueryPerfStat ( + HANDLE Handle, + PEXT2_QUERY_PERFSTAT Stat, + PEXT2_PERF_STATISTICS_V1 *PerfV1, + PEXT2_PERF_STATISTICS_V2 *PerfV2 + ) +{ + NT::NTSTATUS status; + NT::IO_STATUS_BLOCK iosb; + + memset(Stat, 0, sizeof(EXT2_QUERY_PERFSTAT)); + Stat->Magic = EXT2_VOLUME_PROPERTY_MAGIC; + Stat->Command = IOCTL_APP_QUERY_PERFSTAT; + + *PerfV1 = NULL; + *PerfV2 = NULL; + + status = NT::ZwDeviceIoControlFile( + Handle, NULL, NULL, NULL, &iosb, + IOCTL_APP_QUERY_PERFSTAT, + Stat, sizeof(EXT2_QUERY_PERFSTAT), + Stat, sizeof(EXT2_QUERY_PERFSTAT) + ); + if (!NT_SUCCESS(!status)) + return FALSE; + + if (iosb.Information == EXT2_QUERY_PERFSTAT_SZV2 && + (Stat->Flags & EXT2_QUERY_PERFSTAT_VER2) != 0) { + + if (Stat->PerfStatV2.Magic == EXT2_PERF_STAT_MAGIC && + Stat->PerfStatV2.Length == sizeof(EXT2_PERF_STATISTICS_V2) && + Stat->PerfStatV2.Version == EXT2_PERF_STAT_VER2) { + *PerfV2 = &Stat->PerfStatV2; + } + + } else if (iosb.Information >= EXT2_QUERY_PERFSTAT_SZV1) { + + *PerfV1 = &Stat->PerfStatV1; + } + + if (PerfV1 || PerfV2) + return TRUE; + + return FALSE; +} + +VOID +Ext2StorePropertyinRegistry(PEXT2_VOLUME_PROPERTY3 EVP) +{ + CHAR UUID[50], ID[16]; + HKEY hKey; + CHAR keyPath[MAX_PATH]; + LONG status; + CString data = ""; + + int i; + int len = 0; + + memset(UUID, 0, 50); + for (i=0; i < 16; i++) { + if (i == 0) { + sprintf(&UUID[len], "{%2.2X", EVP->UUID[i]); + len += 3; + } else if (i == 15) { + sprintf(&UUID[len], "-%2.2X}", EVP->UUID[i]); + len +=4; + } else { + sprintf(&UUID[len], "-%2.2X", EVP->UUID[i]); + len += 3; + } + } + + /* Create or open ext2fsd volumes key */ + strcpy (keyPath, "SYSTEM\\CurrentControlSet\\Services\\Ext2Fsd\\Volumes") ; + status = ::RegCreateKeyEx (HKEY_LOCAL_MACHINE, + keyPath, + 0, + 0, + REG_OPTION_NON_VOLATILE, + KEY_ALL_ACCESS, + NULL, + &hKey, + NULL); + if (status != ERROR_SUCCESS) { + return; + } + +#define READING_ONLY "Readonly" +#define WRITING_SUPPORT "WritingSupport" +#define EXT3_FORCEWRITING "Ext3ForceWriting" +#define CODEPAGE_NAME "CodePage" +#define HIDING_PREFIX "HidingPrefix" +#define HIDING_SUFFIX "HidingSuffix" +#define MOUNT_POINT "MountPoint" +#define UID "uid" +#define GID "gid" +#define EUID "euid" +#define EGID "egid" + + + if (EVP->bReadonly) { + data += READING_ONLY";"; + } else if (EVP->bExt3 && EVP->bExt3Writable) { + data += EXT3_FORCEWRITING";"; + } + + if (EVP->DrvLetter) { + if ((EVP->DrvLetter & 0x7F) == 0 || EVP->DrvLetter == 0xFF) { + data += MOUNT_POINT";"; + } else { + data += MOUNT_POINT"="; + data += (CHAR)(EVP->DrvLetter & 0x7F); + data += ":;"; + } + } + + if (strlen((CHAR*)EVP->Codepage) > 0) { + data += CODEPAGE_NAME"="; + data += &EVP->Codepage[0]; + data += ";"; + } + + if (EVP->bHidingPrefix) { + data += HIDING_PREFIX"="; + data += EVP->sHidingPrefix; + data += ";"; + } + + if (EVP->bHidingSuffix) { + data += HIDING_SUFFIX"="; + data += EVP->sHidingSuffix; + data += ";"; + } + + if (EVP->Flags2 & EXT2_VPROP3_USERIDS) { + sprintf(ID, "%u", EVP->uid); + data += UID"="; + data += ID; + data += ";"; + + sprintf(ID, "%u", EVP->gid); + data += GID"="; + data += ID; + data += ";"; + + if (EVP->EIDS) { + sprintf(ID, "%u", EVP->euid); + data += EUID"="; + data += ID; + data += ";"; + } + } + + /* set volume parameters */ + status = RegSetValueEx( hKey, UUID, 0, REG_SZ, (BYTE *) + data.GetBuffer(data.GetLength()), + data.GetLength()); + + RegCloseKey(hKey); +} + +BOOL Ext2IsNullUuid (__u8 * uuid) +{ + int i; + for (i = 0; i < 16; i++) { + if (uuid[i]) { + break; + } + } + + return (i >= 16); +} + +BOOL +Ext2CheckVolumeRegistryProperty(PEXT2_VOLUME_PROPERTY3 EVP) +{ + CHAR UUID[50]; + HKEY hKey; + CHAR keyPath[MAX_PATH]; + CHAR content[MAX_PATH]; + LONG status, type = 0; + + int i; + int len = 0; + BOOL rc = TRUE; + + if (Ext2IsNullUuid(&EVP->UUID[0])) { + return TRUE; + } + + memset(UUID, 0, 50); + for (i=0; i < 16; i++) { + if (i == 0) { + sprintf(&UUID[len], "{%2.2X", EVP->UUID[i]); + len += 3; + } else if (i == 15) { + sprintf(&UUID[len], "-%2.2X}", EVP->UUID[i]); + len +=4; + } else { + sprintf(&UUID[len], "-%2.2X", EVP->UUID[i]); + len += 3; + } + } + + /* Create or open ext2fsd volumes key */ + strcpy (keyPath, "SYSTEM\\CurrentControlSet\\Services\\Ext2Fsd\\Volumes") ; + status = ::RegOpenKeyEx (HKEY_LOCAL_MACHINE, + keyPath, + 0, + KEY_ALL_ACCESS, + &hKey) ; + if (status != ERROR_SUCCESS) { + rc = FALSE; + goto errorout; + } + + /* Query volume parameters */ + len = MAX_PATH; + status = RegQueryValueEx(hKey, + &UUID[0], + 0, + (LPDWORD)&type, + (BYTE *)&content[0], + (LPDWORD)&len); + if (status != ERROR_SUCCESS) { + rc = FALSE; + } + + RegCloseKey(hKey); + +errorout: + return rc; +} + +VOID +Ext2SetDefaultVolumeRegistryProperty(PEXT2_VOLUME_PROPERTY3 EVP) +{ + ULONG StartMode; + BOOL AutoMount = 0; + + if (Ext2IsNullUuid(&EVP->UUID[0])) { + return; + } + + /* query global parameters */ + Ext2QueryGlobalProperty( + &StartMode, + (BOOL *)&EVP->bReadonly, + (BOOL *)&EVP->bExt3Writable, + (CHAR *)EVP->Codepage, + (CHAR *)NULL, + (CHAR *)NULL, + (BOOL *)&AutoMount + ); + + if (EVP->bExt3 && !EVP->bExt3Writable) + EVP->bReadonly = TRUE; + + EVP->DrvLetter = 0x80; + EVP->Flags2 |= EXT2_VPROP3_AUTOMOUNT; + Ext2StorePropertyinRegistry(EVP); +} + +BOOL +Ext2SetExt2Property ( + HANDLE Handle, + PEXT2_VOLUME_PROPERTY3 EVP + ) +{ + NT::NTSTATUS status; + NT::IO_STATUS_BLOCK iosb; + + ASSERT(EVP->Magic == EXT2_VOLUME_PROPERTY_MAGIC); + EVP->Command = APP_CMD_SET_PROPERTY3; + + status = NT::ZwDeviceIoControlFile( + Handle, NULL, NULL, NULL, &iosb, + IOCTL_APP_VOLUME_PROPERTY, + EVP, sizeof(EXT2_VOLUME_PROPERTY3), + EVP, sizeof(EXT2_VOLUME_PROPERTY3) + ); + + if (NT_SUCCESS(status)) { + return TRUE; + } else { + CString s; + s.Format("Status = %xh\n", status); + AfxMessageBox(s); + } + + return FALSE; +} + + +BOOL +Ext2QueryGlobalProperty( + ULONG * ulStartup, + BOOL * bReadonly, + BOOL * bExt3Writable, + CHAR * Codepage, + CHAR * sPrefix, + CHAR * sSuffix, + BOOL * bAutoMount + ) +{ + int rc = TRUE; + HKEY hKey; + CHAR keyPath[MAX_PATH]; + DWORD data = 0; + LONG status, type, len; + + /* Open ext2fsd sevice key */ + strcpy (keyPath, "SYSTEM\\CurrentControlSet\\Services\\Ext2Fsd") ; + status = ::RegOpenKeyEx (HKEY_LOCAL_MACHINE, + keyPath, + 0, + KEY_ALL_ACCESS, + &hKey) ; + if (status != ERROR_SUCCESS) { + rc = FALSE; + goto errorout; + } + + /* Query Start type */ + len = sizeof(DWORD); + status = RegQueryValueEx( hKey, + "Start", + 0, + (LPDWORD)&type, + (BYTE *)&data, + (LPDWORD)&len); + if (status == ERROR_SUCCESS) { + *ulStartup = data; + } + + RegCloseKey(hKey); + + /* Open ext2fsd parameters key */ + strcpy (keyPath, "SYSTEM\\CurrentControlSet\\Services\\Ext2Fsd\\Parameters") ; + status = ::RegOpenKeyEx (HKEY_LOCAL_MACHINE, + keyPath, + 0, + KEY_ALL_ACCESS, + &hKey) ; + if (status != ERROR_SUCCESS) { + rc = FALSE; + goto errorout; + } + + /* Query WritingSupport */ + len = sizeof(DWORD); + status = RegQueryValueEx( hKey, + "WritingSupport", + 0, + (LPDWORD)&type, + (BYTE *)&data, + (LPDWORD)&len); + if (status == ERROR_SUCCESS) { + *bReadonly = (data == 0); + } + + /* query Ext3ForceWriting */ + len = sizeof(DWORD); + status = RegQueryValueEx( hKey, + "Ext3ForceWriting", + 0, + (LPDWORD)&type, + (BYTE *)&data, + (LPDWORD)&len); + + if (status == ERROR_SUCCESS) { + *bExt3Writable = (data != 0); + } + + /* query AutoMount */ + len = sizeof(DWORD); + status = RegQueryValueEx( hKey, + "AutoMount", + 0, + (LPDWORD)&type, + (BYTE *)&data, + (LPDWORD)&len); + + if (status == ERROR_SUCCESS) { + *bAutoMount = (data != 0); + } + + if (Codepage) { + /* query codepage */ + len = CODEPAGE_MAXLEN; + status = RegQueryValueEx( hKey, + "CodePage", + 0, + (LPDWORD)&type, + (BYTE *)Codepage, + (LPDWORD)&len); + } + + if (sPrefix) { + /* querying hidding filter patterns */ + len = CODEPAGE_MAXLEN; + status = RegQueryValueEx( hKey, + "HidingPrefix", + 0, + (LPDWORD)&type, + (BYTE *)sPrefix, + (LPDWORD)&len); + } + + if (sSuffix) { + len = CODEPAGE_MAXLEN; + status = RegQueryValueEx( hKey, + "HidingSuffix", + 0, + (LPDWORD)&type, + (BYTE *)sSuffix, + (LPDWORD)&len); + } + + RegCloseKey(hKey); + + +errorout: + + return rc; +} + +INT +Ext2QueryDrvVersion( + CHAR * Version, + CHAR * Date, + CHAR * Time + ) +{ + EXT2_VOLUME_PROPERTY_VERSION EVPV; + NT::NTSTATUS status; + HANDLE handle = NULL; + NT::IO_STATUS_BLOCK iosb; + INT rc = 0; + + memset(&EVPV, 0, sizeof(EXT2_VOLUME_PROPERTY_VERSION)); + EVPV.Magic = EXT2_VOLUME_PROPERTY_MAGIC; + EVPV.Command = APP_CMD_QUERY_VERSION; + EVPV.Flags |= EXT2_FLAG_VP_SET_GLOBAL; + + status = Ext2Open("\\DosDevices\\Ext2Fsd", + &handle, EXT2_DESIRED_ACCESS); + if (!NT_SUCCESS(status)) { + rc = -1; + goto errorout; + } + + status = NT::ZwDeviceIoControlFile( + handle, NULL, NULL, NULL, &iosb, + IOCTL_APP_VOLUME_PROPERTY, + &EVPV, sizeof(EXT2_VOLUME_PROPERTY_VERSION), + &EVPV, sizeof(EXT2_VOLUME_PROPERTY_VERSION) + ); + + if (NT_SUCCESS(status)) { + strncpy(Version, EVPV.Version, 0x1B); + strncpy(Date, EVPV.Date, 0x1F); + strncpy(Time, EVPV.Time, 0x1F); + } + + rc = NT_SUCCESS(status); + +errorout: + + Ext2Close(&handle); + + return rc; +} + +BOOL +Ext2SetGlobalProperty ( + ULONG ulStartup, + BOOLEAN bReadonly, + BOOLEAN bExt3Writable, + CHAR * Codepage, + CHAR * sPrefix, + CHAR * sSuffix, + BOOL bAutoMount + ) +{ + EXT2_VOLUME_PROPERTY3 EVP; + + NT::NTSTATUS status; + HANDLE Handle = NULL; + int rc = TRUE; + HKEY hKey; + CHAR keyPath[MAX_PATH] ; + + ULONG data = 0; + + memset(&EVP, 0, sizeof(EXT2_VOLUME_PROPERTY3)); + EVP.Magic = EXT2_VOLUME_PROPERTY_MAGIC; + EVP.Command = APP_CMD_SET_PROPERTY3; + EVP.Flags |= EXT2_FLAG_VP_SET_GLOBAL; + EVP.bReadonly = bReadonly; + EVP.bExt3Writable = bExt3Writable; + strcpy((CHAR *)EVP.Codepage, Codepage); + + if (strlen(sPrefix)) { + strcpy(EVP.sHidingPrefix, sPrefix); + EVP.bHidingPrefix = TRUE; + } + + if (strlen(sSuffix)) { + strcpy(EVP.sHidingSuffix, sSuffix); + EVP.bHidingSuffix = TRUE; + } + + strcpy (keyPath, "SYSTEM\\CurrentControlSet\\Services\\Ext2Fsd") ; + status = ::RegOpenKeyEx (HKEY_LOCAL_MACHINE, + keyPath, + 0, + KEY_ALL_ACCESS, + &hKey) ; + if (status != ERROR_SUCCESS) { + rc = FALSE; + goto errorout; + } + + /* set Start type */ + status = RegSetValueEx( hKey, + "Start", + 0, + REG_DWORD, + (BYTE *)&ulStartup, + sizeof(DWORD)); + RegCloseKey(hKey); + + strcpy (keyPath, "SYSTEM\\CurrentControlSet\\Services\\Ext2Fsd\\Parameters") ; + status = ::RegOpenKeyEx (HKEY_LOCAL_MACHINE, + keyPath, + 0, + KEY_ALL_ACCESS, + &hKey) ; + if (status != ERROR_SUCCESS) { + rc = FALSE; + goto errorout; + } + + /* set WritingSupport */ + data = !bReadonly; + status = RegSetValueEx( hKey, + "WritingSupport", + 0, + REG_DWORD, + (BYTE *)&data, + sizeof(ULONG)); + + /* set Ext3ForceWriting */ + data = bExt3Writable; + status = RegSetValueEx( hKey, + "Ext3ForceWriting", + 0, + REG_DWORD, + (BYTE *)&data, + sizeof(ULONG)); + /* set AutoMount */ + data = bAutoMount; + status = RegSetValueEx( hKey, + "AutoMount", + 0, + REG_DWORD, + (BYTE *)&data, + sizeof(ULONG)); + + + /* set codepage */ + status = RegSetValueEx( hKey, + "CodePage", + 0, + REG_SZ, + (BYTE *)Codepage, + (int)strlen(Codepage)); + + /* set hiding filter patterns */ + status = RegSetValueEx( hKey, + "HidingPrefix", + 0, + REG_SZ, + (BYTE *)sPrefix, + (int)strlen(sPrefix)); + + status = RegSetValueEx( hKey, + "HidingSuffix", + 0, + REG_SZ, + (BYTE *)sSuffix, + (int)strlen(sSuffix)); + + RegCloseKey(hKey); + + status = Ext2Open("\\DosDevices\\Ext2Fsd", &Handle, EXT2_DESIRED_ACCESS); + if (!NT_SUCCESS(status)) { + goto errorout; + } + + EVP.Flags2 = EXT2_VPROP3_AUTOMOUNT; + EVP.AutoMount = g_bAutoMount; + + rc = Ext2SetExt2Property(Handle, &EVP); + if (!rc) { + } + +errorout: + + Ext2Close(&Handle); + + return rc; +} + +BOOL +Ext2SetService(PCHAR Target, PCHAR Name, PCHAR Desc, BOOL bInstall) +{ + SC_HANDLE hService; + SC_HANDLE hManager; + + // open Service Control Manager + hManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); + if (hManager == NULL) { + // AfxMessageBox("Ext2Mgr: cannot open Service Control Manager", + // MB_ICONEXCLAMATION | MB_OK); + return FALSE; + } + + if (bInstall) { + + // now create service entry + hService = CreateService( + hManager, // SCManager database + Name, // name of service + Desc, // name to display + SERVICE_ALL_ACCESS, // desired access + SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS, + // service type + SERVICE_AUTO_START, // start type + SERVICE_ERROR_NORMAL, // error control type + Target, // service's binary + NULL, // no load ordering group + NULL, // no tag identifier + NULL, // dependencies + NULL, // LocalSystem account + NULL); // no password + + if (hService == NULL) { + DWORD error = GetLastError(); + if (error == ERROR_SERVICE_EXISTS) { + // AfxMessageBox("Service is already registered.", + // MB_ICONEXCLAMATION | MB_OK); + } else { + // AfxMessageBox("Service couldn't be registered.", + // MB_ICONEXCLAMATION | MB_OK); + } + } else { + + CloseServiceHandle(hService); + } + + } else { + + /* open the service */ + hService = OpenService( + hManager, + Name, + SERVICE_ALL_ACCESS + ); + + if (hService != NULL) { + + // remove the service from the SCM + if (DeleteService(hService)) { + } else { + DWORD error = GetLastError(); + if (error == ERROR_SERVICE_MARKED_FOR_DELETE) { + // AfxMessageBox("Service is already unregistered", + // MB_ICONEXCLAMATION | MB_OK); + } else { + // AfxMessageBox("Service could not be unregistered", + // MB_ICONEXCLAMATION | MB_OK); + } + } + + CloseServiceHandle(hService); + } + } + + CloseServiceHandle(hManager); + + return TRUE; +} + + +BOOL ExtSaveResourceToFile(UINT id, CHAR *target) +{ + HANDLE handle; + ULONG bytes = 0; + BOOL rc = FALSE; + + HRSRC hr = FindResource(NULL, MAKEINTRESOURCE(id), RT_RCDATA); + ULONG size = SizeofResource(NULL, hr); + HGLOBAL hg = LoadResource(NULL, hr); + PVOID data = LockResource(hg); + + if (!data) + goto errorout; + + handle = CreateFile(target, GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, + CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (handle == INVALID_HANDLE_VALUE) { + goto errorout; + } + + rc = WriteFile(handle, data, size, &bytes, NULL); + if (rc) + rc = (bytes == size); + + CloseHandle(handle); + +errorout: + + return rc; +} + +TCHAR *Ext2StrLastA(TCHAR *t, TCHAR *s); + +BOOL Ext2InstallExt2Srv() +{ + TCHAR cmd[512] = {0}, *p; + BOOL rc = FALSE; + + if (GetWindowsDirectory(cmd, 512)) { + if (g_isWow64) + strcat(cmd, "\\SysWOW64\\Ext2Srv.EXE"); + else + strcat(cmd, "\\System32\\Ext2Srv.EXE"); + rc = ExtSaveResourceToFile(IDR_RCDAT_SRV, cmd); + } + + if (!rc) { + GetModuleFileName(NULL, cmd, 510); + p = Ext2StrLastA(cmd, ".EXE"); + if (p && p > &cmd[3]) { + p[-3] = 'S'; + p[-2] = 'r'; + p[-1] = 'v'; + } else { + strcat(cmd, "-Srv.EXE"); + } + rc = ExtSaveResourceToFile(IDR_RCDAT_SRV, cmd); + } + + if (!rc) { + GetTempPath(50, cmd); + strcat(cmd, "\\Ext2Srv.EXE"); + rc = ExtSaveResourceToFile(IDR_RCDAT_SRV, cmd); + } + + if (!rc) { + return rc; + } + + rc = Ext2SetService(cmd, "Ext2Srv", "Ext2Fsd Service Manager", TRUE); + if (!rc) { + return rc; + } + + return Ext2StartService("Ext2Srv"); +} + + +BOOL +Ext2StartService(CHAR *service) +{ + BOOL rc = FALSE; + SC_HANDLE scmHandle = NULL; + SC_HANDLE drvHandle = NULL; + + scmHandle = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); + if (!scmHandle) { + goto errorout; + } + + drvHandle = OpenService(scmHandle, + service, + SERVICE_ALL_ACCESS); + if (!drvHandle) { + goto errorout; + } + + rc = (0 != StartService(drvHandle, 0, NULL)); + +errorout: + + if (drvHandle) + CloseServiceHandle(drvHandle); + + if (scmHandle) { + CloseServiceHandle(scmHandle); + } + + return rc; +} + +BOOL +Ext2StartExt2Srv() +{ + BOOL rc = Ext2StartService("Ext2Srv"); + if (!rc) + rc = Ext2InstallExt2Srv(); + + return rc; +} + + +BOOL +Ext2StartExt2Fsd() +{ + if (Ext2IsServiceStarted()) { + return TRUE; + } + + return Ext2StartService("ext2fsd"); +} + +BOOL +Ext2IsServiceStarted() +{ + NT::NTSTATUS status; + HANDLE Handle = NULL; + + status = Ext2Open("\\DosDevices\\Ext2Fsd", + &Handle, EXT2_DESIRED_ACCESS); + + Ext2Close(&Handle); + if (NT_SUCCESS(status)) { + return TRUE; + } + + return FALSE; +} + + +BOOL +Ext2IsRemovable(PEXT2_VOLUME volume) +{ + STORAGE_BUS_TYPE busType = BusTypeAta; + BOOL bRemovableMedia = FALSE; + + if (volume && volume->Part) { + busType = volume->Part->Disk->SDD.BusType; + bRemovableMedia = volume->Part->Disk->SDD.RemovableMedia; + } + + if (busType == BusType1394 || + busType == BusTypeUsb || + bRemovableMedia ) { + return TRUE; + } + + return FALSE; +} + +BOOL +Ext2RemoveDriveLetter(CHAR DrvLetter) +{ + PEXT2_LETTER drvLetter = NULL; + BOOL rc = FALSE; + + if (DrvLetter >= '0' && DrvLetter <= '9') { + drvLetter = &drvDigits[DrvLetter - '0']; + } else if (DrvLetter >= 'A' && DrvLetter <= 'Z') { + drvLetter = &drvLetters[DrvLetter - 'A']; + } else if (DrvLetter >= 'a' && DrvLetter <= 'z') { + drvLetter = &drvLetters[DrvLetter - 'a']; + } + + if (drvLetter && drvLetter->bUsed) { + rc = Ext2RemoveDrvLetter(drvLetter); + } + + return rc; +} + +BOOL +Ext2InitializeVolume( + PCHAR NameString, + PEXT2_VOLUME * Volume + ) +{ + BOOL rc = FALSE; + HANDLE hVolume = NULL; + NT::NTSTATUS status; + NT::IO_STATUS_BLOCK ioSb; + PEXT2_VOLUME volume = NULL; + + volume = (PEXT2_VOLUME) malloc(sizeof(EXT2_VOLUME)); + if (!volume) { + goto errorout; + } + + status = Ext2Open(NameString, &hVolume, EXT2_DESIRED_ACCESS); + if (!NT_SUCCESS(status)) { + free(volume); volume = NULL; + goto errorout; + } + + memset(volume, 0, sizeof(EXT2_VOLUME)); + volume->Magic = EXT2_VOLUME_MAGIC; + strcpy(volume->Name, NameString); + + status = NT::ZwQueryVolumeInformationFile( + hVolume, &ioSb, &volume->FsaInfo, + MAX_PATH, NT::FileFsAttributeInformation + ); + + if (NT_SUCCESS(status)) { + + NT::UNICODE_STRING uniString; + NT::ANSI_STRING aniString; + + NT::ZwQueryVolumeInformationFile( + hVolume, &ioSb, &volume->FsdInfo, + sizeof(NT::FILE_FS_DEVICE_INFORMATION), + NT::FileFsDeviceInformation + ); + + NT::ZwQueryVolumeInformationFile( + hVolume, &ioSb, &volume->FssInfo, + sizeof(NT::FILE_FS_SIZE_INFORMATION), + NT::FileFsSizeInformation + ); + + if (volume->FsaInfo.FileSystemNameLength == 6 && + (volume->FsaInfo.FileSystemName[0] == (WCHAR)'R' || + volume->FsaInfo.FileSystemName[0] == (WCHAR)'r') && + (volume->FsaInfo.FileSystemName[1] == (WCHAR)'A' || + volume->FsaInfo.FileSystemName[1] == (WCHAR)'a') && + (volume->FsaInfo.FileSystemName[2] == (WCHAR)'W' || + volume->FsaInfo.FileSystemName[2] == (WCHAR)'w')) { + if (!Ext2QueryVolumeFS(hVolume, volume)) { + /* memcpy(volume->Codepage, "N/A", 3); */ + } + + } else { + if (Ext2QueryExt2Property(hVolume, &volume->EVP)) { + volume->bRecognized = TRUE; + } + } + + /* convert the unicode file system name to mbs */ + + uniString.MaximumLength = uniString.Length = + (USHORT)volume->FsaInfo.FileSystemNameLength; + uniString.Buffer = volume->FsaInfo.FileSystemName; + + aniString.Buffer = volume->FileSystem; + aniString.Length = 0; + aniString.MaximumLength = 64; + + memset(volume->FileSystem, 0, 64); + NT::RtlUnicodeStringToAnsiString(&aniString, &uniString, FALSE); + } + + volume->Extent = Ext2QueryVolumeExtents(hVolume); + if (!volume->Extent) { + free(volume); volume = NULL; + goto errorout; + } + + *Volume = volume; rc = TRUE; + +errorout: + + Ext2Close(&hVolume); + return rc; +} + + +CHAR +Ext2ProcessExt2Property(PEXT2_VOLUME volume) +{ + HANDLE hVolume = NULL; + NT::NTSTATUS status; + CHAR rc = 0; + + status = Ext2Open(volume->Name, &hVolume, EXT2_DESIRED_ACCESS); + if (!NT_SUCCESS(status)) { + goto errorout; + } + + if (Ext2QueryExt2Property(hVolume, &volume->EVP)) { + if (volume->DrvLetters == 0 && volume->EVP.DrvLetter) { + CHAR DrvLetter = volume->EVP.DrvLetter & 0x7F; + if (DrvLetter && Ext2IsDrvLetterAvailable(DrvLetter)) { + rc = Ext2MountVolumeAs(volume->Name, DrvLetter); + } else { + rc = volume->EVP.DrvLetter = Ext2MountVolume(volume->Name); + volume->EVP.DrvLetter |= 0x80; + } + } + } + +errorout: + + Ext2Close(&hVolume); + return rc; +} + +BOOL Ext2ProcessExt2Volumes() +{ + PEXT2_VOLUME volume = gVols; + BOOL rc = FALSE; + + while (volume) { + if (Ext2ProcessExt2Property(volume)) { + rc = TRUE; + } + volume = volume->Next; + } + return rc; +} + +BOOL +Ext2IsPartitionExtent( + ULONG disk, + PPARTITION_INFORMATION_EXT part, + PVOLUME_DISK_EXTENTS extent + ) +{ + DWORD nExt = 0; + + for (nExt = 0; nExt < extent->NumberOfDiskExtents; nExt++) { + if ((extent->Extents[nExt].DiskNumber == disk) && + (extent->Extents[nExt].StartingOffset.QuadPart == + part->StartingOffset.QuadPart ) && + (extent->Extents[nExt].ExtentLength.QuadPart == + part->PartitionLength.QuadPart)) { + return TRUE; + } + } + return FALSE; +} + +/* should be called after volumes' initiaization */ +BOOL +Ext2LoadDiskPartitions(PEXT2_DISK Disk) +{ + UCHAR i = 0, cnt = 0; + ULONG j = 0; + + BOOL bDynamic = FALSE; + + if (Disk->NumParts == 0) { + Disk->NumParts = 1; + } + + Disk->DataParts = (PEXT2_PARTITION) malloc( + sizeof(EXT2_PARTITION) * Disk->NumParts); + if (!Disk->DataParts) { + return FALSE; + } + + memset(Disk->DataParts, 0, sizeof(EXT2_PARTITION) * Disk->NumParts); + + if (Disk->Layout) { + if (Disk->Layout->PartitionStyle == PARTITION_STYLE_MBR && + Disk->Layout->PartitionEntry->Mbr.PartitionType == PARTITION_LDM) { + bDynamic = TRUE; + } + + + /* Now walk through driveLayout and pack partitions */ + for (i = 0; (Disk->Layout != NULL) && + (i < (UCHAR)Disk->Layout->PartitionCount); i++) { + + PPARTITION_INFORMATION_EXT Part; + Part = &Disk->Layout->PartitionEntry[i]; + + if (Disk->Layout->PartitionStyle == PARTITION_STYLE_MBR) { + if (Part->Mbr.PartitionType == PARTITION_ENTRY_UNUSED || + Part->Mbr.PartitionType == PARTITION_EXTENDED || + Part->Mbr.PartitionType == PARTITION_XINT13_EXTENDED) { + continue; + } + } + + sprintf(&Disk->DataParts[cnt].Name[0], + "\\Device\\Harddisk%u\\Partition%u", + Disk->OrderNo, cnt + 1); + Disk->DataParts[cnt].Magic = EXT2_PART_MAGIC; + Disk->DataParts[cnt].PartType = Disk->Layout->PartitionStyle; + + Disk->DataParts[cnt].Disk = Disk; + Disk->DataParts[cnt].Number = cnt + 1; + Disk->DataParts[cnt++].Entry = Part; + } + + /* Search the volumes of the partition */ + for (i=0; i < cnt; i++) { + + PEXT2_VOLUME volume = gVols; + for (j=0; (ULONG)j < g_nVols; j++) { + if (Ext2IsPartitionExtent(Disk->OrderNo, + Disk->DataParts[i].Entry, + volume->Extent )) { + volume->bDynamic = bDynamic; + if (volume->Extent->NumberOfDiskExtents == 1) { + volume->Part = &Disk->DataParts[i]; + } + Disk->DataParts[i].Volume = volume; + Disk->DataParts[i].DrvLetters = volume->DrvLetters; + break; + } + volume = volume->Next; + } + } + } else { + Disk->DataParts[cnt].Magic = EXT2_PART_MAGIC; + Disk->DataParts[cnt].Disk = Disk; + Disk->DataParts[cnt].Number = cnt + 1; + Disk->DataParts[cnt].DrvLetters = Ext2EjectedDiskLetters(Disk); + } + + return TRUE; +} + + +VOID +Ext2LoadAllDiskPartitions() +{ + for (ULONG i=0; i < g_nDisks; i++) { + Ext2LoadDiskPartitions(&gDisks[i]); + } +} + +VOID +Ext2MountingVolumes() +{ + PEXT2_VOLUME volume = gVols; + int j; + + if (!Ext2IsServiceStarted()) { + return; + } + + for (j=0; (ULONG)j < g_nVols; j++) { + if ((volume->EVP.bExt2 || volume->EVP.bExt3) && !volume->bRecognized) { + if (Ext2IsRemovable(volume) || (volume->DrvLetters != 0) || g_bAutoMount) { + if (!Ext2CheckVolumeRegistryProperty(&volume->EVP)) { + Ext2SetDefaultVolumeRegistryProperty(&volume->EVP); + } + Ext2NotifyVolumePoint(volume, 0); + } + } + + volume = volume->Next; + } + +} + +/* + * Must initialize driver letter before loading volumes + */ + +BOOL +Ext2LoadVolumes() +{ + ULONG rc = TRUE; + + TCHAR *nameString = NULL; + ULONG nameLen = REGSTR_VAL_MAX_HCID_LEN; + + HMACHINE hMachine = NULL; + DEVNODE dnRoot, dnFirst; + + DEVINSTID devIds[] = { + "ROOT\\FTDISK\\0000", + "ROOT\\DMIO\\0000", + NULL, + "ROOT\\VOLMGR\\0000", + NULL + }; + + int i = 0; + + if (IsVistaOrAbove()) { + i = 3; + } + + nameString = new TCHAR [nameLen]; + if (nameString == NULL) { + goto errorout; + } + + while (devIds[i] != NULL) { + + rc = CM_Locate_DevNode_Ex(&dnRoot, devIds[i], + CM_LOCATE_DEVNODE_NORMAL , hMachine); + if (rc != CR_SUCCESS) { + break; + } + + rc = CM_Get_Child_Ex(&dnFirst, dnRoot, 0, hMachine); + if (rc != CR_SUCCESS) { + goto errorout; + } + + while (TRUE) { + + PEXT2_VOLUME volume = NULL; + + nameLen = REGSTR_VAL_MAX_HCID_LEN; + memset(nameString, 0, nameLen); + rc = CM_Get_DevNode_Registry_Property_Ex( + dnFirst, CM_DRP_PHYSICAL_DEVICE_OBJECT_NAME, + NULL, nameString, &nameLen, 0, hMachine); + if (rc != CR_SUCCESS) { + break; + } + + if (Ext2InitializeVolume(nameString, &volume)) { + + volume->bDynamic = 0; + + /* attach the volume to global list */ + if (gVols) { + PEXT2_VOLUME chain = gVols; + while (chain->Next) { + chain = chain->Next; + } + chain->Next = volume; + } else { + gVols = volume; + } + g_nVols++; + } + + rc = CM_Get_Sibling_Ex(&dnFirst, dnFirst, 0, hMachine); + if (rc != CR_SUCCESS) { + break; + } + } + + i++; + } + +errorout: + + if (nameString) { + delete []nameString; + } + + return TRUE; +} + +BOOL +Ext2LoadRemovableVolumes() +{ + BOOL rc = FALSE; + HDEVINFO devInfo = INVALID_HANDLE_VALUE; + PSP_DEVICE_INTERFACE_DETAIL_DATA ifDetail = NULL; + SP_DEVICE_INTERFACE_DATA ifData; + + PCHAR nameString; + int nInterface = 0; + + if (IsVistaOrAbove()) { + return TRUE; + } + + nameString = (PCHAR)malloc(REGSTR_VAL_MAX_HCID_LEN); + if (nameString == NULL) { + goto errorout; + } + + ifDetail = (PSP_DEVICE_INTERFACE_DETAIL_DATA)malloc(PAGE_SIZE); + if (ifDetail == NULL) { + goto errorout; + } + + devInfo = SetupDiGetClassDevs( + &VolumeClassGuid, NULL, NULL, + DIGCF_PRESENT | DIGCF_DEVICEINTERFACE + ); + if (devInfo == INVALID_HANDLE_VALUE) { + goto errorout; + } + + while (TRUE) { + + BOOL bFound = FALSE; + + ifData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); + bFound = SetupDiEnumDeviceInterfaces( + devInfo, + NULL, + &VolumeClassGuid, + (ULONG)nInterface++, + &ifData); + if (!bFound) { + break; + } + + memset(ifDetail, 0, PAGE_SIZE); + ifDetail->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); + if (SetupDiGetInterfaceDeviceDetail( + devInfo, + &ifData, + ifDetail, + PAGE_SIZE, + NULL, + NULL)) { + + PEXT2_VOLUME volume = NULL; + + memset(nameString, 0, REGSTR_VAL_MAX_HCID_LEN); + QueryDosDevice(&ifDetail->DevicePath[4], nameString, REGSTR_VAL_MAX_HCID_LEN); + + if (Ext2InitializeVolume(nameString, &volume)) { + + if (volume->FsdInfo.Characteristics & FILE_REMOVABLE_MEDIA) { + + /* attach the volume to global list */ + if (gVols) { + PEXT2_VOLUME chain = gVols; + while (chain->Next) { + chain = chain->Next; + } + chain->Next = volume; + } else { + gVols = volume; + } + g_nVols++; + } else { + if (volume->Extent) { + free(volume->Extent); + } + free(volume); + } + } + } + } + + rc = TRUE; + +errorout: + + if (nameString) { + free(nameString); + } + + if (ifDetail) { + free(ifDetail); + } + + if (devInfo != INVALID_HANDLE_VALUE) { + SetupDiDestroyDeviceInfoList(devInfo); + } + + return rc; +} + +VOID +Ext2LoadAllVolumeDrvLetters() +{ + PEXT2_VOLUME volume = gVols; + BOOL started = Ext2IsServiceStarted(); + + // Ext2DrvLetters[0] = Ext2DrvLetters[1]; + // Ext2DrvLetters[1] = 0; + + while (volume) { + volume->DrvLetters = Ext2QueryVolumeDrvLetters(volume); + if ( started && volume->bRecognized && + (volume->EVP.bExt2 || volume->EVP.bExt3)) { + Ext2DrvLetters[1] |= volume->DrvLetters; + } + volume = volume->Next; + } +} + + +CString +Ext2QueryVolumeLetterStrings( + ULONGLONG letters, + PEXT2_LETTER * first + ) +{ + CHAR drvName[] = "C:\0"; + CString str; + int i = 0; + BOOL bInserted = FALSE; + ULONGLONG drive = 0; + + str.Empty(); + + for (i=0; i < 10; i++) { + drive = ((ULONGLONG) 1) << (i + 32); + if (letters & drive) { + if (bInserted) { + str += ","; + } else { + str = "("; + if (first) { + *first = &drvDigits[i]; + } + } + drvName[0] = '0' + i; + str += drvName; + bInserted = TRUE; + } + } + + for (i=0; i < 26; i++) { + drive = ((ULONGLONG) 1) << (i); + if (letters & drive) { + if (bInserted) { + str += ","; + } else { + str = "("; + if (first) { + *first = &drvLetters[i]; + } + } + + drvName[0] = 'A' + i; + str += drvName; + bInserted = TRUE; + } + } + + if (bInserted) { + str += ")"; + } + + return str; +} + +VOID +Ext2RefreshVLVI( + CListCtrl *List, + PEXT2_VOLUME chain, + int nItem + ) +{ + ULONGLONG totalSize, usedSize; + CString sSize, sUnit, s; + + PEXT2_LETTER first = NULL; + CString Letters = Ext2QueryVolumeLetterStrings( + chain->DrvLetters, &first); + + List->SetItem( nItem, 1, LVIF_TEXT, (LPCSTR)Letters, 0, 0, 0,0); + + if (chain->bDynamic) { + s.LoadString(IDS_DISK_TYPE_DYN); + } else { + s.LoadString(IDS_DISK_TYPE_BASIC); + } + List->SetItem(nItem, 2, LVIF_TEXT, (LPCSTR)s, 0, 0, 0,0); + List->SetItem(nItem, 3, LVIF_TEXT, (LPCSTR)chain->FileSystem, 0, 0, 0,0); + + totalSize = chain->FssInfo.TotalAllocationUnits.QuadPart; + usedSize = totalSize - chain->FssInfo.AvailableAllocationUnits.QuadPart; + totalSize = totalSize * chain->FssInfo.BytesPerSector * + chain->FssInfo.SectorsPerAllocationUnit; + usedSize = usedSize * chain->FssInfo.BytesPerSector * + chain->FssInfo.SectorsPerAllocationUnit; + + if (totalSize > (ULONGLONG) 10 * 1024 * 1024 * 1024) { + totalSize = totalSize / ((ULONG)1024 * 1024 * 1024); + usedSize = usedSize / ((ULONG)1024 * 1024 * 1024); + sUnit = " GB"; + } else if (totalSize > 10 * 1024 * 1024){ + totalSize = totalSize / (1024 * 1024); + usedSize = usedSize / (1024 * 1024); + sUnit = " MB"; + } else if (totalSize > 10 * 1024){ + totalSize = totalSize / (1024); + usedSize = usedSize / (1024); + sUnit = " KB"; + } else { + sUnit = " B"; + } + + sSize.Format("%I64u", totalSize); + sSize += sUnit; + List->SetItem(nItem, 4, LVIF_TEXT, (LPCSTR)sSize, 0, 0, 0,0); + + if (chain->bRecognized) { + sSize.Format("%I64u", usedSize); + sSize += sUnit; + } + List->SetItem(nItem, 5, LVIF_TEXT, (LPCSTR)sSize, 0, 0, 0,0); + + List->SetItem(nItem, 6, LVIF_TEXT, (LPCSTR)chain->EVP.Codepage, 0, 0, 0,0); + List->SetItem(nItem, 7, LVIF_TEXT, (LPCSTR)chain->Name, 0, 0, 0,0); + +/* + List->SetItemState( nItem, LVIS_SELECTED | LVIS_FOCUSED , + LVIS_SELECTED | LVIS_FOCUSED); +*/ +} + + +VOID +Ext2InsertVolume( + CListCtrl *List, + PEXT2_VOLUME chain + ) +{ + int nItem = 0, nImage = 0; + + nItem = List->GetItemCount(); + nImage = 0; + + if (chain->FsdInfo.Characteristics & FILE_VIRTUAL_VOLUME) { + nImage = IDI_DYNAMIC - IDI_FLOPPY; + } else if (chain->FsdInfo.Characteristics & FILE_REMOVABLE_MEDIA) { + nImage = IDI_FLOPPY - IDI_FLOPPY; + } else { + nImage = IDI_DISK - IDI_FLOPPY; + } + + nItem = List->InsertItem( LVIF_PARAM|LVIF_IMAGE, nItem, NULL, + 0, 0, nImage, (LPARAM)chain); + + Ext2RefreshVLVI(List, chain, nItem); +} + +VOID +Ext2RefreshVLCD( + CListCtrl *List, + PEXT2_CDROM Cdrom, + int nItem + ) +{ + ULONGLONG totalSize; + CString sSize, sUnit, s; + + PEXT2_LETTER first = NULL; + + CString Letters = Ext2QueryVolumeLetterStrings( + Cdrom->DrvLetters, &first); + + List->SetItem( nItem, 1, LVIF_TEXT, (LPCSTR)Letters, 0, 0, 0,0); + + s.LoadString(IDS_DISK_TYPE_BASIC); + List->SetItem(nItem, 2, LVIF_TEXT, (LPCSTR)s, 0, 0, 0,0); + List->SetItem(nItem, 3, LVIF_TEXT, (LPCSTR)"CDFS", 0, 0, 0,0); + + + totalSize = (ULONGLONG)Cdrom->DiskGeometry.Cylinders.QuadPart; + totalSize = totalSize * Cdrom->DiskGeometry.TracksPerCylinder * + Cdrom->DiskGeometry.SectorsPerTrack * + Cdrom->DiskGeometry.BytesPerSector; + + if (totalSize > 1024 * 1024 * 1024) { + totalSize = totalSize / (1024 * 1024 * 1024); + sUnit = " GB"; + } else if (totalSize > 1024 * 1024){ + totalSize = totalSize / (1024 * 1024); + sUnit = " MB"; + } else if (totalSize > 1024){ + totalSize = totalSize / (1024); + sUnit = " KB"; + } else { + sUnit = " B"; + } + + sSize.Format("%I64u", totalSize); + sSize += sUnit; + List->SetItem(nItem, 4, LVIF_TEXT, (LPCSTR)sSize, 0, 0, 0,0); + + sSize.Format("%I64u", totalSize); + sSize += sUnit; + List->SetItem(nItem, 5, LVIF_TEXT, (LPCSTR)sSize, 0, 0, 0,0); + + List->SetItem(nItem, 8, LVIF_TEXT, (LPCSTR)Cdrom->Name, 0, 0, 0,0); +} + +VOID +Ext2InsertCdromAsVolume( + CListCtrl *List, + PEXT2_CDROM Cdrom + ) +{ + int nItem = 0, nImage = 0; + + nItem = List->GetItemCount(); + nImage = 0; + + if (Cdrom->bIsDVD) { + nImage = IDI_DVD - IDI_FLOPPY; + } else { + nImage = IDI_CDROM - IDI_FLOPPY; + } + + nItem = List->InsertItem( LVIF_PARAM|LVIF_IMAGE, nItem, NULL, + 0, 0, nImage, (LPARAM)Cdrom); + + Ext2RefreshVLCD(List, Cdrom, nItem); +} + +VOID +Ext2RefreshVolumeList(CListCtrl *List) +{ + List->DeleteAllItems(); + PEXT2_VOLUME chain = gVols; + + /* adding disk volumes */ + while (chain) { + Ext2InsertVolume(List, chain); + chain = chain->Next; + } + + /* adding cdroms */ + + ULONG i = 0; + + for (i=0; i < g_nCdroms; i++) { + + if (!gCdroms[i].bLoaded || gCdroms[i].bEjected) { + continue; + } + Ext2InsertCdromAsVolume(List, &gCdroms[i]); + } +} + +VOID +Ext2RefreshDVPT( + CListCtrl* List, + PEXT2_PARTITION Part, + int nItem + ) +{ + + ULONGLONG totalSize, usedSize; + CString sSize, sUnit, s; + + PEXT2_LETTER first = NULL; + PEXT2_VOLUME chain = NULL; + + CString Letters = Ext2QueryVolumeLetterStrings( + Part->DrvLetters, &first); + + List->SetItem( nItem, 0, LVIF_TEXT, (LPCSTR)Letters, 0, 0, 0,0); + + if (Part->Entry) { + CString PartType; + if (Part->Entry->PartitionStyle == PARTITION_STYLE_MBR) { + PartType = PartitionString(Part->Entry->Mbr.PartitionType); + } else if (Part->Entry->PartitionStyle == PARTITION_STYLE_GPT) { + PartType = ""; + if (Part->Entry->Gpt.Name && wcslen(Part->Entry->Gpt.Name)) { + for (size_t i = 0; i < wcslen(Part->Entry->Gpt.Name); i++) + PartType += (CHAR)Part->Entry->Gpt.Name[i]; + + } else { + PartType = "GPT"; + } + } else { + PartType = "RAW"; + } + + List->SetItem(nItem, 6, LVIF_TEXT, (LPCSTR) + PartType, 0, 0, 0,0); + } + + /* query the volume information of the partition */ + chain = Part->Volume; + if (!chain) { + PEXT2_DISK disk = Part->Disk; + CString s; + if (disk->SDD.RemovableMedia) { + s.LoadString(IDS_DISK_TYPE_BASIC); + } else if (disk->bLoaded){ + if (disk->Layout) { + if (disk->Layout->PartitionStyle == PARTITION_STYLE_MBR) { + if (disk->Layout->PartitionEntry->Mbr.PartitionType + == PARTITION_LDM) { + s.LoadString(IDS_DISK_TYPE_DYN); + } else { + s.LoadString(IDS_DISK_TYPE_BASIC); + } + } else if (disk->Layout->PartitionStyle == PARTITION_STYLE_GPT) { + s = "GPT"; + } + } else { + s = "RAW"; + } + } else { + s = "Stopped"; + } + + List->SetItem(nItem, 1, LVIF_TEXT, (LPCSTR)s, 0, 0, 0,0); + return; + } + + if (chain->bDynamic) { + s.LoadString(IDS_DISK_TYPE_DYN); + } else { + s.LoadString(IDS_DISK_TYPE_BASIC); + } + List->SetItem(nItem, 1, LVIF_TEXT, (LPCSTR)s, 0, 0, 0,0); + + List->SetItem(nItem, 2, LVIF_TEXT, (LPCSTR)chain->FileSystem, 0, 0, 0,0); + + totalSize = chain->FssInfo.TotalAllocationUnits.QuadPart; + usedSize = totalSize - chain->FssInfo.AvailableAllocationUnits.QuadPart; + totalSize = totalSize * chain->FssInfo.BytesPerSector * + chain->FssInfo.SectorsPerAllocationUnit; + usedSize = usedSize * chain->FssInfo.BytesPerSector * + chain->FssInfo.SectorsPerAllocationUnit; + + if (totalSize > (ULONGLONG) 10 * 1024 * 1024 * 1024) { + totalSize = totalSize / ((ULONG)1024 * 1024 * 1024); + usedSize = usedSize / ((ULONG)1024 * 1024 * 1024); + sUnit = " GB"; + } else if (totalSize > 10 * 1024 * 1024){ + totalSize = totalSize / (1024 * 1024); + usedSize = usedSize / (1024 * 1024); + sUnit = " MB"; + } else if (totalSize > 10 * 1024){ + totalSize = totalSize / (1024); + usedSize = usedSize / (1024); + sUnit = " KB"; + } else { + sUnit = " B"; + } + + sSize.Format("%I64u", totalSize); + sSize += sUnit; + List->SetItem(nItem, 3, LVIF_TEXT, (LPCSTR)sSize, 0, 0, 0,0); + + if (chain->bRecognized) { + sSize.Format("%I64u", usedSize); + sSize += sUnit; + } + List->SetItem(nItem, 4, LVIF_TEXT, (LPCSTR)sSize, 0, 0, 0,0); + + List->SetItem(nItem, 5, LVIF_TEXT, (LPCSTR)chain->EVP.Codepage, 0, 0, 0,0); +} + +VOID +Ext2InsertPartition( + CListCtrl* List, + PEXT2_DISK Disk, + PEXT2_PARTITION Part + ) +{ + int nItem = 0, nImage = 0; + + nItem = List->GetItemCount(); + nImage = 0; + + if (!Disk) { + nItem = List->InsertItem( LVIF_PARAM|LVIF_IMAGE, nItem, NULL, + 0, 0, nImage, (LPARAM)NULL); + return; + } + + if (!Part) { + nItem = List->InsertItem( LVIF_PARAM|LVIF_IMAGE, nItem, NULL, + 0, 0, nImage, (LPARAM)&Disk->Null); + List->SetItem( nItem, 1, LVIF_TEXT, (LPCSTR)"RAW", 0, 0, 0,0); + return; + } + + nItem = List->InsertItem( LVIF_PARAM| LVIF_IMAGE, nItem, NULL, + 0, 0, nImage, (LPARAM)Part); + + Ext2RefreshDVPT(List, Part, nItem); +} + +VOID +Ext2InsertDisk( + CListCtrl *List, + PEXT2_DISK Disk + ) +{ + UCHAR i; + CHAR devName[64]; + int nItem = 0, nImage = 0; + + sprintf(devName, "DISK %d", Disk->OrderNo); + nItem = List->GetItemCount(); + nItem = List->InsertItem( LVIF_PARAM|LVIF_IMAGE, nItem, NULL, + 0, 0, nImage, (LPARAM)Disk); + List->SetItem( nItem, 0, LVIF_TEXT, (LPCSTR)devName, 0, 0, 0,0); + + if (Disk->NumParts > 0) { + for (i=0; i < Disk->NumParts; i++) { + Ext2InsertPartition(List, Disk, &Disk->DataParts[i]); + } + } else { + Ext2InsertPartition(List, Disk, NULL); + } +} + + +VOID +Ext2RefreshDVCM( + CListCtrl *List, + PEXT2_CDROM Cdrom, + int nItem + ) +{ + ULONGLONG totalSize; + CString sSize, sUnit, s; + + PEXT2_LETTER first = NULL; + + CString Letters = Ext2QueryVolumeLetterStrings( + Cdrom->DrvLetters, &first); + + if (!Cdrom->bLoaded) { + List->SetItem( nItem, 1, LVIF_TEXT, (LPCSTR)"Stopped", 0, 0, 0,0); + return; + } + + List->SetItem( nItem, 0, LVIF_TEXT, (LPCSTR)Letters, 0, 0, 0,0); + + if (Cdrom->bEjected) { + return; + } + + s.LoadString(IDS_DISK_TYPE_BASIC); + List->SetItem(nItem, 1, LVIF_TEXT, (LPCSTR)s, 0, 0, 0,0); + List->SetItem(nItem, 2, LVIF_TEXT, (LPCSTR)"CDFS", 0, 0, 0,0); + + totalSize = (ULONGLONG)Cdrom->DiskGeometry.Cylinders.QuadPart; + totalSize = totalSize * Cdrom->DiskGeometry.TracksPerCylinder * + Cdrom->DiskGeometry.SectorsPerTrack * + Cdrom->DiskGeometry.BytesPerSector; + + if (totalSize > 1024 * 1024 * 1024) { + totalSize = totalSize / (1024 * 1024 * 1024); + sUnit = " GB"; + } else if (totalSize > 1024 * 1024){ + totalSize = totalSize / (1024 * 1024); + sUnit = " MB"; + } else if (totalSize > 1024){ + totalSize = totalSize / (1024); + sUnit = " KB"; + } else { + sUnit = " B"; + } + + sSize.Format("%I64u", totalSize); + sSize += sUnit; + List->SetItem(nItem, 3, LVIF_TEXT, (LPCSTR)sSize, 0, 0, 0,0); + + sSize.Format("%I64u", totalSize); + sSize += sUnit; + List->SetItem(nItem, 4, LVIF_TEXT, (LPCSTR)sSize, 0, 0, 0,0); + + List->SetItem(nItem, 5, LVIF_TEXT, (LPCSTR)"", 0, 0, 0,0); + List->SetItem(nItem, 6, LVIF_TEXT, (LPCSTR)"", 0, 0, 0,0); +} + +VOID +Ext2InsertCdromAsDisk( + CListCtrl *List, + PEXT2_CDROM Cdrom + ) +{ + CHAR devName[64]; + int nItem = 0, nImage = 0; + + sprintf(devName, "CDROM %d", Cdrom->OrderNo); + nItem = List->GetItemCount(); + nItem = List->InsertItem( LVIF_PARAM|LVIF_IMAGE, nItem, NULL, + 0, 0, nImage, (LPARAM)Cdrom); + List->SetItem( nItem, 0, LVIF_TEXT, (LPCSTR)devName, 0, 0, 0,0); + + nItem = List->GetItemCount(); + nImage = 0; + + if (Cdrom->bIsDVD) { + nImage = IDI_DVD - IDI_FLOPPY; + } else { + nImage = IDI_CDROM - IDI_FLOPPY; + } + + nItem = List->InsertItem( LVIF_PARAM|LVIF_IMAGE, nItem, NULL, + 0, 0, nImage, (LPARAM)(&Cdrom->Magic[1])); + + Ext2RefreshDVCM(List, Cdrom, nItem); +} + +VOID +Ext2RefreshDiskList(CListCtrl *List) +{ + List->DeleteAllItems(); + ULONG i = 0; + + /* adding disks */ + for (i=0; i < g_nDisks; i++) { + Ext2InsertDisk(List, &gDisks[i]); + Ext2InsertPartition(List, NULL, NULL); + } + + /* adding cdroms */ + for (i=0; i < g_nCdroms; i++) { + Ext2InsertCdromAsDisk(List, &gCdroms[i]); + Ext2InsertPartition(List, NULL, NULL); + } +} + + +VOID +Ext2CleanupVolumes() +{ + PEXT2_VOLUME chain = gVols, next = NULL; + + while (chain) { + next = chain->Next; + if (chain->Extent) { + free(chain->Extent); + } + free(chain); + g_nVols--; + chain = next; + } + + ASSERT(g_nVols == 0); + g_nVols = 0; gVols = NULL; +} + +VOID +Ext2LoadDrvLetter(PEXT2_LETTER drvLetter, CHAR cLetter) +{ + if (drvLetter->bUsed) { + return; + } + + if (cLetter >= 'a' && cLetter <= 'z') { + cLetter -= 0x20; + } + + memset(drvLetter, 0, sizeof(EXT2_LETTER)); + drvLetter->Letter = cLetter; + Ext2QueryDrvLetter(drvLetter); +} + +VOID +Ext2LoadDrvLetters() +{ + int i; + + for (i=0; i < 36; i++) { + + PEXT2_LETTER drvLetter = NULL; + CHAR cLetter = 0; + + if (i < 10) { + drvLetter = &drvDigits[i]; + cLetter = '0' + i; + } else { + drvLetter = &drvLetters[i-10]; + cLetter = 'A' + (i - 10); + } + + Ext2LoadDrvLetter(drvLetter, cLetter); + } +} + +VOID +Ext2CleanDrvLetter(PEXT2_LETTER drvLetter) +{ + if (drvLetter->Extent) { + free(drvLetter->Extent); + drvLetter->Extent = NULL; + } + + if (drvLetter->SDN) { + free(drvLetter->SDN); + drvLetter->SDN = NULL; + } + + drvLetter->bUsed = FALSE; + drvLetter->bTemporary = FALSE; + drvLetter->DrvType = DRIVE_NO_ROOT_DIR; + memset(drvLetter->SymLink, 0, MAX_PATH); +} + +VOID +Ext2CleanupDrvLetters() +{ + int i = 0; + + for (i=0; i < 10; i++) { + Ext2CleanDrvLetter(&drvDigits[i]); + } + + for (i=0; i < 26; i++) { + Ext2CleanDrvLetter(&drvLetters[i]); + } +} + +VOID +Ext2DrvNotify(UCHAR drive, int mount) +{ + DEV_BROADCAST_VOLUME dbv; + DWORD target = BSM_APPLICATIONS; + unsigned long drv = 0; + + if (drive >= 'A' && drive <= 'Z') + drv = drive - 'A'; + else if(drive >= 'a' && drive <= 'z') + drv = drive - 'a'; + else + return; + + dbv.dbcv_size = sizeof( dbv ); + dbv.dbcv_devicetype = DBT_DEVTYP_VOLUME; + dbv.dbcv_reserved = 0; + dbv.dbcv_unitmask = (1 << drv); + dbv.dbcv_flags = DBTF_NET; + BroadcastSystemMessage(BSF_IGNORECURRENTTASK | BSF_FORCEIFHUNG | + BSF_NOHANG | BSF_NOTIMEOUTIFNOTHUNG, + &target, WM_DEVICECHANGE, mount ? + DBT_DEVICEARRIVAL : DBT_DEVICEREMOVECOMPLETE, + (LPARAM)(DEV_BROADCAST_HDR *)&dbv ); +} + +BOOL +Ext2RemoveDrvLetter( + PEXT2_LETTER drvLetter + ) +{ + CHAR drvPath[] = "A:\\\0"; + CHAR dosPath[] = "A:\0"; + + BOOL rc = FALSE; + + if (!drvLetter->bUsed) { + return TRUE; + } + + dosPath[0] = drvPath[0] = drvLetter->Letter; + rc = Ext2DefineDosDevice ( + DDD_RAW_TARGET_PATH| + DDD_REMOVE_DEFINITION| + DDD_EXACT_MATCH_ON_REMOVE, + dosPath, drvLetter->SymLink); + DeleteVolumeMountPoint(drvPath); + + if (!rc) { + return FALSE; + } + + return TRUE; +} + +CHAR +Ext2QueryRegistryMountPoint ( + CHAR * devName + ) +{ + DWORD i = 0; + + LONG status; + HKEY hKey; + + DWORD drvSize; + DWORD dosSize; + DWORD valType; + + CHAR keyPath[MAX_PATH]; + CHAR drvPath[MAX_PATH]; + CHAR dosPath[64]; + + /* set dos deivce path */ + strcpy (keyPath, "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\DOS Devices"); + + /* open session manager\dos devices */ + status = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, + keyPath, + 0, + KEY_ALL_ACCESS, + &hKey) ; + if (status != ERROR_SUCCESS) { + return FALSE; + } + + + /* enum all values and compare devName ... */ + while (status != ERROR_NO_MORE_ITEMS && i < 1024) { + + valType = REG_SZ; + dosSize = 64; + drvSize = MAX_PATH; + + status = RegEnumValue(hKey, + i++, + &dosPath[0], + &dosSize, + NULL, + &valType, + (LPBYTE)&drvPath[0], + &drvSize); + + if (status == ERROR_SUCCESS) { + if (_stricmp(devName, drvPath) == 0) { + RegCloseKey(hKey); + return dosPath[0]; + } + } + } + + RegCloseKey(hKey); + + return 0; +} + +BOOL +Ext2SetRegistryMountPoint ( + CHAR * dosPath, + CHAR * devName, + BOOL bSet + ) +{ + LONG status; + HKEY hKey; + CHAR keyPath[MAX_PATH]; + CHAR drvPath[MAX_PATH]; + + /* set dos driver name */ + sprintf(drvPath, "%c:", dosPath[0]); + + /* set dos deivce path */ + strcpy (keyPath, "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\DOS Devices"); + + /* open session manager\dos devices */ + status = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, + keyPath, + 0, + KEY_ALL_ACCESS, + &hKey) ; + if (status != ERROR_SUCCESS) { + return FALSE; + } + + if (bSet) { + /* set value */ + status = RegSetValueEx( + hKey, drvPath, + 0, REG_SZ, + (BYTE *)devName, + (int)strlen(devName) + ); + } else { + /* delete key */ + status = RegDeleteValue( + hKey, drvPath + ); + } + + RegCloseKey(hKey); + + if (status != ERROR_SUCCESS) { + return FALSE; + } + + return TRUE; +} + +VOID +Ext2UpdateDrvLetter( + PEXT2_LETTER drvLetter, + PCHAR devPath + ) +{ + CHAR dosPath[] = "A:\0"; + BOOL rc = 0; + + if (drvLetter->bUsed) { + return; + } + + dosPath[0] = drvLetter->Letter; + rc = Ext2DefineDosDevice(DDD_RAW_TARGET_PATH, + dosPath, devPath); + + if (rc) { + Ext2DefineDosDevice ( + DDD_RAW_TARGET_PATH| + DDD_REMOVE_DEFINITION| + DDD_EXACT_MATCH_ON_REMOVE, + dosPath, devPath); + } +} + +BOOL +Ext2AssignDrvLetter( + PEXT2_LETTER drvLetter, + PCHAR devPath, + BOOL bMountMgr + ) +{ + CHAR dosPath[] = "A:\0"; + CHAR drvPath[] = "A:\\\0"; + CHAR volumeName[MAX_PATH]; + + BOOL rc = 0; + + if (drvLetter->bUsed) { + return FALSE; + } + + memset(volumeName, 0, MAX_PATH); + dosPath[0] = drvPath[0] = drvLetter->Letter; + + rc = Ext2DefineDosDevice(DDD_RAW_TARGET_PATH, + dosPath, devPath); + + if (rc) { + + /* Now it's done, since user only + needs a temporary mount point */ + if (!bMountMgr) { + goto DrvMounted; + } + + rc = GetVolumeNameForVolumeMountPoint ( + drvPath, volumeName, MAX_PATH); + + Ext2DefineDosDevice ( + DDD_RAW_TARGET_PATH| + DDD_REMOVE_DEFINITION| + DDD_EXACT_MATCH_ON_REMOVE, + dosPath, devPath); + + if (rc) { + rc = SetVolumeMountPoint(drvPath, volumeName); + } + } + + if (!rc) { + return FALSE; + } + +DrvMounted: + + drvLetter->bTemporary = !bMountMgr; + Ext2QueryDrvLetter(drvLetter); + + return TRUE; +} + +/* + * Mount Manager Support Routines + */ + +VOID +Ext2AnsiToUnicode( + CHAR * AnsiName, + WCHAR* UniName, + USHORT UniLength + ) +{ + USHORT NameLength = 0; + NT::ANSI_STRING AnsiFilespec; + NT::UNICODE_STRING UnicodeFilespec; + + memset(UniName, 0, sizeof(WCHAR) * UniLength); + + NameLength = (USHORT)strlen(AnsiName); + ASSERT(NameLength < UniLength); + + AnsiFilespec.MaximumLength = AnsiFilespec.Length = NameLength; + AnsiFilespec.Buffer = AnsiName; + + UnicodeFilespec.MaximumLength = UniLength * 2; + UnicodeFilespec.Length = 0; + UnicodeFilespec.Buffer = (PWSTR)UniName; + + NT::RtlAnsiStringToUnicodeString(&UnicodeFilespec, &AnsiFilespec, FALSE); +} + +BOOL +Ext2VolumeArrivalNotify(PCHAR VolumePath) +{ + HANDLE hMountMgr = NULL; + + NT::IO_STATUS_BLOCK iosb; + NT::NTSTATUS status; + DWORD rc = 0; + + WCHAR volPath[MAX_PATH + 2]; + PMOUNTMGR_TARGET_NAME target; + + target = (PMOUNTMGR_TARGET_NAME) volPath; + Ext2AnsiToUnicode(VolumePath, &target->DeviceName[0], MAX_PATH); + target->DeviceNameLength = (USHORT)wcslen(target->DeviceName) * 2; + + status = Ext2Open("\\Device\\MountPointManager", &hMountMgr, EXT2_DESIRED_ACCESS); + if (!NT_SUCCESS(status)) { + goto errorout; + } + + status = NT::ZwDeviceIoControlFile( + hMountMgr, NULL, NULL, NULL, &iosb, + IOCTL_MOUNTMGR_VOLUME_ARRIVAL_NOTIFICATION, + (PVOID)target, sizeof(USHORT) + + target->DeviceNameLength, NULL, 0 + ); + + if (!NT_SUCCESS(status)) { + goto errorout; + } + +errorout: + + Ext2Close(&hMountMgr); + return NT_SUCCESS(status); +} + + +BOOL +Ext2SymLinkRemoval(CHAR drvLetter) +{ + HANDLE hMountMgr = NULL; + + NT::IO_STATUS_BLOCK iosb; + NT::NTSTATUS status; + DWORD rc = 0; + + WCHAR buffer[MAX_PATH], *dosName; + PMOUNTMGR_MOUNT_POINT pmp = NULL; + PMOUNTMGR_MOUNT_POINTS pms = NULL; + + memset(buffer, 0, sizeof(WCHAR) * MAX_PATH); + pmp = (PMOUNTMGR_MOUNT_POINT) buffer; + pmp->SymbolicLinkNameOffset = sizeof(MOUNTMGR_MOUNT_POINT); + pmp->SymbolicLinkNameLength = 14 * sizeof(WCHAR); + + dosName = (WCHAR *) (pmp + 1); + swprintf_s(dosName, MAX_PATH - sizeof(MOUNTMGR_MOUNT_POINT), + L"\\DosDevices\\%c:\0", drvLetter); + + status = Ext2Open("\\Device\\MountPointManager", &hMountMgr, EXT2_DESIRED_ACCESS); + if (!NT_SUCCESS(status)) { + goto errorout; + } + + status = NT::ZwDeviceIoControlFile( + hMountMgr, NULL, NULL, NULL, &iosb, + IOCTL_MOUNTMGR_DELETE_POINTS, + (PVOID)pmp, sizeof(WCHAR) * MAX_PATH, + (PVOID)pmp, sizeof(WCHAR) * MAX_PATH + ); + + if (!NT_SUCCESS(status)) { + goto errorout; + } + +errorout: + + Ext2Close(&hMountMgr); + return NT_SUCCESS(status); +} + +BOOL +Ext2SetVolumeMountPoint ( + CHAR * dosPath, + CHAR * devName + ) +{ + HANDLE hMountMgr; + + NT::IO_STATUS_BLOCK iosb; + NT::NTSTATUS status; + DWORD rc = 0; + + CHAR dosDevice[MAX_PATH]; + WCHAR volPath[MAX_PATH]; + WCHAR devPath[MAX_PATH]; + + PMOUNTMGR_CREATE_POINT_INPUT mcpi = NULL; + + USHORT lmcpi = 0, lvolp = 0, ldevp = 0; + + memset(dosDevice, 0, MAX_PATH); + memset(volPath, 0, MAX_PATH * sizeof(WCHAR)); + memset(devPath, 0, MAX_PATH * sizeof(WCHAR)); + + /* covert names to unicode */ + sprintf(dosDevice, "\\DosDevices\\%c:", toupper(dosPath[0])); + Ext2AnsiToUnicode(dosDevice, volPath, MAX_PATH); + Ext2AnsiToUnicode(devName, devPath, MAX_PATH); + + ldevp = (USHORT)wcslen(devPath) * 2; + lvolp = (USHORT)wcslen(volPath) * 2; + lmcpi = sizeof(MOUNTMGR_CREATE_POINT_INPUT) + lvolp + ldevp; + + /* initialize MMGR_CREATE_MOUNT_POINT_INPUT */ + mcpi = (PMOUNTMGR_CREATE_POINT_INPUT) malloc(lmcpi); + if (mcpi == NULL) { + status = STATUS_UNSUCCESSFUL; + goto errorout; + } + + mcpi->SymbolicLinkNameOffset = sizeof(MOUNTMGR_CREATE_POINT_INPUT); + mcpi->SymbolicLinkNameLength = lvolp; + mcpi->DeviceNameOffset = mcpi->SymbolicLinkNameOffset + lvolp; + mcpi->DeviceNameLength = ldevp; + + memcpy((PCHAR)mcpi + mcpi->SymbolicLinkNameOffset, + volPath, lvolp); + memcpy((PCHAR)mcpi + mcpi->DeviceNameOffset, + devPath, ldevp); + + /* open MountMgr */ + status = Ext2Open("\\Device\\MountPointManager", &hMountMgr, EXT2_DESIRED_ACCESS); + if (!NT_SUCCESS(status)) { + goto errorout; + } + + /* ioctl .... */ + status = NT::ZwDeviceIoControlFile( + hMountMgr, NULL, NULL, NULL, &iosb, + IOCTL_MOUNTMGR_CREATE_POINT, + (PVOID)mcpi, lmcpi, NULL, 0 + ); + + if (!NT_SUCCESS(status)) { + goto errorout; + } + + Ext2Close(&hMountMgr); + +errorout: + if (mcpi) { + free(mcpi); + } + + return NT_SUCCESS(status); +} + + +UCHAR +Ext2QueryMountPoint( + CHAR * volume + ) +{ + NT::IO_STATUS_BLOCK iosb; + NT::NTSTATUS status; + ULONG lp, lps; + ULONG i; + HANDLE hMountMgr = 0; + + NT::UNICODE_STRING volPoint; + NT::UNICODE_STRING VolumeName; + WCHAR VolumeBuffer[MAX_PATH]; + + PMOUNTMGR_MOUNT_POINT point = NULL; + PMOUNTMGR_MOUNT_POINTS points = NULL; + UCHAR drvLetter = 0; + + memset(VolumeBuffer, 0, MAX_PATH * sizeof(WCHAR)); + Ext2AnsiToUnicode(volume, VolumeBuffer, MAX_PATH); + + VolumeName.MaximumLength = MAX_PATH; + VolumeName.Length = (USHORT)wcslen(VolumeBuffer) * 2; + VolumeName.Buffer = VolumeBuffer; + + status = Ext2Open("\\Device\\MountPointManager", &hMountMgr, EXT2_DESIRED_ACCESS); + if (!NT_SUCCESS(status)) { + goto errorout; + } + + lp = VolumeName.Length + sizeof(MOUNTMGR_MOUNT_POINT) + 2; + point = (PMOUNTMGR_MOUNT_POINT)malloc(lp); + if (point == NULL) { + goto errorout; + } + + /* initialize MountMgr ioctl input structure */ + memset(point, 0, lp); + point->DeviceNameOffset = sizeof(MOUNTMGR_MOUNT_POINT); + point->DeviceNameLength = VolumeName.Length; + RtlMoveMemory((PCHAR) point + point->DeviceNameOffset, + VolumeBuffer, VolumeName.Length); + lps = 1024; + +Again: + + /* allocate ioctl output structure */ + points = (PMOUNTMGR_MOUNT_POINTS)malloc(lps); + if (!points) { + goto errorout; + } + RtlZeroMemory(points, lps); + + /* could MoungMgr to create volume points for us ? */ + status = NT::ZwDeviceIoControlFile( + hMountMgr, NULL, NULL, NULL, &iosb, + IOCTL_MOUNTMGR_QUERY_POINTS, + point, lp, points, lps + ); + + if (status == STATUS_BUFFER_OVERFLOW) { + lps = (ULONG)iosb.Information + 2; + free(points); + points = NULL; + goto Again; + } + + for (i = 0; i < points->NumberOfMountPoints; i++) { + + volPoint.Length = volPoint.MaximumLength = + points->MountPoints[i].SymbolicLinkNameLength; + volPoint.Buffer = (PWSTR) ((PCHAR) points + + points->MountPoints[i].SymbolicLinkNameOffset); + +#if 0 + if (MOUNTMGR_IS_VOLUME_NAME(&volPoint)) { + if (length) { + if (*length >= volPoint.Length + 2) { + *length = volPoint.Length + 2; + memcpy(vp, volPoint.Buffer, volPoint.Length); + vp[1] = (WCHAR)'\\'; + vp[volPoint.Length / 2] = (WCHAR)'\\'; + vp[*length / 2] = 0; + } else { + *length = 0; + } + } + } +#endif + + if (MOUNTMGR_IS_DRIVE_LETTER(&volPoint)) { + drvLetter = (UCHAR)(volPoint.Buffer[12]); + break; + } + } + +errorout: + + if (points) { + free(points); + } + + if (point) { + free(point); + } + + if (hMountMgr) { + Ext2Close(&hMountMgr); + } + + return drvLetter; +} + +PEXT2_LETTER +Ext2GetDrvLetterPoint(CHAR drvChar) +{ + PEXT2_LETTER drvLetter = NULL; + + if (drvChar >= '0' && drvChar <= '9') { + drvLetter = &drvDigits[drvChar - '0']; + } else if (drvChar >= 'A' && drvChar <= 'Z') { + drvLetter = &drvLetters[drvChar - 'A']; + } else { + drvLetter = NULL; + } + + return drvLetter; +} + +BOOL +Ext2InsertMountPoint( + CHAR * volume, + UCHAR drvChar, + BOOL bGlobal + ) +{ + CHAR volumeName[MAX_PATH]; + + CHAR dosPath[] = "A:\0"; + CHAR drvPath[] = "A:\\\0"; + BOOL rc = FALSE; + + dosPath[0] = drvPath[0] = drvChar & 0x7F; + rc = Ext2DefineDosDevice(DDD_RAW_TARGET_PATH, + dosPath, volume); + + if (rc && bGlobal) { + rc = GetVolumeNameForVolumeMountPoint ( + drvPath, volumeName, MAX_PATH); + + Ext2DefineDosDevice ( + DDD_RAW_TARGET_PATH| + DDD_REMOVE_DEFINITION, + dosPath, volume); + if (rc) { + rc = SetVolumeMountPoint(drvPath, volumeName); + } + } + + return rc; +} + +VOID +Ext2RemoveMountPoint( + PEXT2_LETTER drvLetter, + BOOL bPermanent + ) +{ + CHAR drvPath[] = "A:\\\0"; + CHAR dosPath[] = "A:\0"; + + dosPath[0] = drvPath[0] = drvLetter->Letter; + + Ext2DefineDosDevice ( + DDD_RAW_TARGET_PATH| + DDD_REMOVE_DEFINITION| + DDD_EXACT_MATCH_ON_REMOVE, + dosPath, drvLetter->SymLink); + if (bPermanent) { + DeleteVolumeMountPoint(drvPath); + } + + Ext2CleanDrvLetter(drvLetter); + Ext2QueryDrvLetter(drvLetter); +} + +BOOL +Ext2RefreshVolumePoint( + CHAR * volume, + UCHAR drvChar + ) +{ + PEXT2_LETTER drvLetter = NULL; + BOOL rc = TRUE; + CHAR cLetter = 0; + + cLetter = Ext2QueryMountPoint(volume); + if (cLetter) { + goto errorout; + } else { + rc = FALSE; + } + + if (drvChar & 0x7F) { + if (Ext2InsertMountPoint(volume, drvChar & 0x7F, TRUE)) { + return TRUE; + } + } + + if (!rc) { + Ext2VolumeArrivalNotify(volume); + } + + cLetter = Ext2QueryMountPoint(volume); + if (!cLetter && (cLetter != (drvChar & 0x7F))) { + Ext2InsertMountPoint(volume, drvChar & 0x7F, TRUE); + } + + cLetter = Ext2QueryMountPoint(volume); + if (cLetter) { + Ext2InsertMountPoint(volume, cLetter, FALSE); + } + + rc = (cLetter > 0) ? TRUE: FALSE; + +errorout: + + return rc; +} + + +BOOL Ext2IsDrvLetterAvailable(CHAR drive) +{ + CHAR symLink[MAX_PATH] = {0}; + UINT drvType; + + drvType = Ext2QueryDrive(drive, symLink); + if (drvType == DRIVE_NO_ROOT_DIR) { + return TRUE; + } + + return FALSE; +} + + +CHAR Ext2GetFirstAvailableDrvLetter() +{ + int i; + + for (i = 2; i < 24; i++) { + if (Ext2IsDrvLetterAvailable('A' + i)) + return ('A' + i); + } + + return 0; +} + + +BOOL +Ext2NotifyVolumePoint( + PEXT2_VOLUME volume, + UCHAR drvChar + ) +{ + PEXT2_LETTER letter; + UCHAR mounted = 0; + BOOL rc = FALSE; + PCHAR Name = NULL; + + drvChar = (UCHAR)toupper(drvChar); + letter = &drvLetters[drvChar - 'A']; + + if (volume->Part) { + Name = &volume->Part->Name[0]; + } else { + Name = &volume->Name[0]; + } + + /* do drive update */ + if (Ext2IsDrvLetterAvailable(drvChar)) + Ext2UpdateDrvLetter(letter, Name); + + rc = Ext2VolumeArrivalNotify(Name); + + Sleep(500); + + mounted = Ext2QueryMountPoint(Name); + if (mounted) { + rc = TRUE; + goto errorout; + } + + if (!Ext2IsDrvLetterAvailable(drvChar)) { + drvChar = Ext2GetFirstAvailableDrvLetter(); + if ((drvChar|0x20) >= 'a' && (drvChar | 0x20) <= 'z') { + letter = &drvLetters[drvChar - 'A']; + } else { + letter = NULL; + } + } + + if (letter) { + rc = Ext2AssignDrvLetter(letter, Name, FALSE); + } + +errorout: + + return rc; +} + +#define EXT2_MANAGER_NAME "Ext2 Volume Manager" + +BOOL Ext2RunMgrForCurrentUserXP() +{ + HKEY key ; + CHAR keyPath[MAX_PATH] ; + LONG status ; + DWORD type, len = MAX_PATH; + BOOL rc = FALSE; + + CHAR appPath[MAX_PATH] ; + + GetModuleFileName(NULL, appPath, MAX_PATH - 6); + strcat(appPath, " -quiet"); + + strcpy (keyPath, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run") ; + status = RegOpenKeyEx (HKEY_LOCAL_MACHINE, + keyPath, + 0, + KEY_ALL_ACCESS, + &key) ; + + if (status != ERROR_SUCCESS) { + return FALSE; + } + + status = RegQueryValueEx( key, EXT2_MANAGER_NAME, 0, &type, + (BYTE *)appPath, &len); + if (status != ERROR_SUCCESS) { + goto errorout; + } + + rc = TRUE; + +errorout: + + RegCloseKey (key) ; + return rc; +} + +BOOL +Ext2SetAppAutorunXP(BOOL bInstall) +{ + BOOL rc = FALSE; + HKEY key ; + CHAR keyPath[MAX_PATH] ; + LONG status ; + + CHAR appPath[MAX_PATH] ; + + GetModuleFileName(NULL, appPath, MAX_PATH - 6); + strcat(appPath, " -quiet"); + + strcpy (keyPath, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run") ; + status = RegOpenKeyEx (HKEY_LOCAL_MACHINE, + keyPath, + 0, + KEY_ALL_ACCESS, + &key) ; + + if (status != ERROR_SUCCESS) { + return FALSE; + } + + if (!bInstall) { + status = RegDeleteValue (key, EXT2_MANAGER_NAME) ; + if (status != ERROR_SUCCESS) { + goto errorout; + } + } else { + status = RegSetValueEx( key, EXT2_MANAGER_NAME, 0, REG_SZ, + (BYTE *)appPath, (int)strlen(appPath)); + if (status != ERROR_SUCCESS) { + goto errorout; + } + } + + rc = TRUE; + +errorout: + + RegCloseKey (key) ; + return rc; +} + +CHAR *Ext2QueryAutoUserList() +{ + int rc = TRUE; + HKEY hKey; + CHAR keyPath[MAX_PATH]; + CHAR *userList = NULL; + LONG status, type, len; + + /* Open ext2fsd sevice key */ + strcpy (keyPath, "SYSTEM\\CurrentControlSet\\Services\\Ext2Fsd\\Parameters") ; + status = ::RegOpenKeyEx (HKEY_LOCAL_MACHINE, + keyPath, + 0, + KEY_ALL_ACCESS | KEY_WOW64_64KEY, + &hKey) ; + if (status != ERROR_SUCCESS) { + rc = FALSE; + goto errorout; + } + + /* query autorun user list */ + len = PAGE_SIZE - 1; + userList = new CHAR[len + 1]; + if (!userList) + goto errorout; + memset(userList, 0, len + 1); + status = RegQueryValueEx( hKey, + "AutorunUsers", + 0, + (LPDWORD)&type, + (BYTE *)userList, + (LPDWORD)&len); + +errorout: + + RegCloseKey(hKey); + + return userList; +} + +BOOL Ext2SetAutoRunUserList(CHAR *userList) +{ + HKEY key; + CHAR keyPath[MAX_PATH] ; + LONG status; + + strcpy (keyPath, "SYSTEM\\CurrentControlSet\\Services\\Ext2Fsd\\Parameters") ; + status = ::RegOpenKeyEx (HKEY_LOCAL_MACHINE, + keyPath, + 0, + KEY_ALL_ACCESS | KEY_WOW64_64KEY, + &key) ; + if (status != ERROR_SUCCESS) { + goto errorout; + } + + status = RegSetValueEx( key, "AutorunUsers", 0, REG_SZ, + (BYTE *)userList, (int)strlen(userList)); + if (status != ERROR_SUCCESS) { + goto errorout; + } + +errorout: + + RegCloseKey(key) ; + + return (status == ERROR_SUCCESS); +} + +TCHAR * +Ext2StrStr(TCHAR *s, TCHAR *t) +{ + int ls = (int)_tcslen(s), lt = (int)_tcslen(t), i; + for (i = 0; i + lt <= ls; i++) { + if (0 == _tcsnicmp(&s[i], t, lt)) + return &s[i]; + } + + return NULL; +} + + +BOOL Ext2RunMgrForCurrentUserVista() +{ + CHAR *userList = NULL, *user, e; + CHAR userName[256] = {0}; + DWORD userLen = 255; + BOOL rc = FALSE; + + if (!GetUserName(userName, &userLen)) + return FALSE; + + userList = Ext2QueryAutoUserList(); + if (!userList) + return FALSE; + + user = userList; + while (user = Ext2StrStr(user, userName)) { + if (user > userList) { + e = user[-1]; + if (e != ',' && e != ';') { + user = user + strlen(userName); + continue; + } + } + e = user[strlen(userName)]; + if (!e || e == ',' || e == ';') { + rc = TRUE; + goto errorout; + } + user = user + strlen(userName); + } + +errorout: + + if (userList) + delete [] userList; + + return rc; +} + +BOOL +Ext2SetAppAutorunVista(BOOL bAutorun) +{ + CHAR *userList = NULL, *user, *e; + CHAR userName[256] = {0}; + DWORD userLen = 255; + BOOL changed = FALSE; + + if (!GetUserName(userName, &userLen)) + return FALSE; + + userList = Ext2QueryAutoUserList(); + if (!userList) + return FALSE; + + if (bAutorun) { + + user = userList; + while (user = Ext2StrStr(user, userName)) { + if (user > userList) { + e = user-1; + if (*e != ',' && *e != ';') { + user = user + strlen(userName); + continue; + } + } + e = &user[strlen(userName)]; + if (!*e || *e == ',' || *e == ';') { + goto errorout; + } + user = user + strlen(userName); + } + + e = &userList[strlen(userList) - 1]; + if (e > userList && *e != ',' && *e != ';') { + strcat_s(userList, PAGE_SIZE - 1, ";"); + } + strcat_s(userList, PAGE_SIZE - 1, userName); + strcat_s(userList, PAGE_SIZE - 1, ";"); + changed = TRUE; + + } else { + user = userList; + while (user = Ext2StrStr(user, userName)) { + if (user > userList) { + e = user - 1; + if (*e != ',' && *e != ';') { + user = user + strlen(userName); + continue; + } + } + e = &user[strlen(userName)]; + if (!*e) { + memset(user, 0, strlen(userName) + 1); + changed = TRUE; + } else if (*e == ',' || *e == ';') { + memmove(user, e + 1, strlen(e)); + changed = TRUE; + } else { + user = user + strlen(userName); + } + } + } + + if (changed) + changed = Ext2SetAutoRunUserList(userList); + else + changed = TRUE; + +errorout: + + if (userList) + delete []userList; + + return TRUE; +} + +BOOL +Ext2SetAppAutorun(BOOL bAutorun) +{ + if (IsWindowsVistaOrGreater()) + return Ext2SetAppAutorunVista(bAutorun); + + return Ext2SetAppAutorunXP(bAutorun); +} + + +BOOL Ext2RunMgrForCurrentUser() +{ + if (IsWindowsVistaOrGreater()) + return Ext2RunMgrForCurrentUserVista(); + + return Ext2RunMgrForCurrentUserXP(); +} + + +#define SERVICE_CMD_LENGTH (MAX_PATH * 2) + +int +Ext2SetManagerAsService(BOOL bInstall) +{ + SC_HANDLE hService; + SC_HANDLE hManager; + + CHAR Target[SERVICE_CMD_LENGTH]; + + // get the filename of this executable + if (GetModuleFileName(NULL, Target, SERVICE_CMD_LENGTH - 20) == 0) { + AfxMessageBox("Unable to install Ext2Mgr as service", + MB_ICONEXCLAMATION | MB_OK); + return FALSE; + } + + // append parameters to the end of the path: + strcat(Target, " -service -hide"); + + // open Service Control Manager + hManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); + if (hManager == NULL) { + AfxMessageBox("Ext2Mgr: cannot open Service Control Manager", + MB_ICONEXCLAMATION | MB_OK); + return FALSE; + } + + if (bInstall) { + + // now create service entry for Ext2Mgr + hService = CreateService( + hManager, // SCManager database + "Ext2Mgr", // name of service + "Ext2 Volume Manger", // name to display + SERVICE_ALL_ACCESS, // desired access + SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS, + // service type + SERVICE_AUTO_START, // start type + SERVICE_ERROR_NORMAL, // error control type + Target, // service's binary + NULL, // no load ordering group + NULL, // no tag identifier + NULL, // dependencies + NULL, // LocalSystem account + NULL); // no password + + if (hService == NULL) { + DWORD error = GetLastError(); + if (error == ERROR_SERVICE_EXISTS) { + AfxMessageBox("Ext2Mgr service is already registered.", + MB_ICONEXCLAMATION | MB_OK); + } else { + AfxMessageBox("Ext2Mgr service couldn't be registered.", + MB_ICONEXCLAMATION | MB_OK); + } + } else { + + CloseServiceHandle(hService); + + // got Ext2Mgr installed as a service + AfxMessageBox( + "Ext2Mgr service was successfully registered. \n\n" + "You can modify the default settings and start/stop it from Control Panel.\n" + "The service will automatically run the next time when system is restarted.\n", + MB_ICONINFORMATION | MB_OK); + } + + Ext2SetAppAutorun(FALSE); + + } else { + + /* open the service of Ext2Mgr */ + hService = OpenService( + hManager, + "Ext2Mgr", + SERVICE_ALL_ACCESS + ); + + if (hService != NULL) { + +#if 0 + SERVICE_STATUS status; + + // stop the service + if (ControlService(hService, SERVICE_CONTROL_STOP, &status)) { + + while(QueryServiceStatus(hService, &status)) { + if (status.dwCurrentState == SERVICE_STOP_PENDING) { + Sleep(1000); + } else { + break; + } + } + + if (status.dwCurrentState != SERVICE_STOPPED) { + AfxMessageBox("Could not stop Ext2Mgr service !", + MB_ICONEXCLAMATION | MB_OK); + } + } +#endif + // remove the service from the SCM + if (DeleteService(hService)) { + AfxMessageBox("The Ext2Mgr service has been unregistered.", + MB_ICONINFORMATION | MB_OK); + } else { + DWORD error = GetLastError(); + if (error == ERROR_SERVICE_MARKED_FOR_DELETE) { + AfxMessageBox("Ext2Mgr service is already unregistered", + MB_ICONEXCLAMATION | MB_OK); + } else { + AfxMessageBox("Ext2Mgr service could not be unregistered", + MB_ICONEXCLAMATION | MB_OK); + } + } + + CloseServiceHandle(hService); + } + } + + CloseServiceHandle(hManager); + + return TRUE; +} + +BOOL g_bAutoRemoveDeadLetters = TRUE; + +VOID +Ext2AddLetterMask(ULONGLONG LetterMask) +{ + Ext2DrvLetters[1] |= LetterMask; +} + +VOID +Ext2AutoRemoveDeadLetters() +{ + ULONGLONG LetterMask = Ext2DrvLetters[0]; + DWORD i, j; + PEXT2_DISK disk; + PEXT2_PARTITION part; + PEXT2_CDROM cdrom; + + if (LetterMask != -1) { + AfxMessageBox("Different Mask"); + } + + for (i = 0; i < g_nDisks; i++) { + disk = &gDisks[i]; + if (disk->DataParts == NULL) { + continue; + } + for (j=0; j < disk->NumParts; j++) { + part = &disk->DataParts[j]; + if (part) { + LetterMask &= ~(part->DrvLetters); + } + } + } + + for (i = 0; i < g_nCdroms; i++) { + cdrom = &gCdroms[i]; + LetterMask &= ~(cdrom->DrvLetters); + } + + for (i=0; i < 10; i++) { + if (drvDigits[i].bUsed && (drvDigits[i].Extent == NULL) && + (LetterMask & (((ULONGLONG) 1) << (i + 32)) ) ) { + if (drvDigits[i].bInvalid && drvDigits[i].DrvType == DRIVE_FIXED) { + LetterMask &= (~(((ULONGLONG) 1) << (i + 32))); + Ext2RemoveMountPoint(&drvDigits[i], FALSE); + Ext2RemoveDosSymLink(drvDigits[i].Letter); + } + } + } + + for (i=2; i <26; i++) { + if (drvLetters[i].bUsed && (drvLetters[i].Extent == NULL) && + (LetterMask & (((ULONGLONG) 1) << i)) ) { + if (drvLetters[i].bInvalid && drvLetters[i].DrvType == DRIVE_FIXED) { + LetterMask &= (~(((ULONGLONG) 1) << i)); + Ext2RemoveMountPoint(&drvLetters[i], FALSE); + Ext2RemoveDosSymLink(drvLetters[i].Letter); + } + } + } + + // Ext2DrvLetters[0] = LetterMask; +} + +BOOL +Ext2RemoveDosSymLink(CHAR drvChar) +{ + EXT2_MOUNT_POINT E2MP; + NT::NTSTATUS status; + HANDLE handle = NULL; + NT::IO_STATUS_BLOCK iosb; + + Ext2SymLinkRemoval(drvChar); + + memset(&E2MP, 0, sizeof(EXT2_MOUNT_POINT)); + E2MP.Magic = EXT2_APP_MOUNTPOINT_MAGIC; + E2MP.Command = APP_CMD_DEL_DOS_SYMLINK; + E2MP.Link[0] = (USHORT) drvChar; + + status = Ext2Open("\\DosDevices\\Ext2Fsd", + &handle, EXT2_DESIRED_ACCESS); + if (!NT_SUCCESS(status)) { + goto errorout; + } + + status = NT::ZwDeviceIoControlFile( + handle, NULL, NULL, NULL, &iosb, + IOCTL_APP_MOUNT_POINT, + &E2MP, sizeof(EXT2_MOUNT_POINT), + &E2MP, sizeof(EXT2_MOUNT_POINT) + ); + +errorout: + + Ext2Close(&handle); + + return NT_SUCCESS(status); +} diff --git a/Ext2Mgr/enumDisk.h b/Ext2Mgr/enumDisk.h index ef1270d..f750d4c 100644 --- a/Ext2Mgr/enumDisk.h +++ b/Ext2Mgr/enumDisk.h @@ -1,913 +1,913 @@ -#ifndef _ENUM_DISK_INCLUDE_ -#define _ENUM_DISK_INCLUDE_ - -#include "ntdll.h" -#include -#include -#include -#include -#include -#include -#include "dbt.h" -#include "ext2fs.h" -#include - -//#include -//#include - - - -/****************************************************************** -* * -* VersionHelpers.h -- This module defines helper functions to * -* promote version check with proper * -* comparisons. * -* * -* Copyright (c) Microsoft Corp. All rights reserved. * -* * -******************************************************************/ -#ifndef _versionhelpers_H_INCLUDED_ -#define _versionhelpers_H_INCLUDED_ - -#ifndef ___XP_BUILD -#define WINAPI_PARTITION_DESKTOP (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP) -#define WINAPI_FAMILY WINAPI_FAMILY_DESKTOP_APP -#define WINAPI_FAMILY_PARTITION(Partitions) (Partitions) - -#define _WIN32_WINNT_NT4 0x0400 -#define _WIN32_WINNT_WIN2K 0x0500 -#define _WIN32_WINNT_WINXP 0x0501 -#define _WIN32_WINNT_WS03 0x0502 -#define _WIN32_WINNT_WIN6 0x0600 -#define _WIN32_WINNT_VISTA 0x0600 -#define _WIN32_WINNT_WS08 0x0600 -#define _WIN32_WINNT_LONGHORN 0x0600 -#define _WIN32_WINNT_WIN7 0x0601 -#define _WIN32_WINNT_WIN8 0x0602 -#endif - -#ifdef _MSC_VER -#pragma once -#endif // _MSC_VER - -#ifdef __cplusplus - -#define VERSIONHELPERAPI inline bool - -#else // __cplusplus - -#define VERSIONHELPERAPI FORCEINLINE BOOL - -#endif // __cplusplus - -#define _WIN32_WINNT_WINBLUE 0x0603 -#define _WIN32_WINNT_WIN10 0x0A00 - -typedef NT::NTSTATUS( NTAPI* fnRtlGetVersion )(PRTL_OSVERSIONINFOW lpVersionInformation); - -VERSIONHELPERAPI -IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor) -{ - /*OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0, {0}, 0, 0 }; - DWORDLONG const dwlConditionMask = VerSetConditionMask( - VerSetConditionMask( - VerSetConditionMask( - 0, VER_MAJORVERSION, VER_GREATER_EQUAL), - VER_MINORVERSION, VER_GREATER_EQUAL), - VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); - osvi.dwMajorVersion = wMajorVersion; - osvi.dwMinorVersion = wMinorVersion; - osvi.wServicePackMajor = wServicePackMajor; - return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE;*/ - - RTL_OSVERSIONINFOEXW verInfo = { 0 }; - verInfo.dwOSVersionInfoSize = sizeof( verInfo ); - - static fnRtlGetVersion RtlGetVersion = (fnRtlGetVersion)GetProcAddress( GetModuleHandleW( L"ntdll.dll" ), "RtlGetVersion" ); - - if (RtlGetVersion != 0 && RtlGetVersion( (PRTL_OSVERSIONINFOW)&verInfo ) == 0) - { - if (verInfo.dwMajorVersion > wMajorVersion) - return true; - else if (verInfo.dwMajorVersion < wMajorVersion) - return false; - - if (verInfo.dwMinorVersion > wMinorVersion) - return true; - else if (verInfo.dwMinorVersion < wMinorVersion) - return false; - - if (verInfo.wServicePackMajor >= wServicePackMajor) - return true; - } - - return false; -} - -VERSIONHELPERAPI -IsWindowsXPOrGreater() -{ - return IsWindowsVersionOrGreater( HIBYTE( _WIN32_WINNT_WINXP ), LOBYTE( _WIN32_WINNT_WINXP ), 0 ); -} - -VERSIONHELPERAPI -IsWindowsXPSP1OrGreater() -{ - return IsWindowsVersionOrGreater( HIBYTE( _WIN32_WINNT_WINXP ), LOBYTE( _WIN32_WINNT_WINXP ), 1 ); -} - -VERSIONHELPERAPI -IsWindowsXPSP2OrGreater() -{ - return IsWindowsVersionOrGreater( HIBYTE( _WIN32_WINNT_WINXP ), LOBYTE( _WIN32_WINNT_WINXP ), 2 ); -} - -VERSIONHELPERAPI -IsWindowsXPSP3OrGreater() -{ - return IsWindowsVersionOrGreater( HIBYTE( _WIN32_WINNT_WINXP ), LOBYTE( _WIN32_WINNT_WINXP ), 3 ); -} - -VERSIONHELPERAPI -IsWindowsVistaOrGreater() -{ - return IsWindowsVersionOrGreater( HIBYTE( _WIN32_WINNT_VISTA ), LOBYTE( _WIN32_WINNT_VISTA ), 0 ); -} - -VERSIONHELPERAPI -IsWindowsVistaSP1OrGreater() -{ - return IsWindowsVersionOrGreater( HIBYTE( _WIN32_WINNT_VISTA ), LOBYTE( _WIN32_WINNT_VISTA ), 1 ); -} - -VERSIONHELPERAPI -IsWindowsVistaSP2OrGreater() -{ - return IsWindowsVersionOrGreater( HIBYTE( _WIN32_WINNT_VISTA ), LOBYTE( _WIN32_WINNT_VISTA ), 2 ); -} - -VERSIONHELPERAPI -IsWindows7OrGreater() -{ - return IsWindowsVersionOrGreater( HIBYTE( _WIN32_WINNT_WIN7 ), LOBYTE( _WIN32_WINNT_WIN7 ), 0 ); -} - -VERSIONHELPERAPI -IsWindows7SP1OrGreater() -{ - return IsWindowsVersionOrGreater( HIBYTE( _WIN32_WINNT_WIN7 ), LOBYTE( _WIN32_WINNT_WIN7 ), 1 ); -} - -VERSIONHELPERAPI -IsWindows8OrGreater() -{ - return IsWindowsVersionOrGreater( HIBYTE( _WIN32_WINNT_WIN8 ), LOBYTE( _WIN32_WINNT_WIN8 ), 0 ); -} - -VERSIONHELPERAPI -IsWindows8Point1OrGreater() -{ - return IsWindowsVersionOrGreater( HIBYTE( _WIN32_WINNT_WINBLUE ), LOBYTE( _WIN32_WINNT_WINBLUE ), 0 ); -} - -VERSIONHELPERAPI -IsWindows10OrGreater() -{ - return IsWindowsVersionOrGreater( HIBYTE( _WIN32_WINNT_WIN10 ), LOBYTE( _WIN32_WINNT_WIN10 ), 0 ); -} - - -VERSIONHELPERAPI -IsWindowsServer() -{ - OSVERSIONINFOEXW osvi = { sizeof( osvi ), 0, 0, 0, 0, { 0 }, 0, 0, 0, VER_NT_WORKSTATION }; - DWORDLONG const dwlConditionMask = VerSetConditionMask( 0, VER_PRODUCT_TYPE, VER_EQUAL ); - - return !VerifyVersionInfoW( &osvi, VER_PRODUCT_TYPE, dwlConditionMask ); -} - - -#endif // _VERSIONHELPERS_H_INCLUDED_ - -/* - * system definitions - */ - -#define USING_IOCTL_EX TRUE - -#if (USING_IOCTL_EX) - -// -// New IOCTLs for GUID Partition tabled disks. -// - - -#define IOCTL_DISK_GET_DRIVE_LAYOUT_EXT IOCTL_DISK_GET_DRIVE_LAYOUT_EX -#define IOCTL_DISK_SET_DRIVE_LAYOUT_EXT IOCTL_DISK_SET_DRIVE_LAYOUT_EX -#define PARTITION_INFORMATION_EXT PARTITION_INFORMATION_EX -#define PPARTITION_INFORMATION_EXT PARTITION_INFORMATION_EX * -#define DRIVE_LAYOUT_INFORMATION_EXT DRIVE_LAYOUT_INFORMATION_EX -#define PDRIVE_LAYOUT_INFORMATION_EXT DRIVE_LAYOUT_INFORMATION_EX * - -#else - -#define IOCTL_DISK_GET_DRIVE_LAYOUT_EXT IOCTL_DISK_GET_DRIVE_LAYOUT -#define IOCTL_DISK_SET_DRIVE_LAYOUT_EXT IOCTL_DISK_SET_DRIVE_LAYOUT -typedef PARTITION_INFORMATION PARTITION_INFORMATION_EXT, *PPARTITION_INFORMATION_EXT; -typedef DRIVE_LAYOUT_INFORMATION DRIVE_LAYOUT_INFORMATION_EXT, *PDRIVE_LAYOUT_INFORMATION_EXT; - -#endif // USING_IOCTL_EX - - - -// -// Bus Type -// - -static char* BusType[] = { - "UNKNOWN", // 0x00 - "SCSI", - "ATAPI", - "ATA", - "IEEE 1394", - "SSA", - "FIBRE", - "USB", - "RAID" -}; - -// -// SCSI Device Type -// - -static char* DeviceType[] = { - "Direct Access Device", // 0x00 - "Tape Device", // 0x01 - "Printer Device", // 0x02 - "Processor Device", // 0x03 - "WORM Device", // 0x04 - "CDROM Device", // 0x05 - "Scanner Device", // 0x06 - "Optical Disk", // 0x07 - "Media Changer", // 0x08 - "Comm. Device", // 0x09 - "ASCIT8", // 0x0A - "ASCIT8", // 0x0B - "Array Device", // 0x0C - "Enclosure Device", // 0x0D - "RBC Device", // 0x0E - "Unknown Device" // 0x0F -}; - - -/* - * IFS format callbacks - */ - -// -// Output command -// -typedef struct { - DWORD Lines; - PCHAR Output; -} TEXTOUTPUT, *PTEXTOUTPUT; - -// -// Callback command types -// -typedef enum { - PROGRESS, - DONEWITHSTRUCTURE, - UNKNOWN2, - UNKNOWN3, - UNKNOWN4, - UNKNOWN5, - INSUFFICIENTRIGHTS, - UNKNOWN7, - UNKNOWN8, - UNKNOWN9, - UNKNOWNA, - DONE, - UNKNOWNC, - UNKNOWND, - OUTPUT, - STRUCTUREPROGRESS -} CALLBACKCOMMAND; - -/* - * ext2 codepages - */ - -extern CHAR * gCodepages[]; - -// -// FMIFS callback definition -// -typedef BOOL (__stdcall *PFMIFSCALLBACK)( CALLBACKCOMMAND Command, DWORD SubAction, PVOID ActionInfo ); - -// -// Chkdsk command in FMIFS -// -typedef VOID (__stdcall *PCHKDSK)( PWCHAR DriveRoot, - PWCHAR Format, - BOOL CorrectErrors, - BOOL Verbose, - BOOL CheckOnlyIfDirty, - BOOL ScanDrive, - PVOID Unused2, - PVOID Unused3, - PFMIFSCALLBACK Callback ); - -// -// Format command in FMIFS -// - -// media flags -#define FMIFS_HARDDISK 0xC -#define FMIFS_FLOPPY 0x8 - -typedef VOID (__stdcall *PFORMATEX)( PWCHAR DriveRoot, - DWORD MediaFlag, - PWCHAR Format, - PWCHAR Label, - BOOL QuickFormat, - DWORD ClusterSize, - PFMIFSCALLBACK Callback ); - -#include "..\ext4fsd\include\common.h" - -/* - * structure definitions - */ - -typedef struct _EXT2_PARTITION *PEXT2_PARTITION; - -typedef struct _EXT2_DISK { - - ULONG Magic; - ULONG Null; - CHAR Name[256]; - ULONGLONG Size; - - BOOL bEjected; - BOOL bLoaded; - BOOL IsFile; - UCHAR OrderNo; - UCHAR NumParts; - UCHAR ExtStart; - DISK_GEOMETRY DiskGeometry; - STORAGE_DEVICE_DESCRIPTOR SDD; - STORAGE_ADAPTER_DESCRIPTOR SAD; - PDRIVE_LAYOUT_INFORMATION_EXT Layout; - - PEXT2_PARTITION DataParts; -} EXT2_DISK, *PEXT2_DISK; - -#define EXT2_DISK_MAGIC 'EDSK' -#define EXT2_DISK_NULL_MAGIC 'ENUL' - -typedef struct _EXT2_CDROM { - ULONG Magic[2]; - CHAR Name[256]; - ULONGLONG Size; - - UCHAR OrderNo; - BOOL bLoaded; - BOOL bEjected; - BOOL bIsDVD; - ULONGLONG DrvLetters; - - DISK_GEOMETRY DiskGeometry; - STORAGE_DEVICE_DESCRIPTOR SDD; - STORAGE_ADAPTER_DESCRIPTOR SAD; - EXT2_VOLUME_PROPERTY3 EVP; -} EXT2_CDROM, *PEXT2_CDROM; - -#define EXT2_CDROM_DEVICE_MAGIC 'ECDR' -#define EXT2_CDROM_VOLUME_MAGIC 'ECDV' - - -typedef struct _EXT2_VOLUME { - ULONG Magic; - struct _EXT2_VOLUME * Next; - CHAR Name[REGSTR_VAL_MAX_HCID_LEN]; - ULONGLONG DrvLetters; - BOOL bRecognized; - BOOL bDynamic; - PVOLUME_DISK_EXTENTS Extent; - NT::FILE_FS_DEVICE_INFORMATION FsdInfo; - NT::FILE_FS_SIZE_INFORMATION FssInfo; - union { - NT::FILE_FS_ATTRIBUTE_INFORMATION FsaInfo; - CHAR _tmp_alinged_buf[MAX_PATH]; - }; - CHAR FileSystem[64]; - EXT2_VOLUME_PROPERTY3 EVP; - PEXT2_PARTITION Part; -} EXT2_VOLUME, *PEXT2_VOLUME; - -#define EXT2_VOLUME_MAGIC 'EVOL' - -typedef struct _EXT2_PARTITION { - ULONG Magic; - DWORD PartType; - PEXT2_DISK Disk; - PPARTITION_INFORMATION_EXT Entry; - ULONGLONG DrvLetters; - PEXT2_VOLUME Volume; - UCHAR Number; - CHAR Name[REGSTR_VAL_MAX_HCID_LEN]; -} EXT2_PARTITION; -#define EXT2_PART_MAGIC 'EPRT' - -typedef struct _EXT2_LETTER { - - UCHAR Letter; - BOOL bInvalid; - BOOL bUsed; - BOOL bTemporary; - UINT DrvType; - - PVOLUME_DISK_EXTENTS Extent; - PSTORAGE_DEVICE_NUMBER SDN; - - CHAR SymLink[MAX_PATH]; -} EXT2_LETTER, *PEXT2_LETTER; - - -/* - * global definitions - */ - -extern BOOL g_bAutoMount; -extern ULONG g_nFlps; -extern ULONG g_nDisks; -extern ULONG g_nCdroms; -extern ULONG g_nVols; - -extern EXT2_LETTER drvLetters[26]; -extern EXT2_LETTER drvDigits[10]; - -extern PEXT2_DISK gDisks; -extern PEXT2_CDROM gCdroms; -extern PEXT2_VOLUME gVols; - - -/* - * routines definitions - */ - -char *PartitionString(int type); -char *DriveTypeString(UINT type); -char *DeviceTypeString(DEVICE_TYPE type); -char *BusTypeString(STORAGE_BUS_TYPE BusType); - -BOOL IsWindows2000(); -BOOL IsVistaOrAbove(); - -BOOL CanDoLocalMount(); - -#define EXT2_DESIRED_ACCESS (GENERIC_READ) - -NT::NTSTATUS -Ext2Open( - PCHAR FileName, - PHANDLE Handle, - ULONG DesiredAccess - ); - -VOID -Ext2Close(HANDLE* Handle); - -NT::NTSTATUS -Ext2WriteDisk( - HANDLE Handle, - BOOL IsFile, - ULONG SectorSize, - ULONGLONG Offset, - ULONG Length, - PVOID Buffer - ); - -NT::NTSTATUS -Ext2Read( - IN HANDLE Handle, - IN BOOL IsFile, - IN ULONG SectorSize, - IN ULONGLONG Offset, - IN ULONG Length, - IN PVOID Buffer - ); - -NT::NTSTATUS -Ext2QueryDisk( - HANDLE Handle, - PDISK_GEOMETRY DiskGeometry - ); - -PVOLUME_DISK_EXTENTS -Ext2QueryVolumeExtents( - HANDLE hVolume - ); - -PVOLUME_DISK_EXTENTS -Ext2QueryDriveExtents( - CHAR DriveLetter - ); - -BOOL -Ext2QueryDrvLetter( - PEXT2_LETTER drvLetter - ); - -NT::NTSTATUS -Ext2QueryMediaType( - HANDLE Handle, - PDWORD MediaType - ); - -NT::NTSTATUS -Ext2QueryProperty( - HANDLE Handle, - STORAGE_PROPERTY_ID Id, - PVOID DescBuf, - ULONG DescSize - ); - -PDRIVE_LAYOUT_INFORMATION_EXT -Ext2QueryDriveLayout( - HANDLE Handle, - PUCHAR NumOfParts - ); - -NT::NTSTATUS -Ext2SetDriveLayout( - HANDLE Handle, - PDRIVE_LAYOUT_INFORMATION_EXT Layout - ); - -BOOL -Ext2SetPartitionType( - PEXT2_PARTITION Part, - BYTE Type - ); - -PEXT2_PARTITION -Ext2QueryVolumePartition( - PEXT2_VOLUME Volume - ); - -BOOL -Ext2FlushVolume(CHAR *Device); - -BOOL -Ext2QuerySysConfig(); - -BOOL -Ext2CompareExtents( - PVOLUME_DISK_EXTENTS ext1, - PVOLUME_DISK_EXTENTS ext2 - ); - -ULONGLONG -Ext2QueryVolumeDrvLetters(PEXT2_VOLUME Volume); - -VOID -Ext2QueryVolumeDisks(PEXT2_VOLUME Volume); - -ULONGLONG -Ext2QueryCdromDrvLetters(PEXT2_CDROM Cdrom); - -VOID -Ext2DrvNotify(UCHAR drive, int mount); - -BOOL -Ext2QueryExt2Property ( - HANDLE Handle, - PEXT2_VOLUME_PROPERTY3 EVP - ); - -BOOL -Ext2QueryPerfStat ( - HANDLE Handle, - PEXT2_QUERY_PERFSTAT Stat, - PEXT2_PERF_STATISTICS_V1 *PerfV1, - PEXT2_PERF_STATISTICS_V2 *PerfV2 - ); - -BOOL Ext2IsNullUuid (__u8 * uuid); -BOOL -Ext2CheckVolumeRegistryProperty( - PEXT2_VOLUME_PROPERTY3 EVP - ); - -VOID -Ext2SetDefaultVolumeRegistryProperty( - PEXT2_VOLUME_PROPERTY3 EVP - ); - -VOID -Ext2StorePropertyinRegistry( - PEXT2_VOLUME_PROPERTY3 EVP - ); - -BOOL -Ext2SetExt2Property ( - HANDLE Handle, - PEXT2_VOLUME_PROPERTY3 EVP - ); - -BOOL -Ext2QueryGlobalProperty( - ULONG * ulStartup, - BOOL * bReadonly, - BOOL * bExt3Writable, - CHAR * Codepage, - CHAR * sPrefix, - CHAR * sSuffix, - BOOL * bAutoMount - ); - -INT -Ext2QueryDrvVersion( - CHAR * Version, - CHAR * Date, - CHAR * Time - ); - -BOOL -Ext2SetGlobalProperty ( - ULONG ulStartup, - BOOLEAN bReadonly, - BOOLEAN bExt3Writable, - CHAR * Codepage, - CHAR * sPrefix, - CHAR * sSuffix, - BOOL bAutoMount - ); - -BOOL Ext2IsX64System(); - -BOOL -Ext2IsServiceStarted(); - -BOOL -Ext2StartService(CHAR *service); - -BOOL -Ext2StartExt2Srv(); - -BOOL -Ext2StartExt2Fsd(); - -CString -Ext2SysInformation(); - -BOOL -Ext2LoadDisks(); - -BOOL Ext2ProcessExt2Volumes(); - -VOID -Ext2CleanupDisks(); - -BOOL -Ext2LoadCdroms(); - -VOID -Ext2LoadCdromDrvLetters(); - -VOID -Ext2CleanupCdroms(); - -BOOL -Ext2LoadDiskPartitions(PEXT2_DISK Disk); - -VOID -Ext2LoadAllDiskPartitions(); - -VOID -Ext2MountingVolumes(); - -BOOL -Ext2LoadVolumes(); - -VOID -Ext2LoadAllVolumeDrvLetters(); - -BOOL -Ext2LoadRemovableVolumes(); - -CString -Ext2QueryVolumeLetterStrings( - ULONGLONG letters, - PEXT2_LETTER * first - ); - -VOID -Ext2RefreshVLVI( - CListCtrl *List, - PEXT2_VOLUME chain, - int nItem - ); - -VOID -Ext2InsertVolume( - CListCtrl *List, - PEXT2_VOLUME chain - ); - -VOID -Ext2RefreshVLCD( - CListCtrl *List, - PEXT2_CDROM Cdrom, - int nItem - ); - -VOID -Ext2InsertCdromAsVolume( - CListCtrl *List, - PEXT2_CDROM Cdrom - ); - - -VOID -Ext2RefreshVolumeList(CListCtrl *List); - -VOID -Ext2RefreshDVPT( - CListCtrl* List, - PEXT2_PARTITION Part, - int nItem - ); - -VOID -Ext2InsertPartition( - CListCtrl* List, - PEXT2_DISK Disk, - PEXT2_PARTITION Part - ); - -VOID -Ext2InsertDisk( - CListCtrl *List, - PEXT2_DISK Disk - ); - -VOID -Ext2RefreshDVCM( - CListCtrl *List, - PEXT2_CDROM Cdrom, - int nItem - ); - -VOID -Ext2InsertCdromAsDisk( - CListCtrl *List, - PEXT2_CDROM Cdrom - ); - -VOID -Ext2RefreshDiskList(CListCtrl *List); - -VOID -Ext2CleanupVolumes(); - -VOID -Ext2LoadDrvLetter(PEXT2_LETTER drvLetter, CHAR cLetter); - -VOID -Ext2LoadDrvLetters(); - -VOID -Ext2CleanDrvLetter(PEXT2_LETTER drvLetter); - -VOID -Ext2CleanupDrvLetters(); - -BOOL -Ext2RemoveDrvLetter( - PEXT2_LETTER drvLetter - ); -BOOL -Ext2RemoveDriveLetter(CHAR DrvLetter); - -CHAR -Ext2QueryRegistryMountPoint ( - CHAR * devName - ); - -BOOL -Ext2SetRegistryMountPoint ( - CHAR * dosPath, - CHAR * devName, - BOOL bSet - ); - -BOOL -Ext2InsertMountPoint( - CHAR * volume, - UCHAR drvChar, - BOOL bGlobal - ); - -VOID -Ext2UpdateDrvLetter( - PEXT2_LETTER drvLetter, - PCHAR devPath - ); - -BOOL -Ext2AssignDrvLetter( - PEXT2_LETTER drvLetter, - PCHAR devPath, - BOOL bPermanent - ); - -BOOL Ext2IsDrvLetterAvailable(CHAR drive); -CHAR Ext2MountVolume(CHAR *voldev); - -CHAR Ext2MountVolumeAs(CHAR *voldev, CHAR letter); - -VOID -Ext2RemoveMountPoint( - PEXT2_LETTER drvLetter, - BOOL bPermanent - ); - -BOOL -Ext2SymLinkRemoval(CHAR drvLetter); - -BOOL -Ext2SetVolumeMountPoint ( - CHAR * dosPath, - CHAR * devName - ); - -UCHAR -Ext2QueryMountPoint( - CHAR * volume - ); - -BOOL -Ext2RefreshVolumePoint( - CHAR * volume, - UCHAR drvChar - ); - -BOOL -Ext2NotifyVolumePoint( - PEXT2_VOLUME volume, - UCHAR drvChar - ); - -BOOL -Ext2VolumeArrivalNotify(PCHAR VolumePath); - -BOOL -Ext2SetAppAutorun(BOOL bInstall); - -BOOL Ext2RunMgrForCurrentUser(); - -int -Ext2SetManagerAsService(BOOL bInstall); - -extern BOOL g_bAutoRemoveDeadLetters; - -VOID -Ext2AddLetterMask(ULONGLONG LetterMask); - -VOID -Ext2AutoRemoveDeadLetters(); - -BOOL -Ext2RemoveDosSymLink(CHAR drvChar); - -BOOL Ext2DismountVolume(CHAR *voldev); - -#ifdef __cplusplus -extern "C" { -#endif - -BOOL WINAPI -WTSQueryUserToken( - ULONG SessionId, - PHANDLE phToken - ); - -BOOL WINAPI ConvertStringSidToSidA( - LPCTSTR StringSid, - PSID* Sid -); - -WINUSERAPI -HWND -WINAPI -GetShellWindow( - VOID); - -#ifdef __cplusplus -} -#endif - -#endif // _ENUM_DISK_INCLUDE_ +#ifndef _ENUM_DISK_INCLUDE_ +#define _ENUM_DISK_INCLUDE_ + +#include "ntdll.h" +#include +#include +#include +#include +#include +#include +#include "dbt.h" +#include "ext2fs.h" +#include + +//#include +//#include + + + +/****************************************************************** +* * +* VersionHelpers.h -- This module defines helper functions to * +* promote version check with proper * +* comparisons. * +* * +* Copyright (c) Microsoft Corp. All rights reserved. * +* * +******************************************************************/ +#ifndef _versionhelpers_H_INCLUDED_ +#define _versionhelpers_H_INCLUDED_ + +#ifndef ___XP_BUILD +#define WINAPI_PARTITION_DESKTOP (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP) +#define WINAPI_FAMILY WINAPI_FAMILY_DESKTOP_APP +#define WINAPI_FAMILY_PARTITION(Partitions) (Partitions) + +#define _WIN32_WINNT_NT4 0x0400 +#define _WIN32_WINNT_WIN2K 0x0500 +#define _WIN32_WINNT_WINXP 0x0501 +#define _WIN32_WINNT_WS03 0x0502 +#define _WIN32_WINNT_WIN6 0x0600 +#define _WIN32_WINNT_VISTA 0x0600 +#define _WIN32_WINNT_WS08 0x0600 +#define _WIN32_WINNT_LONGHORN 0x0600 +#define _WIN32_WINNT_WIN7 0x0601 +#define _WIN32_WINNT_WIN8 0x0602 +#endif + +#ifdef _MSC_VER +#pragma once +#endif // _MSC_VER + +#ifdef __cplusplus + +#define VERSIONHELPERAPI inline bool + +#else // __cplusplus + +#define VERSIONHELPERAPI FORCEINLINE BOOL + +#endif // __cplusplus + +#define _WIN32_WINNT_WINBLUE 0x0603 +#define _WIN32_WINNT_WIN10 0x0A00 + +typedef NT::NTSTATUS( NTAPI* fnRtlGetVersion )(PRTL_OSVERSIONINFOW lpVersionInformation); + +VERSIONHELPERAPI +IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor) +{ + /*OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0, {0}, 0, 0 }; + DWORDLONG const dwlConditionMask = VerSetConditionMask( + VerSetConditionMask( + VerSetConditionMask( + 0, VER_MAJORVERSION, VER_GREATER_EQUAL), + VER_MINORVERSION, VER_GREATER_EQUAL), + VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); + osvi.dwMajorVersion = wMajorVersion; + osvi.dwMinorVersion = wMinorVersion; + osvi.wServicePackMajor = wServicePackMajor; + return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE;*/ + + RTL_OSVERSIONINFOEXW verInfo = { 0 }; + verInfo.dwOSVersionInfoSize = sizeof( verInfo ); + + static fnRtlGetVersion RtlGetVersion = (fnRtlGetVersion)GetProcAddress( GetModuleHandleW( L"ntdll.dll" ), "RtlGetVersion" ); + + if (RtlGetVersion != 0 && RtlGetVersion( (PRTL_OSVERSIONINFOW)&verInfo ) == 0) + { + if (verInfo.dwMajorVersion > wMajorVersion) + return true; + else if (verInfo.dwMajorVersion < wMajorVersion) + return false; + + if (verInfo.dwMinorVersion > wMinorVersion) + return true; + else if (verInfo.dwMinorVersion < wMinorVersion) + return false; + + if (verInfo.wServicePackMajor >= wServicePackMajor) + return true; + } + + return false; +} + +VERSIONHELPERAPI +IsWindowsXPOrGreater() +{ + return IsWindowsVersionOrGreater( HIBYTE( _WIN32_WINNT_WINXP ), LOBYTE( _WIN32_WINNT_WINXP ), 0 ); +} + +VERSIONHELPERAPI +IsWindowsXPSP1OrGreater() +{ + return IsWindowsVersionOrGreater( HIBYTE( _WIN32_WINNT_WINXP ), LOBYTE( _WIN32_WINNT_WINXP ), 1 ); +} + +VERSIONHELPERAPI +IsWindowsXPSP2OrGreater() +{ + return IsWindowsVersionOrGreater( HIBYTE( _WIN32_WINNT_WINXP ), LOBYTE( _WIN32_WINNT_WINXP ), 2 ); +} + +VERSIONHELPERAPI +IsWindowsXPSP3OrGreater() +{ + return IsWindowsVersionOrGreater( HIBYTE( _WIN32_WINNT_WINXP ), LOBYTE( _WIN32_WINNT_WINXP ), 3 ); +} + +VERSIONHELPERAPI +IsWindowsVistaOrGreater() +{ + return IsWindowsVersionOrGreater( HIBYTE( _WIN32_WINNT_VISTA ), LOBYTE( _WIN32_WINNT_VISTA ), 0 ); +} + +VERSIONHELPERAPI +IsWindowsVistaSP1OrGreater() +{ + return IsWindowsVersionOrGreater( HIBYTE( _WIN32_WINNT_VISTA ), LOBYTE( _WIN32_WINNT_VISTA ), 1 ); +} + +VERSIONHELPERAPI +IsWindowsVistaSP2OrGreater() +{ + return IsWindowsVersionOrGreater( HIBYTE( _WIN32_WINNT_VISTA ), LOBYTE( _WIN32_WINNT_VISTA ), 2 ); +} + +VERSIONHELPERAPI +IsWindows7OrGreater() +{ + return IsWindowsVersionOrGreater( HIBYTE( _WIN32_WINNT_WIN7 ), LOBYTE( _WIN32_WINNT_WIN7 ), 0 ); +} + +VERSIONHELPERAPI +IsWindows7SP1OrGreater() +{ + return IsWindowsVersionOrGreater( HIBYTE( _WIN32_WINNT_WIN7 ), LOBYTE( _WIN32_WINNT_WIN7 ), 1 ); +} + +VERSIONHELPERAPI +IsWindows8OrGreater() +{ + return IsWindowsVersionOrGreater( HIBYTE( _WIN32_WINNT_WIN8 ), LOBYTE( _WIN32_WINNT_WIN8 ), 0 ); +} + +VERSIONHELPERAPI +IsWindows8Point1OrGreater() +{ + return IsWindowsVersionOrGreater( HIBYTE( _WIN32_WINNT_WINBLUE ), LOBYTE( _WIN32_WINNT_WINBLUE ), 0 ); +} + +VERSIONHELPERAPI +IsWindows10OrGreater() +{ + return IsWindowsVersionOrGreater( HIBYTE( _WIN32_WINNT_WIN10 ), LOBYTE( _WIN32_WINNT_WIN10 ), 0 ); +} + + +VERSIONHELPERAPI +IsWindowsServer() +{ + OSVERSIONINFOEXW osvi = { sizeof( osvi ), 0, 0, 0, 0, { 0 }, 0, 0, 0, VER_NT_WORKSTATION }; + DWORDLONG const dwlConditionMask = VerSetConditionMask( 0, VER_PRODUCT_TYPE, VER_EQUAL ); + + return !VerifyVersionInfoW( &osvi, VER_PRODUCT_TYPE, dwlConditionMask ); +} + + +#endif // _VERSIONHELPERS_H_INCLUDED_ + +/* + * system definitions + */ + +#define USING_IOCTL_EX TRUE + +#if (USING_IOCTL_EX) + +// +// New IOCTLs for GUID Partition tabled disks. +// + + +#define IOCTL_DISK_GET_DRIVE_LAYOUT_EXT IOCTL_DISK_GET_DRIVE_LAYOUT_EX +#define IOCTL_DISK_SET_DRIVE_LAYOUT_EXT IOCTL_DISK_SET_DRIVE_LAYOUT_EX +#define PARTITION_INFORMATION_EXT PARTITION_INFORMATION_EX +#define PPARTITION_INFORMATION_EXT PARTITION_INFORMATION_EX * +#define DRIVE_LAYOUT_INFORMATION_EXT DRIVE_LAYOUT_INFORMATION_EX +#define PDRIVE_LAYOUT_INFORMATION_EXT DRIVE_LAYOUT_INFORMATION_EX * + +#else + +#define IOCTL_DISK_GET_DRIVE_LAYOUT_EXT IOCTL_DISK_GET_DRIVE_LAYOUT +#define IOCTL_DISK_SET_DRIVE_LAYOUT_EXT IOCTL_DISK_SET_DRIVE_LAYOUT +typedef PARTITION_INFORMATION PARTITION_INFORMATION_EXT, *PPARTITION_INFORMATION_EXT; +typedef DRIVE_LAYOUT_INFORMATION DRIVE_LAYOUT_INFORMATION_EXT, *PDRIVE_LAYOUT_INFORMATION_EXT; + +#endif // USING_IOCTL_EX + + + +// +// Bus Type +// + +static char* BusType[] = { + "UNKNOWN", // 0x00 + "SCSI", + "ATAPI", + "ATA", + "IEEE 1394", + "SSA", + "FIBRE", + "USB", + "RAID" +}; + +// +// SCSI Device Type +// + +static char* DeviceType[] = { + "Direct Access Device", // 0x00 + "Tape Device", // 0x01 + "Printer Device", // 0x02 + "Processor Device", // 0x03 + "WORM Device", // 0x04 + "CDROM Device", // 0x05 + "Scanner Device", // 0x06 + "Optical Disk", // 0x07 + "Media Changer", // 0x08 + "Comm. Device", // 0x09 + "ASCIT8", // 0x0A + "ASCIT8", // 0x0B + "Array Device", // 0x0C + "Enclosure Device", // 0x0D + "RBC Device", // 0x0E + "Unknown Device" // 0x0F +}; + + +/* + * IFS format callbacks + */ + +// +// Output command +// +typedef struct { + DWORD Lines; + PCHAR Output; +} TEXTOUTPUT, *PTEXTOUTPUT; + +// +// Callback command types +// +typedef enum { + PROGRESS, + DONEWITHSTRUCTURE, + UNKNOWN2, + UNKNOWN3, + UNKNOWN4, + UNKNOWN5, + INSUFFICIENTRIGHTS, + UNKNOWN7, + UNKNOWN8, + UNKNOWN9, + UNKNOWNA, + DONE, + UNKNOWNC, + UNKNOWND, + OUTPUT, + STRUCTUREPROGRESS +} CALLBACKCOMMAND; + +/* + * ext2 codepages + */ + +extern CHAR * gCodepages[]; + +// +// FMIFS callback definition +// +typedef BOOL (__stdcall *PFMIFSCALLBACK)( CALLBACKCOMMAND Command, DWORD SubAction, PVOID ActionInfo ); + +// +// Chkdsk command in FMIFS +// +typedef VOID (__stdcall *PCHKDSK)( PWCHAR DriveRoot, + PWCHAR Format, + BOOL CorrectErrors, + BOOL Verbose, + BOOL CheckOnlyIfDirty, + BOOL ScanDrive, + PVOID Unused2, + PVOID Unused3, + PFMIFSCALLBACK Callback ); + +// +// Format command in FMIFS +// + +// media flags +#define FMIFS_HARDDISK 0xC +#define FMIFS_FLOPPY 0x8 + +typedef VOID (__stdcall *PFORMATEX)( PWCHAR DriveRoot, + DWORD MediaFlag, + PWCHAR Format, + PWCHAR Label, + BOOL QuickFormat, + DWORD ClusterSize, + PFMIFSCALLBACK Callback ); + +#include "..\ext4fsd\include\common.h" + +/* + * structure definitions + */ + +typedef struct _EXT2_PARTITION *PEXT2_PARTITION; + +typedef struct _EXT2_DISK { + + ULONG Magic; + ULONG Null; + CHAR Name[256]; + ULONGLONG Size; + + BOOL bEjected; + BOOL bLoaded; + BOOL IsFile; + UCHAR OrderNo; + UCHAR NumParts; + UCHAR ExtStart; + DISK_GEOMETRY DiskGeometry; + STORAGE_DEVICE_DESCRIPTOR SDD; + STORAGE_ADAPTER_DESCRIPTOR SAD; + PDRIVE_LAYOUT_INFORMATION_EXT Layout; + + PEXT2_PARTITION DataParts; +} EXT2_DISK, *PEXT2_DISK; + +#define EXT2_DISK_MAGIC 'EDSK' +#define EXT2_DISK_NULL_MAGIC 'ENUL' + +typedef struct _EXT2_CDROM { + ULONG Magic[2]; + CHAR Name[256]; + ULONGLONG Size; + + UCHAR OrderNo; + BOOL bLoaded; + BOOL bEjected; + BOOL bIsDVD; + ULONGLONG DrvLetters; + + DISK_GEOMETRY DiskGeometry; + STORAGE_DEVICE_DESCRIPTOR SDD; + STORAGE_ADAPTER_DESCRIPTOR SAD; + EXT2_VOLUME_PROPERTY3 EVP; +} EXT2_CDROM, *PEXT2_CDROM; + +#define EXT2_CDROM_DEVICE_MAGIC 'ECDR' +#define EXT2_CDROM_VOLUME_MAGIC 'ECDV' + + +typedef struct _EXT2_VOLUME { + ULONG Magic; + struct _EXT2_VOLUME * Next; + CHAR Name[REGSTR_VAL_MAX_HCID_LEN]; + ULONGLONG DrvLetters; + BOOL bRecognized; + BOOL bDynamic; + PVOLUME_DISK_EXTENTS Extent; + NT::FILE_FS_DEVICE_INFORMATION FsdInfo; + NT::FILE_FS_SIZE_INFORMATION FssInfo; + union { + NT::FILE_FS_ATTRIBUTE_INFORMATION FsaInfo; + CHAR _tmp_alinged_buf[MAX_PATH]; + }; + CHAR FileSystem[64]; + EXT2_VOLUME_PROPERTY3 EVP; + PEXT2_PARTITION Part; +} EXT2_VOLUME, *PEXT2_VOLUME; + +#define EXT2_VOLUME_MAGIC 'EVOL' + +typedef struct _EXT2_PARTITION { + ULONG Magic; + DWORD PartType; + PEXT2_DISK Disk; + PPARTITION_INFORMATION_EXT Entry; + ULONGLONG DrvLetters; + PEXT2_VOLUME Volume; + UCHAR Number; + CHAR Name[REGSTR_VAL_MAX_HCID_LEN]; +} EXT2_PARTITION; +#define EXT2_PART_MAGIC 'EPRT' + +typedef struct _EXT2_LETTER { + + UCHAR Letter; + BOOL bInvalid; + BOOL bUsed; + BOOL bTemporary; + UINT DrvType; + + PVOLUME_DISK_EXTENTS Extent; + PSTORAGE_DEVICE_NUMBER SDN; + + CHAR SymLink[MAX_PATH]; +} EXT2_LETTER, *PEXT2_LETTER; + + +/* + * global definitions + */ + +extern BOOL g_bAutoMount; +extern ULONG g_nFlps; +extern ULONG g_nDisks; +extern ULONG g_nCdroms; +extern ULONG g_nVols; + +extern EXT2_LETTER drvLetters[26]; +extern EXT2_LETTER drvDigits[10]; + +extern PEXT2_DISK gDisks; +extern PEXT2_CDROM gCdroms; +extern PEXT2_VOLUME gVols; + + +/* + * routines definitions + */ + +char *PartitionString(int type); +char *DriveTypeString(UINT type); +char *DeviceTypeString(DEVICE_TYPE type); +char *BusTypeString(STORAGE_BUS_TYPE BusType); + +BOOL IsWindows2000(); +BOOL IsVistaOrAbove(); + +BOOL CanDoLocalMount(); + +#define EXT2_DESIRED_ACCESS (GENERIC_READ) + +NT::NTSTATUS +Ext2Open( + PCHAR FileName, + PHANDLE Handle, + ULONG DesiredAccess + ); + +VOID +Ext2Close(HANDLE* Handle); + +NT::NTSTATUS +Ext2WriteDisk( + HANDLE Handle, + BOOL IsFile, + ULONG SectorSize, + ULONGLONG Offset, + ULONG Length, + PVOID Buffer + ); + +NT::NTSTATUS +Ext2Read( + IN HANDLE Handle, + IN BOOL IsFile, + IN ULONG SectorSize, + IN ULONGLONG Offset, + IN ULONG Length, + IN PVOID Buffer + ); + +NT::NTSTATUS +Ext2QueryDisk( + HANDLE Handle, + PDISK_GEOMETRY DiskGeometry + ); + +PVOLUME_DISK_EXTENTS +Ext2QueryVolumeExtents( + HANDLE hVolume + ); + +PVOLUME_DISK_EXTENTS +Ext2QueryDriveExtents( + CHAR DriveLetter + ); + +BOOL +Ext2QueryDrvLetter( + PEXT2_LETTER drvLetter + ); + +NT::NTSTATUS +Ext2QueryMediaType( + HANDLE Handle, + PDWORD MediaType + ); + +NT::NTSTATUS +Ext2QueryProperty( + HANDLE Handle, + STORAGE_PROPERTY_ID Id, + PVOID DescBuf, + ULONG DescSize + ); + +PDRIVE_LAYOUT_INFORMATION_EXT +Ext2QueryDriveLayout( + HANDLE Handle, + PUCHAR NumOfParts + ); + +NT::NTSTATUS +Ext2SetDriveLayout( + HANDLE Handle, + PDRIVE_LAYOUT_INFORMATION_EXT Layout + ); + +BOOL +Ext2SetPartitionType( + PEXT2_PARTITION Part, + BYTE Type + ); + +PEXT2_PARTITION +Ext2QueryVolumePartition( + PEXT2_VOLUME Volume + ); + +BOOL +Ext2FlushVolume(CHAR *Device); + +BOOL +Ext2QuerySysConfig(); + +BOOL +Ext2CompareExtents( + PVOLUME_DISK_EXTENTS ext1, + PVOLUME_DISK_EXTENTS ext2 + ); + +ULONGLONG +Ext2QueryVolumeDrvLetters(PEXT2_VOLUME Volume); + +VOID +Ext2QueryVolumeDisks(PEXT2_VOLUME Volume); + +ULONGLONG +Ext2QueryCdromDrvLetters(PEXT2_CDROM Cdrom); + +VOID +Ext2DrvNotify(UCHAR drive, int mount); + +BOOL +Ext2QueryExt2Property ( + HANDLE Handle, + PEXT2_VOLUME_PROPERTY3 EVP + ); + +BOOL +Ext2QueryPerfStat ( + HANDLE Handle, + PEXT2_QUERY_PERFSTAT Stat, + PEXT2_PERF_STATISTICS_V1 *PerfV1, + PEXT2_PERF_STATISTICS_V2 *PerfV2 + ); + +BOOL Ext2IsNullUuid (__u8 * uuid); +BOOL +Ext2CheckVolumeRegistryProperty( + PEXT2_VOLUME_PROPERTY3 EVP + ); + +VOID +Ext2SetDefaultVolumeRegistryProperty( + PEXT2_VOLUME_PROPERTY3 EVP + ); + +VOID +Ext2StorePropertyinRegistry( + PEXT2_VOLUME_PROPERTY3 EVP + ); + +BOOL +Ext2SetExt2Property ( + HANDLE Handle, + PEXT2_VOLUME_PROPERTY3 EVP + ); + +BOOL +Ext2QueryGlobalProperty( + ULONG * ulStartup, + BOOL * bReadonly, + BOOL * bExt3Writable, + CHAR * Codepage, + CHAR * sPrefix, + CHAR * sSuffix, + BOOL * bAutoMount + ); + +INT +Ext2QueryDrvVersion( + CHAR * Version, + CHAR * Date, + CHAR * Time + ); + +BOOL +Ext2SetGlobalProperty ( + ULONG ulStartup, + BOOLEAN bReadonly, + BOOLEAN bExt3Writable, + CHAR * Codepage, + CHAR * sPrefix, + CHAR * sSuffix, + BOOL bAutoMount + ); + +BOOL Ext2IsX64System(); + +BOOL +Ext2IsServiceStarted(); + +BOOL +Ext2StartService(CHAR *service); + +BOOL +Ext2StartExt2Srv(); + +BOOL +Ext2StartExt2Fsd(); + +CString +Ext2SysInformation(); + +BOOL +Ext2LoadDisks(); + +BOOL Ext2ProcessExt2Volumes(); + +VOID +Ext2CleanupDisks(); + +BOOL +Ext2LoadCdroms(); + +VOID +Ext2LoadCdromDrvLetters(); + +VOID +Ext2CleanupCdroms(); + +BOOL +Ext2LoadDiskPartitions(PEXT2_DISK Disk); + +VOID +Ext2LoadAllDiskPartitions(); + +VOID +Ext2MountingVolumes(); + +BOOL +Ext2LoadVolumes(); + +VOID +Ext2LoadAllVolumeDrvLetters(); + +BOOL +Ext2LoadRemovableVolumes(); + +CString +Ext2QueryVolumeLetterStrings( + ULONGLONG letters, + PEXT2_LETTER * first + ); + +VOID +Ext2RefreshVLVI( + CListCtrl *List, + PEXT2_VOLUME chain, + int nItem + ); + +VOID +Ext2InsertVolume( + CListCtrl *List, + PEXT2_VOLUME chain + ); + +VOID +Ext2RefreshVLCD( + CListCtrl *List, + PEXT2_CDROM Cdrom, + int nItem + ); + +VOID +Ext2InsertCdromAsVolume( + CListCtrl *List, + PEXT2_CDROM Cdrom + ); + + +VOID +Ext2RefreshVolumeList(CListCtrl *List); + +VOID +Ext2RefreshDVPT( + CListCtrl* List, + PEXT2_PARTITION Part, + int nItem + ); + +VOID +Ext2InsertPartition( + CListCtrl* List, + PEXT2_DISK Disk, + PEXT2_PARTITION Part + ); + +VOID +Ext2InsertDisk( + CListCtrl *List, + PEXT2_DISK Disk + ); + +VOID +Ext2RefreshDVCM( + CListCtrl *List, + PEXT2_CDROM Cdrom, + int nItem + ); + +VOID +Ext2InsertCdromAsDisk( + CListCtrl *List, + PEXT2_CDROM Cdrom + ); + +VOID +Ext2RefreshDiskList(CListCtrl *List); + +VOID +Ext2CleanupVolumes(); + +VOID +Ext2LoadDrvLetter(PEXT2_LETTER drvLetter, CHAR cLetter); + +VOID +Ext2LoadDrvLetters(); + +VOID +Ext2CleanDrvLetter(PEXT2_LETTER drvLetter); + +VOID +Ext2CleanupDrvLetters(); + +BOOL +Ext2RemoveDrvLetter( + PEXT2_LETTER drvLetter + ); +BOOL +Ext2RemoveDriveLetter(CHAR DrvLetter); + +CHAR +Ext2QueryRegistryMountPoint ( + CHAR * devName + ); + +BOOL +Ext2SetRegistryMountPoint ( + CHAR * dosPath, + CHAR * devName, + BOOL bSet + ); + +BOOL +Ext2InsertMountPoint( + CHAR * volume, + UCHAR drvChar, + BOOL bGlobal + ); + +VOID +Ext2UpdateDrvLetter( + PEXT2_LETTER drvLetter, + PCHAR devPath + ); + +BOOL +Ext2AssignDrvLetter( + PEXT2_LETTER drvLetter, + PCHAR devPath, + BOOL bPermanent + ); + +BOOL Ext2IsDrvLetterAvailable(CHAR drive); +CHAR Ext2MountVolume(CHAR *voldev); + +CHAR Ext2MountVolumeAs(CHAR *voldev, CHAR letter); + +VOID +Ext2RemoveMountPoint( + PEXT2_LETTER drvLetter, + BOOL bPermanent + ); + +BOOL +Ext2SymLinkRemoval(CHAR drvLetter); + +BOOL +Ext2SetVolumeMountPoint ( + CHAR * dosPath, + CHAR * devName + ); + +UCHAR +Ext2QueryMountPoint( + CHAR * volume + ); + +BOOL +Ext2RefreshVolumePoint( + CHAR * volume, + UCHAR drvChar + ); + +BOOL +Ext2NotifyVolumePoint( + PEXT2_VOLUME volume, + UCHAR drvChar + ); + +BOOL +Ext2VolumeArrivalNotify(PCHAR VolumePath); + +BOOL +Ext2SetAppAutorun(BOOL bInstall); + +BOOL Ext2RunMgrForCurrentUser(); + +int +Ext2SetManagerAsService(BOOL bInstall); + +extern BOOL g_bAutoRemoveDeadLetters; + +VOID +Ext2AddLetterMask(ULONGLONG LetterMask); + +VOID +Ext2AutoRemoveDeadLetters(); + +BOOL +Ext2RemoveDosSymLink(CHAR drvChar); + +BOOL Ext2DismountVolume(CHAR *voldev); + +#ifdef __cplusplus +extern "C" { +#endif + +BOOL WINAPI +WTSQueryUserToken( + ULONG SessionId, + PHANDLE phToken + ); + +BOOL WINAPI ConvertStringSidToSidA( + LPCTSTR StringSid, + PSID* Sid +); + +WINUSERAPI +HWND +WINAPI +GetShellWindow( + VOID); + +#ifdef __cplusplus +} +#endif + +#endif // _ENUM_DISK_INCLUDE_ diff --git a/Ext2Mgr/ext2fs.h b/Ext2Mgr/ext2fs.h index 5f44828..5551850 100644 --- a/Ext2Mgr/ext2fs.h +++ b/Ext2Mgr/ext2fs.h @@ -1,584 +1,584 @@ -/* - * linux/include/linux/ext2_fs.h - * - * Copyright (C) 1992, 1993, 1994, 1995 - * Remy Card (card@masi.ibp.fr) - * Laboratoire MASI - Institut Blaise Pascal - * Universite Pierre et Marie Curie (Paris VI) - * - * from - * - * linux/include/linux/minix_fs.h - * - * Copyright f(C) 1991, 1992 Linus Torvalds - */ - -#ifndef _LINUX_EXT2_FS_H -#define _LINUX_EXT2_FS_H - -#include "types.h" /* Changed from linux/types.h */ - -/* - * The second extended filesystem constants/structures - */ - -/* - * Define EXT2FS_DEBUG to produce debug messages - */ -#undef EXT2FS_DEBUG - -/* - * Define EXT2_PREALLOCATE to preallocate data blocks for expanding files - */ -#define EXT2_PREALLOCATE -#define EXT2_DEFAULT_PREALLOC_BLOCKS 8 - -/* - * The second extended file system version - */ -#define EXT2FS_DATE "95/08/09" -#define EXT2FS_VERSION "0.5b" - -/* - * Special inodes numbers - */ -#define EXT2_BAD_INO 1 /* Bad blocks inode */ -#define EXT2_ROOT_INO 2 /* Root inode */ -#define EXT2_ACL_IDX_INO 3 /* ACL inode */ -#define EXT2_ACL_DATA_INO 4 /* ACL inode */ -#define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */ -#define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */ -#define EXT2_RESIZE_INO 7 /* Reserved group descriptors inode */ -#define EXT2_JOURNAL_INO 8 /* Journal inode */ - -/* First non-reserved inode for old ext2 filesystems */ -#define EXT2_GOOD_OLD_FIRST_INO 11 - -/* - * The second extended file system magic number - */ -#define EXT2_SUPER_MAGIC 0xEF53 - -/* - * Maximal count of links to a file - */ -#define EXT2_LINK_MAX 32000 - -/* - * Macro-instructions used to manage several block sizes - */ -#define EXT2_MIN_BLOCK_SIZE 512 -#define EXT2_MAX_BLOCK_SIZE 4096 -#define EXT2_MIN_BLOCK_LOG_SIZE 10 -#ifdef __KERNEL__ -# define EXT2_BLOCK_SIZE(s) ((s)->s_blocksize) -#else -# define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size) -#endif -#define EXT2_ACLE_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_acl_entry)) -#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (__u32)) -#ifdef __KERNEL__ -# define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits) -#else -# define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10) -#endif -#ifdef __KERNEL__ -#define EXT2_ADDR_PER_BLOCK_BITS(s) ((s)->u.ext2_sb.s_addr_per_block_bits) -#define EXT2_INODE_SIZE(s) ((s)->u.ext2_sb.s_inode_size) -#define EXT2_FIRST_INO(s) ((s)->u.ext2_sb.s_first_ino) -#else -#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \ - EXT2_GOOD_OLD_INODE_SIZE : \ - (s)->s_inode_size) -#define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \ - EXT2_GOOD_OLD_FIRST_INO : \ - (s)->s_first_ino) -#endif - -/* - * Macro-instructions used to manage fragments - */ -#define EXT2_MIN_FRAG_SIZE 1024 -#define EXT2_MAX_FRAG_SIZE 4096 -#define EXT2_MIN_FRAG_LOG_SIZE 10 -#ifdef __KERNEL__ -# define EXT2_FRAG_SIZE(s) ((s)->u.ext2_sb.s_frag_size) -# define EXT2_FRAGS_PER_BLOCK(s) ((s)->u.ext2_sb.s_frags_per_block) -#else -# define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size) -# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s)) -#endif - -/* - * ACL structures - */ -struct ext2_acl_header /* Header of Access Control Lists */ -{ - __u32 aclh_size; - __u32 aclh_file_count; - __u32 aclh_acle_count; - __u32 aclh_first_acle; -}; - -struct ext2_acl_entry /* Access Control List Entry */ -{ - __u32 acle_size; - __u16 acle_perms; /* Access permissions */ - __u16 acle_type; /* Type of entry */ - __u16 acle_tag; /* User or group identity */ - __u16 acle_pad1; - __u32 acle_next; /* Pointer on next entry for the */ - /* same inode or on next free entry */ -}; - -/* - * Structure of a blocks group descriptor - */ -struct ext2_group_desc -{ - __u32 bg_block_bitmap; /* Blocks bitmap block */ - __u32 bg_inode_bitmap; /* Inodes bitmap block */ - __u32 bg_inode_table; /* Inodes table block */ - __u16 bg_free_blocks_count; /* Free blocks count */ - __u16 bg_free_inodes_count; /* Free inodes count */ - __u16 bg_used_dirs_count; /* Directories count */ - __u16 bg_pad; - __u32 bg_reserved[3]; -}; - -/* - * Data structures used by the directory indexing feature - * - * Note: all of the multibyte integer fields are little endian. - */ - -/* - * Note: dx_root_info is laid out so that if it should somehow get - * overlaid by a dirent the two low bits of the hash version will be - * zero. Therefore, the hash version mod 4 should never be 0. - * Sincerely, the paranoia department. - */ -struct ext2_dx_root_info { - __u32 reserved_zero; - __u8 hash_version; /* 0 now, 1 at release */ - __u8 info_length; /* 8 */ - __u8 indirect_levels; - __u8 unused_flags; -}; - -struct ext2_dx_entry { - __u32 hash; - __u32 block; -}; - -struct ext2_dx_countlimit { - __u16 limit; - __u16 count; -}; - - -/* - * Macro-instructions used to manage group descriptors - */ -#ifdef __KERNEL__ -# define EXT2_BLOCKS_PER_GROUP(s) ((s)->u.ext2_sb.s_blocks_per_group) -# define EXT2_DESC_PER_BLOCK(s) ((s)->u.ext2_sb.s_desc_per_block) -# define EXT2_INODES_PER_GROUP(s) ((s)->u.ext2_sb.s_inodes_per_group) -# define EXT2_DESC_PER_BLOCK_BITS(s) ((s)->u.ext2_sb.s_desc_per_block_bits) -#else -# define EXT2_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group) -# define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc)) -# define EXT2_INODES_PER_GROUP(s) ((s)->s_inodes_per_group) -#endif - -/* - * Constants relative to the data blocks - */ -#define EXT2_NDIR_BLOCKS 12 -#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS -#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1) -#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1) -#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1) - -/* - * Inode flags - */ -#define EXT2_SECRM_FL 0x00000001 /* Secure deletion */ -#define EXT2_UNRM_FL 0x00000002 /* Undelete */ -#define EXT2_COMPR_FL 0x00000004 /* Compress file */ -#define EXT2_SYNC_FL 0x00000008 /* Synchronous updates */ -#define EXT2_IMMUTABLE_FL 0x00000010 /* Immutable file */ -#define EXT2_APPEND_FL 0x00000020 /* writes to file may only append */ -#define EXT2_NODUMP_FL 0x00000040 /* do not dump file */ -#define EXT2_NOATIME_FL 0x00000080 /* do not update atime */ -/* Reserved for compression usage... */ -#define EXT2_DIRTY_FL 0x00000100 -#define EXT2_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */ -#define EXT2_NOCOMPR_FL 0x00000400 /* Access raw compressed data */ -#define EXT2_ECOMPR_FL 0x00000800 /* Compression error */ -/* End compression flags --- maybe not all used */ -#define EXT2_BTREE_FL 0x00001000 /* btree format dir */ -#define EXT2_INDEX_FL 0x00001000 /* hash-indexed directory */ -#define EXT2_IMAGIC_FL 0x00002000 -#define EXT3_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */ -#define EXT2_NOTAIL_FL 0x00008000 /* file tail should not be merged */ -#define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */ - -#define EXT2_FL_USER_VISIBLE 0x0000DFFF /* User visible flags */ -#define EXT2_FL_USER_MODIFIABLE 0x000080FF /* User modifiable flags */ - -/* - * ioctl commands - */ -#define EXT2_IOC_GETFLAGS _IOR('f', 1, long) -#define EXT2_IOC_SETFLAGS _IOW('f', 2, long) -#define EXT2_IOC_GETVERSION _IOR('v', 1, long) -#define EXT2_IOC_SETVERSION _IOW('v', 2, long) - -/* - * Structure of an inode on the disk - */ -struct ext2_inode { - __u16 i_mode; /* File mode */ - __u16 i_uid; /* Low 16 bits of Owner Uid */ - __u32 i_size; /* Size in bytes */ - __u32 i_atime; /* Access time */ - __u32 i_ctime; /* Creation time */ - __u32 i_mtime; /* Modification time */ - __u32 i_dtime; /* Deletion Time */ - __u16 i_gid; /* Low 16 bits of Group Id */ - __u16 i_links_count; /* Links count */ - __u32 i_blocks; /* Blocks count */ - __u32 i_flags; /* File flags */ - union { - struct { - __u32 l_i_reserved1; - } linux1; - struct { - __u32 h_i_translator; - } hurd1; - struct { - __u32 m_i_reserved1; - } masix1; - } osd1; /* OS dependent 1 */ - __u32 i_block[EXT2_N_BLOCKS];/* Pointers to blocks */ - __u32 i_generation; /* File version (for NFS) */ - __u32 i_file_acl; /* File ACL */ - __u32 i_dir_acl; /* Directory ACL */ - __u32 i_faddr; /* Fragment address */ - union { - struct { - __u8 l_i_frag; /* Fragment number */ - __u8 l_i_fsize; /* Fragment size */ - __u16 i_pad1; - __u16 l_i_uid_high; /* these 2 fields */ - __u16 l_i_gid_high; /* were reserved2[0] */ - __u32 l_i_reserved2; - } linux2; - struct { - __u8 h_i_frag; /* Fragment number */ - __u8 h_i_fsize; /* Fragment size */ - __u16 h_i_mode_high; - __u16 h_i_uid_high; - __u16 h_i_gid_high; - __u32 h_i_author; - } hurd2; - struct { - __u8 m_i_frag; /* Fragment number */ - __u8 m_i_fsize; /* Fragment size */ - __u16 m_pad1; - __u32 m_i_reserved2[2]; - } masix2; - } osd2; /* OS dependent 2 */ -}; - -#define i_size_high i_dir_acl - -#if defined(__KERNEL__) || defined(__linux__) -#define i_reserved1 osd1.linux1.l_i_reserved1 -#define i_frag osd2.linux2.l_i_frag -#define i_fsize osd2.linux2.l_i_fsize -#define i_uid_low i_uid -#define i_gid_low i_gid -#define i_uid_high osd2.linux2.l_i_uid_high -#define i_gid_high osd2.linux2.l_i_gid_high -#define i_reserved2 osd2.linux2.l_i_reserved2 - -#elif defined(__GNU__) - -#define i_translator osd1.hurd1.h_i_translator -#define i_frag osd2.hurd2.h_i_frag; -#define i_fsize osd2.hurd2.h_i_fsize; -#define i_uid_high osd2.hurd2.h_i_uid_high -#define i_gid_high osd2.hurd2.h_i_gid_high -#define i_author osd2.hurd2.h_i_author - -#elif defined(__masix__) - -#define i_reserved1 osd1.masix1.m_i_reserved1 -#define i_frag osd2.masix2.m_i_frag -#define i_fsize osd2.masix2.m_i_fsize -#define i_reserved2 osd2.masix2.m_i_reserved2 - -#endif /* defined(__KERNEL) || defined(__linux__) */ - -/* - * File system states - */ -#define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */ -#define EXT2_ERROR_FS 0x0002 /* Errors detected */ - -/* - * Mount flags - */ -#define EXT2_MOUNT_CHECK 0x0001 /* Do mount-time checks */ -#define EXT2_MOUNT_GRPID 0x0004 /* Create files with directory's group */ -#define EXT2_MOUNT_DEBUG 0x0008 /* Some debugging messages */ -#define EXT2_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */ -#define EXT2_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */ -#define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */ -#define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */ -#define EXT2_MOUNT_NO_UID32 0x0200 /* Disable 32-bit UIDs */ - -#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt -#define set_opt(o, opt) o |= EXT2_MOUNT_##opt -#define test_opt(sb, opt) ((sb)->u.ext2_sb.s_mount_opt & \ - EXT2_MOUNT_##opt) -/* - * Maximal mount counts between two filesystem checks - */ -#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */ -#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */ - -/* - * Behaviour when detecting errors - */ -#define EXT2_ERRORS_CONTINUE 1 /* Continue execution */ -#define EXT2_ERRORS_RO 2 /* Remount fs read-only */ -#define EXT2_ERRORS_PANIC 3 /* Panic */ -#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE - -/* - * Structure of the super block - */ -struct ext2_super_block { - __u32 s_inodes_count; /* Inodes count */ - __u32 s_blocks_count; /* Blocks count */ - __u32 s_r_blocks_count; /* Reserved blocks count */ - __u32 s_free_blocks_count; /* Free blocks count */ - __u32 s_free_inodes_count; /* Free inodes count */ - __u32 s_first_data_block; /* First Data Block */ - __u32 s_log_block_size; /* Block size */ - __s32 s_log_frag_size; /* Fragment size */ - __u32 s_blocks_per_group; /* # Blocks per group */ - __u32 s_frags_per_group; /* # Fragments per group */ - __u32 s_inodes_per_group; /* # Inodes per group */ - __u32 s_mtime; /* Mount time */ - __u32 s_wtime; /* Write time */ - __u16 s_mnt_count; /* Mount count */ - __s16 s_max_mnt_count; /* Maximal mount count */ - __u16 s_magic; /* Magic signature */ - __u16 s_state; /* File system state */ - __u16 s_errors; /* Behaviour when detecting errors */ - __u16 s_minor_rev_level; /* minor revision level */ - __u32 s_lastcheck; /* time of last check */ - __u32 s_checkinterval; /* max. time between checks */ - __u32 s_creator_os; /* OS */ - __u32 s_rev_level; /* Revision level */ - __u16 s_def_resuid; /* Default uid for reserved blocks */ - __u16 s_def_resgid; /* Default gid for reserved blocks */ - /* - * These fields are for EXT2_DYNAMIC_REV superblocks only. - * - * Note: the difference between the compatible feature set and - * the incompatible feature set is that if there is a bit set - * in the incompatible feature set that the kernel doesn't - * know about, it should refuse to mount the filesystem. - * - * e2fsck's requirements are more strict; if it doesn't know - * about a feature in either the compatible or incompatible - * feature set, it must abort and not try to meddle with - * things it doesn't understand... - */ - __u32 s_first_ino; /* First non-reserved inode */ - __u16 s_inode_size; /* size of inode structure */ - __u16 s_block_group_nr; /* block group # of this superblock */ - __u32 s_feature_compat; /* compatible feature set */ - __u32 s_feature_incompat; /* incompatible feature set */ - __u32 s_feature_ro_compat; /* readonly-compatible feature set */ - __u8 s_uuid[16]; /* 128-bit uuid for volume */ - char s_volume_name[16]; /* volume name */ - char s_last_mounted[64]; /* directory where last mounted */ - __u32 s_algorithm_usage_bitmap; /* For compression */ - /* - * Performance hints. Directory preallocation should only - * happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on. - */ - __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/ - __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */ - __u16 s_padding1; - /* - * Journaling support valid if EXT2_FEATURE_COMPAT_HAS_JOURNAL set. - */ - __u8 s_journal_uuid[16]; /* uuid of journal superblock */ - __u32 s_journal_inum; /* inode number of journal file */ - __u32 s_journal_dev; /* device number of journal file */ - __u32 s_last_orphan; /* start of list of inodes to delete */ - - __u32 s_reserved[197]; /* Padding to the end of the block */ -}; - -#ifdef __KERNEL__ -#define EXT2_SB(sb) (&((sb)->u.ext2_sb)) -#else -/* Assume that user mode programs are passing in an ext2fs superblock, not - * a kernel struct super_block. This will allow us to call the feature-test - * macros from user land. */ -#define EXT2_SB(sb) (sb) -#endif - -/* - * Codes for operating systems - */ -#define EXT2_OS_LINUX 0 -#define EXT2_OS_HURD 1 -#define EXT2_OS_MASIX 2 -#define EXT2_OS_FREEBSD 3 -#define EXT2_OS_LITES 4 -#define EXT2_OS_WINNT 5 - -/* - * Revision levels - */ -#define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */ -#define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */ - -#define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV -#define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV - -#define EXT2_GOOD_OLD_INODE_SIZE 128 - -/* - * Feature set definitions - */ - -#define EXT2_HAS_COMPAT_FEATURE(sb,mask) \ - ( EXT2_SB(sb)->s_feature_compat & (mask) ) -#define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \ - ( EXT2_SB(sb)->s_feature_ro_compat & (mask) ) -#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \ - ( EXT2_SB(sb)->s_feature_incompat & (mask) ) - -#define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001 -#define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002 -#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004 -#define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008 -#define EXT2_FEATURE_COMPAT_RESIZE_INODE 0x0010 -#define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020 - -#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001 -#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002 -#define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 - -#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001 -#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002 -#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */ -#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */ - -#define EXT2_FEATURE_COMPAT_SUPP 0 -#define EXT2_FEATURE_INCOMPAT_SUPP EXT2_FEATURE_INCOMPAT_FILETYPE -#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \ - EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \ - EXT2_FEATURE_RO_COMPAT_BTREE_DIR) - -/* - * Default values for user and/or group using reserved blocks - */ -#define EXT2_DEF_RESUID 0 -#define EXT2_DEF_RESGID 0 - -/* - * Structure of a directory entry - */ -#define EXT2_NAME_LEN 255 - -struct ext2_dir_entry { - __u32 inode; /* Inode number */ - __u16 rec_len; /* Directory entry length */ - __u16 name_len; /* Name length */ - char name[EXT2_NAME_LEN]; /* File name */ -}; - -/* - * The new version of the directory entry. Since EXT2 structures are - * stored in intel byte order, and the name_len field could never be - * bigger than 255 chars, it's safe to reclaim the extra byte for the - * file_type field. - */ -struct ext2_dir_entry_2 { - __u32 inode; /* Inode number */ - __u16 rec_len; /* Directory entry length */ - __u8 name_len; /* Name length */ - __u8 file_type; - char name[EXT2_NAME_LEN]; /* File name */ -}; - -/* - * Ext2 directory file types. Only the low 3 bits are used. The - * other bits are reserved for now. - */ -#define EXT2_FT_UNKNOWN 0 -#define EXT2_FT_REG_FILE 1 -#define EXT2_FT_DIR 2 -#define EXT2_FT_CHRDEV 3 -#define EXT2_FT_BLKDEV 4 -#define EXT2_FT_FIFO 5 -#define EXT2_FT_SOCK 6 -#define EXT2_FT_SYMLINK 7 - -#define EXT2_FT_MAX 8 - -/* - * EXT2_DIR_PAD defines the directory entries boundaries - * - * NOTE: It must be a multiple of 4 - */ -#define EXT2_DIR_PAD 4 -#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1) -#define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \ - ~EXT2_DIR_ROUND) - - - -/* - * SWAP information settings - */ - -#define SWAP_HEADER_OFFSET 0 -#define SWAP_HEADER_MAGIC_V1 "SWAP-SPACE" -#define SWAP_HEADER_MAGIC_V2 "SWAPSPACE2" - -/* The following is a subset of linux/include/linux/swap.h (2.2.6) */ - -union swap_header { - struct - { - char reserved[PAGE_SIZE - 10]; - char magic[10]; - } magic; - struct - { - char bootbits[1024]; /* Space for disklabel etc. */ - unsigned int version; - unsigned int last_page; - unsigned int nr_badpages; - unsigned int padding[125]; - unsigned int badpages[1]; - } info; -}; - -/* super block */ -#define SUPER_BLOCK_OFFSET (0x400) -#define SUPER_BLOCK_SIZE (0x400) - -#endif /* _LINUX_EXT2_FS_H */ +/* + * linux/include/linux/ext2_fs.h + * + * Copyright (C) 1992, 1993, 1994, 1995 + * Remy Card (card@masi.ibp.fr) + * Laboratoire MASI - Institut Blaise Pascal + * Universite Pierre et Marie Curie (Paris VI) + * + * from + * + * linux/include/linux/minix_fs.h + * + * Copyright f(C) 1991, 1992 Linus Torvalds + */ + +#ifndef _LINUX_EXT2_FS_H +#define _LINUX_EXT2_FS_H + +#include "types.h" /* Changed from linux/types.h */ + +/* + * The second extended filesystem constants/structures + */ + +/* + * Define EXT2FS_DEBUG to produce debug messages + */ +#undef EXT2FS_DEBUG + +/* + * Define EXT2_PREALLOCATE to preallocate data blocks for expanding files + */ +#define EXT2_PREALLOCATE +#define EXT2_DEFAULT_PREALLOC_BLOCKS 8 + +/* + * The second extended file system version + */ +#define EXT2FS_DATE "95/08/09" +#define EXT2FS_VERSION "0.5b" + +/* + * Special inodes numbers + */ +#define EXT2_BAD_INO 1 /* Bad blocks inode */ +#define EXT2_ROOT_INO 2 /* Root inode */ +#define EXT2_ACL_IDX_INO 3 /* ACL inode */ +#define EXT2_ACL_DATA_INO 4 /* ACL inode */ +#define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */ +#define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */ +#define EXT2_RESIZE_INO 7 /* Reserved group descriptors inode */ +#define EXT2_JOURNAL_INO 8 /* Journal inode */ + +/* First non-reserved inode for old ext2 filesystems */ +#define EXT2_GOOD_OLD_FIRST_INO 11 + +/* + * The second extended file system magic number + */ +#define EXT2_SUPER_MAGIC 0xEF53 + +/* + * Maximal count of links to a file + */ +#define EXT2_LINK_MAX 32000 + +/* + * Macro-instructions used to manage several block sizes + */ +#define EXT2_MIN_BLOCK_SIZE 512 +#define EXT2_MAX_BLOCK_SIZE 4096 +#define EXT2_MIN_BLOCK_LOG_SIZE 10 +#ifdef __KERNEL__ +# define EXT2_BLOCK_SIZE(s) ((s)->s_blocksize) +#else +# define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size) +#endif +#define EXT2_ACLE_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_acl_entry)) +#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (__u32)) +#ifdef __KERNEL__ +# define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits) +#else +# define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10) +#endif +#ifdef __KERNEL__ +#define EXT2_ADDR_PER_BLOCK_BITS(s) ((s)->u.ext2_sb.s_addr_per_block_bits) +#define EXT2_INODE_SIZE(s) ((s)->u.ext2_sb.s_inode_size) +#define EXT2_FIRST_INO(s) ((s)->u.ext2_sb.s_first_ino) +#else +#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \ + EXT2_GOOD_OLD_INODE_SIZE : \ + (s)->s_inode_size) +#define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \ + EXT2_GOOD_OLD_FIRST_INO : \ + (s)->s_first_ino) +#endif + +/* + * Macro-instructions used to manage fragments + */ +#define EXT2_MIN_FRAG_SIZE 1024 +#define EXT2_MAX_FRAG_SIZE 4096 +#define EXT2_MIN_FRAG_LOG_SIZE 10 +#ifdef __KERNEL__ +# define EXT2_FRAG_SIZE(s) ((s)->u.ext2_sb.s_frag_size) +# define EXT2_FRAGS_PER_BLOCK(s) ((s)->u.ext2_sb.s_frags_per_block) +#else +# define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size) +# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s)) +#endif + +/* + * ACL structures + */ +struct ext2_acl_header /* Header of Access Control Lists */ +{ + __u32 aclh_size; + __u32 aclh_file_count; + __u32 aclh_acle_count; + __u32 aclh_first_acle; +}; + +struct ext2_acl_entry /* Access Control List Entry */ +{ + __u32 acle_size; + __u16 acle_perms; /* Access permissions */ + __u16 acle_type; /* Type of entry */ + __u16 acle_tag; /* User or group identity */ + __u16 acle_pad1; + __u32 acle_next; /* Pointer on next entry for the */ + /* same inode or on next free entry */ +}; + +/* + * Structure of a blocks group descriptor + */ +struct ext2_group_desc +{ + __u32 bg_block_bitmap; /* Blocks bitmap block */ + __u32 bg_inode_bitmap; /* Inodes bitmap block */ + __u32 bg_inode_table; /* Inodes table block */ + __u16 bg_free_blocks_count; /* Free blocks count */ + __u16 bg_free_inodes_count; /* Free inodes count */ + __u16 bg_used_dirs_count; /* Directories count */ + __u16 bg_pad; + __u32 bg_reserved[3]; +}; + +/* + * Data structures used by the directory indexing feature + * + * Note: all of the multibyte integer fields are little endian. + */ + +/* + * Note: dx_root_info is laid out so that if it should somehow get + * overlaid by a dirent the two low bits of the hash version will be + * zero. Therefore, the hash version mod 4 should never be 0. + * Sincerely, the paranoia department. + */ +struct ext2_dx_root_info { + __u32 reserved_zero; + __u8 hash_version; /* 0 now, 1 at release */ + __u8 info_length; /* 8 */ + __u8 indirect_levels; + __u8 unused_flags; +}; + +struct ext2_dx_entry { + __u32 hash; + __u32 block; +}; + +struct ext2_dx_countlimit { + __u16 limit; + __u16 count; +}; + + +/* + * Macro-instructions used to manage group descriptors + */ +#ifdef __KERNEL__ +# define EXT2_BLOCKS_PER_GROUP(s) ((s)->u.ext2_sb.s_blocks_per_group) +# define EXT2_DESC_PER_BLOCK(s) ((s)->u.ext2_sb.s_desc_per_block) +# define EXT2_INODES_PER_GROUP(s) ((s)->u.ext2_sb.s_inodes_per_group) +# define EXT2_DESC_PER_BLOCK_BITS(s) ((s)->u.ext2_sb.s_desc_per_block_bits) +#else +# define EXT2_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group) +# define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc)) +# define EXT2_INODES_PER_GROUP(s) ((s)->s_inodes_per_group) +#endif + +/* + * Constants relative to the data blocks + */ +#define EXT2_NDIR_BLOCKS 12 +#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS +#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1) +#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1) +#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1) + +/* + * Inode flags + */ +#define EXT2_SECRM_FL 0x00000001 /* Secure deletion */ +#define EXT2_UNRM_FL 0x00000002 /* Undelete */ +#define EXT2_COMPR_FL 0x00000004 /* Compress file */ +#define EXT2_SYNC_FL 0x00000008 /* Synchronous updates */ +#define EXT2_IMMUTABLE_FL 0x00000010 /* Immutable file */ +#define EXT2_APPEND_FL 0x00000020 /* writes to file may only append */ +#define EXT2_NODUMP_FL 0x00000040 /* do not dump file */ +#define EXT2_NOATIME_FL 0x00000080 /* do not update atime */ +/* Reserved for compression usage... */ +#define EXT2_DIRTY_FL 0x00000100 +#define EXT2_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */ +#define EXT2_NOCOMPR_FL 0x00000400 /* Access raw compressed data */ +#define EXT2_ECOMPR_FL 0x00000800 /* Compression error */ +/* End compression flags --- maybe not all used */ +#define EXT2_BTREE_FL 0x00001000 /* btree format dir */ +#define EXT2_INDEX_FL 0x00001000 /* hash-indexed directory */ +#define EXT2_IMAGIC_FL 0x00002000 +#define EXT3_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */ +#define EXT2_NOTAIL_FL 0x00008000 /* file tail should not be merged */ +#define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */ + +#define EXT2_FL_USER_VISIBLE 0x0000DFFF /* User visible flags */ +#define EXT2_FL_USER_MODIFIABLE 0x000080FF /* User modifiable flags */ + +/* + * ioctl commands + */ +#define EXT2_IOC_GETFLAGS _IOR('f', 1, long) +#define EXT2_IOC_SETFLAGS _IOW('f', 2, long) +#define EXT2_IOC_GETVERSION _IOR('v', 1, long) +#define EXT2_IOC_SETVERSION _IOW('v', 2, long) + +/* + * Structure of an inode on the disk + */ +struct ext2_inode { + __u16 i_mode; /* File mode */ + __u16 i_uid; /* Low 16 bits of Owner Uid */ + __u32 i_size; /* Size in bytes */ + __u32 i_atime; /* Access time */ + __u32 i_ctime; /* Creation time */ + __u32 i_mtime; /* Modification time */ + __u32 i_dtime; /* Deletion Time */ + __u16 i_gid; /* Low 16 bits of Group Id */ + __u16 i_links_count; /* Links count */ + __u32 i_blocks; /* Blocks count */ + __u32 i_flags; /* File flags */ + union { + struct { + __u32 l_i_reserved1; + } linux1; + struct { + __u32 h_i_translator; + } hurd1; + struct { + __u32 m_i_reserved1; + } masix1; + } osd1; /* OS dependent 1 */ + __u32 i_block[EXT2_N_BLOCKS];/* Pointers to blocks */ + __u32 i_generation; /* File version (for NFS) */ + __u32 i_file_acl; /* File ACL */ + __u32 i_dir_acl; /* Directory ACL */ + __u32 i_faddr; /* Fragment address */ + union { + struct { + __u8 l_i_frag; /* Fragment number */ + __u8 l_i_fsize; /* Fragment size */ + __u16 i_pad1; + __u16 l_i_uid_high; /* these 2 fields */ + __u16 l_i_gid_high; /* were reserved2[0] */ + __u32 l_i_reserved2; + } linux2; + struct { + __u8 h_i_frag; /* Fragment number */ + __u8 h_i_fsize; /* Fragment size */ + __u16 h_i_mode_high; + __u16 h_i_uid_high; + __u16 h_i_gid_high; + __u32 h_i_author; + } hurd2; + struct { + __u8 m_i_frag; /* Fragment number */ + __u8 m_i_fsize; /* Fragment size */ + __u16 m_pad1; + __u32 m_i_reserved2[2]; + } masix2; + } osd2; /* OS dependent 2 */ +}; + +#define i_size_high i_dir_acl + +#if defined(__KERNEL__) || defined(__linux__) +#define i_reserved1 osd1.linux1.l_i_reserved1 +#define i_frag osd2.linux2.l_i_frag +#define i_fsize osd2.linux2.l_i_fsize +#define i_uid_low i_uid +#define i_gid_low i_gid +#define i_uid_high osd2.linux2.l_i_uid_high +#define i_gid_high osd2.linux2.l_i_gid_high +#define i_reserved2 osd2.linux2.l_i_reserved2 + +#elif defined(__GNU__) + +#define i_translator osd1.hurd1.h_i_translator +#define i_frag osd2.hurd2.h_i_frag; +#define i_fsize osd2.hurd2.h_i_fsize; +#define i_uid_high osd2.hurd2.h_i_uid_high +#define i_gid_high osd2.hurd2.h_i_gid_high +#define i_author osd2.hurd2.h_i_author + +#elif defined(__masix__) + +#define i_reserved1 osd1.masix1.m_i_reserved1 +#define i_frag osd2.masix2.m_i_frag +#define i_fsize osd2.masix2.m_i_fsize +#define i_reserved2 osd2.masix2.m_i_reserved2 + +#endif /* defined(__KERNEL) || defined(__linux__) */ + +/* + * File system states + */ +#define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */ +#define EXT2_ERROR_FS 0x0002 /* Errors detected */ + +/* + * Mount flags + */ +#define EXT2_MOUNT_CHECK 0x0001 /* Do mount-time checks */ +#define EXT2_MOUNT_GRPID 0x0004 /* Create files with directory's group */ +#define EXT2_MOUNT_DEBUG 0x0008 /* Some debugging messages */ +#define EXT2_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */ +#define EXT2_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */ +#define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */ +#define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */ +#define EXT2_MOUNT_NO_UID32 0x0200 /* Disable 32-bit UIDs */ + +#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt +#define set_opt(o, opt) o |= EXT2_MOUNT_##opt +#define test_opt(sb, opt) ((sb)->u.ext2_sb.s_mount_opt & \ + EXT2_MOUNT_##opt) +/* + * Maximal mount counts between two filesystem checks + */ +#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */ +#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */ + +/* + * Behaviour when detecting errors + */ +#define EXT2_ERRORS_CONTINUE 1 /* Continue execution */ +#define EXT2_ERRORS_RO 2 /* Remount fs read-only */ +#define EXT2_ERRORS_PANIC 3 /* Panic */ +#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE + +/* + * Structure of the super block + */ +struct ext2_super_block { + __u32 s_inodes_count; /* Inodes count */ + __u32 s_blocks_count; /* Blocks count */ + __u32 s_r_blocks_count; /* Reserved blocks count */ + __u32 s_free_blocks_count; /* Free blocks count */ + __u32 s_free_inodes_count; /* Free inodes count */ + __u32 s_first_data_block; /* First Data Block */ + __u32 s_log_block_size; /* Block size */ + __s32 s_log_frag_size; /* Fragment size */ + __u32 s_blocks_per_group; /* # Blocks per group */ + __u32 s_frags_per_group; /* # Fragments per group */ + __u32 s_inodes_per_group; /* # Inodes per group */ + __u32 s_mtime; /* Mount time */ + __u32 s_wtime; /* Write time */ + __u16 s_mnt_count; /* Mount count */ + __s16 s_max_mnt_count; /* Maximal mount count */ + __u16 s_magic; /* Magic signature */ + __u16 s_state; /* File system state */ + __u16 s_errors; /* Behaviour when detecting errors */ + __u16 s_minor_rev_level; /* minor revision level */ + __u32 s_lastcheck; /* time of last check */ + __u32 s_checkinterval; /* max. time between checks */ + __u32 s_creator_os; /* OS */ + __u32 s_rev_level; /* Revision level */ + __u16 s_def_resuid; /* Default uid for reserved blocks */ + __u16 s_def_resgid; /* Default gid for reserved blocks */ + /* + * These fields are for EXT2_DYNAMIC_REV superblocks only. + * + * Note: the difference between the compatible feature set and + * the incompatible feature set is that if there is a bit set + * in the incompatible feature set that the kernel doesn't + * know about, it should refuse to mount the filesystem. + * + * e2fsck's requirements are more strict; if it doesn't know + * about a feature in either the compatible or incompatible + * feature set, it must abort and not try to meddle with + * things it doesn't understand... + */ + __u32 s_first_ino; /* First non-reserved inode */ + __u16 s_inode_size; /* size of inode structure */ + __u16 s_block_group_nr; /* block group # of this superblock */ + __u32 s_feature_compat; /* compatible feature set */ + __u32 s_feature_incompat; /* incompatible feature set */ + __u32 s_feature_ro_compat; /* readonly-compatible feature set */ + __u8 s_uuid[16]; /* 128-bit uuid for volume */ + char s_volume_name[16]; /* volume name */ + char s_last_mounted[64]; /* directory where last mounted */ + __u32 s_algorithm_usage_bitmap; /* For compression */ + /* + * Performance hints. Directory preallocation should only + * happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on. + */ + __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/ + __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */ + __u16 s_padding1; + /* + * Journaling support valid if EXT2_FEATURE_COMPAT_HAS_JOURNAL set. + */ + __u8 s_journal_uuid[16]; /* uuid of journal superblock */ + __u32 s_journal_inum; /* inode number of journal file */ + __u32 s_journal_dev; /* device number of journal file */ + __u32 s_last_orphan; /* start of list of inodes to delete */ + + __u32 s_reserved[197]; /* Padding to the end of the block */ +}; + +#ifdef __KERNEL__ +#define EXT2_SB(sb) (&((sb)->u.ext2_sb)) +#else +/* Assume that user mode programs are passing in an ext2fs superblock, not + * a kernel struct super_block. This will allow us to call the feature-test + * macros from user land. */ +#define EXT2_SB(sb) (sb) +#endif + +/* + * Codes for operating systems + */ +#define EXT2_OS_LINUX 0 +#define EXT2_OS_HURD 1 +#define EXT2_OS_MASIX 2 +#define EXT2_OS_FREEBSD 3 +#define EXT2_OS_LITES 4 +#define EXT2_OS_WINNT 5 + +/* + * Revision levels + */ +#define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */ +#define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */ + +#define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV +#define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV + +#define EXT2_GOOD_OLD_INODE_SIZE 128 + +/* + * Feature set definitions + */ + +#define EXT2_HAS_COMPAT_FEATURE(sb,mask) \ + ( EXT2_SB(sb)->s_feature_compat & (mask) ) +#define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \ + ( EXT2_SB(sb)->s_feature_ro_compat & (mask) ) +#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \ + ( EXT2_SB(sb)->s_feature_incompat & (mask) ) + +#define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001 +#define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002 +#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004 +#define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008 +#define EXT2_FEATURE_COMPAT_RESIZE_INODE 0x0010 +#define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020 + +#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001 +#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002 +#define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 + +#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001 +#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002 +#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */ +#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */ + +#define EXT2_FEATURE_COMPAT_SUPP 0 +#define EXT2_FEATURE_INCOMPAT_SUPP EXT2_FEATURE_INCOMPAT_FILETYPE +#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \ + EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \ + EXT2_FEATURE_RO_COMPAT_BTREE_DIR) + +/* + * Default values for user and/or group using reserved blocks + */ +#define EXT2_DEF_RESUID 0 +#define EXT2_DEF_RESGID 0 + +/* + * Structure of a directory entry + */ +#define EXT2_NAME_LEN 255 + +struct ext2_dir_entry { + __u32 inode; /* Inode number */ + __u16 rec_len; /* Directory entry length */ + __u16 name_len; /* Name length */ + char name[EXT2_NAME_LEN]; /* File name */ +}; + +/* + * The new version of the directory entry. Since EXT2 structures are + * stored in intel byte order, and the name_len field could never be + * bigger than 255 chars, it's safe to reclaim the extra byte for the + * file_type field. + */ +struct ext2_dir_entry_2 { + __u32 inode; /* Inode number */ + __u16 rec_len; /* Directory entry length */ + __u8 name_len; /* Name length */ + __u8 file_type; + char name[EXT2_NAME_LEN]; /* File name */ +}; + +/* + * Ext2 directory file types. Only the low 3 bits are used. The + * other bits are reserved for now. + */ +#define EXT2_FT_UNKNOWN 0 +#define EXT2_FT_REG_FILE 1 +#define EXT2_FT_DIR 2 +#define EXT2_FT_CHRDEV 3 +#define EXT2_FT_BLKDEV 4 +#define EXT2_FT_FIFO 5 +#define EXT2_FT_SOCK 6 +#define EXT2_FT_SYMLINK 7 + +#define EXT2_FT_MAX 8 + +/* + * EXT2_DIR_PAD defines the directory entries boundaries + * + * NOTE: It must be a multiple of 4 + */ +#define EXT2_DIR_PAD 4 +#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1) +#define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \ + ~EXT2_DIR_ROUND) + + + +/* + * SWAP information settings + */ + +#define SWAP_HEADER_OFFSET 0 +#define SWAP_HEADER_MAGIC_V1 "SWAP-SPACE" +#define SWAP_HEADER_MAGIC_V2 "SWAPSPACE2" + +/* The following is a subset of linux/include/linux/swap.h (2.2.6) */ + +union swap_header { + struct + { + char reserved[PAGE_SIZE - 10]; + char magic[10]; + } magic; + struct + { + char bootbits[1024]; /* Space for disklabel etc. */ + unsigned int version; + unsigned int last_page; + unsigned int nr_badpages; + unsigned int padding[125]; + unsigned int badpages[1]; + } info; +}; + +/* super block */ +#define SUPER_BLOCK_OFFSET (0x400) +#define SUPER_BLOCK_SIZE (0x400) + +#endif /* _LINUX_EXT2_FS_H */ diff --git a/Ext2Mgr/ntdll.h b/Ext2Mgr/ntdll.h index 51e3dc7..e8ff1ce 100644 --- a/Ext2Mgr/ntdll.h +++ b/Ext2Mgr/ntdll.h @@ -1,4439 +1,4439 @@ -#include - -namespace NT { - extern "C" { - -/* PAGE_SIZE for X86/X64 */ -#define PAGE_SIZE 0x1000 -#define PAGE_SHIFT 12L - -/* Definitions for NTDDK STATUS */ -typedef LONG NTSTATUS; -typedef ULONG DEVICE_TYPE; - -#define NT_SUCCESS(Status) (((NT::NTSTATUS)(Status)) >= 0) - -/* Common status codes */ - -#define STATUS_SUCCESS ((NT::NTSTATUS)0x00000000L) -#define STATUS_BUFFER_OVERFLOW ((NT::NTSTATUS)0x80000005L) -#define STATUS_UNSUCCESSFUL ((NT::NTSTATUS)0xC0000001L) -#define STATUS_NO_MEDIA_IN_DEVICE ((NT::NTSTATUS)0xC0000013L) -#define STATUS_ACCESS_DENIED ((NT::NTSTATUS)0xC0000022L) -#define STATUS_BUFFER_TOO_SMALL ((NT::NTSTATUS)0xC0000023L) -#define STATUS_INSUFFICIENT_RESOURCES ((NT::NTSTATUS)0xC000009AL) - - -typedef struct _IO_STATUS_BLOCK { - union { - NTSTATUS Status; - PVOID Pointer; - } DUMMYUNIONNAME; - - ULONG_PTR Information; -} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; - - -/* Definitios of kernel I/O IRPs */ - -#define IRP_MJ_CREATE 0x00 -#define IRP_MJ_CREATE_NAMED_PIPE 0x01 -#define IRP_MJ_CLOSE 0x02 -#define IRP_MJ_READ 0x03 -#define IRP_MJ_WRITE 0x04 -#define IRP_MJ_QUERY_INFORMATION 0x05 -#define IRP_MJ_SET_INFORMATION 0x06 -#define IRP_MJ_QUERY_EA 0x07 -#define IRP_MJ_SET_EA 0x08 -#define IRP_MJ_FLUSH_BUFFERS 0x09 -#define IRP_MJ_QUERY_VOLUME_INFORMATION 0x0a -#define IRP_MJ_SET_VOLUME_INFORMATION 0x0b -#define IRP_MJ_DIRECTORY_CONTROL 0x0c -#define IRP_MJ_FILE_SYSTEM_CONTROL 0x0d -#define IRP_MJ_DEVICE_CONTROL 0x0e -#define IRP_MJ_INTERNAL_DEVICE_CONTROL 0x0f -#define IRP_MJ_SHUTDOWN 0x10 -#define IRP_MJ_LOCK_CONTROL 0x11 -#define IRP_MJ_CLEANUP 0x12 -#define IRP_MJ_CREATE_MAILSLOT 0x13 -#define IRP_MJ_QUERY_SECURITY 0x14 -#define IRP_MJ_SET_SECURITY 0x15 -#define IRP_MJ_POWER 0x16 -#define IRP_MJ_SYSTEM_CONTROL 0x17 -#define IRP_MJ_DEVICE_CHANGE 0x18 -#define IRP_MJ_QUERY_QUOTA 0x19 -#define IRP_MJ_SET_QUOTA 0x1a -#define IRP_MJ_PNP 0x1b -#define IRP_MJ_PNP_POWER IRP_MJ_PNP // Obsolete.... -#define IRP_MJ_MAXIMUM_FUNCTION 0x1b - - -/* - * strings - */ - -typedef struct _STRING { - __maybevalid USHORT Length; - __maybevalid USHORT MaximumLength; -#ifdef MIDL_PASS - [size_is(MaximumLength), length_is(Length) ] -#endif // MIDL_PASS - __field_bcount_part_opt(MaximumLength, Length) PCHAR Buffer; -} STRING; -typedef STRING *PSTRING; -typedef STRING ANSI_STRING; -typedef PSTRING PANSI_STRING; - -typedef STRING OEM_STRING; -typedef PSTRING POEM_STRING; -typedef CONST STRING* PCOEM_STRING; - -typedef struct _CSTRING { - USHORT Length; - USHORT MaximumLength; - CONST char *Buffer; -} CSTRING; -typedef CSTRING *PCSTRING; -#define ANSI_NULL ((CHAR)0) // winnt - -typedef STRING CANSI_STRING; -typedef PSTRING PCANSI_STRING; - -typedef struct _UNICODE_STRING { - USHORT Length; - USHORT MaximumLength; -#ifdef MIDL_PASS - [size_is(MaximumLength / 2), length_is((Length) / 2) ] USHORT * Buffer; -#else // MIDL_PASS - __field_bcount_part(MaximumLength, Length) PWCH Buffer; -#endif // MIDL_PASS -} UNICODE_STRING; -typedef UNICODE_STRING *PUNICODE_STRING; -typedef const UNICODE_STRING *PCUNICODE_STRING; -#define UNICODE_NULL ((WCHAR)0) // winnt - -typedef enum _FSINFOCLASS { - FileFsVolumeInformation = 1, - FileFsLabelInformation, // 2 - FileFsSizeInformation, // 3 - FileFsDeviceInformation, // 4 - FileFsAttributeInformation, // 5 - FileFsControlInformation, // 6 - FileFsFullSizeInformation, // 7 - FileFsObjectIdInformation, // 8 - FileFsDriverPathInformation, // 9 - FileFsVolumeFlagsInformation,// 10 - FileFsMaximumInformation -} FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS; - - -typedef struct _FILE_FS_DEVICE_INFORMATION { - DEVICE_TYPE DeviceType; - ULONG Characteristics; -} FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION; - -typedef enum _SYSTEM_INFORMATION_CLASS { - SystemBasicInformation, // 0 Y N - SystemProcessorInformation, // 1 Y N - SystemPerformanceInformation, // 2 Y N - SystemTimeOfDayInformation, // 3 Y N - SystemNotImplemented1, // 4 Y N - SystemProcessesAndThreadsInformation, // 5 Y N - SystemCallCounts, // 6 Y N - SystemConfigurationInformation, // 7 Y N - SystemProcessorTimes, // 8 Y N - SystemGlobalFlag, // 9 Y Y - SystemNotImplemented2, // 10 Y N - SystemModuleInformation, // 11 Y N - SystemLockInformation, // 12 Y N - SystemNotImplemented3, // 13 Y N - SystemNotImplemented4, // 14 Y N - SystemNotImplemented5, // 15 Y N - SystemHandleInformation, // 16 Y N - SystemObjectInformation, // 17 Y N - SystemPagefileInformation, // 18 Y N - SystemInstructionEmulationCounts, // 19 Y N - SystemInvalidInfoClass1, // 20 - SystemCacheInformation, // 21 Y Y - SystemPoolTagInformation, // 22 Y N - SystemProcessorStatistics, // 23 Y N - SystemDpcInformation, // 24 Y Y - SystemNotImplemented6, // 25 Y N - SystemLoadImage, // 26 N Y - SystemUnloadImage, // 27 N Y - SystemTimeAdjustment, // 28 Y Y - SystemNotImplemented7, // 29 Y N - SystemNotImplemented8, // 30 Y N - SystemNotImplemented9, // 31 Y N - SystemCrashDumpInformation, // 32 Y N - SystemExceptionInformation, // 33 Y N - SystemCrashDumpStateInformation, // 34 Y Y/N - SystemKernelDebuggerInformation, // 35 Y N - SystemContextSwitchInformation, // 36 Y N - SystemRegistryQuotaInformation, // 37 Y Y - SystemLoadAndCallImage, // 38 N Y - SystemPrioritySeparation, // 39 N Y - SystemNotImplemented10, // 40 Y N - SystemNotImplemented11, // 41 Y N - SystemInvalidInfoClass2, // 42 - SystemInvalidInfoClass3, // 43 - SystemTimeZoneInformation, // 44 Y N - SystemLookasideInformation, // 45 Y N - SystemSetTimeSlipEvent, // 46 N Y - SystemCreateSession, // 47 N Y - SystemDeleteSession, // 48 N Y - SystemInvalidInfoClass4, // 49 - SystemRangeStartInformation, // 50 Y N - SystemVerifierInformation, // 51 Y Y - SystemAddVerifier, // 52 N Y - SystemSessionProcessesInformation // 53 Y N -} SYSTEM_INFORMATION_CLASS; - -NTSYSAPI -NTSTATUS -NTAPI -ZwQuerySystemInformation( - IN SYSTEM_INFORMATION_CLASS SystemInformationClass, - OUT PVOID SystemInformation, - IN ULONG SystemInformationLength, - OUT PULONG ReturnLength OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetSystemInformation( - IN SYSTEM_INFORMATION_CLASS SystemInformationClass, - IN OUT PVOID SystemInformation, - IN ULONG SystemInformationLength - ); - -typedef struct _SYSTEM_BASIC_INFORMATION { // Information Class 0 - ULONG Unknown; - ULONG MaximumIncrement; - ULONG PhysicalPageSize; - ULONG NumberOfPhysicalPages; - ULONG LowestPhysicalPage; - ULONG HighestPhysicalPage; - ULONG AllocationGranularity; - ULONG LowestUserAddress; - ULONG HighestUserAddress; - ULONG ActiveProcessors; - UCHAR NumberProcessors; -} SYSTEM_BASIC_INFORMATION, *PSYSTEM_BASIC_INFORMATION; - -typedef struct _SYSTEM_PROCESSOR_INFORMATION { // Information Class 1 - USHORT ProcessorArchitecture; - USHORT ProcessorLevel; - USHORT ProcessorRevision; - USHORT Unknown; - ULONG FeatureBits; -} SYSTEM_PROCESSOR_INFORMATION, *PSYSTEM_PROCESSOR_INFORMATION; - -typedef struct _SYSTEM_PERFORMANCE_INFORMATION { // Information Class 2 - LARGE_INTEGER IdleTime; - LARGE_INTEGER ReadTransferCount; - LARGE_INTEGER WriteTransferCount; - LARGE_INTEGER OtherTransferCount; - ULONG ReadOperationCount; - ULONG WriteOperationCount; - ULONG OtherOperationCount; - ULONG AvailablePages; - ULONG TotalCommittedPages; - ULONG TotalCommitLimit; - ULONG PeakCommitment; - ULONG PageFaults; - ULONG WriteCopyFaults; - ULONG TransistionFaults; - ULONG Reserved1; - ULONG DemandZeroFaults; - ULONG PagesRead; - ULONG PageReadIos; - ULONG Reserved2[2]; - ULONG PagefilePagesWritten; - ULONG PagefilePageWriteIos; - ULONG MappedFilePagesWritten; - ULONG MappedFilePageWriteIos; - ULONG PagedPoolUsage; - ULONG NonPagedPoolUsage; - ULONG PagedPoolAllocs; - ULONG PagedPoolFrees; - ULONG NonPagedPoolAllocs; - ULONG NonPagedPoolFrees; - ULONG TotalFreeSystemPtes; - ULONG SystemCodePage; - ULONG TotalSystemDriverPages; - ULONG TotalSystemCodePages; - ULONG SmallNonPagedLookasideListAllocateHits; - ULONG SmallPagedLookasideListAllocateHits; - ULONG Reserved3; - ULONG MmSystemCachePage; - ULONG PagedPoolPage; - ULONG SystemDriverPage; - ULONG FastReadNoWait; - ULONG FastReadWait; - ULONG FastReadResourceMiss; - ULONG FastReadNotPossible; - ULONG FastMdlReadNoWait; - ULONG FastMdlReadWait; - ULONG FastMdlReadResourceMiss; - ULONG FastMdlReadNotPossible; - ULONG MapDataNoWait; - ULONG MapDataWait; - ULONG MapDataNoWaitMiss; - ULONG MapDataWaitMiss; - ULONG PinMappedDataCount; - ULONG PinReadNoWait; - ULONG PinReadWait; - ULONG PinReadNoWaitMiss; - ULONG PinReadWaitMiss; - ULONG CopyReadNoWait; - ULONG CopyReadWait; - ULONG CopyReadNoWaitMiss; - ULONG CopyReadWaitMiss; - ULONG MdlReadNoWait; - ULONG MdlReadWait; - ULONG MdlReadNoWaitMiss; - ULONG MdlReadWaitMiss; - ULONG ReadAheadIos; - ULONG LazyWriteIos; - ULONG LazyWritePages; - ULONG DataFlushes; - ULONG DataPages; - ULONG ContextSwitches; - ULONG FirstLevelTbFills; - ULONG SecondLevelTbFills; - ULONG SystemCalls; -} SYSTEM_PERFORMANCE_INFORMATION, *PSYSTEM_PERFORMANCE_INFORMATION; - -typedef struct _SYSTEM_TIME_OF_DAY_INFORMATION { // Information Class 3 - LARGE_INTEGER BootTime; - LARGE_INTEGER CurrentTime; - LARGE_INTEGER TimeZoneBias; - ULONG CurrentTimeZoneId; -} SYSTEM_TIME_OF_DAY_INFORMATION, *PSYSTEM_TIME_OF_DAY_INFORMATION; - -typedef struct _IO_COUNTERSEX { - LARGE_INTEGER ReadOperationCount; - LARGE_INTEGER WriteOperationCount; - LARGE_INTEGER OtherOperationCount; - LARGE_INTEGER ReadTransferCount; - LARGE_INTEGER WriteTransferCount; - LARGE_INTEGER OtherTransferCount; -} IO_COUNTERSEX, *PIO_COUNTERSEX; - -typedef enum { - StateInitialized, - StateReady, - StateRunning, - StateStandby, - StateTerminated, - StateWait, - StateTransition, - StateUnknown -} THREAD_STATE; - -typedef struct _CLIENT_ID { - HANDLE UniqueProcess; - HANDLE UniqueThread; -} CLIENT_ID; -typedef CLIENT_ID *PCLIENT_ID; - -/* Thread priority */ -typedef LONG KPRIORITY; - -typedef enum _KWAIT_REASON { - Executive, - FreePage, - PageIn, - PoolAllocation, - DelayExecution, - Suspended, - UserRequest, - WrExecutive, - WrFreePage, - WrPageIn, - WrPoolAllocation, - WrDelayExecution, - WrSuspended, - WrUserRequest, - WrEventPair, - WrQueue, - WrLpcReceive, - WrLpcReply, - WrVirtualMemory, - WrPageOut, - WrRendezvous, - WrKeyedEvent, - WrTerminated, - WrProcessInSwap, - WrCpuRateControl, - WrCalloutStack, - WrKernel, - WrResource, - WrPushLock, - WrMutex, - WrQuantumEnd, - WrDispatchInt, - WrPreempted, - WrYieldExecution, - WrFastMutex, - WrGuardedMutex, - WrRundown, - MaximumWaitReason -} KWAIT_REASON; - -typedef struct _SYSTEM_THREADS { - LARGE_INTEGER KernelTime; - LARGE_INTEGER UserTime; - LARGE_INTEGER CreateTime; - ULONG WaitTime; - PVOID StartAddress; - CLIENT_ID ClientId; - KPRIORITY Priority; - KPRIORITY BasePriority; - ULONG ContextSwitchCount; - THREAD_STATE State; - KWAIT_REASON WaitReason; -} SYSTEM_THREADS, *PSYSTEM_THREADS; - -typedef struct _VM_COUNTERS { - SIZE_T PeakVirtualSize; - SIZE_T VirtualSize; - ULONG PageFaultCount; - SIZE_T PeakWorkingSetSize; - SIZE_T WorkingSetSize; - SIZE_T QuotaPeakPagedPoolUsage; - SIZE_T QuotaPagedPoolUsage; - SIZE_T QuotaPeakNonPagedPoolUsage; - SIZE_T QuotaNonPagedPoolUsage; - SIZE_T PagefileUsage; - SIZE_T PeakPagefileUsage; -} VM_COUNTERS; -typedef VM_COUNTERS *PVM_COUNTERS; - -typedef struct _VM_COUNTERS_EX { - SIZE_T PeakVirtualSize; - SIZE_T VirtualSize; - ULONG PageFaultCount; - SIZE_T PeakWorkingSetSize; - SIZE_T WorkingSetSize; - SIZE_T QuotaPeakPagedPoolUsage; - SIZE_T QuotaPagedPoolUsage; - SIZE_T QuotaPeakNonPagedPoolUsage; - SIZE_T QuotaNonPagedPoolUsage; - SIZE_T PagefileUsage; - SIZE_T PeakPagefileUsage; - SIZE_T PrivateUsage; -} VM_COUNTERS_EX; - -typedef VM_COUNTERS_EX *PVM_COUNTERS_EX; -#define MAX_HW_COUNTERS 16 - -typedef struct _SYSTEM_PROCESSES { // Information Class 5 - ULONG NextEntryDelta; - ULONG ThreadCount; - ULONG Reserved1[6]; - LARGE_INTEGER CreateTime; - LARGE_INTEGER UserTime; - LARGE_INTEGER KernelTime; - UNICODE_STRING ProcessName; - KPRIORITY BasePriority; - ULONG ProcessId; - ULONG InheritedFromProcessId; - ULONG HandleCount; - ULONG Reserved2[2]; - VM_COUNTERS VmCounters; - IO_COUNTERS IoCounters; - SYSTEM_THREADS Threads[1]; -} SYSTEM_PROCESSES, *PSYSTEM_PROCESSES; - -typedef struct _SYSTEM_CALLS_INFORMATION { // Information Class 6 - ULONG Size; - ULONG NumberOfDescriptorTables; - ULONG NumberOfRoutinesInTable[1]; - // ULONG CallCounts[]; -} SYSTEM_CALLS_INFORMATION, *PSYSTEM_CALLS_INFORMATION; - -typedef struct _SYSTEM_CONFIGURATION_INFORMATION { // Information Class 7 - ULONG DiskCount; - ULONG FloppyCount; - ULONG CdRomCount; - ULONG TapeCount; - ULONG SerialCount; - ULONG ParallelCount; -} SYSTEM_CONFIGURATION_INFORMATION, *PSYSTEM_CONFIGURATION_INFORMATION; - -typedef struct _SYSTEM_PROCESSOR_TIMES { // Information Class 8 - LARGE_INTEGER IdleTime; - LARGE_INTEGER KernelTime; - LARGE_INTEGER UserTime; - LARGE_INTEGER DpcTime; - LARGE_INTEGER InterruptTime; - ULONG InterruptCount; -} SYSTEM_PROCESSOR_TIMES, *PSYSTEM_PROCESSOR_TIMES; - -typedef struct _SYSTEM_GLOBAL_FLAG { // Information Class 9 - ULONG GlobalFlag; -} SYSTEM_GLOBAL_FLAG, *PSYSTEM_GLOBAL_FLAG; - -typedef struct _SYSTEM_MODULE_INFORMATION { // Information Class 11 - ULONG Reserved[2]; - PVOID Base; - ULONG Size; - ULONG Flags; - USHORT Index; - USHORT Unknown; - USHORT LoadCount; - USHORT ModuleNameOffset; - CHAR ImageName[256]; -} SYSTEM_MODULE_INFORMATION, *PSYSTEM_MODULE_INFORMATION; - -typedef struct _SYSTEM_LOCK_INFORMATION { // Information Class 12 - PVOID Address; - USHORT Type; - USHORT Reserved1; - ULONG ExclusiveOwnerThreadId; - ULONG ActiveCount; - ULONG ContentionCount; - ULONG Reserved2[2]; - ULONG NumberOfSharedWaiters; - ULONG NumberOfExclusiveWaiters; -} SYSTEM_LOCK_INFORMATION, *PSYSTEM_LOCK_INFORMATION; - -typedef struct _SYSTEM_HANDLE_INFORMATION { // Information Class 16 - ULONG ProcessId; - UCHAR ObjectTypeNumber; - UCHAR Flags; // 0x01 = PROTECT_FROM_CLOSE, 0x02 = INHERIT - USHORT Handle; - PVOID Object; - ACCESS_MASK GrantedAccess; -} SYSTEM_HANDLE_INFORMATION, *PSYSTEM_HANDLE_INFORMATION; - -// -// Pool Allocation routines (in pool.c) -// - -typedef enum _POOL_TYPE { - NonPagedPool, - PagedPool, - NonPagedPoolMustSucceed, - DontUseThisType, - NonPagedPoolCacheAligned, - PagedPoolCacheAligned, - NonPagedPoolCacheAlignedMustS, - MaxPoolType, - - // - // Note these per session types are carefully chosen so that the appropriate - // masking still applies as well as MaxPoolType above. - // - - NonPagedPoolSession = 32, - PagedPoolSession = NonPagedPoolSession + 1, - NonPagedPoolMustSucceedSession = PagedPoolSession + 1, - DontUseThisTypeSession = NonPagedPoolMustSucceedSession + 1, - NonPagedPoolCacheAlignedSession = DontUseThisTypeSession + 1, - PagedPoolCacheAlignedSession = NonPagedPoolCacheAlignedSession + 1, - NonPagedPoolCacheAlignedMustSSession = PagedPoolCacheAlignedSession + 1, -} POOL_TYPE; - -typedef struct _SYSTEM_OBJECT_TYPE_INFORMATION { // Information Class 17 - ULONG NextEntryOffset; - ULONG ObjectCount; - ULONG HandleCount; - ULONG TypeNumber; - ULONG InvalidAttributes; - GENERIC_MAPPING GenericMapping; - ACCESS_MASK ValidAccessMask; - POOL_TYPE PoolType; - UCHAR Unknown; - UNICODE_STRING Name; -} SYSTEM_OBJECT_TYPE_INFORMATION, *PSYSTEM_OBJECT_TYPE_INFORMATION; - -typedef struct _SYSTEM_OBJECT_INFORMATION { - ULONG NextEntryOffset; - PVOID Object; - ULONG CreatorProcessId; - USHORT Unknown; - USHORT Flags; - ULONG PointerCount; - ULONG HandleCount; - ULONG PagedPoolUsage; - ULONG NonPagedPoolUsage; - ULONG ExclusiveProcessId; - PSECURITY_DESCRIPTOR SecurityDescriptor; - UNICODE_STRING Name; -} SYSTEM_OBJECT_INFORMATION, *PSYSTEM_OBJECT_INFORMATION; - -typedef struct _SYSTEM_PAGEFILE_INFORMATION { // Information Class 18 - ULONG NextEntryOffset; - ULONG CurrentSize; - ULONG TotalUsed; - ULONG PeakUsed; - UNICODE_STRING FileName; -} SYSTEM_PAGEFILE_INFORMATION, *PSYSTEM_PAGEFILE_INFORMATION; - -typedef struct _SYSTEM_INSTRUCTION_EMULATION_INFORMATION { // Info Class 19 - ULONG GenericInvalidOpcode; - ULONG TwoByteOpcode; - ULONG ESprefix; - ULONG CSprefix; - ULONG SSprefix; - ULONG DSprefix; - ULONG FSPrefix; - ULONG GSprefix; - ULONG OPER32prefix; - ULONG ADDR32prefix; - ULONG INSB; - ULONG INSW; - ULONG OUTSB; - ULONG OUTSW; - ULONG PUSHFD; - ULONG POPFD; - ULONG INTnn; - ULONG INTO; - ULONG IRETD; - ULONG FloatingPointOpcode; - ULONG INBimm; - ULONG INWimm; - ULONG OUTBimm; - ULONG OUTWimm; - ULONG INB; - ULONG INW; - ULONG OUTB; - ULONG OUTW; - ULONG LOCKprefix; - ULONG REPNEprefix; - ULONG REPprefix; - ULONG CLI; - ULONG STI; - ULONG HLT; -} SYSTEM_INSTRUCTION_EMULATION_INFORMATION, *PSYSTEM_INSTRUCTION_EMULATION_INFORMATION; - -typedef struct _SYSTEM_CACHE_INFORMATION { // Information Class 21 - ULONG SystemCacheWsSize; - ULONG SystemCacheWsPeakSize; - ULONG SystemCacheWsFaults; - ULONG SystemCacheWsMinimum; - ULONG SystemCacheWsMaximum; - ULONG TransitionSharedPages; - ULONG TransitionSharedPagesPeak; - ULONG Reserved[2]; -} SYSTEM_CACHE_INFORMATION, *PSYSTEM_CACHE_INFORMATION; - -typedef struct _SYSTEM_POOL_TAG_INFORMATION { // Information Class 22 - CHAR Tag[4]; - ULONG PagedPoolAllocs; - ULONG PagedPoolFrees; - ULONG PagedPoolUsage; - ULONG NonPagedPoolAllocs; - ULONG NonPagedPoolFrees; - ULONG NonPagedPoolUsage; -} SYSTEM_POOL_TAG_INFORMATION, *PSYSTEM_POOL_TAG_INFORMATION; - -typedef struct _SYSTEM_PROCESSOR_STATISTICS { // Information Class 23 - ULONG ContextSwitches; - ULONG DpcCount; - ULONG DpcRequestRate; - ULONG TimeIncrement; - ULONG DpcBypassCount; - ULONG ApcBypassCount; -} SYSTEM_PROCESSOR_STATISTICS, *PSYSTEM_PROCESSOR_STATISTICS; - -typedef struct _SYSTEM_DPC_INFORMATION { // Information Class 24 - ULONG Reserved; - ULONG MaximumDpcQueueDepth; - ULONG MinimumDpcRate; - ULONG AdjustDpcThreshold; - ULONG IdealDpcRate; -} SYSTEM_DPC_INFORMATION, *PSYSTEM_DPC_INFORMATION; - -typedef struct _SYSTEM_LOAD_IMAGE { // Information Class 26 - UNICODE_STRING ModuleName; - PVOID ModuleBase; - PVOID Unknown; - PVOID EntryPoint; - PVOID ExportDirectory; -} SYSTEM_LOAD_IMAGE, *PSYSTEM_LOAD_IMAGE; - -typedef struct _SYSTEM_UNLOAD_IMAGE { // Information Class 27 - PVOID ModuleBase; -} SYSTEM_UNLOAD_IMAGE, *PSYSTEM_UNLOAD_IMAGE; - -typedef struct _SYSTEM_QUERY_TIME_ADJUSTMENT { // Information Class 28 - ULONG TimeAdjustment; - ULONG MaximumIncrement; - BOOL TimeSynchronization; -} SYSTEM_QUERY_TIME_ADJUSTMENT, *PSYSTEM_QUERY_TIME_ADJUSTMENT; - -typedef struct _SYSTEM_SET_TIME_ADJUSTMENT { // Information Class 28 - ULONG TimeAdjustment; - BOOL TimeSynchronization; -} SYSTEM_SET_TIME_ADJUSTMENT, *PSYSTEM_SET_TIME_ADJUSTMENT; - -typedef struct _SYSTEM_CRASH_DUMP_INFORMATION { // Information Class 32 - HANDLE CrashDumpSectionHandle; - HANDLE Unknown; // Windows 2000 only -} SYSTEM_CRASH_DUMP_INFORMATION, *PSYSTEM_CRASH_DUMP_INFORMATION; - -typedef struct _SYSTEM_EXCEPTION_INFORMATION { // Information Class 33 - ULONG AlignmentFixupCount; - ULONG ExceptionDispatchCount; - ULONG FloatingEmulationCount; - ULONG Reserved; -} SYSTEM_EXCEPTION_INFORMATION, *PSYSTEM_EXCEPTION_INFORMATION; - -typedef struct _SYSTEM_CRASH_STATE_INFORMATION { // Information Class 34 - ULONG ValidCrashDump; - ULONG Unknown; // Windows 2000 only -} SYSTEM_CRASH_STATE_INFORMATION, *PSYSTEM_CRASH_STATE_INFORMATION; - -typedef struct _SYSTEM_KERNEL_DEBUGGER_INFORMATION { // Information Class 35 - BOOL DebuggerEnabled; - BOOL DebuggerNotPresent; -} SYSTEM_KERNEL_DEBUGGER_INFORMATION, *PSYSTEM_KERNEL_DEBUGGER_INFORMATION; - -typedef struct _SYSTEM_CONTEXT_SWITCH_INFORMATION { // Information Class 36 - ULONG ContextSwitches; - ULONG ContextSwitchCounters[11]; -} SYSTEM_CONTEXT_SWITCH_INFORMATION, *PSYSTEM_CONTEXT_SWITCH_INFORMATION; - -typedef struct _SYSTEM_REGISTRY_QUOTA_INFORMATION { // Information Class 37 - ULONG RegistryQuota; - ULONG RegistryQuotaInUse; - ULONG PagedPoolSize; -} SYSTEM_REGISTRY_QUOTA_INFORMATION, *PSYSTEM_REGISTRY_QUOTA_INFORMATION; - -typedef struct _SYSTEM_LOAD_AND_CALL_IMAGE { // Information Class 38 - UNICODE_STRING ModuleName; -} SYSTEM_LOAD_AND_CALL_IMAGE, *PSYSTEM_LOAD_AND_CALL_IMAGE; - -typedef struct _SYSTEM_PRIORITY_SEPARATION { // Information Class 39 - ULONG PrioritySeparation; -} SYSTEM_PRIORITY_SEPARATION, *PSYSTEM_PRIORITY_SEPARATION; - -typedef struct _SYSTEM_TIME_ZONE_INFORMATION { // Information Class 44 - LONG Bias; - WCHAR StandardName[32]; - SYSTEMTIME StandardDate; - LONG StandardBias; - WCHAR DaylightName[32]; - SYSTEMTIME DaylightDate; - LONG DaylightBias; -} SYSTEM_TIME_ZONE_INFORMATION, *PSYSTEM_TIME_ZONE_INFORMATION; - -typedef struct _SYSTEM_LOOKASIDE_INFORMATION { // Information Class 45 - USHORT Depth; - USHORT MaximumDepth; - ULONG TotalAllocates; - ULONG AllocateMisses; - ULONG TotalFrees; - ULONG FreeMisses; - POOL_TYPE Type; - ULONG Tag; - ULONG Size; -} SYSTEM_LOOKASIDE_INFORMATION, *PSYSTEM_LOOKASIDE_INFORMATION; - -typedef struct _SYSTEM_SET_TIME_SLIP_EVENT { // Information Class 46 - HANDLE TimeSlipEvent; -} SYSTEM_SET_TIME_SLIP_EVENT, *PSYSTEM_SET_TIME_SLIP_EVENT; - -typedef struct _SYSTEM_CREATE_SESSION { // Information Class 47 - ULONG Session; -} SYSTEM_CREATE_SESSION, *PSYSTEM_CREATE_SESSION; - -typedef struct _SYSTEM_DELETE_SESSION { // Information Class 48 - ULONG Session; -} SYSTEM_DELETE_SESSION, *PSYSTEM_DELETE_SESSION; - -typedef struct _SYSTEM_RANGE_START_INFORMATION { // Information Class 50 - PVOID SystemRangeStart; -} SYSTEM_RANGE_START_INFORMATION, *PSYSTEM_RANGE_START_INFORMATION; - -typedef struct _SYSTEM_POOL_BLOCK { - BOOL Allocated; - USHORT Unknown; - ULONG Size; - CHAR Tag[4]; -} SYSTEM_POOL_BLOCK, *PSYSTEM_POOL_BLOCK; - -typedef struct _SYSTEM_POOL_BLOCKS_INFORMATION { // Info Classes 14 and 15 - ULONG PoolSize; - PVOID PoolBase; - USHORT Unknown; - ULONG NumberOfBlocks; - SYSTEM_POOL_BLOCK PoolBlocks[1]; -} SYSTEM_POOL_BLOCKS_INFORMATION, *PSYSTEM_POOL_BLOCKS_INFORMATION; - -typedef struct _SYSTEM_MEMORY_USAGE { - PVOID Name; - USHORT Valid; - USHORT Standby; - USHORT Modified; - USHORT PageTables; -} SYSTEM_MEMORY_USAGE, *PSYSTEM_MEMORY_USAGE; - -typedef struct _SYSTEM_MEMORY_USAGE_INFORMATION { // Info Classes 25 and 29 - ULONG Reserved; - PVOID EndOfData; - SYSTEM_MEMORY_USAGE MemoryUsage[1]; -} SYSTEM_MEMORY_USAGE_INFORMATION, *PSYSTEM_MEMORY_USAGE_INFORMATION; - -NTSYSAPI -NTSTATUS -NTAPI -ZwQuerySystemEnvironmentValue( - IN PUNICODE_STRING Name, - OUT PVOID Value, - IN ULONG ValueLength, - OUT PULONG ReturnLength OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetSystemEnvironmentValue( - IN PUNICODE_STRING Name, - IN PUNICODE_STRING Value - ); - -typedef enum _SHUTDOWN_ACTION { - ShutdownNoReboot, - ShutdownReboot, - ShutdownPowerOff -} SHUTDOWN_ACTION; - -NTSYSAPI -NTSTATUS -NTAPI -ZwShutdownSystem( - IN SHUTDOWN_ACTION Action - ); - -typedef enum _DEBUG_CONTROL_CODE { - DebugGetTraceInformation = 1, - DebugSetInternalBreakpoint, - DebugSetSpecialCall, - DebugClearSpecialCalls, - DebugQuerySpecialCalls, - DebugDbgBreakPoint -} DEBUG_CONTROL_CODE; - -NTSYSAPI -NTSTATUS -NTAPI -ZwSystemDebugControl( - IN DEBUG_CONTROL_CODE ControlCode, - IN PVOID InputBuffer OPTIONAL, - IN ULONG InputBufferLength, - OUT PVOID OutputBuffer OPTIONAL, - IN ULONG OutputBufferLength, - OUT PULONG ReturnLength OPTIONAL - ); - -typedef enum _OBJECT_INFORMATION_CLASS { - ObjectBasicInformation, // 0 Y N - ObjectNameInformation, // 1 Y N - ObjectTypeInformation, // 2 Y N - ObjectAllTypesInformation, // 3 Y N - ObjectHandleInformation // 4 Y Y -} OBJECT_INFORMATION_CLASS; - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryObject( - IN HANDLE ObjectHandle, - IN OBJECT_INFORMATION_CLASS ObjectInformationClass, - OUT PVOID ObjectInformation, - IN ULONG ObjectInformationLength, - OUT PULONG ReturnLength OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetInformationObject( - IN HANDLE ObjectHandle, - IN OBJECT_INFORMATION_CLASS ObjectInformationClass, - IN PVOID ObjectInformation, - IN ULONG ObjectInformationLength - ); - -typedef struct _OBJECT_BASIC_INFORMATION { // Information Class 0 - ULONG Attributes; - ACCESS_MASK GrantedAccess; - ULONG HandleCount; - ULONG PointerCount; - ULONG PagedPoolUsage; - ULONG NonPagedPoolUsage; - ULONG Reserved[3]; - ULONG NameInformationLength; - ULONG TypeInformationLength; - ULONG SecurityDescriptorLength; - LARGE_INTEGER CreateTime; -} OBJECT_BASIC_INFORMATION, *POBJECT_BASIC_INFORMATION; - -typedef struct _OBJECT_TYPE_INFORMATION { // Information Class 2 - UNICODE_STRING Name; - ULONG ObjectCount; - ULONG HandleCount; - ULONG Reserved1[4]; - ULONG PeakObjectCount; - ULONG PeakHandleCount; - ULONG Reserved2[4]; - ULONG InvalidAttributes; - GENERIC_MAPPING GenericMapping; - ULONG ValidAccess; - UCHAR Unknown; - BOOL MaintainHandleDatabase; - UCHAR Reserved3[2]; - POOL_TYPE PoolType; - ULONG PagedPoolUsage; - ULONG NonPagedPoolUsage; -} OBJECT_TYPE_INFORMATION, *POBJECT_TYPE_INFORMATION; - -typedef struct _OBJECT_ALL_TYPES_INFORMATION { // Information Class 3 - ULONG NumberOfTypes; - OBJECT_TYPE_INFORMATION TypeInformation; -} OBJECT_ALL_TYPES_INFORMATION, *POBJECT_ALL_TYPES_INFORMATION; - -typedef struct _OBJECT_HANDLE_ATTRIBUTE_INFORMATION { // Information Class 4 - BOOL Inherit; - BOOL ProtectFromClose; -} OBJECT_HANDLE_ATTRIBUTE_INFORMATION, *POBJECT_HANDLE_ATTRIBUTE_INFORMATION; - -typedef struct _OBJECT_ATTRIBUTES64 { - ULONG Length; - ULONG64 RootDirectory; - ULONG64 ObjectName; - ULONG Attributes; - ULONG64 SecurityDescriptor; - ULONG64 SecurityQualityOfService; -} OBJECT_ATTRIBUTES64; -typedef OBJECT_ATTRIBUTES64 *POBJECT_ATTRIBUTES64; -typedef CONST OBJECT_ATTRIBUTES64 *PCOBJECT_ATTRIBUTES64; - -typedef struct _OBJECT_ATTRIBUTES32 { - ULONG Length; - ULONG RootDirectory; - ULONG ObjectName; - ULONG Attributes; - ULONG SecurityDescriptor; - ULONG SecurityQualityOfService; -} OBJECT_ATTRIBUTES32; -typedef OBJECT_ATTRIBUTES32 *POBJECT_ATTRIBUTES32; -typedef CONST OBJECT_ATTRIBUTES32 *PCOBJECT_ATTRIBUTES32; - -typedef struct _OBJECT_ATTRIBUTES { - ULONG Length; - HANDLE RootDirectory; - PUNICODE_STRING ObjectName; - ULONG Attributes; - PVOID SecurityDescriptor; // Points to type SECURITY_DESCRIPTOR - PVOID SecurityQualityOfService; // Points to type SECURITY_QUALITY_OF_SERVICE -} OBJECT_ATTRIBUTES; -typedef OBJECT_ATTRIBUTES *POBJECT_ATTRIBUTES; - - -typedef enum _PROCESSINFOCLASS { - ProcessBasicInformation, - ProcessQuotaLimits, - ProcessIoCounters, - ProcessVmCounters, - ProcessTimes, - ProcessBasePriority, - ProcessRaisePriority, - ProcessDebugPort, - ProcessExceptionPort, - ProcessAccessToken, - ProcessLdtInformation, - ProcessLdtSize, - ProcessDefaultHardErrorMode, - ProcessIoPortHandlers, // Note: this is kernel mode only - ProcessPooledUsageAndLimits, - ProcessWorkingSetWatch, - ProcessUserModeIOPL, - ProcessEnableAlignmentFaultFixup, - ProcessPriorityClass, - ProcessWx86Information, - ProcessHandleCount, - ProcessAffinityMask, - ProcessPriorityBoost, - ProcessDeviceMap, - ProcessSessionInformation, - ProcessForegroundInformation, - ProcessWow64Information, - ProcessImageFileName, - ProcessLUIDDeviceMapsEnabled, - ProcessBreakOnTermination, - ProcessDebugObjectHandle, - ProcessDebugFlags, - ProcessHandleTracing, - ProcessIoPriority, - ProcessExecuteFlags, - ProcessTlsInformation, - ProcessCookie, - ProcessImageInformation, - ProcessCycleTime, - ProcessPagePriority, - ProcessInstrumentationCallback, - ProcessThreadStackAllocation, - ProcessWorkingSetWatchEx, - ProcessImageFileNameWin32, - ProcessImageFileMapping, - ProcessAffinityUpdateMode, - ProcessMemoryAllocationMode, - ProcessGroupInformation, - ProcessTokenVirtualizationEnabled, - ProcessConsoleHostProcess, - ProcessWindowInformation, - MaxProcessInfoClass // MaxProcessInfoClass should always be the last enum -} PROCESSINFOCLASS; - -// -// Thread Information Classes -// - -typedef enum _THREADINFOCLASS { - ThreadBasicInformation, - ThreadTimes, - ThreadPriority, - ThreadBasePriority, - ThreadAffinityMask, - ThreadImpersonationToken, - ThreadDescriptorTableEntry, - ThreadEnableAlignmentFaultFixup, - ThreadEventPair_Reusable, - ThreadQuerySetWin32StartAddress, - ThreadZeroTlsCell, - ThreadPerformanceCount, - ThreadAmILastThread, - ThreadIdealProcessor, - ThreadPriorityBoost, - ThreadSetTlsArrayAddress, // Obsolete - ThreadIsIoPending, - ThreadHideFromDebugger, - ThreadBreakOnTermination, - ThreadSwitchLegacyState, - ThreadIsTerminated, - ThreadLastSystemCall, - ThreadIoPriority, - ThreadCycleTime, - ThreadPagePriority, - ThreadActualBasePriority, - ThreadTebInformation, - ThreadCSwitchMon, // Obsolete - ThreadCSwitchPmu, - ThreadWow64Context, - ThreadGroupInformation, - ThreadUmsInformation, // UMS - ThreadCounterProfiling, - ThreadIdealProcessorEx, - MaxThreadInfoClass -} THREADINFOCLASS; - -#define THREAD_CSWITCH_PMU_DISABLE FALSE -#define THREAD_CSWITCH_PMU_ENABLE TRUE - -NTSYSAPI -NTSTATUS -NTAPI -ZwDuplicateObject( - IN HANDLE SourceProcessHandle, - IN HANDLE SourceHandle, - IN HANDLE TargetProcessHandle, - OUT PHANDLE TargetHandle OPTIONAL, - IN ACCESS_MASK DesiredAccess, - IN ULONG Attributes, - IN ULONG Options - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwMakeTemporaryObject( - IN HANDLE Handle - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwClose( - IN HANDLE Handle - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwQuerySecurityObject( - IN HANDLE Handle, - IN SECURITY_INFORMATION RequestedInformation, - OUT PSECURITY_DESCRIPTOR SecurityDescriptor, - IN ULONG SecurityDescriptorLength, - OUT PULONG ReturnLength - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetSecurityObject( - IN HANDLE Handle, - IN SECURITY_INFORMATION SecurityInformation, - IN PSECURITY_DESCRIPTOR SecurityDescriptor - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwCreateDirectoryObject( - OUT PHANDLE DirectoryHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwOpenDirectoryObject( - OUT PHANDLE DirectoryHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryDirectoryObject( - IN HANDLE DirectoryHandle, - OUT PVOID Buffer, - IN ULONG BufferLength, - IN BOOL ReturnSingleEntry, - IN BOOL RestartScan, - IN OUT PULONG Context, - OUT PULONG ReturnLength OPTIONAL - ); - -typedef struct _DIRECTORY_BASIC_INFORMATION { - UNICODE_STRING ObjectName; - UNICODE_STRING ObjectTypeName; -} DIRECTORY_BASIC_INFORMATION, *PDIRECTORY_BASIC_INFORMATION; - -NTSYSAPI -NTSTATUS -NTAPI -ZwCreateSymbolicLinkObject( - OUT PHANDLE SymbolicLinkHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN PUNICODE_STRING TargetName - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwOpenSymbolicLinkObject( - OUT PHANDLE SymbolicLinkHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwQuerySymbolicLinkObject( - IN HANDLE SymbolicLinkHandle, - IN OUT PUNICODE_STRING TargetName, - OUT PULONG ReturnLength OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwAllocateVirtualMemory( - IN HANDLE ProcessHandle, - IN OUT PVOID *BaseAddress, - IN ULONG ZeroBits, - IN OUT PULONG AllocationSize, - IN ULONG AllocationType, - IN ULONG Protect - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwFreeVirtualMemory( - IN HANDLE ProcessHandle, - IN OUT PVOID *BaseAddress, - IN OUT PULONG FreeSize, - IN ULONG FreeType - ); - -typedef enum _MEMORY_INFORMATION_CLASS { - MemoryBasicInformation, - MemoryWorkingSetList, - MemorySectionName, - MemoryBasicVlmInformation -} MEMORY_INFORMATION_CLASS; - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryVirtualMemory( - IN HANDLE ProcessHandle, - IN PVOID BaseAddress, - IN MEMORY_INFORMATION_CLASS MemoryInformationClass, - OUT PVOID MemoryInformation, - IN ULONG MemoryInformationLength, - OUT PULONG ReturnLength OPTIONAL - ); - -typedef struct _MEMORY_BASIC_INFORMATION { // Information Class 0 - PVOID BaseAddress; - PVOID AllocationBase; - ULONG AllocationProtect; - ULONG RegionSize; - ULONG State; - ULONG Protect; - ULONG Type; -} MEMORY_BASIC_INFORMATION, *PMEMORY_BASIC_INFORMATION; - -typedef struct _MEMORY_WORKING_SET_LIST { // Information Class 1 - ULONG NumberOfPages; - ULONG WorkingSetList[1]; -} MEMORY_WORKING_SET_LIST, *PMEMORY_WORKING_SET_LIST; - -typedef struct _MEMORY_SECTION_NAME { // Information Class 2 - UNICODE_STRING SectionFileName; -} MEMORY_SECTION_NAME, *PMEMORY_SECTION_NAME; - -NTSYSAPI -NTSTATUS -NTAPI -ZwLockVirtualMemory( - IN HANDLE ProcessHandle, - IN OUT PVOID *BaseAddress, - IN OUT PULONG LockSize, - IN ULONG LockType - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwUnlockVirtualMemory( - IN HANDLE ProcessHandle, - IN OUT PVOID *BaseAddress, - IN OUT PULONG LockSize, - IN ULONG LockType - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwReadVirtualMemory( - IN HANDLE ProcessHandle, - IN PVOID BaseAddress, - OUT PVOID Buffer, - IN ULONG BufferLength, - OUT PULONG ReturnLength OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwWriteVirtualMemory( - IN HANDLE ProcessHandle, - IN PVOID BaseAddress, - IN PVOID Buffer, - IN ULONG BufferLength, - OUT PULONG ReturnLength OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwProtectVirtualMemory( - IN HANDLE ProcessHandle, - IN OUT PVOID *BaseAddress, - IN OUT PULONG ProtectSize, - IN ULONG NewProtect, - OUT PULONG OldProtect - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwFlushVirtualMemory( - IN HANDLE ProcessHandle, - IN OUT PVOID *BaseAddress, - IN OUT PULONG FlushSize, - OUT PIO_STATUS_BLOCK IoStatusBlock - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwAllocateUserPhysicalPages( - IN HANDLE ProcessHandle, - IN PULONG NumberOfPages, - OUT PULONG PageFrameNumbers - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwFreeUserPhysicalPages( - IN HANDLE ProcessHandle, - IN OUT PULONG NumberOfPages, - IN PULONG PageFrameNumbers - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwMapUserPhysicalPages( - IN PVOID BaseAddress, - IN PULONG NumberOfPages, - IN PULONG PageFrameNumbers - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwMapUserPhysicalPagesScatter( - IN PVOID *BaseAddresses, - IN PULONG NumberOfPages, - IN PULONG PageFrameNumbers - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwGetWriteWatch( - IN HANDLE ProcessHandle, - IN ULONG Flags, - IN PVOID BaseAddress, - IN ULONG RegionSize, - OUT PULONG Buffer, - IN OUT PULONG BufferEntries, - OUT PULONG Granularity - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwResetWriteWatch( - IN HANDLE ProcessHandle, - IN PVOID BaseAddress, - IN ULONG RegionSize - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwCreateSection( - OUT PHANDLE SectionHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN PLARGE_INTEGER SectionSize OPTIONAL, - IN ULONG Protect, - IN ULONG Attributes, - IN HANDLE FileHandle - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwOpenSection( - OUT PHANDLE SectionHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes - ); - -typedef enum _SECTION_INFORMATION_CLASS { - SectionBasicInformation, - SectionImageInformation -} SECTION_INFORMATION_CLASS; - -NTSYSAPI -NTSTATUS -NTAPI -ZwQuerySection( - IN HANDLE SectionHandle, - IN SECTION_INFORMATION_CLASS SectionInformationClass, - OUT PVOID SectionInformation, - IN ULONG SectionInformationLength, - OUT PULONG ResultLength OPTIONAL - ); - -typedef struct _SECTION_BASIC_INFORMATION { // Information Class 0 - PVOID BaseAddress; - ULONG Attributes; - LARGE_INTEGER Size; -} SECTION_BASIC_INFORMATION, *PSECTION_BASIC_INFORMATION; - -typedef struct _SECTION_IMAGE_INFORMATION { // Information Class 1 - PVOID EntryPoint; - ULONG Unknown1; - ULONG StackReserve; - ULONG StackCommit; - ULONG Subsystem; - USHORT MinorSubsystemVersion; - USHORT MajorSubsystemVersion; - ULONG Unknown2; - ULONG Characteristics; - USHORT ImageNumber; - BOOL Executable; - UCHAR Unknown3; - ULONG Unknown4[3]; -} SECTION_IMAGE_INFORMATION, *PSECTION_IMAGE_INFORMATION; - -NTSYSAPI -NTSTATUS -NTAPI -ZwExtendSection( - IN HANDLE SectionHandle, - IN PLARGE_INTEGER SectionSize - ); -#if 0 -NTSYSAPI -NTSTATUS -NTAPI -ZwMapViewOfSection( - IN HANDLE SectionHandle, - IN HANDLE ProcessHandle, - IN OUT PVOID *BaseAddress, - IN ULONG ZeroBits, - IN ULONG CommitSize, - IN OUT PLARGE_INTEGER SectionOffset OPTIONAL, - IN OUT PULONG ViewSize, - IN SECTION_INHERIT InheritDisposition, - IN ULONG AllocationType, - IN ULONG Protect - ); -#endif - -NTSYSAPI -NTSTATUS -NTAPI -ZwUnmapViewOfSection( - IN HANDLE ProcessHandle, - IN PVOID BaseAddress - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwAreMappedFilesTheSame( - IN PVOID Address1, - IN PVOID Address2 - ); - -typedef struct _USER_STACK { - PVOID FixedStackBase; - PVOID FixedStackLimit; - PVOID ExpandableStackBase; - PVOID ExpandableStackLimit; - PVOID ExpandableStackBottom; -} USER_STACK, *PUSER_STACK; - -NTSYSAPI -NTSTATUS -NTAPI -ZwCreateThread( - OUT PHANDLE ThreadHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN HANDLE ProcessHandle, - OUT PCLIENT_ID ClientId, - IN PCONTEXT ThreadContext, - IN PUSER_STACK UserStack, - IN BOOL CreateSuspended - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwOpenThread( - OUT PHANDLE ThreadHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN PCLIENT_ID ClientId - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwTerminateThread( - IN HANDLE ThreadHandle OPTIONAL, - IN NTSTATUS ExitStatus - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryInformationThread( - IN HANDLE ThreadHandle, - IN THREADINFOCLASS ThreadInformationClass, - OUT PVOID ThreadInformation, - IN ULONG ThreadInformationLength, - OUT PULONG ReturnLength OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetInformationThread( - IN HANDLE ThreadHandle, - IN THREADINFOCLASS ThreadInformationClass, - IN PVOID ThreadInformation, - IN ULONG ThreadInformationLength - ); - -typedef struct _THREAD_BASIC_INFORMATION { // Information Class 0 - NTSTATUS ExitStatus; - PNT_TIB TebBaseAddress; - CLIENT_ID ClientId; - KAFFINITY AffinityMask; - KPRIORITY Priority; - KPRIORITY BasePriority; -} THREAD_BASIC_INFORMATION, *PTHREAD_BASIC_INFORMATION; - -NTSYSAPI -NTSTATUS -NTAPI -ZwSuspendThread( - IN HANDLE ThreadHandle, - OUT PULONG PreviousSuspendCount OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwResumeThread( - IN HANDLE ThreadHandle, - OUT PULONG PreviousSuspendCount OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwGetContextThread( - IN HANDLE ThreadHandle, - OUT PCONTEXT Context - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetContextThread( - IN HANDLE ThreadHandle, - IN PCONTEXT Context - ); - -typedef -VOID -(KNORMAL_ROUTINE) ( - IN PVOID NormalContext, - IN PVOID SystemArgument1, - IN PVOID SystemArgument2 - ); -typedef KNORMAL_ROUTINE *PKNORMAL_ROUTINE; - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueueApcThread( - IN HANDLE ThreadHandle, - IN PKNORMAL_ROUTINE ApcRoutine, - IN PVOID ApcContext OPTIONAL, - IN PVOID Argument1 OPTIONAL, - IN PVOID Argument2 OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwTestAlert( - VOID - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwAlertThread( - IN HANDLE ThreadHandle - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwAlertResumeThread( - IN HANDLE ThreadHandle, - OUT PULONG PreviousSuspendCount OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwRegisterThreadTerminatePort( - IN HANDLE PortHandle - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwImpersonateThread( - IN HANDLE ThreadHandle, - IN HANDLE TargetThreadHandle, - IN PSECURITY_QUALITY_OF_SERVICE SecurityQos - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwImpersonateAnonymousToken( - IN HANDLE ThreadHandle - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwCreateProcess( - OUT PHANDLE ProcessHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN HANDLE InheritFromProcessHandle, - IN BOOL InheritHandles, - IN HANDLE SectionHandle OPTIONAL, - IN HANDLE DebugPort OPTIONAL, - IN HANDLE ExceptionPort OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwOpenProcess( - OUT PHANDLE ProcessHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN PCLIENT_ID ClientId OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwTerminateProcess( - IN HANDLE ProcessHandle OPTIONAL, - IN NTSTATUS ExitStatus - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryInformationProcess( - IN HANDLE ProcessHandle, - IN PROCESSINFOCLASS ProcessInformationClass, - OUT PVOID ProcessInformation, - IN ULONG ProcessInformationLength, - OUT PULONG ReturnLength OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetInformationProcess( - IN HANDLE ProcessHandle, - IN PROCESSINFOCLASS ProcessInformationClass, - IN PVOID ProcessInformation, - IN ULONG ProcessInformationLength - ); - -typedef struct _PROCESS_PRIORITY_CLASS { // Information Class 18 - BOOL Foreground; - UCHAR PriorityClass; -} PROCESS_PRIORITY_CLASS, *PPROCESS_PRIORITY_CLASS; - -typedef struct _PROCESS_PARAMETERS { - ULONG AllocationSize; - ULONG Size; - ULONG Flags; - ULONG Zero; - LONG Console; - ULONG ProcessGroup; - HANDLE hStdInput; - HANDLE hStdOutput; - HANDLE hStdError; - UNICODE_STRING CurrentDirectoryName; - HANDLE CurrentDirectoryHandle; - UNICODE_STRING DllPath; - UNICODE_STRING ImageFile; - UNICODE_STRING CommandLine; - PWSTR Environment; - ULONG dwX; - ULONG dwY; - ULONG dwXSize; - ULONG dwYSize; - ULONG dwXCountChars; - ULONG dwYCountChars; - ULONG dwFillAttribute; - ULONG dwFlags; - ULONG wShowWindow; - UNICODE_STRING WindowTitle; - UNICODE_STRING Desktop; - UNICODE_STRING Reserved; - UNICODE_STRING Reserved2; -} PROCESS_PARAMETERS, *PPROCESS_PARAMETERS; - -NTSTATUS -NTAPI -RtlCreateProcessParameters( - OUT PPROCESS_PARAMETERS *ProcessParameters, - IN PUNICODE_STRING ImageFile, - IN PUNICODE_STRING DllPath OPTIONAL, - IN PUNICODE_STRING CurrentDirectory OPTIONAL, - IN PUNICODE_STRING CommandLine OPTIONAL, - IN ULONG CreationFlags, - IN PUNICODE_STRING WindowTitle OPTIONAL, - IN PUNICODE_STRING Desktop OPTIONAL, - IN PUNICODE_STRING Reserved OPTIONAL, - IN PUNICODE_STRING Reserved2 OPTIONAL - ); - -NTSTATUS -NTAPI -RtlDestroyProcessParameters( - IN PPROCESS_PARAMETERS ProcessParameters - ); - -typedef struct _DEBUG_BUFFER { - HANDLE SectionHandle; - PVOID SectionBase; - PVOID RemoteSectionBase; - ULONG SectionBaseDelta; - HANDLE EventPairHandle; - ULONG Unknown[2]; - HANDLE RemoteThreadHandle; - ULONG InfoClassMask; - ULONG SizeOfInfo; - ULONG AllocatedSize; - ULONG SectionSize; - PVOID ModuleInformation; - PVOID BackTraceInformation; - PVOID HeapInformation; - PVOID LockInformation; - PVOID Reserved[8]; -} DEBUG_BUFFER, *PDEBUG_BUFFER; - -#define PDI_MODULES 0x01 -#define PDI_BACKTRACE 0x02 -#define PDI_HEAPS 0x04 -#define PDI_HEAP_TAGS 0x08 -#define PDI_HEAP_BLOCKS 0x10 -#define PDI_LOCKS 0x20 - -typedef struct _DEBUG_MODULE_INFORMATION { // c.f. SYSTEM_MODULE_INFORMATION - ULONG Reserved[2]; - ULONG Base; - ULONG Size; - ULONG Flags; - USHORT Index; - USHORT Unknown; - USHORT LoadCount; - USHORT ModuleNameOffset; - CHAR ImageName[256]; -} DEBUG_MODULE_INFORMATION, *PDEBUG_MODULE_INFORMATION; - -typedef struct _DEBUG_HEAP_INFORMATION { - ULONG Base; - ULONG Flags; - USHORT Granularity; - USHORT Unknown; - ULONG Allocated; - ULONG Committed; - ULONG TagCount; - ULONG BlockCount; - ULONG Reserved[7]; - PVOID Tags; - PVOID Blocks; -} DEBUG_HEAP_INFORMATION, *PDEBUG_HEAP_INFORMATION; - -typedef struct _DEBUG_LOCK_INFORMATION { // c.f. SYSTEM_LOCK_INFORMATION - PVOID Address; - USHORT Type; - USHORT CreatorBackTraceIndex; - ULONG OwnerThreadId; - ULONG ActiveCount; - ULONG ContentionCount; - ULONG EntryCount; - ULONG RecursionCount; - ULONG NumberOfSharedWaiters; - ULONG NumberOfExclusiveWaiters; -} DEBUG_LOCK_INFORMATION, *PDEBUG_LOCK_INFORMATION; - -PDEBUG_BUFFER -NTAPI -RtlCreateQueryDebugBuffer( - IN ULONG Size, - IN BOOL EventPair - ); - -NTSTATUS -NTAPI -RtlQueryProcessDebugInformation( - IN ULONG ProcessId, - IN ULONG DebugInfoClassMask, - IN OUT PDEBUG_BUFFER DebugBuffer - ); - -NTSTATUS -NTAPI -RtlDestroyQueryDebugBuffer( - IN PDEBUG_BUFFER DebugBuffer - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwCreateJobObject( - OUT PHANDLE JobHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwOpenJobObject( - OUT PHANDLE JobHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwTerminateJobObject( - IN HANDLE JobHandle, - IN NTSTATUS ExitStatus - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwAssignProcessToJobObject( - IN HANDLE JobHandle, - IN HANDLE ProcessHandle - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryInformationJobObject( - IN HANDLE JobHandle, - IN JOBOBJECTINFOCLASS JobInformationClass, - OUT PVOID JobInformation, - IN ULONG JobInformationLength, - OUT PULONG ReturnLength OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetInformationJobObject( - IN HANDLE JobHandle, - IN JOBOBJECTINFOCLASS JobInformationClass, - IN PVOID JobInformation, - IN ULONG JobInformationLength - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwCreateToken( - OUT PHANDLE TokenHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN TOKEN_TYPE Type, - IN PLUID AuthenticationId, - IN PLARGE_INTEGER ExpirationTime, - IN PTOKEN_USER User, - IN PTOKEN_GROUPS Groups, - IN PTOKEN_PRIVILEGES Privileges, - IN PTOKEN_OWNER Owner, - IN PTOKEN_PRIMARY_GROUP PrimaryGroup, - IN PTOKEN_DEFAULT_DACL DefaultDacl, - IN PTOKEN_SOURCE Source - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwOpenProcessToken( - IN HANDLE ProcessHandle, - IN ACCESS_MASK DesiredAccess, - OUT PHANDLE TokenHandle - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwOpenThreadToken( - IN HANDLE ThreadHandle, - IN ACCESS_MASK DesiredAccess, - IN BOOL OpenAsSelf, - OUT PHANDLE TokenHandle - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwDuplicateToken( - IN HANDLE ExistingTokenHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN BOOL EffectiveOnly, - IN TOKEN_TYPE TokenType, - OUT PHANDLE NewTokenHandle - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwFilterToken( - IN HANDLE ExistingTokenHandle, - IN ULONG Flags, - IN PTOKEN_GROUPS SidsToDisable, - IN PTOKEN_PRIVILEGES PrivilegesToDelete, - IN PTOKEN_GROUPS SidsToRestricted, - OUT PHANDLE NewTokenHandle - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwAdjustPrivilegesToken( - IN HANDLE TokenHandle, - IN BOOL DisableAllPrivileges, - IN PTOKEN_PRIVILEGES NewState, - IN ULONG BufferLength, - OUT PTOKEN_PRIVILEGES PreviousState OPTIONAL, - OUT PULONG ReturnLength - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwAdjustGroupsToken( - IN HANDLE TokenHandle, - IN BOOL ResetToDefault, - IN PTOKEN_GROUPS NewState, - IN ULONG BufferLength, - OUT PTOKEN_GROUPS PreviousState OPTIONAL, - OUT PULONG ReturnLength - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryInformationToken( - IN HANDLE TokenHandle, - IN TOKEN_INFORMATION_CLASS TokenInformationClass, - OUT PVOID TokenInformation, - IN ULONG TokenInformationLength, - OUT PULONG ReturnLength - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetInformationToken( - IN HANDLE TokenHandle, - IN TOKEN_INFORMATION_CLASS TokenInformationClass, - IN PVOID TokenInformation, - IN ULONG TokenInformationLength - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwWaitForSingleObject( - IN HANDLE Handle, - IN BOOL Alertable, - IN PLARGE_INTEGER Timeout OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSignalAndWaitForSingleObject( - IN HANDLE HandleToSignal, - IN HANDLE HandleToWait, - IN BOOL Alertable, - IN PLARGE_INTEGER Timeout OPTIONAL - ); - -typedef enum _WAIT_TYPE { - WaitAll, - WaitAny -} WAIT_TYPE; - -NTSYSAPI -NTSTATUS -NTAPI -ZwWaitForMultipleObjects( - IN ULONG HandleCount, - IN PHANDLE Handles, - IN WAIT_TYPE WaitType, - IN BOOL Alertable, - IN PLARGE_INTEGER Timeout OPTIONAL - ); - -/* Win2000 DDK includes these declarations but without explicit calling convention specification - -NTSYSAPI -NTSTATUS -NTAPI -ZwCreateTimer( - OUT PHANDLE TimerHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN TIMER_TYPE TimerType - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwOpenTimer( - OUT PHANDLE TimerHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwCancelTimer( - IN HANDLE TimerHandle, - OUT PBOOL PreviousState OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetTimer( - IN HANDLE TimerHandle, - IN PLARGE_INTEGER DueTime, - IN PTIMER_APC_ROUTINE TimerApcRoutine OPTIONAL, - IN PVOID TimerContext, - IN BOOL Resume, - IN LONG Period, - OUT PBOOL PreviousState OPTIONAL - ); - -*/ - -typedef enum _TIMER_INFORMATION_CLASS { - TimerBasicInformation -} TIMER_INFORMATION_CLASS; - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryTimer( - IN HANDLE TimerHandle, - IN TIMER_INFORMATION_CLASS TimerInformationClass, - OUT PVOID TimerInformation, - IN ULONG TimerInformationLength, - OUT PULONG ResultLength OPTIONAL - ); - -typedef struct _TIMER_BASIC_INFORMATION { - LARGE_INTEGER TimeRemaining; - BOOL SignalState; -} TIMER_BASIC_INFORMATION, *PTIMER_BASIC_INFORMATION; - -typedef enum _EVENT_TYPE { - NotificationEvent, - SynchronizationEvent -} EVENT_TYPE; - -NTSYSAPI -NTSTATUS -NTAPI -ZwCreateEvent( - OUT PHANDLE EventHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN EVENT_TYPE EventType, - IN BOOL InitialState - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwOpenEvent( - OUT PHANDLE EventHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetEvent( - IN HANDLE EventHandle, - OUT PULONG PreviousState OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwPulseEvent( - IN HANDLE EventHandle, - OUT PULONG PreviousState OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwResetEvent( - IN HANDLE EventHandle, - OUT PULONG PreviousState OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwClearEvent( - IN HANDLE EventHandle - ); - -typedef enum _EVENT_INFORMATION_CLASS { - EventBasicInformation -} EVENT_INFORMATION_CLASS; - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryEvent( - IN HANDLE EventHandle, - IN EVENT_INFORMATION_CLASS EventInformationClass, - OUT PVOID EventInformation, - IN ULONG EventInformationLength, - OUT PULONG ResultLength OPTIONAL - ); - -typedef struct _EVENT_BASIC_INFORMATION { - EVENT_TYPE EventType; - LONG SignalState; -} EVENT_BASIC_INFORMATION, *PEVENT_BASIC_INFORMATION; - -NTSYSAPI -NTSTATUS -NTAPI -ZwCreateSemaphore( - OUT PHANDLE SemaphoreHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN LONG InitialCount, - IN LONG MaximumCount - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwOpenSemaphore( - OUT PHANDLE SemaphoreHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwReleaseSemaphore( - IN HANDLE SemaphoreHandle, - IN LONG ReleaseCount, - OUT PLONG PreviousCount OPTIONAL - ); - -typedef enum _SEMAPHORE_INFORMATION_CLASS { - SemaphoreBasicInformation -} SEMAPHORE_INFORMATION_CLASS; - -NTSYSAPI -NTSTATUS -NTAPI -ZwQuerySemaphore( - IN HANDLE SemaphoreHandle, - IN SEMAPHORE_INFORMATION_CLASS SemaphoreInformationClass, - OUT PVOID SemaphoreInformation, - IN ULONG SemaphoreInformationLength, - OUT PULONG ResultLength OPTIONAL - ); - -typedef struct _SEMAPHORE_BASIC_INFORMATION { - LONG CurrentCount; - LONG MaximumCount; -} SEMAPHORE_BASIC_INFORMATION, *PSEMAPHORE_BASIC_INFORMATION; - -NTSYSAPI -NTSTATUS -NTAPI -ZwCreateMutant( - OUT PHANDLE MutantHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN BOOL InitialOwner - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwOpenMutant( - OUT PHANDLE MutantHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwReleaseMutant( - IN HANDLE MutantHandle, - OUT PULONG PreviousState - ); - -typedef enum _MUTANT_INFORMATION_CLASS { - MutantBasicInformation -} MUTANT_INFORMATION_CLASS; - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryMutant( - IN HANDLE MutantHandle, - IN MUTANT_INFORMATION_CLASS MutantInformationClass, - OUT PVOID MutantInformation, - IN ULONG MutantInformationLength, - OUT PULONG ResultLength OPTIONAL - ); - -typedef struct _MUTANT_BASIC_INFORMATION { - LONG SignalState; - BOOL Owned; - BOOL Abandoned; -} MUTANT_BASIC_INFORMATION, *PMUTANT_BASIC_INFORMATION; - -NTSYSAPI -NTSTATUS -NTAPI -ZwCreateIoCompletion( - OUT PHANDLE IoCompletionHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN ULONG NumberOfConcurrentThreads - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwOpenIoCompletion( - OUT PHANDLE IoCompletionHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetIoCompletion( - IN HANDLE IoCompletionHandle, - IN ULONG CompletionKey, - IN ULONG CompletionValue, - IN NTSTATUS Status, - IN ULONG Information - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwRemoveIoCompletion( - IN HANDLE IoCompletionHandle, - OUT PULONG CompletionKey, - OUT PULONG CompletionValue, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PLARGE_INTEGER Timeout OPTIONAL - ); - -typedef enum _IO_COMPLETION_INFORMATION_CLASS { - IoCompletionBasicInformation -} IO_COMPLETION_INFORMATION_CLASS; - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryIoCompletion( - IN HANDLE IoCompletionHandle, - IN IO_COMPLETION_INFORMATION_CLASS IoCompletionInformationClass, - OUT PVOID IoCompletionInformation, - IN ULONG IoCompletionInformationLength, - OUT PULONG ResultLength OPTIONAL - ); - -typedef struct _IO_COMPLETION_BASIC_INFORMATION { - LONG SignalState; -} IO_COMPLETION_BASIC_INFORMATION, *PIO_COMPLETION_BASIC_INFORMATION; - -NTSYSAPI -NTSTATUS -NTAPI -ZwCreateEventPair( - OUT PHANDLE EventPairHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwOpenEventPair( - OUT PHANDLE EventPairHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwWaitLowEventPair( - IN HANDLE EventPairHandle - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwWaitHighEventPair( - IN HANDLE EventPairHandle - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetLowWaitHighEventPair( - IN HANDLE EventPairHandle - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetHighWaitLowEventPair( - IN HANDLE EventPairHandle - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetLowEventPair( - IN HANDLE EventPairHandle - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetHighEventPair( - IN HANDLE EventPairHandle - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwQuerySystemTime( - OUT PLARGE_INTEGER CurrentTime - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetSystemTime( - IN PLARGE_INTEGER NewTime, - OUT PLARGE_INTEGER OldTime OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryPerformanceCounter( - OUT PLARGE_INTEGER PerformanceCount, - OUT PLARGE_INTEGER PerformanceFrequency OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetTimerResolution( - IN ULONG RequestedResolution, - IN BOOL Set, - OUT PULONG ActualResolution - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryTimerResolution( - OUT PULONG CoarsestResolution, - OUT PULONG FinestResolution, - OUT PULONG ActualResolution - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwDelayExecution( - IN BOOL Alertable, - IN PLARGE_INTEGER Interval - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwYieldExecution( - VOID - ); - -NTSYSAPI -ULONG -NTAPI -ZwGetTickCount( - VOID - ); - -typedef enum _KPROFILE_SOURCE { - ProfileTime, - ProfileAlignmentFixup, - ProfileTotalIssues, - ProfilePipelineDry, - ProfileLoadInstructions, - ProfilePipelineFrozen, - ProfileBranchInstructions, - ProfileTotalNonissues, - ProfileDcacheMisses, - ProfileIcacheMisses, - ProfileCacheMisses, - ProfileBranchMispredictions, - ProfileStoreInstructions, - ProfileFpInstructions, - ProfileIntegerInstructions, - Profile2Issue, - Profile3Issue, - Profile4Issue, - ProfileSpecialInstructions, - ProfileTotalCycles, - ProfileIcacheIssues, - ProfileDcacheAccesses, - ProfileMemoryBarrierCycles, - ProfileLoadLinkedIssues, - ProfileMaximum -} KPROFILE_SOURCE; - -NTSYSAPI -NTSTATUS -NTAPI -ZwCreateProfile( - OUT PHANDLE ProfileHandle, - IN HANDLE ProcessHandle, - IN PVOID Base, - IN ULONG Size, - IN ULONG BucketShift, - IN PULONG Buffer, - IN ULONG BufferLength, - IN KPROFILE_SOURCE Source, - IN ULONG ProcessorMask - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetIntervalProfile( - IN ULONG Interval, - IN KPROFILE_SOURCE Source - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryIntervalProfile( - IN KPROFILE_SOURCE Source, - OUT PULONG Interval - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwStartProfile( - IN HANDLE ProfileHandle - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwStopProfile( - IN HANDLE ProfileHandle - ); - -typedef struct _PORT_MESSAGE { - USHORT DataSize; - USHORT MessageSize; - USHORT MessageType; - USHORT VirtualRangesOffset; - CLIENT_ID ClientId; - ULONG MessageId; - ULONG SectionSize; - // UCHAR Data[]; -} PORT_MESSAGE, *PPORT_MESSAGE; - -typedef enum _LPC_TYPE { - LPC_NEW_MESSAGE, // A new message - LPC_REQUEST, // A request message - LPC_REPLY, // A reply to a request message - LPC_DATAGRAM, // - LPC_LOST_REPLY, // - LPC_PORT_CLOSED, // Sent when port is deleted - LPC_CLIENT_DIED, // Messages to thread termination ports - LPC_EXCEPTION, // Messages to thread exception port - LPC_DEBUG_EVENT, // Messages to thread debug port - LPC_ERROR_EVENT, // Used by ZwRaiseHardError - LPC_CONNECTION_REQUEST // Used by ZwConnectPort -} LPC_TYPE; - -typedef struct _PORT_SECTION_WRITE { - ULONG Length; - HANDLE SectionHandle; - ULONG SectionOffset; - ULONG ViewSize; - PVOID ViewBase; - PVOID TargetViewBase; -} PORT_SECTION_WRITE, *PPORT_SECTION_WRITE; - -typedef struct _PORT_SECTION_READ { - ULONG Length; - ULONG ViewSize; - ULONG ViewBase; -} PORT_SECTION_READ, *PPORT_SECTION_READ; - -NTSYSAPI -NTSTATUS -NTAPI -ZwCreatePort( - OUT PHANDLE PortHandle, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN ULONG MaxDataSize, - IN ULONG MaxMessageSize, - IN ULONG Reserved - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwCreateWaitablePort( - OUT PHANDLE PortHandle, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN ULONG MaxDataSize, - IN ULONG MaxMessageSize, - IN ULONG Reserved - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwConnectPort( - OUT PHANDLE PortHandle, - IN PUNICODE_STRING PortName, - IN PSECURITY_QUALITY_OF_SERVICE SecurityQos, - IN OUT PPORT_SECTION_WRITE WriteSection OPTIONAL, - IN OUT PPORT_SECTION_READ ReadSection OPTIONAL, - OUT PULONG MaxMessageSize OPTIONAL, - IN OUT PVOID ConnectData OPTIONAL, - IN OUT PULONG ConnectDataLength OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSecureConnectPort( - OUT PHANDLE PortHandle, - IN PUNICODE_STRING PortName, - IN PSECURITY_QUALITY_OF_SERVICE SecurityQos, - IN OUT PPORT_SECTION_WRITE WriteSection OPTIONAL, - IN PSID ServerSid OPTIONAL, - IN OUT PPORT_SECTION_READ ReadSection OPTIONAL, - OUT PULONG MaxMessageSize OPTIONAL, - IN OUT PVOID ConnectData OPTIONAL, - IN OUT PULONG ConnectDataLength OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwListenPort( - IN HANDLE PortHandle, - OUT PPORT_MESSAGE Message - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwAcceptConnectPort( - OUT PHANDLE PortHandle, - IN ULONG PortIdentifier, - IN PPORT_MESSAGE Message, - IN BOOL Accept, - IN OUT PPORT_SECTION_WRITE WriteSection OPTIONAL, - IN OUT PPORT_SECTION_READ ReadSection OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwCompleteConnectPort( - IN HANDLE PortHandle - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwRequestPort( - IN HANDLE PortHandle, - IN PPORT_MESSAGE RequestMessage - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwRequestWaitReplyPort( - IN HANDLE PortHandle, - IN PPORT_MESSAGE RequestMessage, - OUT PPORT_MESSAGE ReplyMessage - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwReplyPort( - IN HANDLE PortHandle, - IN PPORT_MESSAGE ReplyMessage - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwReplyWaitReplyPort( - IN HANDLE PortHandle, - IN OUT PPORT_MESSAGE ReplyMessage - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwReplyWaitReceivePort( - IN HANDLE PortHandle, - OUT PULONG PortIdentifier OPTIONAL, - IN PPORT_MESSAGE ReplyMessage OPTIONAL, - OUT PPORT_MESSAGE Message - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwReplyWaitReceivePortEx( - IN HANDLE PortHandle, - OUT PULONG PortIdentifier OPTIONAL, - IN PPORT_MESSAGE ReplyMessage OPTIONAL, - OUT PPORT_MESSAGE Message, - IN PLARGE_INTEGER Timeout - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwReadRequestData( - IN HANDLE PortHandle, - IN PPORT_MESSAGE Message, - IN ULONG Index, - OUT PVOID Buffer, - IN ULONG BufferLength, - OUT PULONG ReturnLength OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwWriteRequestData( - IN HANDLE PortHandle, - IN PPORT_MESSAGE Message, - IN ULONG Index, - IN PVOID Buffer, - IN ULONG BufferLength, - OUT PULONG ReturnLength OPTIONAL - ); - -typedef enum _PORT_INFORMATION_CLASS { - PortBasicInformation -} PORT_INFORMATION_CLASS; - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryInformationPort( - IN HANDLE PortHandle, - IN PORT_INFORMATION_CLASS PortInformationClass, - OUT PVOID PortInformation, - IN ULONG PortInformationLength, - OUT PULONG ReturnLength OPTIONAL - ); - -typedef struct _PORT_BASIC_INFORMATION { -} PORT_BASIC_INFORMATION, *PPORT_BASIC_INFORMATION; - -NTSYSAPI -NTSTATUS -NTAPI -ZwImpersonateClientOfPort( - IN HANDLE PortHandle, - IN PPORT_MESSAGE Message - ); - -#define FILE_ANY_ACCESS 0 -#define FILE_SPECIAL_ACCESS (FILE_ANY_ACCESS) -#define FILE_READ_ACCESS ( 0x0001 ) // file & pipe -#define FILE_WRITE_ACCESS ( 0x0002 ) // file & pipe - - - -// -// Define access rights to files and directories -// - -// -// The FILE_READ_DATA and FILE_WRITE_DATA constants are also defined in -// devioctl.h as FILE_READ_ACCESS and FILE_WRITE_ACCESS. The values for these -// constants *MUST* always be in sync. -// The values are redefined in devioctl.h because they must be available to -// both DOS and NT. -// - -#define FILE_READ_DATA ( 0x0001 ) // file & pipe -#define FILE_LIST_DIRECTORY ( 0x0001 ) // directory - -#define FILE_WRITE_DATA ( 0x0002 ) // file & pipe -#define FILE_ADD_FILE ( 0x0002 ) // directory - -#define FILE_APPEND_DATA ( 0x0004 ) // file -#define FILE_ADD_SUBDIRECTORY ( 0x0004 ) // directory -#define FILE_CREATE_PIPE_INSTANCE ( 0x0004 ) // named pipe - - -#define FILE_READ_EA ( 0x0008 ) // file & directory - -#define FILE_WRITE_EA ( 0x0010 ) // file & directory - -#define FILE_EXECUTE ( 0x0020 ) // file -#define FILE_TRAVERSE ( 0x0020 ) // directory - -#define FILE_DELETE_CHILD ( 0x0040 ) // directory - -#define FILE_READ_ATTRIBUTES ( 0x0080 ) // all - -#define FILE_WRITE_ATTRIBUTES ( 0x0100 ) // all - -#define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF) - -#define FILE_GENERIC_READ (STANDARD_RIGHTS_READ |\ - FILE_READ_DATA |\ - FILE_READ_ATTRIBUTES |\ - FILE_READ_EA |\ - SYNCHRONIZE) - - -#define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\ - FILE_WRITE_DATA |\ - FILE_WRITE_ATTRIBUTES |\ - FILE_WRITE_EA |\ - FILE_APPEND_DATA |\ - SYNCHRONIZE) - - -#define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\ - FILE_READ_ATTRIBUTES |\ - FILE_EXECUTE |\ - SYNCHRONIZE) - - - - -// -// Define share access rights to files and directories -// - -#define FILE_SHARE_READ 0x00000001 -#define FILE_SHARE_WRITE 0x00000002 -#define FILE_SHARE_DELETE 0x00000004 -#define FILE_SHARE_VALID_FLAGS 0x00000007 - -// -// Define the file attributes values -// -// Note: 0x00000008 is reserved for use for the old DOS VOLID (volume ID) -// and is therefore not considered valid in NT. -// -// Note: Note also that the order of these flags is set to allow both the -// FAT and the Pinball File Systems to directly set the attributes -// flags in attributes words without having to pick each flag out -// individually. The order of these flags should not be changed! -// - -#define FILE_ATTRIBUTE_READONLY 0x00000001 -#define FILE_ATTRIBUTE_HIDDEN 0x00000002 -#define FILE_ATTRIBUTE_SYSTEM 0x00000004 -//OLD DOS VOLID 0x00000008 - -#define FILE_ATTRIBUTE_DIRECTORY 0x00000010 -#define FILE_ATTRIBUTE_ARCHIVE 0x00000020 -#define FILE_ATTRIBUTE_DEVICE 0x00000040 -#define FILE_ATTRIBUTE_NORMAL 0x00000080 - -#define FILE_ATTRIBUTE_TEMPORARY 0x00000100 -#define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200 -#define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400 -#define FILE_ATTRIBUTE_COMPRESSED 0x00000800 - -#define FILE_ATTRIBUTE_OFFLINE 0x00001000 -#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000 -#define FILE_ATTRIBUTE_ENCRYPTED 0x00004000 - -#define FILE_ATTRIBUTE_VIRTUAL 0x00010000 - -#define FILE_ATTRIBUTE_VALID_FLAGS 0x00007fb7 -#define FILE_ATTRIBUTE_VALID_SET_FLAGS 0x000031a7 - -// -// Define the create disposition values -// - -#define FILE_SUPERSEDE 0x00000000 -#define FILE_OPEN 0x00000001 -#define FILE_CREATE 0x00000002 -#define FILE_OPEN_IF 0x00000003 -#define FILE_OVERWRITE 0x00000004 -#define FILE_OVERWRITE_IF 0x00000005 -#define FILE_MAXIMUM_DISPOSITION 0x00000005 - -// -// Define the create/open option flags -// - -#define FILE_DIRECTORY_FILE 0x00000001 -#define FILE_WRITE_THROUGH 0x00000002 -#define FILE_SEQUENTIAL_ONLY 0x00000004 -#define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008 - -#define FILE_SYNCHRONOUS_IO_ALERT 0x00000010 -#define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020 -#define FILE_NON_DIRECTORY_FILE 0x00000040 -#define FILE_CREATE_TREE_CONNECTION 0x00000080 - -#define FILE_COMPLETE_IF_OPLOCKED 0x00000100 -#define FILE_NO_EA_KNOWLEDGE 0x00000200 -#define FILE_OPEN_REMOTE_INSTANCE 0x00000400 -#define FILE_RANDOM_ACCESS 0x00000800 - -#define FILE_DELETE_ON_CLOSE 0x00001000 -#define FILE_OPEN_BY_FILE_ID 0x00002000 -#define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000 -#define FILE_NO_COMPRESSION 0x00008000 - -#if (NTDDI_VERSION >= NTDDI_WIN7) -#define FILE_OPEN_REQUIRING_OPLOCK 0x00010000 -#define FILE_DISALLOW_EXCLUSIVE 0x00020000 -#endif /* NTDDI_VERSION >= NTDDI_WIN7 */ - -#define FILE_RESERVE_OPFILTER 0x00100000 -#define FILE_OPEN_REPARSE_POINT 0x00200000 -#define FILE_OPEN_NO_RECALL 0x00400000 -#define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000 - - -#define FILE_VALID_OPTION_FLAGS 0x00ffffff -#define FILE_VALID_PIPE_OPTION_FLAGS 0x00000032 -#define FILE_VALID_MAILSLOT_OPTION_FLAGS 0x00000032 -#define FILE_VALID_SET_FLAGS 0x00000036 - -// -// Define the I/O status information return values for NtCreateFile/NtOpenFile -// - -#define FILE_SUPERSEDED 0x00000000 -#define FILE_OPENED 0x00000001 -#define FILE_CREATED 0x00000002 -#define FILE_OVERWRITTEN 0x00000003 -#define FILE_EXISTS 0x00000004 -#define FILE_DOES_NOT_EXIST 0x00000005 - -// -// Define special ByteOffset parameters for read and write operations -// - -#define FILE_WRITE_TO_END_OF_FILE 0xffffffff -#define FILE_USE_FILE_POINTER_POSITION 0xfffffffe - -// -// Define alignment requirement values -// - -#define FILE_BYTE_ALIGNMENT 0x00000000 -#define FILE_WORD_ALIGNMENT 0x00000001 -#define FILE_LONG_ALIGNMENT 0x00000003 -#define FILE_QUAD_ALIGNMENT 0x00000007 -#define FILE_OCTA_ALIGNMENT 0x0000000f -#define FILE_32_BYTE_ALIGNMENT 0x0000001f -#define FILE_64_BYTE_ALIGNMENT 0x0000003f -#define FILE_128_BYTE_ALIGNMENT 0x0000007f -#define FILE_256_BYTE_ALIGNMENT 0x000000ff -#define FILE_512_BYTE_ALIGNMENT 0x000001ff - -// -// Define the maximum length of a filename string -// - -#define MAXIMUM_FILENAME_LENGTH 256 - -// -// Define the various device characteristics flags -// - -#define FILE_REMOVABLE_MEDIA 0x00000001 -#define FILE_READ_ONLY_DEVICE 0x00000002 -#define FILE_FLOPPY_DISKETTE 0x00000004 -#define FILE_WRITE_ONCE_MEDIA 0x00000008 -#define FILE_REMOTE_DEVICE 0x00000010 -#define FILE_DEVICE_IS_MOUNTED 0x00000020 -#define FILE_VIRTUAL_VOLUME 0x00000040 -#define FILE_AUTOGENERATED_DEVICE_NAME 0x00000080 -#define FILE_DEVICE_SECURE_OPEN 0x00000100 -#define FILE_CHARACTERISTIC_PNP_DEVICE 0x00000800 -#define FILE_CHARACTERISTIC_TS_DEVICE 0x00001000 -#define FILE_CHARACTERISTIC_WEBDAV_DEVICE 0x00002000 - - -NTSYSAPI -NTSTATUS -NTAPI -ZwCreateFile( - OUT PHANDLE FileHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PLARGE_INTEGER AllocationSize OPTIONAL, - IN ULONG FileAttributes, - IN ULONG ShareAccess, - IN ULONG CreateDisposition, - IN ULONG CreateOptions, - IN PVOID EaBuffer OPTIONAL, - IN ULONG EaLength - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwOpenFile( - OUT PHANDLE FileHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN ULONG ShareAccess, - IN ULONG OpenOptions - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwDeleteFile( - IN POBJECT_ATTRIBUTES ObjectAttributes - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwFlushBuffersFile( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwCancelIoFile( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock - ); - -typedef -VOID -(NTAPI *PIO_APC_ROUTINE) ( - __in PVOID ApcContext, - __in PIO_STATUS_BLOCK IoStatusBlock, - __in ULONG Reserved - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwReadFile( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID Buffer, - IN ULONG Length, - IN PLARGE_INTEGER ByteOffset OPTIONAL, - IN PULONG Key OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwWriteFile( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PVOID Buffer, - IN ULONG Length, - IN PLARGE_INTEGER ByteOffset OPTIONAL, - IN PULONG Key OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwReadFileScatter( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PFILE_SEGMENT_ELEMENT Buffer, - IN ULONG Length, - IN PLARGE_INTEGER ByteOffset OPTIONAL, - IN PULONG Key OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwWriteFileGather( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PFILE_SEGMENT_ELEMENT Buffer, - IN ULONG Length, - IN PLARGE_INTEGER ByteOffset OPTIONAL, - IN PULONG Key OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwLockFile( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PULARGE_INTEGER LockOffset, - IN PULARGE_INTEGER LockLength, - IN ULONG Key, - IN BOOL FailImmediately, - IN BOOL ExclusiveLock - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwUnlockFile( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PULARGE_INTEGER LockOffset, - IN PULARGE_INTEGER LockLength, - IN ULONG Key - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwDeviceIoControlFile( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN ULONG IoControlCode, - IN PVOID InputBuffer OPTIONAL, - IN ULONG InputBufferLength, - OUT PVOID OutputBuffer OPTIONAL, - IN ULONG OutputBufferLength - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwFsControlFile( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN ULONG FsControlCode, - IN PVOID InputBuffer OPTIONAL, - IN ULONG InputBufferLength, - OUT PVOID OutputBuffer OPTIONAL, - IN ULONG OutputBufferLength - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwNotifyChangeDirectoryFile( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PFILE_NOTIFY_INFORMATION Buffer, - IN ULONG BufferLength, - IN ULONG NotifyFilter, - IN BOOL WatchSubtree - ); - -typedef struct _FILE_BASIC_INFORMATION { - LARGE_INTEGER CreationTime; - LARGE_INTEGER LastAccessTime; - LARGE_INTEGER LastWriteTime; - LARGE_INTEGER ChangeTime; - ULONG FileAttributes; -} FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION; - -typedef struct _FILE_STANDARD_INFORMATION { - LARGE_INTEGER AllocationSize; - LARGE_INTEGER EndOfFile; - ULONG NumberOfLinks; - BOOL DeletePending; - BOOL Directory; -} FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION; - - -typedef struct _FILE_POSITION_INFORMATION { - LARGE_INTEGER CurrentByteOffset; -} FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION; - - -typedef struct _FILE_NETWORK_OPEN_INFORMATION { - LARGE_INTEGER CreationTime; - LARGE_INTEGER LastAccessTime; - LARGE_INTEGER LastWriteTime; - LARGE_INTEGER ChangeTime; - LARGE_INTEGER AllocationSize; - LARGE_INTEGER EndOfFile; - ULONG FileAttributes; -} FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION; - -typedef struct _FILE_GET_EA_INFORMATION { - ULONG NextEntryOffset; - UCHAR EaNameLength; - CHAR EaName[1]; -} FILE_GET_EA_INFORMATION, *PFILE_GET_EA_INFORMATION; - -typedef struct _FILE_FULL_EA_INFORMATION { - ULONG NextEntryOffset; - UCHAR Flags; - UCHAR EaNameLength; - USHORT EaValueLength; - CHAR EaName[1]; -} FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION; - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryEaFile( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PFILE_FULL_EA_INFORMATION Buffer, - IN ULONG BufferLength, - IN BOOL ReturnSingleEntry, - IN PFILE_GET_EA_INFORMATION EaList OPTIONAL, - IN ULONG EaListLength, - IN PULONG EaIndex OPTIONAL, - IN BOOL RestartScan - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetEaFile( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PFILE_FULL_EA_INFORMATION Buffer, - IN ULONG BufferLength - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwCreateNamedPipeFile( - OUT PHANDLE FileHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN ULONG ShareAccess, - IN ULONG CreateDisposition, - IN ULONG CreateOptions, - IN BOOL TypeMessage, - IN BOOL ReadmodeMessage, - IN BOOL Nonblocking, - IN ULONG MaxInstances, - IN ULONG InBufferSize, - IN ULONG OutBufferSize, - IN PLARGE_INTEGER DefaultTimeout OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwCreateMailslotFile( - OUT PHANDLE FileHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN ULONG CreateOptions, - IN ULONG Unknown, - IN ULONG MaxMessageSize, - IN PLARGE_INTEGER ReadTimeout OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryVolumeInformationFile( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID VolumeInformation, - IN ULONG VolumeInformationLength, - IN FS_INFORMATION_CLASS VolumeInformationClass - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetVolumeInformationFile( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PVOID Buffer, - IN ULONG BufferLength, - IN FS_INFORMATION_CLASS VolumeInformationClass - ); - -typedef struct _FILE_FS_VOLUME_INFORMATION { - LARGE_INTEGER VolumeCreationTime; - ULONG VolumeSerialNumber; - ULONG VolumeLabelLength; - UCHAR Unknown; - WCHAR VolumeLabel[1]; -} FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION; - -typedef struct _FILE_FS_LABEL_INFORMATION { - ULONG VolumeLabelLength; - WCHAR VolumeLabel; -} FILE_FS_LABEL_INFORMATION, *PFILE_FS_LABEL_INFORMATION; - -typedef struct _FILE_FS_SIZE_INFORMATION { - LARGE_INTEGER TotalAllocationUnits; - LARGE_INTEGER AvailableAllocationUnits; - ULONG SectorsPerAllocationUnit; - ULONG BytesPerSector; -} FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION; - -typedef struct _FILE_FS_ATTRIBUTE_INFORMATION { - ULONG FileSystemFlags; - ULONG MaximumComponentNameLength; - ULONG FileSystemNameLength; - WCHAR FileSystemName[1]; -} FILE_FS_ATTRIBUTE_INFORMATION, *PFILE_FS_ATTRIBUTE_INFORMATION; - -typedef struct _FILE_FS_CONTROL_INFORMATION { - LARGE_INTEGER Reserved[3]; - LARGE_INTEGER DefaultQuotaThreshold; - LARGE_INTEGER DefaultQuotaLimit; - ULONG QuotaFlags; -} FILE_FS_CONTROL_INFORMATION, *PFILE_FS_CONTROL_INFORMATION; - -typedef struct _FILE_FS_FULL_SIZE_INFORMATION { - LARGE_INTEGER TotalQuotaAllocationUnits; - LARGE_INTEGER AvailableQuotaAllocationUnits; - LARGE_INTEGER AvailableAllocationUnits; - ULONG SectorsPerAllocationUnit; - ULONG BytesPerSector; -} FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION; - -typedef struct _FILE_FS_OBJECT_ID_INFORMATION { - UUID VolumeObjectId; - ULONG VolumeObjectIdExtendedInfo[12]; -} FILE_FS_OBJECT_ID_INFORMATION, *PFILE_FS_OBJECT_ID_INFORMATION; - -typedef struct _FILE_USER_QUOTA_INFORMATION { - ULONG NextEntryOffset; - ULONG SidLength; - LARGE_INTEGER ChangeTime; - LARGE_INTEGER QuotaUsed; - LARGE_INTEGER QuotaThreshold; - LARGE_INTEGER QuotaLimit; - SID Sid[1]; -} FILE_USER_QUOTA_INFORMATION, *PFILE_USER_QUOTA_INFORMATION; - -typedef struct _FILE_QUOTA_LIST_INFORMATION { - ULONG NextEntryOffset; - ULONG SidLength; - SID Sid[1]; -} FILE_QUOTA_LIST_INFORMATION, *PFILE_QUOTA_LIST_INFORMATION; - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryQuotaInformationFile( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PFILE_USER_QUOTA_INFORMATION Buffer, - IN ULONG BufferLength, - IN BOOL ReturnSingleEntry, - IN PFILE_QUOTA_LIST_INFORMATION QuotaList OPTIONAL, - IN ULONG QuotaListLength, - IN PSID ResumeSid OPTIONAL, - IN BOOL RestartScan - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetQuotaInformationFile( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PFILE_USER_QUOTA_INFORMATION Buffer, - IN ULONG BufferLength - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryAttributesFile( - IN POBJECT_ATTRIBUTES ObjectAttributes, - OUT PFILE_BASIC_INFORMATION FileInformation - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryFullAttributesFile( - IN POBJECT_ATTRIBUTES ObjectAttributes, - OUT PFILE_NETWORK_OPEN_INFORMATION FileInformation - ); - -typedef enum _FILE_INFORMATION_CLASS { - FileDirectoryInformation = 1, - FileFullDirectoryInformation, // 2 - FileBothDirectoryInformation, // 3 - FileBasicInformation, // 4 - FileStandardInformation, // 5 - FileInternalInformation, // 6 - FileEaInformation, // 7 - FileAccessInformation, // 8 - FileNameInformation, // 9 - FileRenameInformation, // 10 - FileLinkInformation, // 11 - FileNamesInformation, // 12 - FileDispositionInformation, // 13 - FilePositionInformation, // 14 - FileFullEaInformation, // 15 - FileModeInformation, // 16 - FileAlignmentInformation, // 17 - FileAllInformation, // 18 - FileAllocationInformation, // 19 - FileEndOfFileInformation, // 20 - FileAlternateNameInformation, // 21 - FileStreamInformation, // 22 - FilePipeInformation, // 23 - FilePipeLocalInformation, // 24 - FilePipeRemoteInformation, // 25 - FileMailslotQueryInformation, // 26 - FileMailslotSetInformation, // 27 - FileCompressionInformation, // 28 - FileObjectIdInformation, // 29 - FileCompletionInformation, // 30 - FileMoveClusterInformation, // 31 - FileQuotaInformation, // 32 - FileReparsePointInformation, // 33 - FileNetworkOpenInformation, // 34 - FileAttributeTagInformation, // 35 - FileTrackingInformation, // 36 - FileIdBothDirectoryInformation, // 37 - FileIdFullDirectoryInformation, // 38 - FileValidDataLengthInformation, // 39 - FileShortNameInformation, // 40 - FileIoCompletionNotificationInformation, // 41 - FileIoStatusBlockRangeInformation, // 42 - FileIoPriorityHintInformation, // 43 - FileSfioReserveInformation, // 44 - FileSfioVolumeInformation, // 45 - FileHardLinkInformation, // 46 - FileProcessIdsUsingFileInformation, // 47 - FileNormalizedNameInformation, // 48 - FileNetworkPhysicalNameInformation, // 49 - FileIdGlobalTxDirectoryInformation, // 50 - FileIsRemoteDeviceInformation, // 51 - FileAttributeCacheInformation, // 52 - FileNumaNodeInformation, // 53 - FileStandardLinkInformation, // 54 - FileRemoteProtocolInformation, // 55 - FileMaximumInformation -} FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS; - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryInformationFile( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID FileInformation, - IN ULONG FileInformationLength, - IN FILE_INFORMATION_CLASS FileInformationClass - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetInformationFile( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PVOID FileInformation, - IN ULONG FileInformationLength, - IN FILE_INFORMATION_CLASS FileInformationClass - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryDirectoryFile( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID FileInformation, - IN ULONG FileInformationLength, - IN FILE_INFORMATION_CLASS FileInformationClass, - IN BOOL ReturnSingleEntry, - IN PUNICODE_STRING FileName OPTIONAL, - IN BOOL RestartScan - ); - -typedef struct _FILE_DIRECTORY_INFORMATION { // Information Class 1 - ULONG NextEntryOffset; - ULONG Unknown; - LARGE_INTEGER CreationTime; - LARGE_INTEGER LastAccessTime; - LARGE_INTEGER LastWriteTime; - LARGE_INTEGER ChangeTime; - LARGE_INTEGER EndOfFile; - LARGE_INTEGER AllocationSize; - ULONG FileAttributes; - ULONG FileNameLength; - WCHAR FileName[1]; -} FILE_DIRECTORY_INFORMATION, *PFILE_DIRECTORY_INFORMATION; - -typedef struct _FILE_FULL_DIRECTORY_INFORMATION { // Information Class 2 - ULONG NextEntryOffset; - ULONG Unknown; - LARGE_INTEGER CreationTime; - LARGE_INTEGER LastAccessTime; - LARGE_INTEGER LastWriteTime; - LARGE_INTEGER ChangeTime; - LARGE_INTEGER EndOfFile; - LARGE_INTEGER AllocationSize; - ULONG FileAttributes; - ULONG FileNameLength; - ULONG EaInformationLength; - WCHAR FileName[1]; -} FILE_FULL_DIRECTORY_INFORMATION, *PFILE_FULL_DIRECTORY_INFORMATION; - -typedef struct _FILE_BOTH_DIRECTORY_INFORMATION { // Information Class 3 - ULONG NextEntryOffset; - ULONG Unknown; - LARGE_INTEGER CreationTime; - LARGE_INTEGER LastAccessTime; - LARGE_INTEGER LastWriteTime; - LARGE_INTEGER ChangeTime; - LARGE_INTEGER EndOfFile; - LARGE_INTEGER AllocationSize; - ULONG FileAttributes; - ULONG FileNameLength; - ULONG EaInformationLength; - UCHAR AlternateNameLength; - WCHAR AlternateName[12]; - WCHAR FileName[1]; -} FILE_BOTH_DIRECTORY_INFORMATION, *PFILE_BOTH_DIRECTORY_INFORMATION; - -typedef struct _FILE_INTERNAL_INFORMATION { // Information Class 6 - LARGE_INTEGER FileId; -} FILE_INTERNAL_INFORMATION, *PFILE_INTERNAL_INFORMATION; - -typedef struct _FILE_EA_INFORMATION { // Information Class 7 - ULONG EaInformationLength; -} FILE_EA_INFORMATION, *PFILE_EA_INFORMATION; - -typedef struct _FILE_ACCESS_INFORMATION { // Information Class 8 - ACCESS_MASK GrantedAccess; -} FILE_ACCESS_INFORMATION, *PFILE_ACCESS_INFORMATION; - -typedef struct _FILE_NAME_INFORMATION { // Information Classes 9 and 21 - ULONG FileNameLength; - WCHAR FileName[1]; -} FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION, - FILE_ALTERNATE_NAME_INFORMATION, *PFILE_ALTERNATE_NAME_INFORMATION; - -typedef struct _FILE_LINK_RENAME_INFORMATION { // Info Classes 10 and 11 - BOOL ReplaceIfExists; - HANDLE RootDirectory; - ULONG FileNameLength; - WCHAR FileName[1]; -} FILE_LINK_INFORMATION, *PFILE_LINK_INFORMATION, - FILE_RENAME_INFORMATION, *PFILE_RENAME_INFORMATION; - -typedef struct _FILE_NAMES_INFORMATION { // Information Class 12 - ULONG NextEntryOffset; - ULONG Unknown; - ULONG FileNameLength; - WCHAR FileName[1]; -} FILE_NAMES_INFORMATION, *PFILE_NAMES_INFORMATION; - -typedef struct _FILE_MODE_INFORMATION { // Information Class 16 - ULONG Mode; -} FILE_MODE_INFORMATION, *PFILE_MODE_INFORMATION; - -typedef struct _FILE_ALIGNMENT_INFORMATION { - ULONG AlignmentRequirement; -} FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION; - -typedef struct _FILE_ALL_INFORMATION { // Information Class 18 - FILE_BASIC_INFORMATION BasicInformation; - FILE_STANDARD_INFORMATION StandardInformation; - FILE_INTERNAL_INFORMATION InternalInformation; - FILE_EA_INFORMATION EaInformation; - FILE_ACCESS_INFORMATION AccessInformation; - FILE_POSITION_INFORMATION PositionInformation; - FILE_MODE_INFORMATION ModeInformation; - FILE_ALIGNMENT_INFORMATION AlignmentInformation; - FILE_NAME_INFORMATION NameInformation; -} FILE_ALL_INFORMATION, *PFILE_ALL_INFORMATION; - -typedef struct _FILE_ALLOCATION_INFORMATION { // Information Class 19 - LARGE_INTEGER AllocationSize; -} FILE_ALLOCATION_INFORMATION, *PFILE_ALLOCATION_INFORMATION; - -typedef struct _FILE_STREAM_INFORMATION { // Information Class 22 - ULONG NextEntryOffset; - ULONG StreamNameLength; - LARGE_INTEGER EndOfStream; - LARGE_INTEGER AllocationSize; - WCHAR StreamName[1]; -} FILE_STREAM_INFORMATION, *PFILE_STREAM_INFORMATION; - -typedef struct _FILE_PIPE_INFORMATION { // Information Class 23 - ULONG ReadModeMessage; - ULONG WaitModeBlocking; -} FILE_PIPE_INFORMATION, *PFILE_PIPE_INFORMATION; - -typedef struct _FILE_PIPE_LOCAL_INFORMATION { // Information Class 24 - ULONG MessageType; - ULONG Unknown1; - ULONG MaxInstances; - ULONG CurInstances; - ULONG InBufferSize; - ULONG Unknown2; - ULONG OutBufferSize; - ULONG Unknown3[2]; - ULONG ServerEnd; -} FILE_PIPE_LOCAL_INFORMATION, *PFILE_PIPE_LOCAL_INFORMATION; - -typedef struct _FILE_PIPE_REMOTE_INFORMATION { // Information Class 25 - LARGE_INTEGER CollectDataTimeout; - ULONG MaxCollectionCount; -} FILE_PIPE_REMOTE_INFORMATION, *PFILE_PIPE_REMOTE_INFORMATION; - -typedef struct _FILE_MAILSLOT_QUERY_INFORMATION { // Information Class 26 - ULONG MaxMessageSize; - ULONG Unknown; - ULONG NextSize; - ULONG MessageCount; - LARGE_INTEGER ReadTimeout; -} FILE_MAILSLOT_QUERY_INFORMATION, *PFILE_MAILSLOT_QUERY_INFORMATION; - -typedef struct _FILE_MAILSLOT_SET_INFORMATION { // Information Class 27 - LARGE_INTEGER ReadTimeout; -} FILE_MAILSLOT_SET_INFORMATION, *PFILE_MAILSLOT_SET_INFORMATION; - -typedef struct _FILE_COMPRESSION_INFORMATION { // Information Class 28 - LARGE_INTEGER CompressedSize; - USHORT CompressionFormat; - UCHAR CompressionUnitShift; - UCHAR Unknown; - UCHAR ClusterSizeShift; -} FILE_COMPRESSION_INFORMATION, *PFILE_COMPRESSION_INFORMATION; - -typedef struct _FILE_COMPLETION_INFORMATION { // Information Class 30 - HANDLE IoCompletionHandle; - ULONG CompletionKey; -} FILE_COMPLETION_INFORMATION, *PFILE_COMPLETION_INFORMATION; - -NTSYSAPI -NTSTATUS -NTAPI -ZwCreateKey( - OUT PHANDLE KeyHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN ULONG TitleIndex, - IN PUNICODE_STRING Class OPTIONAL, - IN ULONG CreateOptions, - OUT PULONG Disposition OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwOpenKey( - OUT PHANDLE KeyHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwDeleteKey( - IN HANDLE KeyHandle - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwFlushKey( - IN HANDLE KeyHandle - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSaveKey( - IN HANDLE KeyHandle, - IN HANDLE FileHandle - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSaveMergedKeys( - IN HANDLE KeyHandle1, - IN HANDLE KeyHandle2, - IN HANDLE FileHandle - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwRestoreKey( - IN HANDLE KeyHandle, - IN HANDLE FileHandle, - IN ULONG Flags - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwLoadKey( - IN POBJECT_ATTRIBUTES KeyObjectAttributes, - IN POBJECT_ATTRIBUTES FileObjectAttributes - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwLoadKey2( - IN POBJECT_ATTRIBUTES KeyObjectAttributes, - IN POBJECT_ATTRIBUTES FileObjectAttributes, - IN ULONG Flags - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwUnloadKey( - IN POBJECT_ATTRIBUTES KeyObjectAttributes - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwReplaceKey( - IN POBJECT_ATTRIBUTES NewFileObjectAttributes, - IN HANDLE KeyHandle, - IN POBJECT_ATTRIBUTES OldFileObjectAttributes - ); - -typedef struct _KEY_SET_VIRTUALIZATION_INFORMATION { - ULONG VirtualTarget : 1; // Tells if the key is a virtual target key. - ULONG VirtualStore : 1; // Tells if the key is a virtual store key. - ULONG VirtualSource : 1; // Tells if the key has been virtualized at least one (virtual hint) - ULONG Reserved : 29; -} KEY_SET_VIRTUALIZATION_INFORMATION, *PKEY_SET_VIRTUALIZATION_INFORMATION; - -typedef enum _KEY_SET_INFORMATION_CLASS { - KeyWriteTimeInformation, - KeyWow64FlagsInformation, - KeyControlFlagsInformation, - KeySetVirtualizationInformation, - KeySetDebugInformation, - KeySetHandleTagsInformation, - MaxKeySetInfoClass // MaxKeySetInfoClass should always be the last enum -} KEY_SET_INFORMATION_CLASS; - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetInformationKey( - IN HANDLE KeyHandle, - IN KEY_SET_INFORMATION_CLASS KeyInformationClass, - IN PVOID KeyInformation, - IN ULONG KeyInformationLength - ); - -typedef enum _KEY_INFORMATION_CLASS { - KeyBasicInformation, - KeyNodeInformation, - KeyFullInformation, - KeyNameInformation, - KeyCachedInformation, - KeyFlagsInformation, - KeyVirtualizationInformation, - KeyHandleTagsInformation, - MaxKeyInfoClass // MaxKeyInfoClass should always be the last enum -} KEY_INFORMATION_CLASS; - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryKey( - IN HANDLE KeyHandle, - IN KEY_INFORMATION_CLASS KeyInformationClass, - OUT PVOID KeyInformation, - IN ULONG KeyInformationLength, - OUT PULONG ResultLength - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwEnumerateKey( - IN HANDLE KeyHandle, - IN ULONG Index, - IN KEY_INFORMATION_CLASS KeyInformationClass, - OUT PVOID KeyInformation, - IN ULONG KeyInformationLength, - OUT PULONG ResultLength - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwNotifyChangeKey( - IN HANDLE KeyHandle, - IN HANDLE EventHandle OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN ULONG NotifyFilter, - IN BOOL WatchSubtree, - IN PVOID Buffer, - IN ULONG BufferLength, - IN BOOL Asynchronous - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwNotifyChangeMultipleKeys ( - IN HANDLE KeyHandle, - IN ULONG Flags, - IN POBJECT_ATTRIBUTES KeyObjectAttributes, - IN HANDLE EventHandle OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN ULONG NotifyFilter, - IN BOOL WatchSubtree, - IN PVOID Buffer, - IN ULONG BufferLength, - IN BOOL Asynchronous - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwDeleteValueKey( - IN HANDLE KeyHandle, - IN PUNICODE_STRING ValueName - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetValueKey( - IN HANDLE KeyHandle, - IN PUNICODE_STRING ValueName, - IN ULONG TitleIndex, - IN ULONG Type, - IN PVOID Data, - IN ULONG DataSize - ); - -typedef enum _KEY_VALUE_INFORMATION_CLASS { - KeyValueBasicInformation, - KeyValueFullInformation, - KeyValuePartialInformation, - KeyValueFullInformationAlign64, - KeyValuePartialInformationAlign64, - MaxKeyValueInfoClass // MaxKeyValueInfoClass should always be the last enum -} KEY_VALUE_INFORMATION_CLASS; - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryValueKey( - IN HANDLE KeyHandle, - IN PUNICODE_STRING ValueName, - IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, - OUT PVOID KeyValueInformation, - IN ULONG KeyValueInformationLength, - OUT PULONG ResultLength - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwEnumerateValueKey( - IN HANDLE KeyHandle, - IN ULONG Index, - IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, - OUT PVOID KeyValueInformation, - IN ULONG KeyValueInformationLength, - OUT PULONG ResultLength - ); - -typedef struct _KEY_VALUE_ENTRY { - PUNICODE_STRING ValueName; - ULONG DataLength; - ULONG DataOffset; - ULONG Type; -} KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY; - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryMultipleValueKey( - IN HANDLE KeyHandle, - IN OUT PKEY_VALUE_ENTRY ValueList, - IN ULONG NumberOfValues, - OUT PVOID Buffer, - IN OUT PULONG Length, - OUT PULONG ReturnLength - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwPrivilegeCheck( - IN HANDLE TokenHandle, - IN PPRIVILEGE_SET RequiredPrivileges, - OUT PBOOL Result - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwPrivilegeObjectAuditAlarm( - IN PUNICODE_STRING SubsystemName, - IN PVOID HandleId, - IN HANDLE TokenHandle, - IN ACCESS_MASK DesiredAccess, - IN PPRIVILEGE_SET Privileges, - IN BOOL AccessGranted - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwPrivilegedServiceAuditAlarm( - IN PUNICODE_STRING SubsystemName, - IN PUNICODE_STRING ServiceName, - IN HANDLE TokenHandle, - IN PPRIVILEGE_SET Privileges, - IN BOOL AccessGranted - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwAccessCheck( - IN PSECURITY_DESCRIPTOR SecurityDescriptor, - IN HANDLE TokenHandle, - IN ACCESS_MASK DesiredAccess, - IN PGENERIC_MAPPING GenericMapping, - IN PPRIVILEGE_SET PrivilegeSet, - IN PULONG PrivilegeSetLength, - OUT PACCESS_MASK GrantedAccess, - OUT PBOOL AccessStatus - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwAccessCheckAndAuditAlarm( - IN PUNICODE_STRING SubsystemName, - IN PVOID HandleId, - IN PUNICODE_STRING ObjectTypeName, - IN PUNICODE_STRING ObjectName, - IN PSECURITY_DESCRIPTOR SecurityDescriptor, - IN ACCESS_MASK DesiredAccess, - IN PGENERIC_MAPPING GenericMapping, - IN BOOL ObjectCreation, - OUT PACCESS_MASK GrantedAccess, - OUT PBOOL AccessStatus, - OUT PBOOL GenerateOnClose - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwAccessCheckByType( - IN PSECURITY_DESCRIPTOR SecurityDescriptor, - IN PSID PrincipalSelfSid, - IN HANDLE TokenHandle, - IN ULONG DesiredAccess, - IN POBJECT_TYPE_LIST ObjectTypeList, - IN ULONG ObjectTypeListLength, - IN PGENERIC_MAPPING GenericMapping, - IN PPRIVILEGE_SET PrivilegeSet, - IN PULONG PrivilegeSetLength, - OUT PACCESS_MASK GrantedAccess, - OUT PULONG AccessStatus - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwAccessCheckByTypeAndAuditAlarm( - IN PUNICODE_STRING SubsystemName, - IN PVOID HandleId, - IN PUNICODE_STRING ObjectTypeName, - IN PUNICODE_STRING ObjectName, - IN PSECURITY_DESCRIPTOR SecurityDescriptor, - IN PSID PrincipalSelfSid, - IN ACCESS_MASK DesiredAccess, - IN AUDIT_EVENT_TYPE AuditType, - IN ULONG Flags, - IN POBJECT_TYPE_LIST ObjectTypeList, - IN ULONG ObjectTypeListLength, - IN PGENERIC_MAPPING GenericMapping, - IN BOOL ObjectCreation, - OUT PACCESS_MASK GrantedAccess, - OUT PULONG AccessStatus, - OUT PBOOL GenerateOnClose - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwAccessCheckByTypeResultList( - IN PSECURITY_DESCRIPTOR SecurityDescriptor, - IN PSID PrincipalSelfSid, - IN HANDLE TokenHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_TYPE_LIST ObjectTypeList, - IN ULONG ObjectTypeListLength, - IN PGENERIC_MAPPING GenericMapping, - IN PPRIVILEGE_SET PrivilegeSet, - IN PULONG PrivilegeSetLength, - OUT PACCESS_MASK GrantedAccessList, - OUT PULONG AccessStatusList - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwAccessCheckByTypeResultListAndAuditAlarm( - IN PUNICODE_STRING SubsystemName, - IN PVOID HandleId, - IN PUNICODE_STRING ObjectTypeName, - IN PUNICODE_STRING ObjectName, - IN PSECURITY_DESCRIPTOR SecurityDescriptor, - IN PSID PrincipalSelfSid, - IN ACCESS_MASK DesiredAccess, - IN AUDIT_EVENT_TYPE AuditType, - IN ULONG Flags, - IN POBJECT_TYPE_LIST ObjectTypeList, - IN ULONG ObjectTypeListLength, - IN PGENERIC_MAPPING GenericMapping, - IN BOOL ObjectCreation, - OUT PACCESS_MASK GrantedAccessList, - OUT PULONG AccessStatusList, - OUT PULONG GenerateOnClose - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwAccessCheckByTypeResultListAndAuditAlarmByHandle( - IN PUNICODE_STRING SubsystemName, - IN PVOID HandleId, - IN HANDLE TokenHandle, - IN PUNICODE_STRING ObjectTypeName, - IN PUNICODE_STRING ObjectName, - IN PSECURITY_DESCRIPTOR SecurityDescriptor, - IN PSID PrincipalSelfSid, - IN ACCESS_MASK DesiredAccess, - IN AUDIT_EVENT_TYPE AuditType, - IN ULONG Flags, - IN POBJECT_TYPE_LIST ObjectTypeList, - IN ULONG ObjectTypeListLength, - IN PGENERIC_MAPPING GenericMapping, - IN BOOL ObjectCreation, - OUT PACCESS_MASK GrantedAccessList, - OUT PULONG AccessStatusList, - OUT PULONG GenerateOnClose - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwOpenObjectAuditAlarm( - IN PUNICODE_STRING SubsystemName, - IN PVOID *HandleId, - IN PUNICODE_STRING ObjectTypeName, - IN PUNICODE_STRING ObjectName, - IN PSECURITY_DESCRIPTOR SecurityDescriptor, - IN HANDLE TokenHandle, - IN ACCESS_MASK DesiredAccess, - IN ACCESS_MASK GrantedAccess, - IN PPRIVILEGE_SET Privileges OPTIONAL, - IN BOOL ObjectCreation, - IN BOOL AccessGranted, - OUT PBOOL GenerateOnClose - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwCloseObjectAuditAlarm( - IN PUNICODE_STRING SubsystemName, - IN PVOID HandleId, - IN BOOL GenerateOnClose - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwDeleteObjectAuditAlarm( - IN PUNICODE_STRING SubsystemName, - IN PVOID HandleId, - IN BOOL GenerateOnClose - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwRequestWakeupLatency( - IN LATENCY_TIME Latency - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwRequestDeviceWakeup( - IN HANDLE DeviceHandle - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwCancelDeviceWakeupRequest( - IN HANDLE DeviceHandle - ); - -NTSYSAPI -BOOL -NTAPI -ZwIsSystemResumeAutomatic( - VOID - ); - -typedef EXECUTION_STATE *PEXECUTION_STATE; - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetThreadExecutionState( - IN EXECUTION_STATE ExecutionState, - OUT PEXECUTION_STATE PreviousExecutionState - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwGetDevicePowerState( - IN HANDLE DeviceHandle, - OUT PDEVICE_POWER_STATE DevicePowerState - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetSystemPowerState( - IN POWER_ACTION SystemAction, - IN SYSTEM_POWER_STATE MinSystemState, - IN ULONG Flags - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwInitiatePowerAction( - IN POWER_ACTION SystemAction, - IN SYSTEM_POWER_STATE MinSystemState, - IN ULONG Flags, - IN BOOL Asynchronous - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwPowerInformation( - IN POWER_INFORMATION_LEVEL PowerInformationLevel, - IN PVOID InputBuffer OPTIONAL, - IN ULONG InputBufferLength, - OUT PVOID OutputBuffer OPTIONAL, - IN ULONG OutputBufferLength - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwGetPlugPlayEvent( - IN ULONG Reserved1, - IN ULONG Reserved2, - OUT PVOID Buffer, - IN ULONG BufferLength - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwRaiseException( - IN PEXCEPTION_RECORD ExceptionRecord, - IN PCONTEXT Context, - IN BOOL SearchFrames - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwContinue( - IN PCONTEXT Context, - IN BOOL TestAlert - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwW32Call( - IN ULONG RoutineIndex, - IN PVOID Argument, - IN ULONG ArgumentLength, - OUT PVOID *Result OPTIONAL, - OUT PULONG ResultLength OPTIONAL - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwCallbackReturn( - IN PVOID Result OPTIONAL, - IN ULONG ResultLength, - IN NTSTATUS Status - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetLowWaitHighThread( - VOID - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetHighWaitLowThread( - VOID - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwLoadDriver( - IN PUNICODE_STRING DriverServiceName - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwUnloadDriver( - IN PUNICODE_STRING DriverServiceName - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwFlushInstructionCache( - IN HANDLE ProcessHandle, - IN PVOID BaseAddress OPTIONAL, - IN ULONG FlushSize - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwFlushWriteBuffer( - VOID - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryDefaultLocale( - IN BOOL ThreadOrSystem, - OUT PLCID Locale - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetDefaultLocale( - IN BOOL ThreadOrSystem, - IN LCID Locale - ); - -typedef LANGID *PLANGID; - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryDefaultUILanguage( - OUT PLANGID LanguageId - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetDefaultUILanguage( - IN LANGID LanguageId - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryInstallUILanguage( - OUT PLANGID LanguageId - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwAllocateLocallyUniqueId( - OUT PLUID Luid - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwAllocateUuids( - OUT PLARGE_INTEGER UuidLastTimeAllocated, - OUT PULONG UuidDeltaTime, - OUT PULONG UuidSequenceNumber, - OUT PUCHAR UuidSeed - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetUuidSeed( - IN PUCHAR UuidSeed - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwRaiseHardError( - IN NTSTATUS Status, - IN ULONG NumberOfArguments, - IN ULONG StringArgumentsMask, - IN PULONG Arguments, - IN ULONG MessageBoxType, - OUT PULONG MessageBoxResult - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetDefaultHardErrorPort( - IN HANDLE PortHandle - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwDisplayString( - IN PUNICODE_STRING String - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwCreatePagingFile( - IN PUNICODE_STRING FileName, - IN PULARGE_INTEGER InitialSize, - IN PULARGE_INTEGER MaximumSize, - IN ULONG Reserved - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwAddAtom( - IN PWSTR String, - IN ULONG StringLength, - OUT PUSHORT Atom - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwFindAtom( - IN PWSTR String, - IN ULONG StringLength, - OUT PUSHORT Atom - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwDeleteAtom( - IN USHORT Atom - ); - -typedef enum _ATOM_INFORMATION_CLASS { - AtomBasicInformation, - AtomListInformation -} ATOM_INFORMATION_CLASS; - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryInformationAtom( - IN USHORT Atom, - IN ATOM_INFORMATION_CLASS AtomInformationClass, - OUT PVOID AtomInformation, - IN ULONG AtomInformationLength, - OUT PULONG ReturnLength OPTIONAL - ); - -typedef struct _ATOM_BASIC_INFORMATION { - USHORT ReferenceCount; - USHORT Pinned; - USHORT NameLength; - WCHAR Name[1]; -} ATOM_BASIC_INFORMATION, *PATOM_BASIC_INFORMATION; - -typedef struct _ATOM_LIST_INFORMATION { - ULONG NumberOfAtoms; - ATOM Atoms[1]; -} ATOM_LIST_INFORMATION, *PATOM_LIST_INFORMATION; - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetLdtEntries( - IN ULONG Selector1, - IN LDT_ENTRY LdtEntry1, - IN ULONG Selector2, - IN LDT_ENTRY LdtEntry2 - ); - -NTSYSAPI -NTSTATUS -NTAPI -ZwVdmControl( - IN ULONG ControlCode, - IN PVOID ControlData - ); - -NTSYSAPI -NTSTATUS -NTAPI -RtlAnsiStringToUnicodeString( - PUNICODE_STRING DestinationString, - PCANSI_STRING SourceString, - BOOL AllocateDestinationString - ); - -NTSYSAPI -NTSTATUS -NTAPI -RtlUnicodeStringToAnsiString( - PANSI_STRING DestinationString, - PUNICODE_STRING SourceString, - BOOL AllocateDestinationString - ); - -NTSYSAPI -NTSTATUS -NTAPI -RtlUnicodeStringToOemString( - POEM_STRING DestinationString, - PUNICODE_STRING SourceString, - BOOL AllocateDestinationString - ); - - } -} +#include + +namespace NT { + extern "C" { + +/* PAGE_SIZE for X86/X64 */ +#define PAGE_SIZE 0x1000 +#define PAGE_SHIFT 12L + +/* Definitions for NTDDK STATUS */ +typedef LONG NTSTATUS; +typedef ULONG DEVICE_TYPE; + +#define NT_SUCCESS(Status) (((NT::NTSTATUS)(Status)) >= 0) + +/* Common status codes */ + +#define STATUS_SUCCESS ((NT::NTSTATUS)0x00000000L) +#define STATUS_BUFFER_OVERFLOW ((NT::NTSTATUS)0x80000005L) +#define STATUS_UNSUCCESSFUL ((NT::NTSTATUS)0xC0000001L) +#define STATUS_NO_MEDIA_IN_DEVICE ((NT::NTSTATUS)0xC0000013L) +#define STATUS_ACCESS_DENIED ((NT::NTSTATUS)0xC0000022L) +#define STATUS_BUFFER_TOO_SMALL ((NT::NTSTATUS)0xC0000023L) +#define STATUS_INSUFFICIENT_RESOURCES ((NT::NTSTATUS)0xC000009AL) + + +typedef struct _IO_STATUS_BLOCK { + union { + NTSTATUS Status; + PVOID Pointer; + } DUMMYUNIONNAME; + + ULONG_PTR Information; +} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; + + +/* Definitios of kernel I/O IRPs */ + +#define IRP_MJ_CREATE 0x00 +#define IRP_MJ_CREATE_NAMED_PIPE 0x01 +#define IRP_MJ_CLOSE 0x02 +#define IRP_MJ_READ 0x03 +#define IRP_MJ_WRITE 0x04 +#define IRP_MJ_QUERY_INFORMATION 0x05 +#define IRP_MJ_SET_INFORMATION 0x06 +#define IRP_MJ_QUERY_EA 0x07 +#define IRP_MJ_SET_EA 0x08 +#define IRP_MJ_FLUSH_BUFFERS 0x09 +#define IRP_MJ_QUERY_VOLUME_INFORMATION 0x0a +#define IRP_MJ_SET_VOLUME_INFORMATION 0x0b +#define IRP_MJ_DIRECTORY_CONTROL 0x0c +#define IRP_MJ_FILE_SYSTEM_CONTROL 0x0d +#define IRP_MJ_DEVICE_CONTROL 0x0e +#define IRP_MJ_INTERNAL_DEVICE_CONTROL 0x0f +#define IRP_MJ_SHUTDOWN 0x10 +#define IRP_MJ_LOCK_CONTROL 0x11 +#define IRP_MJ_CLEANUP 0x12 +#define IRP_MJ_CREATE_MAILSLOT 0x13 +#define IRP_MJ_QUERY_SECURITY 0x14 +#define IRP_MJ_SET_SECURITY 0x15 +#define IRP_MJ_POWER 0x16 +#define IRP_MJ_SYSTEM_CONTROL 0x17 +#define IRP_MJ_DEVICE_CHANGE 0x18 +#define IRP_MJ_QUERY_QUOTA 0x19 +#define IRP_MJ_SET_QUOTA 0x1a +#define IRP_MJ_PNP 0x1b +#define IRP_MJ_PNP_POWER IRP_MJ_PNP // Obsolete.... +#define IRP_MJ_MAXIMUM_FUNCTION 0x1b + + +/* + * strings + */ + +typedef struct _STRING { + __maybevalid USHORT Length; + __maybevalid USHORT MaximumLength; +#ifdef MIDL_PASS + [size_is(MaximumLength), length_is(Length) ] +#endif // MIDL_PASS + __field_bcount_part_opt(MaximumLength, Length) PCHAR Buffer; +} STRING; +typedef STRING *PSTRING; +typedef STRING ANSI_STRING; +typedef PSTRING PANSI_STRING; + +typedef STRING OEM_STRING; +typedef PSTRING POEM_STRING; +typedef CONST STRING* PCOEM_STRING; + +typedef struct _CSTRING { + USHORT Length; + USHORT MaximumLength; + CONST char *Buffer; +} CSTRING; +typedef CSTRING *PCSTRING; +#define ANSI_NULL ((CHAR)0) // winnt + +typedef STRING CANSI_STRING; +typedef PSTRING PCANSI_STRING; + +typedef struct _UNICODE_STRING { + USHORT Length; + USHORT MaximumLength; +#ifdef MIDL_PASS + [size_is(MaximumLength / 2), length_is((Length) / 2) ] USHORT * Buffer; +#else // MIDL_PASS + __field_bcount_part(MaximumLength, Length) PWCH Buffer; +#endif // MIDL_PASS +} UNICODE_STRING; +typedef UNICODE_STRING *PUNICODE_STRING; +typedef const UNICODE_STRING *PCUNICODE_STRING; +#define UNICODE_NULL ((WCHAR)0) // winnt + +typedef enum _FSINFOCLASS { + FileFsVolumeInformation = 1, + FileFsLabelInformation, // 2 + FileFsSizeInformation, // 3 + FileFsDeviceInformation, // 4 + FileFsAttributeInformation, // 5 + FileFsControlInformation, // 6 + FileFsFullSizeInformation, // 7 + FileFsObjectIdInformation, // 8 + FileFsDriverPathInformation, // 9 + FileFsVolumeFlagsInformation,// 10 + FileFsMaximumInformation +} FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS; + + +typedef struct _FILE_FS_DEVICE_INFORMATION { + DEVICE_TYPE DeviceType; + ULONG Characteristics; +} FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION; + +typedef enum _SYSTEM_INFORMATION_CLASS { + SystemBasicInformation, // 0 Y N + SystemProcessorInformation, // 1 Y N + SystemPerformanceInformation, // 2 Y N + SystemTimeOfDayInformation, // 3 Y N + SystemNotImplemented1, // 4 Y N + SystemProcessesAndThreadsInformation, // 5 Y N + SystemCallCounts, // 6 Y N + SystemConfigurationInformation, // 7 Y N + SystemProcessorTimes, // 8 Y N + SystemGlobalFlag, // 9 Y Y + SystemNotImplemented2, // 10 Y N + SystemModuleInformation, // 11 Y N + SystemLockInformation, // 12 Y N + SystemNotImplemented3, // 13 Y N + SystemNotImplemented4, // 14 Y N + SystemNotImplemented5, // 15 Y N + SystemHandleInformation, // 16 Y N + SystemObjectInformation, // 17 Y N + SystemPagefileInformation, // 18 Y N + SystemInstructionEmulationCounts, // 19 Y N + SystemInvalidInfoClass1, // 20 + SystemCacheInformation, // 21 Y Y + SystemPoolTagInformation, // 22 Y N + SystemProcessorStatistics, // 23 Y N + SystemDpcInformation, // 24 Y Y + SystemNotImplemented6, // 25 Y N + SystemLoadImage, // 26 N Y + SystemUnloadImage, // 27 N Y + SystemTimeAdjustment, // 28 Y Y + SystemNotImplemented7, // 29 Y N + SystemNotImplemented8, // 30 Y N + SystemNotImplemented9, // 31 Y N + SystemCrashDumpInformation, // 32 Y N + SystemExceptionInformation, // 33 Y N + SystemCrashDumpStateInformation, // 34 Y Y/N + SystemKernelDebuggerInformation, // 35 Y N + SystemContextSwitchInformation, // 36 Y N + SystemRegistryQuotaInformation, // 37 Y Y + SystemLoadAndCallImage, // 38 N Y + SystemPrioritySeparation, // 39 N Y + SystemNotImplemented10, // 40 Y N + SystemNotImplemented11, // 41 Y N + SystemInvalidInfoClass2, // 42 + SystemInvalidInfoClass3, // 43 + SystemTimeZoneInformation, // 44 Y N + SystemLookasideInformation, // 45 Y N + SystemSetTimeSlipEvent, // 46 N Y + SystemCreateSession, // 47 N Y + SystemDeleteSession, // 48 N Y + SystemInvalidInfoClass4, // 49 + SystemRangeStartInformation, // 50 Y N + SystemVerifierInformation, // 51 Y Y + SystemAddVerifier, // 52 N Y + SystemSessionProcessesInformation // 53 Y N +} SYSTEM_INFORMATION_CLASS; + +NTSYSAPI +NTSTATUS +NTAPI +ZwQuerySystemInformation( + IN SYSTEM_INFORMATION_CLASS SystemInformationClass, + OUT PVOID SystemInformation, + IN ULONG SystemInformationLength, + OUT PULONG ReturnLength OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetSystemInformation( + IN SYSTEM_INFORMATION_CLASS SystemInformationClass, + IN OUT PVOID SystemInformation, + IN ULONG SystemInformationLength + ); + +typedef struct _SYSTEM_BASIC_INFORMATION { // Information Class 0 + ULONG Unknown; + ULONG MaximumIncrement; + ULONG PhysicalPageSize; + ULONG NumberOfPhysicalPages; + ULONG LowestPhysicalPage; + ULONG HighestPhysicalPage; + ULONG AllocationGranularity; + ULONG LowestUserAddress; + ULONG HighestUserAddress; + ULONG ActiveProcessors; + UCHAR NumberProcessors; +} SYSTEM_BASIC_INFORMATION, *PSYSTEM_BASIC_INFORMATION; + +typedef struct _SYSTEM_PROCESSOR_INFORMATION { // Information Class 1 + USHORT ProcessorArchitecture; + USHORT ProcessorLevel; + USHORT ProcessorRevision; + USHORT Unknown; + ULONG FeatureBits; +} SYSTEM_PROCESSOR_INFORMATION, *PSYSTEM_PROCESSOR_INFORMATION; + +typedef struct _SYSTEM_PERFORMANCE_INFORMATION { // Information Class 2 + LARGE_INTEGER IdleTime; + LARGE_INTEGER ReadTransferCount; + LARGE_INTEGER WriteTransferCount; + LARGE_INTEGER OtherTransferCount; + ULONG ReadOperationCount; + ULONG WriteOperationCount; + ULONG OtherOperationCount; + ULONG AvailablePages; + ULONG TotalCommittedPages; + ULONG TotalCommitLimit; + ULONG PeakCommitment; + ULONG PageFaults; + ULONG WriteCopyFaults; + ULONG TransistionFaults; + ULONG Reserved1; + ULONG DemandZeroFaults; + ULONG PagesRead; + ULONG PageReadIos; + ULONG Reserved2[2]; + ULONG PagefilePagesWritten; + ULONG PagefilePageWriteIos; + ULONG MappedFilePagesWritten; + ULONG MappedFilePageWriteIos; + ULONG PagedPoolUsage; + ULONG NonPagedPoolUsage; + ULONG PagedPoolAllocs; + ULONG PagedPoolFrees; + ULONG NonPagedPoolAllocs; + ULONG NonPagedPoolFrees; + ULONG TotalFreeSystemPtes; + ULONG SystemCodePage; + ULONG TotalSystemDriverPages; + ULONG TotalSystemCodePages; + ULONG SmallNonPagedLookasideListAllocateHits; + ULONG SmallPagedLookasideListAllocateHits; + ULONG Reserved3; + ULONG MmSystemCachePage; + ULONG PagedPoolPage; + ULONG SystemDriverPage; + ULONG FastReadNoWait; + ULONG FastReadWait; + ULONG FastReadResourceMiss; + ULONG FastReadNotPossible; + ULONG FastMdlReadNoWait; + ULONG FastMdlReadWait; + ULONG FastMdlReadResourceMiss; + ULONG FastMdlReadNotPossible; + ULONG MapDataNoWait; + ULONG MapDataWait; + ULONG MapDataNoWaitMiss; + ULONG MapDataWaitMiss; + ULONG PinMappedDataCount; + ULONG PinReadNoWait; + ULONG PinReadWait; + ULONG PinReadNoWaitMiss; + ULONG PinReadWaitMiss; + ULONG CopyReadNoWait; + ULONG CopyReadWait; + ULONG CopyReadNoWaitMiss; + ULONG CopyReadWaitMiss; + ULONG MdlReadNoWait; + ULONG MdlReadWait; + ULONG MdlReadNoWaitMiss; + ULONG MdlReadWaitMiss; + ULONG ReadAheadIos; + ULONG LazyWriteIos; + ULONG LazyWritePages; + ULONG DataFlushes; + ULONG DataPages; + ULONG ContextSwitches; + ULONG FirstLevelTbFills; + ULONG SecondLevelTbFills; + ULONG SystemCalls; +} SYSTEM_PERFORMANCE_INFORMATION, *PSYSTEM_PERFORMANCE_INFORMATION; + +typedef struct _SYSTEM_TIME_OF_DAY_INFORMATION { // Information Class 3 + LARGE_INTEGER BootTime; + LARGE_INTEGER CurrentTime; + LARGE_INTEGER TimeZoneBias; + ULONG CurrentTimeZoneId; +} SYSTEM_TIME_OF_DAY_INFORMATION, *PSYSTEM_TIME_OF_DAY_INFORMATION; + +typedef struct _IO_COUNTERSEX { + LARGE_INTEGER ReadOperationCount; + LARGE_INTEGER WriteOperationCount; + LARGE_INTEGER OtherOperationCount; + LARGE_INTEGER ReadTransferCount; + LARGE_INTEGER WriteTransferCount; + LARGE_INTEGER OtherTransferCount; +} IO_COUNTERSEX, *PIO_COUNTERSEX; + +typedef enum { + StateInitialized, + StateReady, + StateRunning, + StateStandby, + StateTerminated, + StateWait, + StateTransition, + StateUnknown +} THREAD_STATE; + +typedef struct _CLIENT_ID { + HANDLE UniqueProcess; + HANDLE UniqueThread; +} CLIENT_ID; +typedef CLIENT_ID *PCLIENT_ID; + +/* Thread priority */ +typedef LONG KPRIORITY; + +typedef enum _KWAIT_REASON { + Executive, + FreePage, + PageIn, + PoolAllocation, + DelayExecution, + Suspended, + UserRequest, + WrExecutive, + WrFreePage, + WrPageIn, + WrPoolAllocation, + WrDelayExecution, + WrSuspended, + WrUserRequest, + WrEventPair, + WrQueue, + WrLpcReceive, + WrLpcReply, + WrVirtualMemory, + WrPageOut, + WrRendezvous, + WrKeyedEvent, + WrTerminated, + WrProcessInSwap, + WrCpuRateControl, + WrCalloutStack, + WrKernel, + WrResource, + WrPushLock, + WrMutex, + WrQuantumEnd, + WrDispatchInt, + WrPreempted, + WrYieldExecution, + WrFastMutex, + WrGuardedMutex, + WrRundown, + MaximumWaitReason +} KWAIT_REASON; + +typedef struct _SYSTEM_THREADS { + LARGE_INTEGER KernelTime; + LARGE_INTEGER UserTime; + LARGE_INTEGER CreateTime; + ULONG WaitTime; + PVOID StartAddress; + CLIENT_ID ClientId; + KPRIORITY Priority; + KPRIORITY BasePriority; + ULONG ContextSwitchCount; + THREAD_STATE State; + KWAIT_REASON WaitReason; +} SYSTEM_THREADS, *PSYSTEM_THREADS; + +typedef struct _VM_COUNTERS { + SIZE_T PeakVirtualSize; + SIZE_T VirtualSize; + ULONG PageFaultCount; + SIZE_T PeakWorkingSetSize; + SIZE_T WorkingSetSize; + SIZE_T QuotaPeakPagedPoolUsage; + SIZE_T QuotaPagedPoolUsage; + SIZE_T QuotaPeakNonPagedPoolUsage; + SIZE_T QuotaNonPagedPoolUsage; + SIZE_T PagefileUsage; + SIZE_T PeakPagefileUsage; +} VM_COUNTERS; +typedef VM_COUNTERS *PVM_COUNTERS; + +typedef struct _VM_COUNTERS_EX { + SIZE_T PeakVirtualSize; + SIZE_T VirtualSize; + ULONG PageFaultCount; + SIZE_T PeakWorkingSetSize; + SIZE_T WorkingSetSize; + SIZE_T QuotaPeakPagedPoolUsage; + SIZE_T QuotaPagedPoolUsage; + SIZE_T QuotaPeakNonPagedPoolUsage; + SIZE_T QuotaNonPagedPoolUsage; + SIZE_T PagefileUsage; + SIZE_T PeakPagefileUsage; + SIZE_T PrivateUsage; +} VM_COUNTERS_EX; + +typedef VM_COUNTERS_EX *PVM_COUNTERS_EX; +#define MAX_HW_COUNTERS 16 + +typedef struct _SYSTEM_PROCESSES { // Information Class 5 + ULONG NextEntryDelta; + ULONG ThreadCount; + ULONG Reserved1[6]; + LARGE_INTEGER CreateTime; + LARGE_INTEGER UserTime; + LARGE_INTEGER KernelTime; + UNICODE_STRING ProcessName; + KPRIORITY BasePriority; + ULONG ProcessId; + ULONG InheritedFromProcessId; + ULONG HandleCount; + ULONG Reserved2[2]; + VM_COUNTERS VmCounters; + IO_COUNTERS IoCounters; + SYSTEM_THREADS Threads[1]; +} SYSTEM_PROCESSES, *PSYSTEM_PROCESSES; + +typedef struct _SYSTEM_CALLS_INFORMATION { // Information Class 6 + ULONG Size; + ULONG NumberOfDescriptorTables; + ULONG NumberOfRoutinesInTable[1]; + // ULONG CallCounts[]; +} SYSTEM_CALLS_INFORMATION, *PSYSTEM_CALLS_INFORMATION; + +typedef struct _SYSTEM_CONFIGURATION_INFORMATION { // Information Class 7 + ULONG DiskCount; + ULONG FloppyCount; + ULONG CdRomCount; + ULONG TapeCount; + ULONG SerialCount; + ULONG ParallelCount; +} SYSTEM_CONFIGURATION_INFORMATION, *PSYSTEM_CONFIGURATION_INFORMATION; + +typedef struct _SYSTEM_PROCESSOR_TIMES { // Information Class 8 + LARGE_INTEGER IdleTime; + LARGE_INTEGER KernelTime; + LARGE_INTEGER UserTime; + LARGE_INTEGER DpcTime; + LARGE_INTEGER InterruptTime; + ULONG InterruptCount; +} SYSTEM_PROCESSOR_TIMES, *PSYSTEM_PROCESSOR_TIMES; + +typedef struct _SYSTEM_GLOBAL_FLAG { // Information Class 9 + ULONG GlobalFlag; +} SYSTEM_GLOBAL_FLAG, *PSYSTEM_GLOBAL_FLAG; + +typedef struct _SYSTEM_MODULE_INFORMATION { // Information Class 11 + ULONG Reserved[2]; + PVOID Base; + ULONG Size; + ULONG Flags; + USHORT Index; + USHORT Unknown; + USHORT LoadCount; + USHORT ModuleNameOffset; + CHAR ImageName[256]; +} SYSTEM_MODULE_INFORMATION, *PSYSTEM_MODULE_INFORMATION; + +typedef struct _SYSTEM_LOCK_INFORMATION { // Information Class 12 + PVOID Address; + USHORT Type; + USHORT Reserved1; + ULONG ExclusiveOwnerThreadId; + ULONG ActiveCount; + ULONG ContentionCount; + ULONG Reserved2[2]; + ULONG NumberOfSharedWaiters; + ULONG NumberOfExclusiveWaiters; +} SYSTEM_LOCK_INFORMATION, *PSYSTEM_LOCK_INFORMATION; + +typedef struct _SYSTEM_HANDLE_INFORMATION { // Information Class 16 + ULONG ProcessId; + UCHAR ObjectTypeNumber; + UCHAR Flags; // 0x01 = PROTECT_FROM_CLOSE, 0x02 = INHERIT + USHORT Handle; + PVOID Object; + ACCESS_MASK GrantedAccess; +} SYSTEM_HANDLE_INFORMATION, *PSYSTEM_HANDLE_INFORMATION; + +// +// Pool Allocation routines (in pool.c) +// + +typedef enum _POOL_TYPE { + NonPagedPool, + PagedPool, + NonPagedPoolMustSucceed, + DontUseThisType, + NonPagedPoolCacheAligned, + PagedPoolCacheAligned, + NonPagedPoolCacheAlignedMustS, + MaxPoolType, + + // + // Note these per session types are carefully chosen so that the appropriate + // masking still applies as well as MaxPoolType above. + // + + NonPagedPoolSession = 32, + PagedPoolSession = NonPagedPoolSession + 1, + NonPagedPoolMustSucceedSession = PagedPoolSession + 1, + DontUseThisTypeSession = NonPagedPoolMustSucceedSession + 1, + NonPagedPoolCacheAlignedSession = DontUseThisTypeSession + 1, + PagedPoolCacheAlignedSession = NonPagedPoolCacheAlignedSession + 1, + NonPagedPoolCacheAlignedMustSSession = PagedPoolCacheAlignedSession + 1, +} POOL_TYPE; + +typedef struct _SYSTEM_OBJECT_TYPE_INFORMATION { // Information Class 17 + ULONG NextEntryOffset; + ULONG ObjectCount; + ULONG HandleCount; + ULONG TypeNumber; + ULONG InvalidAttributes; + GENERIC_MAPPING GenericMapping; + ACCESS_MASK ValidAccessMask; + POOL_TYPE PoolType; + UCHAR Unknown; + UNICODE_STRING Name; +} SYSTEM_OBJECT_TYPE_INFORMATION, *PSYSTEM_OBJECT_TYPE_INFORMATION; + +typedef struct _SYSTEM_OBJECT_INFORMATION { + ULONG NextEntryOffset; + PVOID Object; + ULONG CreatorProcessId; + USHORT Unknown; + USHORT Flags; + ULONG PointerCount; + ULONG HandleCount; + ULONG PagedPoolUsage; + ULONG NonPagedPoolUsage; + ULONG ExclusiveProcessId; + PSECURITY_DESCRIPTOR SecurityDescriptor; + UNICODE_STRING Name; +} SYSTEM_OBJECT_INFORMATION, *PSYSTEM_OBJECT_INFORMATION; + +typedef struct _SYSTEM_PAGEFILE_INFORMATION { // Information Class 18 + ULONG NextEntryOffset; + ULONG CurrentSize; + ULONG TotalUsed; + ULONG PeakUsed; + UNICODE_STRING FileName; +} SYSTEM_PAGEFILE_INFORMATION, *PSYSTEM_PAGEFILE_INFORMATION; + +typedef struct _SYSTEM_INSTRUCTION_EMULATION_INFORMATION { // Info Class 19 + ULONG GenericInvalidOpcode; + ULONG TwoByteOpcode; + ULONG ESprefix; + ULONG CSprefix; + ULONG SSprefix; + ULONG DSprefix; + ULONG FSPrefix; + ULONG GSprefix; + ULONG OPER32prefix; + ULONG ADDR32prefix; + ULONG INSB; + ULONG INSW; + ULONG OUTSB; + ULONG OUTSW; + ULONG PUSHFD; + ULONG POPFD; + ULONG INTnn; + ULONG INTO; + ULONG IRETD; + ULONG FloatingPointOpcode; + ULONG INBimm; + ULONG INWimm; + ULONG OUTBimm; + ULONG OUTWimm; + ULONG INB; + ULONG INW; + ULONG OUTB; + ULONG OUTW; + ULONG LOCKprefix; + ULONG REPNEprefix; + ULONG REPprefix; + ULONG CLI; + ULONG STI; + ULONG HLT; +} SYSTEM_INSTRUCTION_EMULATION_INFORMATION, *PSYSTEM_INSTRUCTION_EMULATION_INFORMATION; + +typedef struct _SYSTEM_CACHE_INFORMATION { // Information Class 21 + ULONG SystemCacheWsSize; + ULONG SystemCacheWsPeakSize; + ULONG SystemCacheWsFaults; + ULONG SystemCacheWsMinimum; + ULONG SystemCacheWsMaximum; + ULONG TransitionSharedPages; + ULONG TransitionSharedPagesPeak; + ULONG Reserved[2]; +} SYSTEM_CACHE_INFORMATION, *PSYSTEM_CACHE_INFORMATION; + +typedef struct _SYSTEM_POOL_TAG_INFORMATION { // Information Class 22 + CHAR Tag[4]; + ULONG PagedPoolAllocs; + ULONG PagedPoolFrees; + ULONG PagedPoolUsage; + ULONG NonPagedPoolAllocs; + ULONG NonPagedPoolFrees; + ULONG NonPagedPoolUsage; +} SYSTEM_POOL_TAG_INFORMATION, *PSYSTEM_POOL_TAG_INFORMATION; + +typedef struct _SYSTEM_PROCESSOR_STATISTICS { // Information Class 23 + ULONG ContextSwitches; + ULONG DpcCount; + ULONG DpcRequestRate; + ULONG TimeIncrement; + ULONG DpcBypassCount; + ULONG ApcBypassCount; +} SYSTEM_PROCESSOR_STATISTICS, *PSYSTEM_PROCESSOR_STATISTICS; + +typedef struct _SYSTEM_DPC_INFORMATION { // Information Class 24 + ULONG Reserved; + ULONG MaximumDpcQueueDepth; + ULONG MinimumDpcRate; + ULONG AdjustDpcThreshold; + ULONG IdealDpcRate; +} SYSTEM_DPC_INFORMATION, *PSYSTEM_DPC_INFORMATION; + +typedef struct _SYSTEM_LOAD_IMAGE { // Information Class 26 + UNICODE_STRING ModuleName; + PVOID ModuleBase; + PVOID Unknown; + PVOID EntryPoint; + PVOID ExportDirectory; +} SYSTEM_LOAD_IMAGE, *PSYSTEM_LOAD_IMAGE; + +typedef struct _SYSTEM_UNLOAD_IMAGE { // Information Class 27 + PVOID ModuleBase; +} SYSTEM_UNLOAD_IMAGE, *PSYSTEM_UNLOAD_IMAGE; + +typedef struct _SYSTEM_QUERY_TIME_ADJUSTMENT { // Information Class 28 + ULONG TimeAdjustment; + ULONG MaximumIncrement; + BOOL TimeSynchronization; +} SYSTEM_QUERY_TIME_ADJUSTMENT, *PSYSTEM_QUERY_TIME_ADJUSTMENT; + +typedef struct _SYSTEM_SET_TIME_ADJUSTMENT { // Information Class 28 + ULONG TimeAdjustment; + BOOL TimeSynchronization; +} SYSTEM_SET_TIME_ADJUSTMENT, *PSYSTEM_SET_TIME_ADJUSTMENT; + +typedef struct _SYSTEM_CRASH_DUMP_INFORMATION { // Information Class 32 + HANDLE CrashDumpSectionHandle; + HANDLE Unknown; // Windows 2000 only +} SYSTEM_CRASH_DUMP_INFORMATION, *PSYSTEM_CRASH_DUMP_INFORMATION; + +typedef struct _SYSTEM_EXCEPTION_INFORMATION { // Information Class 33 + ULONG AlignmentFixupCount; + ULONG ExceptionDispatchCount; + ULONG FloatingEmulationCount; + ULONG Reserved; +} SYSTEM_EXCEPTION_INFORMATION, *PSYSTEM_EXCEPTION_INFORMATION; + +typedef struct _SYSTEM_CRASH_STATE_INFORMATION { // Information Class 34 + ULONG ValidCrashDump; + ULONG Unknown; // Windows 2000 only +} SYSTEM_CRASH_STATE_INFORMATION, *PSYSTEM_CRASH_STATE_INFORMATION; + +typedef struct _SYSTEM_KERNEL_DEBUGGER_INFORMATION { // Information Class 35 + BOOL DebuggerEnabled; + BOOL DebuggerNotPresent; +} SYSTEM_KERNEL_DEBUGGER_INFORMATION, *PSYSTEM_KERNEL_DEBUGGER_INFORMATION; + +typedef struct _SYSTEM_CONTEXT_SWITCH_INFORMATION { // Information Class 36 + ULONG ContextSwitches; + ULONG ContextSwitchCounters[11]; +} SYSTEM_CONTEXT_SWITCH_INFORMATION, *PSYSTEM_CONTEXT_SWITCH_INFORMATION; + +typedef struct _SYSTEM_REGISTRY_QUOTA_INFORMATION { // Information Class 37 + ULONG RegistryQuota; + ULONG RegistryQuotaInUse; + ULONG PagedPoolSize; +} SYSTEM_REGISTRY_QUOTA_INFORMATION, *PSYSTEM_REGISTRY_QUOTA_INFORMATION; + +typedef struct _SYSTEM_LOAD_AND_CALL_IMAGE { // Information Class 38 + UNICODE_STRING ModuleName; +} SYSTEM_LOAD_AND_CALL_IMAGE, *PSYSTEM_LOAD_AND_CALL_IMAGE; + +typedef struct _SYSTEM_PRIORITY_SEPARATION { // Information Class 39 + ULONG PrioritySeparation; +} SYSTEM_PRIORITY_SEPARATION, *PSYSTEM_PRIORITY_SEPARATION; + +typedef struct _SYSTEM_TIME_ZONE_INFORMATION { // Information Class 44 + LONG Bias; + WCHAR StandardName[32]; + SYSTEMTIME StandardDate; + LONG StandardBias; + WCHAR DaylightName[32]; + SYSTEMTIME DaylightDate; + LONG DaylightBias; +} SYSTEM_TIME_ZONE_INFORMATION, *PSYSTEM_TIME_ZONE_INFORMATION; + +typedef struct _SYSTEM_LOOKASIDE_INFORMATION { // Information Class 45 + USHORT Depth; + USHORT MaximumDepth; + ULONG TotalAllocates; + ULONG AllocateMisses; + ULONG TotalFrees; + ULONG FreeMisses; + POOL_TYPE Type; + ULONG Tag; + ULONG Size; +} SYSTEM_LOOKASIDE_INFORMATION, *PSYSTEM_LOOKASIDE_INFORMATION; + +typedef struct _SYSTEM_SET_TIME_SLIP_EVENT { // Information Class 46 + HANDLE TimeSlipEvent; +} SYSTEM_SET_TIME_SLIP_EVENT, *PSYSTEM_SET_TIME_SLIP_EVENT; + +typedef struct _SYSTEM_CREATE_SESSION { // Information Class 47 + ULONG Session; +} SYSTEM_CREATE_SESSION, *PSYSTEM_CREATE_SESSION; + +typedef struct _SYSTEM_DELETE_SESSION { // Information Class 48 + ULONG Session; +} SYSTEM_DELETE_SESSION, *PSYSTEM_DELETE_SESSION; + +typedef struct _SYSTEM_RANGE_START_INFORMATION { // Information Class 50 + PVOID SystemRangeStart; +} SYSTEM_RANGE_START_INFORMATION, *PSYSTEM_RANGE_START_INFORMATION; + +typedef struct _SYSTEM_POOL_BLOCK { + BOOL Allocated; + USHORT Unknown; + ULONG Size; + CHAR Tag[4]; +} SYSTEM_POOL_BLOCK, *PSYSTEM_POOL_BLOCK; + +typedef struct _SYSTEM_POOL_BLOCKS_INFORMATION { // Info Classes 14 and 15 + ULONG PoolSize; + PVOID PoolBase; + USHORT Unknown; + ULONG NumberOfBlocks; + SYSTEM_POOL_BLOCK PoolBlocks[1]; +} SYSTEM_POOL_BLOCKS_INFORMATION, *PSYSTEM_POOL_BLOCKS_INFORMATION; + +typedef struct _SYSTEM_MEMORY_USAGE { + PVOID Name; + USHORT Valid; + USHORT Standby; + USHORT Modified; + USHORT PageTables; +} SYSTEM_MEMORY_USAGE, *PSYSTEM_MEMORY_USAGE; + +typedef struct _SYSTEM_MEMORY_USAGE_INFORMATION { // Info Classes 25 and 29 + ULONG Reserved; + PVOID EndOfData; + SYSTEM_MEMORY_USAGE MemoryUsage[1]; +} SYSTEM_MEMORY_USAGE_INFORMATION, *PSYSTEM_MEMORY_USAGE_INFORMATION; + +NTSYSAPI +NTSTATUS +NTAPI +ZwQuerySystemEnvironmentValue( + IN PUNICODE_STRING Name, + OUT PVOID Value, + IN ULONG ValueLength, + OUT PULONG ReturnLength OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetSystemEnvironmentValue( + IN PUNICODE_STRING Name, + IN PUNICODE_STRING Value + ); + +typedef enum _SHUTDOWN_ACTION { + ShutdownNoReboot, + ShutdownReboot, + ShutdownPowerOff +} SHUTDOWN_ACTION; + +NTSYSAPI +NTSTATUS +NTAPI +ZwShutdownSystem( + IN SHUTDOWN_ACTION Action + ); + +typedef enum _DEBUG_CONTROL_CODE { + DebugGetTraceInformation = 1, + DebugSetInternalBreakpoint, + DebugSetSpecialCall, + DebugClearSpecialCalls, + DebugQuerySpecialCalls, + DebugDbgBreakPoint +} DEBUG_CONTROL_CODE; + +NTSYSAPI +NTSTATUS +NTAPI +ZwSystemDebugControl( + IN DEBUG_CONTROL_CODE ControlCode, + IN PVOID InputBuffer OPTIONAL, + IN ULONG InputBufferLength, + OUT PVOID OutputBuffer OPTIONAL, + IN ULONG OutputBufferLength, + OUT PULONG ReturnLength OPTIONAL + ); + +typedef enum _OBJECT_INFORMATION_CLASS { + ObjectBasicInformation, // 0 Y N + ObjectNameInformation, // 1 Y N + ObjectTypeInformation, // 2 Y N + ObjectAllTypesInformation, // 3 Y N + ObjectHandleInformation // 4 Y Y +} OBJECT_INFORMATION_CLASS; + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryObject( + IN HANDLE ObjectHandle, + IN OBJECT_INFORMATION_CLASS ObjectInformationClass, + OUT PVOID ObjectInformation, + IN ULONG ObjectInformationLength, + OUT PULONG ReturnLength OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetInformationObject( + IN HANDLE ObjectHandle, + IN OBJECT_INFORMATION_CLASS ObjectInformationClass, + IN PVOID ObjectInformation, + IN ULONG ObjectInformationLength + ); + +typedef struct _OBJECT_BASIC_INFORMATION { // Information Class 0 + ULONG Attributes; + ACCESS_MASK GrantedAccess; + ULONG HandleCount; + ULONG PointerCount; + ULONG PagedPoolUsage; + ULONG NonPagedPoolUsage; + ULONG Reserved[3]; + ULONG NameInformationLength; + ULONG TypeInformationLength; + ULONG SecurityDescriptorLength; + LARGE_INTEGER CreateTime; +} OBJECT_BASIC_INFORMATION, *POBJECT_BASIC_INFORMATION; + +typedef struct _OBJECT_TYPE_INFORMATION { // Information Class 2 + UNICODE_STRING Name; + ULONG ObjectCount; + ULONG HandleCount; + ULONG Reserved1[4]; + ULONG PeakObjectCount; + ULONG PeakHandleCount; + ULONG Reserved2[4]; + ULONG InvalidAttributes; + GENERIC_MAPPING GenericMapping; + ULONG ValidAccess; + UCHAR Unknown; + BOOL MaintainHandleDatabase; + UCHAR Reserved3[2]; + POOL_TYPE PoolType; + ULONG PagedPoolUsage; + ULONG NonPagedPoolUsage; +} OBJECT_TYPE_INFORMATION, *POBJECT_TYPE_INFORMATION; + +typedef struct _OBJECT_ALL_TYPES_INFORMATION { // Information Class 3 + ULONG NumberOfTypes; + OBJECT_TYPE_INFORMATION TypeInformation; +} OBJECT_ALL_TYPES_INFORMATION, *POBJECT_ALL_TYPES_INFORMATION; + +typedef struct _OBJECT_HANDLE_ATTRIBUTE_INFORMATION { // Information Class 4 + BOOL Inherit; + BOOL ProtectFromClose; +} OBJECT_HANDLE_ATTRIBUTE_INFORMATION, *POBJECT_HANDLE_ATTRIBUTE_INFORMATION; + +typedef struct _OBJECT_ATTRIBUTES64 { + ULONG Length; + ULONG64 RootDirectory; + ULONG64 ObjectName; + ULONG Attributes; + ULONG64 SecurityDescriptor; + ULONG64 SecurityQualityOfService; +} OBJECT_ATTRIBUTES64; +typedef OBJECT_ATTRIBUTES64 *POBJECT_ATTRIBUTES64; +typedef CONST OBJECT_ATTRIBUTES64 *PCOBJECT_ATTRIBUTES64; + +typedef struct _OBJECT_ATTRIBUTES32 { + ULONG Length; + ULONG RootDirectory; + ULONG ObjectName; + ULONG Attributes; + ULONG SecurityDescriptor; + ULONG SecurityQualityOfService; +} OBJECT_ATTRIBUTES32; +typedef OBJECT_ATTRIBUTES32 *POBJECT_ATTRIBUTES32; +typedef CONST OBJECT_ATTRIBUTES32 *PCOBJECT_ATTRIBUTES32; + +typedef struct _OBJECT_ATTRIBUTES { + ULONG Length; + HANDLE RootDirectory; + PUNICODE_STRING ObjectName; + ULONG Attributes; + PVOID SecurityDescriptor; // Points to type SECURITY_DESCRIPTOR + PVOID SecurityQualityOfService; // Points to type SECURITY_QUALITY_OF_SERVICE +} OBJECT_ATTRIBUTES; +typedef OBJECT_ATTRIBUTES *POBJECT_ATTRIBUTES; + + +typedef enum _PROCESSINFOCLASS { + ProcessBasicInformation, + ProcessQuotaLimits, + ProcessIoCounters, + ProcessVmCounters, + ProcessTimes, + ProcessBasePriority, + ProcessRaisePriority, + ProcessDebugPort, + ProcessExceptionPort, + ProcessAccessToken, + ProcessLdtInformation, + ProcessLdtSize, + ProcessDefaultHardErrorMode, + ProcessIoPortHandlers, // Note: this is kernel mode only + ProcessPooledUsageAndLimits, + ProcessWorkingSetWatch, + ProcessUserModeIOPL, + ProcessEnableAlignmentFaultFixup, + ProcessPriorityClass, + ProcessWx86Information, + ProcessHandleCount, + ProcessAffinityMask, + ProcessPriorityBoost, + ProcessDeviceMap, + ProcessSessionInformation, + ProcessForegroundInformation, + ProcessWow64Information, + ProcessImageFileName, + ProcessLUIDDeviceMapsEnabled, + ProcessBreakOnTermination, + ProcessDebugObjectHandle, + ProcessDebugFlags, + ProcessHandleTracing, + ProcessIoPriority, + ProcessExecuteFlags, + ProcessTlsInformation, + ProcessCookie, + ProcessImageInformation, + ProcessCycleTime, + ProcessPagePriority, + ProcessInstrumentationCallback, + ProcessThreadStackAllocation, + ProcessWorkingSetWatchEx, + ProcessImageFileNameWin32, + ProcessImageFileMapping, + ProcessAffinityUpdateMode, + ProcessMemoryAllocationMode, + ProcessGroupInformation, + ProcessTokenVirtualizationEnabled, + ProcessConsoleHostProcess, + ProcessWindowInformation, + MaxProcessInfoClass // MaxProcessInfoClass should always be the last enum +} PROCESSINFOCLASS; + +// +// Thread Information Classes +// + +typedef enum _THREADINFOCLASS { + ThreadBasicInformation, + ThreadTimes, + ThreadPriority, + ThreadBasePriority, + ThreadAffinityMask, + ThreadImpersonationToken, + ThreadDescriptorTableEntry, + ThreadEnableAlignmentFaultFixup, + ThreadEventPair_Reusable, + ThreadQuerySetWin32StartAddress, + ThreadZeroTlsCell, + ThreadPerformanceCount, + ThreadAmILastThread, + ThreadIdealProcessor, + ThreadPriorityBoost, + ThreadSetTlsArrayAddress, // Obsolete + ThreadIsIoPending, + ThreadHideFromDebugger, + ThreadBreakOnTermination, + ThreadSwitchLegacyState, + ThreadIsTerminated, + ThreadLastSystemCall, + ThreadIoPriority, + ThreadCycleTime, + ThreadPagePriority, + ThreadActualBasePriority, + ThreadTebInformation, + ThreadCSwitchMon, // Obsolete + ThreadCSwitchPmu, + ThreadWow64Context, + ThreadGroupInformation, + ThreadUmsInformation, // UMS + ThreadCounterProfiling, + ThreadIdealProcessorEx, + MaxThreadInfoClass +} THREADINFOCLASS; + +#define THREAD_CSWITCH_PMU_DISABLE FALSE +#define THREAD_CSWITCH_PMU_ENABLE TRUE + +NTSYSAPI +NTSTATUS +NTAPI +ZwDuplicateObject( + IN HANDLE SourceProcessHandle, + IN HANDLE SourceHandle, + IN HANDLE TargetProcessHandle, + OUT PHANDLE TargetHandle OPTIONAL, + IN ACCESS_MASK DesiredAccess, + IN ULONG Attributes, + IN ULONG Options + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwMakeTemporaryObject( + IN HANDLE Handle + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwClose( + IN HANDLE Handle + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQuerySecurityObject( + IN HANDLE Handle, + IN SECURITY_INFORMATION RequestedInformation, + OUT PSECURITY_DESCRIPTOR SecurityDescriptor, + IN ULONG SecurityDescriptorLength, + OUT PULONG ReturnLength + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetSecurityObject( + IN HANDLE Handle, + IN SECURITY_INFORMATION SecurityInformation, + IN PSECURITY_DESCRIPTOR SecurityDescriptor + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwCreateDirectoryObject( + OUT PHANDLE DirectoryHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenDirectoryObject( + OUT PHANDLE DirectoryHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryDirectoryObject( + IN HANDLE DirectoryHandle, + OUT PVOID Buffer, + IN ULONG BufferLength, + IN BOOL ReturnSingleEntry, + IN BOOL RestartScan, + IN OUT PULONG Context, + OUT PULONG ReturnLength OPTIONAL + ); + +typedef struct _DIRECTORY_BASIC_INFORMATION { + UNICODE_STRING ObjectName; + UNICODE_STRING ObjectTypeName; +} DIRECTORY_BASIC_INFORMATION, *PDIRECTORY_BASIC_INFORMATION; + +NTSYSAPI +NTSTATUS +NTAPI +ZwCreateSymbolicLinkObject( + OUT PHANDLE SymbolicLinkHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN PUNICODE_STRING TargetName + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenSymbolicLinkObject( + OUT PHANDLE SymbolicLinkHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQuerySymbolicLinkObject( + IN HANDLE SymbolicLinkHandle, + IN OUT PUNICODE_STRING TargetName, + OUT PULONG ReturnLength OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwAllocateVirtualMemory( + IN HANDLE ProcessHandle, + IN OUT PVOID *BaseAddress, + IN ULONG ZeroBits, + IN OUT PULONG AllocationSize, + IN ULONG AllocationType, + IN ULONG Protect + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwFreeVirtualMemory( + IN HANDLE ProcessHandle, + IN OUT PVOID *BaseAddress, + IN OUT PULONG FreeSize, + IN ULONG FreeType + ); + +typedef enum _MEMORY_INFORMATION_CLASS { + MemoryBasicInformation, + MemoryWorkingSetList, + MemorySectionName, + MemoryBasicVlmInformation +} MEMORY_INFORMATION_CLASS; + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryVirtualMemory( + IN HANDLE ProcessHandle, + IN PVOID BaseAddress, + IN MEMORY_INFORMATION_CLASS MemoryInformationClass, + OUT PVOID MemoryInformation, + IN ULONG MemoryInformationLength, + OUT PULONG ReturnLength OPTIONAL + ); + +typedef struct _MEMORY_BASIC_INFORMATION { // Information Class 0 + PVOID BaseAddress; + PVOID AllocationBase; + ULONG AllocationProtect; + ULONG RegionSize; + ULONG State; + ULONG Protect; + ULONG Type; +} MEMORY_BASIC_INFORMATION, *PMEMORY_BASIC_INFORMATION; + +typedef struct _MEMORY_WORKING_SET_LIST { // Information Class 1 + ULONG NumberOfPages; + ULONG WorkingSetList[1]; +} MEMORY_WORKING_SET_LIST, *PMEMORY_WORKING_SET_LIST; + +typedef struct _MEMORY_SECTION_NAME { // Information Class 2 + UNICODE_STRING SectionFileName; +} MEMORY_SECTION_NAME, *PMEMORY_SECTION_NAME; + +NTSYSAPI +NTSTATUS +NTAPI +ZwLockVirtualMemory( + IN HANDLE ProcessHandle, + IN OUT PVOID *BaseAddress, + IN OUT PULONG LockSize, + IN ULONG LockType + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwUnlockVirtualMemory( + IN HANDLE ProcessHandle, + IN OUT PVOID *BaseAddress, + IN OUT PULONG LockSize, + IN ULONG LockType + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwReadVirtualMemory( + IN HANDLE ProcessHandle, + IN PVOID BaseAddress, + OUT PVOID Buffer, + IN ULONG BufferLength, + OUT PULONG ReturnLength OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwWriteVirtualMemory( + IN HANDLE ProcessHandle, + IN PVOID BaseAddress, + IN PVOID Buffer, + IN ULONG BufferLength, + OUT PULONG ReturnLength OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwProtectVirtualMemory( + IN HANDLE ProcessHandle, + IN OUT PVOID *BaseAddress, + IN OUT PULONG ProtectSize, + IN ULONG NewProtect, + OUT PULONG OldProtect + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwFlushVirtualMemory( + IN HANDLE ProcessHandle, + IN OUT PVOID *BaseAddress, + IN OUT PULONG FlushSize, + OUT PIO_STATUS_BLOCK IoStatusBlock + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwAllocateUserPhysicalPages( + IN HANDLE ProcessHandle, + IN PULONG NumberOfPages, + OUT PULONG PageFrameNumbers + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwFreeUserPhysicalPages( + IN HANDLE ProcessHandle, + IN OUT PULONG NumberOfPages, + IN PULONG PageFrameNumbers + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwMapUserPhysicalPages( + IN PVOID BaseAddress, + IN PULONG NumberOfPages, + IN PULONG PageFrameNumbers + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwMapUserPhysicalPagesScatter( + IN PVOID *BaseAddresses, + IN PULONG NumberOfPages, + IN PULONG PageFrameNumbers + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwGetWriteWatch( + IN HANDLE ProcessHandle, + IN ULONG Flags, + IN PVOID BaseAddress, + IN ULONG RegionSize, + OUT PULONG Buffer, + IN OUT PULONG BufferEntries, + OUT PULONG Granularity + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwResetWriteWatch( + IN HANDLE ProcessHandle, + IN PVOID BaseAddress, + IN ULONG RegionSize + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwCreateSection( + OUT PHANDLE SectionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN PLARGE_INTEGER SectionSize OPTIONAL, + IN ULONG Protect, + IN ULONG Attributes, + IN HANDLE FileHandle + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenSection( + OUT PHANDLE SectionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes + ); + +typedef enum _SECTION_INFORMATION_CLASS { + SectionBasicInformation, + SectionImageInformation +} SECTION_INFORMATION_CLASS; + +NTSYSAPI +NTSTATUS +NTAPI +ZwQuerySection( + IN HANDLE SectionHandle, + IN SECTION_INFORMATION_CLASS SectionInformationClass, + OUT PVOID SectionInformation, + IN ULONG SectionInformationLength, + OUT PULONG ResultLength OPTIONAL + ); + +typedef struct _SECTION_BASIC_INFORMATION { // Information Class 0 + PVOID BaseAddress; + ULONG Attributes; + LARGE_INTEGER Size; +} SECTION_BASIC_INFORMATION, *PSECTION_BASIC_INFORMATION; + +typedef struct _SECTION_IMAGE_INFORMATION { // Information Class 1 + PVOID EntryPoint; + ULONG Unknown1; + ULONG StackReserve; + ULONG StackCommit; + ULONG Subsystem; + USHORT MinorSubsystemVersion; + USHORT MajorSubsystemVersion; + ULONG Unknown2; + ULONG Characteristics; + USHORT ImageNumber; + BOOL Executable; + UCHAR Unknown3; + ULONG Unknown4[3]; +} SECTION_IMAGE_INFORMATION, *PSECTION_IMAGE_INFORMATION; + +NTSYSAPI +NTSTATUS +NTAPI +ZwExtendSection( + IN HANDLE SectionHandle, + IN PLARGE_INTEGER SectionSize + ); +#if 0 +NTSYSAPI +NTSTATUS +NTAPI +ZwMapViewOfSection( + IN HANDLE SectionHandle, + IN HANDLE ProcessHandle, + IN OUT PVOID *BaseAddress, + IN ULONG ZeroBits, + IN ULONG CommitSize, + IN OUT PLARGE_INTEGER SectionOffset OPTIONAL, + IN OUT PULONG ViewSize, + IN SECTION_INHERIT InheritDisposition, + IN ULONG AllocationType, + IN ULONG Protect + ); +#endif + +NTSYSAPI +NTSTATUS +NTAPI +ZwUnmapViewOfSection( + IN HANDLE ProcessHandle, + IN PVOID BaseAddress + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwAreMappedFilesTheSame( + IN PVOID Address1, + IN PVOID Address2 + ); + +typedef struct _USER_STACK { + PVOID FixedStackBase; + PVOID FixedStackLimit; + PVOID ExpandableStackBase; + PVOID ExpandableStackLimit; + PVOID ExpandableStackBottom; +} USER_STACK, *PUSER_STACK; + +NTSYSAPI +NTSTATUS +NTAPI +ZwCreateThread( + OUT PHANDLE ThreadHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN HANDLE ProcessHandle, + OUT PCLIENT_ID ClientId, + IN PCONTEXT ThreadContext, + IN PUSER_STACK UserStack, + IN BOOL CreateSuspended + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenThread( + OUT PHANDLE ThreadHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN PCLIENT_ID ClientId + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwTerminateThread( + IN HANDLE ThreadHandle OPTIONAL, + IN NTSTATUS ExitStatus + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryInformationThread( + IN HANDLE ThreadHandle, + IN THREADINFOCLASS ThreadInformationClass, + OUT PVOID ThreadInformation, + IN ULONG ThreadInformationLength, + OUT PULONG ReturnLength OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetInformationThread( + IN HANDLE ThreadHandle, + IN THREADINFOCLASS ThreadInformationClass, + IN PVOID ThreadInformation, + IN ULONG ThreadInformationLength + ); + +typedef struct _THREAD_BASIC_INFORMATION { // Information Class 0 + NTSTATUS ExitStatus; + PNT_TIB TebBaseAddress; + CLIENT_ID ClientId; + KAFFINITY AffinityMask; + KPRIORITY Priority; + KPRIORITY BasePriority; +} THREAD_BASIC_INFORMATION, *PTHREAD_BASIC_INFORMATION; + +NTSYSAPI +NTSTATUS +NTAPI +ZwSuspendThread( + IN HANDLE ThreadHandle, + OUT PULONG PreviousSuspendCount OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwResumeThread( + IN HANDLE ThreadHandle, + OUT PULONG PreviousSuspendCount OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwGetContextThread( + IN HANDLE ThreadHandle, + OUT PCONTEXT Context + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetContextThread( + IN HANDLE ThreadHandle, + IN PCONTEXT Context + ); + +typedef +VOID +(KNORMAL_ROUTINE) ( + IN PVOID NormalContext, + IN PVOID SystemArgument1, + IN PVOID SystemArgument2 + ); +typedef KNORMAL_ROUTINE *PKNORMAL_ROUTINE; + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueueApcThread( + IN HANDLE ThreadHandle, + IN PKNORMAL_ROUTINE ApcRoutine, + IN PVOID ApcContext OPTIONAL, + IN PVOID Argument1 OPTIONAL, + IN PVOID Argument2 OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwTestAlert( + VOID + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwAlertThread( + IN HANDLE ThreadHandle + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwAlertResumeThread( + IN HANDLE ThreadHandle, + OUT PULONG PreviousSuspendCount OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwRegisterThreadTerminatePort( + IN HANDLE PortHandle + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwImpersonateThread( + IN HANDLE ThreadHandle, + IN HANDLE TargetThreadHandle, + IN PSECURITY_QUALITY_OF_SERVICE SecurityQos + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwImpersonateAnonymousToken( + IN HANDLE ThreadHandle + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwCreateProcess( + OUT PHANDLE ProcessHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN HANDLE InheritFromProcessHandle, + IN BOOL InheritHandles, + IN HANDLE SectionHandle OPTIONAL, + IN HANDLE DebugPort OPTIONAL, + IN HANDLE ExceptionPort OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenProcess( + OUT PHANDLE ProcessHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN PCLIENT_ID ClientId OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwTerminateProcess( + IN HANDLE ProcessHandle OPTIONAL, + IN NTSTATUS ExitStatus + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryInformationProcess( + IN HANDLE ProcessHandle, + IN PROCESSINFOCLASS ProcessInformationClass, + OUT PVOID ProcessInformation, + IN ULONG ProcessInformationLength, + OUT PULONG ReturnLength OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetInformationProcess( + IN HANDLE ProcessHandle, + IN PROCESSINFOCLASS ProcessInformationClass, + IN PVOID ProcessInformation, + IN ULONG ProcessInformationLength + ); + +typedef struct _PROCESS_PRIORITY_CLASS { // Information Class 18 + BOOL Foreground; + UCHAR PriorityClass; +} PROCESS_PRIORITY_CLASS, *PPROCESS_PRIORITY_CLASS; + +typedef struct _PROCESS_PARAMETERS { + ULONG AllocationSize; + ULONG Size; + ULONG Flags; + ULONG Zero; + LONG Console; + ULONG ProcessGroup; + HANDLE hStdInput; + HANDLE hStdOutput; + HANDLE hStdError; + UNICODE_STRING CurrentDirectoryName; + HANDLE CurrentDirectoryHandle; + UNICODE_STRING DllPath; + UNICODE_STRING ImageFile; + UNICODE_STRING CommandLine; + PWSTR Environment; + ULONG dwX; + ULONG dwY; + ULONG dwXSize; + ULONG dwYSize; + ULONG dwXCountChars; + ULONG dwYCountChars; + ULONG dwFillAttribute; + ULONG dwFlags; + ULONG wShowWindow; + UNICODE_STRING WindowTitle; + UNICODE_STRING Desktop; + UNICODE_STRING Reserved; + UNICODE_STRING Reserved2; +} PROCESS_PARAMETERS, *PPROCESS_PARAMETERS; + +NTSTATUS +NTAPI +RtlCreateProcessParameters( + OUT PPROCESS_PARAMETERS *ProcessParameters, + IN PUNICODE_STRING ImageFile, + IN PUNICODE_STRING DllPath OPTIONAL, + IN PUNICODE_STRING CurrentDirectory OPTIONAL, + IN PUNICODE_STRING CommandLine OPTIONAL, + IN ULONG CreationFlags, + IN PUNICODE_STRING WindowTitle OPTIONAL, + IN PUNICODE_STRING Desktop OPTIONAL, + IN PUNICODE_STRING Reserved OPTIONAL, + IN PUNICODE_STRING Reserved2 OPTIONAL + ); + +NTSTATUS +NTAPI +RtlDestroyProcessParameters( + IN PPROCESS_PARAMETERS ProcessParameters + ); + +typedef struct _DEBUG_BUFFER { + HANDLE SectionHandle; + PVOID SectionBase; + PVOID RemoteSectionBase; + ULONG SectionBaseDelta; + HANDLE EventPairHandle; + ULONG Unknown[2]; + HANDLE RemoteThreadHandle; + ULONG InfoClassMask; + ULONG SizeOfInfo; + ULONG AllocatedSize; + ULONG SectionSize; + PVOID ModuleInformation; + PVOID BackTraceInformation; + PVOID HeapInformation; + PVOID LockInformation; + PVOID Reserved[8]; +} DEBUG_BUFFER, *PDEBUG_BUFFER; + +#define PDI_MODULES 0x01 +#define PDI_BACKTRACE 0x02 +#define PDI_HEAPS 0x04 +#define PDI_HEAP_TAGS 0x08 +#define PDI_HEAP_BLOCKS 0x10 +#define PDI_LOCKS 0x20 + +typedef struct _DEBUG_MODULE_INFORMATION { // c.f. SYSTEM_MODULE_INFORMATION + ULONG Reserved[2]; + ULONG Base; + ULONG Size; + ULONG Flags; + USHORT Index; + USHORT Unknown; + USHORT LoadCount; + USHORT ModuleNameOffset; + CHAR ImageName[256]; +} DEBUG_MODULE_INFORMATION, *PDEBUG_MODULE_INFORMATION; + +typedef struct _DEBUG_HEAP_INFORMATION { + ULONG Base; + ULONG Flags; + USHORT Granularity; + USHORT Unknown; + ULONG Allocated; + ULONG Committed; + ULONG TagCount; + ULONG BlockCount; + ULONG Reserved[7]; + PVOID Tags; + PVOID Blocks; +} DEBUG_HEAP_INFORMATION, *PDEBUG_HEAP_INFORMATION; + +typedef struct _DEBUG_LOCK_INFORMATION { // c.f. SYSTEM_LOCK_INFORMATION + PVOID Address; + USHORT Type; + USHORT CreatorBackTraceIndex; + ULONG OwnerThreadId; + ULONG ActiveCount; + ULONG ContentionCount; + ULONG EntryCount; + ULONG RecursionCount; + ULONG NumberOfSharedWaiters; + ULONG NumberOfExclusiveWaiters; +} DEBUG_LOCK_INFORMATION, *PDEBUG_LOCK_INFORMATION; + +PDEBUG_BUFFER +NTAPI +RtlCreateQueryDebugBuffer( + IN ULONG Size, + IN BOOL EventPair + ); + +NTSTATUS +NTAPI +RtlQueryProcessDebugInformation( + IN ULONG ProcessId, + IN ULONG DebugInfoClassMask, + IN OUT PDEBUG_BUFFER DebugBuffer + ); + +NTSTATUS +NTAPI +RtlDestroyQueryDebugBuffer( + IN PDEBUG_BUFFER DebugBuffer + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwCreateJobObject( + OUT PHANDLE JobHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenJobObject( + OUT PHANDLE JobHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwTerminateJobObject( + IN HANDLE JobHandle, + IN NTSTATUS ExitStatus + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwAssignProcessToJobObject( + IN HANDLE JobHandle, + IN HANDLE ProcessHandle + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryInformationJobObject( + IN HANDLE JobHandle, + IN JOBOBJECTINFOCLASS JobInformationClass, + OUT PVOID JobInformation, + IN ULONG JobInformationLength, + OUT PULONG ReturnLength OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetInformationJobObject( + IN HANDLE JobHandle, + IN JOBOBJECTINFOCLASS JobInformationClass, + IN PVOID JobInformation, + IN ULONG JobInformationLength + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwCreateToken( + OUT PHANDLE TokenHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN TOKEN_TYPE Type, + IN PLUID AuthenticationId, + IN PLARGE_INTEGER ExpirationTime, + IN PTOKEN_USER User, + IN PTOKEN_GROUPS Groups, + IN PTOKEN_PRIVILEGES Privileges, + IN PTOKEN_OWNER Owner, + IN PTOKEN_PRIMARY_GROUP PrimaryGroup, + IN PTOKEN_DEFAULT_DACL DefaultDacl, + IN PTOKEN_SOURCE Source + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenProcessToken( + IN HANDLE ProcessHandle, + IN ACCESS_MASK DesiredAccess, + OUT PHANDLE TokenHandle + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenThreadToken( + IN HANDLE ThreadHandle, + IN ACCESS_MASK DesiredAccess, + IN BOOL OpenAsSelf, + OUT PHANDLE TokenHandle + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDuplicateToken( + IN HANDLE ExistingTokenHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN BOOL EffectiveOnly, + IN TOKEN_TYPE TokenType, + OUT PHANDLE NewTokenHandle + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwFilterToken( + IN HANDLE ExistingTokenHandle, + IN ULONG Flags, + IN PTOKEN_GROUPS SidsToDisable, + IN PTOKEN_PRIVILEGES PrivilegesToDelete, + IN PTOKEN_GROUPS SidsToRestricted, + OUT PHANDLE NewTokenHandle + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwAdjustPrivilegesToken( + IN HANDLE TokenHandle, + IN BOOL DisableAllPrivileges, + IN PTOKEN_PRIVILEGES NewState, + IN ULONG BufferLength, + OUT PTOKEN_PRIVILEGES PreviousState OPTIONAL, + OUT PULONG ReturnLength + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwAdjustGroupsToken( + IN HANDLE TokenHandle, + IN BOOL ResetToDefault, + IN PTOKEN_GROUPS NewState, + IN ULONG BufferLength, + OUT PTOKEN_GROUPS PreviousState OPTIONAL, + OUT PULONG ReturnLength + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryInformationToken( + IN HANDLE TokenHandle, + IN TOKEN_INFORMATION_CLASS TokenInformationClass, + OUT PVOID TokenInformation, + IN ULONG TokenInformationLength, + OUT PULONG ReturnLength + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetInformationToken( + IN HANDLE TokenHandle, + IN TOKEN_INFORMATION_CLASS TokenInformationClass, + IN PVOID TokenInformation, + IN ULONG TokenInformationLength + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwWaitForSingleObject( + IN HANDLE Handle, + IN BOOL Alertable, + IN PLARGE_INTEGER Timeout OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSignalAndWaitForSingleObject( + IN HANDLE HandleToSignal, + IN HANDLE HandleToWait, + IN BOOL Alertable, + IN PLARGE_INTEGER Timeout OPTIONAL + ); + +typedef enum _WAIT_TYPE { + WaitAll, + WaitAny +} WAIT_TYPE; + +NTSYSAPI +NTSTATUS +NTAPI +ZwWaitForMultipleObjects( + IN ULONG HandleCount, + IN PHANDLE Handles, + IN WAIT_TYPE WaitType, + IN BOOL Alertable, + IN PLARGE_INTEGER Timeout OPTIONAL + ); + +/* Win2000 DDK includes these declarations but without explicit calling convention specification + +NTSYSAPI +NTSTATUS +NTAPI +ZwCreateTimer( + OUT PHANDLE TimerHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN TIMER_TYPE TimerType + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenTimer( + OUT PHANDLE TimerHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwCancelTimer( + IN HANDLE TimerHandle, + OUT PBOOL PreviousState OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetTimer( + IN HANDLE TimerHandle, + IN PLARGE_INTEGER DueTime, + IN PTIMER_APC_ROUTINE TimerApcRoutine OPTIONAL, + IN PVOID TimerContext, + IN BOOL Resume, + IN LONG Period, + OUT PBOOL PreviousState OPTIONAL + ); + +*/ + +typedef enum _TIMER_INFORMATION_CLASS { + TimerBasicInformation +} TIMER_INFORMATION_CLASS; + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryTimer( + IN HANDLE TimerHandle, + IN TIMER_INFORMATION_CLASS TimerInformationClass, + OUT PVOID TimerInformation, + IN ULONG TimerInformationLength, + OUT PULONG ResultLength OPTIONAL + ); + +typedef struct _TIMER_BASIC_INFORMATION { + LARGE_INTEGER TimeRemaining; + BOOL SignalState; +} TIMER_BASIC_INFORMATION, *PTIMER_BASIC_INFORMATION; + +typedef enum _EVENT_TYPE { + NotificationEvent, + SynchronizationEvent +} EVENT_TYPE; + +NTSYSAPI +NTSTATUS +NTAPI +ZwCreateEvent( + OUT PHANDLE EventHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN EVENT_TYPE EventType, + IN BOOL InitialState + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenEvent( + OUT PHANDLE EventHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetEvent( + IN HANDLE EventHandle, + OUT PULONG PreviousState OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwPulseEvent( + IN HANDLE EventHandle, + OUT PULONG PreviousState OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwResetEvent( + IN HANDLE EventHandle, + OUT PULONG PreviousState OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwClearEvent( + IN HANDLE EventHandle + ); + +typedef enum _EVENT_INFORMATION_CLASS { + EventBasicInformation +} EVENT_INFORMATION_CLASS; + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryEvent( + IN HANDLE EventHandle, + IN EVENT_INFORMATION_CLASS EventInformationClass, + OUT PVOID EventInformation, + IN ULONG EventInformationLength, + OUT PULONG ResultLength OPTIONAL + ); + +typedef struct _EVENT_BASIC_INFORMATION { + EVENT_TYPE EventType; + LONG SignalState; +} EVENT_BASIC_INFORMATION, *PEVENT_BASIC_INFORMATION; + +NTSYSAPI +NTSTATUS +NTAPI +ZwCreateSemaphore( + OUT PHANDLE SemaphoreHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN LONG InitialCount, + IN LONG MaximumCount + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenSemaphore( + OUT PHANDLE SemaphoreHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwReleaseSemaphore( + IN HANDLE SemaphoreHandle, + IN LONG ReleaseCount, + OUT PLONG PreviousCount OPTIONAL + ); + +typedef enum _SEMAPHORE_INFORMATION_CLASS { + SemaphoreBasicInformation +} SEMAPHORE_INFORMATION_CLASS; + +NTSYSAPI +NTSTATUS +NTAPI +ZwQuerySemaphore( + IN HANDLE SemaphoreHandle, + IN SEMAPHORE_INFORMATION_CLASS SemaphoreInformationClass, + OUT PVOID SemaphoreInformation, + IN ULONG SemaphoreInformationLength, + OUT PULONG ResultLength OPTIONAL + ); + +typedef struct _SEMAPHORE_BASIC_INFORMATION { + LONG CurrentCount; + LONG MaximumCount; +} SEMAPHORE_BASIC_INFORMATION, *PSEMAPHORE_BASIC_INFORMATION; + +NTSYSAPI +NTSTATUS +NTAPI +ZwCreateMutant( + OUT PHANDLE MutantHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN BOOL InitialOwner + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenMutant( + OUT PHANDLE MutantHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwReleaseMutant( + IN HANDLE MutantHandle, + OUT PULONG PreviousState + ); + +typedef enum _MUTANT_INFORMATION_CLASS { + MutantBasicInformation +} MUTANT_INFORMATION_CLASS; + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryMutant( + IN HANDLE MutantHandle, + IN MUTANT_INFORMATION_CLASS MutantInformationClass, + OUT PVOID MutantInformation, + IN ULONG MutantInformationLength, + OUT PULONG ResultLength OPTIONAL + ); + +typedef struct _MUTANT_BASIC_INFORMATION { + LONG SignalState; + BOOL Owned; + BOOL Abandoned; +} MUTANT_BASIC_INFORMATION, *PMUTANT_BASIC_INFORMATION; + +NTSYSAPI +NTSTATUS +NTAPI +ZwCreateIoCompletion( + OUT PHANDLE IoCompletionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN ULONG NumberOfConcurrentThreads + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenIoCompletion( + OUT PHANDLE IoCompletionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetIoCompletion( + IN HANDLE IoCompletionHandle, + IN ULONG CompletionKey, + IN ULONG CompletionValue, + IN NTSTATUS Status, + IN ULONG Information + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwRemoveIoCompletion( + IN HANDLE IoCompletionHandle, + OUT PULONG CompletionKey, + OUT PULONG CompletionValue, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PLARGE_INTEGER Timeout OPTIONAL + ); + +typedef enum _IO_COMPLETION_INFORMATION_CLASS { + IoCompletionBasicInformation +} IO_COMPLETION_INFORMATION_CLASS; + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryIoCompletion( + IN HANDLE IoCompletionHandle, + IN IO_COMPLETION_INFORMATION_CLASS IoCompletionInformationClass, + OUT PVOID IoCompletionInformation, + IN ULONG IoCompletionInformationLength, + OUT PULONG ResultLength OPTIONAL + ); + +typedef struct _IO_COMPLETION_BASIC_INFORMATION { + LONG SignalState; +} IO_COMPLETION_BASIC_INFORMATION, *PIO_COMPLETION_BASIC_INFORMATION; + +NTSYSAPI +NTSTATUS +NTAPI +ZwCreateEventPair( + OUT PHANDLE EventPairHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenEventPair( + OUT PHANDLE EventPairHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwWaitLowEventPair( + IN HANDLE EventPairHandle + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwWaitHighEventPair( + IN HANDLE EventPairHandle + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetLowWaitHighEventPair( + IN HANDLE EventPairHandle + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetHighWaitLowEventPair( + IN HANDLE EventPairHandle + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetLowEventPair( + IN HANDLE EventPairHandle + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetHighEventPair( + IN HANDLE EventPairHandle + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQuerySystemTime( + OUT PLARGE_INTEGER CurrentTime + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetSystemTime( + IN PLARGE_INTEGER NewTime, + OUT PLARGE_INTEGER OldTime OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryPerformanceCounter( + OUT PLARGE_INTEGER PerformanceCount, + OUT PLARGE_INTEGER PerformanceFrequency OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetTimerResolution( + IN ULONG RequestedResolution, + IN BOOL Set, + OUT PULONG ActualResolution + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryTimerResolution( + OUT PULONG CoarsestResolution, + OUT PULONG FinestResolution, + OUT PULONG ActualResolution + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDelayExecution( + IN BOOL Alertable, + IN PLARGE_INTEGER Interval + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwYieldExecution( + VOID + ); + +NTSYSAPI +ULONG +NTAPI +ZwGetTickCount( + VOID + ); + +typedef enum _KPROFILE_SOURCE { + ProfileTime, + ProfileAlignmentFixup, + ProfileTotalIssues, + ProfilePipelineDry, + ProfileLoadInstructions, + ProfilePipelineFrozen, + ProfileBranchInstructions, + ProfileTotalNonissues, + ProfileDcacheMisses, + ProfileIcacheMisses, + ProfileCacheMisses, + ProfileBranchMispredictions, + ProfileStoreInstructions, + ProfileFpInstructions, + ProfileIntegerInstructions, + Profile2Issue, + Profile3Issue, + Profile4Issue, + ProfileSpecialInstructions, + ProfileTotalCycles, + ProfileIcacheIssues, + ProfileDcacheAccesses, + ProfileMemoryBarrierCycles, + ProfileLoadLinkedIssues, + ProfileMaximum +} KPROFILE_SOURCE; + +NTSYSAPI +NTSTATUS +NTAPI +ZwCreateProfile( + OUT PHANDLE ProfileHandle, + IN HANDLE ProcessHandle, + IN PVOID Base, + IN ULONG Size, + IN ULONG BucketShift, + IN PULONG Buffer, + IN ULONG BufferLength, + IN KPROFILE_SOURCE Source, + IN ULONG ProcessorMask + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetIntervalProfile( + IN ULONG Interval, + IN KPROFILE_SOURCE Source + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryIntervalProfile( + IN KPROFILE_SOURCE Source, + OUT PULONG Interval + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwStartProfile( + IN HANDLE ProfileHandle + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwStopProfile( + IN HANDLE ProfileHandle + ); + +typedef struct _PORT_MESSAGE { + USHORT DataSize; + USHORT MessageSize; + USHORT MessageType; + USHORT VirtualRangesOffset; + CLIENT_ID ClientId; + ULONG MessageId; + ULONG SectionSize; + // UCHAR Data[]; +} PORT_MESSAGE, *PPORT_MESSAGE; + +typedef enum _LPC_TYPE { + LPC_NEW_MESSAGE, // A new message + LPC_REQUEST, // A request message + LPC_REPLY, // A reply to a request message + LPC_DATAGRAM, // + LPC_LOST_REPLY, // + LPC_PORT_CLOSED, // Sent when port is deleted + LPC_CLIENT_DIED, // Messages to thread termination ports + LPC_EXCEPTION, // Messages to thread exception port + LPC_DEBUG_EVENT, // Messages to thread debug port + LPC_ERROR_EVENT, // Used by ZwRaiseHardError + LPC_CONNECTION_REQUEST // Used by ZwConnectPort +} LPC_TYPE; + +typedef struct _PORT_SECTION_WRITE { + ULONG Length; + HANDLE SectionHandle; + ULONG SectionOffset; + ULONG ViewSize; + PVOID ViewBase; + PVOID TargetViewBase; +} PORT_SECTION_WRITE, *PPORT_SECTION_WRITE; + +typedef struct _PORT_SECTION_READ { + ULONG Length; + ULONG ViewSize; + ULONG ViewBase; +} PORT_SECTION_READ, *PPORT_SECTION_READ; + +NTSYSAPI +NTSTATUS +NTAPI +ZwCreatePort( + OUT PHANDLE PortHandle, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN ULONG MaxDataSize, + IN ULONG MaxMessageSize, + IN ULONG Reserved + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwCreateWaitablePort( + OUT PHANDLE PortHandle, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN ULONG MaxDataSize, + IN ULONG MaxMessageSize, + IN ULONG Reserved + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwConnectPort( + OUT PHANDLE PortHandle, + IN PUNICODE_STRING PortName, + IN PSECURITY_QUALITY_OF_SERVICE SecurityQos, + IN OUT PPORT_SECTION_WRITE WriteSection OPTIONAL, + IN OUT PPORT_SECTION_READ ReadSection OPTIONAL, + OUT PULONG MaxMessageSize OPTIONAL, + IN OUT PVOID ConnectData OPTIONAL, + IN OUT PULONG ConnectDataLength OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSecureConnectPort( + OUT PHANDLE PortHandle, + IN PUNICODE_STRING PortName, + IN PSECURITY_QUALITY_OF_SERVICE SecurityQos, + IN OUT PPORT_SECTION_WRITE WriteSection OPTIONAL, + IN PSID ServerSid OPTIONAL, + IN OUT PPORT_SECTION_READ ReadSection OPTIONAL, + OUT PULONG MaxMessageSize OPTIONAL, + IN OUT PVOID ConnectData OPTIONAL, + IN OUT PULONG ConnectDataLength OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwListenPort( + IN HANDLE PortHandle, + OUT PPORT_MESSAGE Message + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwAcceptConnectPort( + OUT PHANDLE PortHandle, + IN ULONG PortIdentifier, + IN PPORT_MESSAGE Message, + IN BOOL Accept, + IN OUT PPORT_SECTION_WRITE WriteSection OPTIONAL, + IN OUT PPORT_SECTION_READ ReadSection OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwCompleteConnectPort( + IN HANDLE PortHandle + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwRequestPort( + IN HANDLE PortHandle, + IN PPORT_MESSAGE RequestMessage + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwRequestWaitReplyPort( + IN HANDLE PortHandle, + IN PPORT_MESSAGE RequestMessage, + OUT PPORT_MESSAGE ReplyMessage + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwReplyPort( + IN HANDLE PortHandle, + IN PPORT_MESSAGE ReplyMessage + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwReplyWaitReplyPort( + IN HANDLE PortHandle, + IN OUT PPORT_MESSAGE ReplyMessage + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwReplyWaitReceivePort( + IN HANDLE PortHandle, + OUT PULONG PortIdentifier OPTIONAL, + IN PPORT_MESSAGE ReplyMessage OPTIONAL, + OUT PPORT_MESSAGE Message + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwReplyWaitReceivePortEx( + IN HANDLE PortHandle, + OUT PULONG PortIdentifier OPTIONAL, + IN PPORT_MESSAGE ReplyMessage OPTIONAL, + OUT PPORT_MESSAGE Message, + IN PLARGE_INTEGER Timeout + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwReadRequestData( + IN HANDLE PortHandle, + IN PPORT_MESSAGE Message, + IN ULONG Index, + OUT PVOID Buffer, + IN ULONG BufferLength, + OUT PULONG ReturnLength OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwWriteRequestData( + IN HANDLE PortHandle, + IN PPORT_MESSAGE Message, + IN ULONG Index, + IN PVOID Buffer, + IN ULONG BufferLength, + OUT PULONG ReturnLength OPTIONAL + ); + +typedef enum _PORT_INFORMATION_CLASS { + PortBasicInformation +} PORT_INFORMATION_CLASS; + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryInformationPort( + IN HANDLE PortHandle, + IN PORT_INFORMATION_CLASS PortInformationClass, + OUT PVOID PortInformation, + IN ULONG PortInformationLength, + OUT PULONG ReturnLength OPTIONAL + ); + +typedef struct _PORT_BASIC_INFORMATION { +} PORT_BASIC_INFORMATION, *PPORT_BASIC_INFORMATION; + +NTSYSAPI +NTSTATUS +NTAPI +ZwImpersonateClientOfPort( + IN HANDLE PortHandle, + IN PPORT_MESSAGE Message + ); + +#define FILE_ANY_ACCESS 0 +#define FILE_SPECIAL_ACCESS (FILE_ANY_ACCESS) +#define FILE_READ_ACCESS ( 0x0001 ) // file & pipe +#define FILE_WRITE_ACCESS ( 0x0002 ) // file & pipe + + + +// +// Define access rights to files and directories +// + +// +// The FILE_READ_DATA and FILE_WRITE_DATA constants are also defined in +// devioctl.h as FILE_READ_ACCESS and FILE_WRITE_ACCESS. The values for these +// constants *MUST* always be in sync. +// The values are redefined in devioctl.h because they must be available to +// both DOS and NT. +// + +#define FILE_READ_DATA ( 0x0001 ) // file & pipe +#define FILE_LIST_DIRECTORY ( 0x0001 ) // directory + +#define FILE_WRITE_DATA ( 0x0002 ) // file & pipe +#define FILE_ADD_FILE ( 0x0002 ) // directory + +#define FILE_APPEND_DATA ( 0x0004 ) // file +#define FILE_ADD_SUBDIRECTORY ( 0x0004 ) // directory +#define FILE_CREATE_PIPE_INSTANCE ( 0x0004 ) // named pipe + + +#define FILE_READ_EA ( 0x0008 ) // file & directory + +#define FILE_WRITE_EA ( 0x0010 ) // file & directory + +#define FILE_EXECUTE ( 0x0020 ) // file +#define FILE_TRAVERSE ( 0x0020 ) // directory + +#define FILE_DELETE_CHILD ( 0x0040 ) // directory + +#define FILE_READ_ATTRIBUTES ( 0x0080 ) // all + +#define FILE_WRITE_ATTRIBUTES ( 0x0100 ) // all + +#define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF) + +#define FILE_GENERIC_READ (STANDARD_RIGHTS_READ |\ + FILE_READ_DATA |\ + FILE_READ_ATTRIBUTES |\ + FILE_READ_EA |\ + SYNCHRONIZE) + + +#define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\ + FILE_WRITE_DATA |\ + FILE_WRITE_ATTRIBUTES |\ + FILE_WRITE_EA |\ + FILE_APPEND_DATA |\ + SYNCHRONIZE) + + +#define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\ + FILE_READ_ATTRIBUTES |\ + FILE_EXECUTE |\ + SYNCHRONIZE) + + + + +// +// Define share access rights to files and directories +// + +#define FILE_SHARE_READ 0x00000001 +#define FILE_SHARE_WRITE 0x00000002 +#define FILE_SHARE_DELETE 0x00000004 +#define FILE_SHARE_VALID_FLAGS 0x00000007 + +// +// Define the file attributes values +// +// Note: 0x00000008 is reserved for use for the old DOS VOLID (volume ID) +// and is therefore not considered valid in NT. +// +// Note: Note also that the order of these flags is set to allow both the +// FAT and the Pinball File Systems to directly set the attributes +// flags in attributes words without having to pick each flag out +// individually. The order of these flags should not be changed! +// + +#define FILE_ATTRIBUTE_READONLY 0x00000001 +#define FILE_ATTRIBUTE_HIDDEN 0x00000002 +#define FILE_ATTRIBUTE_SYSTEM 0x00000004 +//OLD DOS VOLID 0x00000008 + +#define FILE_ATTRIBUTE_DIRECTORY 0x00000010 +#define FILE_ATTRIBUTE_ARCHIVE 0x00000020 +#define FILE_ATTRIBUTE_DEVICE 0x00000040 +#define FILE_ATTRIBUTE_NORMAL 0x00000080 + +#define FILE_ATTRIBUTE_TEMPORARY 0x00000100 +#define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200 +#define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400 +#define FILE_ATTRIBUTE_COMPRESSED 0x00000800 + +#define FILE_ATTRIBUTE_OFFLINE 0x00001000 +#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000 +#define FILE_ATTRIBUTE_ENCRYPTED 0x00004000 + +#define FILE_ATTRIBUTE_VIRTUAL 0x00010000 + +#define FILE_ATTRIBUTE_VALID_FLAGS 0x00007fb7 +#define FILE_ATTRIBUTE_VALID_SET_FLAGS 0x000031a7 + +// +// Define the create disposition values +// + +#define FILE_SUPERSEDE 0x00000000 +#define FILE_OPEN 0x00000001 +#define FILE_CREATE 0x00000002 +#define FILE_OPEN_IF 0x00000003 +#define FILE_OVERWRITE 0x00000004 +#define FILE_OVERWRITE_IF 0x00000005 +#define FILE_MAXIMUM_DISPOSITION 0x00000005 + +// +// Define the create/open option flags +// + +#define FILE_DIRECTORY_FILE 0x00000001 +#define FILE_WRITE_THROUGH 0x00000002 +#define FILE_SEQUENTIAL_ONLY 0x00000004 +#define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008 + +#define FILE_SYNCHRONOUS_IO_ALERT 0x00000010 +#define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020 +#define FILE_NON_DIRECTORY_FILE 0x00000040 +#define FILE_CREATE_TREE_CONNECTION 0x00000080 + +#define FILE_COMPLETE_IF_OPLOCKED 0x00000100 +#define FILE_NO_EA_KNOWLEDGE 0x00000200 +#define FILE_OPEN_REMOTE_INSTANCE 0x00000400 +#define FILE_RANDOM_ACCESS 0x00000800 + +#define FILE_DELETE_ON_CLOSE 0x00001000 +#define FILE_OPEN_BY_FILE_ID 0x00002000 +#define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000 +#define FILE_NO_COMPRESSION 0x00008000 + +#if (NTDDI_VERSION >= NTDDI_WIN7) +#define FILE_OPEN_REQUIRING_OPLOCK 0x00010000 +#define FILE_DISALLOW_EXCLUSIVE 0x00020000 +#endif /* NTDDI_VERSION >= NTDDI_WIN7 */ + +#define FILE_RESERVE_OPFILTER 0x00100000 +#define FILE_OPEN_REPARSE_POINT 0x00200000 +#define FILE_OPEN_NO_RECALL 0x00400000 +#define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000 + + +#define FILE_VALID_OPTION_FLAGS 0x00ffffff +#define FILE_VALID_PIPE_OPTION_FLAGS 0x00000032 +#define FILE_VALID_MAILSLOT_OPTION_FLAGS 0x00000032 +#define FILE_VALID_SET_FLAGS 0x00000036 + +// +// Define the I/O status information return values for NtCreateFile/NtOpenFile +// + +#define FILE_SUPERSEDED 0x00000000 +#define FILE_OPENED 0x00000001 +#define FILE_CREATED 0x00000002 +#define FILE_OVERWRITTEN 0x00000003 +#define FILE_EXISTS 0x00000004 +#define FILE_DOES_NOT_EXIST 0x00000005 + +// +// Define special ByteOffset parameters for read and write operations +// + +#define FILE_WRITE_TO_END_OF_FILE 0xffffffff +#define FILE_USE_FILE_POINTER_POSITION 0xfffffffe + +// +// Define alignment requirement values +// + +#define FILE_BYTE_ALIGNMENT 0x00000000 +#define FILE_WORD_ALIGNMENT 0x00000001 +#define FILE_LONG_ALIGNMENT 0x00000003 +#define FILE_QUAD_ALIGNMENT 0x00000007 +#define FILE_OCTA_ALIGNMENT 0x0000000f +#define FILE_32_BYTE_ALIGNMENT 0x0000001f +#define FILE_64_BYTE_ALIGNMENT 0x0000003f +#define FILE_128_BYTE_ALIGNMENT 0x0000007f +#define FILE_256_BYTE_ALIGNMENT 0x000000ff +#define FILE_512_BYTE_ALIGNMENT 0x000001ff + +// +// Define the maximum length of a filename string +// + +#define MAXIMUM_FILENAME_LENGTH 256 + +// +// Define the various device characteristics flags +// + +#define FILE_REMOVABLE_MEDIA 0x00000001 +#define FILE_READ_ONLY_DEVICE 0x00000002 +#define FILE_FLOPPY_DISKETTE 0x00000004 +#define FILE_WRITE_ONCE_MEDIA 0x00000008 +#define FILE_REMOTE_DEVICE 0x00000010 +#define FILE_DEVICE_IS_MOUNTED 0x00000020 +#define FILE_VIRTUAL_VOLUME 0x00000040 +#define FILE_AUTOGENERATED_DEVICE_NAME 0x00000080 +#define FILE_DEVICE_SECURE_OPEN 0x00000100 +#define FILE_CHARACTERISTIC_PNP_DEVICE 0x00000800 +#define FILE_CHARACTERISTIC_TS_DEVICE 0x00001000 +#define FILE_CHARACTERISTIC_WEBDAV_DEVICE 0x00002000 + + +NTSYSAPI +NTSTATUS +NTAPI +ZwCreateFile( + OUT PHANDLE FileHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PLARGE_INTEGER AllocationSize OPTIONAL, + IN ULONG FileAttributes, + IN ULONG ShareAccess, + IN ULONG CreateDisposition, + IN ULONG CreateOptions, + IN PVOID EaBuffer OPTIONAL, + IN ULONG EaLength + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenFile( + OUT PHANDLE FileHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN ULONG ShareAccess, + IN ULONG OpenOptions + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDeleteFile( + IN POBJECT_ATTRIBUTES ObjectAttributes + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwFlushBuffersFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwCancelIoFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock + ); + +typedef +VOID +(NTAPI *PIO_APC_ROUTINE) ( + __in PVOID ApcContext, + __in PIO_STATUS_BLOCK IoStatusBlock, + __in ULONG Reserved + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwReadFile( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID Buffer, + IN ULONG Length, + IN PLARGE_INTEGER ByteOffset OPTIONAL, + IN PULONG Key OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwWriteFile( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PVOID Buffer, + IN ULONG Length, + IN PLARGE_INTEGER ByteOffset OPTIONAL, + IN PULONG Key OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwReadFileScatter( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PFILE_SEGMENT_ELEMENT Buffer, + IN ULONG Length, + IN PLARGE_INTEGER ByteOffset OPTIONAL, + IN PULONG Key OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwWriteFileGather( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PFILE_SEGMENT_ELEMENT Buffer, + IN ULONG Length, + IN PLARGE_INTEGER ByteOffset OPTIONAL, + IN PULONG Key OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwLockFile( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PULARGE_INTEGER LockOffset, + IN PULARGE_INTEGER LockLength, + IN ULONG Key, + IN BOOL FailImmediately, + IN BOOL ExclusiveLock + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwUnlockFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PULARGE_INTEGER LockOffset, + IN PULARGE_INTEGER LockLength, + IN ULONG Key + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDeviceIoControlFile( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN ULONG IoControlCode, + IN PVOID InputBuffer OPTIONAL, + IN ULONG InputBufferLength, + OUT PVOID OutputBuffer OPTIONAL, + IN ULONG OutputBufferLength + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwFsControlFile( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN ULONG FsControlCode, + IN PVOID InputBuffer OPTIONAL, + IN ULONG InputBufferLength, + OUT PVOID OutputBuffer OPTIONAL, + IN ULONG OutputBufferLength + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwNotifyChangeDirectoryFile( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PFILE_NOTIFY_INFORMATION Buffer, + IN ULONG BufferLength, + IN ULONG NotifyFilter, + IN BOOL WatchSubtree + ); + +typedef struct _FILE_BASIC_INFORMATION { + LARGE_INTEGER CreationTime; + LARGE_INTEGER LastAccessTime; + LARGE_INTEGER LastWriteTime; + LARGE_INTEGER ChangeTime; + ULONG FileAttributes; +} FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION; + +typedef struct _FILE_STANDARD_INFORMATION { + LARGE_INTEGER AllocationSize; + LARGE_INTEGER EndOfFile; + ULONG NumberOfLinks; + BOOL DeletePending; + BOOL Directory; +} FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION; + + +typedef struct _FILE_POSITION_INFORMATION { + LARGE_INTEGER CurrentByteOffset; +} FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION; + + +typedef struct _FILE_NETWORK_OPEN_INFORMATION { + LARGE_INTEGER CreationTime; + LARGE_INTEGER LastAccessTime; + LARGE_INTEGER LastWriteTime; + LARGE_INTEGER ChangeTime; + LARGE_INTEGER AllocationSize; + LARGE_INTEGER EndOfFile; + ULONG FileAttributes; +} FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION; + +typedef struct _FILE_GET_EA_INFORMATION { + ULONG NextEntryOffset; + UCHAR EaNameLength; + CHAR EaName[1]; +} FILE_GET_EA_INFORMATION, *PFILE_GET_EA_INFORMATION; + +typedef struct _FILE_FULL_EA_INFORMATION { + ULONG NextEntryOffset; + UCHAR Flags; + UCHAR EaNameLength; + USHORT EaValueLength; + CHAR EaName[1]; +} FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION; + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryEaFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PFILE_FULL_EA_INFORMATION Buffer, + IN ULONG BufferLength, + IN BOOL ReturnSingleEntry, + IN PFILE_GET_EA_INFORMATION EaList OPTIONAL, + IN ULONG EaListLength, + IN PULONG EaIndex OPTIONAL, + IN BOOL RestartScan + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetEaFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PFILE_FULL_EA_INFORMATION Buffer, + IN ULONG BufferLength + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwCreateNamedPipeFile( + OUT PHANDLE FileHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN ULONG ShareAccess, + IN ULONG CreateDisposition, + IN ULONG CreateOptions, + IN BOOL TypeMessage, + IN BOOL ReadmodeMessage, + IN BOOL Nonblocking, + IN ULONG MaxInstances, + IN ULONG InBufferSize, + IN ULONG OutBufferSize, + IN PLARGE_INTEGER DefaultTimeout OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwCreateMailslotFile( + OUT PHANDLE FileHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN ULONG CreateOptions, + IN ULONG Unknown, + IN ULONG MaxMessageSize, + IN PLARGE_INTEGER ReadTimeout OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryVolumeInformationFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID VolumeInformation, + IN ULONG VolumeInformationLength, + IN FS_INFORMATION_CLASS VolumeInformationClass + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetVolumeInformationFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PVOID Buffer, + IN ULONG BufferLength, + IN FS_INFORMATION_CLASS VolumeInformationClass + ); + +typedef struct _FILE_FS_VOLUME_INFORMATION { + LARGE_INTEGER VolumeCreationTime; + ULONG VolumeSerialNumber; + ULONG VolumeLabelLength; + UCHAR Unknown; + WCHAR VolumeLabel[1]; +} FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION; + +typedef struct _FILE_FS_LABEL_INFORMATION { + ULONG VolumeLabelLength; + WCHAR VolumeLabel; +} FILE_FS_LABEL_INFORMATION, *PFILE_FS_LABEL_INFORMATION; + +typedef struct _FILE_FS_SIZE_INFORMATION { + LARGE_INTEGER TotalAllocationUnits; + LARGE_INTEGER AvailableAllocationUnits; + ULONG SectorsPerAllocationUnit; + ULONG BytesPerSector; +} FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION; + +typedef struct _FILE_FS_ATTRIBUTE_INFORMATION { + ULONG FileSystemFlags; + ULONG MaximumComponentNameLength; + ULONG FileSystemNameLength; + WCHAR FileSystemName[1]; +} FILE_FS_ATTRIBUTE_INFORMATION, *PFILE_FS_ATTRIBUTE_INFORMATION; + +typedef struct _FILE_FS_CONTROL_INFORMATION { + LARGE_INTEGER Reserved[3]; + LARGE_INTEGER DefaultQuotaThreshold; + LARGE_INTEGER DefaultQuotaLimit; + ULONG QuotaFlags; +} FILE_FS_CONTROL_INFORMATION, *PFILE_FS_CONTROL_INFORMATION; + +typedef struct _FILE_FS_FULL_SIZE_INFORMATION { + LARGE_INTEGER TotalQuotaAllocationUnits; + LARGE_INTEGER AvailableQuotaAllocationUnits; + LARGE_INTEGER AvailableAllocationUnits; + ULONG SectorsPerAllocationUnit; + ULONG BytesPerSector; +} FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION; + +typedef struct _FILE_FS_OBJECT_ID_INFORMATION { + UUID VolumeObjectId; + ULONG VolumeObjectIdExtendedInfo[12]; +} FILE_FS_OBJECT_ID_INFORMATION, *PFILE_FS_OBJECT_ID_INFORMATION; + +typedef struct _FILE_USER_QUOTA_INFORMATION { + ULONG NextEntryOffset; + ULONG SidLength; + LARGE_INTEGER ChangeTime; + LARGE_INTEGER QuotaUsed; + LARGE_INTEGER QuotaThreshold; + LARGE_INTEGER QuotaLimit; + SID Sid[1]; +} FILE_USER_QUOTA_INFORMATION, *PFILE_USER_QUOTA_INFORMATION; + +typedef struct _FILE_QUOTA_LIST_INFORMATION { + ULONG NextEntryOffset; + ULONG SidLength; + SID Sid[1]; +} FILE_QUOTA_LIST_INFORMATION, *PFILE_QUOTA_LIST_INFORMATION; + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryQuotaInformationFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PFILE_USER_QUOTA_INFORMATION Buffer, + IN ULONG BufferLength, + IN BOOL ReturnSingleEntry, + IN PFILE_QUOTA_LIST_INFORMATION QuotaList OPTIONAL, + IN ULONG QuotaListLength, + IN PSID ResumeSid OPTIONAL, + IN BOOL RestartScan + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetQuotaInformationFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PFILE_USER_QUOTA_INFORMATION Buffer, + IN ULONG BufferLength + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryAttributesFile( + IN POBJECT_ATTRIBUTES ObjectAttributes, + OUT PFILE_BASIC_INFORMATION FileInformation + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryFullAttributesFile( + IN POBJECT_ATTRIBUTES ObjectAttributes, + OUT PFILE_NETWORK_OPEN_INFORMATION FileInformation + ); + +typedef enum _FILE_INFORMATION_CLASS { + FileDirectoryInformation = 1, + FileFullDirectoryInformation, // 2 + FileBothDirectoryInformation, // 3 + FileBasicInformation, // 4 + FileStandardInformation, // 5 + FileInternalInformation, // 6 + FileEaInformation, // 7 + FileAccessInformation, // 8 + FileNameInformation, // 9 + FileRenameInformation, // 10 + FileLinkInformation, // 11 + FileNamesInformation, // 12 + FileDispositionInformation, // 13 + FilePositionInformation, // 14 + FileFullEaInformation, // 15 + FileModeInformation, // 16 + FileAlignmentInformation, // 17 + FileAllInformation, // 18 + FileAllocationInformation, // 19 + FileEndOfFileInformation, // 20 + FileAlternateNameInformation, // 21 + FileStreamInformation, // 22 + FilePipeInformation, // 23 + FilePipeLocalInformation, // 24 + FilePipeRemoteInformation, // 25 + FileMailslotQueryInformation, // 26 + FileMailslotSetInformation, // 27 + FileCompressionInformation, // 28 + FileObjectIdInformation, // 29 + FileCompletionInformation, // 30 + FileMoveClusterInformation, // 31 + FileQuotaInformation, // 32 + FileReparsePointInformation, // 33 + FileNetworkOpenInformation, // 34 + FileAttributeTagInformation, // 35 + FileTrackingInformation, // 36 + FileIdBothDirectoryInformation, // 37 + FileIdFullDirectoryInformation, // 38 + FileValidDataLengthInformation, // 39 + FileShortNameInformation, // 40 + FileIoCompletionNotificationInformation, // 41 + FileIoStatusBlockRangeInformation, // 42 + FileIoPriorityHintInformation, // 43 + FileSfioReserveInformation, // 44 + FileSfioVolumeInformation, // 45 + FileHardLinkInformation, // 46 + FileProcessIdsUsingFileInformation, // 47 + FileNormalizedNameInformation, // 48 + FileNetworkPhysicalNameInformation, // 49 + FileIdGlobalTxDirectoryInformation, // 50 + FileIsRemoteDeviceInformation, // 51 + FileAttributeCacheInformation, // 52 + FileNumaNodeInformation, // 53 + FileStandardLinkInformation, // 54 + FileRemoteProtocolInformation, // 55 + FileMaximumInformation +} FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS; + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryInformationFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID FileInformation, + IN ULONG FileInformationLength, + IN FILE_INFORMATION_CLASS FileInformationClass + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetInformationFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PVOID FileInformation, + IN ULONG FileInformationLength, + IN FILE_INFORMATION_CLASS FileInformationClass + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryDirectoryFile( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID FileInformation, + IN ULONG FileInformationLength, + IN FILE_INFORMATION_CLASS FileInformationClass, + IN BOOL ReturnSingleEntry, + IN PUNICODE_STRING FileName OPTIONAL, + IN BOOL RestartScan + ); + +typedef struct _FILE_DIRECTORY_INFORMATION { // Information Class 1 + ULONG NextEntryOffset; + ULONG Unknown; + LARGE_INTEGER CreationTime; + LARGE_INTEGER LastAccessTime; + LARGE_INTEGER LastWriteTime; + LARGE_INTEGER ChangeTime; + LARGE_INTEGER EndOfFile; + LARGE_INTEGER AllocationSize; + ULONG FileAttributes; + ULONG FileNameLength; + WCHAR FileName[1]; +} FILE_DIRECTORY_INFORMATION, *PFILE_DIRECTORY_INFORMATION; + +typedef struct _FILE_FULL_DIRECTORY_INFORMATION { // Information Class 2 + ULONG NextEntryOffset; + ULONG Unknown; + LARGE_INTEGER CreationTime; + LARGE_INTEGER LastAccessTime; + LARGE_INTEGER LastWriteTime; + LARGE_INTEGER ChangeTime; + LARGE_INTEGER EndOfFile; + LARGE_INTEGER AllocationSize; + ULONG FileAttributes; + ULONG FileNameLength; + ULONG EaInformationLength; + WCHAR FileName[1]; +} FILE_FULL_DIRECTORY_INFORMATION, *PFILE_FULL_DIRECTORY_INFORMATION; + +typedef struct _FILE_BOTH_DIRECTORY_INFORMATION { // Information Class 3 + ULONG NextEntryOffset; + ULONG Unknown; + LARGE_INTEGER CreationTime; + LARGE_INTEGER LastAccessTime; + LARGE_INTEGER LastWriteTime; + LARGE_INTEGER ChangeTime; + LARGE_INTEGER EndOfFile; + LARGE_INTEGER AllocationSize; + ULONG FileAttributes; + ULONG FileNameLength; + ULONG EaInformationLength; + UCHAR AlternateNameLength; + WCHAR AlternateName[12]; + WCHAR FileName[1]; +} FILE_BOTH_DIRECTORY_INFORMATION, *PFILE_BOTH_DIRECTORY_INFORMATION; + +typedef struct _FILE_INTERNAL_INFORMATION { // Information Class 6 + LARGE_INTEGER FileId; +} FILE_INTERNAL_INFORMATION, *PFILE_INTERNAL_INFORMATION; + +typedef struct _FILE_EA_INFORMATION { // Information Class 7 + ULONG EaInformationLength; +} FILE_EA_INFORMATION, *PFILE_EA_INFORMATION; + +typedef struct _FILE_ACCESS_INFORMATION { // Information Class 8 + ACCESS_MASK GrantedAccess; +} FILE_ACCESS_INFORMATION, *PFILE_ACCESS_INFORMATION; + +typedef struct _FILE_NAME_INFORMATION { // Information Classes 9 and 21 + ULONG FileNameLength; + WCHAR FileName[1]; +} FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION, + FILE_ALTERNATE_NAME_INFORMATION, *PFILE_ALTERNATE_NAME_INFORMATION; + +typedef struct _FILE_LINK_RENAME_INFORMATION { // Info Classes 10 and 11 + BOOL ReplaceIfExists; + HANDLE RootDirectory; + ULONG FileNameLength; + WCHAR FileName[1]; +} FILE_LINK_INFORMATION, *PFILE_LINK_INFORMATION, + FILE_RENAME_INFORMATION, *PFILE_RENAME_INFORMATION; + +typedef struct _FILE_NAMES_INFORMATION { // Information Class 12 + ULONG NextEntryOffset; + ULONG Unknown; + ULONG FileNameLength; + WCHAR FileName[1]; +} FILE_NAMES_INFORMATION, *PFILE_NAMES_INFORMATION; + +typedef struct _FILE_MODE_INFORMATION { // Information Class 16 + ULONG Mode; +} FILE_MODE_INFORMATION, *PFILE_MODE_INFORMATION; + +typedef struct _FILE_ALIGNMENT_INFORMATION { + ULONG AlignmentRequirement; +} FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION; + +typedef struct _FILE_ALL_INFORMATION { // Information Class 18 + FILE_BASIC_INFORMATION BasicInformation; + FILE_STANDARD_INFORMATION StandardInformation; + FILE_INTERNAL_INFORMATION InternalInformation; + FILE_EA_INFORMATION EaInformation; + FILE_ACCESS_INFORMATION AccessInformation; + FILE_POSITION_INFORMATION PositionInformation; + FILE_MODE_INFORMATION ModeInformation; + FILE_ALIGNMENT_INFORMATION AlignmentInformation; + FILE_NAME_INFORMATION NameInformation; +} FILE_ALL_INFORMATION, *PFILE_ALL_INFORMATION; + +typedef struct _FILE_ALLOCATION_INFORMATION { // Information Class 19 + LARGE_INTEGER AllocationSize; +} FILE_ALLOCATION_INFORMATION, *PFILE_ALLOCATION_INFORMATION; + +typedef struct _FILE_STREAM_INFORMATION { // Information Class 22 + ULONG NextEntryOffset; + ULONG StreamNameLength; + LARGE_INTEGER EndOfStream; + LARGE_INTEGER AllocationSize; + WCHAR StreamName[1]; +} FILE_STREAM_INFORMATION, *PFILE_STREAM_INFORMATION; + +typedef struct _FILE_PIPE_INFORMATION { // Information Class 23 + ULONG ReadModeMessage; + ULONG WaitModeBlocking; +} FILE_PIPE_INFORMATION, *PFILE_PIPE_INFORMATION; + +typedef struct _FILE_PIPE_LOCAL_INFORMATION { // Information Class 24 + ULONG MessageType; + ULONG Unknown1; + ULONG MaxInstances; + ULONG CurInstances; + ULONG InBufferSize; + ULONG Unknown2; + ULONG OutBufferSize; + ULONG Unknown3[2]; + ULONG ServerEnd; +} FILE_PIPE_LOCAL_INFORMATION, *PFILE_PIPE_LOCAL_INFORMATION; + +typedef struct _FILE_PIPE_REMOTE_INFORMATION { // Information Class 25 + LARGE_INTEGER CollectDataTimeout; + ULONG MaxCollectionCount; +} FILE_PIPE_REMOTE_INFORMATION, *PFILE_PIPE_REMOTE_INFORMATION; + +typedef struct _FILE_MAILSLOT_QUERY_INFORMATION { // Information Class 26 + ULONG MaxMessageSize; + ULONG Unknown; + ULONG NextSize; + ULONG MessageCount; + LARGE_INTEGER ReadTimeout; +} FILE_MAILSLOT_QUERY_INFORMATION, *PFILE_MAILSLOT_QUERY_INFORMATION; + +typedef struct _FILE_MAILSLOT_SET_INFORMATION { // Information Class 27 + LARGE_INTEGER ReadTimeout; +} FILE_MAILSLOT_SET_INFORMATION, *PFILE_MAILSLOT_SET_INFORMATION; + +typedef struct _FILE_COMPRESSION_INFORMATION { // Information Class 28 + LARGE_INTEGER CompressedSize; + USHORT CompressionFormat; + UCHAR CompressionUnitShift; + UCHAR Unknown; + UCHAR ClusterSizeShift; +} FILE_COMPRESSION_INFORMATION, *PFILE_COMPRESSION_INFORMATION; + +typedef struct _FILE_COMPLETION_INFORMATION { // Information Class 30 + HANDLE IoCompletionHandle; + ULONG CompletionKey; +} FILE_COMPLETION_INFORMATION, *PFILE_COMPLETION_INFORMATION; + +NTSYSAPI +NTSTATUS +NTAPI +ZwCreateKey( + OUT PHANDLE KeyHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN ULONG TitleIndex, + IN PUNICODE_STRING Class OPTIONAL, + IN ULONG CreateOptions, + OUT PULONG Disposition OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenKey( + OUT PHANDLE KeyHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDeleteKey( + IN HANDLE KeyHandle + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwFlushKey( + IN HANDLE KeyHandle + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSaveKey( + IN HANDLE KeyHandle, + IN HANDLE FileHandle + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSaveMergedKeys( + IN HANDLE KeyHandle1, + IN HANDLE KeyHandle2, + IN HANDLE FileHandle + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwRestoreKey( + IN HANDLE KeyHandle, + IN HANDLE FileHandle, + IN ULONG Flags + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwLoadKey( + IN POBJECT_ATTRIBUTES KeyObjectAttributes, + IN POBJECT_ATTRIBUTES FileObjectAttributes + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwLoadKey2( + IN POBJECT_ATTRIBUTES KeyObjectAttributes, + IN POBJECT_ATTRIBUTES FileObjectAttributes, + IN ULONG Flags + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwUnloadKey( + IN POBJECT_ATTRIBUTES KeyObjectAttributes + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwReplaceKey( + IN POBJECT_ATTRIBUTES NewFileObjectAttributes, + IN HANDLE KeyHandle, + IN POBJECT_ATTRIBUTES OldFileObjectAttributes + ); + +typedef struct _KEY_SET_VIRTUALIZATION_INFORMATION { + ULONG VirtualTarget : 1; // Tells if the key is a virtual target key. + ULONG VirtualStore : 1; // Tells if the key is a virtual store key. + ULONG VirtualSource : 1; // Tells if the key has been virtualized at least one (virtual hint) + ULONG Reserved : 29; +} KEY_SET_VIRTUALIZATION_INFORMATION, *PKEY_SET_VIRTUALIZATION_INFORMATION; + +typedef enum _KEY_SET_INFORMATION_CLASS { + KeyWriteTimeInformation, + KeyWow64FlagsInformation, + KeyControlFlagsInformation, + KeySetVirtualizationInformation, + KeySetDebugInformation, + KeySetHandleTagsInformation, + MaxKeySetInfoClass // MaxKeySetInfoClass should always be the last enum +} KEY_SET_INFORMATION_CLASS; + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetInformationKey( + IN HANDLE KeyHandle, + IN KEY_SET_INFORMATION_CLASS KeyInformationClass, + IN PVOID KeyInformation, + IN ULONG KeyInformationLength + ); + +typedef enum _KEY_INFORMATION_CLASS { + KeyBasicInformation, + KeyNodeInformation, + KeyFullInformation, + KeyNameInformation, + KeyCachedInformation, + KeyFlagsInformation, + KeyVirtualizationInformation, + KeyHandleTagsInformation, + MaxKeyInfoClass // MaxKeyInfoClass should always be the last enum +} KEY_INFORMATION_CLASS; + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryKey( + IN HANDLE KeyHandle, + IN KEY_INFORMATION_CLASS KeyInformationClass, + OUT PVOID KeyInformation, + IN ULONG KeyInformationLength, + OUT PULONG ResultLength + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwEnumerateKey( + IN HANDLE KeyHandle, + IN ULONG Index, + IN KEY_INFORMATION_CLASS KeyInformationClass, + OUT PVOID KeyInformation, + IN ULONG KeyInformationLength, + OUT PULONG ResultLength + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwNotifyChangeKey( + IN HANDLE KeyHandle, + IN HANDLE EventHandle OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN ULONG NotifyFilter, + IN BOOL WatchSubtree, + IN PVOID Buffer, + IN ULONG BufferLength, + IN BOOL Asynchronous + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwNotifyChangeMultipleKeys ( + IN HANDLE KeyHandle, + IN ULONG Flags, + IN POBJECT_ATTRIBUTES KeyObjectAttributes, + IN HANDLE EventHandle OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN ULONG NotifyFilter, + IN BOOL WatchSubtree, + IN PVOID Buffer, + IN ULONG BufferLength, + IN BOOL Asynchronous + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDeleteValueKey( + IN HANDLE KeyHandle, + IN PUNICODE_STRING ValueName + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetValueKey( + IN HANDLE KeyHandle, + IN PUNICODE_STRING ValueName, + IN ULONG TitleIndex, + IN ULONG Type, + IN PVOID Data, + IN ULONG DataSize + ); + +typedef enum _KEY_VALUE_INFORMATION_CLASS { + KeyValueBasicInformation, + KeyValueFullInformation, + KeyValuePartialInformation, + KeyValueFullInformationAlign64, + KeyValuePartialInformationAlign64, + MaxKeyValueInfoClass // MaxKeyValueInfoClass should always be the last enum +} KEY_VALUE_INFORMATION_CLASS; + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryValueKey( + IN HANDLE KeyHandle, + IN PUNICODE_STRING ValueName, + IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, + OUT PVOID KeyValueInformation, + IN ULONG KeyValueInformationLength, + OUT PULONG ResultLength + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwEnumerateValueKey( + IN HANDLE KeyHandle, + IN ULONG Index, + IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, + OUT PVOID KeyValueInformation, + IN ULONG KeyValueInformationLength, + OUT PULONG ResultLength + ); + +typedef struct _KEY_VALUE_ENTRY { + PUNICODE_STRING ValueName; + ULONG DataLength; + ULONG DataOffset; + ULONG Type; +} KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY; + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryMultipleValueKey( + IN HANDLE KeyHandle, + IN OUT PKEY_VALUE_ENTRY ValueList, + IN ULONG NumberOfValues, + OUT PVOID Buffer, + IN OUT PULONG Length, + OUT PULONG ReturnLength + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwPrivilegeCheck( + IN HANDLE TokenHandle, + IN PPRIVILEGE_SET RequiredPrivileges, + OUT PBOOL Result + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwPrivilegeObjectAuditAlarm( + IN PUNICODE_STRING SubsystemName, + IN PVOID HandleId, + IN HANDLE TokenHandle, + IN ACCESS_MASK DesiredAccess, + IN PPRIVILEGE_SET Privileges, + IN BOOL AccessGranted + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwPrivilegedServiceAuditAlarm( + IN PUNICODE_STRING SubsystemName, + IN PUNICODE_STRING ServiceName, + IN HANDLE TokenHandle, + IN PPRIVILEGE_SET Privileges, + IN BOOL AccessGranted + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwAccessCheck( + IN PSECURITY_DESCRIPTOR SecurityDescriptor, + IN HANDLE TokenHandle, + IN ACCESS_MASK DesiredAccess, + IN PGENERIC_MAPPING GenericMapping, + IN PPRIVILEGE_SET PrivilegeSet, + IN PULONG PrivilegeSetLength, + OUT PACCESS_MASK GrantedAccess, + OUT PBOOL AccessStatus + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwAccessCheckAndAuditAlarm( + IN PUNICODE_STRING SubsystemName, + IN PVOID HandleId, + IN PUNICODE_STRING ObjectTypeName, + IN PUNICODE_STRING ObjectName, + IN PSECURITY_DESCRIPTOR SecurityDescriptor, + IN ACCESS_MASK DesiredAccess, + IN PGENERIC_MAPPING GenericMapping, + IN BOOL ObjectCreation, + OUT PACCESS_MASK GrantedAccess, + OUT PBOOL AccessStatus, + OUT PBOOL GenerateOnClose + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwAccessCheckByType( + IN PSECURITY_DESCRIPTOR SecurityDescriptor, + IN PSID PrincipalSelfSid, + IN HANDLE TokenHandle, + IN ULONG DesiredAccess, + IN POBJECT_TYPE_LIST ObjectTypeList, + IN ULONG ObjectTypeListLength, + IN PGENERIC_MAPPING GenericMapping, + IN PPRIVILEGE_SET PrivilegeSet, + IN PULONG PrivilegeSetLength, + OUT PACCESS_MASK GrantedAccess, + OUT PULONG AccessStatus + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwAccessCheckByTypeAndAuditAlarm( + IN PUNICODE_STRING SubsystemName, + IN PVOID HandleId, + IN PUNICODE_STRING ObjectTypeName, + IN PUNICODE_STRING ObjectName, + IN PSECURITY_DESCRIPTOR SecurityDescriptor, + IN PSID PrincipalSelfSid, + IN ACCESS_MASK DesiredAccess, + IN AUDIT_EVENT_TYPE AuditType, + IN ULONG Flags, + IN POBJECT_TYPE_LIST ObjectTypeList, + IN ULONG ObjectTypeListLength, + IN PGENERIC_MAPPING GenericMapping, + IN BOOL ObjectCreation, + OUT PACCESS_MASK GrantedAccess, + OUT PULONG AccessStatus, + OUT PBOOL GenerateOnClose + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwAccessCheckByTypeResultList( + IN PSECURITY_DESCRIPTOR SecurityDescriptor, + IN PSID PrincipalSelfSid, + IN HANDLE TokenHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_TYPE_LIST ObjectTypeList, + IN ULONG ObjectTypeListLength, + IN PGENERIC_MAPPING GenericMapping, + IN PPRIVILEGE_SET PrivilegeSet, + IN PULONG PrivilegeSetLength, + OUT PACCESS_MASK GrantedAccessList, + OUT PULONG AccessStatusList + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwAccessCheckByTypeResultListAndAuditAlarm( + IN PUNICODE_STRING SubsystemName, + IN PVOID HandleId, + IN PUNICODE_STRING ObjectTypeName, + IN PUNICODE_STRING ObjectName, + IN PSECURITY_DESCRIPTOR SecurityDescriptor, + IN PSID PrincipalSelfSid, + IN ACCESS_MASK DesiredAccess, + IN AUDIT_EVENT_TYPE AuditType, + IN ULONG Flags, + IN POBJECT_TYPE_LIST ObjectTypeList, + IN ULONG ObjectTypeListLength, + IN PGENERIC_MAPPING GenericMapping, + IN BOOL ObjectCreation, + OUT PACCESS_MASK GrantedAccessList, + OUT PULONG AccessStatusList, + OUT PULONG GenerateOnClose + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwAccessCheckByTypeResultListAndAuditAlarmByHandle( + IN PUNICODE_STRING SubsystemName, + IN PVOID HandleId, + IN HANDLE TokenHandle, + IN PUNICODE_STRING ObjectTypeName, + IN PUNICODE_STRING ObjectName, + IN PSECURITY_DESCRIPTOR SecurityDescriptor, + IN PSID PrincipalSelfSid, + IN ACCESS_MASK DesiredAccess, + IN AUDIT_EVENT_TYPE AuditType, + IN ULONG Flags, + IN POBJECT_TYPE_LIST ObjectTypeList, + IN ULONG ObjectTypeListLength, + IN PGENERIC_MAPPING GenericMapping, + IN BOOL ObjectCreation, + OUT PACCESS_MASK GrantedAccessList, + OUT PULONG AccessStatusList, + OUT PULONG GenerateOnClose + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenObjectAuditAlarm( + IN PUNICODE_STRING SubsystemName, + IN PVOID *HandleId, + IN PUNICODE_STRING ObjectTypeName, + IN PUNICODE_STRING ObjectName, + IN PSECURITY_DESCRIPTOR SecurityDescriptor, + IN HANDLE TokenHandle, + IN ACCESS_MASK DesiredAccess, + IN ACCESS_MASK GrantedAccess, + IN PPRIVILEGE_SET Privileges OPTIONAL, + IN BOOL ObjectCreation, + IN BOOL AccessGranted, + OUT PBOOL GenerateOnClose + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwCloseObjectAuditAlarm( + IN PUNICODE_STRING SubsystemName, + IN PVOID HandleId, + IN BOOL GenerateOnClose + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDeleteObjectAuditAlarm( + IN PUNICODE_STRING SubsystemName, + IN PVOID HandleId, + IN BOOL GenerateOnClose + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwRequestWakeupLatency( + IN LATENCY_TIME Latency + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwRequestDeviceWakeup( + IN HANDLE DeviceHandle + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwCancelDeviceWakeupRequest( + IN HANDLE DeviceHandle + ); + +NTSYSAPI +BOOL +NTAPI +ZwIsSystemResumeAutomatic( + VOID + ); + +typedef EXECUTION_STATE *PEXECUTION_STATE; + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetThreadExecutionState( + IN EXECUTION_STATE ExecutionState, + OUT PEXECUTION_STATE PreviousExecutionState + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwGetDevicePowerState( + IN HANDLE DeviceHandle, + OUT PDEVICE_POWER_STATE DevicePowerState + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetSystemPowerState( + IN POWER_ACTION SystemAction, + IN SYSTEM_POWER_STATE MinSystemState, + IN ULONG Flags + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwInitiatePowerAction( + IN POWER_ACTION SystemAction, + IN SYSTEM_POWER_STATE MinSystemState, + IN ULONG Flags, + IN BOOL Asynchronous + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwPowerInformation( + IN POWER_INFORMATION_LEVEL PowerInformationLevel, + IN PVOID InputBuffer OPTIONAL, + IN ULONG InputBufferLength, + OUT PVOID OutputBuffer OPTIONAL, + IN ULONG OutputBufferLength + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwGetPlugPlayEvent( + IN ULONG Reserved1, + IN ULONG Reserved2, + OUT PVOID Buffer, + IN ULONG BufferLength + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwRaiseException( + IN PEXCEPTION_RECORD ExceptionRecord, + IN PCONTEXT Context, + IN BOOL SearchFrames + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwContinue( + IN PCONTEXT Context, + IN BOOL TestAlert + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwW32Call( + IN ULONG RoutineIndex, + IN PVOID Argument, + IN ULONG ArgumentLength, + OUT PVOID *Result OPTIONAL, + OUT PULONG ResultLength OPTIONAL + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwCallbackReturn( + IN PVOID Result OPTIONAL, + IN ULONG ResultLength, + IN NTSTATUS Status + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetLowWaitHighThread( + VOID + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetHighWaitLowThread( + VOID + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwLoadDriver( + IN PUNICODE_STRING DriverServiceName + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwUnloadDriver( + IN PUNICODE_STRING DriverServiceName + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwFlushInstructionCache( + IN HANDLE ProcessHandle, + IN PVOID BaseAddress OPTIONAL, + IN ULONG FlushSize + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwFlushWriteBuffer( + VOID + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryDefaultLocale( + IN BOOL ThreadOrSystem, + OUT PLCID Locale + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetDefaultLocale( + IN BOOL ThreadOrSystem, + IN LCID Locale + ); + +typedef LANGID *PLANGID; + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryDefaultUILanguage( + OUT PLANGID LanguageId + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetDefaultUILanguage( + IN LANGID LanguageId + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryInstallUILanguage( + OUT PLANGID LanguageId + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwAllocateLocallyUniqueId( + OUT PLUID Luid + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwAllocateUuids( + OUT PLARGE_INTEGER UuidLastTimeAllocated, + OUT PULONG UuidDeltaTime, + OUT PULONG UuidSequenceNumber, + OUT PUCHAR UuidSeed + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetUuidSeed( + IN PUCHAR UuidSeed + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwRaiseHardError( + IN NTSTATUS Status, + IN ULONG NumberOfArguments, + IN ULONG StringArgumentsMask, + IN PULONG Arguments, + IN ULONG MessageBoxType, + OUT PULONG MessageBoxResult + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetDefaultHardErrorPort( + IN HANDLE PortHandle + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDisplayString( + IN PUNICODE_STRING String + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwCreatePagingFile( + IN PUNICODE_STRING FileName, + IN PULARGE_INTEGER InitialSize, + IN PULARGE_INTEGER MaximumSize, + IN ULONG Reserved + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwAddAtom( + IN PWSTR String, + IN ULONG StringLength, + OUT PUSHORT Atom + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwFindAtom( + IN PWSTR String, + IN ULONG StringLength, + OUT PUSHORT Atom + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDeleteAtom( + IN USHORT Atom + ); + +typedef enum _ATOM_INFORMATION_CLASS { + AtomBasicInformation, + AtomListInformation +} ATOM_INFORMATION_CLASS; + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryInformationAtom( + IN USHORT Atom, + IN ATOM_INFORMATION_CLASS AtomInformationClass, + OUT PVOID AtomInformation, + IN ULONG AtomInformationLength, + OUT PULONG ReturnLength OPTIONAL + ); + +typedef struct _ATOM_BASIC_INFORMATION { + USHORT ReferenceCount; + USHORT Pinned; + USHORT NameLength; + WCHAR Name[1]; +} ATOM_BASIC_INFORMATION, *PATOM_BASIC_INFORMATION; + +typedef struct _ATOM_LIST_INFORMATION { + ULONG NumberOfAtoms; + ATOM Atoms[1]; +} ATOM_LIST_INFORMATION, *PATOM_LIST_INFORMATION; + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetLdtEntries( + IN ULONG Selector1, + IN LDT_ENTRY LdtEntry1, + IN ULONG Selector2, + IN LDT_ENTRY LdtEntry2 + ); + +NTSYSAPI +NTSTATUS +NTAPI +ZwVdmControl( + IN ULONG ControlCode, + IN PVOID ControlData + ); + +NTSYSAPI +NTSTATUS +NTAPI +RtlAnsiStringToUnicodeString( + PUNICODE_STRING DestinationString, + PCANSI_STRING SourceString, + BOOL AllocateDestinationString + ); + +NTSYSAPI +NTSTATUS +NTAPI +RtlUnicodeStringToAnsiString( + PANSI_STRING DestinationString, + PUNICODE_STRING SourceString, + BOOL AllocateDestinationString + ); + +NTSYSAPI +NTSTATUS +NTAPI +RtlUnicodeStringToOemString( + POEM_STRING DestinationString, + PUNICODE_STRING SourceString, + BOOL AllocateDestinationString + ); + + } +} diff --git a/Ext2Mgr/resource.h b/Ext2Mgr/resource.h index 6d62363..9f5dab9 100644 --- a/Ext2Mgr/resource.h +++ b/Ext2Mgr/resource.h @@ -1,182 +1,182 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by Ext2Mgr.rc -// -#define MANIFEST_RESOURCE_ID 1 -#define ID_RELOAD_DL 3 -#define IDM_ABOUTBOX 0x0010 -#ifndef RT_MANIFEST -#define RT_MANIFEST 24 -#endif -#define IDM_CLOSE_SPLASH 0x0020 -#define IDD_ABOUTBOX 100 -#define IDS_ABOUTBOX 101 -#define IDD_EXT2MGR_DIALOG 102 -#define ID_INDICATOR_MESSAGE 103 -#define ID_INDICATOR_TIME 104 -#define ID_INDICATOR_EXTRA 105 -#define IDR_MAINFRAME 128 -#define IDR_TRAY 133 -#define IDI_FLOPPY 134 -#define IDI_CDROM 135 -#define IDI_DISK 136 -#define IDI_DVD 137 -#define IDI_DYNAMIC 138 -#define IDR_MENU 139 -#define IDB_ABOUT_SCREEN 151 -#define IDR_STANDARDBAR 162 -#define IDB_ABOUT_SMALL 163 -#define IDI_BIG_MAINFRAME 164 -#define IDB_LINE_SEP 166 -#define IDD_SERVICE_MANAGE 167 -#define IDD_FORMAT 169 -#define IDD_EXT2_ATTR 170 -#define IDD_CHANGE_MOUNTPINT 171 -#define IDD_NEW_MOUNTPOINT 172 -#define IDD_PROPERTY_DIALOG 173 -#define IDD_DONATE_DIALOG 174 -#define IDB_SMALL_PENGUIN 184 -#define IDB_BIG_PENGUIN 185 -#define IDD_PERFSTAT_DIALOG 186 -#define IDD_PARTITION_TYPE 187 -#define IDD_REMOVE_DEADLETTER 188 -#define IDR_AKEY_EXT2MGR 190 -#define IDR_RCDAT_SRV 191 -#define IDC_VOLUME_LIST 1001 -#define IDC_AUTHOR 1002 -#define IDC_ABOUT_SHOW 1003 -#define IDC_PROGRAM 1004 -#define IDC_EXT2FSD 1005 -#define IDC_DISK_VIEW 1006 -#define IDC_DISK_LIST 1007 -#define IDC_READ_ONLY 1013 -#define IDC_EXT3_WRITABLE 1014 -#define IDC_COMBO_STARTUP 1015 -#define IDC_COMBO_CODEPAGE 1016 -#define IDC_COMBO_DRVLETTER 1017 -#define IDC_COMBO_AUTOMP 1018 -#define IDC_EXT3_AUTOMOUNT 1018 -#define IDC_FORMAT_PROGRESS 1019 -#define IDC_COMBO_FS 1020 -#define IDC_FORMAT_TITLE 1021 -#define IDC_EDIT_LABEL 1022 -#define IDC_COMBO_CLUSTER 1023 -#define IDC_QUICK_FORMAT 1024 -#define IDC_QUICK_COMPRESS 1025 -#define IDC_DRV_LETTER_LIST 1026 -#define IDC_DRVLETTERS_LIST 1028 -#define IDC_PROPERTY_DEVICE 1029 -#define IDC_PROPERTY_SDEV 1030 -#define IDC_VENDOR_ID 1031 -#define IDC_PRODUCT_ID 1032 -#define IDC_SERIAL_NUMBER 1033 -#define IDC_BUS_TYPE 1034 -#define IDC_DEVICE_TYPE 1035 -#define IDC_MEDIA_TYPE 1036 -#define IDC_TOTAL_SIZE 1037 -#define IDC_SDEV_CHANGE_MP 1038 -#define IDC_MOUNT_POINTS 1039 -#define IDC_VIA_SOURCEFORGE 1040 -#define IDC_SDEV_SIZE 1041 -#define IDC_VIA_PAYPAL 1042 -#define IDC_FILE_SYSTEM 1043 -#define IDC_VIA_TAOBAO 1043 -#define IDC_SDEV_STATUS 1044 -#define IDC_DECLARE 1045 -#define IDC_SERVICE_STATUS 1046 -#define IDC_SDEV_EXT2_INFO 1047 -#define IDC_GLOBAL_PREFIX 1047 -#define IDC_SDEV_FREE_SIZE 1048 -#define IDC_GLOBAL_SUFFIX 1048 -#define IDC_START_SERVICE 1049 -#define IDC_PERMANENT_MP 1050 -#define IDC_DOSDEV_MP 1051 -#define IDC_REGISTRY_MP 1052 -#define IDC_EXT2_PREFIX 1053 -#define IDC_EXT2_SUFFIX 1054 -#define IDC_PERFSTAT_INTERVAL 1055 -#define IDC_MEMORY_LIST 1056 -#define IDC_IRP_LIST 1057 -#define IDC_AUTOMOUNT 1058 -#define IDC_FIXMOUNT 1059 -#define IDC_PARTTION_TYPE_LIST 1059 -#define IDC_PARTITION_TYPE 1060 -#define IDC_PARTITION_NAME 1062 -#define IDC_DEAD_LETTER_LIST 1063 -#define IDC_AUTO_REMOVAL 1064 -#define IDC_AUTOREMOVALTEXT 1065 -#define IDC_REMOVAL_CURRENT 1066 -#define IDC_DRIVER 1067 -#define IDC_SDEV_QUICK_MOUNT 1068 -#define IDC_EDIT_UID 1070 -#define IDC_EDIT_GID 1071 -#define IDC_EDIT_EUID 1072 -#define ID_ABOUT 32771 -#define ID_NEW 32772 -#define ID_CHANGE 32773 -#define ID_REFRESH 32774 -#define ID_EXIT 32775 -#define ID_SERVICE 32776 -#define ID_FORMAT 32777 -#define ID_PROPERTY 32778 -#define ID_COPY 32779 -#define ID_SHOW_MAIN 32780 -#define ID_DRV_LETTER 32781 -#define ID_DONATE 32782 -#define ID_ADD_MOUNTPOINT 32783 -#define ID_CHANGE_MOUNTPOINT 32784 -#define ID_REMOVE_MOUNTPOINT 32785 -#define ID_INSTALL_SERVICE 32786 -#define ID_REMOVE_SERVICE 32787 -#define ID_ENABLE_AUTOSTART 32788 -#define ID_DISABLE_AUTOSTART 32789 -#define ID_PERFSTAT 32790 -#define ID_PERFSTOP 32791 -#define ID_COPYALL 32792 -#define ID_QUERYPERF 32793 -#define ID_FLUSH_BUFFER 32794 -#define ID_CHANGE_PARTTYPE 32795 -#define ID_REMOVE_DEAD_LETTER 32796 -#define ID_DRV_QUICK_MOUNT 32797 -#define ID_DRV_QUICK_REMOVE 32798 -#define IDS_LISTITEM_FILESYSTEM 57671 -#define IDS_LISTITEM_VOLUME 57672 -#define IDS_LISTITEM_TYPE 57673 -#define IDS_LISTITEM_TOTALSIZE 57674 -#define IDS_LISTITEM_USEDSIZE 57675 -#define IDS_LISTITEM_CODEPAGE 57676 -#define IDS_LISTITEM_DEVOBJ 57677 -#define IDS_LISTITEM_PARTID 57678 -#define IDS_DISK_TYPE_BASIC 57679 -#define IDS_DISK_TYPE_DYN 57680 -#define IDS_DONATE_DECLARE 57681 -#define IDS_SHOW_PROPERTY 57682 -#define IDS_COPY_ITEM_TO_CLIP 57683 -#define IDS_CHANGE_DRVLETTER 57684 -#define IDS_EXT2_MANAGEMENT 57685 -#define IDS_FLUSH_BUFFER 57686 -#define IDS_CHANGE_PARTID 57687 -#define IDS_RELOAD_REFRESH 57688 -#define IDS_PERFMEM_STAT 57689 -#define IDS_SERVICE_MANAGE 57690 -#define IDS_REMOVE_DEAD_LETTER 57691 -#define IDS_PERFSTAT_NAME 57692 -#define IDS_PERFSTAT_UNIT 57693 -#define IDS_PERFSTAT_CURRENT 57694 -#define IDS_PERFSTAT_SIZE 57695 -#define IDS_PERFSTAT_TOTAL 57696 -#define IDS_PERFSTAT_PROCESSING 57697 -#define IDS_PERSTAT_PROCESSED 57698 -#define IDS_PERFSTAT_PROCESSED 57698 -#define IDS_DRV_QUICK_MOUNT 57699 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 192 -#define _APS_NEXT_COMMAND_VALUE 32799 -#define _APS_NEXT_CONTROL_VALUE 1071 -#define _APS_NEXT_SYMED_VALUE 106 -#endif -#endif +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by Ext2Mgr.rc +// +#define MANIFEST_RESOURCE_ID 1 +#define ID_RELOAD_DL 3 +#define IDM_ABOUTBOX 0x0010 +#ifndef RT_MANIFEST +#define RT_MANIFEST 24 +#endif +#define IDM_CLOSE_SPLASH 0x0020 +#define IDD_ABOUTBOX 100 +#define IDS_ABOUTBOX 101 +#define IDD_EXT2MGR_DIALOG 102 +#define ID_INDICATOR_MESSAGE 103 +#define ID_INDICATOR_TIME 104 +#define ID_INDICATOR_EXTRA 105 +#define IDR_MAINFRAME 128 +#define IDR_TRAY 133 +#define IDI_FLOPPY 134 +#define IDI_CDROM 135 +#define IDI_DISK 136 +#define IDI_DVD 137 +#define IDI_DYNAMIC 138 +#define IDR_MENU 139 +#define IDB_ABOUT_SCREEN 151 +#define IDR_STANDARDBAR 162 +#define IDB_ABOUT_SMALL 163 +#define IDI_BIG_MAINFRAME 164 +#define IDB_LINE_SEP 166 +#define IDD_SERVICE_MANAGE 167 +#define IDD_FORMAT 169 +#define IDD_EXT2_ATTR 170 +#define IDD_CHANGE_MOUNTPINT 171 +#define IDD_NEW_MOUNTPOINT 172 +#define IDD_PROPERTY_DIALOG 173 +#define IDD_DONATE_DIALOG 174 +#define IDB_SMALL_PENGUIN 184 +#define IDB_BIG_PENGUIN 185 +#define IDD_PERFSTAT_DIALOG 186 +#define IDD_PARTITION_TYPE 187 +#define IDD_REMOVE_DEADLETTER 188 +#define IDR_AKEY_EXT2MGR 190 +#define IDR_RCDAT_SRV 191 +#define IDC_VOLUME_LIST 1001 +#define IDC_AUTHOR 1002 +#define IDC_ABOUT_SHOW 1003 +#define IDC_PROGRAM 1004 +#define IDC_EXT2FSD 1005 +#define IDC_DISK_VIEW 1006 +#define IDC_DISK_LIST 1007 +#define IDC_READ_ONLY 1013 +#define IDC_EXT3_WRITABLE 1014 +#define IDC_COMBO_STARTUP 1015 +#define IDC_COMBO_CODEPAGE 1016 +#define IDC_COMBO_DRVLETTER 1017 +#define IDC_COMBO_AUTOMP 1018 +#define IDC_EXT3_AUTOMOUNT 1018 +#define IDC_FORMAT_PROGRESS 1019 +#define IDC_COMBO_FS 1020 +#define IDC_FORMAT_TITLE 1021 +#define IDC_EDIT_LABEL 1022 +#define IDC_COMBO_CLUSTER 1023 +#define IDC_QUICK_FORMAT 1024 +#define IDC_QUICK_COMPRESS 1025 +#define IDC_DRV_LETTER_LIST 1026 +#define IDC_DRVLETTERS_LIST 1028 +#define IDC_PROPERTY_DEVICE 1029 +#define IDC_PROPERTY_SDEV 1030 +#define IDC_VENDOR_ID 1031 +#define IDC_PRODUCT_ID 1032 +#define IDC_SERIAL_NUMBER 1033 +#define IDC_BUS_TYPE 1034 +#define IDC_DEVICE_TYPE 1035 +#define IDC_MEDIA_TYPE 1036 +#define IDC_TOTAL_SIZE 1037 +#define IDC_SDEV_CHANGE_MP 1038 +#define IDC_MOUNT_POINTS 1039 +#define IDC_VIA_SOURCEFORGE 1040 +#define IDC_SDEV_SIZE 1041 +#define IDC_VIA_PAYPAL 1042 +#define IDC_FILE_SYSTEM 1043 +#define IDC_VIA_TAOBAO 1043 +#define IDC_SDEV_STATUS 1044 +#define IDC_DECLARE 1045 +#define IDC_SERVICE_STATUS 1046 +#define IDC_SDEV_EXT2_INFO 1047 +#define IDC_GLOBAL_PREFIX 1047 +#define IDC_SDEV_FREE_SIZE 1048 +#define IDC_GLOBAL_SUFFIX 1048 +#define IDC_START_SERVICE 1049 +#define IDC_PERMANENT_MP 1050 +#define IDC_DOSDEV_MP 1051 +#define IDC_REGISTRY_MP 1052 +#define IDC_EXT2_PREFIX 1053 +#define IDC_EXT2_SUFFIX 1054 +#define IDC_PERFSTAT_INTERVAL 1055 +#define IDC_MEMORY_LIST 1056 +#define IDC_IRP_LIST 1057 +#define IDC_AUTOMOUNT 1058 +#define IDC_FIXMOUNT 1059 +#define IDC_PARTTION_TYPE_LIST 1059 +#define IDC_PARTITION_TYPE 1060 +#define IDC_PARTITION_NAME 1062 +#define IDC_DEAD_LETTER_LIST 1063 +#define IDC_AUTO_REMOVAL 1064 +#define IDC_AUTOREMOVALTEXT 1065 +#define IDC_REMOVAL_CURRENT 1066 +#define IDC_DRIVER 1067 +#define IDC_SDEV_QUICK_MOUNT 1068 +#define IDC_EDIT_UID 1070 +#define IDC_EDIT_GID 1071 +#define IDC_EDIT_EUID 1072 +#define ID_ABOUT 32771 +#define ID_NEW 32772 +#define ID_CHANGE 32773 +#define ID_REFRESH 32774 +#define ID_EXIT 32775 +#define ID_SERVICE 32776 +#define ID_FORMAT 32777 +#define ID_PROPERTY 32778 +#define ID_COPY 32779 +#define ID_SHOW_MAIN 32780 +#define ID_DRV_LETTER 32781 +#define ID_DONATE 32782 +#define ID_ADD_MOUNTPOINT 32783 +#define ID_CHANGE_MOUNTPOINT 32784 +#define ID_REMOVE_MOUNTPOINT 32785 +#define ID_INSTALL_SERVICE 32786 +#define ID_REMOVE_SERVICE 32787 +#define ID_ENABLE_AUTOSTART 32788 +#define ID_DISABLE_AUTOSTART 32789 +#define ID_PERFSTAT 32790 +#define ID_PERFSTOP 32791 +#define ID_COPYALL 32792 +#define ID_QUERYPERF 32793 +#define ID_FLUSH_BUFFER 32794 +#define ID_CHANGE_PARTTYPE 32795 +#define ID_REMOVE_DEAD_LETTER 32796 +#define ID_DRV_QUICK_MOUNT 32797 +#define ID_DRV_QUICK_REMOVE 32798 +#define IDS_LISTITEM_FILESYSTEM 57671 +#define IDS_LISTITEM_VOLUME 57672 +#define IDS_LISTITEM_TYPE 57673 +#define IDS_LISTITEM_TOTALSIZE 57674 +#define IDS_LISTITEM_USEDSIZE 57675 +#define IDS_LISTITEM_CODEPAGE 57676 +#define IDS_LISTITEM_DEVOBJ 57677 +#define IDS_LISTITEM_PARTID 57678 +#define IDS_DISK_TYPE_BASIC 57679 +#define IDS_DISK_TYPE_DYN 57680 +#define IDS_DONATE_DECLARE 57681 +#define IDS_SHOW_PROPERTY 57682 +#define IDS_COPY_ITEM_TO_CLIP 57683 +#define IDS_CHANGE_DRVLETTER 57684 +#define IDS_EXT2_MANAGEMENT 57685 +#define IDS_FLUSH_BUFFER 57686 +#define IDS_CHANGE_PARTID 57687 +#define IDS_RELOAD_REFRESH 57688 +#define IDS_PERFMEM_STAT 57689 +#define IDS_SERVICE_MANAGE 57690 +#define IDS_REMOVE_DEAD_LETTER 57691 +#define IDS_PERFSTAT_NAME 57692 +#define IDS_PERFSTAT_UNIT 57693 +#define IDS_PERFSTAT_CURRENT 57694 +#define IDS_PERFSTAT_SIZE 57695 +#define IDS_PERFSTAT_TOTAL 57696 +#define IDS_PERFSTAT_PROCESSING 57697 +#define IDS_PERSTAT_PROCESSED 57698 +#define IDS_PERFSTAT_PROCESSED 57698 +#define IDS_DRV_QUICK_MOUNT 57699 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 192 +#define _APS_NEXT_COMMAND_VALUE 32799 +#define _APS_NEXT_CONTROL_VALUE 1071 +#define _APS_NEXT_SYMED_VALUE 106 +#endif +#endif diff --git a/Ext2Mgr/toolbar.cpp b/Ext2Mgr/toolbar.cpp index 9bfcb3c..11e465d 100644 --- a/Ext2Mgr/toolbar.cpp +++ b/Ext2Mgr/toolbar.cpp @@ -1,331 +1,331 @@ -// ToolBar1.cpp : implementation file -// - -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#include "stdafx.h" -#include "afxpriv.h" -#include "resource.h" -#include "toolbar.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CStandardBar - -CStandardBar::CStandardBar() : m_pTBButtons(NULL) -{ - -} - -CStandardBar::~CStandardBar() -{ - if (m_pTBButtons) - delete []m_pTBButtons; - -} - - -BEGIN_MESSAGE_MAP(CStandardBar, CToolBarCtrl) - //{{AFX_MSG_MAP(CStandardBar) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - -BOOL CStandardBar::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, int count, PBUTTON_INFO pButton) -{ - BOOL bRet = CToolBarCtrl::Create(dwStyle, rect, pParentWnd, nID); - - AddBitmap(count, IDR_STANDARDBAR); - - m_pTBButtons = new TBBUTTON[count]; - memset(m_pTBButtons, 0, sizeof(TBBUTTON) * count); - - m_nButtonCount = count; - - TBBUTTON sepButton; - sepButton.idCommand = 0; - sepButton.fsStyle = TBSTYLE_SEP; - sepButton.fsState = TBSTATE_ENABLED; - sepButton.iString = 0; - sepButton.iBitmap = 0; - sepButton.dwData = 0; - - for (int nIndex = 0; nIndex < count; nIndex++) { - CString string; - string.LoadString(pButton[nIndex].ID); - - // Add second '\0' - int nStringLength = string.GetLength() + 1; - TCHAR * pString = string.GetBufferSetLength(nStringLength); - pString[nStringLength] = 0; - - m_pTBButtons[nIndex].iString = AddStrings(pString); - - string.ReleaseBuffer(); - - - m_pTBButtons[nIndex].fsState = TBSTATE_ENABLED; - m_pTBButtons[nIndex].fsStyle = TBSTYLE_BUTTON; - m_pTBButtons[nIndex].dwData = 0; - m_pTBButtons[nIndex].iBitmap = nIndex; - m_pTBButtons[nIndex].idCommand = pButton[nIndex].ID; - - if (pButton[nIndex].bSep) { - AddButtons(1,&sepButton); - AddButtons(1,&sepButton); - } - - AddButtons(1, &m_pTBButtons[nIndex]); - } - - return bRet; -} - - -///////////////////////////////////////////////////////////////////////////// -// CStandardBar message handlers - -// MFC routes the notifications sent to the parent of the control to -// the control before the parent can process the notification. -// The control object can handle the notification or ignore it. -// If the notification is handled then return TRUE. Otherwise MFC -// will route it to the parent of the control. - -BOOL CStandardBar::OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult) -{ - return CToolBarCtrl::OnChildNotify(message, wParam, lParam, pLResult); -} - -BOOL CStandardBar::BeginAdjust(WPARAM wParam, LPARAM lParam, LRESULT* pLResult) -{ - TRACE(_T("TBN_BEGINADJUST\n")); - // the customize dialog box is about to be displayed - - - return TRUE; -} - -BOOL CStandardBar::BeginDrag(WPARAM wParam, LPARAM lParam, LRESULT* pLResult) -{ - TRACE(_T("TBN_BEGINDRAG\n")); - - // we are not implementing custon drag and drop - * pLResult = FALSE; - return FALSE; -} - -BOOL CStandardBar::CustomizeHelp(WPARAM wParam, LPARAM lParam, LRESULT* pLResult) -{ - TRACE(_T("TBN_CUSTHELP\n")); - - return TRUE; -} - -BOOL CStandardBar::EndAdjust(WPARAM wParam, LPARAM lParam, LRESULT* pLResult) -{ - TRACE(_T("TBN_ENDADJUST\n")); - - // the customize dialog box has been closed - - return TRUE; -} - -BOOL CStandardBar::EndDrag(WPARAM wParam, LPARAM lParam, LRESULT* pLResult) -{ - TRACE(_T("TBN_ENDDRAG\n")); - - // Code to handle custom drag and drop. This message indicates that - // the item is being dropped - * pLResult = FALSE; - return TRUE; -} - -BOOL CStandardBar::GetButtonInfo(WPARAM wParam, LPARAM lParam, LRESULT* pLResult) -{ - // This notification message has to be handled correctly if - // all operations in the custom dialogbox has to function correctly - // We have to supply information for the button specified by pTBN->tbButton - // - // This notification is sent in the following cases - // - // After TBN_BEGINADJUST the control sends these notifications until - // * pLResult is TRUE. We have to supply valid values when this value is - // set to TRUE. Here the control is collecting information for all - // the buttons that have to be displayed in the dialog box - // - // The control sends this notification to get information about - // a button if the user is trying to add it to the toolbar or - // rearranging the buttons on the toolbar from within the dialog - - TRACE(_T("TBN_GETBUTTONINFO\n")); - - TBNOTIFY *pTBN = (TBNOTIFY *) lParam; - - if (pTBN->iItem >= m_nButtonCount) - { - * pLResult = FALSE; - } - else - { - CString buffer; - buffer.LoadString(pTBN->iItem + ID_NEW); - - // set the string for the button - // truncate the string if its length is greater than the buffer - // supplied by the toolbar - _tcsncpy(pTBN->pszText, buffer, pTBN->cchText - 1); - pTBN->pszText[pTBN->cchText - 1] = '\0'; - - // set the button info - pTBN->tbButton = m_pTBButtons[pTBN->iItem]; - - // valid values are structure - *pLResult = TRUE; - } - - return TRUE; -} - -BOOL CStandardBar::QueryDelete(WPARAM wParam, LPARAM lParam, LRESULT* pLResult) -{ - TRACE(_T("TBN_QUERYDELETE\n")); - - // in this sample any button can be deleted - // if a particular button cannot be deleted set *pResult to FALSE for that item - *pLResult = FALSE; - return TRUE; -} - -BOOL CStandardBar::QueryInsert(WPARAM wParam, LPARAM lParam, LRESULT* pLResult) -{ - TRACE(_T("TBN_QUERYINSERT\n")); - - // in this sample buttons can be inserted at any location on the - // toolbar - *pLResult = FALSE; - return TRUE; -} - -BOOL CStandardBar::Reset(WPARAM wParam, LPARAM lParam, LRESULT* pLResult) -{ - TRACE(_T("TBN_RESET\n")); - - *pLResult = TRUE; - return TRUE; -} - -BOOL CStandardBar::ToolBarChange(WPARAM wParam, LPARAM lParam,LRESULT* pLResult) -{ - TRACE(_T("TBN_TOOLBARCHANGE\n")); - - // the toolbar has changed - return TRUE; -} - - -// Helper function for tooltips - -CString CStandardBar::NeedText( UINT nID, NMHDR * pNotifyStruct, LRESULT * lResult ) -{ - LPTOOLTIPTEXT lpTTT = (LPTOOLTIPTEXT)pNotifyStruct ; - ASSERT(nID == lpTTT->hdr.idFrom); - - CString toolTipText; - toolTipText.LoadString(nID); - - // szText length is 80 - int nLength = (toolTipText.GetLength() > 79) ? 79 : toolTipText.GetLength(); - - toolTipText = toolTipText.Left(nLength); - - return toolTipText; -} - - -void CStandardBar::OnNeedTextW( UINT nID, NMHDR * pNotifyStruct, LRESULT * lResult ) -{ - CString toolTipText = NeedText(nID, pNotifyStruct, lResult); - - LPTOOLTIPTEXTW lpTTT = (LPTOOLTIPTEXTW)pNotifyStruct; - -#ifndef _UNICODE - mbstowcs(lpTTT->szText,(LPCSTR)toolTipText, toolTipText.GetLength() + 1); -#else - _tcsncpy(lpTTT->szText, toolTipText, toolTipText.GetLength() + 1); -#endif -} - -void CStandardBar::OnNeedTextA( UINT nID, NMHDR * pNotifyStruct, LRESULT * lResult ) -{ - CString toolTipText = NeedText(nID, pNotifyStruct, lResult); - - LPTOOLTIPTEXT lpTTT = (LPTOOLTIPTEXT)pNotifyStruct; - - _tcscpy(lpTTT->szText,(LPCTSTR)toolTipText); -} - - -/////////////////////////////////////////////////////////////////////// -// This has been overridden so we can handle the tooltip TTN_NEEDTEXT// -// notification message // -/////////////////////////////////////////////////////////////////////// - -BOOL CStandardBar::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) -{ - ASSERT(pResult != NULL); - NMHDR* pNMHDR = (NMHDR*)lParam; - HWND hWndCtrl = pNMHDR->hwndFrom; - - // get the child ID from the window itself - // UINT nID = _AfxGetDlgCtrlID(hWndCtrl); - - ////////////////////////////////////////////////////////////////// - // If TTN_NEEDTEXT we cannot get the ID from the tooltip window // - ////////////////////////////////////////////////////////////////// - - int nCode = pNMHDR->code; - - // - // if it is the following notification message - // nID has to obtained from wParam - // - - if (nCode == TTN_NEEDTEXTA || nCode == TTN_NEEDTEXTW) - { - UINT nID; // = _AfxGetDlgCtrlID(hWndCtrl); - nID = (UINT)wParam; - - - ASSERT((UINT)pNMHDR->idFrom == (UINT)wParam); - UNUSED(wParam); // not used in release build - ASSERT(hWndCtrl != NULL); - ASSERT(::IsWindow(hWndCtrl)); - - if (AfxGetThreadState()->m_hLockoutNotifyWindow == m_hWnd) - return TRUE; // locked out - ignore control notification - - // reflect notification to child window control - if (ReflectLastMsg(hWndCtrl, pResult)) - return TRUE; // eaten by child - - AFX_NOTIFY notify; - notify.pResult = pResult; - notify.pNMHDR = pNMHDR; - return OnCmdMsg(nID, MAKELONG(nCode, WM_NOTIFY), ¬ify, NULL); - } - - return CToolBarCtrl::OnNotify(wParam, lParam, pResult); -} +// ToolBar1.cpp : implementation file +// + +// This is a part of the Microsoft Foundation Classes C++ library. +// Copyright (C) 1992-1998 Microsoft Corporation +// All rights reserved. +// +// This source code is only intended as a supplement to the +// Microsoft Foundation Classes Reference and related +// electronic documentation provided with the library. +// See these sources for detailed information regarding the +// Microsoft Foundation Classes product. + +#include "stdafx.h" +#include "afxpriv.h" +#include "resource.h" +#include "toolbar.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CStandardBar + +CStandardBar::CStandardBar() : m_pTBButtons(NULL) +{ + +} + +CStandardBar::~CStandardBar() +{ + if (m_pTBButtons) + delete []m_pTBButtons; + +} + + +BEGIN_MESSAGE_MAP(CStandardBar, CToolBarCtrl) + //{{AFX_MSG_MAP(CStandardBar) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + + +BOOL CStandardBar::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, int count, PBUTTON_INFO pButton) +{ + BOOL bRet = CToolBarCtrl::Create(dwStyle, rect, pParentWnd, nID); + + AddBitmap(count, IDR_STANDARDBAR); + + m_pTBButtons = new TBBUTTON[count]; + memset(m_pTBButtons, 0, sizeof(TBBUTTON) * count); + + m_nButtonCount = count; + + TBBUTTON sepButton; + sepButton.idCommand = 0; + sepButton.fsStyle = TBSTYLE_SEP; + sepButton.fsState = TBSTATE_ENABLED; + sepButton.iString = 0; + sepButton.iBitmap = 0; + sepButton.dwData = 0; + + for (int nIndex = 0; nIndex < count; nIndex++) { + CString string; + string.LoadString(pButton[nIndex].ID); + + // Add second '\0' + int nStringLength = string.GetLength() + 1; + TCHAR * pString = string.GetBufferSetLength(nStringLength); + pString[nStringLength] = 0; + + m_pTBButtons[nIndex].iString = AddStrings(pString); + + string.ReleaseBuffer(); + + + m_pTBButtons[nIndex].fsState = TBSTATE_ENABLED; + m_pTBButtons[nIndex].fsStyle = TBSTYLE_BUTTON; + m_pTBButtons[nIndex].dwData = 0; + m_pTBButtons[nIndex].iBitmap = nIndex; + m_pTBButtons[nIndex].idCommand = pButton[nIndex].ID; + + if (pButton[nIndex].bSep) { + AddButtons(1,&sepButton); + AddButtons(1,&sepButton); + } + + AddButtons(1, &m_pTBButtons[nIndex]); + } + + return bRet; +} + + +///////////////////////////////////////////////////////////////////////////// +// CStandardBar message handlers + +// MFC routes the notifications sent to the parent of the control to +// the control before the parent can process the notification. +// The control object can handle the notification or ignore it. +// If the notification is handled then return TRUE. Otherwise MFC +// will route it to the parent of the control. + +BOOL CStandardBar::OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult) +{ + return CToolBarCtrl::OnChildNotify(message, wParam, lParam, pLResult); +} + +BOOL CStandardBar::BeginAdjust(WPARAM wParam, LPARAM lParam, LRESULT* pLResult) +{ + TRACE(_T("TBN_BEGINADJUST\n")); + // the customize dialog box is about to be displayed + + + return TRUE; +} + +BOOL CStandardBar::BeginDrag(WPARAM wParam, LPARAM lParam, LRESULT* pLResult) +{ + TRACE(_T("TBN_BEGINDRAG\n")); + + // we are not implementing custon drag and drop + * pLResult = FALSE; + return FALSE; +} + +BOOL CStandardBar::CustomizeHelp(WPARAM wParam, LPARAM lParam, LRESULT* pLResult) +{ + TRACE(_T("TBN_CUSTHELP\n")); + + return TRUE; +} + +BOOL CStandardBar::EndAdjust(WPARAM wParam, LPARAM lParam, LRESULT* pLResult) +{ + TRACE(_T("TBN_ENDADJUST\n")); + + // the customize dialog box has been closed + + return TRUE; +} + +BOOL CStandardBar::EndDrag(WPARAM wParam, LPARAM lParam, LRESULT* pLResult) +{ + TRACE(_T("TBN_ENDDRAG\n")); + + // Code to handle custom drag and drop. This message indicates that + // the item is being dropped + * pLResult = FALSE; + return TRUE; +} + +BOOL CStandardBar::GetButtonInfo(WPARAM wParam, LPARAM lParam, LRESULT* pLResult) +{ + // This notification message has to be handled correctly if + // all operations in the custom dialogbox has to function correctly + // We have to supply information for the button specified by pTBN->tbButton + // + // This notification is sent in the following cases + // + // After TBN_BEGINADJUST the control sends these notifications until + // * pLResult is TRUE. We have to supply valid values when this value is + // set to TRUE. Here the control is collecting information for all + // the buttons that have to be displayed in the dialog box + // + // The control sends this notification to get information about + // a button if the user is trying to add it to the toolbar or + // rearranging the buttons on the toolbar from within the dialog + + TRACE(_T("TBN_GETBUTTONINFO\n")); + + TBNOTIFY *pTBN = (TBNOTIFY *) lParam; + + if (pTBN->iItem >= m_nButtonCount) + { + * pLResult = FALSE; + } + else + { + CString buffer; + buffer.LoadString(pTBN->iItem + ID_NEW); + + // set the string for the button + // truncate the string if its length is greater than the buffer + // supplied by the toolbar + _tcsncpy(pTBN->pszText, buffer, pTBN->cchText - 1); + pTBN->pszText[pTBN->cchText - 1] = '\0'; + + // set the button info + pTBN->tbButton = m_pTBButtons[pTBN->iItem]; + + // valid values are structure + *pLResult = TRUE; + } + + return TRUE; +} + +BOOL CStandardBar::QueryDelete(WPARAM wParam, LPARAM lParam, LRESULT* pLResult) +{ + TRACE(_T("TBN_QUERYDELETE\n")); + + // in this sample any button can be deleted + // if a particular button cannot be deleted set *pResult to FALSE for that item + *pLResult = FALSE; + return TRUE; +} + +BOOL CStandardBar::QueryInsert(WPARAM wParam, LPARAM lParam, LRESULT* pLResult) +{ + TRACE(_T("TBN_QUERYINSERT\n")); + + // in this sample buttons can be inserted at any location on the + // toolbar + *pLResult = FALSE; + return TRUE; +} + +BOOL CStandardBar::Reset(WPARAM wParam, LPARAM lParam, LRESULT* pLResult) +{ + TRACE(_T("TBN_RESET\n")); + + *pLResult = TRUE; + return TRUE; +} + +BOOL CStandardBar::ToolBarChange(WPARAM wParam, LPARAM lParam,LRESULT* pLResult) +{ + TRACE(_T("TBN_TOOLBARCHANGE\n")); + + // the toolbar has changed + return TRUE; +} + + +// Helper function for tooltips + +CString CStandardBar::NeedText( UINT nID, NMHDR * pNotifyStruct, LRESULT * lResult ) +{ + LPTOOLTIPTEXT lpTTT = (LPTOOLTIPTEXT)pNotifyStruct ; + ASSERT(nID == lpTTT->hdr.idFrom); + + CString toolTipText; + toolTipText.LoadString(nID); + + // szText length is 80 + int nLength = (toolTipText.GetLength() > 79) ? 79 : toolTipText.GetLength(); + + toolTipText = toolTipText.Left(nLength); + + return toolTipText; +} + + +void CStandardBar::OnNeedTextW( UINT nID, NMHDR * pNotifyStruct, LRESULT * lResult ) +{ + CString toolTipText = NeedText(nID, pNotifyStruct, lResult); + + LPTOOLTIPTEXTW lpTTT = (LPTOOLTIPTEXTW)pNotifyStruct; + +#ifndef _UNICODE + mbstowcs(lpTTT->szText,(LPCSTR)toolTipText, toolTipText.GetLength() + 1); +#else + _tcsncpy(lpTTT->szText, toolTipText, toolTipText.GetLength() + 1); +#endif +} + +void CStandardBar::OnNeedTextA( UINT nID, NMHDR * pNotifyStruct, LRESULT * lResult ) +{ + CString toolTipText = NeedText(nID, pNotifyStruct, lResult); + + LPTOOLTIPTEXT lpTTT = (LPTOOLTIPTEXT)pNotifyStruct; + + _tcscpy(lpTTT->szText,(LPCTSTR)toolTipText); +} + + +/////////////////////////////////////////////////////////////////////// +// This has been overridden so we can handle the tooltip TTN_NEEDTEXT// +// notification message // +/////////////////////////////////////////////////////////////////////// + +BOOL CStandardBar::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) +{ + ASSERT(pResult != NULL); + NMHDR* pNMHDR = (NMHDR*)lParam; + HWND hWndCtrl = pNMHDR->hwndFrom; + + // get the child ID from the window itself + // UINT nID = _AfxGetDlgCtrlID(hWndCtrl); + + ////////////////////////////////////////////////////////////////// + // If TTN_NEEDTEXT we cannot get the ID from the tooltip window // + ////////////////////////////////////////////////////////////////// + + int nCode = pNMHDR->code; + + // + // if it is the following notification message + // nID has to obtained from wParam + // + + if (nCode == TTN_NEEDTEXTA || nCode == TTN_NEEDTEXTW) + { + UINT nID; // = _AfxGetDlgCtrlID(hWndCtrl); + nID = (UINT)wParam; + + + ASSERT((UINT)pNMHDR->idFrom == (UINT)wParam); + UNUSED(wParam); // not used in release build + ASSERT(hWndCtrl != NULL); + ASSERT(::IsWindow(hWndCtrl)); + + if (AfxGetThreadState()->m_hLockoutNotifyWindow == m_hWnd) + return TRUE; // locked out - ignore control notification + + // reflect notification to child window control + if (ReflectLastMsg(hWndCtrl, pResult)) + return TRUE; // eaten by child + + AFX_NOTIFY notify; + notify.pResult = pResult; + notify.pNMHDR = pNMHDR; + return OnCmdMsg(nID, MAKELONG(nCode, WM_NOTIFY), ¬ify, NULL); + } + + return CToolBarCtrl::OnNotify(wParam, lParam, pResult); +} diff --git a/Ext2Mgr/toolbar.h b/Ext2Mgr/toolbar.h index f6d248f..ab9027d 100644 --- a/Ext2Mgr/toolbar.h +++ b/Ext2Mgr/toolbar.h @@ -1,86 +1,86 @@ -// Toolbar1.h : header file -// - -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -///////////////////////////////////////////////////////////////////////////// -// CStandardBar window -#ifndef INC_TOOLBAR1_H -#define INC_TOOLBAR1_H - -typedef struct _BUTTON_INFO { - UINT ID; - BOOL bSep; -} BUTTON_INFO, *PBUTTON_INFO; - -class CStandardBar : public CToolBarCtrl -{ -private: - int m_nButtonCount; - TBBUTTON *m_pTBButtons; - -// Construction -public: - CStandardBar(); - -// Attributes -public: - -// Operations -public: - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CStandardBar) - public: - virtual BOOL OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult); - virtual BOOL Create( DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, int count, PBUTTON_INFO); - //}}AFX_VIRTUAL - - -// Implementation -public: - virtual ~CStandardBar(); - -protected: - BOOL BeginAdjust(WPARAM wParam, LPARAM lParam, LRESULT* pLResult); - BOOL BeginDrag(WPARAM wParam, LPARAM lParam, LRESULT* pLResult); - BOOL CustomizeHelp(WPARAM wParam, LPARAM lParam, LRESULT* pLResult); - BOOL EndAdjust(WPARAM wParam, LPARAM lParam, LRESULT* pLResult); - BOOL EndDrag(WPARAM wParam, LPARAM lParam, LRESULT* pLResult); - BOOL GetButtonInfo(WPARAM wParam, LPARAM lParam, LRESULT* pLResult); - BOOL QueryDelete(WPARAM wParam, LPARAM lParam, LRESULT* pLResult); - BOOL QueryInsert(WPARAM wParam, LPARAM lParam, LRESULT* pLResult); - BOOL Reset(WPARAM wParam, LPARAM lParam, LRESULT* pLResult); - BOOL ToolBarChange(WPARAM wParam, LPARAM lParam,LRESULT* pLResult); - - CString NeedText(UINT nID, NMHDR * pNotifyStruct, LRESULT * lResult); - -/////////////////////////////////////////////////////////////////////////////// -// Following function has to be removed when OnNotify is fixed -// - virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); -// -/////////////////////////////////////////////////////////////////////////////// - - // Generated message map functions -protected: - //{{AFX_MSG(CStandardBar) - afx_msg void OnNeedTextW( UINT nID, NMHDR * pNotifyStruct, LRESULT * lResult ); - afx_msg void OnNeedTextA( UINT nID, NMHDR * pNotifyStruct, LRESULT * lResult ); - //}}AFX_MSG - - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// -#endif +// Toolbar1.h : header file +// + +// This is a part of the Microsoft Foundation Classes C++ library. +// Copyright (C) 1992-1998 Microsoft Corporation +// All rights reserved. +// +// This source code is only intended as a supplement to the +// Microsoft Foundation Classes Reference and related +// electronic documentation provided with the library. +// See these sources for detailed information regarding the +// Microsoft Foundation Classes product. + +///////////////////////////////////////////////////////////////////////////// +// CStandardBar window +#ifndef INC_TOOLBAR1_H +#define INC_TOOLBAR1_H + +typedef struct _BUTTON_INFO { + UINT ID; + BOOL bSep; +} BUTTON_INFO, *PBUTTON_INFO; + +class CStandardBar : public CToolBarCtrl +{ +private: + int m_nButtonCount; + TBBUTTON *m_pTBButtons; + +// Construction +public: + CStandardBar(); + +// Attributes +public: + +// Operations +public: + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CStandardBar) + public: + virtual BOOL OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult); + virtual BOOL Create( DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, int count, PBUTTON_INFO); + //}}AFX_VIRTUAL + + +// Implementation +public: + virtual ~CStandardBar(); + +protected: + BOOL BeginAdjust(WPARAM wParam, LPARAM lParam, LRESULT* pLResult); + BOOL BeginDrag(WPARAM wParam, LPARAM lParam, LRESULT* pLResult); + BOOL CustomizeHelp(WPARAM wParam, LPARAM lParam, LRESULT* pLResult); + BOOL EndAdjust(WPARAM wParam, LPARAM lParam, LRESULT* pLResult); + BOOL EndDrag(WPARAM wParam, LPARAM lParam, LRESULT* pLResult); + BOOL GetButtonInfo(WPARAM wParam, LPARAM lParam, LRESULT* pLResult); + BOOL QueryDelete(WPARAM wParam, LPARAM lParam, LRESULT* pLResult); + BOOL QueryInsert(WPARAM wParam, LPARAM lParam, LRESULT* pLResult); + BOOL Reset(WPARAM wParam, LPARAM lParam, LRESULT* pLResult); + BOOL ToolBarChange(WPARAM wParam, LPARAM lParam,LRESULT* pLResult); + + CString NeedText(UINT nID, NMHDR * pNotifyStruct, LRESULT * lResult); + +/////////////////////////////////////////////////////////////////////////////// +// Following function has to be removed when OnNotify is fixed +// + virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); +// +/////////////////////////////////////////////////////////////////////////////// + + // Generated message map functions +protected: + //{{AFX_MSG(CStandardBar) + afx_msg void OnNeedTextW( UINT nID, NMHDR * pNotifyStruct, LRESULT * lResult ); + afx_msg void OnNeedTextA( UINT nID, NMHDR * pNotifyStruct, LRESULT * lResult ); + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// +#endif diff --git a/Ext2Mgr/types.h b/Ext2Mgr/types.h index e85458b..04f612a 100644 --- a/Ext2Mgr/types.h +++ b/Ext2Mgr/types.h @@ -1,24 +1,24 @@ -#ifndef _LINUX_TYPES_H -#define _LINUX_TYPES_H - -#ifndef _MSC_VER -#error _MSC_VER not defined -#endif - - -typedef unsigned __int8 __u8; -typedef signed __int8 __s8; - -typedef signed __int64 __s64; -typedef unsigned __int64 __u64; - -typedef signed __int16 __s16; -typedef unsigned __int16 __u16; - -typedef signed __int32 __s32; -typedef unsigned __int32 __u32; - -typedef signed __int64 __s64; -typedef unsigned __int64 __u64; - -#endif /* LINUX_TYPES_H */ +#ifndef _LINUX_TYPES_H +#define _LINUX_TYPES_H + +#ifndef _MSC_VER +#error _MSC_VER not defined +#endif + + +typedef unsigned __int8 __u8; +typedef signed __int8 __s8; + +typedef signed __int64 __s64; +typedef unsigned __int64 __u64; + +typedef signed __int16 __s16; +typedef unsigned __int16 __u16; + +typedef signed __int32 __s32; +typedef unsigned __int32 __u32; + +typedef signed __int64 __s64; +typedef unsigned __int64 __u64; + +#endif /* LINUX_TYPES_H */