ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
June 2015
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
13 participants
343 discussions
Start a n
N
ew thread
[gedmurphy] 68167: [DEVMGR] - Add the (not yet dynamic) context menu - Implement right click node select
by gedmurphy@svn.reactos.org
Author: gedmurphy Date: Wed Jun 17 08:15:08 2015 New Revision: 68167 URL:
http://svn.reactos.org/svn/reactos?rev=68167&view=rev
Log: [DEVMGR] - Add the (not yet dynamic) context menu - Implement right click node select Modified: trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.cpp trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.h trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h trunk/reactos/dll/win32/devmgr/devmgmt/lang/en-US.rc Modified: trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/D…
============================================================================== --- trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.cpp [iso-8859-1] Wed Jun 17 08:15:08 2015 @@ -34,7 +34,7 @@ { CDeviceView *This; BOOL ScanForChanges; - BOOL UpdateView; +BOOL UpdateView; }; @@ -46,7 +46,8 @@ m_hMainWnd(hMainWnd), m_hTreeView(NULL), m_hPropertyDialog(NULL), - m_hShortcutMenu(NULL), + m_hMenu(NULL), + m_hContextMenu(NULL), m_ViewType(DevicesByType), m_ShowHidden(FALSE), m_RootClassImage(-1), @@ -72,7 +73,7 @@ WC_TREEVIEW, NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | TVS_HASLINES | - TVS_HASBUTTONS | TVS_SHOWSELALWAYS | TVS_LINESATROOT, + TVS_HASBUTTONS | TVS_SHOWSELALWAYS | TVS_LINESATROOT, 0, 0, 0, 0, m_hMainWnd, (HMENU)IDC_TREEVIEW, @@ -89,6 +90,11 @@ SetWindowTheme(m_hTreeView, L"explorer", NULL); } + // Create the context menu and make properties the default item + m_hMenu = LoadMenuW(g_hInstance, MAKEINTRESOURCEW(IDR_POPUP)); + m_hContextMenu = GetSubMenu(m_hMenu, 0); + SetMenuDefaultItem(m_hContextMenu, IDC_PROPERTIES, FALSE); + return !!(m_hTreeView); } @@ -103,11 +109,13 @@ ZeroMemory(&m_ImageListData, sizeof(SP_CLASSIMAGELIST_DATA)); } + DestroyMenu(m_hMenu); + return true; } -void -CDeviceView::Size( +LRESULT +CDeviceView::OnSize( _In_ int x, _In_ int y, _In_ int cx, @@ -122,12 +130,64 @@ cx, cy, SWP_NOZORDER); -} + + return 0; +} + +LRESULT +CDeviceView::OnRightClick( + _In_ LPNMHDR NmHdr + ) +{ + HTREEITEM hItem = TreeView_GetNextItem(NmHdr->hwndFrom, 0, TVGN_DROPHILITE); + if (hItem) + { + TreeView_SelectItem(NmHdr->hwndFrom, hItem); + } + + return 0; +} + +LRESULT +CDeviceView::OnContextMenu( + _In_ LPARAM lParam + ) +{ + HTREEITEM hSelected = TreeView_GetSelection(m_hTreeView); + + RECT rc; + if (TreeView_GetItemRect(m_hTreeView, + hSelected, + &rc, + TRUE)) + { + POINT pt; + if (GetCursorPos(&pt) && + ScreenToClient(m_hTreeView, &pt) && + PtInRect(&rc, pt)) + { + INT xPos = GET_X_LPARAM(lParam); + INT yPos = GET_Y_LPARAM(lParam); + + TrackPopupMenuEx(m_hContextMenu, + TPM_RIGHTBUTTON, + xPos, + yPos, + m_hMainWnd, + NULL); + } + } + + return 0; +} + void -CDeviceView::Refresh(_In_ ViewType Type, - _In_ bool ScanForChanges, - _In_ bool UpdateView) +CDeviceView::Refresh( + _In_ ViewType Type, + _In_ bool ScanForChanges, + _In_ bool UpdateView + ) { // Enum devices on a seperate thread to keep the gui responsive @@ -192,7 +252,9 @@ } bool -CDeviceView::HasProperties(_In_ LPTV_ITEMW TvItem) +CDeviceView::HasProperties( + _In_ LPTV_ITEMW TvItem + ) { CNode *Node = GetNode(TvItem); if (Node) @@ -203,7 +265,9 @@ } bool -CDeviceView::IsDisabled(_In_ LPTV_ITEMW TvItem) +CDeviceView::IsDisabled( + _In_ LPTV_ITEMW TvItem + ) { CNode *Node = GetNode(TvItem); if (Node) @@ -214,7 +278,9 @@ } bool -CDeviceView::CanDisable(_In_ LPTV_ITEMW TvItem) +CDeviceView::CanDisable( + _In_ LPTV_ITEMW TvItem + ) { CNode *Node = GetNode(TvItem); if (Node) Modified: trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/D…
============================================================================== --- trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.h [iso-8859-1] Wed Jun 17 08:15:08 2015 @@ -20,7 +20,8 @@ HWND m_hMainWnd; HWND m_hTreeView; HWND m_hPropertyDialog; - HWND m_hShortcutMenu; + HMENU m_hMenu; + HMENU m_hContextMenu; ViewType m_ViewType; HTREEITEM m_hTreeRoot; @@ -39,11 +40,19 @@ bool Initialize(); bool Uninitialize(); - VOID Size( + LRESULT OnSize( _In_ int x, _In_ int y, _In_ int cx, _In_ int cy + ); + + LRESULT OnRightClick( + _In_ LPNMHDR NmHdr + ); + + LRESULT OnContextMenu( + _In_ LPARAM lParam ); VOID Refresh( @@ -55,12 +64,7 @@ VOID DisplayPropertySheet(); VOID SetFocus(); - //VOID SetDeviceListType(ListDevices List) - //{ - // m_ListDevices = List; - //} - - VOID ShowHiddenDevices(_In_ bool ShowHidden) + VOID SetHiddenDevices(_In_ bool ShowHidden) { m_ShowHidden = ShowHidden; } Modified: trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/M…
============================================================================== --- trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp [iso-8859-1] Wed Jun 17 08:15:08 2015 @@ -16,7 +16,6 @@ #define BTN_PROPERTIES 0 #define BTN_SCAN_HARDWARE 1 -#define BTN_SEPERATOR -1 #define BTN_ENABLE_DRV 2 #define BTN_DISABLE_DRV 3 #define BTN_UPDATE_DRV 4 @@ -124,7 +123,7 @@ WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, CW_USEDEFAULT, CW_USEDEFAULT, - 500, + 550, 500, NULL, NULL, @@ -229,9 +228,6 @@ true); return true; } - - - bool CMainWindow::CreateToolBar() @@ -311,7 +307,7 @@ return bRet; } -void CMainWindow::UpdateContext(_In_ LPTV_ITEMW TvItem) +void CMainWindow::UpdateUiContext(_In_ LPTV_ITEMW TvItem) { WORD State; @@ -437,10 +433,10 @@ lvHeight = rcClient.bottom - iToolHeight - iStatusHeight; // Resize the device view - m_DeviceView->Size(0, - iToolHeight, - rcClient.right, - lvHeight); + m_DeviceView->OnSize(0, + iToolHeight, + rcClient.right, + lvHeight); return 0; } @@ -449,27 +445,20 @@ CMainWindow::OnNotify(LPARAM lParam) { LPNMHDR NmHdr = (LPNMHDR)lParam; + LRESULT Ret; switch (NmHdr->code) { case TVN_SELCHANGED: { LPNMTREEVIEW NmTreeView = (LPNMTREEVIEW)lParam; - UpdateContext(&NmTreeView->itemNew); - break; - } - - case TVN_DELETEITEMW: - { - LPNMTREEVIEW NmTreeView = (LPNMTREEVIEW)lParam; - NmTreeView->action = NmTreeView->action; - - break; - } - - case NM_DBLCLK: - { - m_DeviceView->DisplayPropertySheet(); + UpdateUiContext(&NmTreeView->itemNew); + break; + } + + case NM_RCLICK: + { + Ret = m_DeviceView->OnRightClick(NmHdr); break; } @@ -486,7 +475,7 @@ LRESULT CMainWindow::OnContext(LPARAM lParam) { - return 0; + return m_DeviceView->OnContextMenu(lParam); } LRESULT @@ -535,12 +524,12 @@ if (CurCheckState == MF_CHECKED) { // Inform the device view of the change - m_DeviceView->ShowHiddenDevices(false); + m_DeviceView->SetHiddenDevices(false); NewCheckState = MF_UNCHECKED; } else if (CurCheckState == MF_UNCHECKED) { - m_DeviceView->ShowHiddenDevices(true); + m_DeviceView->SetHiddenDevices(true); NewCheckState = MF_CHECKED; } else Modified: trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/M…
============================================================================== --- trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h [iso-8859-1] Wed Jun 17 08:15:08 2015 @@ -44,7 +44,7 @@ bool CreateToolBar(); bool CreateStatusBar(); - void UpdateContext(_In_ LPTV_ITEMW TvItem); + void UpdateUiContext(_In_ LPTV_ITEMW TvItem); bool StatusBarLoadString( HWND hStatusBar, Modified: trunk/reactos/dll/win32/devmgr/devmgmt/lang/en-US.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/l…
============================================================================== --- trunk/reactos/dll/win32/devmgr/devmgmt/lang/en-US.rc [iso-8859-1] (original) +++ trunk/reactos/dll/win32/devmgr/devmgmt/lang/en-US.rc [iso-8859-1] Wed Jun 17 08:15:08 2015 @@ -9,6 +9,7 @@ POPUP "Action" BEGIN MENUITEM "Update driver software..." IDC_UPDATE_DRV + MENUITEM "Enable" IDC_ENABLE_DRV MENUITEM "Disable" IDC_DISABLE_DRV MENUITEM "Uninstall" IDC_UNINSTALL_DRV MENUITEM SEPARATOR @@ -36,7 +37,15 @@ BEGIN POPUP "popup" BEGIN - MENUITEM "Properties", IDC_PROPERTIES, GRAYED + MENUITEM "Update driver software..." IDC_UPDATE_DRV + MENUITEM "Enable" IDC_ENABLE_DRV + MENUITEM "Disable" IDC_DISABLE_DRV + MENUITEM "Uninstall" IDC_UNINSTALL_DRV + MENUITEM SEPARATOR + MENUITEM "Scan for hardware changes" IDC_SCAN_HARDWARE + MENUITEM "Add hardware" IDC_ADD_HARDWARE, GRAYED + MENUITEM SEPARATOR + MENUITEM "Properties", IDC_PROPERTIES END END
9 years, 6 months
1
0
0
0
[tfaber] 68166: [NTDLL_APITEST] - Also test FileFsAttributeInformation in NtQueryVolumeInformationFile
by tfaber@svn.reactos.org
Author: tfaber Date: Wed Jun 17 06:54:17 2015 New Revision: 68166 URL:
http://svn.reactos.org/svn/reactos?rev=68166&view=rev
Log: [NTDLL_APITEST] - Also test FileFsAttributeInformation in NtQueryVolumeInformationFile Modified: trunk/rostests/apitests/ntdll/NtQueryVolumeInformationFile.c Modified: trunk/rostests/apitests/ntdll/NtQueryVolumeInformationFile.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/NtQueryVol…
============================================================================== --- trunk/rostests/apitests/ntdll/NtQueryVolumeInformationFile.c [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/NtQueryVolumeInformationFile.c [iso-8859-1] Wed Jun 17 06:54:17 2015 @@ -133,16 +133,122 @@ status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, VolumeInfo, sizeof(Buffer), FileFsVolumeInformation); ok(status == STATUS_SUCCESS, "Got status 0x%lx\n", status); ok(IoStatusBlock.Status == STATUS_SUCCESS, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status); - ok(IoStatusBlock.Information >= FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION, VolumeLabel), - "IoStatusBlock.Information = %Iu, expected >=%lu\n", IoStatusBlock.Information, (ULONG)sizeof(FILE_FS_VOLUME_INFORMATION)); + ok(IoStatusBlock.Information == FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION, VolumeLabel) + VolumeInfo->VolumeLabelLength, + "IoStatusBlock.Information = %Iu, expected %lu+%lu\n", IoStatusBlock.Information, (ULONG)FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION, VolumeLabel), VolumeInfo->VolumeLabelLength); ok(VolumeInfo->VolumeCreationTime.QuadPart != 0x5555555555555555, "VolumeInfo->VolumeCreationTime = %I64d\n", VolumeInfo->VolumeCreationTime.QuadPart); ok(VolumeInfo->VolumeSerialNumber != 0x55555555, "VolumeInfo->VolumeSerialNumber = %lu\n", VolumeInfo->VolumeSerialNumber); ok(VolumeInfo->SupportsObjects == FALSE || VolumeInfo->SupportsObjects == TRUE, "VolumeInfo->SupportsObjects = %u\n", VolumeInfo->SupportsObjects); ok(VolumeInfo->VolumeLabelLength % sizeof(WCHAR) == 0, "VolumeInfo->VolumeLabelLength = %Iu\n", VolumeInfo->VolumeLabelLength); if (VolumeInfo->VolumeLabelLength >= sizeof(WCHAR)) ok(VolumeInfo->VolumeLabel[VolumeInfo->VolumeLabelLength / sizeof(WCHAR) - 1] != 0x5555, "Incorrect VolumeLabel or Length\n"); + trace("VolumeLabel = %.*ls\n", (int)VolumeInfo->VolumeLabelLength / sizeof(WCHAR), VolumeInfo->VolumeLabel); ok(VolumeInfo->VolumeLabel[VolumeInfo->VolumeLabelLength / sizeof(WCHAR)] == 0x5555, "Got %x\n", VolumeInfo->VolumeLabel[VolumeInfo->VolumeLabelLength / sizeof(WCHAR)]); +} + +static +VOID +TestFileFsAttributeInformation(HANDLE handle) +{ + IO_STATUS_BLOCK IoStatusBlock; + ULONG Buffer[(sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 32 * sizeof(WCHAR)) / sizeof(ULONG)]; + PFILE_FS_ATTRIBUTE_INFORMATION AttributeInfo = (PFILE_FS_ATTRIBUTE_INFORMATION)Buffer; + NTSTATUS status; + + status = NtQueryVolumeInformationFile(handle, NULL, NULL, 0, FileFsAttributeInformation); + ok(status == STATUS_INFO_LENGTH_MISMATCH, "Got status 0x%lx\n", status); + + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, NULL, 0, FileFsAttributeInformation); + ok(status == STATUS_INFO_LENGTH_MISMATCH, "Got status 0x%lx\n", status); + ok(IoStatusBlock.Status == 0x55555555, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status); + ok(IoStatusBlock.Information == (ULONG_PTR)0x5555555555555555, "IoStatusBlock.Information = %Iu\n", IoStatusBlock.Information); + + status = NtQueryVolumeInformationFile(handle, NULL, AttributeInfo, 0, FileFsAttributeInformation); + ok(status == STATUS_INFO_LENGTH_MISMATCH, "Got status 0x%lx\n", status); + + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, (PUCHAR)Buffer + 2, sizeof(FILE_FS_ATTRIBUTE_INFORMATION), FileFsAttributeInformation); + ok(status == STATUS_DATATYPE_MISALIGNMENT, "Got status 0x%lx\n", status); + ok(IoStatusBlock.Status == 0x55555555, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status); + ok(IoStatusBlock.Information == (ULONG_PTR)0x5555555555555555, "IoStatusBlock.Information = %Iu\n", IoStatusBlock.Information); + + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, AttributeInfo, 0, FileFsAttributeInformation); + ok(status == STATUS_INFO_LENGTH_MISMATCH, "Got status 0x%lx\n", status); + ok(IoStatusBlock.Status == 0x55555555, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status); + ok(IoStatusBlock.Information == (ULONG_PTR)0x5555555555555555, "IoStatusBlock.Information = %Iu\n", IoStatusBlock.Information); + + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, AttributeInfo, FIELD_OFFSET(FILE_FS_ATTRIBUTE_INFORMATION, FileSystemName), FileFsAttributeInformation); + ok(status == STATUS_INFO_LENGTH_MISMATCH, "Got status 0x%lx\n", status); + ok(IoStatusBlock.Status == 0x55555555, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status); + ok(IoStatusBlock.Information == (ULONG_PTR)0x5555555555555555, "IoStatusBlock.Information = %Iu\n", IoStatusBlock.Information); + + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, AttributeInfo, sizeof(FILE_FS_ATTRIBUTE_INFORMATION) - 1, FileFsAttributeInformation); + ok(status == STATUS_INFO_LENGTH_MISMATCH, "Got status 0x%lx\n", status); + ok(IoStatusBlock.Status == 0x55555555, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status); + ok(IoStatusBlock.Information == (ULONG_PTR)0x5555555555555555, "IoStatusBlock.Information = %Iu\n", IoStatusBlock.Information); + + RtlFillMemory(Buffer, sizeof(Buffer), 0x55); + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, AttributeInfo, sizeof(FILE_FS_ATTRIBUTE_INFORMATION), FileFsAttributeInformation); + ok(status == STATUS_BUFFER_OVERFLOW, "Got status 0x%lx\n", status); + ok(IoStatusBlock.Status == STATUS_BUFFER_OVERFLOW, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status); + ok(AttributeInfo->FileSystemNameLength == sizeof(FILE_FS_ATTRIBUTE_INFORMATION) - FIELD_OFFSET(FILE_FS_ATTRIBUTE_INFORMATION, FileSystemName), + "AttributeInfo->FileSystemNameLength = %Iu\n", AttributeInfo->FileSystemNameLength); + ok(IoStatusBlock.Information == sizeof(FILE_FS_ATTRIBUTE_INFORMATION), + "IoStatusBlock.Information = %Iu, expected %lu\n", IoStatusBlock.Information, (ULONG)sizeof(FILE_FS_ATTRIBUTE_INFORMATION)); + ok(AttributeInfo->FileSystemName[AttributeInfo->FileSystemNameLength / sizeof(WCHAR)] == 0x5555, + "Got %x\n", AttributeInfo->FileSystemName[AttributeInfo->FileSystemNameLength / sizeof(WCHAR)]); + + RtlFillMemory(Buffer, sizeof(Buffer), 0x55); + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, AttributeInfo, sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 1, FileFsAttributeInformation); + ok(status == STATUS_BUFFER_OVERFLOW, "Got status 0x%lx\n", status); + ok(IoStatusBlock.Status == STATUS_BUFFER_OVERFLOW, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status); + ok(AttributeInfo->FileSystemNameLength == sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 1 - FIELD_OFFSET(FILE_FS_ATTRIBUTE_INFORMATION, FileSystemName), + "AttributeInfo->FileSystemNameLength = %Iu\n", AttributeInfo->FileSystemNameLength); + ok(IoStatusBlock.Information == sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 1, + "IoStatusBlock.Information = %Iu, expected %lu\n", IoStatusBlock.Information, (ULONG)sizeof(FILE_FS_ATTRIBUTE_INFORMATION)); + ok((AttributeInfo->FileSystemName[AttributeInfo->FileSystemNameLength / sizeof(WCHAR)] & 0xff00) == 0x5500, + "Got %x\n", AttributeInfo->FileSystemName[AttributeInfo->FileSystemNameLength / sizeof(WCHAR)]); + ok(AttributeInfo->FileSystemName[AttributeInfo->FileSystemNameLength / sizeof(WCHAR) + 1] == 0x5555, + "Got %x\n", AttributeInfo->FileSystemName[AttributeInfo->FileSystemNameLength / sizeof(WCHAR) + 1]); + + RtlFillMemory(Buffer, sizeof(Buffer), 0x55); + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, AttributeInfo, sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + sizeof(WCHAR), FileFsAttributeInformation); + if (status != STATUS_SUCCESS) + { + ok(status == STATUS_BUFFER_OVERFLOW, "Got status 0x%lx\n", status); + ok(IoStatusBlock.Status == STATUS_BUFFER_OVERFLOW, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status); + ok(AttributeInfo->FileSystemNameLength == sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + sizeof(WCHAR) - FIELD_OFFSET(FILE_FS_ATTRIBUTE_INFORMATION, FileSystemName), + "AttributeInfo->FileSystemNameLength = %Iu\n", AttributeInfo->FileSystemNameLength); + ok(IoStatusBlock.Information == sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + sizeof(WCHAR), + "IoStatusBlock.Information = %Iu, expected %lu\n", IoStatusBlock.Information, (ULONG)sizeof(FILE_FS_ATTRIBUTE_INFORMATION)); + ok(AttributeInfo->FileSystemName[AttributeInfo->FileSystemNameLength / sizeof(WCHAR)] == 0x5555, + "Got %x\n", AttributeInfo->FileSystemName[AttributeInfo->FileSystemNameLength / sizeof(WCHAR)]); + } + + RtlFillMemory(Buffer, sizeof(Buffer), 0x55); + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, AttributeInfo, sizeof(Buffer), FileFsAttributeInformation); + ok(status == STATUS_SUCCESS, "Got status 0x%lx\n", status); + ok(IoStatusBlock.Status == STATUS_SUCCESS, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status); + ok(IoStatusBlock.Information == FIELD_OFFSET(FILE_FS_ATTRIBUTE_INFORMATION, FileSystemName) + AttributeInfo->FileSystemNameLength, + "IoStatusBlock.Information = %Iu, expected %lu+%lu\n", IoStatusBlock.Information, (ULONG)FIELD_OFFSET(FILE_FS_ATTRIBUTE_INFORMATION, FileSystemName), AttributeInfo->FileSystemNameLength); + ok(AttributeInfo->FileSystemAttributes != 0x55555555, "AttributeInfo->FileSystemAttributes = 0x%lx\n", AttributeInfo->FileSystemAttributes); + ok(AttributeInfo->MaximumComponentNameLength != 0x55555555, "AttributeInfo->MaximumComponentNameLength = 0x%lx\n", AttributeInfo->MaximumComponentNameLength); + ok(AttributeInfo->FileSystemNameLength % sizeof(WCHAR) == 0, "AttributeInfo->FileSystemNameLength = %Iu\n", AttributeInfo->FileSystemNameLength); + ok(!wcsncmp(AttributeInfo->FileSystemName, L"NTFS", 4) || + !wcsncmp(AttributeInfo->FileSystemName, L"FAT", 3) || + !wcsncmp(AttributeInfo->FileSystemName, L"FAT32", 5), + "FileSystemName = %.*ls\n", (int)AttributeInfo->FileSystemNameLength / sizeof(WCHAR), AttributeInfo->FileSystemName); + trace("FileSystemName = %.*ls\n", (int)AttributeInfo->FileSystemNameLength / sizeof(WCHAR), AttributeInfo->FileSystemName); + ok(AttributeInfo->FileSystemName[AttributeInfo->FileSystemNameLength / sizeof(WCHAR)] == 0x5555, + "Got %x\n", AttributeInfo->FileSystemName[AttributeInfo->FileSystemNameLength / sizeof(WCHAR)]); } START_TEST(NtQueryVolumeInformationFile) @@ -160,7 +266,7 @@ InitializeObjectAttributes(&attr, &pathW, OBJ_CASE_INSENSITIVE, NULL, NULL); status = NtOpenFile(&handle, SYNCHRONIZE|FILE_LIST_DIRECTORY, &attr, &IoStatusBlock, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_DIRECTORY_FILE|FILE_SYNCHRONOUS_IO_NONALERT); - + ok(status == STATUS_SUCCESS, "NtOpenFile failed: 0x%lx\n", status); RtlFreeUnicodeString(&pathW); if (!NT_SUCCESS(status)) @@ -177,6 +283,7 @@ TestFileFsDeviceInformation(handle); TestFileFsVolumeInformation(handle); + TestFileFsAttributeInformation(handle); NtClose(handle); }
9 years, 6 months
1
0
0
0
[gedmurphy] 68165: [DEVMGR] - Move the devmgmt code to devmgr where it belongs and start to rewrite it (devmgmt_new wasn't a good design). It's not part of devmgr yet, I'll merge it and add it to t...
by gedmurphy@svn.reactos.org
Author: gedmurphy Date: Tue Jun 16 21:13:28 2015 New Revision: 68165 URL:
http://svn.reactos.org/svn/reactos?rev=68165&view=rev
Log: [DEVMGR] - Move the devmgmt code to devmgr where it belongs and start to rewrite it (devmgmt_new wasn't a good design). It's not part of devmgr yet, I'll merge it and add it to the build when it's more complete. - Add support for caching devices to speed up switching device views - start to add dynamic context support so we can enable/disable, update and uninstall devices depending on its state. - WIP Added: trunk/reactos/dll/win32/devmgr/devmgmt/ (with props) trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.cpp (with props) trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.h (with props) trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp (with props) trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h (with props) trunk/reactos/dll/win32/devmgr/devmgmt/Node.cpp (with props) trunk/reactos/dll/win32/devmgr/devmgmt/Node.h (with props) trunk/reactos/dll/win32/devmgr/devmgmt/Resource.h (with props) trunk/reactos/dll/win32/devmgr/devmgmt/devmgmt.h (with props) trunk/reactos/dll/win32/devmgr/devmgmt/lang/ (with props) trunk/reactos/dll/win32/devmgr/devmgmt/lang/en-US.rc (with props) trunk/reactos/dll/win32/devmgr/devmgmt/res/ (with props) trunk/reactos/dll/win32/devmgr/devmgmt/res/computer.ico (with props) trunk/reactos/dll/win32/devmgr/devmgmt/res/root.bmp (with props) trunk/reactos/dll/win32/devmgr/devmgmt/res/toolbar.bmp (with props) trunk/reactos/dll/win32/devmgr/devmgmt/rsrc.rc (with props) trunk/reactos/dll/win32/devmgr/devmgmt/stdafx.h (with props) Propchange: trunk/reactos/dll/win32/devmgr/devmgmt/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Tue Jun 16 21:13:28 2015 @@ -0,0 +1 @@ +((CORE|ROSTESTS|ROSAPPS)-\d+)(,? ?((CORE|ROSTESTS|ROSAPPS)-\d+))*(,? ?(and |or )?((CORE|ROSTESTS|ROSAPPS)-\d+))? Propchange: trunk/reactos/dll/win32/devmgr/devmgmt/ ------------------------------------------------------------------------------ bugtraq:message = See issue %BUGID% for more details. Propchange: trunk/reactos/dll/win32/devmgr/devmgmt/ ------------------------------------------------------------------------------ bugtraq:url =
https://jira.reactos.org/browse/%BUGID%
Propchange: trunk/reactos/dll/win32/devmgr/devmgmt/ ------------------------------------------------------------------------------ tsvn:logminsize = 10 Added: trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/D…
============================================================================== --- trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.cpp (added) +++ trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.cpp [iso-8859-1] Tue Jun 16 21:13:28 2015 @@ -0,0 +1,873 @@ +/* +* PROJECT: ReactOS Device Manager +* LICENSE: GPL - See COPYING in the top level directory +* FILE: dll/win32/devmgr/devmgr/DeviceView.cpp +* PURPOSE: Implements the tree view which contains the devices +* COPYRIGHT: Copyright 2015 Ged Murphy <gedmurphy(a)reactos.org> +* +*/ + + +#include "stdafx.h" +#include "devmgmt.h" +#include "DeviceView.h" + + +/* DATA *********************************************/ + +#define CLASS_NAME_LEN 256 +#define CLASS_DESC_LEN 256 + +INT_PTR +WINAPI +DevicePropertiesExW( + IN HWND hWndParent OPTIONAL, + IN LPCWSTR lpMachineName OPTIONAL, + IN LPCWSTR lpDeviceID OPTIONAL, + IN DWORD dwFlags OPTIONAL, + IN BOOL bShowDevMgr +); + +typedef INT_PTR(WINAPI *pDevicePropertiesExW)(HWND,LPCWSTR,LPCWSTR,DWORD,BOOL); + +struct RefreshThreadData +{ + CDeviceView *This; + BOOL ScanForChanges; + BOOL UpdateView; +}; + + +/* PUBLIC METHODS *************************************/ + +CDeviceView::CDeviceView( + HWND hMainWnd + ) : + m_hMainWnd(hMainWnd), + m_hTreeView(NULL), + m_hPropertyDialog(NULL), + m_hShortcutMenu(NULL), + m_ViewType(DevicesByType), + m_ShowHidden(FALSE), + m_RootClassImage(-1), + m_RootDevInst(0) +{ + ZeroMemory(&m_ImageListData, sizeof(SP_CLASSIMAGELIST_DATA)); +} + +CDeviceView::~CDeviceView(void) +{ +} + +bool +CDeviceView::Initialize() +{ + // Get the device image list + m_ImageListData.cbSize = sizeof(SP_CLASSIMAGELIST_DATA); + BOOL bSuccess = SetupDiGetClassImageList(&m_ImageListData); + if (bSuccess == FALSE) return false; + + // Create the main treeview + m_hTreeView = CreateWindowExW(WS_EX_CLIENTEDGE, + WC_TREEVIEW, + NULL, + WS_CHILD | WS_VISIBLE | WS_BORDER | TVS_HASLINES | + TVS_HASBUTTONS | TVS_SHOWSELALWAYS | TVS_LINESATROOT, + 0, 0, 0, 0, + m_hMainWnd, + (HMENU)IDC_TREEVIEW, + g_hInstance, + NULL); + if (m_hTreeView) + { + // Set the image list against the treeview + (void)TreeView_SetImageList(m_hTreeView, + m_ImageListData.ImageList, + TVSIL_NORMAL); + + // Give the treeview arrows instead of +/- boxes (on Win7) + SetWindowTheme(m_hTreeView, L"explorer", NULL); + } + + return !!(m_hTreeView); +} + +bool +CDeviceView::Uninitialize() +{ + EmptyDeviceView(); + + if (m_ImageListData.ImageList != NULL) + { + SetupDiDestroyClassImageList(&m_ImageListData); + ZeroMemory(&m_ImageListData, sizeof(SP_CLASSIMAGELIST_DATA)); + } + + return true; +} + +void +CDeviceView::Size( + _In_ int x, + _In_ int y, + _In_ int cx, + _In_ int cy + ) +{ + // Resize the treeview + SetWindowPos(m_hTreeView, + NULL, + x, + y, + cx, + cy, + SWP_NOZORDER); +} + +void +CDeviceView::Refresh(_In_ ViewType Type, + _In_ bool ScanForChanges, + _In_ bool UpdateView) +{ + // Enum devices on a seperate thread to keep the gui responsive + + m_ViewType = Type; + + RefreshThreadData *ThreadData; + ThreadData = new RefreshThreadData(); + ThreadData->This = this; + ThreadData->ScanForChanges = ScanForChanges; + ThreadData->UpdateView = UpdateView; + + HANDLE hThread; + hThread = (HANDLE)_beginthreadex(NULL, + 0, + &RefreshThread, + ThreadData, + 0, + NULL); + + if (hThread) CloseHandle(hThread); +} + +void +CDeviceView::DisplayPropertySheet() +{ + // + // In ReactOS we can link to DevicePropertiesEx but + // not in windows as it's not part of the SDK + +#ifndef __REACTOS__ + HMODULE hModule = LoadLibraryW(L"devmgr.dll"); + if (hModule == NULL) return; + + pDevicePropertiesExW DevicePropertiesExW; + DevicePropertiesExW = (pDevicePropertiesExW)GetProcAddress(hModule, + "DevicePropertiesExW"); + if (DevicePropertiesExW == NULL) + { + FreeLibrary(hModule); + return; + } +#endif + + CNode *Node = GetSelectedNode(); + if (Node && Node->HasProperties()) + { + DevicePropertiesExW(m_hTreeView, + NULL, + Node->GetDeviceId(), + 1,//DPF_EXTENDED, + FALSE); + } + +#ifndef __REACTOS__ + FreeLibrary(hModule); +#endif +} + +void +CDeviceView::SetFocus() +{ +} + +bool +CDeviceView::HasProperties(_In_ LPTV_ITEMW TvItem) +{ + CNode *Node = GetNode(TvItem); + if (Node) + { + return Node->HasProperties(); + } + return false; +} + +bool +CDeviceView::IsDisabled(_In_ LPTV_ITEMW TvItem) +{ + CNode *Node = GetNode(TvItem); + if (Node) + { + return Node->IsDisabled(); + } + return false; +} + +bool +CDeviceView::CanDisable(_In_ LPTV_ITEMW TvItem) +{ + CNode *Node = GetNode(TvItem); + if (Node) + { + return Node->CanDisable(); + } + return false; +} + + +/* PRIVATE METHODS ********************************************/ + +bool +CDeviceView::AddRootDevice() +{ + // Check whether we've loaded the root bitmap into the imagelist (done on first run) + if (m_RootClassImage == -1) + { + // Load the bitmap we'll be using as the root image + HBITMAP hRootImage; + hRootImage = LoadBitmapW(g_hInstance, + MAKEINTRESOURCEW(IDB_ROOT_IMAGE)); + if (hRootImage == NULL) return FALSE; + + // Add this bitmap to the device image list. This is a bit hacky, but it's safe + m_RootClassImage = ImageList_Add(m_ImageListData.ImageList, + hRootImage, + NULL); + DeleteObject(hRootImage); + } + + /* Get the root instance */ + CONFIGRET cr; + cr = CM_Locate_DevNodeW(&m_RootDevInst, + NULL, + CM_LOCATE_DEVNODE_NORMAL); + if (cr != CR_SUCCESS) + { + return false; + } + + /* The root name is the computer name */ + WCHAR RootDeviceName[ROOT_NAME_SIZE]; + DWORD Size = ROOT_NAME_SIZE; + if (GetComputerNameW(RootDeviceName, &Size)) + _wcslwr_s(RootDeviceName); + + TV_ITEMW tvi; + TV_INSERTSTRUCT tvins; + ZeroMemory(&tvi, sizeof(tvi)); + ZeroMemory(&tvins, sizeof(tvins)); + + // Insert the root / parent item into our treeview + tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE; + tvi.pszText = RootDeviceName; + tvi.cchTextMax = wcslen(RootDeviceName); + tvi.iImage = m_RootClassImage; + tvi.iSelectedImage = m_RootClassImage; + tvins.item = tvi; + m_hTreeRoot = TreeView_InsertItem(m_hTreeView, &tvins); + + return (m_hTreeRoot != NULL); + +} + +bool +CDeviceView::GetNextClass(_In_ ULONG ClassIndex, + _Out_ LPGUID ClassGuid, + _Out_ HDEVINFO *hDevInfo) +{ + CONFIGRET cr; + + // Get the next class in the list + cr = CM_Enumerate_Classes(ClassIndex, + ClassGuid, + 0); + if (cr != CR_SUCCESS) return false; + + // Check for devices without a class + if (IsEqualGUID(*ClassGuid, GUID_DEVCLASS_UNKNOWN)) + { + // Get device info for all devices for all classes + *hDevInfo = SetupDiGetClassDevsW(NULL, + NULL, + NULL, + DIGCF_ALLCLASSES); + } + else + { + // We only want the devices for this class + *hDevInfo = SetupDiGetClassDevsW(ClassGuid, + NULL, + NULL, + DIGCF_PRESENT); + + } + + return (hDevInfo != INVALID_HANDLE_VALUE); +} + +unsigned int __stdcall CDeviceView::RefreshThread(void *Param) +{ + RefreshThreadData *ThreadData = (RefreshThreadData *)Param; + CDeviceView *This = ThreadData->This; + + + // Empty the treeview + This->EmptyDeviceView(); + This->m_hTreeRoot = NULL; + + // Refresh the devices only if requested. This means + // switching views uses the cache and remains fast + if (ThreadData->ScanForChanges) + { + This->RefreshDeviceList(); + } + + // display the type of view the user wants + switch (This->m_ViewType) + { + case DevicesByType: + (void)This->ListDevicesByType(); + break; + + case DevicesByConnection: + (VOID)This->ListDevicesByConnection(); + break; + + case ResourcesByType: + break; + + case ResourcesByConnection: + break; + } + + delete ThreadData; + + return 0; +} + + +bool +CDeviceView::ListDevicesByType() +{ + CNode *ClassNode, *DeviceNode; + HDEVINFO hDevInfo; + HTREEITEM hTreeItem = NULL; + GUID ClassGuid; + INT ClassIndex; + LPTSTR DeviceId = NULL; + BOOL bClassSuccess, bSuccess; + + // Start by adding the root node to the tree + bSuccess = AddRootDevice(); + if (bSuccess == false) return false; + + ClassIndex = 0; + do + { + // Loop through all the device classes + bClassSuccess = GetNextClass(ClassIndex, &ClassGuid, &hDevInfo); + if (bClassSuccess) + { + bool bClassUnknown = false; + bool AddedParent = false; + INT DeviceIndex = 0; + BOOL MoreItems; + + // Get the cached class node + ClassNode = GetClassNode(&ClassGuid); + if (ClassNode == NULL) + { + ATLASSERT(FALSE); + ClassIndex++; + continue; + } + + // Set a flag is this is the (special case) unknown class + if (IsEqualGUID(ClassGuid, GUID_DEVCLASS_UNKNOWN)) + bClassUnknown = true; + + do + { + // Get a handle to all the devices in this class + SP_DEVINFO_DATA DeviceInfoData; + ZeroMemory(&DeviceInfoData, sizeof(SP_DEVINFO_DATA)); + DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA); + bSuccess = SetupDiEnumDeviceInfo(hDevInfo, + DeviceIndex, + &DeviceInfoData); + if (bSuccess == FALSE && GetLastError() == ERROR_NO_MORE_ITEMS) + MoreItems = FALSE; + + if (bSuccess) + { + MoreItems = TRUE; + + // The unknown class handle contains all devices on the system, + // and we're just looking for the ones with a null GUID + if (bClassUnknown) + { + if (IsEqualGUID(DeviceInfoData.ClassGuid, GUID_NULL) == FALSE) + { + // This is a known device, we aren't interested in it + DeviceIndex++; + continue; + } + } + + // Get the cached device node + DeviceNode = GetDeviceNode(DeviceInfoData.DevInst); + if (DeviceNode == NULL) + { + ATLASSERT(bClassUnknown == true); + DeviceIndex++; + continue; + } + + // Check if this is a hidden device + if (DeviceNode->IsHidden()) + { + // Ignore this device if we aren't displaying hidden devices + if (m_ShowHidden == FALSE) + { + DeviceIndex++; + continue; + } + } + + // We have a device, we need to add the parent if it hasn't yet been added + if (AddedParent == false) + { + // Insert the new class under the root item + hTreeItem = InsertIntoTreeView(m_hTreeRoot, + ClassNode); + AddedParent = true; + } + + // Add the device under the class item node + (void)InsertIntoTreeView(hTreeItem, DeviceNode); + + // Expand the class if it has a problem device + if (DeviceNode->HasProblem()) + { + (void)TreeView_Expand(m_hTreeView, + hTreeItem, + TVE_EXPAND); + } + } + + DeviceIndex++; + + } while (MoreItems); + + // If this class has devices, sort them alphabetically + if (AddedParent == true) + { + (void)TreeView_SortChildren(m_hTreeView, + hTreeItem, + 0); + } + } + + ClassIndex++; + + } while (bClassSuccess); + + // Sort the classes alphabetically + (void)TreeView_SortChildren(m_hTreeView, + m_hTreeRoot, + 0); + + // Expand the root item + (void)TreeView_Expand(m_hTreeView, + m_hTreeRoot, + TVE_EXPAND); + + // Pre-select the root item + (VOID)TreeView_SelectItem(m_hTreeView, + m_hTreeRoot); + + return 0; +} + +bool +CDeviceView::ListDevicesByConnection() +{ + BOOL bSuccess; + + // Start by adding the root node to the tree + bSuccess = AddRootDevice(); + if (bSuccess == false) return false; + + /* Walk the device tree and add all the devices */ + RecurseChildDevices(m_RootDevInst, m_hTreeRoot); + + /* Expand the root item */ + (VOID)TreeView_Expand(m_hTreeView, + m_hTreeRoot, + TVE_EXPAND); + + return true; +} + +VOID +CDeviceView::RecurseChildDevices( + _In_ DEVINST ParentDevice, + _In_ HTREEITEM hParentTreeItem + ) +{ + + HTREEITEM hDevItem = NULL; + DEVINST Device; + BOOL bSuccess; + + /* Check if the parent has any child devices */ + if (GetChildDevice(ParentDevice, &Device) == FALSE) + return; + + // Get the cached device node + CNode *DeviceNode; + DeviceNode = GetDeviceNode(Device); + if (DeviceNode == NULL) + { + ATLASSERT(FALSE); + return; + } + + + /* Check if this is a hidden device */ + if ((m_ShowHidden == TRUE) || (!(DeviceNode->IsHidden()))) + { + /* Add this device to the tree under its parent */ + hDevItem = InsertIntoTreeView(hParentTreeItem, + DeviceNode); + + + if (hDevItem) + { + /* Check if this child has any children itself */ + RecurseChildDevices(Device, hDevItem); + } + } + + + for (;;) + { + /* Check if the parent device has anything at the same level */ + bSuccess = GetSiblingDevice(Device, &Device); + if (bSuccess == FALSE) break; + + DeviceNode = GetDeviceNode(Device); + if (DeviceNode == NULL) + { + ATLASSERT(FALSE); + } + + /* Check if this is a hidden device */ + if (DeviceNode->IsHidden()) + { + if (m_ShowHidden == FALSE) + continue; + } + + /* Add this device to the tree under its parent */ + hDevItem = InsertIntoTreeView(hParentTreeItem, + DeviceNode); + if (hDevItem) + { + /* Check if this child has any children itself */ + RecurseChildDevices(Device, hDevItem); + } + } + + (void)TreeView_SortChildren(m_hTreeView, + hParentTreeItem, + 0); + +} + +bool +CDeviceView::GetChildDevice( + _In_ DEVINST ParentDevInst, + _Out_ PDEVINST DevInst +) +{ + CONFIGRET cr; + cr = CM_Get_Child(DevInst, + ParentDevInst, + 0); + return (cr == CR_SUCCESS); +} + +bool +CDeviceView::GetSiblingDevice( + _In_ DEVINST PrevDevice, + _Out_ PDEVINST DevInst +) +{ + CONFIGRET cr; + cr = CM_Get_Sibling(DevInst, + PrevDevice, + 0); + return (cr == CR_SUCCESS); +} + +HTREEITEM +CDeviceView::InsertIntoTreeView( + _In_ HTREEITEM hParent, + _In_ CNode *Node + ) +{ + + LPWSTR lpLabel; + lpLabel = Node->GetDisplayName(); + + TV_ITEMW tvi; + TV_INSERTSTRUCT tvins; + ZeroMemory(&tvi, sizeof(tvi)); + ZeroMemory(&tvins, sizeof(tvins)); + + tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE; + tvi.pszText = lpLabel; + tvi.cchTextMax = wcslen(lpLabel); + tvi.lParam = (LPARAM)Node; + tvi.iImage = Node->GetClassImage(); + tvi.iSelectedImage = Node->GetClassImage(); + + if (Node->GetOverlayImage()) + { + tvi.mask |= TVIF_STATE; + tvi.stateMask = TVIS_OVERLAYMASK; + tvi.state = INDEXTOOVERLAYMASK(Node->GetOverlayImage()); + } + + tvins.item = tvi; + tvins.hParent = hParent; + + return TreeView_InsertItem(m_hTreeView, &tvins); +} + +void +CDeviceView::RecurseDeviceView( + _In_ HTREEITEM hParentItem + ) +{ + HTREEITEM hItem; + TVITEMW tvItem; + + // Check if this node has any children + hItem = TreeView_GetChild(m_hTreeView, hParentItem); + if (hItem == NULL) return; + + // The lParam contains the node pointer data + tvItem.hItem = hItem; + tvItem.mask = TVIF_PARAM; + if (TreeView_GetItem(m_hTreeView, &tvItem) && + tvItem.lParam != NULL) + { + // Delete the node class + //delete reinterpret_cast<CNode *>(tvItem.lParam); + } + + // This node may have its own children + RecurseDeviceView(hItem); + + // Delete all the siblings + for (;;) + { + // Get the next item at this level + hItem = TreeView_GetNextSibling(m_hTreeView, hItem); + if (hItem == NULL) break; + + // The lParam contains the node pointer data + tvItem.hItem = hItem; + tvItem.mask = TVIF_PARAM; + if (TreeView_GetItem(m_hTreeView, &tvItem)) + { + //if (tvItem.lParam != NULL) + // delete reinterpret_cast<CNode *>(tvItem.lParam); + } + + /* This node may have its own children */ + RecurseDeviceView(hItem); + } +} + + +void +CDeviceView::EmptyDeviceView() +{ + HTREEITEM hItem; + + // Check if there are any items in the tree + hItem = TreeView_GetRoot(m_hTreeView); + if (hItem == NULL) return; + + // Free all the class nodes + //RecurseDeviceView(hItem); + + // Delete all the items + (VOID)TreeView_DeleteAllItems(m_hTreeView); +} + + + + +CNode* +CDeviceView::GetClassNode(_In_ LPGUID ClassGuid) +{ + POSITION Pos; + CNode *Node; + + Pos = m_ClassNodeList.GetHeadPosition(); + + do + { + Node = m_ClassNodeList.GetNext(Pos); + if (IsEqualGUID(*Node->GetClassGuid(), *ClassGuid)) + { + //ATLASSERT(Node->GetType() == NodeClass); + break; + } + + Node = NULL; + + } while (Pos != NULL); + + return Node; +} + +CNode* +CDeviceView::GetDeviceNode(_In_ DEVINST Device) +{ + POSITION Pos; + CNode *Node; + + Pos = m_DeviceNodeList.GetHeadPosition(); + + do + { + Node = m_DeviceNodeList.GetNext(Pos); + if (Node->GetDeviceInst() == Device) + { + //ATLASSERT(Node->GetType() == NodeDevice); + break; + } + + Node = NULL; + + } while (Pos != NULL); + + return Node; +} + +CNode* CDeviceView::GetNode(LPTV_ITEMW TvItem) +{ + TvItem->mask = TVIF_PARAM; + if (TreeView_GetItem(m_hTreeView, TvItem)) + { + return (CNode *)TvItem->lParam; + } +} + +CNode* CDeviceView::GetSelectedNode() +{ + TV_ITEM TvItem; + TvItem.hItem = TreeView_GetSelection(m_hTreeView); + return GetNode(&TvItem); +} + +void +CDeviceView::EmptyLists() +{ + POSITION Pos; + CNode *Node; + + if (!m_ClassNodeList.IsEmpty()) + { + Pos = m_ClassNodeList.GetHeadPosition(); + do + { + Node = m_ClassNodeList.GetNext(Pos); + delete Node; + + } while (Pos != NULL); + } + + if (!m_DeviceNodeList.IsEmpty()) + { + Pos = m_DeviceNodeList.GetHeadPosition(); + do + { + Node = m_DeviceNodeList.GetNext(Pos); + delete Node; + + } while (Pos != NULL); + } +} + +bool +CDeviceView::RefreshDeviceList() +{ + GUID ClassGuid; + CNode *Node; + HDEVINFO hDevInfo; + SP_DEVINFO_DATA DeviceInfoData; + DWORD i; + BOOL Success; + + ULONG ClassIndex = 0; + + EmptyLists(); + + do + { + Success = GetNextClass(ClassIndex, &ClassGuid, &hDevInfo); + if (Success) + { + /* Create a new class node */ + Node = new CNode(&ClassGuid, &m_ImageListData); + if (Node->Setup()) + { + m_ClassNodeList.AddTail(Node); + } + } + ClassIndex++; + } while (Success); + + + hDevInfo = SetupDiGetClassDevsW(NULL, + 0, + 0, + DIGCF_PRESENT | DIGCF_ALLCLASSES); + if (hDevInfo == INVALID_HANDLE_VALUE) + { + return false; + } + + + DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA); + for (i = 0;; i++) + { + Success = SetupDiEnumDeviceInfo(hDevInfo, i, &DeviceInfoData); + if (Success == FALSE) break; + + + Node = new CNode(DeviceInfoData.DevInst, &m_ImageListData); + Node->Setup(); + m_DeviceNodeList.AddTail(Node); + } + + SetupDiDestroyDeviceInfoList(hDevInfo); + + return TRUE; +} Propchange: trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.cpp ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/D…
============================================================================== --- trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.h (added) +++ trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.h [iso-8859-1] Tue Jun 16 21:13:28 2015 @@ -0,0 +1,131 @@ +#pragma once +#include "Node.h" + +enum ViewType +{ + DevicesByType, + DevicesByConnection, + ResourcesByType, + ResourcesByConnection +}; + + +class CDeviceView +{ + CAtlList<CNode *> m_ClassNodeList; + CAtlList<CNode *> m_DeviceNodeList; + + SP_CLASSIMAGELIST_DATA m_ImageListData; + + HWND m_hMainWnd; + HWND m_hTreeView; + HWND m_hPropertyDialog; + HWND m_hShortcutMenu; + ViewType m_ViewType; + + HTREEITEM m_hTreeRoot; + DEVINST m_RootDevInst; + + bool m_ShowHidden; + int m_RootClassImage; + +public: + CDeviceView( + HWND hMainWnd + ); + + ~CDeviceView(void); + + bool Initialize(); + bool Uninitialize(); + + VOID Size( + _In_ int x, + _In_ int y, + _In_ int cx, + _In_ int cy + ); + + VOID Refresh( + _In_ ViewType Type, + _In_ bool ScanForChanges, + _In_ bool UpdateView + ); + + VOID DisplayPropertySheet(); + VOID SetFocus(); + + //VOID SetDeviceListType(ListDevices List) + //{ + // m_ListDevices = List; + //} + + VOID ShowHiddenDevices(_In_ bool ShowHidden) + { + m_ShowHidden = ShowHidden; + } + + ViewType GetCurrentView() { return m_ViewType; } + + bool HasProperties(_In_ LPTV_ITEMW TvItem); + //bool SelDeviceIsHidden(); + bool CanDisable(_In_ LPTV_ITEMW TvItem); + bool IsDisabled(_In_ LPTV_ITEMW TvItem); + bool SelDeviceIsStarted(); + bool SelDeviceIsInstalled(); + +private: + bool AddRootDevice(); + + bool RefreshDeviceList(); + + static unsigned int __stdcall RefreshThread( + void *Param + ); + + bool ListDevicesByConnection( + ); + bool ListDevicesByType( + ); + + bool GetNextClass( + _In_ ULONG ClassIndex, + _Out_ LPGUID ClassGuid, + _Out_ HDEVINFO *hDevInfo + ); + + VOID RecurseChildDevices( + _In_ DEVINST ParentDevice, + _In_ HTREEITEM hParentTreeItem + ); + + bool GetChildDevice( + _In_ DEVINST ParentDevInst, + _Out_ PDEVINST DevInst + ); + + bool GetSiblingDevice( + _In_ DEVINST PrevDevice, + _Out_ PDEVINST DevInst + ); + + HTREEITEM InsertIntoTreeView( + _In_ HTREEITEM hParent, + _In_ CNode *Node + ); + + VOID RecurseDeviceView( + _In_ HTREEITEM hParentItem + ); + + VOID EmptyDeviceView( + ); + + CNode* GetNode(_In_ LPTV_ITEMW TvItem); + CNode* GetSelectedNode(); + + CNode* GetClassNode(_In_ LPGUID ClassGuid); + CNode* GetDeviceNode(_In_ DEVINST Device); + void EmptyLists(); +}; + Propchange: trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.h ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/M…
============================================================================== --- trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp (added) +++ trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp [iso-8859-1] Tue Jun 16 21:13:28 2015 @@ -0,0 +1,764 @@ +/* + * PROJECT: ReactOS Device Manager + * LICENSE: GPL - See COPYING in the top level directory + * FILE: dll/win32/devmgr/devmgr/MainWindow.cpp + * PURPOSE: Implements the main container window for the device view + * COPYRIGHT: Copyright 2014 - 2015 Ged Murphy <gedmurphy(a)reactos.org> + */ + + +#include "stdafx.h" +#include "devmgmt.h" +#include "MainWindow.h" + + +/* DATA *****************************************************/ + +#define BTN_PROPERTIES 0 +#define BTN_SCAN_HARDWARE 1 +#define BTN_SEPERATOR -1 +#define BTN_ENABLE_DRV 2 +#define BTN_DISABLE_DRV 3 +#define BTN_UPDATE_DRV 4 +#define BTN_UNINSTALL_DRV 5 + + +// menu hints +static const MENU_HINT MainMenuHintTable[] = +{ + // File Menu + { IDC_EXIT, IDS_HINT_EXIT }, + + // Action Menu + { IDC_UPDATE_DRV, NULL }, + { IDC_DISABLE_DRV, NULL }, + { IDC_UNINSTALL_DRV, NULL }, + { IDC_SCAN_HARDWARE, IDS_HINT_REFRESH }, + { IDC_ADD_HARDWARE, NULL }, + { IDC_PROPERTIES, IDS_HINT_PROP}, + + // View Menu + { IDC_DEVBYTYPE, IDS_HINT_DEV_BY_TYPE}, + { IDC_DEVBYCONN, IDS_HINT_DEV_BY_CONN}, + { IDC_RESBYTYPE, IDS_HINT_RES_BY_TYPE}, + { IDC_RESBYCONN, IDS_HINT_RES_BY_TYPE}, + + { IDC_ABOUT, IDS_HINT_ABOUT } + +}; + +// system menu hints +static const MENU_HINT SystemMenuHintTable[] = +{ + {SC_RESTORE, IDS_HINT_SYS_RESTORE}, + {SC_MOVE, IDS_HINT_SYS_MOVE}, + {SC_SIZE, IDS_HINT_SYS_SIZE}, + {SC_MINIMIZE, IDS_HINT_SYS_MINIMIZE}, + {SC_MAXIMIZE, IDS_HINT_SYS_MAXIMIZE}, + {SC_CLOSE, IDS_HINT_SYS_CLOSE}, +}; + +static TBBUTTON TbButtons[] = +{ + { BTN_PROPERTIES, IDC_PROPERTIES, TBSTATE_ENABLED, BTNS_BUTTON, 0, 0 }, + { BTN_SCAN_HARDWARE, IDC_SCAN_HARDWARE, TBSTATE_ENABLED, BTNS_BUTTON, 0, 0 }, + { 2, IDC_STATIC, TBSTATE_ENABLED, BTNS_SEP, 0, 0 }, + { BTN_ENABLE_DRV, IDC_ENABLE_DRV, TBSTATE_ENABLED, BTNS_BUTTON, 0, 0 }, + { BTN_DISABLE_DRV, IDC_DISABLE_DRV, TBSTATE_ENABLED, BTNS_BUTTON, 0, 0 }, + { BTN_UPDATE_DRV, IDC_UPDATE_DRV, TBSTATE_ENABLED, BTNS_BUTTON, 0, 0 }, + { BTN_UNINSTALL_DRV, IDC_UNINSTALL_DRV, TBSTATE_ENABLED, BTNS_BUTTON, 0, 0 } +}; + + +/* PUBLIC METHODS **********************************************/ + +CMainWindow::CMainWindow(void) : + m_ToolbarhImageList(NULL), + m_hMainWnd(NULL), + m_hStatusBar(NULL), + m_hToolBar(NULL), + m_CmdShow(0) +{ + m_szMainWndClass = L"DevMgmtWndClass"; +} + +CMainWindow::~CMainWindow(void) +{ + // Destroy any previous list + if (m_ToolbarhImageList) ImageList_Destroy(m_ToolbarhImageList); +} + +bool +CMainWindow::Initialize(LPCTSTR lpCaption, + int nCmdShow) +{ + CAtlStringW szCaption; + WNDCLASSEXW wc = {0}; + + // Store the show window value + m_CmdShow = nCmdShow; + + // Setup the window class struct + wc.cbSize = sizeof(WNDCLASSEXW); + wc.lpfnWndProc = MainWndProc; + wc.hInstance = g_hInstance; + wc.hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCEW(IDI_MAIN_ICON)); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); + wc.lpszMenuName = MAKEINTRESOURCEW(IDR_MAINMENU); + wc.lpszClassName = m_szMainWndClass; + wc.hIconSm = (HICON)LoadImage(g_hInstance, + MAKEINTRESOURCE(IDI_MAIN_ICON), + IMAGE_ICON, + 16, + 16, + LR_SHARED); + + // Register the window + if (RegisterClassExW(&wc)) + { + // Create the main window and store the object pointer + m_hMainWnd = CreateWindowExW(WS_EX_WINDOWEDGE, + m_szMainWndClass, + lpCaption, + WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, + CW_USEDEFAULT, + CW_USEDEFAULT, + 500, + 500, + NULL, + NULL, + g_hInstance, + this); + } + + // Return creation result + return !!(m_hMainWnd); +} + +void +CMainWindow::Uninitialize() +{ + // Unregister the window class + UnregisterClassW(m_szMainWndClass, g_hInstance); +} + +int +CMainWindow::Run() +{ + MSG Msg; + + // Pump the message queue + while (GetMessageW(&Msg, NULL, 0, 0 ) != 0) + { + TranslateMessage(&Msg); + DispatchMessageW(&Msg); + } + + return 0; +} + + +/* PRIVATE METHODS **********************************************/ + +bool +CMainWindow::MainWndMenuHint(WORD CmdId, + const MENU_HINT *HintArray, + DWORD HintsCount, + UINT DefHintId) +{ + bool Found = false; + const MENU_HINT *LastHint; + UINT HintId = DefHintId; + + LastHint = HintArray + HintsCount; + while (HintArray != LastHint) + { + if (HintArray->CmdId == CmdId) + { + HintId = HintArray->HintId; + Found = true; + break; + } + HintArray++; + } + + StatusBarLoadString(m_hStatusBar, + SB_SIMPLEID, + g_hInstance, + HintId); + + return Found; +} + +bool +CMainWindow::RefreshView(ViewType Type) +{ + UINT CheckId; + BOOL bSuccess; + + // Refreshed the cached view + m_DeviceView->Refresh(Type, FALSE, TRUE); + + // Get the menu item id + switch (Type) + { + case DevicesByType: CheckId = IDC_DEVBYTYPE; break; + case DevicesByConnection: CheckId = IDC_DEVBYCONN; break; + case ResourcesByType: CheckId = IDC_RESBYTYPE; break; + case ResourcesByConnection: CheckId = IDC_RESBYCONN; break; + default: ATLASSERT(FALSE); break; + } + + // Set the new check item + bSuccess = CheckMenuRadioItem(m_hMenu, + IDC_DEVBYTYPE, + IDC_RESBYCONN, + CheckId, + MF_BYCOMMAND); + + return TRUE; +} + +bool +CMainWindow::ScanForHardwareChanges() +{ + // Refresh the cache and and display + m_DeviceView->Refresh(m_DeviceView->GetCurrentView(), + true, + true); + return true; +} + + + + +bool +CMainWindow::CreateToolBar() +{ + TBADDBITMAP TbAddBitmap; + INT Index; + + DWORD dwStyles = WS_CHILDWINDOW | TBSTYLE_FLAT | TBSTYLE_WRAPABLE | TBSTYLE_TOOLTIPS | CCS_NODIVIDER; + DWORD dwExStyles = WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR; + + // Create the toolbar window + m_hToolBar = CreateWindowExW(dwExStyles, + TOOLBARCLASSNAME, + NULL, + dwStyles, + 0, 0, 0, 0, + m_hMainWnd, + (HMENU)IDC_TOOLBAR, + g_hInstance, + NULL); + if (m_hToolBar == NULL) return FALSE; + + // Don't show clipped buttons + SendMessageW(m_hToolBar, + TB_SETEXTENDEDSTYLE, + 0, + TBSTYLE_EX_HIDECLIPPEDBUTTONS); + + SendMessageW(m_hToolBar, TB_SETBITMAPSIZE, 0, MAKELONG(16, 16)); + + // Set the struct size, the toobar needs this... + SendMessageW(m_hToolBar, + TB_BUTTONSTRUCTSIZE, + sizeof(TBBUTTON), + 0); + + TbAddBitmap.hInst = g_hInstance; + TbAddBitmap.nID = IDB_TOOLBAR; + Index = SendMessageW(m_hToolBar, TB_ADDBITMAP, _countof(TbButtons), (LPARAM)&TbAddBitmap); + + SendMessageW(m_hToolBar, TB_ADDBUTTONSW, _countof(TbButtons), (LPARAM)TbButtons); + SendMessageW(m_hToolBar, TB_AUTOSIZE, 0, 0); + + if (TRUE) + { + ShowWindow(m_hToolBar, SW_SHOW); + } + + return TRUE; +} + +bool +CMainWindow::CreateStatusBar() +{ + int StatWidths[] = {110, -1}; // widths of status bar + bool bRet = FALSE; + + // Create the status bar + m_hStatusBar = CreateWindowExW(0, + STATUSCLASSNAME, + NULL, + WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, + 0, 0, 0, 0, + m_hMainWnd, + (HMENU)IDC_STATUSBAR, + g_hInstance, + NULL); + if (m_hStatusBar) + { + // Set the width + bRet = (SendMessageW(m_hStatusBar, + SB_SETPARTS, + sizeof(StatWidths) / sizeof(int), + (LPARAM)StatWidths) != 0); + } + + return bRet; +} + +void CMainWindow::UpdateContext(_In_ LPTV_ITEMW TvItem) +{ + WORD State; + + // properties button + if (m_DeviceView->HasProperties(TvItem)) + { + State = TBSTATE_ENABLED; + } + else + { + State = TBSTATE_HIDDEN; + } + SendMessageW(m_hToolBar, TB_SETSTATE, IDC_PROPERTIES, MAKELPARAM(State, 0)); + SendMessageW(m_hToolBar, TB_SETSTATE, IDC_UPDATE_DRV, MAKELPARAM(State, 0)); //hack + SendMessageW(m_hToolBar, TB_SETSTATE, IDC_UNINSTALL_DRV, MAKELPARAM(State, 0)); // hack + + // enable driver button + if (m_DeviceView->IsDisabled(TvItem)) + { + State = TBSTATE_ENABLED; + } + else + { + State = TBSTATE_HIDDEN; + } + SendMessageW(m_hToolBar, TB_SETSTATE, IDC_ENABLE_DRV, MAKELPARAM(State, 0)); + + // disable driver button + if (m_DeviceView->CanDisable(TvItem) && !m_DeviceView->IsDisabled(TvItem)) + { + State = TBSTATE_ENABLED; + } + else + { + State = TBSTATE_HIDDEN; + } + SendMessageW(m_hToolBar, TB_SETSTATE, IDC_DISABLE_DRV, MAKELPARAM(State, 0)); + + + + + +} + + + +bool +CMainWindow::StatusBarLoadString(IN HWND hStatusBar, + IN INT PartId, + IN HINSTANCE hInstance, + IN UINT uID) +{ + CAtlStringW szMessage; + bool bRet = false; + + // Load the string + if (szMessage.LoadStringW(hInstance, uID)) + { + // Show the string on the status bar + bRet = (SendMessageW(hStatusBar, + SB_SETTEXT, + (WPARAM)PartId, + (LPARAM)szMessage.GetBuffer()) != 0); + } + + return bRet; +} + +LRESULT +CMainWindow::OnCreate(HWND hwnd) +{ + LRESULT RetCode; + + RetCode = -1; + m_hMainWnd = hwnd; + + // Store a handle to the main menu + m_hMenu = GetMenu(m_hMainWnd); + + // Create the toolbar and statusbar + if (CreateToolBar() && CreateStatusBar()) + { + // Create the device view object + m_DeviceView = new CDeviceView(m_hMainWnd); + if (m_DeviceView->Initialize()) + { + // Do the initial scan + ScanForHardwareChanges(); + + // Display the window according to the user request + ShowWindow(hwnd, m_CmdShow); + RetCode = 0; + } + } + + return RetCode; +} + +LRESULT +CMainWindow::OnSize() +{ + RECT rcClient, rcTool, rcStatus; + INT lvHeight, iToolHeight, iStatusHeight; + + // Autosize the toolbar + SendMessage(m_hToolBar, TB_AUTOSIZE, 0, 0); + + // Get the toolbar rect and save the height + GetWindowRect(m_hToolBar, &rcTool); + iToolHeight = rcTool.bottom - rcTool.top; + + // Resize the status bar + SendMessage(m_hStatusBar, WM_SIZE, 0, 0); + + // Get the statusbar rect and save the height + GetWindowRect(m_hStatusBar, &rcStatus); + iStatusHeight = rcStatus.bottom - rcStatus.top; + + // Get the full client rect + GetClientRect(m_hMainWnd, &rcClient); + + // Calculate the remaining height for the treeview + lvHeight = rcClient.bottom - iToolHeight - iStatusHeight; + + // Resize the device view + m_DeviceView->Size(0, + iToolHeight, + rcClient.right, + lvHeight); + + return 0; +} + +LRESULT +CMainWindow::OnNotify(LPARAM lParam) +{ + LPNMHDR NmHdr = (LPNMHDR)lParam; + + switch (NmHdr->code) + { + case TVN_SELCHANGED: + { + LPNMTREEVIEW NmTreeView = (LPNMTREEVIEW)lParam; + UpdateContext(&NmTreeView->itemNew); + break; + } + + case TVN_DELETEITEMW: + { + LPNMTREEVIEW NmTreeView = (LPNMTREEVIEW)lParam; + NmTreeView->action = NmTreeView->action; + + break; + } + + case NM_DBLCLK: + { + m_DeviceView->DisplayPropertySheet(); + break; + } + + case NM_RETURN: + { + m_DeviceView->DisplayPropertySheet(); + break; + } + } + + return 0; +} + +LRESULT +CMainWindow::OnContext(LPARAM lParam) +{ + return 0; +} + +LRESULT +CMainWindow::OnCommand(WPARAM wParam, + LPARAM lParam) +{ + LRESULT RetCode = 0; + WORD Msg; + + // Get the message + Msg = LOWORD(wParam); + + switch (Msg) + { + case IDC_PROPERTIES: + { + m_DeviceView->DisplayPropertySheet(); + break; + } + + case IDC_SCAN_HARDWARE: + { + ScanForHardwareChanges(); + break; + } + + case IDC_DEVBYTYPE: + { + RefreshView(DevicesByType); + break; + } + + case IDC_DEVBYCONN: + { + RefreshView(DevicesByConnection); + break; + } + + case IDC_SHOWHIDDEN: + { + UINT CurCheckState, NewCheckState; + + // Get the current state + CurCheckState = GetMenuState(m_hMenu, IDC_SHOWHIDDEN, MF_BYCOMMAND); + + if (CurCheckState == MF_CHECKED) + { + // Inform the device view of the change + m_DeviceView->ShowHiddenDevices(false); + NewCheckState = MF_UNCHECKED; + } + else if (CurCheckState == MF_UNCHECKED) + { + m_DeviceView->ShowHiddenDevices(true); + NewCheckState = MF_CHECKED; + } + else + { + ATLASSERT(FALSE); + break; + } + + // Set the new check state + CheckMenuItem(m_hMenu, IDC_SHOWHIDDEN, MF_BYCOMMAND | NewCheckState); + + // Refresh the device view + m_DeviceView->Refresh(m_DeviceView->GetCurrentView(), + false, + true); + break; + } + + case IDC_ABOUT: + { + // Apportion blame + MessageBoxW(m_hMainWnd, + L"ReactOS Device Manager\r\nCopyright Ged Murphy 2015", + L"About", + MB_OK | MB_APPLMODAL); + + // Set focus back to the treeview + m_DeviceView->SetFocus(); + break; + } + + case IDC_EXIT: + { + // Post a close message to the window + PostMessageW(m_hMainWnd, + WM_CLOSE, + 0, + 0); + break; + } + + default: + // We didn't handle it + RetCode = -1; + break; + } + + return RetCode; +} + +LRESULT +CMainWindow::OnDestroy() +{ + // Uninitialize the device view + m_DeviceView->Uninitialize(); + + // Kill the object + delete m_DeviceView; + m_DeviceView = NULL; + + // Clear the user data pointer + SetWindowLongPtr(m_hMainWnd, GWLP_USERDATA, 0); + + // Break the message loop + PostQuitMessage(0); + + return 0; +} + +LRESULT CALLBACK +CMainWindow::MainWndProc(HWND hwnd, + UINT msg, + WPARAM wParam, + LPARAM lParam) +{ + CMainWindow *pThis; + LRESULT RetCode = 0; + + // Get the object pointer from window context + pThis = (CMainWindow *)GetWindowLongPtr(hwnd, GWLP_USERDATA); + if (pThis == NULL) + { + // Check that this isn't a create message + if (msg != WM_CREATE) + { + // Don't handle null info pointer + goto HandleDefaultMessage; + } + } + + switch(msg) + { + case WM_CREATE: + { + // Get the object pointer from the create param + pThis = (CMainWindow *)((LPCREATESTRUCT)lParam)->lpCreateParams; + + // Store the pointer in the window's global user data + SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pThis); + + // Call the create handler + RetCode = pThis->OnCreate(hwnd); + break; + } + + case WM_SIZE: + { + RetCode = pThis->OnSize(); + break; + } + + case WM_NOTIFY: + { + RetCode = pThis->OnNotify(lParam); + break; + } + + case WM_CONTEXTMENU: + { + RetCode = pThis->OnContext(lParam); + break; + } + + case WM_MENUSELECT: + { + if (pThis->m_hStatusBar != NULL) + { + if (!pThis->MainWndMenuHint(LOWORD(wParam), + MainMenuHintTable, + sizeof(MainMenuHintTable) / sizeof(MainMenuHintTable[0]), + IDS_HINT_BLANK)) + { + pThis->MainWndMenuHint(LOWORD(wParam), + SystemMenuHintTable, + sizeof(SystemMenuHintTable) / sizeof(SystemMenuHintTable[0]), + IDS_HINT_BLANK); + } + } + + break; + } + + case WM_COMMAND: + { + // Handle the command message + RetCode = pThis->OnCommand(wParam, lParam); + if (RetCode == -1) + { + // Hand it off to the default message handler + goto HandleDefaultMessage; + } + } + + case WM_CLOSE: + { + // Destroy the main window + DestroyWindow(hwnd); + } + break; + + case WM_DESTROY: + { + // Call the destroy handler + RetCode = pThis->OnDestroy(); + break; + } + + default: + { +HandleDefaultMessage: + RetCode = DefWindowProc(hwnd, msg, wParam, lParam); + break; + } + } + + return RetCode; +} + + +//////// MOVE ME //////////////// + +HINSTANCE g_hInstance = NULL; +HANDLE ProcessHeap = NULL; + +BOOL +WINAPI +DeviceManager_ExecuteW(HWND hWndParent, + HINSTANCE hInst, + LPCWSTR lpMachineName, + int nCmdShow) +{ + CMainWindow MainWindow; + INITCOMMONCONTROLSEX icex; + CAtlStringW szAppName; + int Ret = 1; + + // Store the global values + g_hInstance = hInst; + ProcessHeap = GetProcessHeap(); + + // Initialize common controls + icex.dwSize = sizeof(INITCOMMONCONTROLSEX); + icex.dwICC = ICC_BAR_CLASSES | ICC_COOL_CLASSES; + InitCommonControlsEx(&icex); + + // Load the application name + if (szAppName.LoadStringW(g_hInstance, IDS_APPNAME)) + { + // Initialize the main window + if (MainWindow.Initialize(szAppName, nCmdShow)) + { + // Run the application + Ret = MainWindow.Run(); + + // Uninitialize the main window + MainWindow.Uninitialize(); + } + } + + return Ret; +} Propchange: trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/M…
============================================================================== --- trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h (added) +++ trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h [iso-8859-1] Tue Jun 16 21:13:28 2015 @@ -0,0 +1,70 @@ +#pragma once +#include "DeviceView.h" + +typedef struct _MENU_HINT +{ + WORD CmdId; + UINT HintId; +} MENU_HINT, *PMENU_HINT; + +class CMainWindow +{ + CAtlStringW m_szMainWndClass; + CDeviceView *m_DeviceView; + HWND m_hMainWnd; + HWND m_hStatusBar; + HWND m_hToolBar; + HIMAGELIST m_ToolbarhImageList; + HMENU m_hMenu; + int m_CmdShow; + +public: + CMainWindow(void); + ~CMainWindow(void); + + bool Initialize(LPCTSTR lpCaption, int nCmdShow); + int Run(); + void Uninitialize(); + +private: + static LRESULT CALLBACK MainWndProc( + HWND hwnd, + UINT msg, + WPARAM wParam, + LPARAM lParam + ); + + LRESULT OnCreate(HWND hwnd); + LRESULT OnDestroy(); + LRESULT OnSize(); + LRESULT OnNotify(LPARAM lParam); + LRESULT OnContext(LPARAM lParam); + LRESULT OnCommand(WPARAM wParam, LPARAM lParam); + + bool CreateToolBar(); + bool CreateStatusBar(); + + void UpdateContext(_In_ LPTV_ITEMW TvItem); + + bool StatusBarLoadString( + HWND hStatusBar, + INT PartId, + HINSTANCE hInstance, + UINT uID + ); + + bool MainWndMenuHint( + WORD CmdId, + const MENU_HINT *HintArray, + DWORD HintsCount, + UINT DefHintId + ); + + bool RefreshView( + ViewType Type + ); + + bool ScanForHardwareChanges( + ); +}; + Propchange: trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/dll/win32/devmgr/devmgmt/Node.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/N…
============================================================================== --- trunk/reactos/dll/win32/devmgr/devmgmt/Node.cpp (added) +++ trunk/reactos/dll/win32/devmgr/devmgmt/Node.cpp [iso-8859-1] Tue Jun 16 21:13:28 2015 @@ -0,0 +1,375 @@ +/* +* PROJECT: ReactOS Device Manager +* LICENSE: GPL - See COPYING in the top level directory +* FILE: dll/win32/devmgr/devmgr/node.cpp +* PURPOSE: Object for each device in the tree +* COPYRIGHT: Copyright 2015 Ged Murphy <gedmurphy(a)reactos.org> +* +*/ + +#include "stdafx.h" +#include "devmgmt.h" +#include "Node.h" + + +/* PUBLIC METHODS *******************************************/ + +CNode::CNode(_In_ LPGUID ClassGuid, + _In_ PSP_CLASSIMAGELIST_DATA ImageListData) : + m_ImageListData(ImageListData), + m_NodeType(NodeClass), + m_DevInst(0), + m_DeviceId(NULL), + m_ClassImage(0), + m_Status(0), + m_ProblemNumber(0), + m_OverlayImage(0) +{ + m_DisplayName[0] = UNICODE_NULL; + CopyMemory(&m_ClassGuid, ClassGuid, sizeof(GUID)); +} + +CNode::CNode(_In_opt_ DEVINST Device, + _In_ PSP_CLASSIMAGELIST_DATA ImageListData) : + m_ImageListData(ImageListData), + m_NodeType(NodeDevice), + m_DevInst(Device), + m_DeviceId(NULL), + m_ClassImage(0), + m_Status(0), + m_ProblemNumber(0), + m_OverlayImage(0) +{ + m_DisplayName[0] = UNICODE_NULL; + CopyMemory(&m_ClassGuid, &GUID_NULL, sizeof(GUID)); +} + +CNode::~CNode() +{ + Cleanup(); +} + +bool +CNode::Setup() +{ + // TODO: Make this polymorphic + + if (m_NodeType == NodeClass) + { + return SetupClassNode(); + } + else if (m_NodeType == NodeDevice) + { + return SetupDeviceNode(); + } + + return FALSE; +} + +bool +CNode::HasProperties() +{ + return (m_DeviceId != NULL); +} + +bool +CNode::IsHidden() +{ + return ((m_Status & DN_NO_SHOW_IN_DM) != 0); +} + +bool +CNode::CanDisable() +{ + return (m_NodeType == NodeDevice && ((m_Status & DN_DISABLEABLE) != 0)); +} + +bool +CNode::IsDisabled() +{ + return ((m_ProblemNumber & (CM_PROB_DISABLED | CM_PROB_HARDWARE_DISABLED)) != 0); +} + +bool +CNode::IsStarted() +{ + return ((m_Status & DN_STARTED) != 0); +} + +bool +CNode::IsInstalled() +{ + return ((m_Status & DN_HAS_PROBLEM) != 0 || + (m_Status & (DN_DRIVER_LOADED | DN_STARTED)) != 0); +} + + +/* PRIVATE METHODS ******************************************/ + +bool +CNode::SetupClassNode() +{ + DWORD RequiredSize, Type, Size; + DWORD Success; + HKEY hKey; + + // Open the registry key for this class + hKey = SetupDiOpenClassRegKeyExW(&m_ClassGuid, + MAXIMUM_ALLOWED, + DIOCR_INSTALLER, + NULL, + 0); + if (hKey != INVALID_HANDLE_VALUE) + { + Size = DISPLAY_NAME_LEN; + Type = REG_SZ; + + // Lookup the class description (win7+) + Success = RegQueryValueExW(hKey, + L"ClassDesc", + NULL, + &Type, + (LPBYTE)m_DisplayName, + &Size); + if (Success == ERROR_SUCCESS) + { + // Check if the string starts with an @ + if (m_DisplayName[0] == L'@') + { + // The description is located in a module resource + Success = ConvertResourceDescriptorToString(m_DisplayName, DISPLAY_NAME_LEN); + } + } + else if (Success == ERROR_FILE_NOT_FOUND) + { + // WinXP stores the description in the default value + Success = RegQueryValueExW(hKey, + NULL, + NULL, + &Type, + (LPBYTE)m_DisplayName, + &Size); + } + + // Close the registry key + RegCloseKey(hKey); + } + else + { + Success = GetLastError(); + } + + // Check if we failed to get the class description + if (Success != ERROR_SUCCESS) + { + // Use the class name as the description + RequiredSize = DISPLAY_NAME_LEN; + (VOID)SetupDiClassNameFromGuidW(&m_ClassGuid, + m_DisplayName, + RequiredSize, + &RequiredSize); + } + + // Get the image index for this class + (VOID)SetupDiGetClassImageIndex(m_ImageListData, + &m_ClassGuid, + &m_ClassImage); + + return true; +} + +bool +CNode::SetupDeviceNode() +{ + WCHAR ClassGuidString[MAX_GUID_STRING_LEN]; + ULONG ulLength; + CONFIGRET cr; + +// ATLASSERT(m_DeviceId == NULL); + + // Get the length of the device id string + cr = CM_Get_Device_ID_Size(&ulLength, m_DevInst, 0); + if (cr == CR_SUCCESS) + { + // We alloc heap here because this will be stored in the lParam of the TV + m_DeviceId = (LPWSTR)HeapAlloc(GetProcessHeap(), + 0, + (ulLength + 1) * sizeof(WCHAR)); + if (m_DeviceId) + { + // Now get the actual device id + cr = CM_Get_Device_IDW(m_DevInst, + m_DeviceId, + ulLength + 1, + 0); + if (cr != CR_SUCCESS) + { + HeapFree(GetProcessHeap(), 0, m_DeviceId); + m_DeviceId = NULL; + } + } + } + + // Make sure we got the string + if (m_DeviceId == NULL) + return false; + + // Get the current status of the device + cr = CM_Get_DevNode_Status_Ex(&m_Status, + &m_ProblemNumber, + m_DevInst, + 0, + NULL); + if (cr != CR_SUCCESS) + { + HeapFree(GetProcessHeap(), 0, m_DeviceId); + m_DeviceId = NULL; + return false; + } + + // Check if the device has a problem + if (m_Status & DN_HAS_PROBLEM) + { + m_OverlayImage = 1; + } + + // The disabled overlay takes precidence over the problem overlay + if (m_ProblemNumber & (CM_PROB_DISABLED | CM_PROB_HARDWARE_DISABLED)) + { + m_OverlayImage = 2; + } + + + // Get the class guid for this device + ulLength = MAX_GUID_STRING_LEN * sizeof(WCHAR); + cr = CM_Get_DevNode_Registry_PropertyW(m_DevInst, + CM_DRP_CLASSGUID, + NULL, + ClassGuidString, + &ulLength, + 0); + if (cr == CR_SUCCESS) + { + // Convert the string to a proper guid + CLSIDFromString(ClassGuidString, &m_ClassGuid); + } + else + { + // It's a device with no driver + m_ClassGuid = GUID_DEVCLASS_UNKNOWN; + } + + + // Get the image for the class this device is in + SetupDiGetClassImageIndex(m_ImageListData, + &m_ClassGuid, + &m_ClassImage); + + // Get the description for the device + ulLength = DISPLAY_NAME_LEN * sizeof(WCHAR); + cr = CM_Get_DevNode_Registry_PropertyW(m_DevInst, + CM_DRP_FRIENDLYNAME, + NULL, + m_DisplayName, + &ulLength, + 0); + if (cr != CR_SUCCESS) + { + ulLength = DISPLAY_NAME_LEN * sizeof(WCHAR); + cr = CM_Get_DevNode_Registry_PropertyW(m_DevInst, + CM_DRP_DEVICEDESC, + NULL, + m_DisplayName, + &ulLength, + 0); + + } + + // Cleanup if something failed + if (cr != CR_SUCCESS) + { + HeapFree(GetProcessHeap(), 0, m_DeviceId); + m_DeviceId = NULL; + } + + return (cr == CR_SUCCESS ? true : false); +} + +void +CNode::Cleanup() +{ + if (m_DeviceId) + { + HeapFree(GetProcessHeap(), 0, m_DeviceId); + m_DeviceId = NULL; + } +} + +DWORD +CNode::ConvertResourceDescriptorToString( + _Inout_z_ LPWSTR ResourceDescriptor, + _In_ DWORD ResourceDescriptorSize +) +{ + WCHAR ModulePath[MAX_PATH]; + WCHAR ResString[256]; + INT ResourceId; + HMODULE hModule; + LPWSTR ptr; + DWORD Size; + DWORD dwError; + + + // First check for a semi colon */ + ptr = wcschr(ResourceDescriptor, L';'); + if (ptr) + { + // This must be an inf based descriptor, the desc is after the semi colon + wcscpy_s(ResourceDescriptor, ResourceDescriptorSize, ++ptr); + dwError = ERROR_SUCCESS; + } + else + { + // This must be a dll resource based descriptor. Find the comma + ptr = wcschr(ResourceDescriptor, L','); + if (ptr == NULL) return ERROR_INVALID_DATA; + + // Terminate the string where the comma was + *ptr = UNICODE_NULL; + + // Expand any environment strings + Size = ExpandEnvironmentStringsW(&ResourceDescriptor[1], ModulePath, MAX_PATH); + if (Size > MAX_PATH) return ERROR_BUFFER_OVERFLOW; + if (Size == 0) return GetLastError(); + + // Put the comma back and move past it + *ptr = L','; + ptr++; + + // Load the dll + hModule = LoadLibraryExW(ModulePath, NULL, LOAD_LIBRARY_AS_DATAFILE); + if (hModule == NULL) return GetLastError(); + + // Convert the resource id to a number + ResourceId = _wtoi(ptr); + + // If the number is negative, make it positive + if (ResourceId < 0) ResourceId = -ResourceId; + + // Load the string from the dll + if (LoadStringW(hModule, ResourceId, ResString, 256)) + { + wcscpy_s(ResourceDescriptor, ResourceDescriptorSize, ResString); + dwError = ERROR_SUCCESS; + } + else + { + dwError = GetLastError(); + } + + // Free the library + FreeLibrary(hModule); + } + + return dwError; +} Propchange: trunk/reactos/dll/win32/devmgr/devmgmt/Node.cpp ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/dll/win32/devmgr/devmgmt/Node.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/N…
============================================================================== --- trunk/reactos/dll/win32/devmgr/devmgmt/Node.h (added) +++ trunk/reactos/dll/win32/devmgr/devmgmt/Node.h [iso-8859-1] Tue Jun 16 21:13:28 2015 @@ -0,0 +1,78 @@ +#pragma once + +#define DISPLAY_NAME_LEN 256 +#define ROOT_NAME_SIZE MAX_COMPUTERNAME_LENGTH + 1 + +enum NodeType +{ + NodeClass, + NodeDevice +}; + +typedef ULONG Actions; +#define Update 0x01 +#define Enable 0x02 +#define Disable 0x04 +#define Uninstall 0x08 + + +class CNode +{ +private: + PSP_CLASSIMAGELIST_DATA m_ImageListData; + NodeType m_NodeType; + DEVINST m_DevInst; + Actions m_Actions; + LPWSTR m_DeviceId; + WCHAR m_DisplayName[DISPLAY_NAME_LEN]; + GUID m_ClassGuid; + INT m_ClassImage; + ULONG m_Status; + ULONG m_ProblemNumber; + INT m_OverlayImage; + +public: + CNode( + _In_ LPGUID ClassGuid, + _In_ PSP_CLASSIMAGELIST_DATA ImageListData + ); + + CNode( + _In_ DEVINST Device, + _In_ PSP_CLASSIMAGELIST_DATA ImageListData + ); + + ~CNode(); + + bool Setup(); + + LPGUID GetClassGuid() { return &m_ClassGuid; } + DEVINST GetDeviceInst() { return m_DevInst; } + + LPWSTR GetDisplayName() { return m_DisplayName; } + INT GetClassImage() { return m_ClassImage; } + INT GetOverlayImage() { return m_OverlayImage; } + LPWSTR GetDeviceId() { return m_DeviceId; } + Actions GetActions() { return m_Actions; } + + bool HasProblem() { return !!(m_ProblemNumber); } + bool HasProperties(); + bool IsHidden(); + bool CanDisable(); + bool IsDisabled(); + bool IsStarted(); + bool IsInstalled(); + bool CanInstall() { return TRUE; } // unimplemented + bool CanUninstall() { return TRUE; } // unimplemented + +private: + bool SetupClassNode(); + bool SetupDeviceNode(); + void Cleanup(); + + DWORD ConvertResourceDescriptorToString( + _Inout_z_ LPWSTR ResourceDescriptor, + _In_ DWORD ResourceDescriptorSize + ); +}; + Propchange: trunk/reactos/dll/win32/devmgr/devmgmt/Node.h ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/dll/win32/devmgr/devmgmt/Resource.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/R…
============================================================================== --- trunk/reactos/dll/win32/devmgr/devmgmt/Resource.h (added) +++ trunk/reactos/dll/win32/devmgr/devmgmt/Resource.h [iso-8859-1] Tue Jun 16 21:13:28 2015 @@ -0,0 +1,63 @@ +#define IDC_STATIC -1 + +#define IDI_MAIN_ICON 20 +#define IDB_ROOT_IMAGE 21 +#define IDB_TOOLBAR 22 + +/* windows */ +#define IDC_TREEVIEW 50 +#define IDC_TOOLBAR 51 +#define IDC_STATUSBAR 52 +#define IDR_MAINMENU 53 +#define IDR_POPUP 54 + +/* Actions */ +#define IDC_PROPERTIES 100 +#define IDC_SCAN_HARDWARE 101 +#define IDC_ENABLE_DRV 102 +#define IDC_DISABLE_DRV 103 +#define IDC_UPDATE_DRV 104 +#define IDC_UNINSTALL_DRV 105 +#define IDC_ADD_HARDWARE 106 +#define IDC_ABOUT 107 +#define IDC_EXIT 108 + +/* view menu */ +#define IDC_DEVBYTYPE 200 +#define IDC_DEVBYCONN 201 +#define IDC_RESBYTYPE 202 +#define IDC_RESBYCONN 203 +#define IDC_SHOWHIDDEN 204 + +/* about box info */ +#define IDD_ABOUTBOX 300 +#define IDC_LICENSE_EDIT 301 +#define IDS_APPNAME 302 +#define IDS_LICENSE 303 + +/* tooltips */ +#define IDS_TOOLTIP_PROP 6000 +#define IDS_TOOLTIP_REFRESH 6001 +#define IDS_TOOLTIP_HELP 6002 + +/* menu hints */ +#define IDS_HINT_BLANK 20000 +#define IDS_HINT_REFRESH 20002 +#define IDS_HINT_PROP 20003 +#define IDS_HINT_HELP 20004 +#define IDS_HINT_ABOUT 20005 +#define IDS_HINT_EXIT 20006 + +#define IDS_HINT_DEV_BY_TYPE 20020 +#define IDS_HINT_DEV_BY_CONN 20021 +#define IDS_HINT_RES_BY_TYPE 20022 +#define IDS_HINT_RES_BY_CONN 20023 + +/* system menu hints */ +#define IDS_HINT_SYS_RESTORE 21001 +#define IDS_HINT_SYS_MOVE 21002 +#define IDS_HINT_SYS_SIZE 21003 +#define IDS_HINT_SYS_MINIMIZE 21004 +#define IDS_HINT_SYS_MAXIMIZE 21005 +#define IDS_HINT_SYS_CLOSE 21006 + Propchange: trunk/reactos/dll/win32/devmgr/devmgmt/Resource.h ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/dll/win32/devmgr/devmgmt/devmgmt.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/d…
============================================================================== --- trunk/reactos/dll/win32/devmgr/devmgmt/devmgmt.h (added) +++ trunk/reactos/dll/win32/devmgr/devmgmt/devmgmt.h [iso-8859-1] Tue Jun 16 21:13:28 2015 @@ -0,0 +1,9 @@ +#pragma once +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#pragma once +#include "resource.h" + +extern HINSTANCE g_hInstance; +extern HANDLE ProcessHeap; + Propchange: trunk/reactos/dll/win32/devmgr/devmgmt/devmgmt.h ------------------------------------------------------------------------------ svn:eol-style = native Propchange: trunk/reactos/dll/win32/devmgr/devmgmt/lang/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Tue Jun 16 21:13:28 2015 @@ -0,0 +1 @@ +((CORE|ROSTESTS|ROSAPPS)-\d+)(,? ?((CORE|ROSTESTS|ROSAPPS)-\d+))*(,? ?(and |or )?((CORE|ROSTESTS|ROSAPPS)-\d+))? Propchange: trunk/reactos/dll/win32/devmgr/devmgmt/lang/ ------------------------------------------------------------------------------ bugtraq:message = See issue %BUGID% for more details. Propchange: trunk/reactos/dll/win32/devmgr/devmgmt/lang/ ------------------------------------------------------------------------------ bugtraq:url =
https://jira.reactos.org/browse/%BUGID%
Propchange: trunk/reactos/dll/win32/devmgr/devmgmt/lang/ ------------------------------------------------------------------------------ tsvn:logminsize = 10 Added: trunk/reactos/dll/win32/devmgr/devmgmt/lang/en-US.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/l…
============================================================================== --- trunk/reactos/dll/win32/devmgr/devmgmt/lang/en-US.rc (added) +++ trunk/reactos/dll/win32/devmgr/devmgmt/lang/en-US.rc [iso-8859-1] Tue Jun 16 21:13:28 2015 @@ -0,0 +1,72 @@ +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +IDR_MAINMENU MENU +BEGIN + POPUP "&File" + BEGIN + MENUITEM "E&xit", IDC_EXIT + END + POPUP "Action" + BEGIN + MENUITEM "Update driver software..." IDC_UPDATE_DRV + MENUITEM "Disable" IDC_DISABLE_DRV + MENUITEM "Uninstall" IDC_UNINSTALL_DRV + MENUITEM SEPARATOR + MENUITEM "Scan for hardware changes" IDC_SCAN_HARDWARE + MENUITEM "Add hardware" IDC_ADD_HARDWARE, GRAYED + MENUITEM SEPARATOR + MENUITEM "Properties", IDC_PROPERTIES + END + POPUP "View" + BEGIN + MENUITEM "Devices by type", IDC_DEVBYTYPE + MENUITEM "Devices by connection", IDC_DEVBYCONN + MENUITEM "Resources by type", IDC_RESBYTYPE, GRAYED + MENUITEM "Resources by connection", IDC_RESBYCONN, GRAYED + MENUITEM SEPARATOR + MENUITEM "Show hidden devices", IDC_SHOWHIDDEN + END + POPUP "Help" + BEGIN + MENUITEM "About", IDC_ABOUT + END +END + +IDR_POPUP MENU +BEGIN + POPUP "popup" + BEGIN + MENUITEM "Properties", IDC_PROPERTIES, GRAYED + END +END + +STRINGTABLE DISCARDABLE +BEGIN + IDS_TOOLTIP_PROP "Properties" + IDS_TOOLTIP_REFRESH "Scan for hardware changes" + IDS_TOOLTIP_HELP "Help" +END + +/* Hints */ +STRINGTABLE DISCARDABLE +BEGIN + IDS_APPNAME "ReactOS Device Manager" + IDS_HINT_BLANK " " + IDS_HINT_EXIT " Exits the program." + IDS_HINT_REFRESH " Scan for changed or new Plug and Play devices." + IDS_HINT_PROP " Open property dialog for the current selection." + IDS_HINT_HELP " Display help window." + IDS_HINT_ABOUT " About ReactOS Device Manager." + + IDS_HINT_DEV_BY_TYPE "Displays devices by hardware type" + IDS_HINT_DEV_BY_CONN "Displays devices by connection" + IDS_HINT_RES_BY_TYPE "Diaplays resources by type" + IDS_HINT_RES_BY_CONN "Displays resources by connection type" + + IDS_HINT_SYS_RESTORE " Restores this window to normal size." + IDS_HINT_SYS_MOVE " Moves this window." + IDS_HINT_SYS_SIZE " Resizes this window." + IDS_HINT_SYS_MINIMIZE " Collapses this window to an icon." + IDS_HINT_SYS_MAXIMIZE " Expands this window to fill this screen." + IDS_HINT_SYS_CLOSE " Closes this window." +END Propchange: trunk/reactos/dll/win32/devmgr/devmgmt/lang/en-US.rc ------------------------------------------------------------------------------ svn:eol-style = native Propchange: trunk/reactos/dll/win32/devmgr/devmgmt/res/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Tue Jun 16 21:13:28 2015 @@ -0,0 +1 @@ +((CORE|ROSTESTS|ROSAPPS)-\d+)(,? ?((CORE|ROSTESTS|ROSAPPS)-\d+))*(,? ?(and |or )?((CORE|ROSTESTS|ROSAPPS)-\d+))? Propchange: trunk/reactos/dll/win32/devmgr/devmgmt/res/ ------------------------------------------------------------------------------ bugtraq:message = See issue %BUGID% for more details. Propchange: trunk/reactos/dll/win32/devmgr/devmgmt/res/ ------------------------------------------------------------------------------ bugtraq:url =
https://jira.reactos.org/browse/%BUGID%
Propchange: trunk/reactos/dll/win32/devmgr/devmgmt/res/ ------------------------------------------------------------------------------ tsvn:logminsize = 10 Added: trunk/reactos/dll/win32/devmgr/devmgmt/res/computer.ico URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/r…
============================================================================== Binary file - no diff available. Propchange: trunk/reactos/dll/win32/devmgr/devmgmt/res/computer.ico ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: trunk/reactos/dll/win32/devmgr/devmgmt/res/root.bmp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/r…
============================================================================== Binary file - no diff available. Propchange: trunk/reactos/dll/win32/devmgr/devmgmt/res/root.bmp ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: trunk/reactos/dll/win32/devmgr/devmgmt/res/toolbar.bmp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/r…
============================================================================== Binary file - no diff available. Propchange: trunk/reactos/dll/win32/devmgr/devmgmt/res/toolbar.bmp ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: trunk/reactos/dll/win32/devmgr/devmgmt/rsrc.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/r…
============================================================================== --- trunk/reactos/dll/win32/devmgr/devmgmt/rsrc.rc (added) +++ trunk/reactos/dll/win32/devmgr/devmgmt/rsrc.rc [iso-8859-1] Tue Jun 16 21:13:28 2015 @@ -0,0 +1,80 @@ +#include <windows.h> +#include "resource.h" + +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL + +IDI_MAIN_ICON ICON "res/computer.ico" +IDB_ROOT_IMAGE BITMAP "res/root.bmp" + +/* main toolbar icons */ +IDB_TOOLBAR BITMAP DISCARDABLE "res/toolbar.bmp" + +// UTF-8 +#pragma code_page(65001) + +#ifdef LANGUAGE_BG_BG + #include "lang/bg-BG.rc" +#endif +#ifdef LANGUAGE_DE_DE + #include "lang/de-DE.rc" +#endif +#ifdef LANGUAGE_EL_GR + #include "lang/el-GR.rc" +#endif +#ifdef LANGUAGE_EN_US + #include "lang/en-US.rc" +#endif +#ifdef LANGUAGE_ES_ES + #include "lang/es-ES.rc" +#endif +#ifdef LANGUAGE_FR_FR + #include "lang/fr-FR.rc" +#endif +#ifdef LANGUAGE_HE_IL + #include "lang/he-IL.rc" +#endif +#ifdef LANGUAGE_ID_ID + #include "lang/id-ID.rc" +#endif +#ifdef LANGUAGE_IT_IT + #include "lang/it-IT.rc" +#endif +#ifdef LANGUAGE_JA_JP + #include "lang/ja-JP.rc" +#endif +#ifdef LANGUAGE_KO_KR + #include "lang/ko-KR.rc" +#endif +#ifdef LANGUAGE_NB_NO + #include "lang/no-NO.rc" +#endif +#ifdef LANGUAGE_PL_PL + #include "lang/pl-PL.rc" +#endif +#ifdef LANGUAGE_PT_BR + #include "lang/pt-BR.rc" +#endif +#ifdef LANGUAGE_RO_RO + #include "lang/ro-RO.rc" +#endif +#ifdef LANGUAGE_RU_RU + #include "lang/ru-RU.rc" +#endif +#ifdef LANGUAGE_SK_SK + #include "lang/sk-SK.rc" +#endif +#ifdef LANGUAGE_SV_SE + #include "lang/sv-SE.rc" +#endif +#ifdef LANGUAGE_TH_TH + #include "lang/th-TH.rc" +#endif +#ifdef LANGUAGE_TR_TR + #include "lang/tr-TR.rc" +#endif +#ifdef LANGUAGE_UK_UA + #include "lang/uk-UA.rc" +#endif +#ifdef LANGUAGE_ZH_CN + #include "lang/zh-CN.rc" +#endif Propchange: trunk/reactos/dll/win32/devmgr/devmgmt/rsrc.rc ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/dll/win32/devmgr/devmgmt/stdafx.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/s…
============================================================================== --- trunk/reactos/dll/win32/devmgr/devmgmt/stdafx.h (added) +++ trunk/reactos/dll/win32/devmgr/devmgmt/stdafx.h [iso-8859-1] Tue Jun 16 21:13:28 2015 @@ -0,0 +1,50 @@ +#pragma once + +#ifndef __REACTOS___ + +#define WIN32_LEAN_AND_MEAN +#include <Windows.h> +#include <windowsx.h> +#include <setupapi.h> +#include <cfgmgr32.h> +#include <commctrl.h> +#include <Uxtheme.h> +#include <Cfgmgr32.h> +#include <devguid.h> +#include <process.h> + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit +#include <tchar.h> +#include <atlbase.h> +#include <atlstr.h> +#include <atlcoll.h> + +#else + +#include <tchar.h> + +#include <windef.h> +#include <winbase.h> +#include <winreg.h> +#include <wingdi.h> +#include <winnls.h> +#include <wincon.h> +#include <shlobj.h> +#include <shlwapi.h> +#include <strsafe.h> +#include <process.h> + +#include <string.h> +#include <wchar.h> + +#include <setupapi.h> +#include <commctrl.h> +#include <cfgmgr32.h> +#include <Uxtheme.h> + +#include <atlbase.h> +#include <atlcom.h> +#include <atlwin.h> +#include <atlstr.h> + +#endif Propchange: trunk/reactos/dll/win32/devmgr/devmgmt/stdafx.h ------------------------------------------------------------------------------ svn:eol-style = native
9 years, 6 months
1
0
0
0
[gedmurphy] 68164: [DEVMGMT] Add the icon back
by gedmurphy@svn.reactos.org
Author: gedmurphy Date: Tue Jun 16 12:45:24 2015 New Revision: 68164 URL:
http://svn.reactos.org/svn/reactos?rev=68164&view=rev
Log: [DEVMGMT] Add the icon back Added: trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt.ico (with props) Modified: trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt.rc Added: trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt.ico URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== Binary file - no diff available. Propchange: trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt.ico ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Modified: trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== Binary files - no diff available.
9 years, 6 months
1
0
0
0
[gedmurphy] 68163: [DEVMGMT] The new device manager will be located in devmgr.dll
by gedmurphy@svn.reactos.org
Author: gedmurphy Date: Tue Jun 16 12:22:14 2015 New Revision: 68163 URL:
http://svn.reactos.org/svn/reactos?rev=68163&view=rev
Log: [DEVMGMT] The new device manager will be located in devmgr.dll Added: trunk/reactos/base/applications/mscutils/devmgmt_new/CMakeLists.txt (with props) Removed: trunk/reactos/base/applications/mscutils/devmgmt_new/DeviceView.cpp trunk/reactos/base/applications/mscutils/devmgmt_new/DeviceView.h trunk/reactos/base/applications/mscutils/devmgmt_new/Devices.cpp trunk/reactos/base/applications/mscutils/devmgmt_new/Devices.h trunk/reactos/base/applications/mscutils/devmgmt_new/MainWindow.cpp trunk/reactos/base/applications/mscutils/devmgmt_new/MainWindow.h trunk/reactos/base/applications/mscutils/devmgmt_new/Resource.h trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt.exe.manifest trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt_new.sln trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt_new.vcxproj trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt_new.vcxproj.filters trunk/reactos/base/applications/mscutils/devmgmt_new/lang/ trunk/reactos/base/applications/mscutils/devmgmt_new/precomp.h trunk/reactos/base/applications/mscutils/devmgmt_new/res/ trunk/reactos/base/applications/mscutils/devmgmt_new/rsrc.rc trunk/reactos/base/applications/mscutils/devmgmt_new/stdafx.cpp trunk/reactos/base/applications/mscutils/devmgmt_new/stdafx.h trunk/reactos/base/applications/mscutils/devmgmt_new/targetver.h Modified: trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt.cpp trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt.h trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt.rc Added: trunk/reactos/base/applications/mscutils/devmgmt_new/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/devmgmt_new/CMakeLists.txt (added) +++ trunk/reactos/base/applications/mscutils/devmgmt_new/CMakeLists.txt [iso-8859-1] Tue Jun 16 12:22:14 2015 @@ -0,0 +1,8 @@ + +list(APPEND SOURCE + devmgmt.cpp) + +add_executable(devmgmt ${SOURCE} devmgmt.rc) +set_module_type(devmgmt win32gui UNICODE) +add_importlibs(devmgmt setupapi gdi32 user32 comctl32 advapi32 devmgr msvcrt kernel32) +add_cd_file(TARGET devmgmt DESTINATION reactos/system32 FOR all) Propchange: trunk/reactos/base/applications/mscutils/devmgmt_new/CMakeLists.txt ------------------------------------------------------------------------------ svn:eol-style = native Removed: trunk/reactos/base/applications/mscutils/devmgmt_new/DeviceView.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/devmgmt_new/DeviceView.cpp [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/devmgmt_new/DeviceView.cpp (removed) @@ -1,686 +0,0 @@ -/* -* PROJECT: ReactOS Device Manager -* LICENSE: GPL - See COPYING in the top level directory -* FILE: base/applications/mscutils/devmgmt/deviceview.cpp -* PURPOSE: Implements the tree view which holds the devices -* COPYRIGHT: Copyright 2014 Ged Murphy <gedmurphy(a)gmail.com> -* -*/ - - -#include "stdafx.h" -#include "devmgmt.h" -#include "DeviceView.h" - - -/* DATA *********************************************/ - -#define DEVICE_NAME_LEN 256 -#define CLASS_NAME_LEN 256 -#define CLASS_DESC_LEN 256 - -INT_PTR -WINAPI -DevicePropertiesExW( - IN HWND hWndParent OPTIONAL, - IN LPCWSTR lpMachineName OPTIONAL, - IN LPCWSTR lpDeviceID OPTIONAL, - IN DWORD dwFlags OPTIONAL, - IN BOOL bShowDevMgr -); - -typedef INT_PTR(WINAPI *pDevicePropertiesExW)(HWND,LPCWSTR,LPCWSTR,DWORD,BOOL); - - -/* PUBLIC METHODS *************************************/ - -CDeviceView::CDeviceView( - HWND hMainWnd, - ListDevices List - ) : - m_Devices(NULL), - m_hMainWnd(hMainWnd), - m_hTreeView(NULL), - m_hPropertyDialog(NULL), - m_hShortcutMenu(NULL), - m_ListDevices(List), - m_ShowHidden(FALSE) -{ - m_Devices = new CDevices(); -} - -CDeviceView::~CDeviceView(void) -{ - delete m_Devices; - m_Devices = NULL; - - DestroyMenu(m_hShortcutMenu); -} - -BOOL -CDeviceView::Initialize() -{ - BOOL bSuccess; - - /* Initialize the devices class */ - bSuccess = m_Devices->Initialize(); - if (bSuccess == FALSE) return FALSE; - - /* Create Popup Menu */ - m_hShortcutMenu = LoadMenu(g_hInstance, - MAKEINTRESOURCE(IDR_POPUP)); - m_hShortcutMenu = GetSubMenu(m_hShortcutMenu, - 0); - SetMenuDefaultItem(m_hShortcutMenu, IDC_PROP, FALSE); - - - /* Create the main treeview */ - m_hTreeView = CreateWindowExW(WS_EX_CLIENTEDGE, - WC_TREEVIEW, - NULL, - WS_CHILD | WS_VISIBLE | WS_BORDER | TVS_HASLINES | - TVS_HASBUTTONS | TVS_SHOWSELALWAYS | TVS_LINESATROOT, - 0, 0, 0, 0, - m_hMainWnd, - (HMENU)IDC_TREEVIEW, - g_hInstance, - NULL); - if (m_hTreeView) - { - /* Get the devices image list */ - m_ImageList = m_Devices->GetImageList(); - - /* Set the image list against the treeview */ - (VOID)TreeView_SetImageList(m_hTreeView, - m_ImageList, - TVSIL_NORMAL); - - /* Give the treeview arrows instead of +/- boxes (on Win7) */ - SetWindowTheme(m_hTreeView, L"explorer", NULL); - } - - return !!(m_hTreeView); -} - -BOOL -CDeviceView::Uninitialize() -{ - EmptyDeviceView(); - - (VOID)m_Devices->Uninitialize(); - - return TRUE; -} - -BOOL CDeviceView::HasChildItem( - _In_ HTREEITEM Item) -{ - return (TreeView_GetChild(m_hTreeView, Item) != NULL); -} - -BOOL CDeviceView::IsRootItem( - _In_ HTREEITEM Item) -{ - return (TreeView_GetRoot(m_hTreeView) == Item); -} - -BOOL CDeviceView::IsRootItemSelected() -{ - return (TreeView_GetRoot(m_hTreeView) == TreeView_GetSelection(m_hTreeView)); -} - -VOID CDeviceView::EnableContextMenuItem( - _In_ UINT Id, - _In_ UINT Enabled) -{ - EnableMenuItem(m_hShortcutMenu, Id, Enabled); -} - -VOID -CDeviceView::ShowContextMenu( - _In_ INT xPos, - _In_ INT yPos) -{ - HTREEITEM hSelected; - POINT pt; - RECT rc; - - hSelected = TreeView_GetSelection(m_hTreeView); - - if (TreeView_GetItemRect(m_hTreeView, - hSelected, - &rc, - TRUE)) - { - if (GetCursorPos(&pt) && - ScreenToClient(m_hTreeView, &pt) && - PtInRect(&rc, pt)) - { - TrackPopupMenuEx(m_hShortcutMenu, - TPM_RIGHTBUTTON, - xPos, - yPos, - m_hMainWnd, - NULL); - } - } -} - -VOID -CDeviceView::Size( - _In_ INT x, - _In_ INT y, - _In_ INT cx, - _In_ INT cy - ) -{ - /* Resize the treeview */ - SetWindowPos(m_hTreeView, - NULL, - x, - y, - cx, - cy, - SWP_NOZORDER); -} - - -VOID -CDeviceView::Refresh() -{ - HANDLE hThread; - - /* Run on a new thread to keep the gui responsive */ - hThread = (HANDLE)_beginthreadex(NULL, - 0, - &ListDevicesThread, - this, - 0, - NULL); - - if (hThread) CloseHandle(hThread); -} - -VOID -CDeviceView::DisplayPropertySheet() -{ -#ifndef __REACTOS__ - pDevicePropertiesExW DevicePropertiesExW; - HMODULE hModule; - - hModule = LoadLibraryW(L"devmgr.dll"); - if (hModule == NULL) return; - - DevicePropertiesExW = (pDevicePropertiesExW)GetProcAddress(hModule, - "DevicePropertiesExW"); - if (DevicePropertiesExW == NULL) - { - FreeLibrary(hModule); - return; - } -#endif - - TV_ITEM tvItem; - - tvItem.hItem = TreeView_GetSelection(m_hTreeView); - tvItem.mask = TVIF_PARAM; - - if (TreeView_GetItem(m_hTreeView, &tvItem) && - (LPTSTR)tvItem.lParam != NULL) - { - DevicePropertiesExW(m_hTreeView, - NULL, - (LPTSTR)tvItem.lParam, - 1,//DPF_EXTENDED, - FALSE); - } - -#ifndef __REACTOS__ - FreeLibrary(hModule); -#endif -} - -VOID -CDeviceView::SetFocus() -{ -} - - -/* PRIVATE METHODS ********************************************/ - -unsigned int __stdcall CDeviceView::ListDevicesThread(void *Param) -{ - CDeviceView *This = (CDeviceView *)Param; - - /* Clear any existing data */ - This->EmptyDeviceView(); - - /* Reset the tree root */ - This->m_hTreeRoot = NULL; - - switch (This->m_ListDevices) - { - case DevicesByType: - (VOID)This->ListDevicesByType(); - break; - - case DevicesByConnection: - (VOID)This->ListDevicesByConnection(); - break; - - case ResourcesByType: - break; - - case ResourcesByConnection: - break; - } - return 0; -} - - -BOOL -CDeviceView::ListDevicesByType() -{ - HTREEITEM hDevItem = NULL; - GUID ClassGuid; - WCHAR ClassName[CLASS_NAME_LEN]; - WCHAR ClassDescription[CLASS_DESC_LEN]; - INT ClassIndex; - INT ClassImage; - LPTSTR DeviceId = NULL; - BOOL bSuccess; - - - /* Get the details of the root of the device tree */ - bSuccess = m_Devices->GetDeviceTreeRoot(ClassName, CLASS_NAME_LEN, &ClassImage); - if (bSuccess) - { - /* Add the root of the device tree to the treeview */ - m_hTreeRoot = InsertIntoTreeView(NULL, - ClassName, - NULL, - ClassImage, - 0); - } - - /* If something went wrong, bail */ - if (m_hTreeRoot == NULL) return FALSE; - - ClassIndex = 0; - do - { - /* Get the next device class */ - bSuccess = m_Devices->EnumClasses(ClassIndex, - &ClassGuid, - ClassName, - CLASS_NAME_LEN, - ClassDescription, - CLASS_DESC_LEN, - &ClassImage); - if (bSuccess) - { - BOOL bDevSuccess, AddedParent; - HANDLE Handle = NULL; - WCHAR DeviceName[DEVICE_NAME_LEN]; - INT DeviceIndex = 0; - BOOL MoreItems = FALSE; - BOOL DeviceHasProblem = FALSE; - ULONG DeviceStatus = 0; - ULONG ProblemNumber = 0; - ULONG OverlayImage = 0; - - AddedParent = FALSE; - - do - { - /* Enum all the devices that belong to this class */ - bDevSuccess = m_Devices->EnumDevicesForClass(&Handle, - &ClassGuid, - DeviceIndex, - &MoreItems, - DeviceName, - DEVICE_NAME_LEN, - &DeviceId, - &DeviceStatus, - &ProblemNumber); - if (bDevSuccess) - { - /* Check if this is a hidden device */ - if (DeviceStatus & DN_NO_SHOW_IN_DM) - { - if (m_ShowHidden == FALSE) - { - DeviceIndex++; - continue; - } - } - - /* Check if the device has a problem */ - if (DeviceStatus & DN_HAS_PROBLEM) - { - DeviceHasProblem = TRUE; - OverlayImage = 1; - } - - /* The disabled overlay takes precidence over the problem overlay */ - if (ProblemNumber == CM_PROB_HARDWARE_DISABLED) - { - OverlayImage = 2; - } - - - /* We have a device, we're gonna need to add the parent first */ - if (AddedParent == FALSE) - { - /* Insert the new class under the root item */ - hDevItem = InsertIntoTreeView(m_hTreeRoot, - ClassDescription, - NULL, - ClassImage, - 0); - - /* Don't add it again */ - AddedParent = TRUE; - } - - /* Add the device under the class item */ - (VOID)InsertIntoTreeView(hDevItem, - DeviceName, - (LPARAM)DeviceId, - ClassImage, - OverlayImage); - - /* Check if there's a problem with the device */ - if (DeviceHasProblem) - { - /* Expand the class */ - (VOID)TreeView_Expand(m_hTreeView, - hDevItem, - TVE_EXPAND); - } - } - - DeviceIndex++; - - } while (MoreItems); - - /* Check if this class has any devices */ - if (AddedParent == TRUE) - { - /* Sort the devices alphabetically */ - (VOID)TreeView_SortChildren(m_hTreeView, - hDevItem, - 0); - } - } - - ClassIndex++; - - } while (bSuccess); - - /* Sort the classes alphabetically */ - (VOID)TreeView_SortChildren(m_hTreeView, - m_hTreeRoot, - 0); - - /* Expand the root item */ - (VOID)TreeView_Expand(m_hTreeView, - m_hTreeRoot, - TVE_EXPAND); - - /* Pre-select the root item */ - (VOID)TreeView_SelectItem(m_hTreeView, - m_hTreeRoot); - - return 0; -} - -BOOL -CDeviceView::ListDevicesByConnection() -{ - WCHAR DeviceName[DEVICE_NAME_LEN]; - INT ClassImage; - BOOL bSuccess; - - /* Get the details of the root of the device tree */ - bSuccess = m_Devices->GetDeviceTreeRoot(DeviceName, DEVICE_NAME_LEN, &ClassImage); - if (bSuccess) - { - /* Add the root of the device tree to the treeview */ - m_hTreeRoot = InsertIntoTreeView(NULL, - DeviceName, - NULL, - ClassImage, - 0); - } - - /* Walk the device tree and add all the devices */ - RecurseChildDevices(m_Devices->GetRootDevice(), m_hTreeRoot); - - /* Expand the root item */ - (VOID)TreeView_Expand(m_hTreeView, - m_hTreeRoot, - TVE_EXPAND); - - return TRUE; -} - -VOID -CDeviceView::RecurseChildDevices( - _In_ DEVINST ParentDevice, - _In_ HTREEITEM hParentTreeItem - ) -{ - HTREEITEM hDevItem = NULL; - DEVINST Device; - WCHAR DeviceName[DEVICE_NAME_LEN]; - LPTSTR DeviceId = NULL; - INT ClassImage; - BOOL IsUnknown = FALSE; - BOOL IsHidden = FALSE; - ULONG DeviceStatus = 0; - ULONG ProblemNumber = 0; - UINT OverlayImage = 0; - BOOL bSuccess; - - /* Check if the parent has any child devices */ - if (m_Devices->GetChildDevice(ParentDevice, &Device) == FALSE) - return; - - /* Lookup the info about this device */ - bSuccess = m_Devices->GetDevice(Device, - DeviceName, - DEVICE_NAME_LEN, - &DeviceId, - &ClassImage, - &DeviceStatus, - &ProblemNumber); - if (bSuccess) - { - /* Check if this is a hidden device */ - if ((m_ShowHidden == TRUE) || (!(DeviceStatus & DN_NO_SHOW_IN_DM))) - { - /* Check if the device has a problem */ - if (DeviceStatus & DN_HAS_PROBLEM) - { - OverlayImage = 1; - } - - /* The disabled overlay takes precidence over the problem overlay */ - if (ProblemNumber == CM_PROB_HARDWARE_DISABLED) - { - OverlayImage = 2; - } - - /* Add this device to the tree under its parent */ - hDevItem = InsertIntoTreeView(hParentTreeItem, - DeviceName, - (LPARAM)DeviceId, - ClassImage, - 0); - - - if (hDevItem) - { - /* Check if this child has any children itself */ - RecurseChildDevices(Device, hDevItem); - } - } - } - - - for (;;) - { - /* Check if the parent device has anything at the same level */ - bSuccess = m_Devices->GetSiblingDevice(Device, &Device); - if (bSuccess == FALSE) break; - - /* Lookup the info about this device */ - bSuccess = m_Devices->GetDevice(Device, - DeviceName, - DEVICE_NAME_LEN, - &DeviceId, - &ClassImage, - &DeviceStatus, - &ProblemNumber); - if (bSuccess) - { - /* Check if this is a hidden device */ - if (DeviceStatus & DN_NO_SHOW_IN_DM) - { - if (m_ShowHidden == FALSE) - continue; - } - - /* Check if the device has a problem */ - if (DeviceStatus & DN_HAS_PROBLEM) - { - OverlayImage = 1; - } - - /* The disabled overlay takes precidence over the problem overlay */ - if (ProblemNumber == CM_PROB_HARDWARE_DISABLED) - { - OverlayImage = 2; - } - - - /* Add this device to the tree under its parent */ - hDevItem = InsertIntoTreeView(hParentTreeItem, - DeviceName, - (LPARAM)DeviceId, - ClassImage, - 0); - if (hDevItem) - { - /* Check if this child has any children itself */ - RecurseChildDevices(Device, hDevItem); - } - } - } - - (void)TreeView_SortChildren(m_hTreeView, - hParentTreeItem, - 0); -} - - HTREEITEM -CDeviceView::InsertIntoTreeView( - _In_ HTREEITEM hParent, - _In_z_ LPWSTR lpLabel, - _In_ LPARAM lParam, - _In_ INT DevImage, - _In_ UINT OverlayImage - ) -{ - TV_ITEMW tvi; - TV_INSERTSTRUCT tvins; - - ZeroMemory(&tvi, sizeof(tvi)); - ZeroMemory(&tvins, sizeof(tvins)); - - tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE; - tvi.pszText = lpLabel; - tvi.cchTextMax = wcslen(lpLabel); - tvi.lParam = lParam; - tvi.iImage = DevImage; - tvi.iSelectedImage = DevImage; - - if (OverlayImage != 0) - { - tvi.mask |= TVIF_STATE; - tvi.stateMask = TVIS_OVERLAYMASK; - tvi.state = INDEXTOOVERLAYMASK(OverlayImage); - } - - tvins.item = tvi; - tvins.hParent = hParent; - - return TreeView_InsertItem(m_hTreeView, &tvins); -} - -VOID -CDeviceView::RecurseDeviceView( - _In_ HTREEITEM hParentItem - ) -{ - HTREEITEM hItem; - TVITEMW tvItem; - - /* Check if this node has any children */ - hItem = TreeView_GetChild(m_hTreeView, hParentItem); - if (hItem == NULL) return; - - /* The lParam contains the device id */ - tvItem.hItem = hItem; - tvItem.mask = TVIF_PARAM; - - /* Get the item data */ - if (TreeView_GetItem(m_hTreeView, &tvItem) && - tvItem.lParam != NULL) - { - /* Free the device id */ - HeapFree(GetProcessHeap(), 0, (LPVOID)tvItem.lParam); - } - - /* This node may have its own children */ - RecurseDeviceView(hItem); - - for (;;) - { - /* Get the next item at this level */ - hItem = TreeView_GetNextSibling(m_hTreeView, hItem); - if (hItem == NULL) break; - - /* The lParam contains the device id */ - tvItem.hItem = hItem; - tvItem.mask = TVIF_PARAM; - - /* Get the item data and free the device id */ - if (TreeView_GetItem(m_hTreeView, &tvItem)) - { - if (tvItem.lParam != NULL) - HeapFree(GetProcessHeap(), 0, (LPVOID)tvItem.lParam); - } - - /* This node may have its own children */ - RecurseDeviceView(hItem); - } -} - - -VOID -CDeviceView::EmptyDeviceView() -{ - HTREEITEM hItem; - - /* Check if there are any items in the tree */ - hItem = TreeView_GetRoot(m_hTreeView); - if (hItem == NULL) return; - - /* Free all the Device Ids */ - RecurseDeviceView(hItem); - - /* Delete all the items */ - (VOID)TreeView_DeleteAllItems(m_hTreeView); -} Removed: trunk/reactos/base/applications/mscutils/devmgmt_new/DeviceView.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/devmgmt_new/DeviceView.h [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/devmgmt_new/DeviceView.h (removed) @@ -1,113 +0,0 @@ -#pragma once -#include "Devices.h" - -enum ListDevices -{ - DevicesByType, - DevicesByConnection, - ResourcesByType, - ResourcesByConnection -}; - -class CDeviceView : public CDevices -{ - CDevices *m_Devices; - HWND m_hMainWnd; - HWND m_hTreeView; - HWND m_hPropertyDialog; - HMENU m_hShortcutMenu; - ListDevices m_ListDevices; - - HIMAGELIST m_ImageList; - HTREEITEM m_hTreeRoot; - - BOOL m_ShowHidden; - -public: - CDeviceView( - HWND hMainWnd, - ListDevices List - ); - - ~CDeviceView(void); - - BOOL Initialize(); - BOOL Uninitialize(); - - VOID EnableContextMenuItem( - _In_ UINT Id, - _In_ UINT Enabled - ); - - VOID ShowContextMenu( - _In_ INT xPos, - _In_ INT yPos - ); - - VOID Size( - _In_ INT x, - _In_ INT y, - _In_ INT cx, - _In_ INT cy - ); - - VOID Refresh(); - VOID DisplayPropertySheet(); - VOID SetFocus(); - - BOOL IsRootItemSelected(); - - BOOL IsRootItem( - _In_ HTREEITEM Item - ); - - BOOL HasChildItem( - _In_ HTREEITEM Item - ); - - VOID SetDeviceListType(ListDevices List) - { - m_ListDevices = List; - } - - ListDevices GetDeviceListType() - { - return m_ListDevices; - } - - VOID ShowHiddenDevices(_In_ BOOL ShowHidden) - { - m_ShowHidden = ShowHidden; - } - -private: - static unsigned int __stdcall ListDevicesThread( - void *Param - ); - - BOOL ListDevicesByConnection( - ); - BOOL ListDevicesByType( - ); - - VOID RecurseChildDevices( - _In_ DEVINST ParentDevice, - _In_ HTREEITEM hParentTreeItem - ); - - HTREEITEM InsertIntoTreeView( - _In_ HTREEITEM hParent, - _In_z_ LPWSTR lpLabel, - _In_ LPARAM lParam, - _In_ INT DevImage, - _In_ UINT OverlayImage - ); - - VOID RecurseDeviceView( - _In_ HTREEITEM hParentItem - ); - - VOID EmptyDeviceView( - ); -}; - Removed: trunk/reactos/base/applications/mscutils/devmgmt_new/Devices.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/devmgmt_new/Devices.cpp [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/devmgmt_new/Devices.cpp (removed) @@ -1,622 +0,0 @@ -/* -* PROJECT: ReactOS Device Manager -* LICENSE: GPL - See COPYING in the top level directory -* FILE: base/applications/mscutils/devmgmt/devices.cpp -* PURPOSE: Wrapper around setupapi functions -* COPYRIGHT: Copyright 2014 Ged Murphy <gedmurphy(a)gmail.com> -* -*/ - -#include "stdafx.h" -#include "devmgmt.h" -#include "Devices.h" - - -/* PUBLIC METHODS *****************************************/ - -CDevices::CDevices(void) : - m_bInitialized(FALSE), - m_RootImageIndex(-1) -{ - ZeroMemory(&m_ImageListData, sizeof(SP_CLASSIMAGELIST_DATA)); - - m_RootName[0] = UNICODE_NULL; -} - -CDevices::~CDevices(void) -{ - ATLASSERT(m_bInitialized == FALSE); -} - -BOOL -CDevices::Initialize() -{ - BOOL bSuccess; - - ATLASSERT(m_bInitialized == FALSE); - - /* Get the device image list */ - m_ImageListData.cbSize = sizeof(SP_CLASSIMAGELIST_DATA); - bSuccess = SetupDiGetClassImageList(&m_ImageListData); - if (bSuccess == FALSE) return FALSE; - - bSuccess = CreateRootDevice(); - if (bSuccess) m_bInitialized = TRUE; - - return m_bInitialized; -} - -BOOL -CDevices::Uninitialize() -{ - if (m_ImageListData.ImageList != NULL) - { - SetupDiDestroyClassImageList(&m_ImageListData); - ZeroMemory(&m_ImageListData, sizeof(SP_CLASSIMAGELIST_DATA)); - } - - m_bInitialized = FALSE; - - return TRUE; -} - -BOOL -CDevices::GetDeviceTreeRoot( - _Out_ LPWSTR RootName, - _In_ DWORD RootNameSize, - _Out_ PINT RootImageIndex - ) -{ - wcscpy_s(RootName, RootNameSize, m_RootName); - *RootImageIndex = m_RootImageIndex; - - return TRUE; -} - -BOOL -CDevices::GetChildDevice( - _In_ DEVINST ParentDevInst, - _Out_ PDEVINST DevInst - ) -{ - CONFIGRET cr; - - cr = CM_Get_Child(DevInst, - ParentDevInst, - 0); - return (cr == CR_SUCCESS); -} - -BOOL -CDevices::GetSiblingDevice( - _In_ DEVINST PrevDevice, - _Out_ PDEVINST DevInst - ) -{ - CONFIGRET cr; - - cr = CM_Get_Sibling(DevInst, - PrevDevice, - 0); - return (cr == CR_SUCCESS); -} - -BOOL -CDevices::GetDeviceStatus( - _In_ LPWSTR DeviceId, - _Out_ PULONG Status, - _Out_ PULONG ProblemNumber - ) -{ - DEVINST DeviceInstance; - CONFIGRET cr; - - *Status = 0; - *ProblemNumber = 0; - - /* Use the device id string to lookup the instance */ - cr = CM_Locate_DevNodeW(&DeviceInstance, - DeviceId, - CM_LOCATE_DEVNODE_NORMAL); - if (cr == CR_SUCCESS) - { - /* Get the status of this device */ - cr = CM_Get_DevNode_Status_Ex(Status, - ProblemNumber, - DeviceInstance, - 0, - NULL); - } - - return (cr == CR_SUCCESS) ? TRUE : FALSE; -} - -BOOL -CDevices::GetDevice( - _In_ DEVINST Device, - _Out_writes_(DeviceNameSize) LPWSTR DeviceName, - _In_ DWORD DeviceNameSize, - _Outptr_ LPWSTR *DeviceId, - _Out_ PINT ClassImage, - _Out_ PULONG Status, - _Out_ PULONG ProblemNumber - ) -{ - WCHAR ClassGuidString[MAX_GUID_STRING_LEN]; - GUID ClassGuid; - ULONG ulLength; - CONFIGRET cr; - BOOL bSuccess; - - *DeviceId = NULL; - - /* Get the length of the device id string */ - cr = CM_Get_Device_ID_Size(&ulLength, Device, 0); - if (cr == CR_SUCCESS) - { - /* We alloc heap here because this will be stored in the lParam of the TV */ - *DeviceId = (LPWSTR)HeapAlloc(GetProcessHeap(), - 0, - (ulLength + 1) * sizeof(WCHAR)); - if (*DeviceId) - { - /* Now get the actual device id */ - cr = CM_Get_Device_IDW(Device, - *DeviceId, - ulLength + 1, - 0); - if (cr != CR_SUCCESS) - { - HeapFree(GetProcessHeap(), 0, *DeviceId); - *DeviceId = NULL; - } - } - } - - /* Make sure we got the string */ - if (*DeviceId == NULL) - return FALSE; - - - /* Get the current status of the device */ - bSuccess = GetDeviceStatus(*DeviceId, Status, ProblemNumber); - if (bSuccess == FALSE) - { - HeapFree(GetProcessHeap(), 0, *DeviceId); - *DeviceId = NULL; - return FALSE; - } - - /* Get the class guid for this device */ - ulLength = MAX_GUID_STRING_LEN * sizeof(WCHAR); - cr = CM_Get_DevNode_Registry_PropertyW(Device, - CM_DRP_CLASSGUID, - NULL, - ClassGuidString, - &ulLength, - 0); - if (cr == CR_SUCCESS) - { - /* Convert the string to a proper guid */ - CLSIDFromString(ClassGuidString, &ClassGuid); - } - else - { - /* It's a device with no driver */ - ClassGuid = GUID_DEVCLASS_UNKNOWN; - } - - - /* Get the image for the class this device is in */ - SetupDiGetClassImageIndex(&m_ImageListData, - &ClassGuid, - ClassImage); - - /* Get the description for the device */ - ulLength = DeviceNameSize * sizeof(WCHAR); - cr = CM_Get_DevNode_Registry_PropertyW(Device, - CM_DRP_FRIENDLYNAME, - NULL, - DeviceName, - &ulLength, - 0); - if (cr != CR_SUCCESS) - { - ulLength = DeviceNameSize * sizeof(WCHAR); - cr = CM_Get_DevNode_Registry_PropertyW(Device, - CM_DRP_DEVICEDESC, - NULL, - DeviceName, - &ulLength, - 0); - - } - - /* Cleanup if something failed */ - if (cr != CR_SUCCESS) - { - HeapFree(GetProcessHeap(), 0, *DeviceId); - *DeviceId = NULL; - } - - return (cr == CR_SUCCESS ? TRUE : FALSE); -} - -BOOL -CDevices::EnumClasses( - _In_ ULONG ClassIndex, - _Out_writes_bytes_(sizeof(GUID)) LPGUID ClassGuid, - _Out_writes_(ClassNameSize) LPWSTR ClassName, - _In_ DWORD ClassNameSize, - _Out_writes_(ClassDescSize) LPWSTR ClassDesc, - _In_ DWORD ClassDescSize, - _Out_ PINT ClassImage - ) -{ - DWORD RequiredSize, Type, Size; - CONFIGRET cr; - DWORD Success; - HKEY hKey; - - ClassName[0] = UNICODE_NULL; - ClassDesc[0] = UNICODE_NULL; - *ClassImage = -1; - - /* Get the next class in the list */ - cr = CM_Enumerate_Classes(ClassIndex, - ClassGuid, - 0); - if (cr != CR_SUCCESS) return FALSE; - - /* Get the name of the device class */ - RequiredSize = MAX_CLASS_NAME_LEN; - (VOID)SetupDiClassNameFromGuidW(ClassGuid, - ClassName, - RequiredSize, - &RequiredSize); - - /* Open the registry key for this class */ - hKey = SetupDiOpenClassRegKeyExW(ClassGuid, - MAXIMUM_ALLOWED, - DIOCR_INSTALLER, - NULL, - 0); - if (hKey != INVALID_HANDLE_VALUE) - { - Size = ClassDescSize; - Type = REG_SZ; - - /* Lookup the class description (win7+) */ - Success = RegQueryValueExW(hKey, - L"ClassDesc", - NULL, - &Type, - (LPBYTE)ClassDesc, - &Size); - if (Success == ERROR_SUCCESS) - { - /* Check if the string starts with an @ */ - if (ClassDesc[0] == L'@') - { - /* The description is located in a module resource */ - Success = ConvertResourceDescriptorToString(ClassDesc, ClassDescSize); - } - } - else if (Success == ERROR_FILE_NOT_FOUND) - { - /* WinXP stores the description in the default value */ - Success = RegQueryValueExW(hKey, - NULL, - NULL, - &Type, - (LPBYTE)ClassDesc, - &Size); - } - - /* Close the registry key */ - RegCloseKey(hKey); - } - else - { - Success = GetLastError(); - } - - /* Check if we failed to get the class description */ - if (Success != ERROR_SUCCESS) - { - /* Use the class name as the description */ - wcscpy_s(ClassDesc, ClassDescSize, ClassName); - } - - /* Get the image index for this class */ - (VOID)SetupDiGetClassImageIndex(&m_ImageListData, - ClassGuid, - ClassImage); - - return TRUE; -} - -BOOL -CDevices::EnumDevicesForClass( - _Inout_opt_ LPHANDLE DeviceHandle, - _In_ LPCGUID ClassGuid, - _In_ DWORD Index, - _Out_ LPBOOL MoreItems, - _Out_ LPTSTR DeviceName, - _In_ DWORD DeviceNameSize, - _Outptr_ LPTSTR *DeviceId, - _Out_ PULONG Status, - _Out_ PULONG ProblemNumber - ) -{ - SP_DEVINFO_DATA DeviceInfoData; - DWORD DevIdSize; - HDEVINFO hDevInfo; - BOOL bUnknown, bSuccess; - - *MoreItems = FALSE; - *DeviceName = NULL; - *DeviceId = NULL; - bUnknown = FALSE; - - /* The unknown class is a special case */ - if (IsEqualGUID(*ClassGuid, GUID_DEVCLASS_UNKNOWN)) - bUnknown = TRUE; - - - /* Check if this is the first call for this class */ - if (*DeviceHandle == NULL) - { - ATLASSERT(Index == 0); - - /* Check for the special case */ - if (bUnknown == TRUE) - { - /* Get device info for all devices for all classes */ - hDevInfo = SetupDiGetClassDevsW(NULL, - NULL, - NULL, - DIGCF_ALLCLASSES); - if (hDevInfo == INVALID_HANDLE_VALUE) - return FALSE; - } - else - { - /* We only want the devices for this class */ - hDevInfo = SetupDiGetClassDevsW(ClassGuid, - NULL, - NULL, - DIGCF_PRESENT); - if (hDevInfo == INVALID_HANDLE_VALUE) - return FALSE; - } - - /* Store the handle for the next call */ - *DeviceHandle = (HANDLE)hDevInfo; - } - else - { - hDevInfo = (HDEVINFO)*DeviceHandle; - } - - - /* Get the device info for this device in the class */ - ZeroMemory(&DeviceInfoData, sizeof(SP_DEVINFO_DATA)); - DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA); - bSuccess = SetupDiEnumDeviceInfo(hDevInfo, - Index, - &DeviceInfoData); - if (bSuccess == FALSE) goto Quit; - - - - /* We found a device, let the caller know they might be more */ - *MoreItems = TRUE; - - /* Check if this is the unknown class */ - if (bUnknown) - { - /* We're looking for devices without guids */ - if (IsEqualGUID(DeviceInfoData.ClassGuid, GUID_NULL) == FALSE) - { - /* This is a known device, we aren't interested in it */ - return FALSE; - } - } - - /* Get the size required to hold the device id */ - bSuccess = SetupDiGetDeviceInstanceIdW(hDevInfo, - &DeviceInfoData, - NULL, - 0, - &DevIdSize); - if (bSuccess == FALSE && (GetLastError() != ERROR_INSUFFICIENT_BUFFER)) - goto Quit; - - /* Allocate some heap to hold the device string */ - *DeviceId = (LPTSTR)HeapAlloc(GetProcessHeap(), - 0, - DevIdSize * sizeof(WCHAR)); - if (*DeviceId == NULL) goto Quit; - - /* Now get the device id string */ - bSuccess = SetupDiGetDeviceInstanceIdW(hDevInfo, - &DeviceInfoData, - *DeviceId, - DevIdSize, - NULL); - if (bSuccess == FALSE) goto Quit; - - /* Skip the root device */ - if (*DeviceId != NULL && - wcscmp(*DeviceId, L"HTREE\\ROOT\\0") == 0) - { - bSuccess = FALSE; - goto Quit; - } - - - /* Get the current status of the device */ - bSuccess = GetDeviceStatus(*DeviceId, Status, ProblemNumber); - if (bSuccess == FALSE) goto Quit; - - - /* Get the device's friendly name */ - bSuccess = SetupDiGetDeviceRegistryPropertyW(hDevInfo, - &DeviceInfoData, - SPDRP_FRIENDLYNAME, - 0, - (BYTE*)DeviceName, - 256, - NULL); - if (bSuccess == FALSE) - { - /* if the friendly name fails, try the description instead */ - bSuccess = SetupDiGetDeviceRegistryPropertyW(hDevInfo, - &DeviceInfoData, - SPDRP_DEVICEDESC, - 0, - (BYTE*)DeviceName, - 256, - NULL); - } - - /* If we didn't find a name, check if this is an unknown device */ - if (bSuccess == FALSE && bUnknown == TRUE) - { - /* We add in our own text */ - wcscpy_s(DeviceName, 256, L"Unknown device"); - bSuccess = TRUE; - } - -Quit: - if (MoreItems == FALSE) - SetupDiDestroyDeviceInfoList(hDevInfo); - - if (bSuccess == FALSE) - { - if (*DeviceId) - { - HeapFree(GetProcessHeap(), 0, *DeviceId); - *DeviceId = NULL; - } - } - - return bSuccess; -} - - -/* PRIVATE METHODS ******************************************/ - -BOOL -CDevices::CreateRootDevice() -{ - HBITMAP hRootImage = NULL; - DWORD Size = ROOT_NAME_SIZE; - BOOL bSuccess = FALSE; - CONFIGRET cr; - - /* The root name is the computer name */ - (VOID)GetComputerNameW(m_RootName, &Size); - - /* Load the bitmap we'll be using as the root image */ - hRootImage = LoadBitmapW(g_hInstance, - MAKEINTRESOURCEW(IDB_ROOT_IMAGE)); - if (hRootImage == NULL) goto Cleanup; - - /* Add this bitmap to the device image list. This is a bit hacky, but it's safe */ - m_RootImageIndex = ImageList_Add(m_ImageListData.ImageList, - hRootImage, - NULL); - if (m_RootImageIndex == -1) - goto Cleanup; - - /* Get the root instance */ - cr = CM_Locate_DevNodeW(&m_RootDevInst, - NULL, - CM_LOCATE_DEVNODE_NORMAL); - if (cr == CR_SUCCESS) - bSuccess = TRUE; - -Cleanup: - if (bSuccess == FALSE) - { - SetupDiDestroyClassImageList(&m_ImageListData); - ZeroMemory(&m_ImageListData, sizeof(SP_CLASSIMAGELIST_DATA)); - } - - if (hRootImage) DeleteObject(hRootImage); - - return bSuccess; -} - -DWORD -CDevices::ConvertResourceDescriptorToString( - _Inout_z_ LPWSTR ResourceDescriptor, - _In_ DWORD ResourceDescriptorSize - ) -{ - WCHAR ModulePath[MAX_PATH]; - WCHAR ResString[256]; - INT ResourceId; - HMODULE hModule; - LPWSTR ptr; - DWORD Size; - DWORD dwError; - - - /* First check for a semi colon */ - ptr = wcschr(ResourceDescriptor, L';'); - if (ptr) - { - /* This must be an inf based descriptor, the desc is after the semi colon */ - wcscpy_s(ResourceDescriptor, ResourceDescriptorSize, ++ptr); - dwError = ERROR_SUCCESS; - } - else - { - /* This must be a dll resource based descriptor. Find the comma */ - ptr = wcschr(ResourceDescriptor, L','); - if (ptr == NULL) return ERROR_INVALID_DATA; - - /* Terminate the string where the comma was */ - *ptr = UNICODE_NULL; - - /* Expand any environment strings */ - Size = ExpandEnvironmentStringsW(&ResourceDescriptor[1], ModulePath, MAX_PATH); - if (Size > MAX_PATH) return ERROR_BUFFER_OVERFLOW; - if (Size == 0) return GetLastError(); - - /* Put the comma back and move past it */ - *ptr = L','; - ptr++; - - /* Load the dll */ - hModule = LoadLibraryExW(ModulePath, NULL, LOAD_LIBRARY_AS_DATAFILE); - if (hModule == NULL) return GetLastError(); - - /* Convert the resource id to a number */ - ResourceId = _wtoi(ptr); - - /* If the number is negative, make it positive */ - if (ResourceId < 0) ResourceId = -ResourceId; - - /* Load the string from the dll */ - if (LoadStringW(hModule, ResourceId, ResString, 256)) - { - wcscpy_s(ResourceDescriptor, ResourceDescriptorSize, ResString); - dwError = ERROR_SUCCESS; - } - else - { - dwError = GetLastError(); - } - - /* Free the library */ - FreeLibrary(hModule); - } - - return dwError; -} - - Removed: trunk/reactos/base/applications/mscutils/devmgmt_new/Devices.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/devmgmt_new/Devices.h [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/devmgmt_new/Devices.h (removed) @@ -1,97 +0,0 @@ -#pragma once - -#define ROOT_NAME_SIZE MAX_COMPUTERNAME_LENGTH + 1 - -class CDevices -{ -private: - SP_CLASSIMAGELIST_DATA m_ImageListData; - BOOL m_bInitialized; - - DEVINST m_RootDevInst; - WCHAR m_RootName[ROOT_NAME_SIZE]; - INT m_RootImageIndex; - -public: - CDevices(void); - ~CDevices(void); - - BOOL Initialize( - ); - - BOOL Uninitialize( - ); - - BOOL GetDeviceTreeRoot( - _Out_ LPWSTR RootName, - _In_ DWORD RootNameSize, - _Out_ PINT RootImageIndex - ); - - BOOL GetChildDevice( - _In_ DEVINST ParentDevInst, - _Out_ PDEVINST DevInst - ); - - BOOL GetSiblingDevice( - _In_ DEVINST PrevDevice, - _Out_ PDEVINST DevInst - ); - - BOOL GetDevice( - _In_ DEVINST Device, - _Out_writes_(DeviceNameSize) LPTSTR DeviceName, - _In_ DWORD DeviceNameSize, - _Outptr_ LPTSTR *DeviceId, - _Out_ PINT ClassImage, - _Out_ PULONG Status, - _Out_ PULONG ProblemNumber - ); - - BOOL EnumClasses( - _In_ ULONG ClassIndex, - _Out_writes_bytes_(sizeof(GUID)) LPGUID ClassGuid, - _Out_writes_(ClassNameSize) LPWSTR ClassName, - _In_ DWORD ClassNameSize, - _Out_writes_(ClassDescSize) LPWSTR ClassDesc, - _In_ DWORD ClassDescSize, - _Out_ PINT ClassImage - ); - - BOOL EnumDevicesForClass( - _Inout_opt_ LPHANDLE DeviceHandle, - _In_ LPCGUID ClassGuid, - _In_ DWORD Index, - _Out_ LPBOOL MoreItems, - _Out_writes_(DeviceNameSize) LPTSTR DeviceName, - _In_ DWORD DeviceNameSize, - _Outptr_ LPTSTR *DeviceId, - _Out_ PULONG Status, - _Out_ PULONG ProblemNumber - ); - - BOOL GetDeviceStatus( - _In_ LPWSTR DeviceId, - _Out_ PULONG pulStatus, - _Out_ PULONG pulProblemNumber - ); - - - HIMAGELIST GetImageList() { return m_ImageListData.ImageList; } - DEVINST GetRootDevice() { return m_RootDevInst; } - -private: - BOOL CreateImageList( - ); - - BOOL CreateRootDevice( - ); - - DWORD ConvertResourceDescriptorToString( - _Inout_z_ LPWSTR ResourceDescriptor, - _In_ DWORD ResourceDescriptorSize - ); - - -}; - Removed: trunk/reactos/base/applications/mscutils/devmgmt_new/MainWindow.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/devmgmt_new/MainWindow.cpp [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/devmgmt_new/MainWindow.cpp (removed) @@ -1,755 +0,0 @@ -/* -* PROJECT: ReactOS Device Manager -* LICENSE: GPL - See COPYING in the top level directory -* FILE: base/applications/mscutils/devmgmt/deviceview.cpp -* PURPOSE: Implements main window -* COPYRIGHT: Copyright 2014 Ged Murphy <gedmurphy(a)gmail.com> -* -*/ - -#include "stdafx.h" -#include "devmgmt.h" -#include "MainWindow.h" - - -/* DATA *****************************************************/ - -/* menu hints */ -static const MENU_HINT MainMenuHintTable[] = -{ - /* File Menu */ - {IDC_EXIT, IDS_HINT_EXIT}, - - /* Action Menu */ - {IDC_REFRESH, IDS_HINT_REFRESH}, - {IDC_PROP, IDS_HINT_PROP}, - - {IDC_ABOUT, IDS_HINT_ABOUT}, - - {IDC_DEVBYTYPE, IDS_HINT_DEV_BY_TYPE}, - {IDC_DEVBYCONN, IDS_HINT_DEV_BY_CONN}, - {IDC_RESBYTYPE, IDS_HINT_RES_BY_TYPE}, - {IDC_RESBYCONN, IDS_HINT_RES_BY_TYPE} - -}; - -/* system menu hints */ -static const MENU_HINT SystemMenuHintTable[] = -{ - {SC_RESTORE, IDS_HINT_SYS_RESTORE}, - {SC_MOVE, IDS_HINT_SYS_MOVE}, - {SC_SIZE, IDS_HINT_SYS_SIZE}, - {SC_MINIMIZE, IDS_HINT_SYS_MINIMIZE}, - {SC_MAXIMIZE, IDS_HINT_SYS_MAXIMIZE}, - {SC_CLOSE, IDS_HINT_SYS_CLOSE}, -}; - - -/* PUBLIC METHODS **********************************************/ - -CMainWindow::CMainWindow(void) : - m_ToolbarhImageList(NULL), - m_hMainWnd(NULL), - m_hStatusBar(NULL), - m_hToolBar(NULL), - m_CmdShow(0) -{ - m_szMainWndClass = L"DevMgmtWndClass"; -} - -CMainWindow::~CMainWindow(void) -{ - /* Destroy any previous list */ - if (m_ToolbarhImageList) ImageList_Destroy(m_ToolbarhImageList); -} - -BOOL -CMainWindow::Initialize(LPCTSTR lpCaption, - int nCmdShow) -{ - CAtlString szCaption; - WNDCLASSEXW wc = {0}; - - /* Store the show window value */ - m_CmdShow = nCmdShow; - - /* Setup the window class struct */ - wc.cbSize = sizeof(WNDCLASSEXW); - wc.lpfnWndProc = MainWndProc; - wc.hInstance = g_hInstance; - wc.hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCEW(IDI_MAIN_ICON)); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); - wc.lpszMenuName = MAKEINTRESOURCEW(IDR_MAINMENU); - wc.lpszClassName = m_szMainWndClass; - wc.hIconSm = (HICON)LoadImage(g_hInstance, - MAKEINTRESOURCE(IDI_MAIN_ICON), - IMAGE_ICON, - 16, - 16, - LR_SHARED); - - /* Register the window */ - if (RegisterClassExW(&wc)) - { - /* Create the main window and store the info pointer */ - m_hMainWnd = CreateWindowExW(WS_EX_WINDOWEDGE, - m_szMainWndClass, - lpCaption, - WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, - CW_USEDEFAULT, - CW_USEDEFAULT, - 600, - 450, - NULL, - NULL, - g_hInstance, - this); - } - - /* Return creation result */ - return !!(m_hMainWnd); -} - -VOID -CMainWindow::Uninitialize() -{ - /* Unregister the window class */ - UnregisterClassW(m_szMainWndClass, g_hInstance); -} - -INT -CMainWindow::Run() -{ - MSG Msg; - - /* Pump the message queue */ - while (GetMessageW(&Msg, NULL, 0, 0 ) != 0) - { - TranslateMessage(&Msg); - DispatchMessageW(&Msg); - } - - return 0; -} - - -/* PRIVATE METHODS **********************************************/ - - -BOOL -CMainWindow::MainWndMenuHint(WORD CmdId, - const MENU_HINT *HintArray, - DWORD HintsCount, - UINT DefHintId) -{ - BOOL Found = FALSE; - const MENU_HINT *LastHint; - UINT HintId = DefHintId; - - LastHint = HintArray + HintsCount; - while (HintArray != LastHint) - { - if (HintArray->CmdId == CmdId) - { - HintId = HintArray->HintId; - Found = TRUE; - break; - } - HintArray++; - } - - StatusBarLoadString(m_hStatusBar, - SB_SIMPLEID, - g_hInstance, - HintId); - - return Found; -} - -BOOL -CMainWindow::UpdateDevicesDisplay(ListDevices List) -{ - UINT CheckId; - BOOL bSuccess; - - /* Set the new type*/ - m_DeviceView->SetDeviceListType(List); - - /* Get the menu item id */ - switch (List) - { - case DevicesByType: CheckId = IDC_DEVBYTYPE; break; - case DevicesByConnection: CheckId = IDC_DEVBYCONN; break; - case ResourcesByType: CheckId = IDC_RESBYTYPE; break; - case ResourcesByConnection: CheckId = IDC_RESBYCONN; break; - default: ATLASSERT(FALSE); break; - } - - /* Set the new check item */ - bSuccess = CheckMenuRadioItem(m_hMenu, - IDC_DEVBYTYPE, - IDC_RESBYCONN, - CheckId, - MF_BYCOMMAND); - - /* Refresh the view */ - m_DeviceView->Refresh(); - - return TRUE; -} - -BOOL -CMainWindow::CreateToolBar() -{ - HIMAGELIST hImageList; - HBITMAP hBitmap; - UINT StartResource, EndResource; - INT NumButtons; - BOOL bRet = FALSE; - - static TBBUTTON ToolbarButtons [] = - { - {TBICON_PROP, IDC_PROP, TBSTATE_INDETERMINATE, BTNS_BUTTON, {0}, 0, 0}, - {TBICON_REFRESH, IDC_REFRESH, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0}, - - /* Add a seperator: First item for a seperator is its width in pixels */ - {15, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0}, - }; - - /* Calculate the number of buttons */ - NumButtons = sizeof(ToolbarButtons) / sizeof(ToolbarButtons[0]); - - /* Create the toolbar window */ - m_hToolBar = CreateWindowExW(0, - TOOLBARCLASSNAME, - NULL, - WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS, - 0, 0, 0, 0, - m_hMainWnd, - (HMENU)IDC_TOOLBAR, - g_hInstance, - NULL); - if (m_hToolBar == NULL) return FALSE; - - /* Don't show clipped buttons */ - SendMessageW(m_hToolBar, - TB_SETEXTENDEDSTYLE, - 0, - TBSTYLE_EX_HIDECLIPPEDBUTTONS); - - /* Set the struct size, the toobar needs this... */ - SendMessageW(m_hToolBar, - TB_BUTTONSTRUCTSIZE, - sizeof(ToolbarButtons[0]), - 0); - - /* Create the toolbar icon image list */ - m_ToolbarhImageList = ImageList_Create(16, - 16, - ILC_MASK | ILC_COLOR24, - NumButtons, - 0); - if (m_ToolbarhImageList == NULL) return FALSE; - - /* Set the index endpoints */ - StartResource = IDB_PROP; - EndResource = IDB_REFRESH; - - /* Add all icons to the image list */ - for (UINT i = StartResource; i <= EndResource; i++) - { - /* Load the image resource */ - hBitmap = (HBITMAP)LoadImage(g_hInstance, - MAKEINTRESOURCE(i), - IMAGE_BITMAP, - 16, - 16, - LR_LOADTRANSPARENT); - if (hBitmap) - { - /* Add it to the image list */ - ImageList_AddMasked(m_ToolbarhImageList, - hBitmap, - RGB(255, 0, 128)); - - /* Delete the bitmap */ - DeleteObject(hBitmap); - } - } - - /* Set the new image list */ - hImageList = (HIMAGELIST)SendMessageW(m_hToolBar, - TB_SETIMAGELIST, - 0, - (LPARAM)m_ToolbarhImageList); - - /* Destroy any previous list */ - if (hImageList) ImageList_Destroy(hImageList); - - /* Add the buttons */ - bRet = (BOOL)SendMessageW(m_hToolBar, - TB_ADDBUTTONS, - NumButtons, - (LPARAM)ToolbarButtons); - - return bRet; -} - -BOOL -CMainWindow::CreateStatusBar() -{ - INT StatWidths[] = {110, -1}; /* widths of status bar */ - BOOL bRet = FALSE; - - /* Create the status bar */ - m_hStatusBar = CreateWindowExW(0, - STATUSCLASSNAME, - NULL, - WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, - 0, 0, 0, 0, - m_hMainWnd, - (HMENU)IDC_STATUSBAR, - g_hInstance, - NULL); - if (m_hStatusBar) - { - /* Set the width */ - bRet = (BOOL)SendMessageW(m_hStatusBar, - SB_SETPARTS, - sizeof(StatWidths) / sizeof(INT), - (LPARAM)StatWidths); - } - - return bRet; -} - -BOOL -CMainWindow::StatusBarLoadString(IN HWND hStatusBar, - IN INT PartId, - IN HINSTANCE hInstance, - IN UINT uID) -{ - CAtlString szMessage; - BOOL bRet = FALSE; - - /* Load the string */ - if (szMessage.LoadStringW(hInstance, uID)) - { - /* Send the message to the status bar */ - bRet = (BOOL)SendMessageW(hStatusBar, - SB_SETTEXT, - (WPARAM)PartId, - (LPARAM)szMessage.GetBuffer()); - } - - return bRet; -} - -LRESULT -CMainWindow::OnCreate(HWND hwnd) -{ - LRESULT RetCode; - - /* Assume failure */ - RetCode = -1; - - /* Store the window handle */ - m_hMainWnd = hwnd; - - /* Get the menu handle */ - m_hMenu = GetMenu(m_hMainWnd); - - /* Create the toolbar */ - if (CreateToolBar() && CreateStatusBar()) - { - /* Create the device view object */ - m_DeviceView = new CDeviceView(m_hMainWnd, DevicesByType); - - /* Initialize it */ - if (m_DeviceView->Initialize()) - { - UpdateDevicesDisplay(DevicesByType); - - /* Display the window according to the user request */ - ShowWindow(hwnd, m_CmdShow); - - /* Set as handled */ - RetCode = 0; - } - } - - return RetCode; -} - -LRESULT -CMainWindow::OnSize() -{ - RECT rcClient, rcTool, rcStatus; - INT lvHeight, iToolHeight, iStatusHeight; - - /* Autosize the toolbar */ - SendMessage(m_hToolBar, TB_AUTOSIZE, 0, 0); - - /* Get the toolbar rect and save the height */ - GetWindowRect(m_hToolBar, &rcTool); - iToolHeight = rcTool.bottom - rcTool.top; - - /* Resize the status bar */ - SendMessage(m_hStatusBar, WM_SIZE, 0, 0); - - /* Get the statusbar rect and save the height */ - GetWindowRect(m_hStatusBar, &rcStatus); - iStatusHeight = rcStatus.bottom - rcStatus.top; - - /* Get the full client rect */ - GetClientRect(m_hMainWnd, &rcClient); - - /* Calculate the remaining height for the treeview */ - lvHeight = rcClient.bottom - iToolHeight - iStatusHeight; - - /* Resize the device view */ - m_DeviceView->Size(0, - iToolHeight, - rcClient.right, - lvHeight); - - return 0; -} - -LRESULT -CMainWindow::OnNotify(LPARAM lParam) -{ - LPNMHDR NmHdr = (LPNMHDR)lParam; - - switch (NmHdr->code) - { - case TVN_DELETEITEMW: - { - LPNMTREEVIEW NmTreeView = (LPNMTREEVIEW)lParam; - - NmTreeView->action = NmTreeView->action; - - break; - } - - case TVN_SELCHANGED: - { - LPNM_TREEVIEW pnmtv = (LPNM_TREEVIEW)lParam; - ListDevices ListType = m_DeviceView->GetDeviceListType(); - - if (ListType == DevicesByType) - { - if (!m_DeviceView->HasChildItem(pnmtv->itemNew.hItem)) - { - SendMessage(m_hToolBar, - TB_SETSTATE, - IDC_PROP, - (LPARAM)MAKELONG(TBSTATE_ENABLED, 0)); - - EnableMenuItem(GetMenu(m_hMainWnd), IDC_PROP, MF_ENABLED); - m_DeviceView->EnableContextMenuItem(IDC_PROP, MF_ENABLED); - } - else - { - SendMessage(m_hToolBar, - TB_SETSTATE, - IDC_PROP, - (LPARAM)MAKELONG(TBSTATE_INDETERMINATE, 0)); - - EnableMenuItem(GetMenu(m_hMainWnd), IDC_PROP, MF_GRAYED); - m_DeviceView->EnableContextMenuItem(IDC_PROP, MF_GRAYED); - } - } - else if (ListType == DevicesByConnection) - { - if (m_DeviceView->IsRootItem(pnmtv->itemNew.hItem)) - { - SendMessage(m_hToolBar, - TB_SETSTATE, - IDC_PROP, - (LPARAM)MAKELONG(TBSTATE_INDETERMINATE, 0)); - - EnableMenuItem(GetMenu(m_hMainWnd), IDC_PROP, MF_GRAYED); - m_DeviceView->EnableContextMenuItem(IDC_PROP, MF_GRAYED); - } - else - { - SendMessage(m_hToolBar, - TB_SETSTATE, - IDC_PROP, - (LPARAM)MAKELONG(TBSTATE_ENABLED, 0)); - - EnableMenuItem(GetMenu(m_hMainWnd), IDC_PROP, MF_ENABLED); - m_DeviceView->EnableContextMenuItem(IDC_PROP, MF_ENABLED); - } - } - } - break; - - case NM_DBLCLK: - { - m_DeviceView->DisplayPropertySheet(); - break; - } - - case NM_RETURN: - { - ListDevices ListType = m_DeviceView->GetDeviceListType(); - if (ListType == DevicesByType) - { - m_DeviceView->DisplayPropertySheet(); - } - else if (ListType == DevicesByConnection) - { - if (!m_DeviceView->IsRootItemSelected()) - { - m_DeviceView->DisplayPropertySheet(); - } - } - break; - } - } - - return 0; -} - -LRESULT -CMainWindow::OnContext(LPARAM lParam) -{ - INT xPos = GET_X_LPARAM(lParam); - INT yPos = GET_Y_LPARAM(lParam); - - m_DeviceView->ShowContextMenu(xPos, yPos); - return 0; -} - -LRESULT -CMainWindow::OnCommand(WPARAM wParam, - LPARAM lParam) -{ - LRESULT RetCode = 0; - WORD Msg; - - /* Get the message */ - Msg = LOWORD(wParam); - - switch (Msg) - { - case IDC_PROP: - { - /* Display the device property sheet */ - m_DeviceView->DisplayPropertySheet(); - break; - } - - case IDC_REFRESH: - { - /* Refresh the device list */ - m_DeviceView->Refresh(); - break; - } - - case IDC_DEVBYTYPE: - { - UpdateDevicesDisplay(DevicesByType); - break; - } - - case IDC_DEVBYCONN: - { - UpdateDevicesDisplay(DevicesByConnection); - break; - } - - case IDC_SHOWHIDDEN: - { - UINT CurCheckState, NewCheckState; - - /* Get the current state */ - CurCheckState = GetMenuState(m_hMenu, IDC_SHOWHIDDEN, MF_BYCOMMAND); - - /* Inform the device view of the change */ - if (CurCheckState == MF_CHECKED) - { - NewCheckState = MF_UNCHECKED; - m_DeviceView->ShowHiddenDevices(FALSE); - } - else if (CurCheckState == MF_UNCHECKED) - { - NewCheckState = MF_CHECKED; - m_DeviceView->ShowHiddenDevices(TRUE); - } - else - { - ATLASSERT(FALSE); - break; - } - - /* Set the new check state */ - CheckMenuItem(m_hMenu, IDC_SHOWHIDDEN, MF_BYCOMMAND | NewCheckState); - - /* Refresh the device view */ - m_DeviceView->Refresh(); - break; - } - - case IDC_ABOUT: - { - /* Apportion blame */ - MessageBoxW(m_hMainWnd, - L"ReactOS Device Manager\r\nCopyright Ged Murphy 2014", - L"About", - MB_OK | MB_APPLMODAL); - - /* Set focus back to the treeview */ - m_DeviceView->SetFocus(); - break; - } - - case IDC_EXIT: - { - /* Post a close message to the window */ - PostMessageW(m_hMainWnd, - WM_CLOSE, - 0, - 0); - break; - } - - default: - break; - } - - return RetCode; -} - -LRESULT -CMainWindow::OnDestroy() -{ - /* Uninitialize the device view */ - m_DeviceView->Uninitialize(); - - /* Kill the object */ - delete m_DeviceView; - m_DeviceView = NULL; - - /* Clear the user data pointer */ - SetWindowLongPtr(m_hMainWnd, GWLP_USERDATA, 0); - - /* Break the message loop */ - PostQuitMessage(0); - - return 0; -} - -LRESULT CALLBACK -CMainWindow::MainWndProc(HWND hwnd, - UINT msg, - WPARAM wParam, - LPARAM lParam) -{ - CMainWindow *pThis; - LRESULT RetCode = 0; - - /* Get the object pointer from window context */ - pThis = (CMainWindow *)GetWindowLongPtr(hwnd, GWLP_USERDATA); - - /* Check for an invalid pointer */ - if (pThis == NULL) - { - /* Check that this isn't a create message */ - if (msg != WM_CREATE) - { - /* Don't handle null info pointer */ - goto HandleDefaultMessage; - } - } - - switch(msg) - { - case WM_CREATE: - { - /* Get the object pointer from the create param */ - pThis = (CMainWindow *)((LPCREATESTRUCT)lParam)->lpCreateParams; - - /* Store the info pointer in the window's global user data */ - SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pThis); - - /* Call the create handler */ - RetCode = pThis->OnCreate(hwnd); - break; - } - - case WM_SIZE: - { - RetCode = pThis->OnSize(); - break; - } - - case WM_NOTIFY: - { - /* Handle the notify message */ - RetCode = pThis->OnNotify(lParam); - break; - } - - case WM_CONTEXTMENU: - { - /* Handle creating the context menu */ - RetCode = pThis->OnContext(lParam); - break; - } - - case WM_MENUSELECT: - { - if (pThis->m_hStatusBar != NULL) - { - if (!pThis->MainWndMenuHint(LOWORD(wParam), - MainMenuHintTable, - sizeof(MainMenuHintTable) / sizeof(MainMenuHintTable[0]), - IDS_HINT_BLANK)) - { - pThis->MainWndMenuHint(LOWORD(wParam), - SystemMenuHintTable, - sizeof(SystemMenuHintTable) / sizeof(SystemMenuHintTable[0]), - IDS_HINT_BLANK); - } - } - - break; - } - - case WM_COMMAND: - { - /* Handle the command message */ - RetCode = pThis->OnCommand(wParam, lParam); - - /* Hand it off to the default message handler */ - goto HandleDefaultMessage; - } - - case WM_CLOSE: - { - /* Destroy the main window */ - DestroyWindow(hwnd); - } - break; - - case WM_DESTROY: - { - /* Call the destroy handler */ - RetCode = pThis->OnDestroy(); - break; - } - - default: - { -HandleDefaultMessage: - RetCode = DefWindowProc(hwnd, msg, wParam, lParam); - break; - } - } - - return RetCode; -} Removed: trunk/reactos/base/applications/mscutils/devmgmt_new/MainWindow.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/devmgmt_new/MainWindow.h [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/devmgmt_new/MainWindow.h (removed) @@ -1,65 +0,0 @@ -#pragma once -#include "DeviceView.h" - -typedef struct _MENU_HINT -{ - WORD CmdId; - UINT HintId; -} MENU_HINT, *PMENU_HINT; - -class CMainWindow -{ - CAtlString m_szMainWndClass; - CDeviceView *m_DeviceView; - HWND m_hMainWnd; - HWND m_hStatusBar; - HWND m_hToolBar; - HIMAGELIST m_ToolbarhImageList; - HMENU m_hMenu; - int m_CmdShow; - -public: - CMainWindow(void); - ~CMainWindow(void); - - BOOL Initialize(LPCTSTR lpCaption, int nCmdShow); - INT Run(); - VOID Uninitialize(); - -private: - static LRESULT CALLBACK MainWndProc( - HWND hwnd, - UINT msg, - WPARAM wParam, - LPARAM lParam - ); - - LRESULT OnCreate(HWND hwnd); - LRESULT OnDestroy(); - LRESULT OnSize(); - LRESULT OnNotify(LPARAM lParam); - LRESULT OnContext(LPARAM lParam); - LRESULT OnCommand(WPARAM wParam, LPARAM lParam); - - BOOL CreateToolBar(); - BOOL CreateStatusBar(); - - BOOL StatusBarLoadString( - HWND hStatusBar, - INT PartId, - HINSTANCE hInstance, - UINT uID - ); - - BOOL MainWndMenuHint( - WORD CmdId, - const MENU_HINT *HintArray, - DWORD HintsCount, - UINT DefHintId - ); - - BOOL UpdateDevicesDisplay( - ListDevices List - ); -}; - Removed: trunk/reactos/base/applications/mscutils/devmgmt_new/Resource.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/devmgmt_new/Resource.h [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/devmgmt_new/Resource.h (removed) @@ -1,68 +0,0 @@ -#define IDC_STATIC -1 - -#define IDI_MAIN_ICON 50 -#define IDB_ROOT_IMAGE 51 - -/* windows */ -#define IDC_TREEVIEW 1000 -#define IDC_TOOLBAR 1001 -#define IDC_STATUSBAR 1002 - -/* commands */ -#define IDC_PROP 2000 -#define IDC_REFRESH 2001 -#define IDC_PRINT 2002 -#define IDC_EXIT 2003 -#define IDC_ABOUT 4031 - -/* menus */ -#define IDR_MAINMENU 102 -#define IDR_POPUP 103 -#define IDC_DEVBYTYPE 104 -#define IDC_DEVBYCONN 105 -#define IDC_RESBYTYPE 106 -#define IDC_RESBYCONN 107 -#define IDC_SHOWHIDDEN 108 - -/* tooltips */ -#define IDS_TOOLTIP_PROP 6000 -#define IDS_TOOLTIP_REFRESH 6001 -#define IDS_TOOLTIP_HELP 6002 - -/* button bitmaps */ -#define IDB_PROP 10000 -#define IDB_REFRESH 10001 - -/* toolbar buttons */ -#define TBICON_PROP 0 -#define TBICON_REFRESH 1 -#define TBICON_HELP 2 - -/* about box info */ -#define IDD_ABOUTBOX 200 -#define IDC_LICENSE_EDIT 201 -#define IDS_APPNAME 202 -#define IDS_LICENSE 203 - - -/* menu hints */ -#define IDS_HINT_BLANK 20000 -#define IDS_HINT_REFRESH 20002 -#define IDS_HINT_PROP 20003 -#define IDS_HINT_HELP 20004 -#define IDS_HINT_ABOUT 20005 -#define IDS_HINT_EXIT 20006 - -#define IDS_HINT_DEV_BY_TYPE 20020 -#define IDS_HINT_DEV_BY_CONN 20021 -#define IDS_HINT_RES_BY_TYPE 20022 -#define IDS_HINT_RES_BY_CONN 20023 - -/* system menu hints */ -#define IDS_HINT_SYS_RESTORE 21001 -#define IDS_HINT_SYS_MOVE 21002 -#define IDS_HINT_SYS_SIZE 21003 -#define IDS_HINT_SYS_MINIMIZE 21004 -#define IDS_HINT_SYS_MAXIMIZE 21005 -#define IDS_HINT_SYS_CLOSE 21006 - Modified: trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt.cpp [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt.cpp [iso-8859-1] Tue Jun 16 12:22:14 2015 @@ -1,9 +1,7 @@ -#include "stdafx.h" -#include "devmgmt.h" -#include "MainWindow.h" - -HINSTANCE g_hInstance = NULL; -HANDLE ProcessHeap = NULL; +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#include <cfgmgr32.h> +#include <dll\devmgr\devmgr.h> int WINAPI wWinMain(HINSTANCE hThisInstance, @@ -11,47 +9,13 @@ LPWSTR lpCmdLine, int nCmdShow) { - CMainWindow MainWindow; - INITCOMMONCONTROLSEX icex; - HANDLE hMutex; - CAtlString szAppName; - - int Ret = 1; - - /* Check if the app is already running */ - hMutex = CreateMutexW(NULL, TRUE, L"devmgmt_mutex2"); - if (hMutex == NULL || GetLastError() == ERROR_ALREADY_EXISTS) + if (!DeviceManager_ExecuteW(NULL, + hThisInstance, + NULL, + nCmdShow)) { - /* Cleanup and exit */ - //if (hMutex) CloseHandle(hMutex); - //return 0; + return GetLastError(); } - /* Store the global values */ - g_hInstance = hThisInstance; - ProcessHeap = GetProcessHeap(); - - /* Initialize common controls */ - icex.dwSize = sizeof(INITCOMMONCONTROLSEX); - icex.dwICC = ICC_BAR_CLASSES | ICC_COOL_CLASSES; - InitCommonControlsEx(&icex); - - /* Load the application name */ - if (szAppName.LoadStringW(g_hInstance, IDS_APPNAME)) - { - /* Initialize the main window */ - if (MainWindow.Initialize(szAppName, nCmdShow)) - { - /* Run the application */ - Ret = MainWindow.Run(); - - /* Uninitialize the main window */ - MainWindow.Uninitialize(); - } - } - - /* Delete the app mutex */ - CloseHandle(hMutex); - - return Ret; + return 0; } Removed: trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt.exe.manifest URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt.exe.manifest [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt.exe.manifest (removed) @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<assembly - xmlns="urn:schemas-microsoft-com:asm.v1" - manifestVersion="1.0"> -<assemblyIdentity - name="ReactOS.Apps.devmgmt" - processorArchitecture="*" - version="1.0.0.0" - type="win32"/> -<description>ReactOS Device Manager</description> -<dependency> - <dependentAssembly> - <assemblyIdentity - type="win32" - name="Microsoft.Windows.Common-Controls" - version="6.0.0.0" - processorArchitecture="*" - publicKeyToken="6595b64144ccf1df" - language="*" - /> - </dependentAssembly> -</dependency> -</assembly> - Modified: trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt.h [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt.h [iso-8859-1] Tue Jun 16 12:22:14 2015 @@ -1,9 +1 @@ #pragma once -#define WIN32_LEAN_AND_MEAN -#include <windows.h> -#pragma once -#include "resource.h" - -extern HINSTANCE g_hInstance; -extern HANDLE ProcessHeap; - Modified: trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== Binary files - no diff available. Removed: trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt_new.sln URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt_new.sln [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt_new.sln (removed) @@ -1,24 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.30501.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "devmgmt_new", "devmgmt_new.vcxproj", "{47B3358F-E7C3-4D02-9310-68813B9292E0}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {47B3358F-E7C3-4D02-9310-68813B9292E0}.Debug|Win32.ActiveCfg = Debug|Win32 - {47B3358F-E7C3-4D02-9310-68813B9292E0}.Debug|Win32.Build.0 = Debug|Win32 - {47B3358F-E7C3-4D02-9310-68813B9292E0}.Debug|Win32.Deploy.0 = Debug|Win32 - {47B3358F-E7C3-4D02-9310-68813B9292E0}.Release|Win32.ActiveCfg = Release|Win32 - {47B3358F-E7C3-4D02-9310-68813B9292E0}.Release|Win32.Build.0 = Release|Win32 - {47B3358F-E7C3-4D02-9310-68813B9292E0}.Release|Win32.Deploy.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal Removed: trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt_new.vcxproj URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt_new.vcxproj [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt_new.vcxproj (removed) @@ -1,106 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="
http://schemas.microsoft.com/developer/msbuild/2003
"> - <ItemGroup Label="ProjectConfigurations"> - <ProjectConfiguration Include="Debug|Win32"> - <Configuration>Debug</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|Win32"> - <Configuration>Release</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - </ItemGroup> - <PropertyGroup Label="Globals"> - <ProjectGuid>{47B3358F-E7C3-4D02-9310-68813B9292E0}</ProjectGuid> - <Keyword>Win32Proj</Keyword> - <RootNamespace>devmgmt_new</RootNamespace> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v120_xp</PlatformToolset> - <CharacterSet>Unicode</CharacterSet> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <PlatformToolset>v120_xp</PlatformToolset> - <WholeProgramOptimization>true</WholeProgramOptimization> - <CharacterSet>Unicode</CharacterSet> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> - <ImportGroup Label="ExtensionSettings"> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <PropertyGroup Label="UserMacros" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <LinkIncremental>true</LinkIncremental> - <GenerateManifest>false</GenerateManifest> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <LinkIncremental>false</LinkIncremental> - <GenerateManifest>false</GenerateManifest> - </PropertyGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <ClCompile> - <PrecompiledHeader> - </PrecompiledHeader> - <WarningLevel>Level3</WarningLevel> - <Optimization>Disabled</Optimization> - <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions> - </ClCompile> - <Link> - <SubSystem>Windows</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - <AdditionalDependencies>UxTheme.lib;comctl32.lib;setupapi.lib;%(AdditionalDependencies)</AdditionalDependencies> - </Link> - <ResourceCompile> - <PreprocessorDefinitions>LANGUAGE_EN_US;%(PreprocessorDefinitions)</PreprocessorDefinitions> - </ResourceCompile> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <ClCompile> - <WarningLevel>Level3</WarningLevel> - <PrecompiledHeader> - </PrecompiledHeader> - <Optimization>MaxSpeed</Optimization> - <FunctionLevelLinking>true</FunctionLevelLinking> - <IntrinsicFunctions>true</IntrinsicFunctions> - <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions> - </ClCompile> - <Link> - <SubSystem>Windows</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - <AdditionalDependencies>UxTheme.lib;comctl32.lib;setupapi.lib;%(AdditionalDependencies)</AdditionalDependencies> - </Link> - </ItemDefinitionGroup> - <ItemGroup> - <ClCompile Include="Devices.cpp" /> - <ClCompile Include="DeviceView.cpp" /> - <ClCompile Include="devmgmt.cpp" /> - <ClCompile Include="MainWindow.cpp" /> - <ClCompile Include="stdafx.cpp" /> - </ItemGroup> - <ItemGroup> - <ClInclude Include="Devices.h" /> - <ClInclude Include="DeviceView.h" /> - <ClInclude Include="devmgmt.h" /> - <ClInclude Include="MainWindow.h" /> - <ClInclude Include="Resource.h" /> - <ClInclude Include="stdafx.h" /> - </ItemGroup> - <ItemGroup> - <ResourceCompile Include="devmgmt.rc" /> - </ItemGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> - <ImportGroup Label="ExtensionTargets"> - </ImportGroup> -</Project> Removed: trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt_new.vcxproj.filters URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt_new.vcxproj.filters [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/devmgmt_new/devmgmt_new.vcxproj.filters (removed) @@ -1,59 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="4.0" xmlns="
http://schemas.microsoft.com/developer/msbuild/2003
"> - <ItemGroup> - <Filter Include="Source Files"> - <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> - <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> - </Filter> - <Filter Include="Header Files"> - <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> - <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions> - </Filter> - <Filter Include="Resource Files"> - <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> - <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> - </Filter> - </ItemGroup> - <ItemGroup> - <ClCompile Include="Devices.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="DeviceView.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="devmgmt.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="MainWindow.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="stdafx.cpp"> - <Filter>Source Files</Filter> - </ClCompile> - </ItemGroup> - <ItemGroup> - <ClInclude Include="Devices.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="DeviceView.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="devmgmt.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="MainWindow.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="Resource.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="stdafx.h"> - <Filter>Header Files</Filter> - </ClInclude> - </ItemGroup> - <ItemGroup> - <ResourceCompile Include="devmgmt.rc"> - <Filter>Resource Files</Filter> - </ResourceCompile> - </ItemGroup> -</Project> Removed: trunk/reactos/base/applications/mscutils/devmgmt_new/precomp.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/devmgmt_new/precomp.h [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/devmgmt_new/precomp.h (removed) @@ -1,29 +0,0 @@ -#pragma once - -#include <stdio.h> -#include <tchar.h> - -#define WIN32_NO_STATUS -#define _INC_WINDOWS -#define COM_NO_WINDOWS_H - -#define COBJMACROS - -#include <windows.h> -#include <windowsx.h> - -#include <setupapi.h> -#include <cfgmgr32.h> -#include <commctrl.h> -#include <uxtheme.h> -#include <cfgmgr32.h> -#include <devguid.h> - -#include <atlbase.h> - -#include <strsafe.h> - -#include "resource.h" - -extern HINSTANCE g_hInstance; -extern HANDLE ProcessHeap; Removed: trunk/reactos/base/applications/mscutils/devmgmt_new/rsrc.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/devmgmt_new/rsrc.rc [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/devmgmt_new/rsrc.rc (removed) @@ -1,83 +0,0 @@ -#include <windows.h> -#include "resource.h" - -LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL - -IDI_MAIN_ICON ICON "res/computer.ico" -IDB_ROOT_IMAGE BITMAP "res/root.bmp" - -/* main toolbar icons */ -IDB_PROP BITMAP DISCARDABLE "res/properties.bmp" -IDB_REFRESH BITMAP DISCARDABLE "res/refresh.bmp" -IDB_HELP BITMAP DISCARDABLE "res/help.bmp" -IDB_EXIT BITMAP DISCARDABLE "res/exit.bmp" - -// UTF-8 -#pragma code_page(65001) - -#ifdef LANGUAGE_BG_BG - #include "lang/bg-BG.rc" -#endif -#ifdef LANGUAGE_DE_DE - #include "lang/de-DE.rc" -#endif -#ifdef LANGUAGE_EL_GR - #include "lang/el-GR.rc" -#endif -#ifdef LANGUAGE_EN_US - #include "lang/en-US.rc" -#endif -#ifdef LANGUAGE_ES_ES - #include "lang/es-ES.rc" -#endif -#ifdef LANGUAGE_FR_FR - #include "lang/fr-FR.rc" -#endif -#ifdef LANGUAGE_HE_IL - #include "lang/he-IL.rc" -#endif -#ifdef LANGUAGE_ID_ID - #include "lang/id-ID.rc" -#endif -#ifdef LANGUAGE_IT_IT - #include "lang/it-IT.rc" -#endif -#ifdef LANGUAGE_JA_JP - #include "lang/ja-JP.rc" -#endif -#ifdef LANGUAGE_KO_KR - #include "lang/ko-KR.rc" -#endif -#ifdef LANGUAGE_NB_NO - #include "lang/no-NO.rc" -#endif -#ifdef LANGUAGE_PL_PL - #include "lang/pl-PL.rc" -#endif -#ifdef LANGUAGE_PT_BR - #include "lang/pt-BR.rc" -#endif -#ifdef LANGUAGE_RO_RO - #include "lang/ro-RO.rc" -#endif -#ifdef LANGUAGE_RU_RU - #include "lang/ru-RU.rc" -#endif -#ifdef LANGUAGE_SK_SK - #include "lang/sk-SK.rc" -#endif -#ifdef LANGUAGE_SV_SE - #include "lang/sv-SE.rc" -#endif -#ifdef LANGUAGE_TH_TH - #include "lang/th-TH.rc" -#endif -#ifdef LANGUAGE_TR_TR - #include "lang/tr-TR.rc" -#endif -#ifdef LANGUAGE_UK_UA - #include "lang/uk-UA.rc" -#endif -#ifdef LANGUAGE_ZH_CN - #include "lang/zh-CN.rc" -#endif Removed: trunk/reactos/base/applications/mscutils/devmgmt_new/stdafx.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/devmgmt_new/stdafx.cpp [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/devmgmt_new/stdafx.cpp (removed) @@ -1 +0,0 @@ -#include "stdafx.h" Removed: trunk/reactos/base/applications/mscutils/devmgmt_new/stdafx.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/devmgmt_new/stdafx.h [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/devmgmt_new/stdafx.h (removed) @@ -1,16 +0,0 @@ -#pragma once - -#define WIN32_LEAN_AND_MEAN -#include <Windows.h> -#include <windowsx.h> -#include <setupapi.h> -#include <cfgmgr32.h> -#include <commctrl.h> -#include <Uxtheme.h> -#include <Cfgmgr32.h> -#include <devguid.h> - -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - -#include <atlbase.h> -#include <atlstr.h> Removed: trunk/reactos/base/applications/mscutils/devmgmt_new/targetver.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
============================================================================== --- trunk/reactos/base/applications/mscutils/devmgmt_new/targetver.h [iso-8859-1] (original) +++ trunk/reactos/base/applications/mscutils/devmgmt_new/targetver.h (removed) @@ -1,8 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include <SDKDDKVer.h>
9 years, 6 months
1
0
0
0
[gedmurphy] 68162: [DEVMGR] Make the header c++ friendly
by gedmurphy@svn.reactos.org
Author: gedmurphy Date: Tue Jun 16 12:18:01 2015 New Revision: 68162 URL:
http://svn.reactos.org/svn/reactos?rev=68162&view=rev
Log: [DEVMGR] Make the header c++ friendly Modified: trunk/reactos/include/reactos/dll/devmgr/devmgr.h Modified: trunk/reactos/include/reactos/dll/devmgr/devmgr.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/dll/devmgr…
============================================================================== --- trunk/reactos/include/reactos/dll/devmgr/devmgr.h [iso-8859-1] (original) +++ trunk/reactos/include/reactos/dll/devmgr/devmgr.h [iso-8859-1] Tue Jun 16 12:18:01 2015 @@ -1,5 +1,9 @@ #ifndef __DEVMGR__H #define __DEVMGR__H + +#ifdef __cplusplus +extern "C" { +#endif BOOL WINAPI @@ -178,4 +182,8 @@ #define DevicePropertiesEx DevicePropertiesExA #endif +#ifdef __cplusplus +} +#endif + #endif /* __DEVMGR__H */
9 years, 6 months
1
0
0
0
[tfaber] 68161: [NTDLL_APITEST] - Fix GCC build
by tfaber@svn.reactos.org
Author: tfaber Date: Tue Jun 16 11:40:51 2015 New Revision: 68161 URL:
http://svn.reactos.org/svn/reactos?rev=68161&view=rev
Log: [NTDLL_APITEST] - Fix GCC build Modified: trunk/rostests/apitests/ntdll/NtQueryVolumeInformationFile.c Modified: trunk/rostests/apitests/ntdll/NtQueryVolumeInformationFile.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/NtQueryVol…
============================================================================== --- trunk/rostests/apitests/ntdll/NtQueryVolumeInformationFile.c [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/NtQueryVolumeInformationFile.c [iso-8859-1] Tue Jun 16 11:40:51 2015 @@ -136,7 +136,7 @@ ok(IoStatusBlock.Information >= FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION, VolumeLabel), "IoStatusBlock.Information = %Iu, expected >=%lu\n", IoStatusBlock.Information, (ULONG)sizeof(FILE_FS_VOLUME_INFORMATION)); ok(VolumeInfo->VolumeCreationTime.QuadPart != 0x5555555555555555, "VolumeInfo->VolumeCreationTime = %I64d\n", VolumeInfo->VolumeCreationTime.QuadPart); - ok(VolumeInfo->VolumeSerialNumber != 0x55555555, "VolumeInfo->VolumeSerialNumber = %u\n", VolumeInfo->VolumeSerialNumber); + ok(VolumeInfo->VolumeSerialNumber != 0x55555555, "VolumeInfo->VolumeSerialNumber = %lu\n", VolumeInfo->VolumeSerialNumber); ok(VolumeInfo->SupportsObjects == FALSE || VolumeInfo->SupportsObjects == TRUE, "VolumeInfo->SupportsObjects = %u\n", VolumeInfo->SupportsObjects); ok(VolumeInfo->VolumeLabelLength % sizeof(WCHAR) == 0, "VolumeInfo->VolumeLabelLength = %Iu\n", VolumeInfo->VolumeLabelLength); if (VolumeInfo->VolumeLabelLength >= sizeof(WCHAR))
9 years, 6 months
1
0
0
0
[tfaber] 68160: [NTDLL_APITEST] - Test FileFsVolumeInformation in NtQueryVolumeInformationFile test CORE-9820
by tfaber@svn.reactos.org
Author: tfaber Date: Tue Jun 16 11:33:35 2015 New Revision: 68160 URL:
http://svn.reactos.org/svn/reactos?rev=68160&view=rev
Log: [NTDLL_APITEST] - Test FileFsVolumeInformation in NtQueryVolumeInformationFile test CORE-9820 Modified: trunk/rostests/apitests/ntdll/NtQueryVolumeInformationFile.c Modified: trunk/rostests/apitests/ntdll/NtQueryVolumeInformationFile.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ntdll/NtQueryVol…
============================================================================== --- trunk/rostests/apitests/ntdll/NtQueryVolumeInformationFile.c [iso-8859-1] (original) +++ trunk/rostests/apitests/ntdll/NtQueryVolumeInformationFile.c [iso-8859-1] Tue Jun 16 11:33:35 2015 @@ -10,30 +10,13 @@ #include <wine/test.h> #include <ndk/ntndk.h> -START_TEST(NtQueryVolumeInformationFile) +static +VOID +TestFileFsDeviceInformation(HANDLE handle) { IO_STATUS_BLOCK IoStatusBlock; FILE_FS_DEVICE_INFORMATION FileFsDevice; - OBJECT_ATTRIBUTES attr; - HANDLE handle; - WCHAR path[MAX_PATH]; - UNICODE_STRING pathW; NTSTATUS status; - - /*Store a valid Handle*/ - GetWindowsDirectoryW(path, MAX_PATH); - RtlDosPathNameToNtPathName_U(path, &pathW, NULL, NULL); - - InitializeObjectAttributes(&attr, &pathW, OBJ_CASE_INSENSITIVE, NULL, NULL); - status = NtOpenFile(&handle, SYNCHRONIZE|FILE_LIST_DIRECTORY, &attr, &IoStatusBlock, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_DIRECTORY_FILE|FILE_SYNCHRONOUS_IO_NONALERT); - - RtlFreeUnicodeString(&pathW); - - if (!NT_SUCCESS(status)) - { - skip("NtOpenFile failed: 0x%lx\n", status); - return; - } /*Testing VALID handle, with NULL IN parameters*/ SetLastError(0xdeadb33f); @@ -69,17 +52,131 @@ ok(status == STATUS_OBJECT_TYPE_MISMATCH, "Expected STATUS_OBJECT_TYPE_MISMATCH, got 0x%lx\n", status); ok(GetLastError() == 0xdeaddead, "Expected 0xdeaddead, got %lx\n", GetLastError()); + /*Almost all NULL. Then it checks against the Length!*/ + SetLastError(0xdeadbeef); + status = NtQueryVolumeInformationFile(NULL, NULL, NULL, 0, FileFsDeviceInformation); + ok(status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got 0x%lx\n", status); + ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %lx\n", GetLastError()); +} + +static +VOID +TestFileFsVolumeInformation(HANDLE handle) +{ + IO_STATUS_BLOCK IoStatusBlock; + ULONG Buffer[(sizeof(FILE_FS_VOLUME_INFORMATION) + MAX_PATH * sizeof(WCHAR)) / sizeof(ULONG)]; + PFILE_FS_VOLUME_INFORMATION VolumeInfo = (PFILE_FS_VOLUME_INFORMATION)Buffer; + NTSTATUS status; + + status = NtQueryVolumeInformationFile(handle, NULL, NULL, 0, FileFsVolumeInformation); + ok(status == STATUS_INFO_LENGTH_MISMATCH, "Got status 0x%lx\n", status); + + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, NULL, 0, FileFsVolumeInformation); + ok(status == STATUS_INFO_LENGTH_MISMATCH, "Got status 0x%lx\n", status); + ok(IoStatusBlock.Status == 0x55555555, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status); + ok(IoStatusBlock.Information == (ULONG_PTR)0x5555555555555555, "IoStatusBlock.Information = %Iu\n", IoStatusBlock.Information); + + status = NtQueryVolumeInformationFile(handle, NULL, VolumeInfo, 0, FileFsVolumeInformation); + ok(status == STATUS_INFO_LENGTH_MISMATCH, "Got status 0x%lx\n", status); + + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, (PUCHAR)Buffer + 2, sizeof(FILE_FS_VOLUME_INFORMATION), FileFsVolumeInformation); + ok(status == STATUS_DATATYPE_MISALIGNMENT, "Got status 0x%lx\n", status); + ok(IoStatusBlock.Status == 0x55555555, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status); + ok(IoStatusBlock.Information == (ULONG_PTR)0x5555555555555555, "IoStatusBlock.Information = %Iu\n", IoStatusBlock.Information); + + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, VolumeInfo, 0, FileFsVolumeInformation); + ok(status == STATUS_INFO_LENGTH_MISMATCH, "Got status 0x%lx\n", status); + ok(IoStatusBlock.Status == 0x55555555, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status); + ok(IoStatusBlock.Information == (ULONG_PTR)0x5555555555555555, "IoStatusBlock.Information = %Iu\n", IoStatusBlock.Information); + + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, VolumeInfo, FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION, VolumeLabel), FileFsVolumeInformation); + ok(status == STATUS_INFO_LENGTH_MISMATCH, "Got status 0x%lx\n", status); + ok(IoStatusBlock.Status == 0x55555555, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status); + ok(IoStatusBlock.Information == (ULONG_PTR)0x5555555555555555, "IoStatusBlock.Information = %Iu\n", IoStatusBlock.Information); + + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, VolumeInfo, sizeof(FILE_FS_VOLUME_INFORMATION) - 1, FileFsVolumeInformation); + ok(status == STATUS_INFO_LENGTH_MISMATCH, "Got status 0x%lx\n", status); + ok(IoStatusBlock.Status == 0x55555555, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status); + ok(IoStatusBlock.Information == (ULONG_PTR)0x5555555555555555, "IoStatusBlock.Information = %Iu\n", IoStatusBlock.Information); + + RtlFillMemory(Buffer, sizeof(Buffer), 0x55); + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, VolumeInfo, sizeof(FILE_FS_VOLUME_INFORMATION), FileFsVolumeInformation); + ok(status == STATUS_SUCCESS || status == STATUS_BUFFER_OVERFLOW, "Got status 0x%lx\n", status); + ok(IoStatusBlock.Status == status, "IoStatusBlock.Status = 0x%lx, expected 0x%lx\n", IoStatusBlock.Status, status); + if (status == STATUS_SUCCESS) + { + ok(VolumeInfo->VolumeLabelLength <= sizeof(FILE_FS_VOLUME_INFORMATION) - FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION, VolumeLabel), + "VolumeInfo->VolumeLabelLength = %Iu\n", VolumeInfo->VolumeLabelLength); + ok(IoStatusBlock.Information >= FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION, VolumeLabel), + "IoStatusBlock.Information = %Iu, expected >=%lu\n", IoStatusBlock.Information, (ULONG)FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION, VolumeLabel)); + ok(IoStatusBlock.Information <= sizeof(FILE_FS_VOLUME_INFORMATION), + "IoStatusBlock.Information = %Iu, expected <=%lu\n", IoStatusBlock.Information, (ULONG)sizeof(FILE_FS_VOLUME_INFORMATION)); + } + else + { + ok(VolumeInfo->VolumeLabelLength > sizeof(FILE_FS_VOLUME_INFORMATION) - FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION, VolumeLabel), + "VolumeInfo->VolumeLabelLength = %Iu\n", VolumeInfo->VolumeLabelLength); + ok(IoStatusBlock.Information == sizeof(FILE_FS_VOLUME_INFORMATION), + "IoStatusBlock.Information = %Iu, expected %lu\n", IoStatusBlock.Information, (ULONG)sizeof(FILE_FS_VOLUME_INFORMATION)); + } + ok(VolumeInfo->VolumeLabel[VolumeInfo->VolumeLabelLength / sizeof(WCHAR)] == 0x5555, + "Got %x\n", VolumeInfo->VolumeLabel[VolumeInfo->VolumeLabelLength / sizeof(WCHAR)]); + + RtlFillMemory(Buffer, sizeof(Buffer), 0x55); + RtlFillMemory(&IoStatusBlock, sizeof(IoStatusBlock), 0x55); + status = NtQueryVolumeInformationFile(handle, &IoStatusBlock, VolumeInfo, sizeof(Buffer), FileFsVolumeInformation); + ok(status == STATUS_SUCCESS, "Got status 0x%lx\n", status); + ok(IoStatusBlock.Status == STATUS_SUCCESS, "IoStatusBlock.Status = 0x%lx\n", IoStatusBlock.Status); + ok(IoStatusBlock.Information >= FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION, VolumeLabel), + "IoStatusBlock.Information = %Iu, expected >=%lu\n", IoStatusBlock.Information, (ULONG)sizeof(FILE_FS_VOLUME_INFORMATION)); + ok(VolumeInfo->VolumeCreationTime.QuadPart != 0x5555555555555555, "VolumeInfo->VolumeCreationTime = %I64d\n", VolumeInfo->VolumeCreationTime.QuadPart); + ok(VolumeInfo->VolumeSerialNumber != 0x55555555, "VolumeInfo->VolumeSerialNumber = %u\n", VolumeInfo->VolumeSerialNumber); + ok(VolumeInfo->SupportsObjects == FALSE || VolumeInfo->SupportsObjects == TRUE, "VolumeInfo->SupportsObjects = %u\n", VolumeInfo->SupportsObjects); + ok(VolumeInfo->VolumeLabelLength % sizeof(WCHAR) == 0, "VolumeInfo->VolumeLabelLength = %Iu\n", VolumeInfo->VolumeLabelLength); + if (VolumeInfo->VolumeLabelLength >= sizeof(WCHAR)) + ok(VolumeInfo->VolumeLabel[VolumeInfo->VolumeLabelLength / sizeof(WCHAR) - 1] != 0x5555, "Incorrect VolumeLabel or Length\n"); + ok(VolumeInfo->VolumeLabel[VolumeInfo->VolumeLabelLength / sizeof(WCHAR)] == 0x5555, + "Got %x\n", VolumeInfo->VolumeLabel[VolumeInfo->VolumeLabelLength / sizeof(WCHAR)]); +} + +START_TEST(NtQueryVolumeInformationFile) +{ + IO_STATUS_BLOCK IoStatusBlock; + OBJECT_ATTRIBUTES attr; + HANDLE handle; + WCHAR path[MAX_PATH]; + UNICODE_STRING pathW; + NTSTATUS status; + + /*Store a valid Handle*/ + GetWindowsDirectoryW(path, MAX_PATH); + RtlDosPathNameToNtPathName_U(path, &pathW, NULL, NULL); + + InitializeObjectAttributes(&attr, &pathW, OBJ_CASE_INSENSITIVE, NULL, NULL); + status = NtOpenFile(&handle, SYNCHRONIZE|FILE_LIST_DIRECTORY, &attr, &IoStatusBlock, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_DIRECTORY_FILE|FILE_SYNCHRONOUS_IO_NONALERT); + + RtlFreeUnicodeString(&pathW); + + if (!NT_SUCCESS(status)) + { + skip("NtOpenFile failed: 0x%lx\n", status); + return; + } + /*Now all NULL. Priority check: FsInformationClass value!*/ SetLastError(0xcacacaca); status = NtQueryVolumeInformationFile(NULL, NULL, NULL, 0, 0); ok(status == STATUS_INVALID_INFO_CLASS, "Expected STATUS_INVALID_INFO_CLASS, got 0x%lx\n", status); ok(GetLastError() == 0xcacacaca, "Expected 0xcacacaca, got %lx\n", GetLastError()); - /*Almost all NULL. Then it checks against the Length!*/ - SetLastError(0xdeadbeef); - status = NtQueryVolumeInformationFile(NULL, NULL, NULL, 0, FileFsDeviceInformation); - ok(status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got 0x%lx\n", status); - ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %lx\n", GetLastError()); + TestFileFsDeviceInformation(handle); + TestFileFsVolumeInformation(handle); NtClose(handle); }
9 years, 6 months
1
0
0
0
[hbelusca] 68159: [NTVDM]: Commit what I have in my local wc so far (and which is commitable & works): - Simplify PicIRQComplete helper function. - Set up temporary stack for the BIOS. - Initialize...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Mon Jun 15 23:43:16 2015 New Revision: 68159 URL:
http://svn.reactos.org/svn/reactos?rev=68159&view=rev
Log: [NTVDM]: Commit what I have in my local wc so far (and which is commitable & works): - Simplify PicIRQComplete helper function. - Set up temporary stack for the BIOS. - Initialize the "User Data Area" that is found at 0050:xxxx (see
http://helppc.netcore2k.net/table/memory-map
for more details). - Some INT --> UINT - Simplify few macros. - Simplify DOS initialization; add few functions that will be useful later on. - Remove trailing whitespace. Modified: trunk/reactos/subsystems/mvdm/ntvdm/bios/bios.h trunk/reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32.c trunk/reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32p.h trunk/reactos/subsystems/mvdm/ntvdm/bios/bios32/kbdbios32.c trunk/reactos/subsystems/mvdm/ntvdm/bios/bios32/moubios32.c trunk/reactos/subsystems/mvdm/ntvdm/dos/dem.c trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/bios.c trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/emsdrv.c trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/himem.c trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/memory.c trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/memory.h trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/process.h trunk/reactos/subsystems/mvdm/ntvdm/dos/mouse32.c trunk/reactos/subsystems/mvdm/ntvdm/emulator.h trunk/reactos/subsystems/mvdm/ntvdm/hardware/cmos.c trunk/reactos/subsystems/mvdm/ntvdm/hardware/pic.c trunk/reactos/subsystems/mvdm/ntvdm/hardware/video/vga.c trunk/reactos/subsystems/mvdm/ntvdm/memory.c trunk/reactos/subsystems/mvdm/ntvdm/memory.h Modified: trunk/reactos/subsystems/mvdm/ntvdm/bios/bios.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/bios…
============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/bios/bios.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/bios/bios.h [iso-8859-1] Mon Jun 15 23:43:16 2015 @@ -111,14 +111,32 @@ DWORD EGAPtr; // 0xa8 BYTE Reserved12[68]; // 0xac BYTE Reserved13[16]; // 0xf0 +} BIOS_DATA_AREA, *PBIOS_DATA_AREA; +C_ASSERT(sizeof(BIOS_DATA_AREA) == 0x100); - DWORD Reserved14; // 0x100 - BYTE Reserved15[12]; // 0x104 - BYTE Reserved16[17]; // 0x110 - BYTE Reserved17[15]; // 0x121 - BYTE Reserved18[3]; // 0x130 -} BIOS_DATA_AREA, *PBIOS_DATA_AREA; -C_ASSERT(sizeof(BIOS_DATA_AREA) == 0x133); +/* + * User Data Area at 0050:XXXX + * + * See:
http://helppc.netcore2k.net/table/memory-map
+ * for more information. + */ +typedef struct +{ + BYTE PrintScreen; // 0x00 + BYTE Basic0[3]; // 0x01 + BYTE SingleDisketteFlag; // 0x04 + BYTE PostArea[10]; // 0x05 + BYTE Basic1; // 0x0f + WORD Basic2; // 0x10 + DWORD Basic3; // 0x12 + DWORD Basic4; // 0x16 + DWORD Basic5; // 0x1a + WORD Reserved0; // 0x1e + WORD DynStorage; // 0x20 + BYTE DisketteInitStorage[14]; // 0x22 + DWORD Reserved1; // 0x30 +} USER_DATA_AREA, *PUSER_DATA_AREA; +C_ASSERT(sizeof(USER_DATA_AREA) == 0x34); /* * BIOS Configuration Table at F000:E6F5 for 100% compatible BIOSes. Modified: trunk/reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/bios…
============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32.c [iso-8859-1] Mon Jun 15 23:43:16 2015 @@ -224,7 +224,7 @@ Return = (Value & getBH()) != 0; break; } - + /* Test and return if zero */ case 4: { @@ -554,15 +554,11 @@ } -VOID PicIRQComplete(LPWORD Stack) -{ - /* Get the interrupt number */ - BYTE IntNum = LOBYTE(Stack[STACK_INT_NUM]); - +VOID PicIRQComplete(BYTE IntNum) +{ /* * If this was a PIC IRQ, send an End-of-Interrupt to the PIC. */ - if (IntNum >= BIOS_PIC_MASTER_INT && IntNum < BIOS_PIC_MASTER_INT + 8) { /* It was an IRQ from the master PIC */ @@ -585,7 +581,7 @@ DPRINT("Master - IrqNumber = 0x%02X\n", IrqNumber); - PicIRQComplete(Stack); + PicIRQComplete(LOBYTE(Stack[STACK_INT_NUM])); } static VOID WINAPI BiosHandleSlavePicIRQ(LPWORD Stack) @@ -597,7 +593,7 @@ DPRINT("Slave - IrqNumber = 0x%02X\n", IrqNumber); - PicIRQComplete(Stack); + PicIRQComplete(LOBYTE(Stack[STACK_INT_NUM])); } // Timer IRQ 0 @@ -612,7 +608,7 @@ */ Int32Call(&BiosContext, BIOS_SYS_TIMER_INTERRUPT); // BiosSystemTimerInterrupt(Stack); - PicIRQComplete(Stack); + PicIRQComplete(LOBYTE(Stack[STACK_INT_NUM])); } @@ -795,15 +791,17 @@ /* Disable interrupts */ setIF(0); + /* Set the data segment */ + setDS(BDA_SEGMENT); + /* Initialize the stack */ - // That's what says IBM... (stack at 30:00FF going downwards) + // Temporary stack for POST (to be used only before initializing the INT vectors) // setSS(0x0000); // setSP(0x0400); - setSS(0x0050); // Stack at 50:0400, going downwards - setSP(0x0400); - - /* Set data segment */ - setDS(BDA_SEGMENT); + // + // Stack to be used after the initialization of the INT vectors + setSS(0x0000); // Stack at 00:8000, going downwards + setSP(0x8000); /* * Perform early CMOS shutdown status checks @@ -911,6 +909,9 @@ /* Initialize the BDA and the BIOS ROM Information */ InitializeBiosData(); InitializeBiosInfo(); + + /* Initialize the User Data Area at 0050:XXXX */ + RtlZeroMemory(SEG_OFF_TO_PTR(0x50, 0x0000), sizeof(USER_DATA_AREA)); /* * Initialize IVT and hardware Modified: trunk/reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32p.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/bios…
============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32p.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/bios/bios32/bios32p.h [iso-8859-1] Mon Jun 15 23:43:16 2015 @@ -40,7 +40,7 @@ } while(0); VOID EnableHwIRQ(UCHAR hwirq, EMULATOR_INT32_PROC func); -VOID PicIRQComplete(LPWORD Stack); +VOID PicIRQComplete(BYTE IntNum); #endif // _BIOS32P_H_ Modified: trunk/reactos/subsystems/mvdm/ntvdm/bios/bios32/kbdbios32.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/bios…
============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/bios/bios32/kbdbios32.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/bios/bios32/kbdbios32.c [iso-8859-1] Mon Jun 15 23:43:16 2015 @@ -118,7 +118,7 @@ case 0x11: { WORD Character; - + if (BiosKbdBufferTop(&Character)) { /* There is a character, clear ZF and return it */ @@ -315,7 +315,7 @@ Character, ScanCode, Bda->KeybdShiftFlags); Quit: - PicIRQComplete(Stack); + PicIRQComplete(LOBYTE(Stack[STACK_INT_NUM])); } /* PUBLIC FUNCTIONS ***********************************************************/ Modified: trunk/reactos/subsystems/mvdm/ntvdm/bios/bios32/moubios32.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/bios…
============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/bios/bios32/moubios32.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/bios/bios32/moubios32.c [iso-8859-1] Mon Jun 15 23:43:16 2015 @@ -26,7 +26,7 @@ // Mouse IRQ 12 static VOID WINAPI BiosMouseIrq(LPWORD Stack) { - PicIRQComplete(Stack); + PicIRQComplete(LOBYTE(Stack[STACK_INT_NUM])); } VOID BiosMousePs2Interface(LPWORD Stack) Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dem.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/dos/dem.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dem.c [iso-8859-1] Mon Jun 15 23:43:16 2015 @@ -16,6 +16,8 @@ #include "ntvdm.h" #include "emulator.h" +#include <isvbop.h> + #include "utils.h" #include "dem.h" @@ -40,18 +42,18 @@ switch (FuncNum) { - case 0x11: // Load the DOS kernel + /* Load the DOS kernel */ + case 0x11: { BOOLEAN Success = FALSE; + LPCSTR DosKernelFileName = "ntdos.sys"; HANDLE hDosKernel; ULONG ulDosKernelSize = 0; DPRINT1("You are loading Windows NT DOS!\n"); /* Open the DOS kernel file */ - hDosKernel = FileOpen("ntdos.sys", &ulDosKernelSize); - - /* If we failed, bail out */ + hDosKernel = FileOpen(DosKernelFileName, &ulDosKernelSize); if (hDosKernel == NULL) goto Quit; /* @@ -64,7 +66,8 @@ ulDosKernelSize, &ulDosKernelSize); - DPRINT1("Windows NT DOS loading %s at %04X:%04X, size 0x%X ; GetLastError() = %u\n", + DPRINT1("Windows NT DOS file '%s' loading %s at %04X:%04X, size 0x%X ; GetLastError() = %u\n", + DosKernelFileName, (Success ? "succeeded" : "failed"), getDI(), 0x0000, ulDosKernelSize, @@ -77,6 +80,8 @@ if (!Success) { /* We failed everything, stop the VDM */ + DisplayMessage(L"Windows NT DOS kernel file '%S' loading failed (Error: %u). The VDM will shut down.", + DosKernelFileName, GetLastError()); EmulatorTerminate(); return; } @@ -301,16 +306,16 @@ // /* 16-bit bootstrap code at 0000:7C00 */ -/* Of course, this is not in real bootsector format, because we don't care */ +/* Of course, this is not in real bootsector format, because we don't care about it for now */ static BYTE Bootsector1[] = { - LOBYTE(EMULATOR_BOP), HIBYTE(EMULATOR_BOP), BOP_LOAD_DOS, // Call DOS Loading + LOBYTE(EMULATOR_BOP), HIBYTE(EMULATOR_BOP), BOP_LOAD_DOS }; /* This portion of code is run if we failed to load the DOS */ +// NOTE: This may also be done by the BIOS32. static BYTE Bootsector2[] = { - 0xEA, // jmp far ptr - 0x5B, 0xE0, 0x00, 0xF0, // F000:E05B /** HACK! What to do instead?? **/ + LOBYTE(EMULATOR_BOP), HIBYTE(EMULATOR_BOP), BOP_UNSIMULATE }; static VOID WINAPI DosInitialize(LPWORD Stack); @@ -319,7 +324,7 @@ { /* We write the bootsector at 0000:7C00 */ ULONG_PTR Address = (ULONG_PTR)SEG_OFF_TO_PTR(0x0000, 0x7C00); - CHAR DosKernelFileName[] = ""; // No DOS file name, therefore we'll load DOS32 + CHAR DosKernelFileName[] = ""; // No DOS BIOS file name, therefore we will load DOS32 DPRINT("DosBootsectorInitialize\n"); @@ -336,43 +341,47 @@ // -// This function is called by the DOS bootsector. We finish to load -// the DOS, then we jump to 0070:0000. +// This function is called by the DOS bootsector in case we load DOS32. +// It sets up the DOS32 start code then jumps to 0070:0000. // -/* 16-bit startup code at 0070:0000 */ +/* 16-bit startup code for DOS32 at 0070:0000 */ static BYTE Startup[] = { - LOBYTE(EMULATOR_BOP), HIBYTE(EMULATOR_BOP), BOP_START_DOS, // Call DOS Start + LOBYTE(EMULATOR_BOP), HIBYTE(EMULATOR_BOP), BOP_START_DOS, + LOBYTE(EMULATOR_BOP), HIBYTE(EMULATOR_BOP), BOP_UNSIMULATE }; static VOID WINAPI DosStart(LPWORD Stack); static VOID WINAPI DosInitialize(LPWORD Stack) { - BOOLEAN Success = FALSE; - - /* Get the DOS kernel file name (NULL-terminated) */ + /* Get the DOS BIOS file name (NULL-terminated) */ // FIXME: Isn't it possible to use some DS:SI instead?? - LPCSTR DosKernelFileName = (LPCSTR)SEG_OFF_TO_PTR(getCS(), getIP()); - setIP(getIP() + strlen(DosKernelFileName) + 1); // Skip it - - DPRINT("DosInitialize('%s')\n", DosKernelFileName); + LPCSTR DosBiosFileName = (LPCSTR)SEG_OFF_TO_PTR(getCS(), getIP()); + setIP(getIP() + strlen(DosBiosFileName) + 1); // Skip it + + DPRINT("DosInitialize('%s')\n", DosBiosFileName); + + /* + * We succeeded, deregister the DOS Loading BOP + * so that no app will be able to call us back. + */ + RegisterBop(BOP_LOAD_DOS, NULL); /* Register the DOS BOPs */ RegisterBop(BOP_DOS, DosSystemBop ); RegisterBop(BOP_CMD, DosCmdInterpreterBop); - if (DosKernelFileName && DosKernelFileName[0] != '\0') - { + if (DosBiosFileName && DosBiosFileName[0] != '\0') + { + BOOLEAN Success = FALSE; HANDLE hDosBios; ULONG ulDosBiosSize = 0; /* Open the DOS BIOS file */ - hDosBios = FileOpen(DosKernelFileName, &ulDosBiosSize); - - /* If we failed, bail out */ - if (hDosBios == NULL) goto QuitCustom; + hDosBios = FileOpen(DosBiosFileName, &ulDosBiosSize); + if (hDosBios == NULL) goto Quit; /* Attempt to load the DOS BIOS into memory */ Success = FileLoadByHandle(hDosBios, @@ -380,7 +389,8 @@ ulDosBiosSize, &ulDosBiosSize); - DPRINT1("DOS BIOS loading %s at %04X:%04X, size 0x%X ; GetLastError() = %u\n", + DPRINT1("DOS BIOS file '%s' loading %s at %04X:%04X, size 0x%X ; GetLastError() = %u\n", + DosBiosFileName, (Success ? "succeeded" : "failed"), 0x0070, 0x0000, ulDosBiosSize, @@ -389,52 +399,32 @@ /* Close the DOS BIOS file */ FileClose(hDosBios); - if (!Success) goto QuitCustom; - - /* Position execution pointers and return */ - setCS(0x0070); - setIP(0x0000); - - /* Return control */ -QuitCustom: +Quit: if (!Success) - DisplayMessage(L"Custom DOS '%S' loading failed, what to do??", DosKernelFileName); + { + DisplayMessage(L"DOS BIOS file '%S' loading failed (Error: %u). The VDM will shut down.", + DosBiosFileName, GetLastError()); + return; + } } else { - Success = DosBIOSInitialize(); - // Success &= DosKRNLInitialize(); - - if (!Success) goto Quit32; - - /* Write the "bootsector" */ + /* Load the 16-bit startup code for DOS32 and register its Starting BOP */ RtlCopyMemory(SEG_OFF_TO_PTR(0x0070, 0x0000), Startup, sizeof(Startup)); - /* Register the DOS Starting BOP */ + // This is the equivalent of BOP_LOAD_DOS, function 0x11 "Load the DOS kernel" + // for the Windows NT DOS. RegisterBop(BOP_START_DOS, DosStart); - - /* Position execution pointers and return */ - setCS(0x0070); - setIP(0x0000); - - /* Return control */ -Quit32: - if (!Success) - DisplayMessage(L"DOS32 loading failed, what to do??"); - } - - if (Success) - { - /* - * We succeeded, deregister the DOS Loading BOP - * so that no app will be able to call us back. - */ - RegisterBop(BOP_LOAD_DOS, NULL); - } + } + + /* Position execution pointers for DOS startup and return */ + setCS(0x0070); + setIP(0x0000); } static VOID WINAPI DosStart(LPWORD Stack) { + BOOLEAN Success; #ifdef STANDALONE DWORD Result; CHAR ApplicationName[MAX_PATH]; @@ -450,6 +440,15 @@ * so that no app will be able to call us back. */ RegisterBop(BOP_START_DOS, NULL); + + Success = DosBIOSInitialize(); +// Success &= DosKRNLInitialize(); + if (!Success) + { + DisplayMessage(L"DOS32 loading failed (Error: %u). The VDM will shut down.", GetLastError()); + EmulatorTerminate(); + return; + } /* Load the mouse driver */ DosMouseInitialize(); Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/bios.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/bios.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/bios.c [iso-8859-1] Mon Jun 15 23:43:16 2015 @@ -30,8 +30,6 @@ #undef FreeEnvironmentStrings #define FreeEnvironmentStrings FreeEnvironmentStringsA -#define CHARACTER_ADDRESS 0x007000FF /* 0070:00FF */ - /* PRIVATE VARIABLES **********************************************************/ // static BYTE CurrentDrive; @@ -102,39 +100,10 @@ &BytesWritten); } -BOOLEAN DosBIOSInitialize(VOID) -{ - PDOS_MCB Mcb = SEGMENT_TO_MCB(FIRST_MCB_SEGMENT); - +BOOLEAN DosBuildSysEnvBlock(VOID) +{ LPSTR SourcePtr, Environment; LPSTR DestPtr = (LPSTR)SEG_OFF_TO_PTR(SYSTEM_ENV_BLOCK, 0); - -#if 0 - UCHAR i; - CHAR CurrentDirectory[MAX_PATH]; - CHAR DosDirectory[DOS_DIR_LENGTH]; - LPSTR Path; - - FILE *Stream; - WCHAR Buffer[256]; -#endif - - /* Initialize the MCB */ - Mcb->BlockType = 'Z'; - Mcb->Size = USER_MEMORY_SIZE; - Mcb->OwnerPsp = 0; - - /* Initialize the link MCB to the UMB area */ - Mcb = SEGMENT_TO_MCB(FIRST_MCB_SEGMENT + USER_MEMORY_SIZE + 1); - Mcb->BlockType = 'M'; - Mcb->Size = UMB_START_SEGMENT - FIRST_MCB_SEGMENT - USER_MEMORY_SIZE - 2; - Mcb->OwnerPsp = SYSTEM_PSP; - - /* Initialize the UMB area */ - Mcb = SEGMENT_TO_MCB(UMB_START_SEGMENT); - Mcb->BlockType = 'Z'; - Mcb->Size = UMB_END_SEGMENT - UMB_START_SEGMENT; - Mcb->OwnerPsp = 0; /* Get the environment strings */ SourcePtr = Environment = GetEnvironmentStrings(); @@ -178,6 +147,40 @@ /* Free the memory allocated for environment strings */ FreeEnvironmentStrings(Environment); + return TRUE; +} + +BOOLEAN DosBIOSInitialize(VOID) +{ +#if 0 + UCHAR i; + CHAR CurrentDirectory[MAX_PATH]; + CHAR DosDirectory[DOS_DIR_LENGTH]; + LPSTR Path; + + FILE *Stream; + WCHAR Buffer[256]; +#endif + + /* Set the data segment */ + setDS(DOS_DATA_SEGMENT); + + /* Initialize the DOS stack */ + // Stack just before FIRST_MCB_SEGMENT and after SYSTEM_ENV_BLOCK + // FIXME: Add a block of fixed size for the stack in DOS_DATA instead! + setSS(0x0F00); + setSP(0x0FF0); + setBP(0x091E); // DOS base stack pointer relic value + + /* Initialize memory management */ + DosInitializeMemory(); + + /* Build the system master environment block (inherited by the shell) */ + if (!DosBuildSysEnvBlock()) + { + DPRINT1("An error occurred when setting up the system environment block.\n"); + } + #if 0 Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c [iso-8859-1] Mon Jun 15 23:43:16 2015 @@ -1502,7 +1502,6 @@ /* Return the DOS "list of lists" in ES:BX */ setES(DOS_DATA_SEGMENT); setBX(DOS_DATA_OFFSET(SysVars.FirstDpb)); - break; } @@ -1877,6 +1876,7 @@ /* * This call should leave the flags on the stack for some reason, * so move the stack by one word. + * See:
http://www.techhelpmanual.com/565-int_25h_26h__absolute_disk_read_write.html
*/ Stack[STACK_INT_NUM] = Stack[STACK_IP]; Stack[STACK_IP] = Stack[STACK_CS]; @@ -1896,6 +1896,7 @@ /* * This call should leave the flags on the stack for some reason, * so move the stack by one word. + * See:
http://www.techhelpmanual.com/565-int_25h_26h__absolute_disk_read_write.html
*/ Stack[STACK_INT_NUM] = Stack[STACK_IP]; Stack[STACK_IP] = Stack[STACK_CS]; @@ -1966,19 +1967,27 @@ DWORD DriverEntry; if (!XmsGetDriverEntry(&DriverEntry)) break; - if (getAL() == 0x00) - { - /* The driver is loaded */ - setAL(0x80); - } - else if (getAL() == 0x10) - { - setES(HIWORD(DriverEntry)); - setBX(LOWORD(DriverEntry)); - } - else - { - DPRINT1("Unknown DOS XMS Function: INT 0x2F, AH = 43h, AL = %xh\n", getAL()); + switch (getAL()) + { + /* Installation Check */ + case 0x00: + { + /* The driver is loaded */ + setAL(0x80); + break; + } + + /* Get Driver Address */ + case 0x10: + { + setES(HIWORD(DriverEntry)); + setBX(LOWORD(DriverEntry)); + break; + } + + default: + DPRINT1("Unknown DOS XMS Function: INT 0x2F, AH = 43h, AL = %xh\n", getAL()); + break; } break; @@ -2125,7 +2134,7 @@ RegisterDosInt32(0x27, DosInt27h ); // Terminate and Stay Resident RegisterDosInt32(0x28, DosIdle ); // DOS Idle Interrupt RegisterDosInt32(0x29, DosFastConOut ); // DOS 2+ Fast Console Output - RegisterDosInt32(0x2F, DosInt2Fh ); + RegisterDosInt32(0x2F, DosInt2Fh ); // Multiplex Interrupt /* Unimplemented DOS interrupts */ RegisterDosInt32(0x2A, NULL); // Network - Installation Check Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c [iso-8859-1] Mon Jun 15 23:43:16 2015 @@ -624,7 +624,7 @@ return (WORD)GetLastError(); } } - + DescriptorId = DosFindFreeDescriptor(); if (DescriptorId == 0xFF) { @@ -1026,7 +1026,7 @@ { /* Not ready */ *Length = 0; - } + } } return TRUE; Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/emsdrv.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/emsdrv.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/emsdrv.c [iso-8859-1] Mon Jun 15 23:43:16 2015 @@ -153,7 +153,7 @@ } PageEntry = GetLogicalPage(HandleEntry, LogicalPage); - if (!PageEntry) return EMS_STATUS_INV_LOGICAL_PAGE; + if (!PageEntry) return EMS_STATUS_INV_LOGICAL_PAGE; Mapping[PhysicalPage] = (PVOID)((ULONG_PTR)EmsMemory + ARRAY_INDEX(PageEntry, PageTable) * EMS_PAGE_SIZE); @@ -501,7 +501,6 @@ EmsReadMemory, EmsWriteMemory); - /* Create the device */ Node = DosCreateDeviceEx(DOS_DEVATTR_IOCTL | DOS_DEVATTR_CHARACTER, EMS_DEVICE_NAME, Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/himem.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/himem.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/himem.c [iso-8859-1] Mon Jun 15 23:43:16 2015 @@ -485,7 +485,7 @@ if (Entry && Entry->Handle != 0) { - INT i; + UINT i; UCHAR Handles = 0; for (i = 0; i < XMS_MAX_HANDLES; i++) @@ -557,7 +557,7 @@ { WORD Segment; WORD MaxAvailable; - + Segment = DosResizeMemory(getDX(), getBX(), &MaxAvailable); if (Segment) Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/memory.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/memory.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/memory.c [iso-8859-1] Mon Jun 15 23:43:16 2015 @@ -274,7 +274,7 @@ /* It is, split it into two blocks */ NextMcb = SEGMENT_TO_MCB(Segment + NewSize + 1); - + /* Initialize the new MCB structure */ NextMcb->BlockType = Mcb->BlockType; NextMcb->Size = Mcb->Size - NewSize - 1; @@ -312,7 +312,7 @@ /* Return the maximum possible size */ if (MaxAvailable) *MaxAvailable = ReturnSize; } - + return Success; } @@ -402,3 +402,26 @@ Mcb->OwnerPsp = NewOwner; } +VOID DosInitializeMemory(VOID) +{ + PDOS_MCB Mcb = SEGMENT_TO_MCB(FIRST_MCB_SEGMENT); + + /* Initialize the MCB */ + Mcb->BlockType = 'Z'; + Mcb->Size = USER_MEMORY_SIZE; + Mcb->OwnerPsp = 0; + + /* Initialize the link MCB to the UMB area */ + Mcb = SEGMENT_TO_MCB(FIRST_MCB_SEGMENT + USER_MEMORY_SIZE + 1); + Mcb->BlockType = 'M'; + Mcb->Size = UMB_START_SEGMENT - FIRST_MCB_SEGMENT - USER_MEMORY_SIZE - 2; + Mcb->OwnerPsp = SYSTEM_PSP; + + /* Initialize the UMB area */ + Mcb = SEGMENT_TO_MCB(UMB_START_SEGMENT); + Mcb->BlockType = 'Z'; + Mcb->Size = UMB_END_SEGMENT - UMB_START_SEGMENT; + Mcb->OwnerPsp = 0; +} + +/* EOF */ Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/memory.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/memory.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/memory.h [iso-8859-1] Mon Jun 15 23:43:16 2015 @@ -11,7 +11,7 @@ /* TYPEDEFS *******************************************************************/ -#define SEGMENT_TO_MCB(seg) ((PDOS_MCB)((ULONG_PTR)BaseAddress + TO_LINEAR((seg), 0))) +#define SEGMENT_TO_MCB(seg) ((PDOS_MCB)SEG_OFF_TO_PTR((seg), 0)) enum DOS_ALLOC_STRATEGY { @@ -45,6 +45,8 @@ BOOLEAN DosUnlinkUmb(VOID); VOID DosChangeMemoryOwner(WORD Segment, WORD NewOwner); +VOID DosInitializeMemory(VOID); + #endif // _DOS_MEMORY_H_ /* EOF */ Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/process.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/process.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/process.h [iso-8859-1] Mon Jun 15 23:43:16 2015 @@ -8,16 +8,16 @@ /* DEFINITIONS ****************************************************************/ -#define DOS_CMDLINE_LENGTH 127 +#define DOS_CMDLINE_LENGTH 127 #define DOS_PROGRAM_NAME_TAG 0x0001 -#define SEGMENT_TO_PSP(seg) ((PDOS_PSP)((ULONG_PTR)BaseAddress + TO_LINEAR((seg), 0))) +#define SEGMENT_TO_PSP(seg) ((PDOS_PSP)SEG_OFF_TO_PTR((seg), 0)) typedef enum { DOS_LOAD_AND_EXECUTE = 0x00, - DOS_LOAD_ONLY = 0x01, - DOS_LOAD_OVERLAY = 0x03 + DOS_LOAD_ONLY = 0x01, + DOS_LOAD_OVERLAY = 0x03 } DOS_EXEC_TYPE; #pragma pack(push, 1) @@ -75,13 +75,11 @@ typedef struct _DOS_REGISTER_STATE { WORD AX, BX, CX, DX, SI, DI, BP, DS, ES; +// WORD IP, CS, Flags; // They are supposed to be already + // pushed on stack by the DOS caller. } DOS_REGISTER_STATE, *PDOS_REGISTER_STATE; #pragma pack(pop) - -/* VARIABLES ******************************************************************/ - -extern WORD CurrentPsp; /* FUNCTIONS ******************************************************************/ Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/mouse32.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/dos/mouse32.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/dos/mouse32.c [iso-8859-1] Mon Jun 15 23:43:16 2015 @@ -339,7 +339,7 @@ DosUpdateButtons(ButtonState); /* Complete the IRQ */ - PicIRQComplete(Stack); + PicIRQComplete(LOBYTE(Stack[STACK_INT_NUM])); } static VOID WINAPI DosMouseService(LPWORD Stack) Modified: trunk/reactos/subsystems/mvdm/ntvdm/emulator.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/emul…
============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/emulator.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/emulator.h [iso-8859-1] Mon Jun 15 23:43:16 2015 @@ -16,19 +16,18 @@ /* DEFINES ********************************************************************/ /* Basic Memory Management */ +#define MEM_ALIGN_DOWN(ptr, align) (PVOID)((ULONG_PTR)(ptr) & ~((align) - 1l)) #define MEM_ALIGN_UP(ptr, align) MEM_ALIGN_DOWN((ULONG_PTR)(ptr) + (align) - 1l, (align)) -#define MEM_ALIGN_DOWN(ptr, align) (PVOID)((ULONG_PTR)(ptr) & ~((align) - 1l)) #define TO_LINEAR(seg, off) (((seg) << 4) + (off)) #define MAX_SEGMENT 0xFFFF #define MAX_OFFSET 0xFFFF #define MAX_ADDRESS 0x1000000 // 16 MB of RAM; see also: kernel32/client/vdm.c!BaseGetVdmConfigInfo -#define FAR_POINTER(x) \ - (PVOID)((ULONG_PTR)BaseAddress + TO_LINEAR(HIWORD(x), LOWORD(x))) - #define SEG_OFF_TO_PTR(seg, off) \ (PVOID)((ULONG_PTR)BaseAddress + TO_LINEAR((seg), (off))) + +#define FAR_POINTER(x) SEG_OFF_TO_PTR(HIWORD(x), LOWORD(x)) #define REAL_TO_PHYS(ptr) (PVOID)((ULONG_PTR)(ptr) + (ULONG_PTR)BaseAddress) #define PHYS_TO_REAL(ptr) (PVOID)((ULONG_PTR)(ptr) - (ULONG_PTR)BaseAddress) Modified: trunk/reactos/subsystems/mvdm/ntvdm/hardware/cmos.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/hard…
============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/hardware/cmos.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/hardware/cmos.c [iso-8859-1] Mon Jun 15 23:43:16 2015 @@ -105,7 +105,7 @@ { /* Update the NMI enabled flag */ NmiEnabled = !(Value & CMOS_DISABLE_NMI); - + /* Get the register number */ Value &= ~CMOS_DISABLE_NMI; Modified: trunk/reactos/subsystems/mvdm/ntvdm/hardware/pic.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/hard…
============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/hardware/pic.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/hardware/pic.c [iso-8859-1] Mon Jun 15 23:43:16 2015 @@ -258,7 +258,7 @@ BYTE PicGetInterrupt(VOID) { - INT i; + UINT i; /* Search the master PIC interrupts by priority */ for (i = 0; i < 8; i++) @@ -299,7 +299,7 @@ } } } - + /* Spurious interrupt */ if (MasterPic.InServiceRegister & (1 << 2)) return SlavePic.IntOffset + 7; else return MasterPic.IntOffset + 7; @@ -330,7 +330,7 @@ /* * Adjust the interrupt request number according to the parameters, * by adding an offset == 8 to the interrupt number. - * + * * Indeed VDDs calling this function usually subtracts 8 so that they give: * * ms | line | corresponding interrupt number Modified: trunk/reactos/subsystems/mvdm/ntvdm/hardware/video/vga.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/hard…
============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/hardware/video/vga.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/hardware/video/vga.c [iso-8859-1] Mon Jun 15 23:43:16 2015 @@ -777,7 +777,7 @@ VGA_MAX_COLORS * sizeof(PALETTEENTRY)); TextPalette = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, - sizeof(LOGPALETTE) + + sizeof(LOGPALETTE) + (VGA_AC_PAL_F_REG + 1) * sizeof(PALETTEENTRY)); if ((Palette == NULL) || (TextPalette == NULL)) goto Cleanup; @@ -1461,7 +1461,7 @@ case VGA_SEQ_INDEX: return VgaSeqIndex; - + case VGA_SEQ_DATA: return VgaSeqRegisters[VgaSeqIndex]; @@ -1985,7 +1985,7 @@ for (i = 0; i < Size; i++) { VideoAddress = VgaTranslateReadAddress(Address + i); - + /* Copy the value to the buffer */ BufPtr[i] = VgaMemory[VideoAddress]; } Modified: trunk/reactos/subsystems/mvdm/ntvdm/memory.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/memo…
============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/memory.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/memory.c [iso-8859-1] Mon Jun 15 23:43:16 2015 @@ -149,7 +149,7 @@ if (Address >= 0xFFFFFFF0) Address -= 0xFFF00000; /* If the A20 line is disabled, mask bit 20 */ - if (!A20Line) Address &= ~(1 << 20); + if (!A20Line) Address &= ~(1 << 20); if ((Address + Size - 1) >= MAX_ADDRESS) { @@ -171,7 +171,7 @@ } else { - for (i = FirstPage; i <= LastPage; i++) + for (i = FirstPage; i <= LastPage; i++) { Offset = (i == FirstPage) ? (Address & (PAGE_SIZE - 1)) : 0; Length = ((i == LastPage) ? (Address + Size - (LastPage << 12)) : PAGE_SIZE) - Offset; @@ -190,7 +190,7 @@ UNREFERENCED_PARAMETER(State); /* If the A20 line is disabled, mask bit 20 */ - if (!A20Line) Address &= ~(1 << 20); + if (!A20Line) Address &= ~(1 << 20); if (Address >= MAX_ADDRESS) return; Size = min(Size, MAX_ADDRESS - Address); @@ -204,7 +204,7 @@ } else { - for (i = FirstPage; i <= LastPage; i++) + for (i = FirstPage; i <= LastPage; i++) { Offset = (i == FirstPage) ? (Address & (PAGE_SIZE - 1)) : 0; Length = ((i == LastPage) ? (Address + Size - (LastPage << 12)) : PAGE_SIZE) - Offset; Modified: trunk/reactos/subsystems/mvdm/ntvdm/memory.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/memo…
============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/memory.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/memory.h [iso-8859-1] Mon Jun 15 23:43:16 2015 @@ -27,7 +27,7 @@ ULONG Address, PVOID Buffer, ULONG Size -); +); /* FUNCTIONS ******************************************************************/
9 years, 6 months
1
0
0
0
[ekohl] 68158: [USETUP] Improve the recovery console: - Add help texts. - Implement the partinfo command which displays the partition table of the chosen drive.
by ekohl@svn.reactos.org
Author: ekohl Date: Mon Jun 15 22:44:12 2015 New Revision: 68158 URL:
http://svn.reactos.org/svn/reactos?rev=68158&view=rev
Log: [USETUP] Improve the recovery console: - Add help texts. - Implement the partinfo command which displays the partition table of the chosen drive. Modified: trunk/reactos/base/setup/usetup/cmdcons.c Modified: trunk/reactos/base/setup/usetup/cmdcons.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/cmdcons.…
============================================================================== --- trunk/reactos/base/setup/usetup/cmdcons.c [iso-8859-1] (original) +++ trunk/reactos/base/setup/usetup/cmdcons.c [iso-8859-1] Mon Jun 15 22:44:12 2015 @@ -27,8 +27,13 @@ LPSTR name; INT flags; INT (*func)(PCONSOLE_STATE, LPSTR); + VOID (*help)(VOID); } COMMAND, *LPCOMMAND; + +static +VOID +HelpCls(VOID); static INT @@ -37,30 +42,53 @@ LPSTR param); static +VOID +HelpDumpSector(VOID); + +static INT CommandDumpSector( PCONSOLE_STATE State, LPSTR param); static +VOID +HelpExit(VOID); + +static INT CommandExit( PCONSOLE_STATE State, LPSTR param); static +VOID +HelpHelp(VOID); + +static INT CommandHelp( PCONSOLE_STATE State, LPSTR param); +static +VOID +HelpPartInfo(VOID); + +static +INT +CommandPartInfo( + PCONSOLE_STATE State, + LPSTR param); + COMMAND Commands[] = { - {"cls", 0, CommandCls}, - {"dumpsector", 0, CommandDumpSector}, - {"exit", 0, CommandExit}, - {"help", 0, CommandHelp}, + {"cls", 0, CommandCls, HelpCls}, + {"dumpsector", 0, CommandDumpSector, HelpDumpSector}, + {"exit", 0, CommandExit, HelpExit}, + {"help", 0, CommandHelp, HelpHelp}, + {"partinfo", 0, CommandPartInfo, HelpPartInfo}, {NULL, 0, NULL} }; @@ -220,36 +248,24 @@ static +VOID +HelpCls(VOID) +{ + CONSOLE_ConOutPrintf("CLS\n\nClears the screen.\n\n"); +} + + +static INT CommandCls( PCONSOLE_STATE State, LPSTR param) { -#if 0 - HANDLE hOutput; - COORD coPos; - DWORD dwWritten; - -#if 0 - if (!strncmp(param, "/?", 2)) - { - ConOutResPaging(TRUE,STRING_CLS_HELP); + if (!strcmp(param, "/?")) + { + HelpCls(); return 0; } -#endif - - coPos.X = 0; - coPos.Y = 0; - - hOutput = GetStdHandle(STD_OUTPUT_HANDLE); - FillConsoleOutputAttribute(hOutput, csbi.wAttributes, - State->maxx * State->maxy, - coPos, &dwWritten); - FillConsoleOutputCharacter(hOutput, ' ', - State->maxx * State->maxy, - coPos, &dwWritten); - SetConsoleCursorPosition(hOutput, coPos); -#endif CONSOLE_ClearScreen(); CONSOLE_SetCursorXY(0, 0); @@ -304,6 +320,15 @@ CONSOLE_ConOutPrintf("\n"); } + +static +VOID +HelpDumpSector(VOID) +{ + CONSOLE_ConOutPrintf("DUMPSECT DiskNumber Sector\n\nDumps a disk sector to the screen.\n\n"); +} + + static INT CommandDumpSector( @@ -327,9 +352,9 @@ DPRINT1("param: %s\n", param); - if (!strncmp(param, "/?", 2)) - { - CONSOLE_ConOutPrintf("DUMPSECT DiskNumber Sector\n\nDumps a disk sector to the screen.\n\n"); + if (!strcmp(param, "/?")) + { + HelpDumpSector(); return 0; } @@ -453,25 +478,36 @@ static +VOID +HelpExit(VOID) +{ + CONSOLE_ConOutPrintf("EXIT\n\nExits the repair console.\n\n"); +} + + +static INT CommandExit( PCONSOLE_STATE State, LPSTR param) { -#if 0 - if (!strncmp(param, "/?", 2)) - { - ConOutResPaging(TRUE,STRING_EXIT_HELP); - /* Just make sure */ - bExit = FALSE; - /* Dont exit */ + if (!strcmp(param, "/?")) + { + HelpExit(); return 0; } -#endif State->bExit = TRUE; return 0; +} + + +static +VOID +HelpHelp(VOID) +{ + CONSOLE_ConOutPrintf("HELP [Command]\n\nShows help on repair console commands.\n\n"); } @@ -481,11 +517,196 @@ PCONSOLE_STATE State, LPSTR param) { + LPCOMMAND cmdptr; + + DPRINT1("param: %p %u '%s'\n", param, strlen(param), param); + + if (!strcmp(param, "/?")) + { + HelpHelp(); + return 0; + } + + if (param != NULL && strlen(param) > 0) + { + for (cmdptr = Commands; cmdptr->name != NULL; cmdptr++) + { + if (!stricmp(param, cmdptr->name)) + { + if (cmdptr->help != NULL) + { + cmdptr->help(); + return 0; + } + } + } + } + CONSOLE_ConOutPrintf("CLS\n"); CONSOLE_ConOutPrintf("DUMPSECTOR\n"); CONSOLE_ConOutPrintf("EXIT\n"); CONSOLE_ConOutPrintf("HELP\n"); CONSOLE_ConOutPrintf("\n"); + + return 0; +} + + +static +VOID +HelpPartInfo(VOID) +{ + CONSOLE_ConOutPrintf("PARTINFO DiskNumber\n\nDumps a partiton table to the screen.\n\n"); +} + + +static +INT +CommandPartInfo( + PCONSOLE_STATE State, + LPSTR param) +{ + OBJECT_ATTRIBUTES ObjectAttributes; + IO_STATUS_BLOCK IoStatusBlock; + UNICODE_STRING PathName; + HANDLE hDisk = NULL; + DISK_GEOMETRY DiskGeometry; + NTSTATUS Status; + + LPTSTR *argv = NULL; + INT argc = 0; + WCHAR DriveName[40]; + ULONG ulDrive, i; + PDRIVE_LAYOUT_INFORMATION LayoutBuffer = NULL; + PPARTITION_INFORMATION PartitionInfo; + + DPRINT1("param: %s\n", param); + + if (!strcmp(param, "/?")) + { + HelpPartInfo(); + return 0; + } + + argv = split(param, &argc); + + DPRINT1("argc: %d\n", argc); + DPRINT1("argv: %p\n", argv); + + if (argc != 1) + { + goto done; + } + + DPRINT1("Device: %s\n", argv[0]); + + ulDrive = strtoul(argv[0], NULL, 0); + + /* Build full drive name */ + swprintf(DriveName, L"\\Device\\Harddisk%lu\\Partition0", ulDrive); + + RtlInitUnicodeString(&PathName, + DriveName); + + InitializeObjectAttributes(&ObjectAttributes, + &PathName, + OBJ_CASE_INSENSITIVE | OBJ_INHERIT, + NULL, + NULL); + + Status = NtOpenFile(&hDisk, + GENERIC_READ | SYNCHRONIZE, + &ObjectAttributes, + &IoStatusBlock, + FILE_SHARE_READ, + FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE | FILE_RANDOM_ACCESS); + if (!NT_SUCCESS(Status)) + { + DPRINT1("NtCreateFile failed (Status 0x%08lx)\n", Status); + goto done; + } + + Status = NtDeviceIoControlFile(hDisk, + NULL, + NULL, + NULL, + &IoStatusBlock, + IOCTL_DISK_GET_DRIVE_GEOMETRY, + NULL, + 0, + &DiskGeometry, + sizeof(DISK_GEOMETRY)); + if (!NT_SUCCESS(Status)) + { + DPRINT1("NtDeviceIoControlFile failed (Status 0x%08lx)\n", Status); + goto done; + } + + CONSOLE_ConOutPrintf("Drive number: %lu\n", ulDrive); + CONSOLE_ConOutPrintf("Cylinders: %I64u\nMediaType: %x\nTracksPerCylinder: %lu\n" + "SectorsPerTrack: %lu\nBytesPerSector: %lu\n\n", + DiskGeometry.Cylinders.QuadPart, + DiskGeometry.MediaType, + DiskGeometry.TracksPerCylinder, + DiskGeometry.SectorsPerTrack, + DiskGeometry.BytesPerSector); + + LayoutBuffer = RtlAllocateHeap(ProcessHeap, + HEAP_ZERO_MEMORY, + 8192); + if (LayoutBuffer == NULL) + { + DPRINT1("LayoutBuffer allocation failed\n"); + goto done; + } + + Status = NtDeviceIoControlFile(hDisk, + NULL, + NULL, + NULL, + &IoStatusBlock, + IOCTL_DISK_GET_DRIVE_LAYOUT, + NULL, + 0, + LayoutBuffer, + 8192); + if (!NT_SUCCESS(Status)) + { + DPRINT1("NtDeviceIoControlFile(IOCTL_DISK_GET_DRIVE_LAYOUT) failed (Status 0x%08lx)\n", Status); + goto done; + } + + CONSOLE_ConOutPrintf("Partitions: %lu Signature: %lx\n\n", + LayoutBuffer->PartitionCount, + LayoutBuffer->Signature); + + CONSOLE_ConOutPrintf(" # Start Size Hidden Nr Type Boot\n"); + CONSOLE_ConOutPrintf("-- --------------- --------------- ------------ -- ---- ----\n"); + + for (i = 0; i < LayoutBuffer->PartitionCount; i++) + { + PartitionInfo = &LayoutBuffer->PartitionEntry[i]; + + CONSOLE_ConOutPrintf("%2lu %15I64u %15I64u %12lu %2lu %2x %c\n", + i, + PartitionInfo->StartingOffset.QuadPart / DiskGeometry.BytesPerSector, + PartitionInfo->PartitionLength.QuadPart / DiskGeometry.BytesPerSector, + PartitionInfo->HiddenSectors, + PartitionInfo->PartitionNumber, + PartitionInfo->PartitionType, + PartitionInfo->BootIndicator ? '*': ' '); + } + + CONSOLE_ConOutPrintf("\n"); + +done: + if (LayoutBuffer != NULL) + RtlFreeHeap(ProcessHeap, 0, LayoutBuffer); + + if (hDisk != NULL) + NtClose(hDisk); + + freep(argv); return 0; } @@ -696,7 +917,6 @@ if (str[0]) History (0, str); #endif - str[charcount++] = '\n'; str[charcount] = '\0'; CONSOLE_ConOutChar('\n'); bReturn = TRUE; @@ -902,7 +1122,7 @@ break; } - if (strcmp(com, cmdptr->name) == 0) + if (stricmp(com, cmdptr->name) == 0) { cmdptr->func(State, rest); break;
9 years, 6 months
1
0
0
0
← Newer
1
...
14
15
16
17
18
19
20
...
35
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Results per page:
10
25
50
100
200