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
July 2017
----- 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
19 participants
213 discussions
Start a n
N
ew thread
[jimtabor] 75294: [NtGDI] - Return Set if managed, part of CORE-12888.
by jimtabor@svn.reactos.org
Author: jimtabor Date: Thu Jul 6 19:13:49 2017 New Revision: 75294 URL:
http://svn.reactos.org/svn/reactos?rev=75294&view=rev
Log: [NtGDI] - Return Set if managed, part of CORE-12888. Modified: trunk/reactos/win32ss/gdi/ntgdi/dcutil.c Modified: trunk/reactos/win32ss/gdi/ntgdi/dcutil.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/dcutil.c…
============================================================================== --- trunk/reactos/win32ss/gdi/ntgdi/dcutil.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/gdi/ntgdi/dcutil.c [iso-8859-1] Thu Jul 6 19:13:49 2017 @@ -739,7 +739,10 @@ DPRINT(" r %d b %d\n",rc.right,rc.bottom); } else + { rc = pdc->erclBounds; + ret = DCB_SET; + } /* Copy the rect to the caller */ _SEH2_TRY
7 years, 5 months
1
0
0
0
[jimtabor] 75293: [NtUser] - Part of CORE-13110. Set DC window rectangle and pointer.
by jimtabor@svn.reactos.org
Author: jimtabor Date: Thu Jul 6 19:06:29 2017 New Revision: 75293 URL:
http://svn.reactos.org/svn/reactos?rev=75293&view=rev
Log: [NtUser] - Part of CORE-13110. Set DC window rectangle and pointer. Modified: trunk/reactos/win32ss/user/ntuser/windc.c Modified: trunk/reactos/win32ss/user/ntuser/windc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/windc.…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/windc.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/windc.c [iso-8859-1] Thu Jul 6 19:06:29 2017 @@ -146,30 +146,22 @@ ULONG Flags, BOOL SetClipOrigin) { - DC *dc = DC_LockDc(hDC); - if(!dc) - return; - - if (Window == NULL) - { - dc->ptlDCOrig.x = 0; - dc->ptlDCOrig.y = 0; - } - else + RECTL rect; + + if (Window) { if (Flags & DCX_WINDOW) { - dc->ptlDCOrig.x = Window->rcWindow.left; - dc->ptlDCOrig.y = Window->rcWindow.top; + rect = Window->rcWindow; } else { - dc->ptlDCOrig.x = Window->rcClient.left; - dc->ptlDCOrig.y = Window->rcClient.top; - } - } - dc->fs |= DC_FLAG_DIRTY_RAO; - DC_UnlockDc(dc); + rect = Window->rcClient; + } + } + + /* Set DC Origin and Window Rectangle */ + GreSetDCOrg( hDC, rect.left, rect.top, &rect); }
7 years, 5 months
1
0
0
0
[jimtabor] 75292: [Gdi32] - Sync/Port Wine Enhanced/Metafile code. This is a fix for CORE-12888. - Wine made this difficult to port and keep the whole file unchanged for syncing.
by jimtabor@svn.reactos.org
Author: jimtabor Date: Thu Jul 6 18:52:22 2017 New Revision: 75292 URL:
http://svn.reactos.org/svn/reactos?rev=75292&view=rev
Log: [Gdi32] - Sync/Port Wine Enhanced/Metafile code. This is a fix for CORE-12888. - Wine made this difficult to port and keep the whole file unchanged for syncing. Added: trunk/reactos/win32ss/gdi/gdi32/wine/path.c (with props) Modified: trunk/reactos/win32ss/gdi/gdi32/include/wine/gdi_driver.h trunk/reactos/win32ss/gdi/gdi32/misc/misc.c trunk/reactos/win32ss/gdi/gdi32/wine/CMakeLists.txt trunk/reactos/win32ss/gdi/gdi32/wine/enhmetafile.c trunk/reactos/win32ss/gdi/gdi32/wine/enhmfdrv/bitblt.c trunk/reactos/win32ss/gdi/gdi32/wine/enhmfdrv/dc.c trunk/reactos/win32ss/gdi/gdi32/wine/enhmfdrv/enhmetafiledrv.h trunk/reactos/win32ss/gdi/gdi32/wine/enhmfdrv/graphics.c trunk/reactos/win32ss/gdi/gdi32/wine/enhmfdrv/init.c trunk/reactos/win32ss/gdi/gdi32/wine/enhmfdrv/objects.c trunk/reactos/win32ss/gdi/gdi32/wine/gdi_private.h trunk/reactos/win32ss/gdi/gdi32/wine/metafile.c trunk/reactos/win32ss/gdi/gdi32/wine/mfdrv/bitblt.c trunk/reactos/win32ss/gdi/gdi32/wine/mfdrv/init.c trunk/reactos/win32ss/gdi/gdi32/wine/mfdrv/objects.c trunk/reactos/win32ss/gdi/gdi32/wine/rosglue.c [This mail would be too long, it was shortened to contain the URLs only.] Modified: trunk/reactos/win32ss/gdi/gdi32/include/wine/gdi_driver.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/include/…
Modified: trunk/reactos/win32ss/gdi/gdi32/misc/misc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/misc/mis…
Modified: trunk/reactos/win32ss/gdi/gdi32/wine/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/wine/CMa…
Modified: trunk/reactos/win32ss/gdi/gdi32/wine/enhmetafile.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/wine/enh…
Modified: trunk/reactos/win32ss/gdi/gdi32/wine/enhmfdrv/bitblt.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/wine/enh…
Modified: trunk/reactos/win32ss/gdi/gdi32/wine/enhmfdrv/dc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/wine/enh…
Modified: trunk/reactos/win32ss/gdi/gdi32/wine/enhmfdrv/enhmetafiledrv.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/wine/enh…
Modified: trunk/reactos/win32ss/gdi/gdi32/wine/enhmfdrv/graphics.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/wine/enh…
Modified: trunk/reactos/win32ss/gdi/gdi32/wine/enhmfdrv/init.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/wine/enh…
Modified: trunk/reactos/win32ss/gdi/gdi32/wine/enhmfdrv/objects.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/wine/enh…
Modified: trunk/reactos/win32ss/gdi/gdi32/wine/gdi_private.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/wine/gdi…
Modified: trunk/reactos/win32ss/gdi/gdi32/wine/metafile.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/wine/met…
Modified: trunk/reactos/win32ss/gdi/gdi32/wine/mfdrv/bitblt.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/wine/mfd…
Modified: trunk/reactos/win32ss/gdi/gdi32/wine/mfdrv/init.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/wine/mfd…
Modified: trunk/reactos/win32ss/gdi/gdi32/wine/mfdrv/objects.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/wine/mfd…
Added: trunk/reactos/win32ss/gdi/gdi32/wine/path.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/wine/pat…
Modified: trunk/reactos/win32ss/gdi/gdi32/wine/rosglue.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/wine/ros…
7 years, 5 months
1
0
0
0
[rgampa] 75291: [USBXHCI] - added dprints to all the xhci functions. - some fixes suggested in code review. - have written interrupt code (rudimentary). CORE-13344
by rgampa@svn.reactos.org
Author: rgampa Date: Thu Jul 6 07:36:05 2017 New Revision: 75291 URL:
http://svn.reactos.org/svn/reactos?rev=75291&view=rev
Log: [USBXHCI] - added dprints to all the xhci functions. - some fixes suggested in code review. - have written interrupt code (rudimentary). CORE-13344 Modified: branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbport/roothub.c branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/hardware.h branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/roothub.c branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/usbxhci.c branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/usbxhci.h Modified: branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbport/roothub.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/usbxhci/reactos/drive…
============================================================================== --- branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbport/roothub.c [iso-8859-1] (original) +++ branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbport/roothub.c [iso-8859-1] Thu Jul 6 07:36:05 2017 @@ -3,7 +3,7 @@ #define NDEBUG #include <debug.h> -#define NDEBUG_USBPORT_CORE +//#define NDEBUG_USBPORT_CORE #include "usbdebug.h" RHSTATUS Modified: branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/hardware.h URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/usbxhci/reactos/drive…
============================================================================== --- branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/hardware.h [iso-8859-1] (original) +++ branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/hardware.h [iso-8859-1] Thu Jul 6 07:36:05 2017 @@ -5,7 +5,8 @@ #define XHCI_HCSP3 3 #define XHCI_HCCP1 4 #define XHCI_DBOFF 5 -#define XHCI_HCCP2 6 +#define XHCI_RTSOFF 6 +#define XHCI_HCCP2 7 #define XHCI_USBCMD 0 #define XHCI_USBSTS 1 @@ -13,8 +14,15 @@ #define XHCI_CRCR 6 #define XHCI_DCBAAP 12 #define XHCI_CONFIG 14 - -typedef unsigned long long ULONGULONG ; +#define XHCI_PORTSC 100 + +#define XHCI_IMAN 0 +#define XHCI_IMOD 1 +#define XHCI_ERSTSZ 2 +#define XHCI_ERSTBA 4 +#define XHCI_ERSTDP 6 + + typedef union _XHCI_HC_STRUCTURAL_PARAMS_1 { struct { @@ -77,8 +85,8 @@ typedef union _XHCI_RT_REGISTER_SPACE_OFFSET { //RUNTIME REGISTER SPACE OFFSET struct { - ULONG Rsvd : 2; - ULONG RTSOffset : 30; + ULONG Rsvd : 5; + ULONG RTSOffset : 27; }; ULONG AsULONG; } XHCI_RT_REGISTER_SPACE_OFFSET; @@ -149,12 +157,34 @@ ULONG AsULONG; } XHCI_DEVICE_NOTIFICATION_CONTROL; +typedef union _XHCI_COMMAND_RING_CONTROL { + struct { + ULONGLONG RingCycleState : 1; + ULONGLONG CommandStop : 1; + ULONGLONG CommandAbort : 1; + ULONGLONG CommandRingRunning : 1; + ULONGLONG RsvdP : 2; + ULONGLONG CommandRingPointerLo : 26; + ULONGLONG CommandRingPointerHi : 32; + }; + ULONGLONG AsULONGLONG; +} XHCI_COMMAND_RING_CONTROL; + +typedef union _XHCI_DEVICE_CONTEXT_BASE_ADD_ARRAY_POINTER { + struct { + ULONGLONG RsvdZ : 6; + ULONGLONG DCBAAPointerLo : 26; + ULONGLONG DCBAAPointerHi : 32; + }; + ULONGLONG AsULONGLONG; +} XHCI_DEVICE_CONTEXT_BASE_ADD_ARRAY_POINTER; + typedef union _XHCI_CONFIGURE { struct { ULONG MaxDeviceSlotsEnabled : 8; ULONG U3EntryEnable : 1; ULONG ConfigurationInfoEnable : 1; - ULONG Rsvd : 21; + ULONG Rsvd : 22; }; ULONG AsULONG; } XHCI_CONFIGURE; @@ -189,25 +219,45 @@ ULONG AsULONG; } XHCI_PORT_STATUS_CONTROL; -typedef union _XHCI_COMMAND_RING_CONTROL { - struct { - ULONGULONG RingCycleState : 1; - ULONGULONG CommandStop : 1; - ULONGULONG CommandAbort : 1; - ULONGULONG CommandRingRunning : 1; - ULONGULONG RsvdP : 2; - ULONGULONG CommandRingPointerLo : 26; - ULONGULONG CommandRingPointerHi : 32; - }; - ULONGULONG AsULONGULONG; -} XHCI_COMMAND_RING_CONTROL; - -typedef union _XHCI_DEVICE_CONTEXT_BASE_ADD_ARRAY_POINTER { - struct { - ULONGULONG RsvdZ : 6; - ULONGULONG DCBAAPointerLo : 26; - ULONGULONG DCBAAPointerHi : 32; - }; - ULONGULONG AsULONGULONG; -} XHCI_DEVICE_CONTEXT_BASE_ADD_ARRAY_POINTER; - +// Interrupt Register Set +typedef union _XHCI_INTERRUPTER_MANAGEMENT { + struct { + ULONG InterruptPending : 1; + ULONG InterruptEnable : 1; + ULONG RsvdP : 30; + }; + ULONG AsULONG; +} XHCI_INTERRUPTER_MANAGEMENT; + +typedef union _XHCI_INTERRUPTER_MODERATION { + struct { + ULONG InterruptModIterval : 16; + ULONG InterruptModCounter : 16; + }; + ULONG AsULONG; +} XHCI_INTERRUPTER_MODERATION; + +typedef union _XHCI_EVENT_RING_TABLE_SIZE { + struct { + ULONG EventRingSegTableSize : 16; + ULONG RsvdP : 16; + }; + ULONG AsULONG; +} XHCI_EVENT_RING_TABLE_SIZE; + +typedef union _XHCI_EVENT_RING_TABLE_BASE_ADDR { + struct { + ULONGLONG RsvdP : 6; + ULONGLONG EventRingSegTableBaseAddr : 58; + }; + ULONGLONG AsULONGLONG; +} XHCI_EVENT_RING_TABLE_BASE_ADDR; + +typedef union _XHCI_EVENT_RING_DEQUEUE_POINTER { + struct { + ULONGLONG DequeueERSTIndex : 3; + ULONGLONG EventHandlerBusy : 1; + ULONGLONG EventRingSegDequeuePointer : 60; + }; + ULONGLONG AsULONGLONG; +} XHCI_EVENT_RING_DEQUEUE_POINTER; Modified: branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/roothub.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/usbxhci/reactos/drive…
============================================================================== --- branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/roothub.c [iso-8859-1] (original) +++ branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/roothub.c [iso-8859-1] Thu Jul 6 07:36:05 2017 @@ -11,6 +11,7 @@ XHCI_RH_GetRootHubData(IN PVOID xhciExtension, IN PVOID rootHubData) { + DPRINT1("XHCI_RH_GetRootHubData: function initiated\n"); PXHCI_EXTENSION XhciExtension; PUSBPORT_ROOT_HUB_DATA RootHubData; @@ -40,7 +41,7 @@ XHCI_RH_GetStatus(IN PVOID xhciExtension, IN PUSHORT Status) { - + DPRINT1("XHCI_RH_GetStatus: function initiated\n"); return 0; } @@ -50,9 +51,20 @@ IN USHORT Port, IN PULONG PortStatus) { + int cntr = 0; + DPRINT1("XHCI_RH_GetPortStatus: function initiated\n" + cntr); + cntr = cntr + 1; + PXHCI_EXTENSION XhciExtension; + PULONG PortStatusReg; + XHCI_PORT_STATUS_CONTROL PortStatusRegister; - - return 0; + XhciExtension = (PXHCI_EXTENSION)xhciExtension; + PortStatusReg = (XhciExtension->OperationalRegs) + (XHCI_PORTSC + (Port - 1)*4); + PortStatusRegister.AsULONG = READ_REGISTER_ULONG(PortStatusReg) ; + + *PortStatus = PortStatusRegister.AsULONG; + + return MP_STATUS_SUCCESS; } MPSTATUS @@ -60,7 +72,7 @@ XHCI_RH_GetHubStatus(IN PVOID xhciExtension, IN PULONG HubStatus) { - + DPRINT1("XHCI_RH_GetHubStatus: function initiated\n"); return 0; } @@ -69,7 +81,7 @@ XHCI_RH_FinishReset(IN PVOID xhciExtension, IN PUSHORT Port) { - + DPRINT1("XHCI_RH_FinishReset: function initiated\n"); } ULONG @@ -77,6 +89,7 @@ XHCI_RH_PortResetComplete(IN PVOID xhciExtension, IN PUSHORT Port) { + DPRINT1("XHCI_RH_PortResetComplete: function initiated\n"); return 0; } @@ -85,7 +98,7 @@ XHCI_RH_SetFeaturePortReset(IN PVOID xhciExtension, IN USHORT Port) { - + DPRINT1("XHCI_RH_SetFeaturePortReset: function initiated\n"); return 0; } @@ -94,7 +107,7 @@ XHCI_RH_SetFeaturePortPower(IN PVOID xhciExtension, IN USHORT Port) { - + DPRINT1("XHCI_RH_SetFeaturePortPower: function initiated\n"); return 0; } MPSTATUS @@ -111,7 +124,7 @@ XHCI_RH_SetFeaturePortSuspend(IN PVOID xhciExtension, IN USHORT Port) { - + DPRINT1("XHCI_RH_SetFeaturePortSuspend: function initiated\n"); return 0; } @@ -120,7 +133,7 @@ XHCI_RH_ClearFeaturePortEnable(IN PVOID xhciExtension, IN USHORT Port) { - + DPRINT1("XHCI_RH_ClearFeaturePortEnable: function initiated\n"); return 0; } @@ -129,6 +142,7 @@ XHCI_RH_ClearFeaturePortPower(IN PVOID xhciExtension, IN USHORT Port) { + DPRINT1("XHCI_RH_ClearFeaturePortPower: function initiated\n"); return 0; } @@ -138,7 +152,7 @@ XHCI_RH_PortResumeComplete(IN PULONG xhciExtension, IN PUSHORT Port) { - + DPRINT1("XHCI_RH_PortResumeComplete: function initiated\n"); } MPSTATUS @@ -146,7 +160,7 @@ XHCI_RH_ClearFeaturePortSuspend(IN PVOID xhciExtension, IN USHORT Port) { - + DPRINT1("XHCI_RH_ClearFeaturePortSuspend: function initiated\n"); return 0; } @@ -155,7 +169,7 @@ XHCI_RH_ClearFeaturePortEnableChange(IN PVOID xhciExtension, IN USHORT Port) { - + DPRINT1("XHCI_RH_ClearFeaturePortEnableChange: function initiated\n"); return 0; } @@ -164,6 +178,7 @@ XHCI_RH_ClearFeaturePortConnectChange(IN PVOID xhciExtension, IN USHORT Port) { + DPRINT1("XHCI_RH_ClearFeaturePortConnectChange: function initiated\n"); return 0; } @@ -172,6 +187,7 @@ XHCI_RH_ClearFeaturePortResetChange(IN PVOID xhciExtension, IN USHORT Port) { + DPRINT1("XHCI_RH_ClearFeaturePortResetChange: function initiated\n"); return 0; } @@ -180,7 +196,7 @@ XHCI_RH_ClearFeaturePortSuspendChange(IN PVOID xhciExtension, IN USHORT Port) { - + DPRINT1("XHCI_RH_ClearFeaturePortSuspendChange: function initiated\n"); return 0; } @@ -189,7 +205,7 @@ XHCI_RH_ClearFeaturePortOvercurrentChange(IN PVOID xhciExtension, IN USHORT Port) { - + DPRINT1("XHCI_RH_ClearFeaturePortOvercurrentChange: function initiated\n"); return 0; } @@ -197,12 +213,37 @@ NTAPI XHCI_RH_DisableIrq(IN PVOID xhciExtension) { - + DPRINT1("XHCI_RH_DisableIrq: function initiated\n"); + PXHCI_EXTENSION XhciExtension; + PULONG OperationalRegs; + XHCI_USB_COMMAND usbCommand; + + XhciExtension = (PXHCI_EXTENSION)xhciExtension; + OperationalRegs = XhciExtension->OperationalRegs; + usbCommand.AsULONG =READ_REGISTER_ULONG (OperationalRegs + XHCI_USBCMD); + + usbCommand.InterrupterEnable = 0; + + WRITE_REGISTER_ULONG(OperationalRegs + XHCI_USBCMD,usbCommand.AsULONG ); + DPRINT1("XHCI_RH_DisableIrq: Disable Interupts succesfull\n"); } VOID NTAPI XHCI_RH_EnableIrq(IN PVOID xhciExtension) { - -} + DPRINT1("XHCI_RH_EnableIrq: function initiated\n"); + PXHCI_EXTENSION XhciExtension; + PULONG OperationalRegs; + XHCI_USB_COMMAND usbCommand; + + XhciExtension = (PXHCI_EXTENSION)xhciExtension; + OperationalRegs = XhciExtension->OperationalRegs; + usbCommand.AsULONG =READ_REGISTER_ULONG (OperationalRegs + XHCI_USBCMD); + + usbCommand.InterrupterEnable = 1; + + WRITE_REGISTER_ULONG(OperationalRegs + XHCI_USBCMD,usbCommand.AsULONG ); + DPRINT1("XHCI_RH_EnableIrq: Enable Interupts\n"); + +} Modified: branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/usbxhci.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/usbxhci/reactos/drive…
============================================================================== --- branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/usbxhci.c [iso-8859-1] (original) +++ branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/usbxhci.c [iso-8859-1] Thu Jul 6 07:36:05 2017 @@ -14,6 +14,7 @@ IN PVOID endpointParameters, IN PVOID xhciEndpoint) { + DPRINT1("XHCI_OpenEndpoint: function initiated\n"); return MP_STATUS_SUCCESS; } @@ -23,6 +24,7 @@ IN PVOID endpointParameters, IN PVOID xhciEndpoint) { + DPRINT1("XHCI_ReopenEndpoint: function initiated\n"); return MP_STATUS_SUCCESS; } @@ -32,7 +34,7 @@ IN PVOID endpointParameters, IN PULONG EndpointRequirements) { - + DPRINT1("XHCI_QueryEndpointRequirements: function initiated\n"); } VOID @@ -50,13 +52,24 @@ IN PVOID resourcesStartVA, IN PVOID resourcesStartPA) { + DPRINT1("XHCI_InitializeResources: function initiated\n"); PXHCI_HC_RESOURCES HcResourcesVA; PHYSICAL_ADDRESS HcResourcesPA; + PULONG BaseIoAdress; + PULONG OperationalRegs; + + + PULONG RunTimeRegisterBase; + XHCI_INTERRUPTER_MANAGEMENT Iman; + XHCI_INTERRUPTER_MODERATION Imod; + XHCI_EVENT_RING_TABLE_SIZE erstz; + XHCI_EVENT_RING_TABLE_BASE_ADDR erstba; + XHCI_EVENT_RING_DEQUEUE_POINTER erstdp; + XHCI_EVENT_RING_SEGMENT_TABLE EventRingSegTable; XHCI_COMMAND_RING_CONTROL CommandRingControlRegister; XHCI_DEVICE_CONTEXT_BASE_ADD_ARRAY_POINTER DCBAAPointer; - PULONG OperationalRegs; unsigned long X, Y; DPRINT_XHCI("XHCI_InitializeResources: BaseVA - %p, BasePA - %p\n", @@ -65,17 +78,19 @@ HcResourcesVA = (PXHCI_HC_RESOURCES)resourcesStartVA; HcResourcesPA.QuadPart = (ULONG_PTR)resourcesStartPA; - - DCBAAPointer.AsULONGULONG = HcResourcesPA.QuadPart + FIELD_OFFSET(XHCI_HC_RESOURCES, DCBAA); - + + //DCBAA init + DCBAAPointer.AsULONGLONG = HcResourcesPA.QuadPart + FIELD_OFFSET(XHCI_HC_RESOURCES, DCBAA); + + BaseIoAdress = XhciExtension->BaseIoAdress; OperationalRegs = XhciExtension->OperationalRegs; - //DCBAAPointer.RsvdZ =0; + WRITE_REGISTER_ULONG(OperationalRegs + XHCI_DCBAAP, DCBAAPointer.DCBAAPointerLo | DCBAAPointer.RsvdZ ); WRITE_REGISTER_ULONG(OperationalRegs + XHCI_DCBAAP + 1, DCBAAPointer.DCBAAPointerHi); X = READ_REGISTER_ULONG(OperationalRegs + XHCI_DCBAAP) ; Y = READ_REGISTER_ULONG(OperationalRegs + XHCI_DCBAAP + 1) ; - DCBAAPointer.AsULONGULONG = Y|X ; + DCBAAPointer.AsULONGLONG = Y|X ; ASSERT(DCBAAPointer.RsvdZ == 0); // command ring intialisation. @@ -88,17 +103,42 @@ HcResourcesVA->CommandRing.CREnquePointer= &HcResourcesVA->CommandRing.Segment[0]; HcResourcesVA->CommandRing.CRDequePointer= HcResourcesVA->CommandRing.CREnquePointer; - CommandRingControlRegister.AsULONGULONG = HcResourcesPA.QuadPart + FIELD_OFFSET(XHCI_HC_RESOURCES, CommandRing.Segment); + CommandRingControlRegister.AsULONGLONG = HcResourcesPA.QuadPart + FIELD_OFFSET(XHCI_HC_RESOURCES, CommandRing.Segment); ASSERT(CommandRingControlRegister.RingCycleState == 0); ASSERT(CommandRingControlRegister.CommandStop == 0); ASSERT(CommandRingControlRegister.CommandAbort == 0); ASSERT(CommandRingControlRegister.CommandRingRunning == 0); ASSERT(CommandRingControlRegister.RsvdP == 0); - WRITE_REGISTER_ULONG(OperationalRegs + XHCI_CRCR, CommandRingControlRegister.AsULONGULONG); + WRITE_REGISTER_ULONG(OperationalRegs + XHCI_CRCR, CommandRingControlRegister.AsULONGLONG); WRITE_REGISTER_ULONG(OperationalRegs + XHCI_CRCR + 1, CommandRingControlRegister.CommandRingPointerHi); - - DbgBreakPoint(); + // end of command ring init + + //Primary Interrupter init + RunTimeRegisterBase = XhciExtension -> RunTimeRegisterBase; + + Iman.InterruptEnable = 1; + WRITE_REGISTER_ULONG (RunTimeRegisterBase + XHCI_IMAN , Iman.AsULONG); + + // dont change imod now + erstz.EventRingSegTableSize = 1; + WRITE_REGISTER_ULONG (RunTimeRegisterBase + XHCI_ERSTSZ , erstz.AsULONG); + + erstba.AsULONGLONG = HcResourcesPA.QuadPart + FIELD_OFFSET(XHCI_HC_RESOURCES, EventRingSegTable); + + EventRingSegTable.RingSegmentBaseAddr = HcResourcesPA.QuadPart + FIELD_OFFSET(XHCI_HC_RESOURCES, EventRing); + EventRingSegTable.RingSegmentSize = 16; + HcResourcesVA->EventRingSegTable = EventRingSegTable; + + WRITE_REGISTER_ULONG (RunTimeRegisterBase + XHCI_ERSTBA, erstba.AsULONGLONG); + WRITE_REGISTER_ULONG (RunTimeRegisterBase + XHCI_ERSTBA + 1, erstba.AsULONGLONG >> 32); + // intially enque and deque are equal. + erstdp.AsULONGLONG = HcResourcesPA.QuadPart + FIELD_OFFSET(XHCI_HC_RESOURCES, EventRing); + erstdp.DequeueERSTIndex =0; + WRITE_REGISTER_ULONG (RunTimeRegisterBase + XHCI_ERSTDP, erstdp.AsULONGLONG); + WRITE_REGISTER_ULONG (RunTimeRegisterBase + XHCI_ERSTDP + 1, erstdp.AsULONGLONG >> 32); + + //DbgBreakPoint(); return MP_STATUS_SUCCESS; } @@ -106,8 +146,11 @@ NTAPI XHCI_InitializeHardware(IN PXHCI_EXTENSION XhciExtension) { + DPRINT1("XHCI_InitializeHardware: function initiated\n"); PULONG BaseIoAdress; PULONG OperationalRegs; + + XHCI_USB_COMMAND Command; XHCI_USB_STATUS Status; LARGE_INTEGER CurrentTime = {{0, 0}}; @@ -119,8 +162,7 @@ OperationalRegs = XhciExtension->OperationalRegs; BaseIoAdress = XhciExtension->BaseIoAdress; - - + KeQuerySystemTime(&CurrentTime); CurrentTime.QuadPart += 100 * 10000; // 100 msec @@ -166,7 +208,7 @@ // Device Context base aaddress array to be defined // Commnad ring deque pointer to be defined in CRCR - DbgBreakPoint(); + //DbgBreakPoint(); return MP_STATUS_SUCCESS; } @@ -175,15 +217,19 @@ XHCI_StartController(IN PVOID xhciExtension, IN PUSBPORT_RESOURCES Resources) { + DPRINT1("XHCI_StartController: function initiated\n"); PXHCI_EXTENSION XhciExtension; PULONG BaseIoAdress; PULONG OperationalRegs; + PULONG RunTimeRegisterBase; + MPSTATUS MPStatus; XHCI_USB_COMMAND Command; + XHCI_RT_REGISTER_SPACE_OFFSET RTSOffsetRegister; UCHAR CapabilityRegLength; UCHAR Fladj; - DPRINT1("XHCI_StartController: function initiated\n"); + if ((Resources->TypesResources & (USBPORT_RESOURCES_MEMORY | USBPORT_RESOURCES_INTERRUPT)) != (USBPORT_RESOURCES_MEMORY | USBPORT_RESOURCES_INTERRUPT)) @@ -199,9 +245,14 @@ XhciExtension->BaseIoAdress = BaseIoAdress; CapabilityRegLength = (UCHAR)READ_REGISTER_ULONG(BaseIoAdress); - OperationalRegs = (PULONG)((ULONG)BaseIoAdress + CapabilityRegLength); + OperationalRegs = (PULONG)((ULONG_PTR)BaseIoAdress + CapabilityRegLength); XhciExtension->OperationalRegs = OperationalRegs; - + + RTSOffsetRegister.AsULONG = READ_REGISTER_ULONG(BaseIoAdress + XHCI_RTSOFF); + RunTimeRegisterBase = BaseIoAdress + RTSOffsetRegister.AsULONG ; + + XhciExtension->RunTimeRegisterBase = RunTimeRegisterBase; + DPRINT("XHCI_StartController: BaseIoAdress - %p\n", BaseIoAdress); DPRINT("XHCI_StartController: OperationalRegs - %p\n", OperationalRegs); @@ -230,7 +281,9 @@ DPRINT1("XHCI_StartController: Unsuccessful InitializeSchedule()\n"); return MPStatus; } - + + //Command.RunStop =1; + //WRITE_REGISTER_ULONG (OperationalRegs + XHCI_USBCMD, Command.AsULONG ); //DPRINT1("XHCI_StartController: UNIMPLEMENTED. FIXME\n"); return MP_STATUS_SUCCESS; } @@ -247,13 +300,14 @@ NTAPI XHCI_SuspendController(IN PVOID xhciExtension) { - + DPRINT1("XHCI_SuspendController: function initiated\n"); } MPSTATUS NTAPI XHCI_ResumeController(IN PVOID xhciExtension) { + DPRINT1("XHCI_ResumeController: function initiated\n"); return MP_STATUS_SUCCESS; } @@ -262,6 +316,7 @@ XHCI_HardwarePresent(IN PXHCI_EXTENSION xhciExtension, IN BOOLEAN IsInvalidateController) { + DPRINT1("XHCI_HardwarePresent: function initiated\n"); return TRUE; } @@ -269,6 +324,29 @@ NTAPI XHCI_InterruptService(IN PVOID xhciExtension) { + DPRINT1("XHCI_InterruptService: function initiated\n"); + XHCI_RT_REGISTER_SPACE_OFFSET RTSOffsetRegister; + PULONG RunTimeRegisterBase; + XHCI_INTERRUPTER_MANAGEMENT Iman; + PXHCI_EXTENSION XhciExtension; + XhciExtension = (PXHCI_EXTENSION)xhciExtension; + XHCI_EVENT_RING_DEQUEUE_POINTER erstdp; + + RunTimeRegisterBase = XhciExtension-> RunTimeRegisterBase; + + Iman.AsULONG = READ_REGISTER_ULONG(RunTimeRegisterBase + XHCI_IMAN); + + Iman.InterruptPending =0; + + WRITE_REGISTER_ULONG(RunTimeRegisterBase + XHCI_IMAN, Iman.AsULONG); + DPRINT1("XHCI_InterruptService: Succesful Interupt\n"); + // changing the enque pointer + erstdp.AsULONGLONG = READ_REGISTER_ULONG(RunTimeRegisterBase + XHCI_ERSTDP + 1)||READ_REGISTER_ULONG(RunTimeRegisterBase + XHCI_ERSTDP); + erstdp.AsULONGLONG = erstdp.AsULONGLONG +2; + erstdp.DequeueERSTIndex =0; + WRITE_REGISTER_ULONG (RunTimeRegisterBase + XHCI_ERSTDP, erstdp.AsULONGLONG); + WRITE_REGISTER_ULONG (RunTimeRegisterBase + XHCI_ERSTDP + 1, erstdp.AsULONGLONG >> 32); + return TRUE; } @@ -277,7 +355,7 @@ XHCI_InterruptDpc(IN PVOID xhciExtension, IN BOOLEAN IsDoEnableInterrupts) { - + DPRINT1("XHCI_InterruptDpc: function initiated\n"); } MPSTATUS @@ -288,7 +366,7 @@ IN PVOID xhciTransfer, IN PVOID sgList) { - + DPRINT1("XHCI_SubmitTransfer: function initiated\n"); return MP_STATUS_SUCCESS; } @@ -319,7 +397,7 @@ IN PXHCI_ENDPOINT xhciEndpoint, IN PXHCI_TRANSFER xhciTransfer) { - + DPRINT1("XHCI_AbortAsyncTransfer: function initiated\n"); } VOID @@ -329,7 +407,7 @@ IN PVOID xhciTransfer, IN PULONG CompletedLength) { - + DPRINT1("XHCI_AbortTransfer: function initiated\n"); } ULONG @@ -347,7 +425,7 @@ IN PVOID xhciEndpoint, IN ULONG EndpointState) { - + DPRINT1("XHCI_SetEndpointState: function initiated\n"); } VOID @@ -355,20 +433,21 @@ XHCI_PollEndpoint(IN PVOID xhciExtension, IN PVOID xhciEndpoint) { - + DPRINT1("XHCI_PollEndpoint: function initiated\n"); } VOID NTAPI XHCI_CheckController(IN PVOID xhciExtension) { - + DPRINT1("XHCI_CheckController: function initiated\n"); } ULONG NTAPI XHCI_Get32BitFrameNumber(IN PVOID xhciExtension) { + DPRINT1("XHCI_Get32BitFrameNumber: function initiated\n"); return 0; } @@ -376,27 +455,40 @@ NTAPI XHCI_InterruptNextSOF(IN PVOID xhciExtension) { - + DPRINT1("XHCI_InterruptNextSOF: function initiated\n"); } VOID NTAPI XHCI_EnableInterrupts(IN PVOID xhciExtension) { - + DPRINT1("XHCI_EnableInterrupts: function initiated\n"); + PXHCI_EXTENSION XhciExtension; + PULONG OperationalRegs; + XHCI_USB_COMMAND usbCommand; + + XhciExtension = (PXHCI_EXTENSION)xhciExtension; + OperationalRegs = XhciExtension->OperationalRegs; + usbCommand.AsULONG =READ_REGISTER_ULONG (OperationalRegs + XHCI_USBCMD); + + usbCommand.InterrupterEnable = 1; + + WRITE_REGISTER_ULONG(OperationalRegs + XHCI_USBCMD,usbCommand.AsULONG ); + DPRINT1("XHCI_EnableInterrupts: Interrupts enabled\n"); } VOID NTAPI XHCI_DisableInterrupts(IN PVOID xhciExtension) { + DPRINT1("XHCI_DisableInterrupts: function initiated\n"); } VOID NTAPI XHCI_PollController(IN PVOID xhciExtension) { - + DPRINT1("XHCI_PollController: function initiated\n"); } VOID @@ -405,7 +497,7 @@ IN PVOID xhciEndpoint, IN ULONG DataToggle) { - + DPRINT1("XHCI_SetEndpointDataToggle: function initiated\n"); } ULONG @@ -413,7 +505,7 @@ XHCI_GetEndpointStatus(IN PVOID xhciExtension, IN PVOID xhciEndpoint) { - + DPRINT1("XHCI_GetEndpointStatus: function initiated\n"); return 0; } @@ -423,6 +515,7 @@ IN PVOID xhciEndpoint, IN ULONG EndpointStatus) { + DPRINT1("XHCI_SetEndpointStatus: function initiated\n"); } MPSTATUS @@ -479,7 +572,7 @@ NTAPI XHCI_FlushInterrupts(IN PVOID xhciExtension) { - + DPRINT1("XHCI_FlushInterrupts: function initiated\n"); } MPSTATUS Modified: branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/usbxhci.h URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/usbxhci/reactos/drive…
============================================================================== --- branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/usbxhci.h [iso-8859-1] (original) +++ branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/usbxhci.h [iso-8859-1] Thu Jul 6 07:36:05 2017 @@ -4,7 +4,6 @@ #include <ntddk.h> #include <windef.h> #include <stdio.h> -#include <wdm.h> #include <hubbusif.h> #include <usbbusif.h> #include <usbdlib.h> @@ -161,13 +160,40 @@ XHCI_CONTROL_STATUS_TRB StatusTRB[4]; } XHCI_CONTROL_TRB, *PXHCI_CONTROL_TRB; - +//----------------event strucs------------------- +typedef struct _XHCI_EVENT_TRB { + ULONG Word0; + ULONG Word1; + ULONG Word2; + ULONG Word3; +}XHCI_EVENT_TRB, *PXHCI_EVENT_TRB; + +typedef struct _XHCI_EVENT_RING_SEGMENT_TABLE{ + ULONGLONG RingSegmentBaseAddr; + ULONGLONG RingSegmentSize : 16; + ULONGLONG RsvdZ : 48; + +} XHCI_EVENT_RING_SEGMENT_TABLE; //------------------------------------main structs----------------------- + +typedef union _XHCI_TRB { + XHCI_COMMAND_TRB CommandTRB; + XHCI_LINK_TRB LinkTRB; + XHCI_CONTROL_TRB ControlTRB; + XHCI_EVENT_TRB EventTRB; +} XHCI_TRB, *PXHCI_TRB; + +typedef struct _XHCI_RING { + XHCI_TRB ring[16]; + //PXHCI_TRB dequeue_pointer; +}XHCI_RING , *PXHCI_RING; + typedef struct _XHCI_EXTENSION { ULONG Reserved; ULONG Flags; PULONG BaseIoAdress; PULONG OperationalRegs; + PULONG RunTimeRegisterBase; UCHAR FrameLengthAdjustment; BOOLEAN IsStarted; USHORT HcSystemErrors; @@ -180,6 +206,8 @@ typedef struct _XHCI_HC_RESOURCES { XHCI_DEVICE_CONTEXT_BASE_ADD_ARRAY DCBAA; XHCI_COMMAND_RING CommandRing; + XHCI_RING EventRing; + XHCI_EVENT_RING_SEGMENT_TABLE EventRingSegTable; } XHCI_HC_RESOURCES, *PXHCI_HC_RESOURCES; typedef struct _XHCI_ENDPOINT {
7 years, 5 months
1
0
0
0
[tthompson] 75290: [NTFS] - Fix some formatting / style issues, per CR-123.
by tthompson@svn.reactos.org
Author: tthompson Date: Wed Jul 5 22:10:22 2017 New Revision: 75290 URL:
http://svn.reactos.org/svn/reactos?rev=75290&view=rev
Log: [NTFS] - Fix some formatting / style issues, per CR-123. Modified: branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/attrib.c branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/btree.c branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/create.c branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/fcb.c branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/mft.c Modified: branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/attrib.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/NTFS/drivers/filesyst…
============================================================================== --- branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/attrib.c [iso-8859-1] (original) +++ branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/attrib.c [iso-8859-1] Wed Jul 5 22:10:22 2017 @@ -316,7 +316,8 @@ NextVBN = AttrContext->Record.NonResident.HighestVCN + 1; // Add newly-assigned clusters to mcb - _SEH2_TRY{ + _SEH2_TRY + { if (!FsRtlAddLargeMcbEntry(&AttrContext->DataRunsMCB, NextVBN, NextAssignedCluster, @@ -796,7 +797,7 @@ break; } - if( LargeLbn != -1) + if (LargeLbn != -1) { // deallocate this cluster RtlClearBits(&Bitmap, LargeLbn, 1); Modified: branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/btree.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/NTFS/drivers/filesyst…
============================================================================== --- branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/btree.c [iso-8859-1] (original) +++ branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/btree.c [iso-8859-1] Wed Jul 5 22:10:22 2017 @@ -77,7 +77,7 @@ = Key2->IndexEntry->FileName.NameLength * sizeof(WCHAR); // Are the two keys the same length? - if(Key1Name.Length == Key2Name.Length) + if (Key1Name.Length == Key2Name.Length) return RtlCompareUnicodeString(&Key1Name, &Key2Name, !CaseSensitive); // Is Key1 shorter? @@ -416,7 +416,9 @@ DbgPrint(" '%wZ'\n", &FileName); } else + { DbgPrint(" (Dummy Key)\n"); + } } VOID Modified: branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/create.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/NTFS/drivers/filesyst…
============================================================================== --- branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/create.c [iso-8859-1] (original) +++ branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/create.c [iso-8859-1] Wed Jul 5 22:10:22 2017 @@ -299,7 +299,7 @@ ParentFcb); } - if (!NT_SUCCESS (Status)) + if (!NT_SUCCESS(Status)) { DPRINT("Could not make a new FCB, status: %x\n", Status); @@ -347,7 +347,7 @@ DeviceExt = DeviceObject->DeviceExtension; ASSERT(DeviceExt); - Stack = IoGetCurrentIrpStackLocation (Irp); + Stack = IoGetCurrentIrpStackLocation(Irp); ASSERT(Stack); RequestedDisposition = ((Stack->Parameters.Create.Options >> 24) & 0xff); Modified: branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/fcb.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/NTFS/drivers/filesyst…
============================================================================== --- branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/fcb.c [iso-8859-1] (original) +++ branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/fcb.c [iso-8859-1] Wed Jul 5 22:10:22 2017 @@ -617,7 +617,7 @@ #if 1 /* Trivial case, open of the root directory on volume */ - if (pFileName [0] == L'\0' || wcscmp(pFileName, L"\\") == 0) + if (pFileName[0] == L'\0' || wcscmp(pFileName, L"\\") == 0) { DPRINT("returning root FCB\n"); Modified: branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/mft.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/NTFS/drivers/filesyst…
============================================================================== --- branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/mft.c [iso-8859-1] (original) +++ branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/mft.c [iso-8859-1] Wed Jul 5 22:10:22 2017 @@ -448,7 +448,7 @@ if (NT_SUCCESS(Status)) { - if(AttrContext->Record.IsNonResident) + if (AttrContext->Record.IsNonResident) Fcb->RFCB.AllocationSize.QuadPart = AttrContext->Record.NonResident.AllocatedSize; else Fcb->RFCB.AllocationSize = *DataSize; @@ -1319,7 +1319,7 @@ } // end while (Length > 0) [more data to write] // TEMPTEMP - if(Context->Record.IsNonResident) + if (Context->Record.IsNonResident) ExFreePoolWithTag(TempBuffer, TAG_NTFS); Context->CacheRun = DataRun;
7 years, 5 months
1
0
0
0
[gadamopoulos] 75289: [SHELL32] -Remove IShellView_Constructor and CDefView_Constructor. Use SHCreateShellFolderView and SHCreateShellFolderViewEx instead.
by gadamopoulos@svn.reactos.org
Author: gadamopoulos Date: Wed Jul 5 21:36:20 2017 New Revision: 75289 URL:
http://svn.reactos.org/svn/reactos?rev=75289&view=rev
Log: [SHELL32] -Remove IShellView_Constructor and CDefView_Constructor. Use SHCreateShellFolderView and SHCreateShellFolderViewEx instead. Modified: trunk/reactos/dll/win32/shell32/CDefView.cpp trunk/reactos/dll/win32/shell32/folders/CControlPanelFolder.cpp trunk/reactos/dll/win32/shell32/folders/CDesktopFolder.cpp trunk/reactos/dll/win32/shell32/folders/CDrivesFolder.cpp trunk/reactos/dll/win32/shell32/folders/CFSFolder.cpp trunk/reactos/dll/win32/shell32/folders/CNetFolder.cpp trunk/reactos/dll/win32/shell32/folders/CPrinterFolder.cpp trunk/reactos/dll/win32/shell32/folders/CRecycleBin.cpp trunk/reactos/dll/win32/shell32/wine/shell32_main.h trunk/reactos/dll/win32/shell32/wine/shellord.c Modified: trunk/reactos/dll/win32/shell32/CDefView.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/CDefView…
============================================================================== --- trunk/reactos/dll/win32/shell32/CDefView.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/CDefView.cpp [iso-8859-1] Wed Jul 5 21:36:20 2017 @@ -3153,15 +3153,49 @@ return S_OK; } -/********************************************************** - * IShellView_Constructor - */ -HRESULT WINAPI IShellView_Constructor(IShellFolder *pFolder, IShellView **newView) -{ - return ShellObjectCreatorInit<CDefView>(pFolder, IID_PPV_ARG(IShellView, newView)); -} - -HRESULT WINAPI CDefView_Constructor(IShellFolder *pFolder, REFIID riid, LPVOID * ppvOut) + +HRESULT CDefView_CreateInstance(IShellFolder *pFolder, REFIID riid, LPVOID * ppvOut) { return ShellObjectCreatorInit<CDefView>(pFolder, riid, ppvOut); } + +HRESULT WINAPI SHCreateShellFolderViewEx( + LPCSFV psvcbi, /* [in] shelltemplate struct */ + IShellView **ppsv) /* [out] IShellView pointer */ +{ + CComPtr<IShellView> psv; + HRESULT hRes; + + TRACE("sf=%p pidl=%p cb=%p mode=0x%08x parm=%p\n", + psvcbi->pshf, psvcbi->pidl, psvcbi->pfnCallback, + psvcbi->fvm, psvcbi->psvOuter); + + *ppsv = NULL; + hRes = CDefView_CreateInstance(psvcbi->pshf, IID_PPV_ARG(IShellView, &psv)); + if (FAILED_UNEXPECTEDLY(hRes)) + return hRes; + + *ppsv = psv.Detach(); + return hRes; +} + +HRESULT WINAPI SHCreateShellFolderView(const SFV_CREATE *pcsfv, + IShellView **ppsv) +{ + CComPtr<IShellView> psv; + HRESULT hRes; + + *ppsv = NULL; + if (!pcsfv || pcsfv->cbSize != sizeof(*pcsfv)) + return E_INVALIDARG; + + TRACE("sf=%p outer=%p callback=%p\n", + pcsfv->pshf, pcsfv->psvOuter, pcsfv->psfvcb); + + hRes = CDefView_CreateInstance(pcsfv->pshf, IID_PPV_ARG(IShellView, &psv)); + if (FAILED(hRes)) + return hRes; + + *ppsv = psv.Detach(); + return hRes; +} Modified: trunk/reactos/dll/win32/shell32/folders/CControlPanelFolder.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
============================================================================== --- trunk/reactos/dll/win32/shell32/folders/CControlPanelFolder.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/folders/CControlPanelFolder.cpp [iso-8859-1] Wed Jul 5 21:36:20 2017 @@ -394,7 +394,8 @@ WARN("IContextMenu not implemented\n"); hr = E_NOTIMPL; } else if (IsEqualIID(riid, IID_IShellView)) { - hr = CDefView_Constructor(this, riid, ppvOut); + SFV_CREATE sfvparams = {sizeof(SFV_CREATE), this}; + hr = SHCreateShellFolderView(&sfvparams, (IShellView**)ppvOut); } } TRACE("--(%p)->(interface=%p)\n", this, ppvOut); Modified: trunk/reactos/dll/win32/shell32/folders/CDesktopFolder.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
============================================================================== --- trunk/reactos/dll/win32/shell32/folders/CDesktopFolder.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/folders/CDesktopFolder.cpp [iso-8859-1] Wed Jul 5 21:36:20 2017 @@ -514,7 +514,6 @@ REFIID riid, LPVOID *ppvOut) { - CComPtr<IShellView> pShellView; HRESULT hr = E_INVALIDARG; TRACE ("(%p)->(hwnd=%p,%s,%p)\n", @@ -549,9 +548,8 @@ } else if (IsEqualIID (riid, IID_IShellView)) { - hr = IShellView_Constructor((IShellFolder *)this, &pShellView); - if (pShellView) - hr = pShellView->QueryInterface(riid, ppvOut); + SFV_CREATE sfvparams = {sizeof(SFV_CREATE), this}; + hr = SHCreateShellFolderView(&sfvparams, (IShellView**)ppvOut); } TRACE ("-- (%p)->(interface=%p)\n", this, ppvOut); return hr; Modified: trunk/reactos/dll/win32/shell32/folders/CDrivesFolder.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
============================================================================== --- trunk/reactos/dll/win32/shell32/folders/CDrivesFolder.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/folders/CDrivesFolder.cpp [iso-8859-1] Wed Jul 5 21:36:20 2017 @@ -531,7 +531,8 @@ } else if (IsEqualIID(riid, IID_IShellView)) { - hr = CDefView_Constructor(this, riid, ppvOut); + SFV_CREATE sfvparams = {sizeof(SFV_CREATE), this}; + hr = SHCreateShellFolderView(&sfvparams, (IShellView**)ppvOut); } TRACE ("-- (%p)->(interface=%p)\n", this, ppvOut); return hr; Modified: trunk/reactos/dll/win32/shell32/folders/CFSFolder.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
============================================================================== --- trunk/reactos/dll/win32/shell32/folders/CFSFolder.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/folders/CFSFolder.cpp [iso-8859-1] Wed Jul 5 21:36:20 2017 @@ -393,7 +393,8 @@ } else if (IsEqualIID (riid, IID_IShellView)) { - hr = CDefView_Constructor(this, riid, ppvOut); + SFV_CREATE sfvparams = {sizeof(SFV_CREATE), this}; + hr = SHCreateShellFolderView(&sfvparams, (IShellView**)ppvOut); } } TRACE("-- (%p)->(interface=%p)\n", this, ppvOut); Modified: trunk/reactos/dll/win32/shell32/folders/CNetFolder.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
============================================================================== --- trunk/reactos/dll/win32/shell32/folders/CNetFolder.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/folders/CNetFolder.cpp [iso-8859-1] Wed Jul 5 21:36:20 2017 @@ -362,7 +362,8 @@ } else if (IsEqualIID(riid, IID_IShellView)) { - hr = CDefView_Constructor(this, riid, ppvOut); + SFV_CREATE sfvparams = {sizeof(SFV_CREATE), this}; + hr = SHCreateShellFolderView(&sfvparams, (IShellView**)ppvOut); } TRACE("-- (%p)->(interface=%p)\n", this, ppvOut); return hr; Modified: trunk/reactos/dll/win32/shell32/folders/CPrinterFolder.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
============================================================================== --- trunk/reactos/dll/win32/shell32/folders/CPrinterFolder.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/folders/CPrinterFolder.cpp [iso-8859-1] Wed Jul 5 21:36:20 2017 @@ -285,7 +285,8 @@ } else if(IsEqualIID(riid, IID_IShellView)) { - hr = CDefView_Constructor(this, riid, ppvOut); + SFV_CREATE sfvparams = {sizeof(SFV_CREATE), this}; + hr = SHCreateShellFolderView(&sfvparams, (IShellView**)ppvOut); } TRACE ("-- (%p)->(interface=%p)\n", this, ppvOut); return hr; Modified: trunk/reactos/dll/win32/shell32/folders/CRecycleBin.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders/…
============================================================================== --- trunk/reactos/dll/win32/shell32/folders/CRecycleBin.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/folders/CRecycleBin.cpp [iso-8859-1] Wed Jul 5 21:36:20 2017 @@ -564,7 +564,8 @@ } else if (IsEqualIID (riid, IID_IShellView)) { - hr = CDefView_Constructor(this, riid, ppv); + SFV_CREATE sfvparams = {sizeof(SFV_CREATE), this}; + hr = SHCreateShellFolderView(&sfvparams, (IShellView**)ppv); } else return hr; Modified: trunk/reactos/dll/win32/shell32/wine/shell32_main.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/wine/she…
============================================================================== --- trunk/reactos/dll/win32/shell32/wine/shell32_main.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/wine/shell32_main.h [iso-8859-1] Wed Jul 5 21:36:20 2017 @@ -69,8 +69,6 @@ HRESULT WINAPI INewItem_Constructor(IUnknown * pUnkOuter, REFIID riif, LPVOID *ppv); IContextMenu2 * ISvStaticItemCm_Constructor(LPSHELLFOLDER pSFParent, LPCITEMIDLIST pidl, LPCITEMIDLIST *apidl, UINT cidl, HKEY hKey); IContextMenu2 * ISvBgCm_Constructor(LPSHELLFOLDER pSFParent, BOOL bDesktop); -HRESULT WINAPI IShellView_Constructor(IShellFolder *pFolder, IShellView **newView); -HRESULT WINAPI CDefView_Constructor(IShellFolder *pFolder, REFIID riid, LPVOID * ppvOut); HRESULT WINAPI CDefViewDual_Constructor(REFIID riid, LPVOID * ppvOut); HRESULT WINAPI CShellDispatch_Constructor(REFIID riid, LPVOID * ppvOut); Modified: trunk/reactos/dll/win32/shell32/wine/shellord.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/wine/she…
============================================================================== --- trunk/reactos/dll/win32/shell32/wine/shellord.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/wine/shellord.c [iso-8859-1] Wed Jul 5 21:36:20 2017 @@ -1046,6 +1046,8 @@ * NOTES * see IShellFolder::CreateViewObject */ + #ifndef __REACTOS__ + HRESULT WINAPI SHCreateShellFolderViewEx( LPCSFV psvcbi, /* [in] shelltemplate struct */ IShellView **ppv) /* [out] IShellView pointer */ @@ -1068,6 +1070,8 @@ return hRes; } +#endif + /************************************************************************* * SHWinHelp [SHELL32.127] * @@ -2108,6 +2112,8 @@ return ret; } +#ifndef __REACTOS__ + /************************************************************************* * SHCreateShellFolderView [SHELL32.256] * @@ -2142,3 +2148,4 @@ return hRes; } +#endif
7 years, 5 months
1
0
0
0
[tthompson] 75288: [NTFS] - Add a few fixes and improvements, most from CR-123: -Add ATTR_RECORD_ALIGNMENT define to replace magic value of 8 when we need to adjust an attribute's beginning or leng...
by tthompson@svn.reactos.org
Author: tthompson Date: Wed Jul 5 16:29:16 2017 New Revision: 75288 URL:
http://svn.reactos.org/svn/reactos?rev=75288&view=rev
Log: [NTFS] - Add a few fixes and improvements, most from CR-123: -Add ATTR_RECORD_ALIGNMENT define to replace magic value of 8 when we need to adjust an attribute's beginning or length. -Don't use int's. -GetPackedByteCount() - Remove unused "bytes" variable. Modified: branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/attrib.c branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/btree.c branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/create.c branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/mft.c branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/ntfs.h Modified: branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/attrib.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/NTFS/drivers/filesyst…
============================================================================== --- branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/attrib.c [iso-8859-1] (original) +++ branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/attrib.c [iso-8859-1] Wed Jul 5 16:29:16 2017 @@ -77,7 +77,7 @@ AttributeAddress->Type = AttributeData; AttributeAddress->Length = ResidentHeaderLength; - AttributeAddress->Length = ALIGN_UP_BY(AttributeAddress->Length, 8); + AttributeAddress->Length = ALIGN_UP_BY(AttributeAddress->Length, ATTR_RECORD_ALIGNMENT); AttributeAddress->Resident.ValueLength = 0; AttributeAddress->Resident.ValueOffset = ResidentHeaderLength; @@ -241,7 +241,7 @@ AttributeAddress->Length = ResidentHeaderLength + FIELD_OFFSET(FILENAME_ATTRIBUTE, Name) + FilenameNoPath.Length; - AttributeAddress->Length = ALIGN_UP_BY(AttributeAddress->Length, 8); + AttributeAddress->Length = ALIGN_UP_BY(AttributeAddress->Length, ATTR_RECORD_ALIGNMENT); AttributeAddress->Resident.ValueLength = FIELD_OFFSET(FILENAME_ATTRIBUTE, Name) + FilenameNoPath.Length; AttributeAddress->Resident.ValueOffset = ResidentHeaderLength; @@ -363,7 +363,7 @@ // calculate position of end markers NextAttributeOffset = AttrOffset + AttrContext->Record.NonResident.MappingPairsOffset + RunBufferSize; - NextAttributeOffset = ALIGN_UP_BY(NextAttributeOffset, 8); + NextAttributeOffset = ALIGN_UP_BY(NextAttributeOffset, ATTR_RECORD_ALIGNMENT); // Update the length DestinationAttribute->Length = NextAttributeOffset - AttrOffset; @@ -437,7 +437,7 @@ AttributeAddress->Type = AttributeStandardInformation; AttributeAddress->Length = sizeof(STANDARD_INFORMATION) + ResidentHeaderLength; - AttributeAddress->Length = ALIGN_UP_BY(AttributeAddress->Length, 8); + AttributeAddress->Length = ALIGN_UP_BY(AttributeAddress->Length, ATTR_RECORD_ALIGNMENT); AttributeAddress->Resident.ValueLength = sizeof(STANDARD_INFORMATION); AttributeAddress->Resident.ValueOffset = ResidentHeaderLength; AttributeAddress->Instance = FileRecord->NextAttributeNumber++; @@ -847,7 +847,8 @@ if (NextAttribute->Type == AttributeEnd) { // update attribute length - AttrContext->Record.Length = ALIGN_UP_BY(AttrContext->Record.NonResident.MappingPairsOffset + RunBufferSize, 8); + AttrContext->Record.Length = ALIGN_UP_BY(AttrContext->Record.NonResident.MappingPairsOffset + RunBufferSize, + ATTR_RECORD_ALIGNMENT); DestinationAttribute->Length = AttrContext->Record.Length; // write end markers @@ -1459,7 +1460,6 @@ GetPackedByteCount(LONGLONG NumberToPack, BOOLEAN IsSigned) { - int bytes = 0; if (!IsSigned) { if (NumberToPack >= 0x0100000000000000) @@ -1496,7 +1496,6 @@ return 3; if (NumberToPack >= 0x0000000000000080) return 2; - return 1; } else { @@ -1515,9 +1514,8 @@ return 3; if (NumberToPack <= 0xffffffffffffff80) return 2; - return 1; - } - return bytes; + } + return 1; } NTSTATUS Modified: branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/btree.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/NTFS/drivers/filesyst…
============================================================================== --- branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/btree.c [iso-8859-1] (original) +++ branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/btree.c [iso-8859-1] Wed Jul 5 16:29:16 2017 @@ -271,7 +271,7 @@ PINDEX_ROOT_ATTRIBUTE *IndexRoot, ULONG *Length) { - int i; + ULONG i; PB_TREE_KEY CurrentKey; PINDEX_ENTRY_ATTRIBUTE CurrentNodeEntry; PINDEX_ROOT_ATTRIBUTE NewIndexRoot = ExAllocatePoolWithTag(NonPagedPool, @@ -366,7 +366,7 @@ { PB_TREE_KEY NextKey; PB_TREE_KEY CurrentKey = Node->FirstKey; - int i; + ULONG i; for (i = 0; i < Node->KeyCount; i++) { NT_ASSERT(CurrentKey); @@ -400,9 +400,9 @@ } VOID -DumpBTreeKey(PB_TREE_KEY Key, int Number, int Depth) -{ - int i; +DumpBTreeKey(PB_TREE_KEY Key, ULONG Number, ULONG Depth) +{ + ULONG i; for (i = 0; i < Depth; i++) DbgPrint(" "); DbgPrint(" Key #%d", Number); @@ -420,10 +420,10 @@ } VOID -DumpBTreeNode(PB_TREE_FILENAME_NODE Node, int Number, int Depth) +DumpBTreeNode(PB_TREE_FILENAME_NODE Node, ULONG Number, ULONG Depth) { PB_TREE_KEY CurrentKey; - int i; + ULONG i; for (i = 0; i < Depth; i++) DbgPrint(" "); DbgPrint("Node #%d, Depth %d\n", Number, Depth); @@ -488,7 +488,7 @@ ULONG EntrySize = ALIGN_UP_BY(AttributeSize + FIELD_OFFSET(INDEX_ENTRY_ATTRIBUTE, FileName), 8); PINDEX_ENTRY_ATTRIBUTE NewEntry; PB_TREE_KEY NewKey, CurrentKey, PreviousKey; - int i; + ULONG i; DPRINT1("NtfsInsertKey(0x%02I64, %p, %p, %s)\n", FileReference, Modified: branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/create.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/NTFS/drivers/filesyst…
============================================================================== --- branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/create.c [iso-8859-1] (original) +++ branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/create.c [iso-8859-1] Wed Jul 5 16:29:16 2017 @@ -699,7 +699,7 @@ // setup other file record fields FileRecord->SequenceNumber = 1; FileRecord->AttributeOffset = FileRecord->Ntfs.UsaOffset + (2 * FileRecord->Ntfs.UsaCount); - FileRecord->AttributeOffset = ALIGN_UP_BY(FileRecord->AttributeOffset, 8); + FileRecord->AttributeOffset = ALIGN_UP_BY(FileRecord->AttributeOffset, ATTR_RECORD_ALIGNMENT); FileRecord->Flags = FRH_IN_USE; FileRecord->BytesInUse = FileRecord->AttributeOffset + sizeof(ULONG) * 2; Modified: branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/mft.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/NTFS/drivers/filesyst…
============================================================================== --- branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/mft.c [iso-8859-1] (original) +++ branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/mft.c [iso-8859-1] Wed Jul 5 16:29:16 2017 @@ -373,7 +373,7 @@ // Ensure NextAttributeOffset is aligned to an 8-byte boundary if (NextAttributeOffset % 8 != 0) { - USHORT Padding = 8 - (NextAttributeOffset % 8); + USHORT Padding = ATTR_RECORD_ALIGNMENT - (NextAttributeOffset % ATTR_RECORD_ALIGNMENT); NextAttributeOffset += Padding; AttrContext->Record.Length += Padding; Destination->Length += Padding; @@ -731,7 +731,7 @@ // update the end of the file record // calculate position of end markers (1 byte for empty data run) EndAttributeOffset = AttrOffset + AttrContext->Record.NonResident.MappingPairsOffset + 1; - EndAttributeOffset = ALIGN_UP_BY(EndAttributeOffset, 8); + EndAttributeOffset = ALIGN_UP_BY(EndAttributeOffset, ATTR_RECORD_ALIGNMENT); // Update the length Destination->Length = EndAttributeOffset - AttrOffset; Modified: branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/ntfs.h URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2016/NTFS/drivers/filesyst…
============================================================================== --- branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/ntfs.h [iso-8859-1] (original) +++ branches/GSoC_2016/NTFS/drivers/filesystems/ntfs/ntfs.h [iso-8859-1] Wed Jul 5 16:29:16 2017 @@ -293,6 +293,10 @@ }; } NTFS_ATTR_RECORD, *PNTFS_ATTR_RECORD; +// The beginning and length of an attribute record are always aligned to an 8-byte boundary, +// relative to the beginning of the file record. +#define ATTR_RECORD_ALIGNMENT 8 + typedef struct { ULONGLONG CreationTime; @@ -408,7 +412,7 @@ // A key's sub-node precedes that key in the ordered list. typedef struct { - int KeyCount; + ULONG KeyCount; PB_TREE_KEY FirstKey; } B_TREE_FILENAME_NODE, *PB_TREE_FILENAME_NODE;
7 years, 5 months
1
0
0
0
[cfinck] 75287: [PRINTING] Apply a consistent style to all similar functions: - Spoolss functions don't necessarily set ERROR_SUCCESS. Check the boolean return value instead and only query the erro...
by cfinck@svn.reactos.org
Author: cfinck Date: Wed Jul 5 15:29:13 2017 New Revision: 75287 URL:
http://svn.reactos.org/svn/reactos?rev=75287&view=rev
Log: [PRINTING] Apply a consistent style to all similar functions: - Spoolss functions don't necessarily set ERROR_SUCCESS. Check the boolean return value instead and only query the error code on failure. - Use AlignRpcPtr and UndoAlignRpcPtr wherever feasible. - Use one static function per level that can be called from both Get* and Enum* APIs. - Use PackStrings in all functions that return structures with strings. - Add TRACEs to all non-static functions in localspl. - Pass a double pointer to all Marshalling functions and advance to the next structure there. - Perform sanity checks and return the right error codes in a Windows-compatible way. - Return TRUE when an Enum* API has no elements to enumerate. Also fixes CORE-12793 Modified: trunk/reactos/win32ss/printing/base/spoolss/monitors.c trunk/reactos/win32ss/printing/base/spoolss/ports.c trunk/reactos/win32ss/printing/base/spoolss/printers.c trunk/reactos/win32ss/printing/base/spoolsv/init.c trunk/reactos/win32ss/printing/base/spoolsv/jobs.c trunk/reactos/win32ss/printing/base/spoolsv/monitors.c trunk/reactos/win32ss/printing/base/spoolsv/ports.c trunk/reactos/win32ss/printing/base/spoolsv/printers.c trunk/reactos/win32ss/printing/base/spoolsv/printprocessors.c trunk/reactos/win32ss/printing/monitors/localmon/ports.c trunk/reactos/win32ss/printing/providers/localspl/jobs.c trunk/reactos/win32ss/printing/providers/localspl/main.c trunk/reactos/win32ss/printing/providers/localspl/monitors.c trunk/reactos/win32ss/printing/providers/localspl/ports.c trunk/reactos/win32ss/printing/providers/localspl/precomp.h trunk/reactos/win32ss/printing/providers/localspl/printerdata.c trunk/reactos/win32ss/printing/providers/localspl/printers.c trunk/reactos/win32ss/printing/providers/localspl/printingthread.c trunk/reactos/win32ss/printing/providers/localspl/printprocessors.c Modified: trunk/reactos/win32ss/printing/base/spoolss/monitors.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/printing/base/spoo…
============================================================================== --- trunk/reactos/win32ss/printing/base/spoolss/monitors.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/printing/base/spoolss/monitors.c [iso-8859-1] Wed Jul 5 15:29:13 2017 @@ -10,7 +10,7 @@ BOOL WINAPI EnumMonitorsW(PWSTR pName, DWORD Level, PBYTE pMonitors, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned) { - BOOL bReturnValue; + BOOL bReturnValue = TRUE; DWORD cbCallBuffer; DWORD cbNeeded; DWORD dwReturned; @@ -19,9 +19,9 @@ PLIST_ENTRY pEntry; // Sanity checks. - if ((cbBuf && !pMonitors) || !pcbNeeded || !pcReturned) + if (cbBuf && !pMonitors) { - SetLastError(ERROR_INVALID_PARAMETER); + SetLastError(ERROR_INVALID_USER_BUFFER); return FALSE; } Modified: trunk/reactos/win32ss/printing/base/spoolss/ports.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/printing/base/spoo…
============================================================================== --- trunk/reactos/win32ss/printing/base/spoolss/ports.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/printing/base/spoolss/ports.c [iso-8859-1] Wed Jul 5 15:29:13 2017 @@ -10,7 +10,7 @@ BOOL WINAPI EnumPortsW(PWSTR pName, DWORD Level, PBYTE pPorts, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned) { - BOOL bReturnValue; + BOOL bReturnValue = TRUE; DWORD cbCallBuffer; DWORD cbNeeded; DWORD dwReturned; @@ -19,9 +19,9 @@ PLIST_ENTRY pEntry; // Sanity checks. - if ((cbBuf && !pPorts) || !pcbNeeded || !pcReturned) + if (cbBuf && !pPorts) { - SetLastError(ERROR_INVALID_PARAMETER); + SetLastError(ERROR_INVALID_USER_BUFFER); return FALSE; } Modified: trunk/reactos/win32ss/printing/base/spoolss/printers.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/printing/base/spoo…
============================================================================== --- trunk/reactos/win32ss/printing/base/spoolss/printers.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/printing/base/spoolss/printers.c [iso-8859-1] Wed Jul 5 15:29:13 2017 @@ -67,7 +67,7 @@ { DWORD cbCallBuffer; DWORD cbNeeded; - DWORD dwErrorCode = 0xFFFFFFFF; + DWORD dwErrorCode = MAXDWORD; DWORD dwReturned; PBYTE pCallBuffer; PSPOOLSS_PRINT_PROVIDER pPrintProvider; Modified: trunk/reactos/win32ss/printing/base/spoolsv/init.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/printing/base/spoo…
============================================================================== --- trunk/reactos/win32ss/printing/base/spoolsv/init.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/printing/base/spoolsv/init.c [iso-8859-1] Wed Jul 5 15:29:13 2017 @@ -2,7 +2,7 @@ * PROJECT: ReactOS Print Spooler Service * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation * PURPOSE: Various initialization functions - * COPYRIGHT: Copyright 2015 Colin Finck <colin(a)reactos.org> + * COPYRIGHT: Copyright 2015-2017 Colin Finck <colin(a)reactos.org> */ #include "precomp.h" @@ -21,8 +21,8 @@ return dwErrorCode; } - SpoolerInit(); - dwErrorCode = GetLastError(); + if (!SpoolerInit()) + dwErrorCode = GetLastError(); RpcRevertToSelf(); return dwErrorCode; Modified: trunk/reactos/win32ss/printing/base/spoolsv/jobs.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/printing/base/spoo…
============================================================================== --- trunk/reactos/win32ss/printing/base/spoolsv/jobs.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/printing/base/spoolsv/jobs.c [iso-8859-1] Wed Jul 5 15:29:13 2017 @@ -2,28 +2,29 @@ * PROJECT: ReactOS Print Spooler Service * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation * PURPOSE: Functions for managing print jobs - * COPYRIGHT: Copyright 2015 Colin Finck <colin(a)reactos.org> + * COPYRIGHT: Copyright 2015-2017 Colin Finck <colin(a)reactos.org> */ #include "precomp.h" static void -_MarshallDownAddJobInfo(PADDJOB_INFO_1W pAddJobInfo1) +_MarshallDownAddJobInfo(PADDJOB_INFO_1W* ppAddJobInfo1) { // Replace absolute pointer addresses in the output by relative offsets. + PADDJOB_INFO_1W pAddJobInfo1 = *ppAddJobInfo1; pAddJobInfo1->Path = (PWSTR)((ULONG_PTR)pAddJobInfo1->Path - (ULONG_PTR)pAddJobInfo1); + + *ppAddJobInfo1 += sizeof(ADDJOB_INFO_1W); } static void -_MarshallDownJobInfo(PBYTE pJobInfo, DWORD Level) -{ - PJOB_INFO_1W pJobInfo1; - PJOB_INFO_2W pJobInfo2; - +_MarshallDownJobInfo(PBYTE* ppJobInfo, DWORD Level) +{ // Replace absolute pointer addresses in the output by relative offsets. if (Level == 1) { - pJobInfo1 = (PJOB_INFO_1W)pJobInfo; + PJOB_INFO_1W pJobInfo1 = (PJOB_INFO_1W)(*ppJobInfo); + pJobInfo1->pDatatype = (PWSTR)((ULONG_PTR)pJobInfo1->pDatatype - (ULONG_PTR)pJobInfo1); pJobInfo1->pDocument = (PWSTR)((ULONG_PTR)pJobInfo1->pDocument - (ULONG_PTR)pJobInfo1); pJobInfo1->pMachineName = (PWSTR)((ULONG_PTR)pJobInfo1->pMachineName - (ULONG_PTR)pJobInfo1); @@ -33,10 +34,13 @@ pJobInfo1->pStatus = (PWSTR)((ULONG_PTR)pJobInfo1->pStatus - (ULONG_PTR)pJobInfo1); pJobInfo1->pUserName = (PWSTR)((ULONG_PTR)pJobInfo1->pUserName - (ULONG_PTR)pJobInfo1); + + *ppJobInfo += sizeof(JOB_INFO_1W); } else if (Level == 2) { - pJobInfo2 = (PJOB_INFO_2W)pJobInfo; + PJOB_INFO_2W pJobInfo2 = (PJOB_INFO_2W)(*ppJobInfo); + pJobInfo2->pDatatype = (PWSTR)((ULONG_PTR)pJobInfo2->pDatatype - (ULONG_PTR)pJobInfo2); pJobInfo2->pDevMode = (PDEVMODEW)((ULONG_PTR)pJobInfo2->pDevMode - (ULONG_PTR)pJobInfo2); pJobInfo2->pDocument = (PWSTR)((ULONG_PTR)pJobInfo2->pDocument - (ULONG_PTR)pJobInfo2); @@ -53,6 +57,8 @@ pJobInfo2->pStatus = (PWSTR)((ULONG_PTR)pJobInfo2->pStatus - (ULONG_PTR)pJobInfo2); pJobInfo2->pUserName = (PWSTR)((ULONG_PTR)pJobInfo2->pUserName - (ULONG_PTR)pJobInfo2); + + *ppJobInfo += sizeof(JOB_INFO_2W); } } @@ -60,21 +66,32 @@ _RpcAddJob(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD Level, BYTE* pAddJob, DWORD cbBuf, DWORD* pcbNeeded) { DWORD dwErrorCode; - - dwErrorCode = RpcImpersonateClient(NULL); - if (dwErrorCode != ERROR_SUCCESS) - { - ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode); - return dwErrorCode; - } - - AddJobW(hPrinter, Level, pAddJob, cbBuf, pcbNeeded); - dwErrorCode = GetLastError(); - - if (dwErrorCode == ERROR_SUCCESS) - _MarshallDownAddJobInfo((PADDJOB_INFO_1W)pAddJob); - - RpcRevertToSelf(); + PBYTE pAddJobAligned; + + dwErrorCode = RpcImpersonateClient(NULL); + if (dwErrorCode != ERROR_SUCCESS) + { + ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode); + return dwErrorCode; + } + + pAddJobAligned = AlignRpcPtr(pAddJob, &cbBuf); + + if (AddJobW(hPrinter, Level, pAddJobAligned, cbBuf, pcbNeeded)) + { + PBYTE p = pAddJobAligned; + + // Replace absolute pointer addresses in the output by relative offsets. + _MarshallDownAddJobInfo((PADDJOB_INFO_1W*)&p); + } + else + { + dwErrorCode = GetLastError(); + } + + RpcRevertToSelf(); + UndoAlignRpcPtr(pAddJob, pAddJobAligned, cbBuf, pcbNeeded); + return dwErrorCode; } @@ -82,34 +99,34 @@ _RpcEnumJobs(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD FirstJob, DWORD NoJobs, DWORD Level, BYTE* pJob, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned) { DWORD dwErrorCode; - DWORD i; - PBYTE p = pJob; - - dwErrorCode = RpcImpersonateClient(NULL); - if (dwErrorCode != ERROR_SUCCESS) - { - ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode); - return dwErrorCode; - } - - EnumJobsW(hPrinter, FirstJob, NoJobs, Level, pJob, cbBuf, pcbNeeded, pcReturned); - dwErrorCode = GetLastError(); - - if (dwErrorCode == ERROR_SUCCESS) - { + PBYTE pJobAligned; + + dwErrorCode = RpcImpersonateClient(NULL); + if (dwErrorCode != ERROR_SUCCESS) + { + ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode); + return dwErrorCode; + } + + pJobAligned = AlignRpcPtr(pJob, &cbBuf); + + if (EnumJobsW(hPrinter, FirstJob, NoJobs, Level, pJobAligned, cbBuf, pcbNeeded, pcReturned)) + { + DWORD i; + PBYTE p = pJobAligned; + // Replace absolute pointer addresses in the output by relative offsets. for (i = 0; i < *pcReturned; i++) - { - _MarshallDownJobInfo(p, Level); - - if (Level == 1) - p += sizeof(JOB_INFO_1W); - else if (Level == 2) - p += sizeof(JOB_INFO_2W); - } - } - - RpcRevertToSelf(); + _MarshallDownJobInfo(&p, Level); + } + else + { + dwErrorCode = GetLastError(); + } + + RpcRevertToSelf(); + UndoAlignRpcPtr(pJob, pJobAligned, cbBuf, pcbNeeded); + return dwErrorCode; } @@ -117,24 +134,32 @@ _RpcGetJob(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD JobId, DWORD Level, BYTE* pJob, DWORD cbBuf, DWORD* pcbNeeded) { DWORD dwErrorCode; - - dwErrorCode = RpcImpersonateClient(NULL); - if (dwErrorCode != ERROR_SUCCESS) - { - ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode); - return dwErrorCode; - } - - GetJobW(hPrinter, JobId, Level, pJob, cbBuf, pcbNeeded); - dwErrorCode = GetLastError(); - - if (dwErrorCode == ERROR_SUCCESS) - { + PBYTE pJobAligned; + + dwErrorCode = RpcImpersonateClient(NULL); + if (dwErrorCode != ERROR_SUCCESS) + { + ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode); + return dwErrorCode; + } + + pJobAligned = AlignRpcPtr(pJob, &cbBuf); + + if (GetJobW(hPrinter, JobId, Level, pJobAligned, cbBuf, pcbNeeded)) + { + PBYTE p = pJobAligned; + // Replace absolute pointer addresses in the output by relative offsets. - _MarshallDownJobInfo(pJob, Level); - } - - RpcRevertToSelf(); + _MarshallDownJobInfo(&p, Level); + } + else + { + dwErrorCode = GetLastError(); + } + + RpcRevertToSelf(); + UndoAlignRpcPtr(pJob, pJobAligned, cbBuf, pcbNeeded); + return dwErrorCode; } @@ -150,8 +175,8 @@ return dwErrorCode; } - ScheduleJob(hPrinter, JobId); - dwErrorCode = GetLastError(); + if (!ScheduleJob(hPrinter, JobId)) + dwErrorCode = GetLastError(); RpcRevertToSelf(); return dwErrorCode; @@ -170,9 +195,9 @@ } // pJobContainer->JobInfo is a union of pointers, so we can just convert any element to our BYTE pointer. - SetJobW(hPrinter, JobId, pJobContainer->Level, (PBYTE)pJobContainer->JobInfo.Level1, Command); - dwErrorCode = GetLastError(); - - RpcRevertToSelf(); - return dwErrorCode; -} + if (!SetJobW(hPrinter, JobId, pJobContainer->Level, (PBYTE)pJobContainer->JobInfo.Level1, Command)) + dwErrorCode = GetLastError(); + + RpcRevertToSelf(); + return dwErrorCode; +} Modified: trunk/reactos/win32ss/printing/base/spoolsv/monitors.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/printing/base/spoo…
============================================================================== --- trunk/reactos/win32ss/printing/base/spoolsv/monitors.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/printing/base/spoolsv/monitors.c [iso-8859-1] Wed Jul 5 15:29:13 2017 @@ -2,23 +2,28 @@ * PROJECT: ReactOS Print Spooler Service * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation * PURPOSE: Functions related to Print Monitors - * COPYRIGHT: Copyright 2015 Colin Finck <colin(a)reactos.org> + * COPYRIGHT: Copyright 2015-2017 Colin Finck <colin(a)reactos.org> */ #include "precomp.h" static void -_MarshallDownMonitorInfo(PBYTE pMonitorInfo, DWORD Level) +_MarshallDownMonitorInfo(PBYTE* ppMonitorInfo, DWORD Level) { - PMONITOR_INFO_2W pMonitorInfo2 = (PMONITOR_INFO_2W)pMonitorInfo; // MONITOR_INFO_1W is a subset of MONITOR_INFO_2W + PMONITOR_INFO_2W pMonitorInfo2 = (PMONITOR_INFO_2W)(*ppMonitorInfo); // MONITOR_INFO_1W is a subset of MONITOR_INFO_2W // Replace absolute pointer addresses in the output by relative offsets. pMonitorInfo2->pName = (PWSTR)((ULONG_PTR)pMonitorInfo2->pName - (ULONG_PTR)pMonitorInfo2); - if (Level == 2) + if (Level == 1) + { + *ppMonitorInfo += sizeof(MONITOR_INFO_1W); + } + else { pMonitorInfo2->pDLLName = (PWSTR)((ULONG_PTR)pMonitorInfo2->pDLLName - (ULONG_PTR)pMonitorInfo2); pMonitorInfo2->pEnvironment = (PWSTR)((ULONG_PTR)pMonitorInfo2->pEnvironment - (ULONG_PTR)pMonitorInfo2); + *ppMonitorInfo += sizeof(MONITOR_INFO_2W); } } @@ -40,8 +45,7 @@ _RpcEnumMonitors(WINSPOOL_HANDLE pName, DWORD Level, BYTE* pMonitor, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned) { DWORD dwErrorCode; - DWORD i; - PBYTE p = pMonitor; + PBYTE pMonitorAligned; dwErrorCode = RpcImpersonateClient(NULL); if (dwErrorCode != ERROR_SUCCESS) @@ -50,23 +54,24 @@ return dwErrorCode; } - EnumMonitorsW(pName, Level, pMonitor, cbBuf, pcbNeeded, pcReturned); - dwErrorCode = GetLastError(); + pMonitorAligned = AlignRpcPtr(pMonitor, &cbBuf); - if (dwErrorCode == ERROR_SUCCESS) + if(EnumMonitorsW(pName, Level, pMonitorAligned, cbBuf, pcbNeeded, pcReturned)) { // Replace absolute pointer addresses in the output by relative offsets. + DWORD i; + PBYTE p = pMonitorAligned; + for (i = 0; i < *pcReturned; i++) - { - _MarshallDownMonitorInfo(p, Level); - - if (Level == 1) - p += sizeof(MONITOR_INFO_1W); - else if (Level == 2) - p += sizeof(MONITOR_INFO_2W); - } + _MarshallDownMonitorInfo(&p, Level); + } + else + { + dwErrorCode = GetLastError(); } RpcRevertToSelf(); + UndoAlignRpcPtr(pMonitor, pMonitorAligned, cbBuf, pcbNeeded); + return dwErrorCode; } Modified: trunk/reactos/win32ss/printing/base/spoolsv/ports.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/printing/base/spoo…
============================================================================== --- trunk/reactos/win32ss/printing/base/spoolsv/ports.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/printing/base/spoolsv/ports.c [iso-8859-1] Wed Jul 5 15:29:13 2017 @@ -2,23 +2,40 @@ * PROJECT: ReactOS Print Spooler Service * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation * PURPOSE: Functions related to Ports - * COPYRIGHT: Copyright 2015 Colin Finck <colin(a)reactos.org> + * COPYRIGHT: Copyright 2015-2017 Colin Finck <colin(a)reactos.org> */ #include "precomp.h" static void -_MarshallDownPortInfo(PBYTE pPortInfo, DWORD Level) +_MarshallDownPortInfo(PBYTE* ppPortInfo, DWORD Level) { - PPORT_INFO_2W pPortInfo2 = (PPORT_INFO_2W)pPortInfo; // PORT_INFO_1W is a subset of PORT_INFO_2W + // Replace absolute pointer addresses in the output by relative offsets. + if (Level == 1) + { + PPORT_INFO_1W pPortInfo1 = (PPORT_INFO_1W)(*ppPortInfo); - // Replace absolute pointer addresses in the output by relative offsets. - pPortInfo2->pPortName = (PWSTR)((ULONG_PTR)pPortInfo2->pPortName - (ULONG_PTR)pPortInfo2); + pPortInfo1->pName = (PWSTR)((ULONG_PTR)pPortInfo1->pName - (ULONG_PTR)pPortInfo1); - if (Level == 2) + *ppPortInfo += sizeof(PORT_INFO_1W); + } + else if (Level == 2) { + PPORT_INFO_2W pPortInfo2 = (PPORT_INFO_2W)(*ppPortInfo); + + pPortInfo2->pPortName = (PWSTR)((ULONG_PTR)pPortInfo2->pPortName - (ULONG_PTR)pPortInfo2); pPortInfo2->pDescription = (PWSTR)((ULONG_PTR)pPortInfo2->pDescription - (ULONG_PTR)pPortInfo2); pPortInfo2->pMonitorName = (PWSTR)((ULONG_PTR)pPortInfo2->pMonitorName - (ULONG_PTR)pPortInfo2); + + *ppPortInfo += sizeof(PORT_INFO_2W); + } + else if (Level == 3) + { + PPORT_INFO_3W pPortInfo3 = (PPORT_INFO_3W)(*ppPortInfo); + + pPortInfo3->pszStatus = (PWSTR)((ULONG_PTR)pPortInfo3->pszStatus - (ULONG_PTR)pPortInfo3); + + *ppPortInfo += sizeof(PORT_INFO_3W); } } @@ -54,8 +71,7 @@ _RpcEnumPorts(WINSPOOL_HANDLE pName, DWORD Level, BYTE* pPort, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned) { DWORD dwErrorCode; - DWORD i; - PBYTE p = pPort; + PBYTE pPortAligned; dwErrorCode = RpcImpersonateClient(NULL); if (dwErrorCode != ERROR_SUCCESS) @@ -64,24 +80,25 @@ return dwErrorCode; } - EnumPortsW(pName, Level, pPort, cbBuf, pcbNeeded, pcReturned); - dwErrorCode = GetLastError(); + pPortAligned = AlignRpcPtr(pPort, &cbBuf); - if (dwErrorCode == ERROR_SUCCESS) + if (EnumPortsW(pName, Level, pPortAligned, cbBuf, pcbNeeded, pcReturned)) { // Replace absolute pointer addresses in the output by relative offsets. + DWORD i; + PBYTE p = pPortAligned; + for (i = 0; i < *pcReturned; i++) - { - _MarshallDownPortInfo(p, Level); - - if (Level == 1) - p += sizeof(PORT_INFO_1W); - else if (Level == 2) - p += sizeof(PORT_INFO_2W); - } + _MarshallDownPortInfo(&p, Level); + } + else + { + dwErrorCode = GetLastError(); } RpcRevertToSelf(); + UndoAlignRpcPtr(pPort, pPortAligned, cbBuf, pcbNeeded); + return dwErrorCode; } Modified: trunk/reactos/win32ss/printing/base/spoolsv/printers.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/printing/base/spoo…
============================================================================== --- trunk/reactos/win32ss/printing/base/spoolsv/printers.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/printing/base/spoolsv/printers.c [iso-8859-1] Wed Jul 5 15:29:13 2017 @@ -150,8 +150,8 @@ if (ClosePrinter(*phPrinter)) *phPrinter = NULL; - - dwErrorCode = GetLastError(); + else + dwErrorCode = GetLastError(); RpcRevertToSelf(); return dwErrorCode; @@ -176,8 +176,8 @@ return dwErrorCode; } - EndDocPrinter(hPrinter); - dwErrorCode = GetLastError(); + if (!EndDocPrinter(hPrinter)) + dwErrorCode = GetLastError(); RpcRevertToSelf(); return dwErrorCode; @@ -195,8 +195,8 @@ return dwErrorCode; } - EndPagePrinter(hPrinter); - dwErrorCode = GetLastError(); + if (!EndPagePrinter(hPrinter)) + dwErrorCode = GetLastError(); RpcRevertToSelf(); return dwErrorCode; @@ -216,10 +216,8 @@ } pPrinterEnumAligned = AlignRpcPtr(pPrinterEnum, &cbBuf); - EnumPrintersW(Flags, Name, Level, pPrinterEnumAligned, cbBuf, pcbNeeded, pcReturned); - dwErrorCode = GetLastError(); - - if (dwErrorCode == ERROR_SUCCESS) + + if (EnumPrintersW(Flags, Name, Level, pPrinterEnumAligned, cbBuf, pcbNeeded, pcReturned)) { DWORD i; PBYTE p = pPrinterEnumAligned; @@ -227,6 +225,10 @@ for (i = 0; i < *pcReturned; i++) _MarshallDownPrinterInfo(&p, Level); } + else + { + dwErrorCode = GetLastError(); + } RpcRevertToSelf(); UndoAlignRpcPtr(pPrinterEnum, pPrinterEnumAligned, cbBuf, pcbNeeded); @@ -255,13 +257,15 @@ } pPrinterAligned = AlignRpcPtr(pPrinter, &cbBuf); - GetPrinterW(hPrinter, Level, pPrinterAligned, cbBuf, pcbNeeded); - dwErrorCode = GetLastError(); - - if (dwErrorCode == ERROR_SUCCESS) + + if (GetPrinterW(hPrinter, Level, pPrinterAligned, cbBuf, pcbNeeded)) { PBYTE p = pPrinterAligned; _MarshallDownPrinterInfo(&p, Level); + } + else + { + dwErrorCode = GetLastError(); } RpcRevertToSelf(); @@ -287,8 +291,8 @@ Default.pDatatype = pDatatype; Default.pDevMode = (PDEVMODEW)pDevModeContainer->pDevMode; - OpenPrinterW(pPrinterName, phPrinter, &Default); - dwErrorCode = GetLastError(); + if (!OpenPrinterW(pPrinterName, phPrinter, &Default)) + dwErrorCode = GetLastError(); RpcRevertToSelf(); return dwErrorCode; @@ -313,8 +317,8 @@ return dwErrorCode; } - ReadPrinter(hPrinter, pBuf, cbBuf, pcNoBytesRead); - dwErrorCode = GetLastError(); + if (!ReadPrinter(hPrinter, pBuf, cbBuf, pcNoBytesRead)) + dwErrorCode = GetLastError(); RpcRevertToSelf(); return dwErrorCode; @@ -379,8 +383,8 @@ return dwErrorCode; } - StartPagePrinter(hPrinter); - dwErrorCode = GetLastError(); + if (!StartPagePrinter(hPrinter)) + dwErrorCode = GetLastError(); RpcRevertToSelf(); return dwErrorCode; @@ -398,9 +402,9 @@ return dwErrorCode; } - WritePrinter(hPrinter, pBuf, cbBuf, pcWritten); - dwErrorCode = GetLastError(); - - RpcRevertToSelf(); - return dwErrorCode; -} + if (!WritePrinter(hPrinter, pBuf, cbBuf, pcWritten)) + dwErrorCode = GetLastError(); + + RpcRevertToSelf(); + return dwErrorCode; +} Modified: trunk/reactos/win32ss/printing/base/spoolsv/printprocessors.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/printing/base/spoo…
============================================================================== --- trunk/reactos/win32ss/printing/base/spoolsv/printprocessors.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/printing/base/spoolsv/printprocessors.c [iso-8859-1] Wed Jul 5 15:29:13 2017 @@ -2,7 +2,7 @@ * PROJECT: ReactOS Print Spooler Service * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation * PURPOSE: Functions related to Print Processors - * COPYRIGHT: Copyright 2015 Colin Finck <colin(a)reactos.org> + * COPYRIGHT: Copyright 2015-2017 Colin Finck <colin(a)reactos.org> */ #include "precomp.h" @@ -78,6 +78,7 @@ _RpcEnumPrintProcessors(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, DWORD Level, BYTE* pPrintProcessorInfo, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned) { DWORD dwErrorCode; + PBYTE pPrintProcessorInfoAligned; dwErrorCode = RpcImpersonateClient(NULL); if (dwErrorCode != ERROR_SUCCESS) @@ -86,20 +87,25 @@ return dwErrorCode; } - EnumPrintProcessorsW(pName, pEnvironment, Level, pPrintProcessorInfo, cbBuf, pcbNeeded, pcReturned); - dwErrorCode = GetLastError(); + pPrintProcessorInfoAligned = AlignRpcPtr(pPrintProcessorInfo, &cbBuf); - if (dwErrorCode == ERROR_SUCCESS) + if (EnumPrintProcessorsW(pName, pEnvironment, Level, pPrintProcessorInfoAligned, cbBuf, pcbNeeded, pcReturned)) { // Replace absolute pointer addresses in the output by relative offsets. DWORD i; - PPRINTPROCESSOR_INFO_1W p = (PPRINTPROCESSOR_INFO_1W)pPrintProcessorInfo; + PPRINTPROCESSOR_INFO_1W p = (PPRINTPROCESSOR_INFO_1W)pPrintProcessorInfoAligned; for (i = 0; i < *pcReturned; i++) _MarshallDownPrintProcessorInfo(&p); } + else + { + dwErrorCode = GetLastError(); + } RpcRevertToSelf(); + UndoAlignRpcPtr(pPrintProcessorInfo, pPrintProcessorInfoAligned, cbBuf, pcbNeeded); + return dwErrorCode; } @@ -115,8 +121,8 @@ return dwErrorCode; } - GetPrintProcessorDirectoryW(pName, pEnvironment, Level, pPrintProcessorDirectory, cbBuf, pcbNeeded); - dwErrorCode = GetLastError(); + if (!GetPrintProcessorDirectoryW(pName, pEnvironment, Level, pPrintProcessorDirectory, cbBuf, pcbNeeded)) + dwErrorCode = GetLastError(); RpcRevertToSelf(); return dwErrorCode; Modified: trunk/reactos/win32ss/printing/monitors/localmon/ports.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/printing/monitors/…
============================================================================== --- trunk/reactos/win32ss/printing/monitors/localmon/ports.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/printing/monitors/localmon/ports.c [iso-8859-1] Wed Jul 5 15:29:13 2017 @@ -2,15 +2,26 @@ * PROJECT: ReactOS Local Port Monitor * LICENSE: GNU LGPL v2.1 or any later version as published by the Free Software Foundation * PURPOSE: Functions related to ports - * COPYRIGHT: Copyright 2015 Colin Finck <colin(a)reactos.org> + * COPYRIGHT: Copyright 2015-2017 Colin Finck <colin(a)reactos.org> */ #include "precomp.h" - // Local Constants static const WCHAR wszNonspooledPrefix[] = L"NONSPOOLED_"; static const DWORD cchNonspooledPrefix = _countof(wszNonspooledPrefix) - 1; + +static DWORD dwPortInfo1Offsets[] = { + FIELD_OFFSET(PORT_INFO_1W, pName), + MAXDWORD +}; + +static DWORD dwPortInfo2Offsets[] = { + FIELD_OFFSET(PORT_INFO_2W, pPortName), + FIELD_OFFSET(PORT_INFO_2W, pMonitorName), + FIELD_OFFSET(PORT_INFO_2W, pDescription), + MAXDWORD +}; /** @@ -359,130 +370,60 @@ return NULL; } -static DWORD -_LocalmonEnumPortsLevel1(PLOCALMON_HANDLE pLocalmon, PBYTE pPorts, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned) +static void +_LocalmonGetPortLevel1(PLOCALMON_PORT pPort, PPORT_INFO_1W* ppPortInfo, PBYTE* ppPortInfoEnd, PDWORD pcbNeeded) { DWORD cbPortName; - DWORD dwErrorCode; - DWORD dwPortCount = 0; - PBYTE pPortInfo; - PBYTE pPortString; - PLIST_ENTRY pEntry; - PLOCALMON_PORT pPort; - PORT_INFO_1W PortInfo1; - - // Count the required buffer size and the number of datatypes. - for (pEntry = pLocalmon->RegistryPorts.Flink; pEntry != &pLocalmon->RegistryPorts; pEntry = pEntry->Flink) - { - pPort = CONTAINING_RECORD(pEntry, LOCALMON_PORT, Entry); - + PWSTR pwszStrings[1]; + + // Calculate the string lengths. + if (!ppPortInfo) + { cbPortName = (wcslen(pPort->pwszPortName) + 1) * sizeof(WCHAR); + *pcbNeeded += sizeof(PORT_INFO_1W) + cbPortName; - dwPortCount++; - } - - // Check if the supplied buffer is large enough. - if (cbBuf < *pcbNeeded) - { - dwErrorCode = ERROR_INSUFFICIENT_BUFFER; - goto Cleanup; - } - - // Put the strings right after the last PORT_INFO_1W structure. - pPortInfo = pPorts; - pPortString = pPorts + dwPortCount * sizeof(PORT_INFO_1W); - - // Copy over all ports. - for (pEntry = pLocalmon->RegistryPorts.Flink; pEntry != &pLocalmon->RegistryPorts; pEntry = pEntry->Flink) - { - pPort = CONTAINING_RECORD(pEntry, LOCALMON_PORT, Entry); - - // Copy the port name. - PortInfo1.pName = (PWSTR)pPortString; + return; + } + + // Set the pName field. + pwszStrings[0] = pPort->pwszPortName; + + // Copy the structure and advance to the next one in the output buffer. + *ppPortInfoEnd = PackStrings(pwszStrings, (PBYTE)(*ppPortInfo), dwPortInfo1Offsets, *ppPortInfoEnd); + (*ppPortInfo)++; +} + +static void +_LocalmonGetPortLevel2(PLOCALMON_PORT pPort, PPORT_INFO_2W* ppPortInfo, PBYTE* ppPortInfoEnd, PDWORD pcbNeeded) +{ + DWORD cbPortName; + PWSTR pwszStrings[3]; + + // Calculate the string lengths. + if (!ppPortInfo) + { cbPortName = (wcslen(pPort->pwszPortName) + 1) * sizeof(WCHAR); - CopyMemory(pPortString, pPort->pwszPortName, cbPortName); - pPortString += cbPortName; - - // Copy the structure and advance to the next one in the output buffer. - CopyMemory(pPortInfo, &PortInfo1, sizeof(PORT_INFO_1W)); - pPortInfo += sizeof(PORT_INFO_1W); - } - - *pcReturned = dwPortCount; - dwErrorCode = ERROR_SUCCESS; - -Cleanup: - return dwErrorCode; -} - -static DWORD -_LocalmonEnumPortsLevel2(PLOCALMON_HANDLE pLocalmon, PBYTE pPorts, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned) -{ - DWORD cbPortName; - DWORD dwErrorCode; - DWORD dwPortCount = 0; - PBYTE pPortInfo; - PBYTE pPortString; - PLIST_ENTRY pEntry; - PLOCALMON_PORT pPort; - PORT_INFO_2W PortInfo2; - - // Count the required buffer size and the number of datatypes. - for (pEntry = pLocalmon->RegistryPorts.Flink; pEntry != &pLocalmon->RegistryPorts; pEntry = pEntry->Flink) - { - pPort = CONTAINING_RECORD(pEntry, LOCALMON_PORT, Entry); - - cbPortName = (wcslen(pPort->pwszPortName) + 1) * sizeof(WCHAR); + *pcbNeeded += sizeof(PORT_INFO_2W) + cbPortName + cbLocalMonitor + cbLocalPort; - dwPortCount++; - } - - // Check if the supplied buffer is large enough. - if (cbBuf < *pcbNeeded) - { - dwErrorCode = ERROR_INSUFFICIENT_BUFFER; - goto Cleanup; - } - - // Put the strings right after the last PORT_INFO_2W structure. - pPortInfo = pPorts; - pPortString = pPorts + dwPortCount * sizeof(PORT_INFO_2W); - - // Copy over all ports. - for (pEntry = pLocalmon->RegistryPorts.Flink; pEntry != &pLocalmon->RegistryPorts; pEntry = pEntry->Flink) - { - pPort = CONTAINING_RECORD(pEntry, LOCALMON_PORT, Entry); - - // All local ports are writable and readable. - PortInfo2.fPortType = PORT_TYPE_WRITE | PORT_TYPE_READ; - PortInfo2.Reserved = 0; - - // Copy the port name. - PortInfo2.pPortName = (PWSTR)pPortString; - cbPortName = (wcslen(pPort->pwszPortName) + 1) * sizeof(WCHAR); - CopyMemory(pPortString, pPort->pwszPortName, cbPortName); - pPortString += cbPortName; - - // Copy the monitor name. - PortInfo2.pMonitorName = (PWSTR)pPortString; - CopyMemory(pPortString, pwszLocalMonitor, cbLocalMonitor); - pPortString += cbLocalMonitor; - - // Copy the description. - PortInfo2.pDescription = (PWSTR)pPortString; - CopyMemory(pPortString, pwszLocalPort, cbLocalPort); - pPortString += cbLocalPort; - - // Copy the structure and advance to the next one in the output buffer. - CopyMemory(pPortInfo, &PortInfo2, sizeof(PORT_INFO_2W)); - pPortInfo += sizeof(PORT_INFO_2W); - } - - *pcReturned = dwPortCount; - dwErrorCode = ERROR_SUCCESS; - -Cleanup: - return dwErrorCode; + return; + } + + // All local ports are writable and readable. + (*ppPortInfo)->fPortType = PORT_TYPE_WRITE | PORT_TYPE_READ; + (*ppPortInfo)->Reserved = 0; + + // Set the pPortName field. + pwszStrings[0] = pPort->pwszPortName; + + // Set the pMonitorName field. + pwszStrings[1] = (PWSTR)pwszLocalMonitor; + + // Set the pDescription field. + pwszStrings[2] = (PWSTR)pwszLocalPort; + + // Copy the structure and advance to the next one in the output buffer. + *ppPortInfoEnd = PackStrings(pwszStrings, (PBYTE)(*ppPortInfo), dwPortInfo2Offsets, *ppPortInfoEnd); + (*ppPortInfo)++; } /** @@ -590,20 +531,18 @@ LocalmonEnumPorts(HANDLE hMonitor, PWSTR pName, DWORD Level, PBYTE pPorts, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned) { DWORD dwErrorCode; + PBYTE pPortInfoEnd; + PLIST_ENTRY pEntry; PLOCALMON_HANDLE pLocalmon = (PLOCALMON_HANDLE)hMonitor; + PLOCALMON_PORT pPort; TRACE("LocalmonEnumPorts(%p, %S, %lu, %p, %lu, %p, %p)\n", hMonitor, pName, Level, pPorts, cbBuf, pcbNeeded, pcReturned); - // Sanity checks - if (!pLocalmon || (cbBuf && !pPorts) || !pcbNeeded || !pcReturned) - { - dwErrorCode = ERROR_INVALID_PARAMETER; - goto Cleanup; - } - - if (Level > 2) - { - dwErrorCode = ERROR_INVALID_LEVEL; + // Windows Server 2003's Local Port Monitor does absolutely no sanity checks here, not even for the Level parameter. + // As we implement a more modern MONITOR2-based Port Monitor, check at least our hMonitor. + if (!pLocalmon) + { + dwErrorCode = ERROR_INVALID_HANDLE; goto Cleanup; } @@ -613,13 +552,42 @@ EnterCriticalSection(&pLocalmon->Section); - // The function behaves differently for each level. - if (Level == 1) - dwErrorCode = _LocalmonEnumPortsLevel1(pLocalmon, pPorts, cbBuf, pcbNeeded, pcReturned); - else if (Level == 2) - dwErrorCode = _LocalmonEnumPortsLevel2(pLocalmon, pPorts, cbBuf, pcbNeeded, pcReturned); + // Count the required buffer size and the number of ports. + for (pEntry = pLocalmon->RegistryPorts.Flink; pEntry != &pLocalmon->RegistryPorts; pEntry = pEntry->Flink) + { + pPort = CONTAINING_RECORD(pEntry, LOCALMON_PORT, Entry); + + if (Level == 1) + _LocalmonGetPortLevel1(pPort, NULL, NULL, pcbNeeded); + else if (Level == 2) + _LocalmonGetPortLevel2(pPort, NULL, NULL, pcbNeeded); + } + + // Check if the supplied buffer is large enough. + if (cbBuf < *pcbNeeded) + { + LeaveCriticalSection(&pLocalmon->Section); + dwErrorCode = ERROR_INSUFFICIENT_BUFFER; + goto Cleanup; + } + + // Copy over the Port information. + pPortInfoEnd = &pPorts[*pcbNeeded]; + + for (pEntry = pLocalmon->RegistryPorts.Flink; pEntry != &pLocalmon->RegistryPorts; pEntry = pEntry->Flink) + { + pPort = CONTAINING_RECORD(pEntry, LOCALMON_PORT, Entry); + + if (Level == 1) + _LocalmonGetPortLevel1(pPort, (PPORT_INFO_1W*)&pPorts, &pPortInfoEnd, NULL); + else if (Level == 2) + _LocalmonGetPortLevel2(pPort, (PPORT_INFO_2W*)&pPorts, &pPortInfoEnd, NULL); + + (*pcReturned)++; + } LeaveCriticalSection(&pLocalmon->Section); + dwErrorCode = ERROR_SUCCESS; Cleanup: SetLastError(dwErrorCode); @@ -729,6 +697,8 @@ goto Cleanup; } + EnterCriticalSection(&pLocalmon->Section); + // Check if this is a FILE: port. if (_wcsicmp(pName, L"FILE:") == 0) { @@ -739,13 +709,10 @@ pPort->hFile = INVALID_HANDLE_VALUE; // Add it to the list of file ports. - EnterCriticalSection(&pLocalmon->Section); InsertTailList(&pLocalmon->FilePorts, &pPort->Entry); } else { - EnterCriticalSection(&pLocalmon->Section); - // Check if the port name is valid. pPort = _FindPort(pLocalmon, pName); if (!pPort) Modified: trunk/reactos/win32ss/printing/providers/localspl/jobs.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/printing/providers…
============================================================================== --- trunk/reactos/win32ss/printing/providers/localspl/jobs.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/printing/providers/localspl/jobs.c [iso-8859-1] Wed Jul 5 15:29:13 2017 @@ -12,6 +12,31 @@ // Local Variables static DWORD _dwLastJobID; + +// Local Constants +static DWORD dwJobInfo1Offsets[] = { + FIELD_OFFSET(JOB_INFO_1W, pPrinterName), + FIELD_OFFSET(JOB_INFO_1W, pMachineName), + FIELD_OFFSET(JOB_INFO_1W, pUserName), + FIELD_OFFSET(JOB_INFO_1W, pDocument), + FIELD_OFFSET(JOB_INFO_1W, pDatatype), + FIELD_OFFSET(JOB_INFO_1W, pStatus), + MAXDWORD +}; + +static DWORD dwJobInfo2Offsets[] = { + FIELD_OFFSET(JOB_INFO_2W, pPrinterName), + FIELD_OFFSET(JOB_INFO_2W, pMachineName), + FIELD_OFFSET(JOB_INFO_2W, pUserName), + FIELD_OFFSET(JOB_INFO_2W, pDocument), + FIELD_OFFSET(JOB_INFO_2W, pNotifyName), + FIELD_OFFSET(JOB_INFO_2W, pDatatype), + FIELD_OFFSET(JOB_INFO_2W, pPrintProcessor), + FIELD_OFFSET(JOB_INFO_2W, pParameters), + FIELD_OFFSET(JOB_INFO_2W, pDriverName), + FIELD_OFFSET(JOB_INFO_2W, pStatus), + MAXDWORD +}; /** @@ -135,6 +160,8 @@ DWORD GetJobFilePath(PCWSTR pwszExtension, DWORD dwJobID, PWSTR pwszOutput) { + TRACE("GetJobFilePath(%S, %lu, %p)\n", pwszExtension, dwJobID, pwszOutput); + if (pwszOutput) { CopyMemory(pwszOutput, wszJobDirectory, cchJobDirectory * sizeof(WCHAR)); @@ -146,7 +173,7 @@ } BOOL -InitializeGlobalJobList() +InitializeGlobalJobList(void) { const WCHAR wszPath[] = L"\\?????.SHD"; const DWORD cchPath = _countof(wszPath) - 1; @@ -159,6 +186,8 @@ WCHAR wszFullPath[MAX_PATH]; WIN32_FIND_DATAW FindData; + TRACE("InitializeGlobalJobList()\n"); + // This one is incremented in _GetNextJobID. _dwLastJobID = 0; @@ -232,6 +261,8 @@ void InitializePrinterJobList(PLOCAL_PRINTER pPrinter) { + TRACE("InitializePrinterJobList(%p)\n", pPrinter); + // Initialize an empty list for this printer's jobs. // This one is only for sorting the jobs. If you need to lookup a job, search the GlobalJobList by Job ID. InitializeSkiplist(&pPrinter->JobList, DllAllocSplMem, _PrinterJobListCompareRoutine, (PSKIPLIST_FREE_ROUTINE)DllFreeSplMem); @@ -250,6 +281,8 @@ RPC_BINDING_HANDLE hServerBinding = NULL; RPC_WSTR pwszBinding = NULL; RPC_WSTR pwszMachineName = NULL; + + TRACE("CreateJob(%p)\n", pPrinterHandle); // Create a new job. pJob = DllAllocSplMem(sizeof(LOCAL_JOB)); @@ -366,6 +399,8 @@ PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter; PLOCAL_PRINTER_HANDLE pPrinterHandle; + TRACE("LocalAddJob(%p, %lu, %p, %lu, %p)\n", hPrinter, Level, pData, cbBuf, pcbNeeded); + // Check if this is a printer handle. if (pHandle->HandleType != HandleType_Printer) { @@ -426,198 +461,146 @@ } -static DWORD -_LocalGetJobLevel1(PLOCAL_PRINTER_HANDLE pPrinterHandle, PLOCAL_JOB pJob, PBYTE* ppStart, PBYTE* ppEnd, DWORD cbBuf, PDWORD pcbNeeded) -{ - DWORD cbDatatype = (wcslen(pJob->pwszDatatype) + 1) * sizeof(WCHAR); - DWORD cbDocumentName = 0; - DWORD cbMachineName = (wcslen(pJob->pwszMachineName) + 1) * sizeof(WCHAR); - DWORD cbPrinterName = (wcslen(pJob->pPrinter->pwszPrinterName) + 1) * sizeof(WCHAR); +static void +_LocalGetJobLevel1(PLOCAL_JOB pJob, PJOB_INFO_1W* ppJobInfo, PBYTE* ppJobInfoEnd, PDWORD pcbNeeded) +{ + DWORD cbDatatype; + DWORD cbDocumentName = 0; + DWORD cbMachineName; + DWORD cbPrinterName; DWORD cbStatus = 0; DWORD cbUserName = 0; - DWORD dwErrorCode; - JOB_INFO_1W JobInfo1 = { 0 }; - - // Calculate the lengths of the optional values. - if (pJob->pwszDocumentName) - cbDocumentName = (wcslen(pJob->pwszDocumentName) + 1) * sizeof(WCHAR); - - if (pJob->pwszStatus) - cbStatus = (wcslen(pJob->pwszStatus) + 1) * sizeof(WCHAR); - - if (pJob->pwszUserName) - cbUserName = (wcslen(pJob->pwszUserName) + 1) * sizeof(WCHAR); - - // Check if the supplied buffer is large enough. - *pcbNeeded += sizeof(JOB_INFO_1W) + cbDatatype + cbDocumentName + cbMachineName + cbPrinterName + cbStatus + cbUserName; - if (cbBuf < *pcbNeeded) - { - dwErrorCode = ERROR_INSUFFICIENT_BUFFER; - goto Cleanup; - } - - // Put the strings at the end of the buffer. - *ppEnd -= cbDatatype; - JobInfo1.pDatatype = (PWSTR)*ppEnd; - CopyMemory(*ppEnd, pJob->pwszDatatype, cbDatatype); - - *ppEnd -= cbMachineName; - JobInfo1.pMachineName = (PWSTR)*ppEnd; - CopyMemory(*ppEnd, pJob->pwszMachineName, cbMachineName); - - *ppEnd -= cbPrinterName; - JobInfo1.pPrinterName = (PWSTR)*ppEnd; - CopyMemory(*ppEnd, pJob->pPrinter->pwszPrinterName, cbPrinterName); - - // Copy the optional values. - if (cbDocumentName) - { - *ppEnd -= cbDocumentName; - JobInfo1.pDocument = (PWSTR)*ppEnd; - CopyMemory(*ppEnd, pJob->pwszDocumentName, cbDocumentName); - } - - if (cbStatus) - { - *ppEnd -= cbStatus; - JobInfo1.pStatus = (PWSTR)*ppEnd; - CopyMemory(*ppEnd, pJob->pwszStatus, cbStatus); - } - - if (cbUserName) - { - *ppEnd -= cbUserName; - JobInfo1.pUserName = (PWSTR)*ppEnd; - CopyMemory(*ppEnd, pJob->pwszUserName, cbUserName); - } - - // Fill the rest of the structure. - JobInfo1.JobId = pJob->dwJobID; - JobInfo1.Priority = pJob->dwPriority; - JobInfo1.Status = pJob->dwStatus; - JobInfo1.TotalPages = pJob->dwTotalPages; - CopyMemory(&JobInfo1.Submitted, &pJob->stSubmitted, sizeof(SYSTEMTIME)); - - // Finally copy the structure to the output pointer. - CopyMemory(*ppStart, &JobInfo1, sizeof(JOB_INFO_1W)); - *ppStart += sizeof(JOB_INFO_1W); - dwErrorCode = ERROR_SUCCESS; - -Cleanup: - return dwErrorCode; -} - -static DWORD -_LocalGetJobLevel2(PLOCAL_PRINTER_HANDLE pPrinterHandle, PLOCAL_JOB pJob, PBYTE* ppStart, PBYTE* ppEnd, DWORD cbBuf, PDWORD pcbNeeded) -{ - DWORD cbDatatype = (wcslen(pJob->pwszDatatype) + 1) * sizeof(WCHAR); - DWORD cbDevMode = pJob->pDevMode->dmSize + pJob->pDevMode->dmDriverExtra; + PWSTR pwszStrings[6]; + + // Calculate the string lengths. + if (!ppJobInfo) + { + cbDatatype = (wcslen(pJob->pwszDatatype) + 1) * sizeof(WCHAR); + cbMachineName = (wcslen(pJob->pwszMachineName) + 1) * sizeof(WCHAR); + cbPrinterName = (wcslen(pJob->pPrinter->pwszPrinterName) + 1) * sizeof(WCHAR); + + // These values are optional. + if (pJob->pwszDocumentName) + cbDocumentName = (wcslen(pJob->pwszDocumentName) + 1) * sizeof(WCHAR); + + if (pJob->pwszStatus) + cbStatus = (wcslen(pJob->pwszStatus) + 1) * sizeof(WCHAR); + + if (pJob->pwszUserName) + cbUserName = (wcslen(pJob->pwszUserName) + 1) * sizeof(WCHAR); + + *pcbNeeded += sizeof(JOB_INFO_1W) + cbDatatype + cbDocumentName + cbMachineName + cbPrinterName + cbStatus + cbUserName; + return; + } + + // Set the general fields. + (*ppJobInfo)->JobId = pJob->dwJobID; + (*ppJobInfo)->Status = pJob->dwStatus; + (*ppJobInfo)->Priority = pJob->dwPriority; + (*ppJobInfo)->TotalPages = pJob->dwTotalPages; + (*ppJobInfo)->PagesPrinted = pJob->dwPagesPrinted; + CopyMemory(&(*ppJobInfo)->Submitted, &pJob->stSubmitted, sizeof(SYSTEMTIME)); + + // Position in JOB_INFO_1W is the 1-based index of the job in the processing queue. + // Retrieve this through the element index of the job in the Printer's Job List. + if (!LookupElementSkiplist(&pJob->pPrinter->JobList, pJob, &(*ppJobInfo)->Position)) + { + ERR("pJob could not be located in the Printer's Job List!\n"); + return; + } + + // Make the index 1-based. + ++(*ppJobInfo)->Position; + + // Set the pPrinterName field. + pwszStrings[0] = pJob->pPrinter->pwszPrinterName; + + // Set the pMachineName field. + pwszStrings[1] = pJob->pwszMachineName; + + // Set the pUserName field. + pwszStrings[2] = pJob->pwszUserName; + + // Set the pDocument field. + pwszStrings[3] = pJob->pwszDocumentName; + + // Set the pDatatype field. + pwszStrings[4] = pJob->pwszDatatype; + + // Set the pStatus field. + pwszStrings[5] = pJob->pwszStatus; + + // Finally copy the structure and advance to the next one in the output buffer. + *ppJobInfoEnd = PackStrings(pwszStrings, (PBYTE)(*ppJobInfo), dwJobInfo1Offsets, *ppJobInfoEnd); + (*ppJobInfo)++; +} + +static void +_LocalGetJobLevel2(PLOCAL_JOB pJob, PJOB_INFO_2W* ppJobInfo, PBYTE* ppJobInfoEnd, PDWORD pcbNeeded) +{ + DWORD cbDatatype; + DWORD cbDevMode; DWORD cbDocumentName = 0; - DWORD cbDriverName = (wcslen(pJob->pPrinter->pwszPrinterDriver) + 1) * sizeof(WCHAR); - DWORD cbMachineName = (wcslen(pJob->pwszMachineName) + 1) * sizeof(WCHAR); + DWORD cbDriverName; + DWORD cbMachineName; DWORD cbNotifyName = 0; - DWORD cbPrinterName = (wcslen(pJob->pPrinter->pwszPrinterName) + 1) * sizeof(WCHAR); - DWORD cbPrintProcessor = (wcslen(pJob->pPrintProcessor->pwszName) + 1) * sizeof(WCHAR); + DWORD cbPrinterName; + DWORD cbPrintProcessor; DWORD cbPrintProcessorParameters = 0; DWORD cbStatus = 0; DWORD cbUserName = 0; - DWORD dwErrorCode; FILETIME ftNow; FILETIME ftSubmitted; - JOB_INFO_2W JobInfo2 = { 0 }; + PWSTR pwszStrings[10]; ULARGE_INTEGER uliNow; ULARGE_INTEGER uliSubmitted; - // Calculate the lengths of the optional values. - if (pJob->pwszDocumentName) - cbDocumentName = (wcslen(pJob->pwszDocumentName) + 1) * sizeof(WCHAR); - - if (pJob->pwszNotifyName) - cbNotifyName = (wcslen(pJob->pwszNotifyName) + 1) * sizeof(WCHAR); - - if (pJob->pwszPrintProcessorParameters) - cbPrintProcessorParameters = (wcslen(pJob->pwszPrintProcessorParameters) + 1) * sizeof(WCHAR); - - if (pJob->pwszStatus) - cbStatus = (wcslen(pJob->pwszStatus) + 1) * sizeof(WCHAR); - - if (pJob->pwszUserName) - cbUserName = (wcslen(pJob->pwszUserName) + 1) * sizeof(WCHAR); - - // Check if the supplied buffer is large enough. - *pcbNeeded += sizeof(JOB_INFO_2W) + cbDatatype + cbDevMode + cbDocumentName + cbDriverName + cbMachineName + cbNotifyName + cbPrinterName + cbPrintProcessor + cbPrintProcessorParameters + cbStatus + cbUserName; - if (cbBuf < *pcbNeeded) - { - dwErrorCode = ERROR_INSUFFICIENT_BUFFER; - goto Cleanup; - } - - // Put the strings at the end of the buffer. - *ppEnd -= cbDatatype; - JobInfo2.pDatatype = (PWSTR)*ppEnd; - CopyMemory(*ppEnd, pJob->pwszDatatype, cbDatatype); - - *ppEnd -= cbDevMode; - JobInfo2.pDevMode = (PDEVMODEW)*ppEnd; - CopyMemory(*ppEnd, pJob->pDevMode, cbDevMode); - - *ppEnd -= cbDriverName; - JobInfo2.pDriverName = (PWSTR)*ppEnd; - CopyMemory(*ppEnd, pJob->pPrinter->pwszPrinterDriver, cbDriverName); - - *ppEnd -= cbMachineName; - JobInfo2.pMachineName = (PWSTR)*ppEnd; - CopyMemory(*ppEnd, pJob->pwszMachineName, cbMachineName); - - *ppEnd -= cbPrinterName; - JobInfo2.pPrinterName = (PWSTR)*ppEnd; - CopyMemory(*ppEnd, pJob->pPrinter->pwszPrinterName, cbPrinterName); - - *ppEnd -= cbPrintProcessor; - JobInfo2.pPrintProcessor = (PWSTR)*ppEnd; - CopyMemory(*ppEnd, pJob->pPrintProcessor->pwszName, cbPrintProcessor); - - // Copy the optional values. - if (cbDocumentName) - { - *ppEnd -= cbDocumentName; - JobInfo2.pDocument = (PWSTR)*ppEnd; - CopyMemory(*ppEnd, pJob->pwszDocumentName, cbDocumentName); - } - - if (cbNotifyName) - { - *ppEnd -= cbNotifyName; - JobInfo2.pNotifyName = (PWSTR)*ppEnd; - CopyMemory(*ppEnd, pJob->pwszNotifyName, cbNotifyName); - } - - if (cbPrintProcessorParameters) - { - *ppEnd -= cbPrintProcessorParameters; - JobInfo2.pParameters = (PWSTR)*ppEnd; - CopyMemory(*ppEnd, pJob->pwszPrintProcessorParameters, cbPrintProcessorParameters); - } - - if (cbStatus) - { - *ppEnd -= cbStatus; - JobInfo2.pStatus = (PWSTR)*ppEnd; - CopyMemory(*ppEnd, pJob->pwszStatus, cbStatus); - } - - if (cbUserName) - { - *ppEnd -= cbUserName; - JobInfo2.pUserName = (PWSTR)*ppEnd; - CopyMemory(*ppEnd, pJob->pwszUserName, cbUserName); - } + // Calculate the string lengths. + cbDevMode = pJob->pDevMode->dmSize + pJob->pDevMode->dmDriverExtra; + + if (!ppJobInfo) + { + cbDatatype = (wcslen(pJob->pwszDatatype) + 1) * sizeof(WCHAR); + cbDriverName = (wcslen(pJob->pPrinter->pwszPrinterDriver) + 1) * sizeof(WCHAR); + cbMachineName = (wcslen(pJob->pwszMachineName) + 1) * sizeof(WCHAR); + cbPrinterName = (wcslen(pJob->pPrinter->pwszPrinterName) + 1) * sizeof(WCHAR); + cbPrintProcessor = (wcslen(pJob->pPrintProcessor->pwszName) + 1) * sizeof(WCHAR); + + // These values are optional. + if (pJob->pwszDocumentName) + cbDocumentName = (wcslen(pJob->pwszDocumentName) + 1) * sizeof(WCHAR); + + if (pJob->pwszNotifyName) + cbNotifyName = (wcslen(pJob->pwszNotifyName) + 1) * sizeof(WCHAR); + + if (pJob->pwszPrintProcessorParameters) + cbPrintProcessorParameters = (wcslen(pJob->pwszPrintProcessorParameters) + 1) * sizeof(WCHAR); + + if (pJob->pwszStatus) + cbStatus = (wcslen(pJob->pwszStatus) + 1) * sizeof(WCHAR); + + if (pJob->pwszUserName) + cbUserName = (wcslen(pJob->pwszUserName) + 1) * sizeof(WCHAR); + + *pcbNeeded += sizeof(JOB_INFO_2W) + cbDatatype + cbDevMode + cbDocumentName + cbDriverName + cbMachineName + cbNotifyName + cbPrinterName + cbPrintProcessor + cbPrintProcessorParameters + cbStatus + cbUserName; + return; + } + + // Set the general fields. + (*ppJobInfo)->JobId = pJob->dwJobID; + (*ppJobInfo)->Status = pJob->dwStatus; + (*ppJobInfo)->Priority = pJob->dwPriority; + (*ppJobInfo)->StartTime = pJob->dwStartTime; + (*ppJobInfo)->UntilTime = pJob->dwUntilTime; + (*ppJobInfo)->TotalPages = pJob->dwTotalPages; + (*ppJobInfo)->PagesPrinted = pJob->dwPagesPrinted; + CopyMemory(&(*ppJobInfo)->Submitted, &pJob->stSubmitted, sizeof(SYSTEMTIME)); // Time in JOB_INFO_2W is the number of milliseconds elapsed since the job was submitted. Calculate this time. if (!SystemTimeToFileTime(&pJob->stSubmitted, &ftSubmitted)) { ERR("SystemTimeToFileTime failed with error %lu!\n", GetLastError()); - return FALSE; + return; } GetSystemTimeAsFileTime(&ftNow); @@ -625,37 +608,62 @@ uliSubmitted.HighPart = ftSubmitted.dwHighDateTime; uliNow.LowPart = ftNow.dwLowDateTime; uliNow.HighPart = ftNow.dwHighDateTime; - JobInfo2.Time = (DWORD)((uliNow.QuadPart - uliSubmitted.QuadPart) / 10000); + (*ppJobInfo)->Time = (DWORD)((uliNow.QuadPart - uliSubmitted.QuadPart) / 10000); // Position in JOB_INFO_2W is the 1-based index of the job in the processing queue. // Retrieve this through the element index of the job in the Printer's Job List. - if (!LookupElementSkiplist(&pJob->pPrinter->JobList, pJob, &JobInfo2.Position)) - { - dwErrorCode = ERROR_NOT_ENOUGH_MEMORY; + if (!LookupElementSkiplist(&pJob->pPrinter->JobList, pJob, &(*ppJobInfo)->Position)) + { ERR("pJob could not be located in the Printer's Job List!\n"); - goto Cleanup; + return; } // Make the index 1-based. - ++JobInfo2.Position; - - // Fill the rest of the structure. - JobInfo2.JobId = pJob->dwJobID; - JobInfo2.PagesPrinted = pJob->dwPagesPrinted; - JobInfo2.Priority = pJob->dwPriority; - JobInfo2.StartTime = pJob->dwStartTime; - JobInfo2.Status = pJob->dwStatus; - JobInfo2.TotalPages = pJob->dwTotalPages; - JobInfo2.UntilTime = pJob->dwUntilTime; - CopyMemory(&JobInfo2.Submitted, &pJob->stSubmitted, sizeof(SYSTEMTIME)); - - // Finally copy the structure to the output pointer. - CopyMemory(*ppStart, &JobInfo2, sizeof(JOB_INFO_2W)); - *ppStart += sizeof(JOB_INFO_2W); - dwErrorCode = ERROR_SUCCESS; - -Cleanup: - return dwErrorCode; + ++(*ppJobInfo)->Position; + + // FIXME! + FIXME("Setting pSecurityDescriptor and Size to 0 for now!\n"); + (*ppJobInfo)->pSecurityDescriptor = NULL; + (*ppJobInfo)->Size = 0; + + // Set the pDevMode field (and copy the DevMode). + *ppJobInfoEnd -= cbDevMode; + CopyMemory(*ppJobInfoEnd, pJob->pDevMode, cbDevMode); + (*ppJobInfo)->pDevMode = (PDEVMODEW)(*ppJobInfoEnd); + + // Set the pPrinterName field. + pwszStrings[0] = pJob->pPrinter->pwszPrinterName; + + // Set the pMachineName field. + pwszStrings[1] = pJob->pwszMachineName; + + // Set the pUserName field. + pwszStrings[2] = pJob->pwszUserName; + + // Set the pDocument field. + pwszStrings[3] = pJob->pwszDocumentName; + + // Set the pNotifyName field. + pwszStrings[4] = pJob->pwszNotifyName; + + // Set the pDatatype field. + pwszStrings[5] = pJob->pwszDatatype; + + // Set the pPrintProcessor field. + pwszStrings[6] = pJob->pPrintProcessor->pwszName; + + // Set the pParameters field. + pwszStrings[7] = pJob->pwszPrintProcessorParameters; + + // Set the pDriverName field. + pwszStrings[8] = pJob->pPrinter->pwszPrinterDriver; + + // Set the pStatus field. + pwszStrings[9] = pJob->pwszStatus; + + // Finally copy the structure and advance to the next one in the output buffer. + *ppJobInfoEnd = PackStrings(pwszStrings, (PBYTE)(*ppJobInfo), dwJobInfo2Offsets, *ppJobInfoEnd); + (*ppJobInfo)++; } BOOL WINAPI @@ -667,6 +675,8 @@ PLOCAL_JOB pJob; PLOCAL_PRINTER_HANDLE pPrinterHandle; + TRACE("LocalGetJob(%p, %lu, %lu, %p, %lu, %p)\n", hPrinter, JobId, Level, pStart, cbBuf, pcbNeeded); + // Check if this is a printer handle. pHandle = (PLOCAL_HANDLE)hPrinter; if (pHandle->HandleType != HandleType_Printer) @@ -685,16 +695,37 @@ goto Cleanup; } - // Begin counting. + if (Level > 2) + { + // The caller supplied an invalid level for GetJob. + dwErrorCode = ERROR_INVALID_LEVEL; + goto Cleanup; + } + + // Count the required buffer size. *pcbNeeded = 0; - // The function behaves differently for each level. if (Level == 1) - dwErrorCode = _LocalGetJobLevel1(pPrinterHandle, pJob, &pStart, &pEnd, cbBuf, pcbNeeded); + _LocalGetJobLevel1(pJob, NULL, NULL, pcbNeeded); else if (Level == 2) - dwErrorCode = _LocalGetJobLevel2(pPrinterHandle, pJob, &pStart, &pEnd, cbBuf, pcbNeeded); - else - dwErrorCode = ERROR_INVALID_LEVEL; + _LocalGetJobLevel2(pJob, NULL, NULL, pcbNeeded); + + // Check if the supplied buffer is large enough. + if (cbBuf < *pcbNeeded) + { + dwErrorCode = ERROR_INSUFFICIENT_BUFFER; + goto Cleanup; + } + + // Copy over the Job information. + pEnd = &pStart[*pcbNeeded]; + + if (Level == 1) + _LocalGetJobLevel1(pJob, (PJOB_INFO_1W*)&pStart, &pEnd, NULL); + else if (Level == 2) + _LocalGetJobLevel2(pJob, (PJOB_INFO_2W*)&pStart, &pEnd, NULL); + + dwErrorCode = ERROR_SUCCESS; Cleanup: SetLastError(dwErrorCode); @@ -938,6 +969,8 @@ PLOCAL_PRINTER_HANDLE pPrinterHandle; WCHAR wszFullPath[MAX_PATH]; + TRACE("LocalSetJob(%p, %lu, %lu, %p, %lu)\n", hPrinter, JobId, Level, pJobInfo, Command); + // Check if this is a printer handle. pHandle = (PLOCAL_HANDLE)hPrinter; if (pHandle->HandleType != HandleType_Printer) @@ -1012,13 +1045,15 @@ { DWORD dwErrorCode; DWORD i; - PBYTE pEnd = &pStart[cbBuf]; + PBYTE pEnd; PLOCAL_HANDLE pHandle; PLOCAL_JOB pJob; PSKIPLIST_NODE pFirstJobNode; PSKIPLIST_NODE pNode; PLOCAL_PRINTER_HANDLE pPrinterHandle; + TRACE("LocalEnumJobs(%p, %lu, %lu, %lu, %p, %lu, %p, %p)\n", hPrinter, FirstJob, NoJobs, Level, pStart, cbBuf, pcbNeeded, pcReturned); + // Check if this is a printer handle. pHandle = (PLOCAL_HANDLE)hPrinter; if (pHandle->HandleType != HandleType_Printer) @@ -1051,11 +1086,10 @@ { pJob = (PLOCAL_JOB)pNode->Element; - // The function behaves differently for each level. if (Level == 1) - _LocalGetJobLevel1(pPrinterHandle, pJob, NULL, NULL, 0, pcbNeeded); + _LocalGetJobLevel1(pJob, NULL, NULL, pcbNeeded); else if (Level == 2) - _LocalGetJobLevel2(pPrinterHandle, pJob, NULL, NULL, 0, pcbNeeded); + _LocalGetJobLevel2(pJob, NULL, NULL, pcbNeeded); // We stop either when there are no more jobs in the list or when the caller didn't request more, whatever comes first. i++; @@ -1069,26 +1103,19 @@ goto Cleanup; } - // Begin counting again and also empty the given buffer. - *pcbNeeded = 0; - ZeroMemory(pStart, cbBuf); - - // Now call the same functions again to copy the actual data for each job into the buffer. + // Copy over the Job information. i = 0; pNode = pFirstJobNode; + pEnd = &pStart[*pcbNeeded]; while (i < NoJobs && pNode) { pJob = (PLOCAL_JOB)pNode->Element; - // The function behaves differently for each level. if (Level == 1) - dwErrorCode = _LocalGetJobLevel1(pPrinterHandle, pJob, &pStart, &pEnd, cbBuf, pcbNeeded); + _LocalGetJobLevel1(pJob, (PJOB_INFO_1W*)&pStart, &pEnd, NULL); else if (Level == 2) - dwErrorCode = _LocalGetJobLevel2(pPrinterHandle, pJob, &pStart, &pEnd, cbBuf, pcbNeeded); - - if (dwErrorCode != ERROR_SUCCESS) - goto Cleanup; + _LocalGetJobLevel2(pJob, (PJOB_INFO_2W*)&pStart, &pEnd, NULL); // We stop either when there are no more jobs in the list or when the caller didn't request more, whatever comes first. i++; @@ -1113,6 +1140,8 @@ PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter; PLOCAL_PRINTER_HANDLE pPrinterHandle; WCHAR wszFullPath[MAX_PATH]; + + TRACE("LocalScheduleJob(%p, %lu)\n", hPrinter, dwJobID); // Check if this is a printer handle. if (pHandle->HandleType != HandleType_Printer) @@ -1189,6 +1218,8 @@ PSHD_HEADER pShadowFile = NULL; PWSTR pwszPrinterName; PWSTR pwszPrintProcessor; + + TRACE("ReadJobShadowFile(%S)\n", pwszFilePath); // Try to open the file. hFile = CreateFileW(pwszFilePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); @@ -1308,6 +1339,8 @@ HANDLE hSPLFile = INVALID_HANDLE_VALUE; PSHD_HEADER pShadowFile = NULL; + TRACE("WriteJobShadowFile(%S, %p)\n", pwszFilePath, pJob); + // Try to open the SHD file. hSHDFile = CreateFileW(pwszFilePath, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, 0, NULL); if (hSHDFile == INVALID_HANDLE_VALUE) @@ -1441,7 +1474,9 @@ FreeJob(PLOCAL_JOB pJob) { PWSTR pwszSHDFile; - + + TRACE("FreeJob(%p)\n", pJob); + // Remove the Job from both Job Lists. DeleteElementSkiplist(&pJob->pPrinter->JobList, pJob); DeleteElementSkiplist(&GlobalJobList, pJob); Modified: trunk/reactos/win32ss/printing/providers/localspl/main.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/printing/providers…
============================================================================== --- trunk/reactos/win32ss/printing/providers/localspl/main.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/printing/providers/localspl/main.c [iso-8859-1] Wed Jul 5 15:29:13 2017 @@ -245,6 +245,8 @@ BOOL WINAPI InitializePrintProvidor(LPPRINTPROVIDOR pPrintProvidor, DWORD cbPrintProvidor, LPWSTR pFullRegistryPath) { + TRACE("InitializePrintProvidor(%p, %lu, %S)\n", pPrintProvidor, cbPrintProvidor, pFullRegistryPath); + CopyMemory(pPrintProvidor, &_PrintProviderFunctions, min(cbPrintProvidor, sizeof(PRINTPROVIDOR))); SetLastError(ERROR_SUCCESS); Modified: trunk/reactos/win32ss/printing/providers/localspl/monitors.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/printing/providers…
============================================================================== --- trunk/reactos/win32ss/printing/providers/localspl/monitors.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/printing/providers/localspl/monitors.c [iso-8859-1] Wed Jul 5 15:29:13 2017 @@ -10,6 +10,19 @@ // Global Variables LIST_ENTRY PrintMonitorList; +// Local Constants +static DWORD dwMonitorInfo1Offsets[] = { + FIELD_OFFSET(MONITOR_INFO_1W, pName), + MAXDWORD +}; + +static DWORD dwMonitorInfo2Offsets[] = { + FIELD_OFFSET(MONITOR_INFO_2W, pName), + FIELD_OFFSET(MONITOR_INFO_2W, pEnvironment), + FIELD_OFFSET(MONITOR_INFO_2W, pDLLName), + MAXDWORD +}; + PLOCAL_PRINT_MONITOR FindPrintMonitor(PCWSTR pwszName) @@ -17,6 +30,8 @@ PLIST_ENTRY pEntry; PLOCAL_PRINT_MONITOR pPrintMonitor; + TRACE("FindPrintMonitor(%S)\n", pwszName); + if (!pwszName) return NULL; @@ -32,7 +47,7 @@ } BOOL -InitializePrintMonitorList() +InitializePrintMonitorList(void) { const WCHAR wszMonitorsPath[] = L"SYSTEM\\CurrentControlSet\\Control\\Print\\Monitors"; const DWORD cchMonitorsPath = _countof(wszMonitorsPath) - 1; @@ -51,6 +66,8 @@ PLOCAL_PRINT_MONITOR pPrintMonitor = NULL; PWSTR pwszRegistryPath = NULL; + TRACE("InitializePrintMonitorList()\n"); + // Initialize an empty list for our Print Monitors. InitializeListHead(&PrintMonitorList); @@ -236,28 +253,74 @@ return (dwErrorCode == ERROR_SUCCESS); } +static void +_LocalGetMonitorLevel1(PLOCAL_PRINT_MONITOR pPrintMonitor, PMONITOR_INFO_1W* ppMonitorInfo, PBYTE* ppMonitorInfoEnd, PDWORD pcbNeeded) +{ + DWORD cbMonitorName; + PWSTR pwszStrings[1]; + + // Calculate the string lengths. + if (!ppMonitorInfo) + { + cbMonitorName = (wcslen(pPrintMonitor->pwszName) + 1) * sizeof(WCHAR); + + *pcbNeeded += sizeof(MONITOR_INFO_1W) + cbMonitorName; + return; + } + + // Set the pName field. + pwszStrings[0] = pPrintMonitor->pwszName; + + // Copy the structure and advance to the next one in the output buffer. + *ppMonitorInfoEnd = PackStrings(pwszStrings, (PBYTE)(*ppMonitorInfo), dwMonitorInfo1Offsets, *ppMonitorInfoEnd); + (*ppMonitorInfo)++; +} + +static void +_LocalGetMonitorLevel2(PLOCAL_PRINT_MONITOR pPrintMonitor, PMONITOR_INFO_2W* ppMonitorInfo, PBYTE* ppMonitorInfoEnd, PDWORD pcbNeeded) +{ + DWORD cbFileName; + DWORD cbMonitorName; + PWSTR pwszStrings[3]; + + // Calculate the string lengths. + if (!ppMonitorInfo) + { + cbMonitorName = (wcslen(pPrintMonitor->pwszName) + 1) * sizeof(WCHAR); + cbFileName = (wcslen(pPrintMonitor->pwszFileName) + 1) * sizeof(WCHAR); + + *pcbNeeded += sizeof(MONITOR_INFO_2W) + cbMonitorName + cbCurrentEnvironment + cbFileName; + return; + } + + // Set the pName field. + pwszStrings[0] = pPrintMonitor->pwszName; + + // Set the pEnvironment field. + pwszStrings[1] = (PWSTR)wszCurrentEnvironment; + + // Set the pDLLName field. + pwszStrings[2] = pPrintMonitor->pwszFileName; + + // Copy the structure and advance to the next one in the output buffer. + *ppMonitorInfoEnd = PackStrings(pwszStrings, (PBYTE)(*ppMonitorInfo), dwMonitorInfo2Offsets, *ppMonitorInfoEnd); + (*ppMonitorInfo)++; +} + BOOL WINAPI LocalEnumMonitors(PWSTR pName, DWORD Level, PBYTE pMonitors, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned) { - DWORD cbFileName; - DWORD cbMonitorName; DWORD dwErrorCode; - PBYTE pStart; - PBYTE pEnd; + PBYTE pMonitorInfoEnd; PLIST_ENTRY pEntry; PLOCAL_PRINT_MONITOR pPrintMonitor; - MONITOR_INFO_2W MonitorInfo2; // MONITOR_INFO_1W is a subset of MONITOR_INFO_2W, so we can handle both in one function here. + + TRACE("LocalEnumMonitors(%S, %lu, %p, %lu, %p, %p)\n", pName, Level, pMonitors, cbBuf, pcbNeeded, pcReturned); // Sanity checks. if (Level > 2) { dwErrorCode = ERROR_INVALID_LEVEL; - goto Cleanup; - } - - if ((cbBuf && !pMonitors) || !pcbNeeded || !pcReturned) - { - dwErrorCode = ERROR_INVALID_PARAMETER; goto Cleanup; } @@ -270,13 +333,10 @@ { pPrintMonitor = CONTAINING_RECORD(pEntry, LOCAL_PRINT_MONITOR, Entry); - cbMonitorName = (wcslen(pPrintMonitor->pwszName) + 1) * sizeof(WCHAR); - cbFileName = (wcslen(pPrintMonitor->pwszFileName) + 1) * sizeof(WCHAR); - if (Level == 1) - *pcbNeeded += sizeof(MONITOR_INFO_1W) + cbMonitorName; - else - *pcbNeeded += sizeof(MONITOR_INFO_2W) + cbMonitorName + cbCurrentEnvironment + cbFileName; + _LocalGetMonitorLevel1(pPrintMonitor, NULL, NULL, pcbNeeded); + else if (Level == 2) + _LocalGetMonitorLevel2(pPrintMonitor, NULL, NULL, pcbNeeded); } // Check if the supplied buffer is large enough. @@ -286,43 +346,17 @@ goto Cleanup; } - // Put the strings at the end of the buffer. - pStart = pMonitors; - pEnd = &pMonitors[cbBuf]; + // Copy over the Monitor information. + pMonitorInfoEnd = &pMonitors[*pcbNeeded]; for (pEntry = PrintMonitorList.Flink; pEntry != &PrintMonitorList; pEntry = pEntry->Flink) { pPrintMonitor = CONTAINING_RECORD(pEntry, LOCAL_PRINT_MONITOR, Entry); - // Copy the monitor name. - cbMonitorName = (wcslen(pPrintMonitor->pwszName) + 1) * sizeof(WCHAR); - pEnd -= cbMonitorName; - MonitorInfo2.pName = (PWSTR)pEnd; - CopyMemory(pEnd, pPrintMonitor->pwszName, cbMonitorName); - if (Level == 1) - { - // Finally copy the structure. - CopyMemory(pStart, &MonitorInfo2, sizeof(MONITOR_INFO_1W)); - pStart += sizeof(MONITOR_INFO_1W); - } - else - { - // Copy the environment. - pEnd -= cbCurrentEnvironment; - MonitorInfo2.pEnvironment = (PWSTR)pEnd; - CopyMemory(pEnd, wszCurrentEnvironment, cbCurrentEnvironment); - - // Copy the file name. - cbFileName = (wcslen(pPrintMonitor->pwszFileName) + 1) * sizeof(WCHAR); - pEnd -= cbFileName; - MonitorInfo2.pDLLName = (PWSTR)pEnd; - CopyMemory(pEnd, pPrintMonitor->pwszFileName, cbFileName); - - // Finally copy the structure. - CopyMemory(pStart, &MonitorInfo2, sizeof(MONITOR_INFO_2W)); - pStart += sizeof(MONITOR_INFO_2W); - } + _LocalGetMonitorLevel1(pPrintMonitor, (PMONITOR_INFO_1W*)&pMonitors, &pMonitorInfoEnd, NULL); + else if (Level == 2) + _LocalGetMonitorLevel2(pPrintMonitor, (PMONITOR_INFO_2W*)&pMonitors, &pMonitorInfoEnd, NULL); (*pcReturned)++; } Modified: trunk/reactos/win32ss/printing/providers/localspl/ports.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/printing/providers…
============================================================================== --- trunk/reactos/win32ss/printing/providers/localspl/ports.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/printing/providers/localspl/ports.c [iso-8859-1] Wed Jul 5 15:29:13 2017 @@ -17,6 +17,8 @@ PLIST_ENTRY pEntry; PLOCAL_PORT pPort; + TRACE("FindPort(%S)\n", pwszName); + if (!pwszName) return NULL; @@ -32,7 +34,7 @@ } BOOL -InitializePortList() +InitializePortList(void) { BOOL bReturnValue; DWORD cbNeeded; @@ -45,6 +47,8 @@ PLIST_ENTRY pEntry; PPORT_INFO_1W p; PPORT_INFO_1W pPortInfo1 = NULL; + + TRACE("InitializePortList()\n"); // Initialize an empty list for our Ports. InitializeListHead(&_PortList); @@ -136,7 +140,7 @@ BOOL WINAPI LocalEnumPorts(PWSTR pName, DWORD Level, PBYTE pPorts, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned) { - BOOL bReturnValue; + BOOL bReturnValue = TRUE; DWORD cbCallBuffer; DWORD cbNeeded; DWORD dwReturned; @@ -144,12 +148,7 @@ PLOCAL_PRINT_MONITOR pPrintMonitor; PLIST_ENTRY pEntry; - // Sanity checks. - if ((cbBuf && !pPorts) || !pcbNeeded || !pcReturned) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } + TRACE("LocalEnumPorts(%S, %lu, %p, %lu, %p, %p)\n", pName, Level, pPorts, cbBuf, pcbNeeded, pcReturned); // Begin counting. *pcbNeeded = 0; Modified: trunk/reactos/win32ss/printing/providers/localspl/precomp.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/printing/providers…
============================================================================== --- trunk/reactos/win32ss/printing/providers/localspl/precomp.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/printing/providers/localspl/precomp.h [iso-8859-1] Wed Jul 5 15:29:13 2017 @@ -273,12 +273,12 @@ // monitors.c extern LIST_ENTRY PrintMonitorList; PLOCAL_PRINT_MONITOR FindPrintMonitor(PCWSTR pwszName); -BOOL InitializePrintMonitorList(); +BOOL InitializePrintMonitorList(void); BOOL WINAPI LocalEnumMonitors(PWSTR pName, DWORD Level, PBYTE pMonitors, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned); // ports.c PLOCAL_PORT FindPort(PCWSTR pwszName); -BOOL InitializePortList(); +BOOL InitializePortList(void); BOOL WINAPI LocalEnumPorts(PWSTR pName, DWORD Level, PBYTE pPorts, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned); // printerdata.c @@ -289,7 +289,7 @@ // printers.c extern SKIPLIST PrinterList; -BOOL InitializePrinterList(); +BOOL InitializePrinterList(void); BOOL WINAPI LocalEnumPrinters(DWORD Flags, LPWSTR Name, DWORD Level, LPBYTE pPrinterEnum, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned); BOOL WINAPI LocalGetPrinter(HANDLE hPrinter, DWORD Level, LPBYTE pPrinter, DWORD cbBuf, LPDWORD pcbNeeded); BOOL WINAPI LocalOpenPrinter(PWSTR lpPrinterName, HANDLE* phPrinter, PPRINTER_DEFAULTSW pDefault); @@ -307,7 +307,7 @@ // printprocessors.c BOOL FindDatatype(const PLOCAL_PRINT_PROCESSOR pPrintProcessor, PCWSTR pwszDatatype); PLOCAL_PRINT_PROCESSOR FindPrintProcessor(PCWSTR pwszName); -BOOL InitializePrintProcessorList(); +BOOL InitializePrintProcessorList(void); BOOL WINAPI LocalEnumPrintProcessorDatatypes(LPWSTR pName, LPWSTR pPrintProcessorName, DWORD Level, LPBYTE pDatatypes, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned); BOOL WINAPI LocalEnumPrintProcessors(LPWSTR pName, LPWSTR pEnvironment, DWORD Level, LPBYTE pPrintProcessorInfo, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned); BOOL WINAPI LocalGetPrintProcessorDirectory(LPWSTR pName, LPWSTR pEnvironment, DWORD Level, LPBYTE pPrintProcessorInfo, DWORD cbBuf, LPDWORD pcbNeeded); Modified: trunk/reactos/win32ss/printing/providers/localspl/printerdata.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/printing/providers…
============================================================================== --- trunk/reactos/win32ss/printing/providers/localspl/printerdata.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/printing/providers/localspl/printerdata.c [iso-8859-1] Wed Jul 5 15:29:13 2017 @@ -10,6 +10,8 @@ DWORD WINAPI LocalGetPrinterData(HANDLE hPrinter, PWSTR pValueName, PDWORD pType, PBYTE pData, DWORD nSize, PDWORD pcbNeeded) { + TRACE("LocalGetPrinterData(%p, %S, %p, %p, %lu, %p)\n", hPrinter, pValueName, pType, pData, nSize, pcbNeeded); + // The ReactOS Printing Stack forwards all GetPrinterData calls to GetPrinterDataEx as soon as possible. // This function may only be called if localspl.dll is used together with Windows Printing Stack components. WARN("This function should never be called!\n"); @@ -316,6 +318,8 @@ DWORD dwTemp; PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter; + TRACE("LocalGetPrinterDataEx(%p, %S, %S, %p, %p, %lu, %p)\n", hPrinter, pKeyName, pValueName, pType, pData, nSize, pcbNeeded); + // Even if GetPrinterDataExW in winspool ensures that the RPC function is never called without a valid pointer for pType, // it's officially optional. Windows' fpGetPrinterDataEx also works with NULL for pType! // Ensure here that it is always set to simplify the code later. @@ -356,6 +360,8 @@ DWORD WINAPI LocalSetPrinterData(HANDLE hPrinter, PWSTR pValueName, DWORD Type, PBYTE pData, DWORD cbData) { + TRACE("LocalSetPrinterData(%p, %S, %lu, %p, %lu)\n", hPrinter, pValueName, Type, pData, cbData); + // The ReactOS Printing Stack forwards all SetPrinterData calls to SetPrinterDataEx as soon as possible. // This function may only be called if localspl.dll is used together with Windows Printing Stack components. WARN("This function should never be called!\n"); @@ -446,6 +452,8 @@ DWORD dwErrorCode; PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter; + TRACE("LocalSetPrinterDataEx(%p, %S, %S, %lu, %p, %lu)\n", hPrinter, pKeyName, pValueName, Type, pData, cbData); + if (!pHandle) { dwErrorCode = ERROR_INVALID_HANDLE; Modified: trunk/reactos/win32ss/printing/providers/localspl/printers.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/printing/providers…
============================================================================== --- trunk/reactos/win32ss/printing/providers/localspl/printers.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/printing/providers/localspl/printers.c [iso-8859-1] Wed Jul 5 15:29:13 2017 @@ -118,6 +118,8 @@ PWSTR pwszPort = NULL; PWSTR pwszPrintProcessor = NULL; WCHAR wszPrinterName[MAX_PRINTER_NAME + 1]; + + TRACE("InitializePrinterList()\n"); // Initialize an empty list for our printers. InitializeSkiplist(&PrinterList, DllAllocSplMem, _PrinterListCompareRoutine, (PSKIPLIST_FREE_ROUTINE)DllFreeSplMem); @@ -864,12 +866,13 @@ { DWORD cchComputerName = 0; DWORD dwErrorCode; - DWORD i; PBYTE pPrinterInfoEnd; PSKIPLIST_NODE pNode; WCHAR wszComputerName[2 + MAX_COMPUTERNAME_LENGTH + 1 + 1] = { 0 }; PLOCAL_PRINTER pPrinter; + TRACE("LocalEnumPrinters(%lu, %S, %lu, %p, %lu, %p, %p)\n", Flags, Name, Level, pPrinterEnum, cbBuf, pcbNeeded, pcReturned); + // Do no sanity checks or assertions for pcbNeeded and pcReturned here. // This is verified and required by localspl_apitest! @@ -916,7 +919,6 @@ goto Cleanup; // Count the required buffer size and the number of printers. - i = 0; for (pNode = PrinterList.Head.Next[0]; pNode; pNode = pNode->Next[0]) { pPrinter = (PLOCAL_PRINTER)pNode->Element; @@ -929,7 +931,6 @@ } pfnGetPrinterLevels[Level](pPrinter, NULL, NULL, pcbNeeded, cchComputerName, wszComputerName); - i++; } // Check if the supplied buffer is large enough. @@ -951,9 +952,9 @@ continue; pfnGetPrinterLevels[Level](pPrinter, &pPrinterEnum, &pPrinterInfoEnd, NULL, cchComputerName, wszComputerName); - } - - *pcReturned = i; + (*pcReturned)++; + } + dwErrorCode = ERROR_SUCCESS; Cleanup: @@ -969,6 +970,8 @@ PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter; PLOCAL_PRINTER_HANDLE pPrinterHandle; + TRACE("LocalGetPrinter(%p, %lu, %p, %lu, %p)\n", hPrinter, Level, pPrinter, cbBuf, pcbNeeded); + // Sanity checks. if (!pHandle) { @@ -993,6 +996,7 @@ } // Count the required buffer size. + *pcbNeeded = 0; pfnGetPrinterLevels[Level](pPrinterHandle->pPrinter, NULL, NULL, pcbNeeded, 0, NULL); // Check if the supplied buffer is large enough. @@ -1363,6 +1367,8 @@ PWSTR pwszSecondParameter; WCHAR wszComputerName[MAX_COMPUTERNAME_LENGTH + 1]; + TRACE("LocalOpenPrinter(%S, %p, %p)\n", lpPrinterName, phPrinter, pDefault); + ASSERT(phPrinter); *phPrinter = NULL; @@ -1493,6 +1499,8 @@ PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter; PLOCAL_PORT_HANDLE pPortHandle; PLOCAL_PRINTER_HANDLE pPrinterHandle; + + TRACE("LocalReadPrinter(%p, %p, %lu, %p)\n", hPrinter, pBuf, cbBuf, pNoBytesRead); // Sanity checks. if (!pHandle) @@ -1568,6 +1576,8 @@ PLOCAL_PORT_HANDLE pPortHandle; PLOCAL_PRINTER_HANDLE pPrinterHandle; + TRACE("LocalStartDocPrinter(%p, %lu, %p)\n", hPrinter, Level, pDocInfo); + // Sanity checks. if (!pHandle) { @@ -1678,6 +1688,8 @@ PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter; PLOCAL_PRINTER_HANDLE pPrinterHandle; + TRACE("LocalStartPagePrinter(%p)\n", hPrinter); + // Sanity checks. if (!pHandle || pHandle->HandleType != HandleType_Printer) { @@ -1712,6 +1724,8 @@ PLOCAL_PORT_HANDLE pPortHandle; PLOCAL_PRINTER_HANDLE pPrinterHandle; + TRACE("LocalWritePrinter(%p, %p, %lu, %p)\n", hPrinter, pBuf, cbBuf, pcWritten); + // Sanity checks. if (!pHandle) { @@ -1783,6 +1797,8 @@ DWORD dwErrorCode; PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter; + TRACE("LocalEndPagePrinter(%p)\n", hPrinter); + // Sanity checks. if (!pHandle || pHandle->HandleType != HandleType_Printer) { @@ -1807,6 +1823,8 @@ PLOCAL_PORT_HANDLE pPortHandle; PLOCAL_PRINTER_HANDLE pPrinterHandle; + TRACE("LocalEndDocPrinter(%p)\n", hPrinter); + // Sanity checks. if (!pHandle) { @@ -1902,6 +1920,8 @@ { PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter; + TRACE("LocalClosePrinter(%p)\n", hPrinter); + if (!pHandle) { SetLastError(ERROR_INVALID_HANDLE); Modified: trunk/reactos/win32ss/printing/providers/localspl/printingthread.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/printing/providers…
============================================================================== --- trunk/reactos/win32ss/printing/providers/localspl/printingthread.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/printing/providers/localspl/printingthread.c [iso-8859-1] Wed Jul 5 15:29:13 2017 @@ -24,6 +24,8 @@ PWSTR pwszPrinterAndJob = NULL; PWSTR pwszPrinterPort = NULL; PWSTR pwszSPLFile = NULL; + + TRACE("PrintingThreadProc(%p)\n", pJob); // Prepare the pPrinterName parameter. // This is the string for LocalOpenPrinter to open a port (e.g. "LPT1:, Port"). Modified: trunk/reactos/win32ss/printing/providers/localspl/printprocessors.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/printing/providers…
============================================================================== --- trunk/reactos/win32ss/printing/providers/localspl/printprocessors.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/printing/providers/localspl/printprocessors.c [iso-8859-1] Wed Jul 5 15:29:13 2017 @@ -82,6 +82,8 @@ DWORD i; PDATATYPES_INFO_1W pCurrentDatatype = pPrintProcessor->pDatatypesInfo1; + TRACE("FindDatatype(%p, %S)\n", pPrintProcessor, pwszDatatype); + if (!pwszDatatype) return FALSE; @@ -102,6 +104,8 @@ PLIST_ENTRY pEntry; PLOCAL_PRINT_PROCESSOR pPrintProcessor; + TRACE("FindPrintProcessor(%S)\n", pwszName); + if (!pwszName) return NULL; @@ -122,7 +126,7 @@ * Initializes a singly linked list of locally available Print Processors. */ BOOL -InitializePrintProcessorList() +InitializePrintProcessorList(void) { DWORD cbDatatypes; DWORD cbFileName; @@ -140,6 +144,8 @@ WCHAR wszFileName[MAX_PATH]; WCHAR wszPrintProcessorPath[MAX_PATH]; + TRACE("InitializePrintProcessorList()\n"); + // Initialize an empty list for our Print Processors. InitializeListHead(&_PrintProcessorList); @@ -397,6 +403,8 @@ { DWORD dwErrorCode; PLOCAL_PRINT_PROCESSOR pPrintProcessor; + + TRACE("LocalEnumPrintProcessorDatatypes(%S, %S, %lu, %p, %lu, %p, %p)\n", pName, pPrintProcessorName, Level, pDatatypes, cbBuf, pcbNeeded, pcReturned); // Sanity checks if (Level != 1) @@ -474,6 +482,8 @@ PRINTPROCESSOR_INFO_1W PrintProcessorInfo1; PWSTR pwszTemp = NULL; + TRACE("LocalEnumPrintProcessors(%S, %S, %lu, %p, %lu, %p, %p)\n", pName, pEnvironment, Level, pPrintProcessorInfo, cbBuf, pcbNeeded, pcReturned); + // Sanity checks if (Level != 1) { @@ -630,6 +640,8 @@ HKEY hKey = NULL; PWSTR pwszDirectory = (PWSTR)pPrintProcessorInfo; + TRACE("LocalGetPrintProcessorDirectory(%S, %S, %lu, %p, %lu, %p)\n", pName, pEnvironment, Level, pPrintProcessorInfo, cbBuf, pcbNeeded); + // Verify pEnvironment and open its registry key. dwErrorCode = _OpenEnvironment(pEnvironment, &hKey); if (dwErrorCode != ERROR_SUCCESS)
7 years, 5 months
1
0
0
0
[pschweitzer] 75286: [RXCE] - Implement RxFinalizeConnection(), RxOrphanSrvOpens() - Stub RxOrphanSrvOpensForThisFcb() [RDBSS] - Fix a bug in RxCommonDevFCBClose() where prefix table wasn't acquire...
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Wed Jul 5 06:11:10 2017 New Revision: 75286 URL:
http://svn.reactos.org/svn/reactos?rev=75286&view=rev
Log: [RXCE] - Implement RxFinalizeConnection(), RxOrphanSrvOpens() - Stub RxOrphanSrvOpensForThisFcb() [RDBSS] - Fix a bug in RxCommonDevFCBClose() where prefix table wasn't acquire exclusively; this was problematic due to potential prefix table removal on dereference - Stub RxCancelNotifyChangeDirectoryRequestsForVNetRoot() This commit basically allows you to delete a NFS share you would have made use of in ReactOS. Like net use z: \\share\path can be deleted through net use /delete z: Note that if you access the share using cmd tools (dir, copy, more, and so on), dismount will work. If you attempt to access with Explorer, then, handles will be kept open and dismount will fail. CORE-8204 CORE-11327 Modified: trunk/reactos/sdk/include/ddk/fcb.h trunk/reactos/sdk/include/ddk/mrxfcb.h trunk/reactos/sdk/include/ddk/rxcontx.h trunk/reactos/sdk/include/ddk/rxprocs.h trunk/reactos/sdk/lib/drivers/rdbsslib/rdbss.c trunk/reactos/sdk/lib/drivers/rxce/rxce.c Modified: trunk/reactos/sdk/include/ddk/fcb.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/ddk/fcb.h?rev=…
============================================================================== --- trunk/reactos/sdk/include/ddk/fcb.h [iso-8859-1] (original) +++ trunk/reactos/sdk/include/ddk/fcb.h [iso-8859-1] Wed Jul 5 06:11:10 2017 @@ -619,18 +619,18 @@ _In_ BOOLEAN ForceFinalize); #ifdef __REACTOS__ -#define FILL_IN_FCB(Fcb, a, nl, ct, lat, lwt, lct, as, fs, vdl) \ - (Fcb)->Attributes = a; \ - (Fcb)->NumberOfLinks = nl; \ - (Fcb)->CreationTime.QuadPart = ct; \ - (Fcb)->LastAccessTime.QuadPart = lat; \ - (Fcb)->LastWriteTime.QuadPart = lwt; \ - (Fcb)->LastChangeTime.QuadPart = lct; \ - (Fcb)->ActualAllocationLength = as; \ - (Fcb)->Header.AllocationSize.QuadPart = as; \ - (Fcb)->Header.FileSize.QuadPart = fs; \ - (Fcb)->Header.ValidDataLength.QuadPart = vdl; \ - (Fcb)->FcbState |= FCB_STATE_TIME_AND_SIZE_ALREADY_SET +#define FILL_IN_FCB(Fcb, a, nl, ct, lat, lwt, lct, as, fs, vdl) \ + (Fcb)->Attributes = a; \ + (Fcb)->NumberOfLinks = nl; \ + (Fcb)->CreationTime.QuadPart = ct; \ + (Fcb)->LastAccessTime.QuadPart = lat; \ + (Fcb)->LastWriteTime.QuadPart = lwt; \ + (Fcb)->LastChangeTime.QuadPart = lct; \ + (Fcb)->ActualAllocationLength = as; \ + (Fcb)->Header.AllocationSize.QuadPart = as; \ + (Fcb)->Header.FileSize.QuadPart = fs; \ + (Fcb)->Header.ValidDataLength.QuadPart = vdl; \ + SetFlag((Fcb)->FcbState, FCB_STATE_TIME_AND_SIZE_ALREADY_SET) #define TRACKER_ACQUIRE_FCB 0x61616161 #define TRACKER_RELEASE_FCB_NO_BUFF_PENDING 0x72727272 Modified: trunk/reactos/sdk/include/ddk/mrxfcb.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/ddk/mrxfcb.h?r…
============================================================================== --- trunk/reactos/sdk/include/ddk/mrxfcb.h [iso-8859-1] (original) +++ trunk/reactos/sdk/include/ddk/mrxfcb.h [iso-8859-1] Wed Jul 5 06:11:10 2017 @@ -31,6 +31,7 @@ #define NET_ROOT_PIPE ((UCHAR)1) #define NET_ROOT_PRINT ((UCHAR)3) #define NET_ROOT_WILD ((UCHAR)4) +#define NET_ROOT_MAILSLOT ((UCHAR)5) typedef UCHAR NET_ROOT_TYPE, *PNET_ROOT_TYPE; Modified: trunk/reactos/sdk/include/ddk/rxcontx.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/ddk/rxcontx.h?…
============================================================================== --- trunk/reactos/sdk/include/ddk/rxcontx.h [iso-8859-1] (original) +++ trunk/reactos/sdk/include/ddk/rxcontx.h [iso-8859-1] Wed Jul 5 06:11:10 2017 @@ -435,6 +435,11 @@ ExReleaseFastMutex(Mutex); \ } +NTSTATUS +RxCancelNotifyChangeDirectoryRequestsForVNetRoot( + PV_NET_ROOT VNetRoot, + BOOLEAN ForceFilesClosed); + VOID RxCancelNotifyChangeDirectoryRequestsForFobx( PFOBX Fobx Modified: trunk/reactos/sdk/include/ddk/rxprocs.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/ddk/rxprocs.h?…
============================================================================== --- trunk/reactos/sdk/include/ddk/rxprocs.h [iso-8859-1] (original) +++ trunk/reactos/sdk/include/ddk/rxprocs.h [iso-8859-1] Wed Jul 5 06:11:10 2017 @@ -693,6 +693,12 @@ RxOrphanThisFcb( _In_ PFCB Fcb); +VOID +RxOrphanSrvOpensForThisFcb( + _In_ PFCB Fcb, + _In_ PV_NET_ROOT ThisVNetRoot, + _In_ BOOLEAN OrphanAll); + #define RxEqualConnectionId(C1, C2) RtlEqualMemory(C1, C2, sizeof(RX_CONNECTION_ID)) NTSTATUS Modified: trunk/reactos/sdk/lib/drivers/rdbsslib/rdbss.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/drivers/rdbsslib/r…
============================================================================== --- trunk/reactos/sdk/lib/drivers/rdbsslib/rdbss.c [iso-8859-1] (original) +++ trunk/reactos/sdk/lib/drivers/rdbsslib/rdbss.c [iso-8859-1] Wed Jul 5 06:11:10 2017 @@ -792,6 +792,15 @@ UNIMPLEMENTED; } +NTSTATUS +RxCancelNotifyChangeDirectoryRequestsForVNetRoot( + PV_NET_ROOT VNetRoot, + BOOLEAN ForceFilesClosed) +{ + UNIMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; +} + VOID NTAPI RxCancelRoutine( @@ -2066,7 +2075,7 @@ /* Our FOBX if set, has to be a VNetRoot */ if (NetRoot != NULL) { - RxAcquirePrefixTableLockShared(Context->RxDeviceObject->pRxNetNameTable, TRUE); + RxAcquirePrefixTableLockExclusive(Context->RxDeviceObject->pRxNetNameTable, TRUE); if (NetRoot->NodeTypeCode == RDBSS_NTC_V_NETROOT) { --NetRoot->NumberOfOpens; @@ -3787,17 +3796,6 @@ } NTSTATUS -NTAPI -RxFinalizeConnection( - IN OUT PNET_ROOT NetRoot, - IN OUT PV_NET_ROOT VNetRoot OPTIONAL, - IN LOGICAL ForceFilesClosed) -{ - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; -} - -NTSTATUS RxFindOrCreateFcb( PRX_CONTEXT RxContext, PUNICODE_STRING NetRootName) Modified: trunk/reactos/sdk/lib/drivers/rxce/rxce.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/drivers/rxce/rxce.…
============================================================================== --- trunk/reactos/sdk/lib/drivers/rxce/rxce.c [iso-8859-1] (original) +++ trunk/reactos/sdk/lib/drivers/rxce/rxce.c [iso-8859-1] Wed Jul 5 06:11:10 2017 @@ -2438,6 +2438,182 @@ /* * @implemented */ +NTSTATUS +NTAPI +RxFinalizeConnection( + IN OUT PNET_ROOT NetRoot, + IN OUT PV_NET_ROOT VNetRoot OPTIONAL, + IN LOGICAL ForceFilesClosed) +{ + NTSTATUS Status; + PRX_PREFIX_TABLE PrefixTable; + ULONG UncleanAny, UncleanDir; + LONG FilesOpen, AdditionalRef; + BOOLEAN PrefixLocked, FcbTableLocked, ForceClose; + + PAGED_CODE(); + + ASSERT(NodeType(NetRoot) == RDBSS_NTC_NETROOT); + + /* Get a BOOLEAN out of LOGICAL + * -1 is like FALSE but also drops extra V_NET_ROOT reference in case of failure + */ + ForceClose = (ForceFilesClosed == TRUE ? TRUE : FALSE); + + /* First, delete any notification change */ + Status = RxCancelNotifyChangeDirectoryRequestsForVNetRoot(VNetRoot, ForceClose); + /* If it failed, continue if forced */ + if (Status != STATUS_SUCCESS && !ForceFilesClosed) + { + return Status; + } + /* Reset status, in case notification deletion failed */ + Status = STATUS_SUCCESS; + + PrefixTable = NetRoot->pSrvCall->RxDeviceObject->pRxNetNameTable; + + PrefixLocked = FALSE; + FcbTableLocked = FALSE; + FilesOpen = 0; + AdditionalRef = 0; + UncleanAny = 0; + UncleanDir = 0; + _SEH2_TRY + { + RxAcquirePrefixTableLockExclusive(PrefixTable, TRUE); + PrefixLocked = TRUE; + + RxReferenceNetRoot(NetRoot); + + RxAcquireFcbTableLockExclusive(&NetRoot->FcbTable, TRUE); + FcbTableLocked = TRUE; + + /* If our V_NET_ROOT wasn't finalized yet, proceed! */ + if (!VNetRoot->ConnectionFinalizationDone) + { + USHORT Bucket; + PRX_FCB_TABLE FcbTable; + + DPRINT("Finalizing connection %p: %wZ\n", NetRoot, &NetRoot->PrefixEntry.Prefix); + + /* We'll browse all its associated FCB to check whether they're open/orphaned */ + FcbTable = &NetRoot->FcbTable; + for (Bucket = 0; Bucket < FcbTable->NumberOfBuckets; ++Bucket) + { + PLIST_ENTRY BucketList, Entry; + + BucketList = &FcbTable->HashBuckets[Bucket]; + Entry = BucketList->Flink; + while (Entry != BucketList) + { + PFCB Fcb; + + Fcb = CONTAINING_RECORD(Entry, FCB, FcbTableEntry.HashLinks); + Entry = Entry->Flink; + + /* FCB for this connection, go ahead */ + if (Fcb->VNetRoot == VNetRoot) + { + /* It's still open, and no force? Fail and keep track */ + if (Fcb->UncleanCount > 0 && !ForceClose) + { + Status = STATUS_CONNECTION_IN_USE; + if (NodeType(Fcb) == RDBSS_NTC_STORAGE_TYPE_DIRECTORY) + { + ++UncleanDir; + } + else + { + ++UncleanAny; + } + } + else + { + /* Else, force purge */ + ASSERT(NodeTypeIsFcb(Fcb)); + + Status = RxAcquireExclusiveFcb(NULL, Fcb); + ASSERT(Status == STATUS_SUCCESS); + + ClearFlag(Fcb->FcbState, FCB_STATE_COLLAPSING_ENABLED); + + RxScavengeRelatedFobxs(Fcb); + RxPurgeFcb(Fcb); + + /* We don't need to release FCB lock, FCB finalize will take care of it */ + } + } + } + } + + /* No files left, our V_NET_ROOT is finalized */ + if (VNetRoot->NumberOfFobxs == 0) + { + VNetRoot->ConnectionFinalizationDone = TRUE; + } + } + + /* Keep Number of open files and track of the extra reference */ + FilesOpen = VNetRoot->NumberOfFobxs; + AdditionalRef = VNetRoot->AdditionalReferenceForDeleteFsctlTaken; + /* If force close, caller doesn't want to keep connection alive + * and wants it totally close, so drop the V_NET_ROOT too + */ + if (ForceClose) + { + RxFinalizeVNetRoot(VNetRoot, FALSE, TRUE); + } + } + _SEH2_FINALLY + { + /* Release what was acquired */ + if (FcbTableLocked) + { + RxReleaseFcbTableLock(&NetRoot->FcbTable); + } + + /* If close is forced, only fix status if there are open files */ + if (ForceClose) + { + if (Status != STATUS_SUCCESS && UncleanAny != 0) + { + Status = STATUS_FILES_OPEN; + } + } + /* Else, fix status and fail closing if there are open files */ + else + { + if ((Status != STATUS_SUCCESS && UncleanAny != 0) || FilesOpen > 0) + { + Status = STATUS_FILES_OPEN; + } + } + + DPRINT("UncleanAny: %ld, UncleanDir: %ld, FilesOpen: %ld\n", UncleanAny, UncleanDir, FilesOpen); + + /* If we're are asked to remove the extra ref, or if closing was a success, do it; + * only if it was still referenced! + */ + if ((ForceFilesClosed == 0xFF || Status == STATUS_SUCCESS) && AdditionalRef != 0) + { + VNetRoot->AdditionalReferenceForDeleteFsctlTaken = 0; + RxDereferenceVNetRoot(VNetRoot, LHS_ExclusiveLockHeld); + } + + if (PrefixLocked) + { + RxDereferenceNetRoot(NetRoot, LHS_ExclusiveLockHeld); + RxReleasePrefixTableLock(PrefixTable); + } + } + _SEH2_END; + + return Status; +} + +/* + * @implemented + */ VOID RxFinalizeFcbTable( IN OUT PRX_FCB_TABLE FcbTable) @@ -5434,6 +5610,67 @@ RxOrphanSrvOpens( IN PV_NET_ROOT ThisVNetRoot) { + PFCB Fcb; + USHORT Bucket; + PNET_ROOT NetRoot; + PRX_FCB_TABLE FcbTable; + PRX_PREFIX_TABLE PrefixTable; + + PAGED_CODE(); + + /* Mailslot won't have any SRV_OPEN (to orphan) */ + NetRoot = (PNET_ROOT)ThisVNetRoot->pNetRoot; + if (NetRoot->Type == NET_ROOT_MAILSLOT) + { + return; + } + + PrefixTable = NetRoot->pSrvCall->RxDeviceObject->pRxNetNameTable; + ASSERT(RxIsPrefixTableLockExclusive(PrefixTable)); + + FcbTable = &NetRoot->FcbTable; + RxAcquireFcbTableLockExclusive(FcbTable, TRUE); + + _SEH2_TRY + { + /* Now, we'll browse all the FCBs attached, and orphan related SRV_OPENs */ + for (Bucket = 0; Bucket < FcbTable->NumberOfBuckets; ++Bucket) + { + PLIST_ENTRY BucketList, Entry; + + BucketList = &FcbTable->HashBuckets[Bucket]; + Entry = BucketList->Flink; + while (Entry != BucketList) + { + Fcb = CONTAINING_RECORD(Entry, FCB, FcbTableEntry.HashLinks); + Entry = Entry->Flink; + + ASSERT(NodeTypeIsFcb(Fcb)); + RxOrphanSrvOpensForThisFcb(Fcb, ThisVNetRoot, FALSE); + } + } + + /* Of course, don't forget about NULL-entry */ + if (FcbTable->TableEntryForNull != NULL) + { + Fcb = CONTAINING_RECORD(FcbTable->TableEntryForNull, FCB, FcbTableEntry.HashLinks); + ASSERT(NodeTypeIsFcb(Fcb)); + RxOrphanSrvOpensForThisFcb(Fcb, ThisVNetRoot, FALSE); + } + } + _SEH2_FINALLY + { + RxReleaseFcbTableLock(FcbTable); + } + _SEH2_END; +} + +VOID +RxOrphanSrvOpensForThisFcb( + IN PFCB Fcb, + IN PV_NET_ROOT ThisVNetRoot, + IN BOOLEAN OrphanAll) +{ UNIMPLEMENTED; }
7 years, 5 months
1
0
0
0
[pschweitzer] 75285: [MPR] Import Wine commit: - 26192671700360859cd8a0133dabcd96ec1a786b, Implement WNetConnectionDialog(). CORE-13516
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Wed Jul 5 05:40:01 2017 New Revision: 75285 URL:
http://svn.reactos.org/svn/reactos?rev=75285&view=rev
Log: [MPR] Import Wine commit: - 26192671700360859cd8a0133dabcd96ec1a786b, Implement WNetConnectionDialog(). CORE-13516 Modified: trunk/reactos/dll/win32/mpr/wnet.c Modified: trunk/reactos/dll/win32/mpr/wnet.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/mpr/wnet.c?rev=7…
============================================================================== --- trunk/reactos/dll/win32/mpr/wnet.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/mpr/wnet.c [iso-8859-1] Wed Jul 5 05:40:01 2017 @@ -2669,10 +2669,18 @@ */ DWORD WINAPI WNetConnectionDialog( HWND hwnd, DWORD dwType ) { - FIXME( "(%p, %08X): stub\n", hwnd, dwType ); - - SetLastError(WN_NO_NETWORK); - return WN_NO_NETWORK; + CONNECTDLGSTRUCTW conn_dlg; + NETRESOURCEW net_res; + + ZeroMemory(&conn_dlg, sizeof(conn_dlg)); + ZeroMemory(&net_res, sizeof(net_res)); + + conn_dlg.cbStructure = sizeof(conn_dlg); + conn_dlg.lpConnRes = &net_res; + conn_dlg.hwndOwner = hwnd; + net_res.dwType = dwType; + + return WNetConnectionDialog1W(&conn_dlg); } /*********************************************************************
7 years, 5 months
1
0
0
0
← Newer
1
...
15
16
17
18
19
20
21
22
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
Results per page:
10
25
50
100
200