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
December 2005
----- 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
40 participants
704 discussions
Start a n
N
ew thread
[gvg] 19806: Commit forgotten file
by gvg@svn.reactos.com
Commit forgotten file Modified: trunk/reactos/subsys/win32k/w32k.h _____ Modified: trunk/reactos/subsys/win32k/w32k.h --- trunk/reactos/subsys/win32k/w32k.h 2005-12-01 20:31:49 UTC (rev 19805) +++ trunk/reactos/subsys/win32k/w32k.h 2005-12-01 21:17:13 UTC (rev 19806) @@ -37,6 +37,9 @@ /* Helper Header */ #include <reactos/helper.h> +/* Probe and capture */ +#include <reactos/probe.h> + /* External Win32K Header */ #include <win32k/win32k.h>
19 years
1
0
0
0
[weiden] 19805: fixed refreshing the advanced properties on device changes
by weiden@svn.reactos.com
fixed refreshing the advanced properties on device changes Modified: trunk/reactos/lib/devmgr/advprop.c _____ Modified: trunk/reactos/lib/devmgr/advprop.c --- trunk/reactos/lib/devmgr/advprop.c 2005-12-01 20:12:00 UTC (rev 19804) +++ trunk/reactos/lib/devmgr/advprop.c 2005-12-01 20:31:49 UTC (rev 19805) @@ -30,6 +30,8 @@ #define NDEBUG #include <debug.h> +#define DPN_DEVICEUPDATE (WM_USER + 0x1000) + typedef INT_PTR (WINAPI *PPROPERTYSHEETW)(LPCPROPSHEETHEADERW); typedef HPROPSHEETPAGE (WINAPI *PCREATEPROPERTYSHEETPAGEW)(LPCPROPSHEETPAGEW); typedef BOOL (WINAPI *PDESTROYPROPERTYSHEETPAGE)(HPROPSHEETPAGE); @@ -43,12 +45,27 @@ typedef struct _DEVADVPROP_INFO { + HWND hWndGeneralPage; + HWND hWndParent; + WNDPROC ParentOldWndProc; + HDEVINFO DeviceInfoSet; - PSP_DEVINFO_DATA DeviceInfoData; + SP_DEVINFO_DATA DeviceInfoData; + HANDLE hMachine; + LPCWSTR lpMachineName; + HINSTANCE hComCtl32; - HANDLE hMachine; - BOOL CanDisable; - BOOL DeviceEnabled; + + DWORD PropertySheetType; + DWORD nDevPropSheets; + HPROPSHEETPAGE *DevPropSheets; + + BOOL FreeDevPropSheets : 1; + BOOL CanDisable : 1; + BOOL DeviceEnabled : 1; + BOOL DeviceUsageChanged : 1; + BOOL CreatedDevInfoSet : 1; + WCHAR szDevName[255]; WCHAR szTemp[255]; WCHAR szDeviceID[1]; @@ -155,63 +172,193 @@ ApplyGeneralSettings(IN HWND hwndDlg, IN PDEVADVPROP_INFO dap) { - DEVENABLEACTION SelectedUsageAction; + if (dap->DeviceUsageChanged) + { + DEVENABLEACTION SelectedUsageAction; - SelectedUsageAction = GetSelectedUsageAction(GetDlgItem(hwndDlg, - IDC_DEVUSAGE)); - if (SelectedUsageAction != DEA_UNKNOWN) - { - switch (SelectedUsageAction) + SelectedUsageAction = GetSelectedUsageAction(GetDlgItem(hwndDlg, + IDC_DEVUSAGE)); + if (SelectedUsageAction != DEA_UNKNOWN) { - case DEA_ENABLE: - if (!dap->DeviceEnabled) - { - /* FIXME - enable device */ - } - break; + switch (SelectedUsageAction) + { + case DEA_ENABLE: + if (!dap->DeviceEnabled) + { + /* FIXME - enable device */ + } + break; - case DEA_DISABLE: - if (dap->DeviceEnabled) - { - /* FIXME - disable device */ - } - break; + case DEA_DISABLE: + if (dap->DeviceEnabled) + { + /* FIXME - disable device */ + } + break; - default: - break; + default: + break; + } } + } - /* disable the apply button */ - PropSheet_UnChanged(GetParent(hwndDlg), - hwndDlg); - } + /* disable the apply button */ + PropSheet_UnChanged(GetParent(hwndDlg), + hwndDlg); + dap->DeviceUsageChanged = FALSE; } static VOID UpdateDevInfo(IN HWND hwndDlg, IN PDEVADVPROP_INFO dap, - IN BOOL ReOpenDevice) + IN BOOL ReOpen) { HICON hIcon; HWND hDevUsage; + HWND hPropSheetDlg; + BOOL bFlag; + DWORD i; - if (ReOpenDevice) + hPropSheetDlg = GetParent(hwndDlg); + + if (ReOpen) { - /* note, we ignore the fact that SetupDiOpenDeviceInfo could fail here, - in case of failure we're still going to query information from it even - though those calls are going to fail. But they return readable strings - even in that case. */ - SetupDiOpenDeviceInfo(dap->DeviceInfoSet, - dap->szDeviceID, - hwndDlg, - 0, - dap->DeviceInfoData); + PROPSHEETHEADER psh; + HDEVINFO hOldDevInfo; + + /* switch to the General page */ + PropSheet_SetCurSelByID(hPropSheetDlg, + IDD_DEVICEGENERAL); + + /* remove and destroy the existing device property sheet pages */ + for (i = 0; + i != dap->nDevPropSheets; + i++) + { + PropSheet_RemovePage(hPropSheetDlg, + -1, + dap->DevPropSheets[i]); + } + + if (dap->FreeDevPropSheets) + { + /* don't free the array if it's the one allocated in + DisplayDeviceAdvancedProperties */ + HeapFree(GetProcessHeap(), + 0, + dap->DevPropSheets); + + dap->FreeDevPropSheets = FALSE; + } + + dap->DevPropSheets = NULL; + dap->nDevPropSheets = 0; + + /* create a new device info set and re-open the device */ + hOldDevInfo = dap->DeviceInfoSet; + dap->DeviceInfoSet = SetupDiCreateDeviceInfoListEx(NULL, + hwndDlg, + dap->lpMachineName, + NULL); + if (dap->DeviceInfoSet != INVALID_HANDLE_VALUE) + { + if (SetupDiOpenDeviceInfo(dap->DeviceInfoSet, + dap->szDeviceID, + hwndDlg, + 0, + &dap->DeviceInfoData)) + { + if (dap->CreatedDevInfoSet) + { + SetupDiDestroyDeviceInfoList(hOldDevInfo); + } + + dap->CreatedDevInfoSet = TRUE; + } + else + { + SetupDiDestroyDeviceInfoList(dap->DeviceInfoSet); + dap->DeviceInfoSet = INVALID_HANDLE_VALUE; + dap->CreatedDevInfoSet = FALSE; + } + } + else + { + /* oops, something went wrong, restore the old device info set */ + dap->DeviceInfoSet = hOldDevInfo; + + if (dap->DeviceInfoSet != INVALID_HANDLE_VALUE) + { + SetupDiOpenDeviceInfo(dap->DeviceInfoSet, + dap->szDeviceID, + hwndDlg, + 0, + &dap->DeviceInfoData); + } + } + + /* find out how many new device property sheets to add. + fake a PROPSHEETHEADER structure, we don't plan to + call PropertySheet again!*/ + psh.dwSize = sizeof(PROPSHEETHEADER); + psh.dwFlags = 0; + psh.nPages = 0; + + if (!SetupDiGetClassDevPropertySheets(dap->DeviceInfoSet, + &dap->DeviceInfoData, + &psh, + 0, + &dap->nDevPropSheets, + dap->PropertySheetType) && + dap->nDevPropSheets != 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER) + { + dap->DevPropSheets = HeapAlloc(GetProcessHeap(), + HEAP_ZERO_MEMORY, + dap->nDevPropSheets * sizeof(HPROPSHEETPAGE)); + if (dap->DevPropSheets != NULL) + { + psh.phpage = dap->DevPropSheets; + + /* query the new property sheet pages to add */ + if (SetupDiGetClassDevPropertySheets(dap->DeviceInfoSet, + &dap->DeviceInfoData, + &psh, + dap->nDevPropSheets, + NULL, + dap->PropertySheetType)) + { + /* add the property sheets */ + + for (i = 0; + i != dap->nDevPropSheets; + i++) + { + PropSheet_AddPage(hPropSheetDlg, + dap->DevPropSheets[i]); + } + + dap->FreeDevPropSheets = TRUE; + } + else + { + /* cleanup, we were unable to get the device property sheets */ + HeapFree(GetProcessHeap(), + 0, + dap->DevPropSheets); + + dap->nDevPropSheets = 0; + dap->DevPropSheets = NULL; + } + } + else + dap->nDevPropSheets = 0; + } } /* get the device name */ if (GetDeviceDescriptionString(dap->DeviceInfoSet, - dap->DeviceInfoData, + &dap->DeviceInfoData, dap->szDevName, sizeof(dap->szDevName) / sizeof(dap->szDevName[0]))) { @@ -221,7 +368,7 @@ } /* set the device image */ - if (SetupDiLoadClassIcon(&dap->DeviceInfoData->ClassGuid, + if (SetupDiLoadClassIcon(&dap->DeviceInfoData.ClassGuid, &hIcon, NULL)) { @@ -242,7 +389,7 @@ dap->szDevName); /* set the device type edit control text */ - if (GetDeviceTypeString(dap->DeviceInfoData, + if (GetDeviceTypeString(&dap->DeviceInfoData, dap->szTemp, sizeof(dap->szTemp) / sizeof(dap->szTemp[0]))) { @@ -253,7 +400,7 @@ /* set the device manufacturer edit control text */ if (GetDeviceManufacturerString(dap->DeviceInfoSet, - dap->DeviceInfoData, + &dap->DeviceInfoData, dap->szTemp, sizeof(dap->szTemp) / sizeof(dap->szTemp[0]))) { @@ -263,7 +410,7 @@ } /* set the device location edit control text */ - if (GetDeviceLocationString(dap->DeviceInfoData->DevInst, + if (GetDeviceLocationString(dap->DeviceInfoData.DevInst, dap->szTemp, sizeof(dap->szTemp) / sizeof(dap->szTemp[0]))) { @@ -273,7 +420,7 @@ } /* set the device status edit control text */ - if (GetDeviceStatusString(dap->DeviceInfoData->DevInst, + if (GetDeviceStatusString(dap->DeviceInfoData.DevInst, dap->hMachine, dap->szTemp, sizeof(dap->szTemp) / sizeof(dap->szTemp[0]))) @@ -287,18 +434,24 @@ hDevUsage = GetDlgItem(hwndDlg, IDC_DEVUSAGE); - if (!CanDisableDevice(dap->DeviceInfoData->DevInst, - dap->hMachine, - &dap->CanDisable)) + dap->CanDisable = FALSE; + dap->DeviceEnabled = FALSE; + + if (dap->DeviceInfoSet != INVALID_HANDLE_VALUE) { - dap->CanDisable = FALSE; - } + if (CanDisableDevice(dap->DeviceInfoData.DevInst, + dap->hMachine, + &bFlag)) + { + dap->CanDisable = bFlag; + } - if (!IsDeviceEnabled(dap->DeviceInfoData->DevInst, - dap->hMachine, - &dap->DeviceEnabled)) - { - dap->DeviceEnabled = FALSE; + if (IsDeviceEnabled(dap->DeviceInfoData.DevInst, + dap->hMachine, + &bFlag)) + { + dap->DeviceEnabled = bFlag; + } } /* enable/disable the device usage controls */ @@ -321,11 +474,55 @@ } /* finally, disable the apply button */ - PropSheet_UnChanged(GetParent(hwndDlg), + PropSheet_UnChanged(hPropSheetDlg, hwndDlg); + dap->DeviceUsageChanged = FALSE; } +static LRESULT +CALLBACK +DlgParentSubWndProc(IN HWND hwnd, + IN UINT uMsg, + IN WPARAM wParam, + IN LPARAM lParam) +{ + PDEVADVPROP_INFO dap; + + dap = (PDEVADVPROP_INFO)GetProp(hwnd, + L"DevMgrDevChangeSub"); + if (dap != NULL) + { + if (uMsg == WM_DEVICECHANGE && !IsWindowVisible(dap->hWndGeneralPage)) + { + SendMessage(dap->hWndGeneralPage, + WM_DEVICECHANGE, + wParam, + lParam); + } + + /* pass the message the the old window proc */ + return CallWindowProc(dap->ParentOldWndProc, + hwnd, + uMsg, + wParam, + lParam); + } + else + { + /* this is not a good idea if the subclassed window was an ansi + window, but we failed finding out the previous window proc + so we can't use CallWindowProc. This should rarely - if ever - + happen. */ + + return DefWindowProc(hwnd, + uMsg, + wParam, + lParam); + } +} + + static INT_PTR CALLBACK AdvPropGeneralDlgProc(IN HWND hwndDlg, @@ -353,6 +550,7 @@ { PropSheet_Changed(GetParent(hwndDlg), hwndDlg); + dap->DeviceUsageChanged = TRUE; } break; } @@ -378,10 +576,34 @@ dap = (PDEVADVPROP_INFO)((LPPROPSHEETPAGE)lParam)->lParam; if (dap != NULL) { + HWND hWndParent; + + dap->hWndGeneralPage = hwndDlg; + SetWindowLongPtr(hwndDlg, DWL_USER, (DWORD_PTR)dap); + /* subclass the parent window to always receive + WM_DEVICECHANGE messages */ + hWndParent = GetParent(hwndDlg); + if (hWndParent != NULL) + { + /* subclass the parent window. This is not safe + if the parent window belongs to another thread! */ + dap->ParentOldWndProc = (WNDPROC)SetWindowLongPtr(hWndParent, + GWLP_WNDPROC, + (LONG_PTR)DlgParentSubWndProc); + + if (dap->ParentOldWndProc != NULL && + SetProp(hWndParent, + L"DevMgrDevChangeSub", + (HANDLE)dap)) + { + dap->hWndParent = hWndParent; + } + } + UpdateDevInfo(hwndDlg, dap, FALSE); @@ -403,6 +625,14 @@ { HICON hDevIcon; + /* restore the old window proc of the subclassed parent window */ + if (dap->hWndParent != NULL && dap->ParentOldWndProc != NULL) + { + SetWindowLongPtr(dap->hWndParent, + GWLP_WNDPROC, + (LONG_PTR)dap->ParentOldWndProc); + } + /* destroy the device icon */ hDevIcon = (HICON)SendDlgItemMessage(hwndDlg, IDC_DEVICON, @@ -437,7 +667,6 @@ PCREATEPROPERTYSHEETPAGEW pCreatePropertySheetPageW; PDESTROYPROPERTYSHEETPAGE pDestroyPropertySheetPage; PDEVADVPROP_INFO DevAdvPropInfo; - DWORD PropertySheetType; HANDLE hMachine = NULL; DWORD DevIdSize = 0; INT_PTR Ret = -1; @@ -469,7 +698,7 @@ 0, &DevIdSize)) { - DPRINT1("SetupDiGetDeviceInterfaceDetail unexpectedly returned TRUE!\n"); + DPRINT1("SetupDiGetDeviceInstanceId unexpectedly returned TRUE!\n"); return -1; } @@ -496,7 +725,7 @@ /* create the internal structure associated with the "General", "Driver", ... pages */ DevAdvPropInfo = HeapAlloc(GetProcessHeap(), - 0, + HEAP_ZERO_MEMORY, FIELD_OFFSET(DEVADVPROP_INFO, szDeviceID) + (DevIdSize * sizeof(WCHAR))); @@ -517,29 +746,36 @@ goto Cleanup; } } + else + { + /* copy the device instance id supplied by the caller */ + wcscpy(DevAdvPropInfo->szDeviceID, + lpDeviceID); + } DevAdvPropInfo->DeviceInfoSet = DeviceInfoSet; - DevAdvPropInfo->DeviceInfoData = DeviceInfoData; - DevAdvPropInfo->hComCtl32 = hComCtl32; + DevAdvPropInfo->DeviceInfoData = *DeviceInfoData; DevAdvPropInfo->hMachine = hMachine; + DevAdvPropInfo->lpMachineName = lpMachineName; DevAdvPropInfo->szDevName[0] = L'\0'; + DevAdvPropInfo->hComCtl32 = hComCtl32; psh.dwSize = sizeof(PROPSHEETHEADER); psh.dwFlags = PSH_PROPTITLE | PSH_NOAPPLYNOW; psh.hwndParent = hWndParent; psh.pszCaption = DevAdvPropInfo->szDevName; - PropertySheetType = lpMachineName != NULL ? - DIGCDP_FLAG_REMOTE_ADVANCED : - DIGCDP_FLAG_ADVANCED; + DevAdvPropInfo->PropertySheetType = lpMachineName != NULL ? + DIGCDP_FLAG_REMOTE_ADVANCED : + DIGCDP_FLAG_ADVANCED; /* find out how many property sheets we need */ if (SetupDiGetClassDevPropertySheets(DeviceInfoSet, - DeviceInfoData, + &DevAdvPropInfo->DeviceInfoData, &psh, 0, &nPropSheets, - PropertySheetType) && + DevAdvPropInfo->PropertySheetType) && nPropSheets != 0) { DPRINT1("SetupDiGetClassDevPropertySheets unexpectedly returned TRUE!\n"); @@ -572,15 +808,19 @@ psh.nPages++; } + DevAdvPropInfo->nDevPropSheets = nPropSheets; + if (nPropSheets != 0) { + DevAdvPropInfo->DevPropSheets = psh.phpage + psh.nPages; + /* create the device property sheets */ if (!SetupDiGetClassDevPropertySheets(DeviceInfoSet, - DeviceInfoData, + &DevAdvPropInfo->DeviceInfoData, &psh, nPropSheets + psh.nPages, NULL, - PropertySheetType)) + DevAdvPropInfo->PropertySheetType)) { goto Cleanup; } @@ -600,25 +840,49 @@ Cleanup: /* in case of failure the property sheets must be destroyed */ - for (i = 0; - i < psh.nPages; - i++) + if (psh.phpage != NULL) { - if (psh.phpage[i] != NULL) + for (i = 0; + i < psh.nPages; + i++) { - pDestroyPropertySheetPage(psh.phpage[i]); + if (psh.phpage[i] != NULL) + { + pDestroyPropertySheetPage(psh.phpage[i]); + } } } } - HeapFree(GetProcessHeap(), - 0, - psh.phpage); + if (DevAdvPropInfo != NULL) + { + if (DevAdvPropInfo->FreeDevPropSheets) + { + /* don't free the array if it's the one allocated in + DisplayDeviceAdvancedProperties */ + HeapFree(GetProcessHeap(), + 0, + DevAdvPropInfo->DevPropSheets); + } - HeapFree(GetProcessHeap(), - 0, - DevAdvPropInfo); + if (DevAdvPropInfo->CreatedDevInfoSet) + { + /* close the device info set in case a new one was created */ + SetupDiDestroyDeviceInfoList(DevAdvPropInfo->DeviceInfoSet); + } + HeapFree(GetProcessHeap(), + 0, + DevAdvPropInfo); + } + + if (psh.phpage != NULL) + { + HeapFree(GetProcessHeap(), + 0, + psh.phpage); + } + if (hMachine != NULL) { CM_Disconnect_Machine(hMachine); @@ -665,19 +929,10 @@ hComCtl32 = LoadAndInitComctl32(); if (hComCtl32 != NULL) { - if (lpMachineName != NULL) - { - hDevInfo = SetupDiCreateDeviceInfoListEx(NULL, - hWndParent, - lpMachineName, - NULL); - } - else - { - hDevInfo = SetupDiCreateDeviceInfoList(NULL, - hWndParent); - } - + hDevInfo = SetupDiCreateDeviceInfoListEx(NULL, + hWndParent, + lpMachineName, + NULL); if (hDevInfo != INVALID_HANDLE_VALUE) { DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
19 years
1
0
0
0
[gvg] 19804: Get correct window station for CSRSS
by gvg@svn.reactos.com
Get correct window station for CSRSS Modified: trunk/reactos/subsys/win32k/ntuser/desktop.c _____ Modified: trunk/reactos/subsys/win32k/ntuser/desktop.c --- trunk/reactos/subsys/win32k/ntuser/desktop.c 2005-12-01 20:09:38 UTC (rev 19803) +++ trunk/reactos/subsys/win32k/ntuser/desktop.c 2005-12-01 20:12:00 UTC (rev 19804) @@ -948,6 +948,7 @@ ACCESS_MASK dwDesiredAccess) { OBJECT_ATTRIBUTES ObjectAttributes; + HWINSTA WinSta; PWINSTATION_OBJECT WinStaObject; UNICODE_STRING DesktopName; NTSTATUS Status; @@ -962,16 +963,16 @@ * qualified desktop name */ + WinSta = UserGetProcessWindowStation(); Status = IntValidateWindowStationHandle( - PsGetCurrentProcess()->Win32WindowStation, + WinSta, KernelMode, 0, &WinStaObject); if (!NT_SUCCESS(Status)) { - DPRINT1("Failed validation of window station handle (0x%X)\n", - PsGetCurrentProcess()->Win32WindowStation); + DPRINT1("Failed validation of window station handle (0x%X)\n", WinSta); SetLastNtError(Status); RETURN( 0); } @@ -986,7 +987,7 @@ ObDereferenceObject(WinStaObject); - DPRINT1("Trying to open desktop (%wZ)\n", &DesktopName); + DPRINT("Trying to open desktop (%wZ)\n", &DesktopName); /* Initialize ObjectAttributes for the desktop object */ InitializeObjectAttributes( @@ -1000,7 +1001,7 @@ &ObjectAttributes, ExDesktopObjectType, NULL, - UserMode, + KernelMode, dwDesiredAccess, NULL, (HANDLE*)&Desktop);
19 years
1
0
0
0
[gvg] 19803: Capture window station name passed from usermode
by gvg@svn.reactos.com
Capture window station name passed from usermode Modified: trunk/reactos/subsys/win32k/ntuser/winsta.c _____ Modified: trunk/reactos/subsys/win32k/ntuser/winsta.c --- trunk/reactos/subsys/win32k/ntuser/winsta.c 2005-12-01 20:06:10 UTC (rev 19802) +++ trunk/reactos/subsys/win32k/ntuser/winsta.c 2005-12-01 20:09:38 UTC (rev 19803) @@ -16,8 +16,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id$ - * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * PURPOSE: Window stations @@ -435,6 +433,7 @@ { PSYSTEM_CURSORINFO CurInfo; UNICODE_STRING WindowStationName; + UNICODE_STRING FullWindowStationName; PWINSTATION_OBJECT WindowStationObject; HWINSTA WindowStation; OBJECT_ATTRIBUTES ObjectAttributes; @@ -443,10 +442,21 @@ /* * Generate full window station name */ - - if (!IntGetFullWindowStationName(&WindowStationName, lpszWindowStationName, + Status = ProbeAndCaptureUnicodeString(&WindowStationName, + UserMode, + lpszWindowStationName); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to capture window station name (status 0x%08x)\n", + Status); + SetLastNtError(Status); + return 0; + } + if (!IntGetFullWindowStationName(&FullWindowStationName, + &WindowStationName, NULL)) { + ReleaseCapturedUnicodeString(&WindowStationName, UserMode); SetLastNtError(STATUS_INSUFFICIENT_RESOURCES); return 0; } @@ -455,12 +465,12 @@ * Try to open already existing window station */ - DPRINT("Trying to open window station (%wZ)\n", &WindowStationName); + DPRINT("Trying to open window station (%wZ)\n", &FullWindowStationName); /* Initialize ObjectAttributes for the window station object */ InitializeObjectAttributes( &ObjectAttributes, - &WindowStationName, + &FullWindowStationName, 0, NULL, NULL); @@ -476,8 +486,10 @@ if (NT_SUCCESS(Status)) { - DPRINT("Successfully opened window station (%wZ)\n", WindowStationName); - ExFreePool(WindowStationName.Buffer); + DPRINT("Successfully opened window station (%wZ)\n", + FullWindowStationName); + ExFreePool(FullWindowStationName.Buffer); + ReleaseCapturedUnicodeString(&WindowStationName, UserMode); return (HWINSTA)WindowStation; } @@ -485,7 +497,7 @@ * No existing window station found, try to create new one */ - DPRINT("Creating window station (%wZ)\n", &WindowStationName); + DPRINT("Creating window station (%wZ)\n", &FullWindowStationName); Status = ObCreateObject( KernelMode, @@ -500,13 +512,14 @@ if (!NT_SUCCESS(Status)) { - DPRINT1("Failed creating window station (%wZ)\n", &WindowStationName); - ExFreePool(WindowStationName.Buffer); + DPRINT1("Failed creating window station (%wZ)\n", &FullWindowStationName); + ExFreePool(FullWindowStationName.Buffer); + ReleaseCapturedUnicodeString(&WindowStationName, UserMode); SetLastNtError(STATUS_INSUFFICIENT_RESOURCES); return 0; } - WindowStationObject->Name = *lpszWindowStationName; + WindowStationObject->Name = WindowStationName; Status = ObInsertObject( (PVOID)WindowStationObject, @@ -518,7 +531,8 @@ if (!NT_SUCCESS(Status)) { - DPRINT1("Failed creating window station (%wZ)\n", &WindowStationName); + DPRINT1("Failed creating window station (%wZ)\n", &FullWindowStationName); + ExFreePool(FullWindowStationName.Buffer); ExFreePool(WindowStationName.Buffer); SetLastNtError(STATUS_INSUFFICIENT_RESOURCES); ObDereferenceObject(WindowStationObject); @@ -531,7 +545,7 @@ if(!(CurInfo = ExAllocatePool(PagedPool, sizeof(SYSTEM_CURSORINFO)))) { - ExFreePool(WindowStationName.Buffer); + ExFreePool(FullWindowStationName.Buffer); /* FIXME - Delete window station object */ ObDereferenceObject(WindowStationObject); SetLastNtError(STATUS_INSUFFICIENT_RESOURCES); @@ -557,10 +571,11 @@ { DPRINT1("Setting up the Cursor/Icon Handle table failed!\n"); /* FIXME: Complain more loudly? */ + ExFreePool(FullWindowStationName.Buffer); } - DPRINT("Window station successfully created (%wZ)\n", lpszWindowStationName); - ExFreePool(WindowStationName.Buffer); + DPRINT("Window station successfully created (%wZ)\n", FullWindowStationName); + ExFreePool(FullWindowStationName.Buffer); return WindowStation; }
19 years
1
0
0
0
[gvg] 19802: Factor out probe and capture code from private ntoskrnl header and put it in
by gvg@svn.reactos.com
Factor out probe and capture code from private ntoskrnl header and put it in a more public place so other kernelmode components can use it too Added: trunk/reactos/include/reactos/probe.h Modified: trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h Modified: trunk/reactos/ntoskrnl/include/ntoskrnl.h _____ Added: trunk/reactos/include/reactos/probe.h --- trunk/reactos/include/reactos/probe.h 2005-12-01 19:51:08 UTC (rev 19801) +++ trunk/reactos/include/reactos/probe.h 2005-12-01 20:06:10 UTC (rev 19802) @@ -0,0 +1,154 @@ +#ifndef INCLUDE_REACTOS_CAPTURE_H +#define INCLUDE_REACTOS_CAPTURE_H + +static const UNICODE_STRING __emptyUnicodeString = {0}; +static const LARGE_INTEGER __emptyLargeInteger = {{0, 0}}; +static const ULARGE_INTEGER __emptyULargeInteger = {{0, 0}}; + +/* + * NOTE: Alignment of the pointers is not verified! + */ +#define ProbeForWriteGenericType(Ptr, Type) \ + do { \ + if ((ULONG_PTR)(Ptr) + sizeof(Type) - 1 < (ULONG_PTR)(Ptr) || \ + (ULONG_PTR)(Ptr) + sizeof(Type) - 1 >= (ULONG_PTR)MmUserProbeAddress) { \ + RtlRaiseStatus (STATUS_ACCESS_VIOLATION); \ + } \ + *(volatile Type *)(Ptr) = *(volatile Type *)(Ptr); \ + } while (0) + +#define ProbeForWriteBoolean(Ptr) ProbeForWriteGenericType(Ptr, BOOLEAN) +#define ProbeForWriteUchar(Ptr) ProbeForWriteGenericType(Ptr, UCHAR) +#define ProbeForWriteChar(Ptr) ProbeForWriteGenericType(Ptr, Char) +#define ProbeForWriteUshort(Ptr) ProbeForWriteGenericType(Ptr, USHORT) +#define ProbeForWriteShort(Ptr) ProbeForWriteGenericType(Ptr, SHORT) +#define ProbeForWriteUlong(Ptr) ProbeForWriteGenericType(Ptr, ULONG) +#define ProbeForWriteLong(Ptr) ProbeForWriteGenericType(Ptr, LONG) +#define ProbeForWriteUint(Ptr) ProbeForWriteGenericType(Ptr, UINT) +#define ProbeForWriteInt(Ptr) ProbeForWriteGenericType(Ptr, INT) +#define ProbeForWriteUlonglong(Ptr) ProbeForWriteGenericType(Ptr, ULONGLONG) +#define ProbeForWriteLonglong(Ptr) ProbeForWriteGenericType(Ptr, LONGLONG) +#define ProbeForWriteLonglong(Ptr) ProbeForWriteGenericType(Ptr, LONGLONG) +#define ProbeForWritePointer(Ptr) ProbeForWriteGenericType(Ptr, PVOID) +#define ProbeForWriteHandle(Ptr) ProbeForWriteGenericType(Ptr, HANDLE) +#define ProbeForWriteLangid(Ptr) ProbeForWriteGenericType(Ptr, LANGID) +#define ProbeForWriteSize_t(Ptr) ProbeForWriteGenericType(Ptr, SIZE_T) +#define ProbeForWriteLargeInteger(Ptr) ProbeForWriteGenericType(&(Ptr)->QuadPart, LONGLONG) +#define ProbeForWriteUlargeInteger(Ptr) ProbeForWriteGenericType(&(Ptr)->QuadPart, ULONGLONG) +#define ProbeForWriteUnicodeString(Ptr) ProbeForWriteGenericType(Ptr, UNICODE_STRING) + +#define ProbeForReadGenericType(Ptr, Type, Default) \ + (((ULONG_PTR)(Ptr) + sizeof(Type) - 1 < (ULONG_PTR)(Ptr) || \ + (ULONG_PTR)(Ptr) + sizeof(Type) - 1 >= (ULONG_PTR)MmUserProbeAddress) ? \ + ExRaiseStatus (STATUS_ACCESS_VIOLATION), Default : \ + *(Type *)(Ptr)) + +#define ProbeForReadBoolean(Ptr) ProbeForReadGenericType(Ptr, BOOLEAN, FALSE) +#define ProbeForReadUchar(Ptr) ProbeForReadGenericType(Ptr, UCHAR, 0) +#define ProbeForReadChar(Ptr) ProbeForReadGenericType(Ptr, CHAR, 0) +#define ProbeForReadUshort(Ptr) ProbeForReadGenericType(Ptr, USHORT, 0) +#define ProbeForReadShort(Ptr) ProbeForReadGenericType(Ptr, SHORT, 0) +#define ProbeForReadUlong(Ptr) ProbeForReadGenericType(Ptr, ULONG, 0) +#define ProbeForReadLong(Ptr) ProbeForReadGenericType(Ptr, LONG, 0) +#define ProbeForReadUint(Ptr) ProbeForReadGenericType(Ptr, UINT, 0) +#define ProbeForReadInt(Ptr) ProbeForReadGenericType(Ptr, INT, 0) +#define ProbeForReadUlonglong(Ptr) ProbeForReadGenericType(Ptr, ULONGLONG, 0) +#define ProbeForReadLonglong(Ptr) ProbeForReadGenericType(Ptr, LONGLONG, 0) +#define ProbeForReadPointer(Ptr) ProbeForReadGenericType(Ptr, PVOID, NULL) +#define ProbeForReadHandle(Ptr) ProbeForReadGenericType(Ptr, HANDLE, NULL) +#define ProbeForReadLangid(Ptr) ProbeForReadGenericType(Ptr, LANGID, 0) +#define ProbeForReadSize_t(Ptr) ProbeForReadGenericType(Ptr, SIZE_T, 0) +#define ProbeForReadLargeInteger(Ptr) ProbeForReadGenericType(Ptr, LARGE_INTEGER, __emptyLargeInteger) +#define ProbeForReadUlargeInteger(Ptr) ProbeForReadGenericType(Ptr, ULARGE_INTEGER, __emptyULargeInteger) +#define ProbeForReadUnicodeString(Ptr) ProbeForReadGenericType(Ptr, UNICODE_STRING, __emptyUnicodeString) + +/* + * Inlined Probing Macros + */ +static __inline +NTSTATUS +NTAPI +ProbeAndCaptureUnicodeString(OUT PUNICODE_STRING Dest, + IN KPROCESSOR_MODE CurrentMode, + IN PUNICODE_STRING UnsafeSrc) +{ + NTSTATUS Status = STATUS_SUCCESS; + WCHAR *Buffer; + ASSERT(Dest != NULL); + + /* Probe the structure and buffer*/ + if(CurrentMode != KernelMode) + { + _SEH_TRY + { + *Dest = ProbeForReadUnicodeString(UnsafeSrc); + if(Dest->Buffer != NULL) + { + if (Dest->Length != 0) + { + ProbeForRead(Dest->Buffer, + Dest->Length, + sizeof(WCHAR)); + + /* Allocate space for the buffer */ + Buffer = ExAllocatePoolWithTag(PagedPool, + Dest->Length + sizeof(WCHAR), + TAG('U', 'S', 'T', 'R')); + if (Buffer == NULL) + { + Status = STATUS_INSUFFICIENT_RESOURCES; + _SEH_LEAVE; + } + + /* Copy it */ + RtlCopyMemory(Buffer, Dest->Buffer, Dest->Length); + Buffer[Dest->Length / sizeof(WCHAR)] = UNICODE_NULL; + + /* Set it as the buffer */ + Dest->Buffer = Buffer; + Dest->MaximumLength = Dest->Length + sizeof(WCHAR); + } + else + { + /* sanitize structure */ + Dest->MaximumLength = 0; + Dest->Buffer = NULL; + } + } + else + { + /* sanitize structure */ + Dest->Length = 0; + Dest->MaximumLength = 0; + } + } + _SEH_HANDLE + { + Status = _SEH_GetExceptionCode(); + } + _SEH_END; + } + else + { + /* Just copy the UNICODE_STRING structure, don't allocate new memory! + We trust the caller to supply valid pointers and data. */ + *Dest = *UnsafeSrc; + } + + /* Return */ + return Status; +} + +static __inline +VOID +NTAPI +ReleaseCapturedUnicodeString(IN PUNICODE_STRING CapturedString, + IN KPROCESSOR_MODE CurrentMode) +{ + if(CurrentMode != KernelMode && CapturedString->Buffer != NULL) + { + ExFreePool(CapturedString->Buffer); + } +} + +#endif /* INCLUDE_REACTOS_CAPTURE_H */ Property changes on: trunk/reactos/include/reactos/probe.h ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native _____ Modified: trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h --- trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h 2005-12-01 19:51:08 UTC (rev 19801) +++ trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h 2005-12-01 20:06:10 UTC (rev 19802) @@ -81,159 +81,7 @@ IN PVOID ContextData, IN ULONG Size); -#define ExRaiseStatus RtlRaiseStatus - -static const UNICODE_STRING __emptyUnicodeString = {0}; -static const LARGE_INTEGER __emptyLargeInteger = {{0, 0}}; -static const ULARGE_INTEGER __emptyULargeInteger = {{0, 0}}; - /* - * NOTE: Alignment of the pointers is not verified! - */ -#define ProbeForWriteGenericType(Ptr, Type) \ - do { \ - if ((ULONG_PTR)(Ptr) + sizeof(Type) - 1 < (ULONG_PTR)(Ptr) || \ - (ULONG_PTR)(Ptr) + sizeof(Type) - 1 >= (ULONG_PTR)MmUserProbeAddress) { \ - RtlRaiseStatus (STATUS_ACCESS_VIOLATION); \ - } \ - *(volatile Type *)(Ptr) = *(volatile Type *)(Ptr); \ - } while (0) - -#define ProbeForWriteBoolean(Ptr) ProbeForWriteGenericType(Ptr, BOOLEAN) -#define ProbeForWriteUchar(Ptr) ProbeForWriteGenericType(Ptr, UCHAR) -#define ProbeForWriteChar(Ptr) ProbeForWriteGenericType(Ptr, Char) -#define ProbeForWriteUshort(Ptr) ProbeForWriteGenericType(Ptr, USHORT) -#define ProbeForWriteShort(Ptr) ProbeForWriteGenericType(Ptr, SHORT) -#define ProbeForWriteUlong(Ptr) ProbeForWriteGenericType(Ptr, ULONG) -#define ProbeForWriteLong(Ptr) ProbeForWriteGenericType(Ptr, LONG) -#define ProbeForWriteUint(Ptr) ProbeForWriteGenericType(Ptr, UINT) -#define ProbeForWriteInt(Ptr) ProbeForWriteGenericType(Ptr, INT) -#define ProbeForWriteUlonglong(Ptr) ProbeForWriteGenericType(Ptr, ULONGLONG) -#define ProbeForWriteLonglong(Ptr) ProbeForWriteGenericType(Ptr, LONGLONG) -#define ProbeForWriteLonglong(Ptr) ProbeForWriteGenericType(Ptr, LONGLONG) -#define ProbeForWritePointer(Ptr) ProbeForWriteGenericType(Ptr, PVOID) -#define ProbeForWriteHandle(Ptr) ProbeForWriteGenericType(Ptr, HANDLE) -#define ProbeForWriteLangid(Ptr) ProbeForWriteGenericType(Ptr, LANGID) -#define ProbeForWriteSize_t(Ptr) ProbeForWriteGenericType(Ptr, SIZE_T) -#define ProbeForWriteLargeInteger(Ptr) ProbeForWriteGenericType(&(Ptr)->QuadPart, LONGLONG) -#define ProbeForWriteUlargeInteger(Ptr) ProbeForWriteGenericType(&(Ptr)->QuadPart, ULONGLONG) -#define ProbeForWriteUnicodeString(Ptr) ProbeForWriteGenericType(Ptr, UNICODE_STRING) - -#define ProbeForReadGenericType(Ptr, Type, Default) \ - (((ULONG_PTR)(Ptr) + sizeof(Type) - 1 < (ULONG_PTR)(Ptr) || \ - (ULONG_PTR)(Ptr) + sizeof(Type) - 1 >= (ULONG_PTR)MmUserProbeAddress) ? \ - ExRaiseStatus (STATUS_ACCESS_VIOLATION), Default : \ - *(Type *)(Ptr)) - -#define ProbeForReadBoolean(Ptr) ProbeForReadGenericType(Ptr, BOOLEAN, FALSE) -#define ProbeForReadUchar(Ptr) ProbeForReadGenericType(Ptr, UCHAR, 0) -#define ProbeForReadChar(Ptr) ProbeForReadGenericType(Ptr, CHAR, 0) -#define ProbeForReadUshort(Ptr) ProbeForReadGenericType(Ptr, USHORT, 0) -#define ProbeForReadShort(Ptr) ProbeForReadGenericType(Ptr, SHORT, 0) -#define ProbeForReadUlong(Ptr) ProbeForReadGenericType(Ptr, ULONG, 0) -#define ProbeForReadLong(Ptr) ProbeForReadGenericType(Ptr, LONG, 0) -#define ProbeForReadUint(Ptr) ProbeForReadGenericType(Ptr, UINT, 0) -#define ProbeForReadInt(Ptr) ProbeForReadGenericType(Ptr, INT, 0) -#define ProbeForReadUlonglong(Ptr) ProbeForReadGenericType(Ptr, ULONGLONG, 0) -#define ProbeForReadLonglong(Ptr) ProbeForReadGenericType(Ptr, LONGLONG, 0) -#define ProbeForReadPointer(Ptr) ProbeForReadGenericType(Ptr, PVOID, NULL) -#define ProbeForReadHandle(Ptr) ProbeForReadGenericType(Ptr, HANDLE, NULL) -#define ProbeForReadLangid(Ptr) ProbeForReadGenericType(Ptr, LANGID, 0) -#define ProbeForReadSize_t(Ptr) ProbeForReadGenericType(Ptr, SIZE_T, 0) -#define ProbeForReadLargeInteger(Ptr) ProbeForReadGenericType(Ptr, LARGE_INTEGER, __emptyLargeInteger) -#define ProbeForReadUlargeInteger(Ptr) ProbeForReadGenericType(Ptr, ULARGE_INTEGER, __emptyULargeInteger) -#define ProbeForReadUnicodeString(Ptr) ProbeForReadGenericType(Ptr, UNICODE_STRING, __emptyUnicodeString) - -/* - * Inlined Probing Macros - */ -static __inline -NTSTATUS -NTAPI -ProbeAndCaptureUnicodeString(OUT PUNICODE_STRING Dest, - IN KPROCESSOR_MODE CurrentMode, - IN PUNICODE_STRING UnsafeSrc) -{ - NTSTATUS Status = STATUS_SUCCESS; - WCHAR *Buffer; - ASSERT(Dest != NULL); - - /* Probe the structure and buffer*/ - if(CurrentMode != KernelMode) - { - _SEH_TRY - { - *Dest = ProbeForReadUnicodeString(UnsafeSrc); - if(Dest->Buffer != NULL) - { - if (Dest->Length != 0) - { - ProbeForRead(Dest->Buffer, - Dest->Length, - sizeof(WCHAR)); - - /* Allocate space for the buffer */ - Buffer = ExAllocatePoolWithTag(PagedPool, - Dest->Length + sizeof(WCHAR), - TAG('U', 'S', 'T', 'R')); - if (Buffer == NULL) - { - Status = STATUS_INSUFFICIENT_RESOURCES; - _SEH_LEAVE; - } - - /* Copy it */ - RtlCopyMemory(Buffer, Dest->Buffer, Dest->Length); - Buffer[Dest->Length / sizeof(WCHAR)] = UNICODE_NULL; - - /* Set it as the buffer */ - Dest->Buffer = Buffer; - Dest->MaximumLength = Dest->Length + sizeof(WCHAR); - } - else - { - /* sanitize structure */ - Dest->MaximumLength = 0; - Dest->Buffer = NULL; - } - } - else - { - /* sanitize structure */ - Dest->Length = 0; - Dest->MaximumLength = 0; - } - } - _SEH_HANDLE - { - Status = _SEH_GetExceptionCode(); - } - _SEH_END; - } - else - { - /* Just copy the UNICODE_STRING structure, don't allocate new memory! - We trust the caller to supply valid pointers and data. */ - *Dest = *UnsafeSrc; - } - - /* Return */ - return Status; -} - -static __inline -VOID -NTAPI -ReleaseCapturedUnicodeString(IN PUNICODE_STRING CapturedString, - IN KPROCESSOR_MODE CurrentMode) -{ - if(CurrentMode != KernelMode && CapturedString->Buffer != NULL) - { - ExFreePool(CapturedString->Buffer); - } -} - -/* * generic information class probing code */ _____ Modified: trunk/reactos/ntoskrnl/include/ntoskrnl.h --- trunk/reactos/ntoskrnl/include/ntoskrnl.h 2005-12-01 19:51:08 UTC (rev 19801) +++ trunk/reactos/ntoskrnl/include/ntoskrnl.h 2005-12-01 20:06:10 UTC (rev 19802) @@ -21,12 +21,6 @@ /* FIXME: Temporary until CC Ros is gone */ #include <ccros.h> -/* ReactOS Headers */ -#include <reactos/version.h> -#include <reactos/resource.h> -#include <reactos/bugcodes.h> -#include <reactos/rossym.h> - /* Disk Dump Driver Header */ #include <diskdump/diskdump.h> @@ -39,6 +33,14 @@ /* SEH support with PSEH */ #include <pseh/pseh.h> +/* ReactOS Headers */ +#include <reactos/version.h> +#include <reactos/resource.h> +#include <reactos/bugcodes.h> +#include <reactos/rossym.h> +#define ExRaiseStatus RtlRaiseStatus +#include <reactos/probe.h> + /* PNP GUIDs */ #include <umpnpmgr/sysguid.h>
19 years
1
0
0
0
[hpoussin] 19801: Link video miniports to videoprt library only
by hpoussin@svn.reactos.com
Link video miniports to videoprt library only Modified: trunk/reactos/drivers/video/miniport/vbe/vbemp.c Modified: trunk/reactos/drivers/video/miniport/vbe/vbemp.h Modified: trunk/reactos/drivers/video/miniport/vbe/vbemp.xml Modified: trunk/reactos/drivers/video/miniport/vga/vgamp.c Modified: trunk/reactos/drivers/video/miniport/vga/vgamp.h Modified: trunk/reactos/drivers/video/miniport/vga/vgamp.xml Modified: trunk/reactos/drivers/video/videoprt/videoprt.c Modified: trunk/reactos/drivers/video/videoprt/videoprt.h _____ Modified: trunk/reactos/drivers/video/miniport/vbe/vbemp.c --- trunk/reactos/drivers/video/miniport/vbe/vbemp.c 2005-12-01 17:23:26 UTC (rev 19800) +++ trunk/reactos/drivers/video/miniport/vbe/vbemp.c 2005-12-01 19:51:08 UTC (rev 19801) @@ -29,9 +29,6 @@ #include "vbemp.h" -#define NDEBUG -#include <debug.h> - /* PUBLIC AND PRIVATE FUNCTIONS ***********************************************/ VP_STATUS STDCALL @@ -80,7 +77,7 @@ static int VBESortModesCallback(PVBE_MODEINFO VbeModeInfoA, PVBE_MODEINFO VbeModeInfoB) { - DPRINT("VBESortModesCallback: %dx%dx%d / %dx%dx%d\n", + VideoPortDebugPrint(Info, "VBESortModesCallback: %dx%dx%d / %dx%dx%d\n", VbeModeInfoA->XResolution, VbeModeInfoA->YResolution, VbeModeInfoA->BitsPerPixel, VbeModeInfoB->XResolution, VbeModeInfoB->YResolution, @@ -190,7 +187,7 @@ if (Status != NO_ERROR) { - DPRINT1("Failed to get Int 10 service functions (Status %x)\n", Status); + VideoPortDebugPrint(Error, "Failed to get Int 10 service functions (Status %x)\n", Status); return FALSE; } @@ -209,7 +206,7 @@ if (Status != NO_ERROR) { - DPRINT1("Failed to allocate virtual memory (Status %x)\n", Status); + VideoPortDebugPrint(Error, "Failed to allocate virtual memory (Status %x)\n", Status); return FALSE; } @@ -242,9 +239,9 @@ sizeof(VBEDeviceExtension->VbeInfo)); /* Verify VBE is found and not an²thing else */ - if (strncmp(VBEDeviceExtension->VbeInfo.Signature,"VESA",4) != 0) + if (VideoPortCompareMemory(VBEDeviceExtension->VbeInfo.Signature, "VESA", 4) != 4) { - DPRINT("No VBE BIOS present\n"); + VideoPortDebugPrint(Warn, "No VBE BIOS present\n"); return FALSE; } @@ -254,7 +251,7 @@ VBEDeviceExtension->VbeInfo.Version = 0x102; } - DPRINT("VBE BIOS Present (%d.%d, %8ld Kb)\n", + VideoPortDebugPrint(Trace, "VBE BIOS Present (%d.%d, %8ld Kb)\n", VBEDeviceExtension->VbeInfo.Version / 0x100, VBEDeviceExtension->VbeInfo.Version & 0xFF, VBEDeviceExtension->VbeInfo.TotalMemory * 64); @@ -265,13 +262,13 @@ if (VBEDeviceExtension->VbeInfo.Version < 0x200) #endif { - DPRINT("VBE BIOS present, but incompatible version.\n"); + VideoPortDebugPrint(Warn, "VBE BIOS present, but incompatible version.\n"); return FALSE; } } else { - DPRINT("No VBE BIOS found.\n"); + VideoPortDebugPrint(Warn, "No VBE BIOS found.\n"); return FALSE; } @@ -308,9 +305,9 @@ */ VBEDeviceExtension->ModeInfo = - ExAllocatePool(PagedPool, ModeCount * sizeof(VBE_MODEINFO)); + VideoPortAllocatePool(HwDeviceExtension, VpPagedPool, ModeCount * sizeof(VBE_MODEINFO), TAG_VBE); VBEDeviceExtension->ModeNumbers = - ExAllocatePool(PagedPool, ModeCount * sizeof(WORD)); + VideoPortAllocatePool(HwDeviceExtension, VpPagedPool, ModeCount * sizeof(WORD), TAG_VBE); /* * Get the actual mode infos. @@ -372,7 +369,7 @@ if (SuitableModeCount == 0) { - DPRINT("VBEMP: No video modes supported\n"); + VideoPortDebugPrint(Warn, "VBEMP: No video modes supported\n"); return FALSE; } @@ -388,17 +385,15 @@ * Print the supported video modes when NDEBUG is not set. */ -#ifndef NDEBUG for (CurrentMode = 0; CurrentMode < SuitableModeCount; CurrentMode++) { - DPRINT("%dx%dx%d\n", + VideoPortDebugPrint(Trace, "%dx%dx%d\n", VBEDeviceExtension->ModeInfo[CurrentMode].XResolution, VBEDeviceExtension->ModeInfo[CurrentMode].YResolution, VBEDeviceExtension->ModeInfo[CurrentMode].BitsPerPixel); } -#endif return TRUE; } @@ -746,7 +741,7 @@ } else { - DPRINT1("VBEMP: VBESetCurrentMode failed (%x)\n", BiosRegisters.Eax); + VideoPortDebugPrint(Error, "VBEMP: VBESetCurrentMode failed (%x)\n", BiosRegisters.Eax); DeviceExtension->CurrentMode = -1; } _____ Modified: trunk/reactos/drivers/video/miniport/vbe/vbemp.h --- trunk/reactos/drivers/video/miniport/vbe/vbemp.h 2005-12-01 17:23:26 UTC (rev 19800) +++ trunk/reactos/drivers/video/miniport/vbe/vbemp.h 2005-12-01 19:51:08 UTC (rev 19801) @@ -28,6 +28,9 @@ #include <ddk/video.h> #include <ddk/ntddvdeo.h> +#define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24)) +#define TAG_VBE TAG('V', 'B', 'E', ' ') + /* * Compile-time define to get VBE 1.2 support. The implementation * is far from complete now and so it's left undefined. _____ Modified: trunk/reactos/drivers/video/miniport/vbe/vbemp.xml --- trunk/reactos/drivers/video/miniport/vbe/vbemp.xml 2005-12-01 17:23:26 UTC (rev 19800) +++ trunk/reactos/drivers/video/miniport/vbe/vbemp.xml 2005-12-01 19:51:08 UTC (rev 19801) @@ -1,9 +1,6 @@ <module name="vbemp" type="kernelmodedriver" installbase="system32/drivers" installname="vbemp.sys"> <include base="vbemp">.</include> - <include base="ntoskrnl">include</include> <define name="__USE_W32API" /> - <library>ntoskrnl</library> - <library>hal</library> <library>videoprt</library> <file>vbemp.c</file> <file>vbemp.rc</file> _____ Modified: trunk/reactos/drivers/video/miniport/vga/vgamp.c --- trunk/reactos/drivers/video/miniport/vga/vgamp.c 2005-12-01 17:23:26 UTC (rev 19800) +++ trunk/reactos/drivers/video/miniport/vga/vgamp.c 2005-12-01 19:51:08 UTC (rev 19801) @@ -526,7 +526,7 @@ InitVGAMode(); return TRUE; } else { - DPRINT1("Unrecognised mode for VGASetCurrentMode\n"); + VideoPortDebugPrint(Warn, "Unrecognised mode for VGASetCurrentMode\n"); return FALSE; } } _____ Modified: trunk/reactos/drivers/video/miniport/vga/vgamp.h --- trunk/reactos/drivers/video/miniport/vga/vgamp.h 2005-12-01 17:23:26 UTC (rev 19800) +++ trunk/reactos/drivers/video/miniport/vga/vgamp.h 2005-12-01 19:51:08 UTC (rev 19801) @@ -27,8 +27,10 @@ #include <ddk/miniport.h> #include <ddk/video.h> #include <ddk/ntddvdeo.h> -#include <debug.h> +#define UNIMPLEMENTED \ + VideoPortDebugPrint(Error, "WARNING: %s at %s:%d is UNIMPLEMENTED!\n",__FUNCTION__,__FILE__,__LINE__); + void InitVGAMode(); _____ Modified: trunk/reactos/drivers/video/miniport/vga/vgamp.xml --- trunk/reactos/drivers/video/miniport/vga/vgamp.xml 2005-12-01 17:23:26 UTC (rev 19800) +++ trunk/reactos/drivers/video/miniport/vga/vgamp.xml 2005-12-01 19:51:08 UTC (rev 19801) @@ -1,9 +1,6 @@ <module name="vgamp" type="kernelmodedriver" installbase="system32/drivers" installname="vgamp.sys"> <include base="vgamp">.</include> - <include base="ntoskrnl">include</include> <define name="__USE_W32API" /> - <library>ntoskrnl</library> - <library>hal</library> <library>videoprt</library> <file>initvga.c</file> <file>vgamp.c</file> _____ Modified: trunk/reactos/drivers/video/videoprt/videoprt.c --- trunk/reactos/drivers/video/videoprt/videoprt.c 2005-12-01 17:23:26 UTC (rev 19800) +++ trunk/reactos/drivers/video/videoprt/videoprt.c 2005-12-01 19:51:08 UTC (rev 19801) @@ -658,7 +658,7 @@ vsprintf(Buffer, DebugMessage, ap); va_end(ap); - DbgPrint(Buffer); + DbgPrintEx(DPFLTR_IHVVIDEO_ID, DebugPrintLevel, Buffer); } /* _____ Modified: trunk/reactos/drivers/video/videoprt/videoprt.h --- trunk/reactos/drivers/video/videoprt/videoprt.h 2005-12-01 17:23:26 UTC (rev 19800) +++ trunk/reactos/drivers/video/videoprt/videoprt.h 2005-12-01 19:51:08 UTC (rev 19801) @@ -39,6 +39,8 @@ #define TAG_VIDEO_PORT TAG('V', 'I', 'D', 'P') +#define DPFLTR_IHVVIDEO_ID 0 /* FIXME */ + typedef struct _VIDEO_PORT_ADDRESS_MAPPING { LIST_ENTRY List;
19 years
1
0
0
0
[weiden] 19800: handle device updates in the advanced property pages and refresh the information
by weiden@svn.reactos.com
handle device updates in the advanced property pages and refresh the information Modified: trunk/reactos/lib/devmgr/advprop.c Modified: trunk/reactos/lib/devmgr/hwpage.c Modified: trunk/reactos/lib/devmgr/precomp.h _____ Modified: trunk/reactos/lib/devmgr/advprop.c --- trunk/reactos/lib/devmgr/advprop.c 2005-12-01 17:08:52 UTC (rev 19799) +++ trunk/reactos/lib/devmgr/advprop.c 2005-12-01 17:23:26 UTC (rev 19800) @@ -51,6 +51,8 @@ BOOL DeviceEnabled; WCHAR szDevName[255]; WCHAR szTemp[255]; + WCHAR szDeviceID[1]; + /* struct may be dynamically expanded here! */ } DEVADVPROP_INFO, *PDEVADVPROP_INFO; @@ -188,11 +190,25 @@ static VOID UpdateDevInfo(IN HWND hwndDlg, - IN PDEVADVPROP_INFO dap) + IN PDEVADVPROP_INFO dap, + IN BOOL ReOpenDevice) { HICON hIcon; HWND hDevUsage; + if (ReOpenDevice) + { + /* note, we ignore the fact that SetupDiOpenDeviceInfo could fail here, + in case of failure we're still going to query information from it even + though those calls are going to fail. But they return readable strings + even in that case. */ + SetupDiOpenDeviceInfo(dap->DeviceInfoSet, + dap->szDeviceID, + hwndDlg, + 0, + dap->DeviceInfoData); + } + /* get the device name */ if (GetDeviceDescriptionString(dap->DeviceInfoSet, dap->DeviceInfoData, @@ -367,7 +383,8 @@ (DWORD_PTR)dap); UpdateDevInfo(hwndDlg, - dap); + dap, + FALSE); } Ret = TRUE; break; @@ -377,7 +394,8 @@ { /* FIXME - don't call UpdateDevInfo in all events */ UpdateDevInfo(hwndDlg, - dap); + dap, + TRUE); break; } @@ -406,6 +424,7 @@ INT_PTR DisplayDeviceAdvancedProperties(IN HWND hWndParent, + IN LPCWSTR lpDeviceID OPTIONAL, IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData, IN HINSTANCE hComCtl32, @@ -420,6 +439,7 @@ PDEVADVPROP_INFO DevAdvPropInfo; DWORD PropertySheetType; HANDLE hMachine = NULL; + DWORD DevIdSize = 0; INT_PTR Ret = -1; /* we don't want to statically link against comctl32, so find the @@ -440,6 +460,29 @@ return -1; } + if (lpDeviceID == NULL) + { + /* find out how much size is needed for the device id */ + if (SetupDiGetDeviceInstanceId(DeviceInfoSet, + DeviceInfoData, + NULL, + 0, + &DevIdSize)) + { + DPRINT1("SetupDiGetDeviceInterfaceDetail unexpectedly returned TRUE!\n"); + return -1; + } + + if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) + { + return -1; + } + } + else + { + DevIdSize = (DWORD)wcslen(lpDeviceID) + 1; + } + if (lpMachineName != NULL) { CONFIGRET cr = CM_Connect_Machine(lpMachineName, @@ -454,12 +497,27 @@ "Driver", ... pages */ DevAdvPropInfo = HeapAlloc(GetProcessHeap(), 0, - sizeof(DEVADVPROP_INFO)); + FIELD_OFFSET(DEVADVPROP_INFO, + szDeviceID) + + (DevIdSize * sizeof(WCHAR))); if (DevAdvPropInfo == NULL) { goto Cleanup; } + if (lpDeviceID == NULL) + { + /* read the device instance id */ + if (!SetupDiGetDeviceInstanceId(DeviceInfoSet, + DeviceInfoData, + DevAdvPropInfo->szDeviceID, + DevIdSize, + NULL)) + { + goto Cleanup; + } + } + DevAdvPropInfo->DeviceInfoSet = DeviceInfoSet; DevAdvPropInfo->DeviceInfoData = DeviceInfoData; DevAdvPropInfo->hComCtl32 = hComCtl32; @@ -630,6 +688,7 @@ &DevInfoData)) { Ret = DisplayDeviceAdvancedProperties(hWndParent, + lpDeviceID, hDevInfo, &DevInfoData, hComCtl32, _____ Modified: trunk/reactos/lib/devmgr/hwpage.c --- trunk/reactos/lib/devmgr/hwpage.c 2005-12-01 17:08:52 UTC (rev 19799) +++ trunk/reactos/lib/devmgr/hwpage.c 2005-12-01 17:23:26 UTC (rev 19800) @@ -135,6 +135,7 @@ if (HwDevInfo != NULL) { Ret = DisplayDeviceAdvancedProperties(hpd->hWnd, + NULL, HwDevInfo->ClassDevInfo->hDevInfo, &HwDevInfo->DevInfoData, hpd->hComCtl32, _____ Modified: trunk/reactos/lib/devmgr/precomp.h --- trunk/reactos/lib/devmgr/precomp.h 2005-12-01 17:08:52 UTC (rev 19799) +++ trunk/reactos/lib/devmgr/precomp.h 2005-12-01 17:23:26 UTC (rev 19800) @@ -184,6 +184,7 @@ INT_PTR DisplayDeviceAdvancedProperties(IN HWND hWndParent, + IN LPCWSTR lpDeviceID OPTIONAL, IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DeviceInfoData, IN HINSTANCE hComCtl32,
19 years
1
0
0
0
[weiden] 19799: Patch by Sylvain Petreolle <spetreolle@yahoo.fr>
by weiden@svn.reactos.com
Patch by Sylvain Petreolle <spetreolle(a)yahoo.fr> - Remove rosapps' shutdown.exe from the bootcd Modified: trunk/reactos/bootdata/packages/reactos.dff _____ Modified: trunk/reactos/bootdata/packages/reactos.dff --- trunk/reactos/bootdata/packages/reactos.dff 2005-12-01 16:02:15 UTC (rev 19798) +++ trunk/reactos/bootdata/packages/reactos.dff 2005-12-01 17:08:52 UTC (rev 19799) @@ -352,6 +352,5 @@ modules\rosapps\sysutils\man\man.exe 1 optional modules\rosapps\sysutils\pedump\pedump.exe 1 optional modules\rosapps\sysutils\regexpl\regexpl.exe 1 optional -modules\rosapps\sysutils\shutdown\shutdown.exe 1 optional modules\rosapps\sysutils\tcat\cat.exe 1 optional modules\rosapps\sysutils\tlist\tlist.exe 1 optional
19 years
1
0
0
0
[weiden] 19798: - display whether the device is enabled or disabled
by weiden@svn.reactos.com
- display whether the device is enabled or disabled - add the remaining missing device node status codes Modified: trunk/reactos/lib/devmgr/En.rc Modified: trunk/reactos/lib/devmgr/advprop.c Modified: trunk/reactos/lib/devmgr/misc.c Modified: trunk/reactos/lib/devmgr/precomp.h Modified: trunk/reactos/lib/devmgr/resource.h Modified: trunk/reactos/w32api/include/setupapi.h _____ Modified: trunk/reactos/lib/devmgr/En.rc --- trunk/reactos/lib/devmgr/En.rc 2005-12-01 15:37:00 UTC (rev 19797) +++ trunk/reactos/lib/devmgr/En.rc 2005-12-01 16:02:15 UTC (rev 19798) @@ -12,6 +12,9 @@ IDS_UNKNOWN "Unknown" IDS_LOCATIONSTR "Location %1!u! (%2)" IDS_DEVCODE " (Code %1!u!)" + IDS_ENABLEDEVICE "Use this device (enable)" + IDS_DISABLEDEVICE "Do not use this device (disable)" + IDS_UNKNOWNDEVICE "Unknown device" END STRINGTABLE @@ -100,6 +103,6 @@ GROUPBOX "Device status", IDC_DEVSTATUSGROUP, 7, 83, 238, 100 EDITTEXT IDC_DEVSTATUS, 14, 96, 224, 61, NOT WS_TABSTOP | ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL PUSHBUTTON "&Troubleshoot...", IDC_TROUBLESHOOT, 148, 163, 90, 15 - LTEXT "&Device usage:", -1, 7, 188, 222, 8 - COMBOBOX IDC_DEVUSAGE, 7, 198, 239, 40, CBS_DROPDOWNLIST | WS_VSCROLL + LTEXT "&Device usage:", IDC_DEVUSAGELABEL, 7, 188, 222, 8, WS_DISABLED + COMBOBOX IDC_DEVUSAGE, 7, 198, 239, 40, CBS_DROPDOWNLIST | WS_VSCROLL | WS_DISABLED END _____ Modified: trunk/reactos/lib/devmgr/advprop.c --- trunk/reactos/lib/devmgr/advprop.c 2005-12-01 15:37:00 UTC (rev 19797) +++ trunk/reactos/lib/devmgr/advprop.c 2005-12-01 16:02:15 UTC (rev 19798) @@ -34,17 +34,282 @@ typedef HPROPSHEETPAGE (WINAPI *PCREATEPROPERTYSHEETPAGEW)(LPCPROPSHEETPAGEW); typedef BOOL (WINAPI *PDESTROYPROPERTYSHEETPAGE)(HPROPSHEETPAGE); +typedef enum +{ + DEA_DISABLE = 0, + DEA_ENABLE, + DEA_UNKNOWN +} DEVENABLEACTION; + typedef struct _DEVADVPROP_INFO { HDEVINFO DeviceInfoSet; PSP_DEVINFO_DATA DeviceInfoData; HINSTANCE hComCtl32; HANDLE hMachine; + BOOL CanDisable; + BOOL DeviceEnabled; WCHAR szDevName[255]; WCHAR szTemp[255]; } DEVADVPROP_INFO, *PDEVADVPROP_INFO; +static VOID +InitDevUsageActions(IN HWND hwndDlg, + IN HWND hComboBox, + IN PDEVADVPROP_INFO dap) +{ + INT Index; + UINT i; + struct + { + UINT szId; + DEVENABLEACTION Action; + } Actions[] = + { + {IDS_ENABLEDEVICE, DEA_ENABLE}, + {IDS_DISABLEDEVICE, DEA_DISABLE}, + }; + + for (i = 0; + i != sizeof(Actions) / sizeof(Actions[0]); + i++) + { + /* fill in the device usage combo box */ + if (LoadString(hDllInstance, + Actions[i].szId, + dap->szTemp, + sizeof(dap->szTemp) / sizeof(dap->szTemp[0]))) + { + Index = (INT)SendMessage(hComboBox, + CB_ADDSTRING, + 0, + (LPARAM)dap->szTemp); + if (Index != CB_ERR) + { + SendMessage(hComboBox, + CB_SETITEMDATA, + (WPARAM)Index, + (LPARAM)Actions[i].Action); + + switch (Actions[i].Action) + { + case DEA_ENABLE: + if (dap->DeviceEnabled) + { + SendMessage(hComboBox, + CB_SETCURSEL, + (WPARAM)Index, + 0); + } + break; + + case DEA_DISABLE: + if (!dap->DeviceEnabled) + { + SendMessage(hComboBox, + CB_SETCURSEL, + (WPARAM)Index, + 0); + } + break; + + default: + break; + } + } + } + } +} + + +static DEVENABLEACTION +GetSelectedUsageAction(IN HWND hComboBox) +{ + INT Index; + DEVENABLEACTION Ret = DEA_UNKNOWN; + + Index = (INT)SendMessage(hComboBox, + CB_GETCURSEL, + 0, + 0); + if (Index != CB_ERR) + { + INT iRet = SendMessage(hComboBox, + CB_GETITEMDATA, + (WPARAM)Index, + 0); + if (iRet != CB_ERR && iRet < (INT)DEA_UNKNOWN) + { + Ret = (DEVENABLEACTION)iRet; + } + } + + return Ret; +} + + +static VOID +ApplyGeneralSettings(IN HWND hwndDlg, + IN PDEVADVPROP_INFO dap) +{ + DEVENABLEACTION SelectedUsageAction; + + SelectedUsageAction = GetSelectedUsageAction(GetDlgItem(hwndDlg, + IDC_DEVUSAGE)); + if (SelectedUsageAction != DEA_UNKNOWN) + { + switch (SelectedUsageAction) + { + case DEA_ENABLE: + if (!dap->DeviceEnabled) + { + /* FIXME - enable device */ + } + break; + + case DEA_DISABLE: + if (dap->DeviceEnabled) + { + /* FIXME - disable device */ + } + break; + + default: + break; + } + + /* disable the apply button */ + PropSheet_UnChanged(GetParent(hwndDlg), + hwndDlg); + } +} + + +static VOID +UpdateDevInfo(IN HWND hwndDlg, + IN PDEVADVPROP_INFO dap) +{ + HICON hIcon; + HWND hDevUsage; + + /* get the device name */ + if (GetDeviceDescriptionString(dap->DeviceInfoSet, + dap->DeviceInfoData, + dap->szDevName, + sizeof(dap->szDevName) / sizeof(dap->szDevName[0]))) + { + PropSheet_SetTitle(GetParent(hwndDlg), + PSH_PROPTITLE, + dap->szDevName); + } + + /* set the device image */ + if (SetupDiLoadClassIcon(&dap->DeviceInfoData->ClassGuid, + &hIcon, + NULL)) + { + HICON hOldIcon = (HICON)SendDlgItemMessage(hwndDlg, + IDC_DEVICON, + STM_SETICON, + (WPARAM)hIcon, + 0); + if (hOldIcon != NULL) + { + DestroyIcon(hOldIcon); + } + } + + /* set the device name edit control text */ + SetDlgItemText(hwndDlg, + IDC_DEVNAME, + dap->szDevName); + + /* set the device type edit control text */ + if (GetDeviceTypeString(dap->DeviceInfoData, + dap->szTemp, + sizeof(dap->szTemp) / sizeof(dap->szTemp[0]))) + { + SetDlgItemText(hwndDlg, + IDC_DEVTYPE, + dap->szTemp); + } + + /* set the device manufacturer edit control text */ + if (GetDeviceManufacturerString(dap->DeviceInfoSet, + dap->DeviceInfoData, + dap->szTemp, + sizeof(dap->szTemp) / sizeof(dap->szTemp[0]))) + { + SetDlgItemText(hwndDlg, + IDC_DEVMANUFACTURER, + dap->szTemp); + } + + /* set the device location edit control text */ + if (GetDeviceLocationString(dap->DeviceInfoData->DevInst, + dap->szTemp, + sizeof(dap->szTemp) / sizeof(dap->szTemp[0]))) + { + SetDlgItemText(hwndDlg, + IDC_DEVLOCATION, + dap->szTemp); + } + + /* set the device status edit control text */ + if (GetDeviceStatusString(dap->DeviceInfoData->DevInst, + dap->hMachine, + dap->szTemp, + sizeof(dap->szTemp) / sizeof(dap->szTemp[0]))) + { + SetDlgItemText(hwndDlg, + IDC_DEVSTATUS, + dap->szTemp); + } + + /* check if the device can be enabled/disabled */ + hDevUsage = GetDlgItem(hwndDlg, + IDC_DEVUSAGE); + + if (!CanDisableDevice(dap->DeviceInfoData->DevInst, + dap->hMachine, + &dap->CanDisable)) + { + dap->CanDisable = FALSE; + } + + if (!IsDeviceEnabled(dap->DeviceInfoData->DevInst, + dap->hMachine, + &dap->DeviceEnabled)) + { + dap->DeviceEnabled = FALSE; + } + + /* enable/disable the device usage controls */ + EnableWindow(GetDlgItem(hwndDlg, + IDC_DEVUSAGELABEL), + dap->CanDisable); + EnableWindow(hDevUsage, + dap->CanDisable); + + /* clear the combobox */ + SendMessage(hDevUsage, + CB_RESETCONTENT, + 0, + 0); + if (dap->CanDisable) + { + InitDevUsageActions(hwndDlg, + hDevUsage, + dap); + } + + /* finally, disable the apply button */ + PropSheet_UnChanged(GetParent(hwndDlg), + hwndDlg); +} + + static INT_PTR CALLBACK AdvPropGeneralDlgProc(IN HWND hwndDlg, @@ -62,80 +327,60 @@ { switch (uMsg) { + case WM_COMMAND: + { + switch (LOWORD(wParam)) + { + case IDC_DEVUSAGE: + { + if (HIWORD(wParam) == CBN_SELCHANGE) + { + PropSheet_Changed(GetParent(hwndDlg), + hwndDlg); + } + break; + } + } + break; + } + + case WM_NOTIFY: + { + NMHDR *hdr = (NMHDR*)lParam; + switch (hdr->code) + { + case PSN_APPLY: + ApplyGeneralSettings(hwndDlg, + dap); + break; + } + break; + } + case WM_INITDIALOG: { dap = (PDEVADVPROP_INFO)((LPPROPSHEETPAGE)lParam)->lParam; if (dap != NULL) { - HICON hIcon; - SetWindowLongPtr(hwndDlg, DWL_USER, (DWORD_PTR)dap); - /* set the device image */ - if (SetupDiLoadClassIcon(&dap->DeviceInfoData->ClassGuid, - &hIcon, - NULL)) - { - SendDlgItemMessage(hwndDlg, - IDC_DEVICON, - STM_SETICON, - (WPARAM)hIcon, - 0); - } - - /* set the device name edit control text */ - SetDlgItemText(hwndDlg, - IDC_DEVNAME, - dap->szDevName); - - /* set the device type edit control text */ - if (GetDeviceTypeString(dap->DeviceInfoData, - dap->szTemp, - sizeof(dap->szTemp) / sizeof(dap->szTemp[0]))) - { - SetDlgItemText(hwndDlg, - IDC_DEVTYPE, - dap->szTemp); - } - - /* set the device manufacturer edit control text */ - if (GetDeviceManufacturerString(dap->DeviceInfoSet, - dap->DeviceInfoData, - dap->szTemp, - sizeof(dap->szTemp) / sizeof(dap->szTemp[0]))) - { - SetDlgItemText(hwndDlg, - IDC_DEVMANUFACTURER, - dap->szTemp); - } - - /* set the device location edit control text */ - if (GetDeviceLocationString(dap->DeviceInfoData->DevInst, - dap->szTemp, - sizeof(dap->szTemp) / sizeof(dap->szTemp[0]))) - { - SetDlgItemText(hwndDlg, - IDC_DEVLOCATION, - dap->szTemp); - } - - /* set the device status edit control text */ - if (GetDeviceStatusString(dap->DeviceInfoData->DevInst, - dap->hMachine, - dap->szTemp, - sizeof(dap->szTemp) / sizeof(dap->szTemp[0]))) - { - SetDlgItemText(hwndDlg, - IDC_DEVSTATUS, - dap->szTemp); - } + UpdateDevInfo(hwndDlg, + dap); } Ret = TRUE; break; } + case WM_DEVICECHANGE: + { + /* FIXME - don't call UpdateDevInfo in all events */ + UpdateDevInfo(hwndDlg, + dap); + break; + } + case WM_DESTROY: { HICON hDevIcon; @@ -221,106 +466,99 @@ DevAdvPropInfo->hMachine = hMachine; DevAdvPropInfo->szDevName[0] = L'\0'; - /* get the device name */ - if (GetDeviceDescriptionString(DeviceInfoSet, - DeviceInfoData, - DevAdvPropInfo->szDevName, - sizeof(DevAdvPropInfo->szDevName) / sizeof(DevAdvPropInfo->szDevName[0]))) + psh.dwSize = sizeof(PROPSHEETHEADER); + psh.dwFlags = PSH_PROPTITLE | PSH_NOAPPLYNOW; + psh.hwndParent = hWndParent; + psh.pszCaption = DevAdvPropInfo->szDevName; + + PropertySheetType = lpMachineName != NULL ? + DIGCDP_FLAG_REMOTE_ADVANCED : + DIGCDP_FLAG_ADVANCED; + + /* find out how many property sheets we need */ + if (SetupDiGetClassDevPropertySheets(DeviceInfoSet, + DeviceInfoData, + &psh, + 0, + &nPropSheets, + PropertySheetType) && + nPropSheets != 0) { - psh.dwSize = sizeof(PROPSHEETHEADER); - psh.dwFlags = PSH_PROPTITLE; - psh.hwndParent = hWndParent; - psh.pszCaption = DevAdvPropInfo->szDevName; + DPRINT1("SetupDiGetClassDevPropertySheets unexpectedly returned TRUE!\n"); + goto Cleanup; + } - PropertySheetType = lpMachineName != NULL ? - DIGCDP_FLAG_REMOTE_ADVANCED : - DIGCDP_FLAG_ADVANCED; + if (nPropSheets != 0 && GetLastError() != ERROR_INSUFFICIENT_BUFFER) + { + goto Cleanup; + } - /* find out how many property sheets we need */ - if (SetupDiGetClassDevPropertySheets(DeviceInfoSet, - DeviceInfoData, - &psh, - 0, - &nPropSheets, - PropertySheetType) && - nPropSheets != 0) - { - DPRINT1("SetupDiGetClassDevPropertySheets unexpectedly returned TRUE!\n"); - goto Cleanup; - } + psh.phpage = HeapAlloc(GetProcessHeap(), + HEAP_ZERO_MEMORY, + (nPropSheets + 1) * sizeof(HPROPSHEETPAGE)); + if (psh.phpage == NULL) + { + goto Cleanup; + } - if (nPropSheets != 0 && GetLastError() != ERROR_INSUFFICIENT_BUFFER) - { - goto Cleanup; - } + /* add the "General" property sheet */ + pspGeneral.dwSize = sizeof(PROPSHEETPAGE); + pspGeneral.dwFlags = PSP_DEFAULT; + pspGeneral.hInstance = hDllInstance; + pspGeneral.pszTemplate = (LPCWSTR)MAKEINTRESOURCE(IDD_DEVICEGENERAL); + pspGeneral.pfnDlgProc = AdvPropGeneralDlgProc; + pspGeneral.lParam = (LPARAM)DevAdvPropInfo; + psh.phpage[0] = pCreatePropertySheetPageW(&pspGeneral); + if (psh.phpage[0] != NULL) + { + psh.nPages++; + } - psh.phpage = HeapAlloc(GetProcessHeap(), - HEAP_ZERO_MEMORY, - (nPropSheets + 1) * sizeof(HPROPSHEETPAGE)); - if (psh.phpage == NULL) + if (nPropSheets != 0) + { + /* create the device property sheets */ + if (!SetupDiGetClassDevPropertySheets(DeviceInfoSet, + DeviceInfoData, + &psh, + nPropSheets + psh.nPages, + NULL, + PropertySheetType)) { goto Cleanup; } + } - /* add the "General" property sheet */ - pspGeneral.dwSize = sizeof(PROPSHEETPAGE); - pspGeneral.dwFlags = PSP_DEFAULT; - pspGeneral.hInstance = hDllInstance; - pspGeneral.pszTemplate = (LPCWSTR)MAKEINTRESOURCE(IDD_DEVICEGENERAL); - pspGeneral.pfnDlgProc = AdvPropGeneralDlgProc; - pspGeneral.lParam = (LPARAM)DevAdvPropInfo; - psh.phpage[0] = pCreatePropertySheetPageW(&pspGeneral); - if (psh.phpage[0] != NULL) - { - psh.nPages++; - } + /* FIXME - add the "Driver" property sheet if necessary */ - if (nPropSheets != 0) - { - /* create the device property sheets */ - if (!SetupDiGetClassDevPropertySheets(DeviceInfoSet, - DeviceInfoData, - &psh, - nPropSheets + psh.nPages, - NULL, - PropertySheetType)) - { - goto Cleanup; - } - } + if (psh.nPages != 0) + { + Ret = pPropertySheetW(&psh); - /* FIXME - add the "Driver" property sheet if necessary */ + /* NOTE: no need to destroy the property sheets anymore! */ + } + else + { + UINT i; - if (psh.nPages != 0) +Cleanup: + /* in case of failure the property sheets must be destroyed */ + for (i = 0; + i < psh.nPages; + i++) { - Ret = pPropertySheetW(&psh); - - /* NOTE: no need to destroy the property sheets anymore! */ - } - else - { - UINT i; - -Cleanup: - /* in case of failure the property sheets must be destroyed */ - for (i = 0; - i < psh.nPages; - i++) + if (psh.phpage[i] != NULL) { - if (psh.phpage[i] != NULL) - { - pDestroyPropertySheetPage(psh.phpage[i]); - } + pDestroyPropertySheetPage(psh.phpage[i]); } } - - HeapFree(GetProcessHeap(), - 0, - psh.phpage); } HeapFree(GetProcessHeap(), 0, + psh.phpage); + + HeapFree(GetProcessHeap(), + 0, DevAdvPropInfo); if (hMachine != NULL) _____ Modified: trunk/reactos/lib/devmgr/misc.c --- trunk/reactos/lib/devmgr/misc.c 2005-12-01 15:37:00 UTC (rev 19797) +++ trunk/reactos/lib/devmgr/misc.c 2005-12-01 16:02:15 UTC (rev 19798) @@ -439,22 +439,11 @@ UINT MessageId = IDS_UNKNOWN; BOOL Ret = FALSE; - if (hMachine != NULL) - { - cr = CM_Get_DevNode_Status_Ex(&Status, - &ProblemNumber, - DevInst, - 0, - hMachine); - } - else - { - cr = CM_Get_DevNode_Status(&Status, - &ProblemNumber, - DevInst, - 0); - } - + cr = CM_Get_DevNode_Status_Ex(&Status, + &ProblemNumber, + DevInst, + 0, + hMachine); if (cr == CR_SUCCESS) { if (ProblemNumber < sizeof(ProblemStringId) / sizeof(ProblemStringId[0])) @@ -516,25 +505,62 @@ ULONG Status, ProblemNumber; BOOL Ret = FALSE; - if (hMachine != NULL) + cr = CM_Get_DevNode_Status_Ex(&Status, + &ProblemNumber, + DevInst, + 0, + hMachine); + if (cr == CR_SUCCESS) { - cr = CM_Get_DevNode_Status_Ex(&Status, - &ProblemNumber, - DevInst, - 0, - hMachine); + *IsHidden = ((Status & DN_NO_SHOW_IN_DM) != 0); + Ret = TRUE; } - else + + return Ret; +} + + +BOOL +CanDisableDevice(IN DEVINST DevInst, + IN HANDLE hMachine, + OUT BOOL *CanDisable) +{ + CONFIGRET cr; + ULONG Status, ProblemNumber; + BOOL Ret = FALSE; + + cr = CM_Get_DevNode_Status_Ex(&Status, + &ProblemNumber, + DevInst, + 0, + hMachine); + if (cr == CR_SUCCESS) { - cr = CM_Get_DevNode_Status(&Status, - &ProblemNumber, - DevInst, - 0); + *CanDisable = ((Status & DN_DISABLEABLE) != 0); + Ret = TRUE; } + return Ret; +} + + +BOOL +IsDeviceEnabled(IN DEVINST DevInst, + IN HANDLE hMachine, + OUT BOOL *IsEnabled) +{ + CONFIGRET cr; + ULONG Status, ProblemNumber; + BOOL Ret = FALSE; + + cr = CM_Get_DevNode_Status_Ex(&Status, + &ProblemNumber, + DevInst, + 0, + hMachine); if (cr == CR_SUCCESS) { - *IsHidden = ((Status & DN_NO_SHOW_IN_DM) != 0); + *IsEnabled = ((Status & DN_STARTED) != 0); Ret = TRUE; } @@ -605,7 +631,7 @@ { szBuffer[0] = L'\0'; if (LoadString(hDllInstance, - IDS_UNKNOWN, + IDS_UNKNOWNDEVICE, szBuffer, BufferSize)) { _____ Modified: trunk/reactos/lib/devmgr/precomp.h --- trunk/reactos/lib/devmgr/precomp.h 2005-12-01 15:37:00 UTC (rev 19797) +++ trunk/reactos/lib/devmgr/precomp.h 2005-12-01 16:02:15 UTC (rev 19798) @@ -237,6 +237,16 @@ OUT BOOL *IsHidden); BOOL +CanDisableDevice(IN DEVINST DevInst, + IN HANDLE hMachine, + OUT BOOL *CanDisable); + +BOOL +IsDeviceEnabled(IN DEVINST DevInst, + IN HANDLE hMachine, + OUT BOOL *IsEnabled); + +BOOL GetDeviceTypeString(IN PSP_DEVINFO_DATA DeviceInfoData, OUT LPWSTR szBuffer, IN DWORD BufferSize); _____ Modified: trunk/reactos/lib/devmgr/resource.h --- trunk/reactos/lib/devmgr/resource.h 2005-12-01 15:37:00 UTC (rev 19797) +++ trunk/reactos/lib/devmgr/resource.h 2005-12-01 16:02:15 UTC (rev 19798) @@ -22,6 +22,7 @@ #define IDC_STATUS 0x586 #define IDC_TROUBLESHOOT 0x589 #define IDC_PROPERTIES 0x58A +#define IDC_DEVUSAGELABEL 0x58B #define IDS_NAME 0x100 @@ -32,6 +33,9 @@ #define IDS_UNKNOWN 0x105 #define IDS_LOCATIONSTR 0x106 #define IDS_DEVCODE 0x107 +#define IDS_ENABLEDEVICE 0x108 +#define IDS_DISABLEDEVICE 0x109 +#define IDS_UNKNOWNDEVICE 0x10A #define IDS_DEV_NO_PROBLEM 0x200 #define IDS_DEV_NOT_CONFIGURED 0x201 _____ Modified: trunk/reactos/w32api/include/setupapi.h --- trunk/reactos/w32api/include/setupapi.h 2005-12-01 15:37:00 UTC (rev 19797) +++ trunk/reactos/w32api/include/setupapi.h 2005-12-01 16:02:15 UTC (rev 19798) @@ -212,6 +212,31 @@ #define DMI_MASK 0x00000001 #define DMI_BKCOLOR 0x00000002 #define DMI_USERECT 0x00000004 +#define DN_ROOT_ENUMERATED 0x00000001 +#define DN_DRIVER_LOADED 0x00000002 +#define DN_ENUM_LOADED 0x00000004 +#define DN_STARTED 0x00000008 +#define DN_MANUAL 0x00000010 +#define DN_NEED_TO_ENUM 0x00000020 +#define DN_NOT_FIRST_TIME 0x00000040 +#define DN_HARDWARE_ENUM 0x00000080 +#define DN_LIAR 0x00000100 +#define DN_HAS_MARK 0x00000200 +#define DN_HAS_PROBLEM 0x00000400 +#define DN_FILTERED 0x00000800 +#define DN_MOVED 0x00001000 +#define DN_DISABLEABLE 0x00002000 +#define DN_REMOVABLE 0x00004000 +#define DN_PRIVATE_PROBLEM 0x00008000 +#define DN_MF_PARENT 0x00010000 +#define DN_MF_CHILD 0x00020000 +#define DN_WILL_BE_REMOVED 0x00040000 +#define DN_NOT_FIRST_TIMEE 0x00080000 +#define DN_STOP_FREE_RES 0x00100000 +#define DN_REBAL_CANDIDATE 0x00200000 +#define DN_BAD_PARTIAL 0x00400000 +#define DN_NT_ENUMERATOR 0x00800000 +#define DN_NT_DRIVER 0x01000000 #define DN_NEEDS_LOCKING 0x02000000 #define DN_ARM_WAKEUP 0x04000000 #define DN_APM_ENUMERATOR 0x08000000
19 years
1
0
0
0
[gvg] 19797: Notify main thread in case of exception
by gvg@svn.reactos.com
Notify main thread in case of exception Modified: trunk/reactos/lib/syssetup/syssetup.xml Modified: trunk/reactos/lib/syssetup/wizard.c _____ Modified: trunk/reactos/lib/syssetup/syssetup.xml --- trunk/reactos/lib/syssetup/syssetup.xml 2005-12-01 15:01:38 UTC (rev 19796) +++ trunk/reactos/lib/syssetup/syssetup.xml 2005-12-01 15:37:00 UTC (rev 19797) @@ -20,6 +20,7 @@ <library>ole32</library> <library>shell32</library> <library>shlwapi</library> + <library>pseh</library> <file>dllmain.c</file> <file>install.c</file> <file>logfile.c</file> _____ Modified: trunk/reactos/lib/syssetup/wizard.c --- trunk/reactos/lib/syssetup/wizard.c 2005-12-01 15:01:38 UTC (rev 19796) +++ trunk/reactos/lib/syssetup/wizard.c 2005-12-01 15:37:00 UTC (rev 19797) @@ -14,6 +14,7 @@ #include <tchar.h> #include <string.h> #include <setupapi.h> +#include <pseh/pseh.h> #define NTOS_MODE_USER #include <ndk/ntndk.h> @@ -1421,25 +1422,42 @@ RegistrationData->Registered = 0; RegistrationData->DefaultContext = SetupInitDefaultQueueCallback(RegistrationData->hwndDlg); - if (SetupInstallFromInfSectionW(GetParent(RegistrationData->hwndDlg), - hSysSetupInf, - L"RegistrationPhase2", - SPINST_REGISTRY | - SPINST_REGISTERCALLBACKAWARE | - SPINST_REGSVR, - 0, - NULL, - 0, - RegistrationNotificationProc, - RegistrationData, - NULL, - NULL)) + _SEH_TRY { + if (SetupInstallFromInfSectionW(GetParent(RegistrationData->hwndDlg), + hSysSetupInf, + L"RegistrationPhase2", + SPINST_REGISTRY | + SPINST_REGISTERCALLBACKAWARE | + SPINST_REGSVR, + 0, + NULL, + 0, + RegistrationNotificationProc, + RegistrationData, + NULL, + NULL)) + { + LastError = NO_ERROR; + } + else + { + LastError = GetLastError(); + } + } + _SEH_HANDLE + { + DPRINT("Catching exception\n"); + LastError = RtlNtStatusToDosError(_SEH_GetExceptionCode()); + } + _SEH_END; + + if (NO_ERROR == LastError) + { RegistrationNotify.ErrorMessage = NULL; } else { - LastError = GetLastError(); DPRINT1("SetupInstallFromInfSection failed with error %u\n", LastError); if (0 == FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
19 years
1
0
0
0
← Newer
1
...
67
68
69
70
71
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Results per page:
10
25
50
100
200