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
January 2012
----- 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
559 discussions
Start a n
N
ew thread
[cgutman] 54857: [HIVESYS] - Add an entry for ndisuio (temporary until INF install works) - Autostart WZC service [NDISUIO] - Fix crash during binding and receive - Add more debugging
by cgutman@svn.reactos.org
Author: cgutman Date: Sat Jan 7 05:54:14 2012 New Revision: 54857 URL:
http://svn.reactos.org/svn/reactos?rev=54857&view=rev
Log: [HIVESYS] - Add an entry for ndisuio (temporary until INF install works) - Autostart WZC service [NDISUIO] - Fix crash during binding and receive - Add more debugging Modified: branches/wlan-bringup/boot/bootdata/hivesys_i386.inf branches/wlan-bringup/drivers/network/ndisuio/createclose.c branches/wlan-bringup/drivers/network/ndisuio/ioctl.c branches/wlan-bringup/drivers/network/ndisuio/main.c branches/wlan-bringup/drivers/network/ndisuio/protocol.c Modified: branches/wlan-bringup/boot/bootdata/hivesys_i386.inf URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/boot/bootdata/hive…
============================================================================== --- branches/wlan-bringup/boot/bootdata/hivesys_i386.inf [iso-8859-1] (original) +++ branches/wlan-bringup/boot/bootdata/hivesys_i386.inf [iso-8859-1] Sat Jan 7 05:54:14 2012 @@ -1398,6 +1398,13 @@ HKLM,"SYSTEM\CurrentControlSet\Services\NMIDebug","ImagePath",0x00020000,"system32\drivers\nmidebug.sys" HKLM,"SYSTEM\CurrentControlSet\Services\NMIDebug","Start",0x00010001,0x00000000 HKLM,"SYSTEM\CurrentControlSet\Services\NMIDebug","Type",0x00010001,0x00000001 + +; NDIS User I/O driver (FIXME: Should be installed via INF and started on demand) +HKLM,"SYSTEM\CurrentControlSet\Services\Ndisuio","ErrorControl",0x00010001,0x00000001 +HKLM,"SYSTEM\CurrentControlSet\Services\Ndisuio","Group",0x00000000,"NDIS" +HKLM,"SYSTEM\CurrentControlSet\Services\Ndisuio","ImagePath",0x00020000,"system32\drivers\ndisuio.sys" +HKLM,"SYSTEM\CurrentControlSet\Services\Ndisuio","Start",0x00010001,0x00000001 +HKLM,"SYSTEM\CurrentControlSet\Services\Ndisuio","Type",0x00010001,0x00000001 ; Packet driver HKLM,"SYSTEM\CurrentControlSet\Services\Packet","ErrorControl",0x00010001,0x00000001 @@ -1629,7 +1636,7 @@ HKLM,"SYSTEM\CurrentControlSet\Services\WlanSvc","Group",0x00000000,"TDI" HKLM,"SYSTEM\CurrentControlSet\Services\WlanSvc","ImagePath",0x00020000,"%SystemRoot%\system32\wlansvc.exe" HKLM,"SYSTEM\CurrentControlSet\Services\WlanSvc","ObjectName",0x00000000,"LocalSystem" -HKLM,"SYSTEM\CurrentControlSet\Services\WlanSvc","Start",0x00010001,0x00000003 +HKLM,"SYSTEM\CurrentControlSet\Services\WlanSvc","Start",0x00010001,0x00000002 HKLM,"SYSTEM\CurrentControlSet\Services\WlanSvc","Type",0x00010001,0x00000110 ; Simple TCP services Modified: branches/wlan-bringup/drivers/network/ndisuio/createclose.c URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
============================================================================== --- branches/wlan-bringup/drivers/network/ndisuio/createclose.c [iso-8859-1] (original) +++ branches/wlan-bringup/drivers/network/ndisuio/createclose.c [iso-8859-1] Sat Jan 7 05:54:14 2012 @@ -8,7 +8,7 @@ #include "ndisuio.h" -#define NDEBUG +//#define NDEBUG #include <debug.h> NTSTATUS @@ -19,6 +19,8 @@ PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp); ASSERT(DeviceObject == GlobalDeviceObject); + + DPRINT("Created file object 0x%x\n", IrpSp->FileObject); /* This is associated with an adapter during IOCTL_NDISUIO_OPEN_(WRITE_)DEVICE */ IrpSp->FileObject->FsContext = NULL; @@ -43,11 +45,15 @@ PNDISUIO_OPEN_ENTRY OpenEntry = IrpSp->FileObject->FsContext2; ASSERT(DeviceObject == GlobalDeviceObject); + + DPRINT("Closing file object 0x%x\n", IrpSp->FileObject); /* Check if this handle was ever associated with an adapter */ if (AdapterContext != NULL) { ASSERT(OpenEntry != NULL); + + DPRINT("Removing binding to adapter %wZ\n", &AdapterContext->DeviceName); /* Call the our helper */ DereferenceAdapterContextWithOpenEntry(AdapterContext, OpenEntry); Modified: branches/wlan-bringup/drivers/network/ndisuio/ioctl.c URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
============================================================================== --- branches/wlan-bringup/drivers/network/ndisuio/ioctl.c [iso-8859-1] (original) +++ branches/wlan-bringup/drivers/network/ndisuio/ioctl.c [iso-8859-1] Sat Jan 7 05:54:14 2012 @@ -8,7 +8,7 @@ #include "ndisuio.h" -#define NDEBUG +//#define NDEBUG #include <debug.h> static @@ -57,6 +57,7 @@ if (i == QueryBinding->BindingIndex) { AdapterContext = CONTAINING_RECORD(CurrentEntry, NDISUIO_ADAPTER_CONTEXT, ListEntry); + DPRINT("Query binding for index %d is adapter %wZ\n", i, &AdapterContext->DeviceName); if (AdapterContext->DeviceName.Length <= QueryBinding->DeviceNameLength) { BytesCopied += AdapterContext->DeviceName.Length; @@ -155,6 +156,8 @@ Request.DATA.SET_INFORMATION.Oid = SetOidRequest->Oid; Request.DATA.SET_INFORMATION.InformationBuffer = SetOidRequest->Data; Request.DATA.SET_INFORMATION.InformationBufferLength = RequestLength - sizeof(NDIS_OID); + + DPRINT("Setting OID 0x%x on adapter %wZ\n", SetOidRequest->Oid, &AdapterContext->DeviceName); /* Dispatch the request */ NdisRequest(&Status, @@ -209,6 +212,8 @@ Request.DATA.QUERY_INFORMATION.Oid = QueryOidRequest->Oid; Request.DATA.QUERY_INFORMATION.InformationBuffer = QueryOidRequest->Data; Request.DATA.QUERY_INFORMATION.InformationBufferLength = RequestLength - sizeof(NDIS_OID); + + DPRINT("Querying OID 0x%x on adapter %wZ\n", QueryOidRequest->Oid, &AdapterContext->DeviceName); /* Dispatch the request */ NdisRequest(&Status, @@ -264,6 +269,8 @@ AdapterContext = FindAdapterContextByName(&DeviceName); if (AdapterContext != NULL) { + DPRINT("Binding file object 0x%x to device %wZ\n", FileObject, &AdapterContext->DeviceName); + /* Reference the adapter context */ KeAcquireSpinLock(&AdapterContext->Spinlock, &OldIrql); if (AdapterContext->OpenCount != 0) Modified: branches/wlan-bringup/drivers/network/ndisuio/main.c URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
============================================================================== --- branches/wlan-bringup/drivers/network/ndisuio/main.c [iso-8859-1] (original) +++ branches/wlan-bringup/drivers/network/ndisuio/main.c [iso-8859-1] Sat Jan 7 05:54:14 2012 @@ -8,7 +8,7 @@ #include "ndisuio.h" -#define NDEBUG +//#define NDEBUG #include <debug.h> PDEVICE_OBJECT GlobalDeviceObject; @@ -20,7 +20,7 @@ VOID NTAPI NduUnload(PDRIVER_OBJECT DriverObject) { - DPRINT1("NDISUIO: Unloaded\n"); + DPRINT("NDISUIO: Unloaded\n"); } NTSTATUS @@ -98,7 +98,7 @@ return Status; } - DPRINT1("NDISUIO: Loaded\n"); + DPRINT("NDISUIO: Loaded\n"); return STATUS_SUCCESS; } Modified: branches/wlan-bringup/drivers/network/ndisuio/protocol.c URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
============================================================================== --- branches/wlan-bringup/drivers/network/ndisuio/protocol.c [iso-8859-1] (original) +++ branches/wlan-bringup/drivers/network/ndisuio/protocol.c [iso-8859-1] Sat Jan 7 05:54:14 2012 @@ -8,10 +8,8 @@ #include "ndisuio.h" -//#define NDEBUG +#define NDEBUG #include <debug.h> - -PNDIS_MEDIUM SupportedMedia = {NdisMedium802_3}; VOID NTAPI @@ -118,9 +116,7 @@ PNDIS_PACKET Packet; NDIS_STATUS Status; UINT BytesTransferred; - - DPRINT("Received a %d byte packet on %wZ\n", PacketSize + HeaderBufferSize, &AdapterContext->DeviceName); - + /* Discard if nobody is waiting for it */ if (AdapterContext->OpenCount == 0) return NDIS_STATUS_NOT_ACCEPTED; @@ -171,8 +167,8 @@ but not the pool because we still need it */ CleanupAndFreePacket(Packet, FALSE); - /* Allocate a packet entry from paged pool */ - PacketEntry = ExAllocatePool(PagedPool, sizeof(NDISUIO_PACKET_ENTRY) + BytesTransferred + HeaderBufferSize - 1); + /* Allocate a packet entry from pool */ + PacketEntry = ExAllocatePool(NonPagedPool, sizeof(NDISUIO_PACKET_ENTRY) + BytesTransferred + HeaderBufferSize - 1); if (!PacketEntry) { ExFreePool(PacketBuffer); @@ -183,7 +179,7 @@ PacketEntry->PacketLength = BytesTransferred + HeaderBufferSize; RtlCopyMemory(&PacketEntry->PacketData[0], PacketBuffer, PacketEntry->PacketLength); - /* Free the old non-paged buffer */ + /* Free the old buffer */ ExFreePool(PacketBuffer); /* Insert the packet on the adapter's packet list */ @@ -313,11 +309,10 @@ { NDIS_STATUS OpenErrorStatus; PNDISUIO_ADAPTER_CONTEXT AdapterContext; + NDIS_MEDIUM SupportedMedia[1] = {NdisMedium802_3}; UINT SelectedMedium; NDIS_STATUS Status; - - DPRINT("Binding adapter %wZ\n", &AdapterContext->DeviceName); - + /* Allocate the adapter context */ AdapterContext = ExAllocatePool(NonPagedPool, sizeof(*AdapterContext)); if (!AdapterContext) @@ -345,6 +340,8 @@ /* Copy the device name into the adapter context */ RtlCopyMemory(AdapterContext->DeviceName.Buffer, DeviceName->Buffer, DeviceName->Length); + + DPRINT("Binding adapter %wZ\n", &AdapterContext->DeviceName); /* Create the buffer pool */ NdisAllocateBufferPool(&Status, @@ -377,7 +374,7 @@ &OpenErrorStatus, &AdapterContext->BindingHandle, &SelectedMedium, - &SupportedMedia[0], + SupportedMedia, 1, GlobalProtocolHandle, AdapterContext,
12 years, 11 months
1
0
0
0
[janderwald] 54856: [KBDHID] - Implement KbdHid_ReadCompletion routine - Start implementing KbdHid_InsertScanCodes routine
by janderwald@svn.reactos.org
Author: janderwald Date: Fri Jan 6 20:37:13 2012 New Revision: 54856 URL:
http://svn.reactos.org/svn/reactos?rev=54856&view=rev
Log: [KBDHID] - Implement KbdHid_ReadCompletion routine - Start implementing KbdHid_InsertScanCodes routine Modified: branches/usb-bringup/drivers/hid/kbdhid/kbdhid.c branches/usb-bringup/drivers/hid/kbdhid/kbdhid.h Modified: branches/usb-bringup/drivers/hid/kbdhid/kbdhid.c URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/hid/kbdhid/…
============================================================================== --- branches/usb-bringup/drivers/hid/kbdhid/kbdhid.c [iso-8859-1] (original) +++ branches/usb-bringup/drivers/hid/kbdhid/kbdhid.c [iso-8859-1] Fri Jan 6 20:37:13 2012 @@ -13,8 +13,7 @@ VOID KbdHid_DispatchInputData( IN PKBDHID_DEVICE_EXTENSION DeviceExtension, - IN PKEYBOARD_INPUT_DATA InputData, - IN ULONG InputDataLength) + IN PKEYBOARD_INPUT_DATA InputData) { KIRQL OldIrql; ULONG InputDataConsumed; @@ -30,11 +29,37 @@ KeRaiseIrql(DISPATCH_LEVEL, &OldIrql); /* dispatch input data */ - (*(PSERVICE_CALLBACK_ROUTINE)DeviceExtension->ClassService)(DeviceExtension->ClassDeviceObject, InputData, InputData + InputDataLength + 1, &InputDataConsumed); + (*(PSERVICE_CALLBACK_ROUTINE)DeviceExtension->ClassService)(DeviceExtension->ClassDeviceObject, InputData, InputData + 1, &InputDataConsumed); /* lower irql to previous level */ KeLowerIrql(OldIrql); } + +BOOLEAN +NTAPI +KbdHid_InsertScanCodes( + IN PVOID Context, + IN PCHAR NewScanCodes, + IN ULONG Length) +{ + KEYBOARD_INPUT_DATA InputData; + ULONG Index; + + for(Index = 0; Index < Length; Index++) + { + DPRINT1("[KBDHID] ScanCode Index %lu ScanCode %x\n", Index, NewScanCodes[Index] & 0xFF); + // + // TODO: set up input data + // + //KbdHid_DispatchInputData((PKBDHID_DEVICE_EXTENSION)Context, &InputData); + } + + // + // done + // + return TRUE; +} + NTSTATUS NTAPI @@ -44,6 +69,8 @@ IN PVOID Context) { PKBDHID_DEVICE_EXTENSION DeviceExtension; + NTSTATUS Status; + ULONG ButtonLength; /* get device extension */ DeviceExtension = (PKBDHID_DEVICE_EXTENSION)Context; @@ -67,11 +94,27 @@ return STATUS_MORE_PROCESSING_REQUIRED; } - UNIMPLEMENTED - ASSERT(FALSE); - - /* dispatch mouse action */ - //KbdHid_DispatchInputData(DeviceExtension, &InputData); + /* get current usages */ + ButtonLength = DeviceExtension->UsageListLength; + Status = HidP_GetUsagesEx(HidP_Input, HIDP_LINK_COLLECTION_UNSPECIFIED, DeviceExtension->CurrentUsageList, &ButtonLength, DeviceExtension->PreparsedData, DeviceExtension->Report, DeviceExtension->ReportLength); + ASSERT(Status == HIDP_STATUS_SUCCESS); + + /* FIXME check if needs mapping */ + + /* get usage difference */ + Status = HidP_UsageAndPageListDifference(DeviceExtension->PreviousUsageList, DeviceExtension->CurrentUsageList, DeviceExtension->BreakUsageList, DeviceExtension->MakeUsageList, DeviceExtension->UsageListLength); + ASSERT(Status == HIDP_STATUS_SUCCESS); + + /* replace previous usage list with current list */ + RtlMoveMemory(DeviceExtension->PreviousUsageList, DeviceExtension->CurrentUsageList, sizeof(USAGE_AND_PAGE) * DeviceExtension->UsageListLength); + + /* translate break usage list */ + HidP_TranslateUsageAndPagesToI8042ScanCodes(DeviceExtension->BreakUsageList, DeviceExtension->UsageListLength, HidP_Keyboard_Break, &DeviceExtension->ModifierState, KbdHid_InsertScanCodes, DeviceExtension); + ASSERT(Status == HIDP_STATUS_SUCCESS); + + /* translate new usage list */ + HidP_TranslateUsageAndPagesToI8042ScanCodes(DeviceExtension->MakeUsageList, DeviceExtension->UsageListLength, HidP_Keyboard_Make, &DeviceExtension->ModifierState, KbdHid_InsertScanCodes, DeviceExtension); + ASSERT(Status == HIDP_STATUS_SUCCESS); /* re-init read */ KbdHid_InitiateRead(DeviceExtension); Modified: branches/usb-bringup/drivers/hid/kbdhid/kbdhid.h URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/hid/kbdhid/…
============================================================================== --- branches/usb-bringup/drivers/hid/kbdhid/kbdhid.h [iso-8859-1] (original) +++ branches/usb-bringup/drivers/hid/kbdhid/kbdhid.h [iso-8859-1] Fri Jan 6 20:37:13 2012 @@ -67,7 +67,7 @@ // // preparsed data // - PVOID PreparsedData; + PHIDP_PREPARSED_DATA PreparsedData; // // mdl for reading input report @@ -77,7 +77,7 @@ // // input report buffer // - PUCHAR Report; + PCHAR Report; // // input report length @@ -104,6 +104,11 @@ // KEYBOARD_ATTRIBUTES Attributes; + // + // keyboard modifier state + // + HIDP_KEYBOARD_MODIFIER_STATE ModifierState; + }KBDHID_DEVICE_EXTENSION, *PKBDHID_DEVICE_EXTENSION; /* defaults from kbfiltr.h */
12 years, 11 months
1
0
0
0
[cgutman] 54855: [NDISUIO] - Bug fixes - Make the packet and buffer pools per adapter - Crashes during bind for some reason
by cgutman@svn.reactos.org
Author: cgutman Date: Fri Jan 6 19:43:15 2012 New Revision: 54855 URL:
http://svn.reactos.org/svn/reactos?rev=54855&view=rev
Log: [NDISUIO] - Bug fixes - Make the packet and buffer pools per adapter - Crashes during bind for some reason Modified: branches/wlan-bringup/boot/bootdata/packages/reactos.dff branches/wlan-bringup/drivers/network/ndisuio/main.c branches/wlan-bringup/drivers/network/ndisuio/misc.c branches/wlan-bringup/drivers/network/ndisuio/ndisuio.h branches/wlan-bringup/drivers/network/ndisuio/protocol.c branches/wlan-bringup/drivers/network/ndisuio/readwrite.c Modified: branches/wlan-bringup/boot/bootdata/packages/reactos.dff URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/boot/bootdata/pack…
============================================================================== --- branches/wlan-bringup/boot/bootdata/packages/reactos.dff [iso-8859-1] (original) +++ branches/wlan-bringup/boot/bootdata/packages/reactos.dff [iso-8859-1] Fri Jan 6 19:43:15 2012 @@ -532,6 +532,7 @@ drivers\network\tdi\tdi.sys 2 drivers\network\dd\ne2000\ne2000.sys 2 drivers\network\dd\pcnet\pcnet.sys 2 +drivers\network\ndisuio\ndisuio.sys 2 drivers\serial\serenum\serenum.sys 2 drivers\serial\serial\serial.sys 2 Modified: branches/wlan-bringup/drivers/network/ndisuio/main.c URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
============================================================================== --- branches/wlan-bringup/drivers/network/ndisuio/main.c [iso-8859-1] (original) +++ branches/wlan-bringup/drivers/network/ndisuio/main.c [iso-8859-1] Fri Jan 6 19:43:15 2012 @@ -15,8 +15,6 @@ NDIS_HANDLE GlobalProtocolHandle; KSPIN_LOCK GlobalAdapterListLock; LIST_ENTRY GlobalAdapterList; -NDIS_HANDLE GlobalPacketPoolHandle; -NDIS_HANDLE GlobalBufferPoolHandle; NDIS_STRING ProtocolName = RTL_CONSTANT_STRING(L"NDISUIO"); @@ -70,32 +68,6 @@ return Status; } - /* Create the buffer pool */ - NdisAllocateBufferPool(&Status, - &GlobalBufferPoolHandle, - 100); - if (Status != NDIS_STATUS_SUCCESS) - { - DPRINT1("Failed to allocate buffer pool with status 0x%x\n", Status); - IoDeleteSymbolicLink(&DosDeviceName); - IoDeleteDevice(GlobalDeviceObject); - return Status; - } - - /* Create the packet pool */ - NdisAllocatePacketPool(&Status, - &GlobalPacketPoolHandle, - 50, - 0); - if (Status != NDIS_STATUS_SUCCESS) - { - DPRINT1("Failed to allocate packet pool with status 0x%x\n", Status); - NdisFreeBufferPool(GlobalBufferPoolHandle); - IoDeleteSymbolicLink(&DosDeviceName); - IoDeleteDevice(GlobalDeviceObject); - return Status; - } - /* Register the protocol with NDIS */ RtlZeroMemory(&Chars, sizeof(Chars)); Chars.MajorNdisVersion = NDIS_MAJOR_VERSION; @@ -121,8 +93,6 @@ if (Status != NDIS_STATUS_SUCCESS) { DPRINT1("Failed to register protocol with status 0x%x\n", Status); - NdisFreePacketPool(GlobalPacketPoolHandle); - NdisFreeBufferPool(GlobalBufferPoolHandle); IoDeleteSymbolicLink(&DosDeviceName); IoDeleteDevice(GlobalDeviceObject); return Status; Modified: branches/wlan-bringup/drivers/network/ndisuio/misc.c URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
============================================================================== --- branches/wlan-bringup/drivers/network/ndisuio/misc.c [iso-8859-1] (original) +++ branches/wlan-bringup/drivers/network/ndisuio/misc.c [iso-8859-1] Fri Jan 6 19:43:15 2012 @@ -12,7 +12,11 @@ #include <debug.h> NDIS_STATUS -AllocateAndChainBuffer(PNDIS_PACKET Packet, PVOID Buffer, ULONG BufferSize, BOOLEAN Front) +AllocateAndChainBuffer(PNDISUIO_ADAPTER_CONTEXT AdapterContext, + PNDIS_PACKET Packet, + PVOID Buffer, + ULONG BufferSize, + BOOLEAN Front) { NDIS_STATUS Status; PNDIS_BUFFER NdisBuffer; @@ -20,7 +24,7 @@ /* Allocate the NDIS buffer mapping the pool */ NdisAllocateBuffer(&Status, &NdisBuffer, - GlobalBufferPoolHandle, + AdapterContext->BufferPoolHandle, Buffer, BufferSize); if (Status != NDIS_STATUS_SUCCESS) @@ -45,7 +49,9 @@ } PNDIS_PACKET -CreatePacketFromPoolBuffer(PVOID Buffer, ULONG BufferSize) +CreatePacketFromPoolBuffer(PNDISUIO_ADAPTER_CONTEXT AdapterContext, + PVOID Buffer, + ULONG BufferSize) { PNDIS_PACKET Packet; NDIS_STATUS Status; @@ -53,7 +59,7 @@ /* Allocate a packet descriptor */ NdisAllocatePacket(&Status, &Packet, - GlobalPacketPoolHandle); + AdapterContext->PacketPoolHandle); if (Status != NDIS_STATUS_SUCCESS) { DPRINT1("No free packet descriptors\n"); @@ -61,7 +67,8 @@ } /* Use the helper to chain the buffer */ - Status = AllocateAndChainBuffer(Packet, Buffer, BufferSize, TRUE); + Status = AllocateAndChainBuffer(AdapterContext, Packet, + Buffer, BufferSize, TRUE); if (Status != NDIS_STATUS_SUCCESS) { NdisFreePacket(Packet); Modified: branches/wlan-bringup/drivers/network/ndisuio/ndisuio.h URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
============================================================================== --- branches/wlan-bringup/drivers/network/ndisuio/ndisuio.h [iso-8859-1] (original) +++ branches/wlan-bringup/drivers/network/ndisuio/ndisuio.h [iso-8859-1] Fri Jan 6 19:43:15 2012 @@ -15,8 +15,6 @@ extern NDIS_HANDLE GlobalProtocolHandle; extern LIST_ENTRY GlobalAdapterList; extern KSPIN_LOCK GlobalAdapterListLock; -extern NDIS_HANDLE GlobalPacketPoolHandle; -extern NDIS_HANDLE GlobalBufferPoolHandle; typedef struct _NDISUIO_ADAPTER_CONTEXT { @@ -30,6 +28,10 @@ /* Reference count information */ ULONG OpenCount; LIST_ENTRY OpenEntryList; + + /* NDIS pools */ + NDIS_HANDLE PacketPoolHandle; + NDIS_HANDLE BufferPoolHandle; /* Receive packet list */ LIST_ENTRY PacketList; @@ -92,13 +94,15 @@ /* misc.c */ NDIS_STATUS -AllocateAndChainBuffer(PNDIS_PACKET Packet, +AllocateAndChainBuffer(PNDISUIO_ADAPTER_CONTEXT AdapterContext, + PNDIS_PACKET Packet, PVOID Buffer, ULONG BufferSize, BOOLEAN Front); PNDIS_PACKET -CreatePacketFromPoolBuffer(PVOID Buffer, +CreatePacketFromPoolBuffer(PNDISUIO_ADAPTER_CONTEXT AdapterContext, + PVOID Buffer, ULONG BufferSize); VOID Modified: branches/wlan-bringup/drivers/network/ndisuio/protocol.c URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
============================================================================== --- branches/wlan-bringup/drivers/network/ndisuio/protocol.c [iso-8859-1] (original) +++ branches/wlan-bringup/drivers/network/ndisuio/protocol.c [iso-8859-1] Fri Jan 6 19:43:15 2012 @@ -8,7 +8,7 @@ #include "ndisuio.h" -#define NDEBUG +//#define NDEBUG #include <debug.h> PNDIS_MEDIUM SupportedMedia = {NdisMedium802_3}; @@ -119,13 +119,20 @@ NDIS_STATUS Status; UINT BytesTransferred; + DPRINT("Received a %d byte packet on %wZ\n", PacketSize + HeaderBufferSize, &AdapterContext->DeviceName); + + /* Discard if nobody is waiting for it */ + if (AdapterContext->OpenCount == 0) + return NDIS_STATUS_NOT_ACCEPTED; + /* Allocate a buffer to hold the packet data and header */ PacketBuffer = ExAllocatePool(NonPagedPool, PacketSize); if (!PacketBuffer) return NDIS_STATUS_NOT_ACCEPTED; /* Allocate the packet descriptor and buffer */ - Packet = CreatePacketFromPoolBuffer((PUCHAR)PacketBuffer + HeaderBufferSize, + Packet = CreatePacketFromPoolBuffer(AdapterContext, + (PUCHAR)PacketBuffer + HeaderBufferSize, PacketSize); if (!Packet) { @@ -221,20 +228,28 @@ UnbindAdapterByContext(PNDISUIO_ADAPTER_CONTEXT AdapterContext) { KIRQL OldIrql; - PLIST_ENTRY CurrentOpenEntry; + PLIST_ENTRY CurrentEntry; PNDISUIO_OPEN_ENTRY OpenEntry; + PNDISUIO_PACKET_ENTRY PacketEntry; NDIS_STATUS Status; + DPRINT("Unbinding adapter %wZ\n", &AdapterContext->DeviceName); + + /* FIXME: We don't do anything with outstanding reads */ + /* Remove the adapter context from the global list */ KeAcquireSpinLock(&GlobalAdapterListLock, &OldIrql); RemoveEntryList(&AdapterContext->ListEntry); KeReleaseSpinLock(&GlobalAdapterListLock, OldIrql); + + /* Free the device name string */ + RtlFreeUnicodeString(&AdapterContext->DeviceName); /* Invalidate all handles to this adapter */ - CurrentOpenEntry = AdapterContext->OpenEntryList.Flink; - while (CurrentOpenEntry != &AdapterContext->OpenEntryList) - { - OpenEntry = CONTAINING_RECORD(CurrentOpenEntry, NDISUIO_OPEN_ENTRY, ListEntry); + CurrentEntry = AdapterContext->OpenEntryList.Flink; + while (CurrentEntry != &AdapterContext->OpenEntryList) + { + OpenEntry = CONTAINING_RECORD(CurrentEntry, NDISUIO_OPEN_ENTRY, ListEntry); /* Make sure the entry is sane */ ASSERT(OpenEntry->FileObject); @@ -249,7 +264,7 @@ OpenEntry->FileObject->FsContext2 = NULL; /* Move to the next entry */ - CurrentOpenEntry = CurrentOpenEntry->Flink; + CurrentEntry = CurrentEntry->Flink; /* Free the open entry */ ExFreePool(OpenEntry); @@ -257,6 +272,19 @@ /* If this fails, we have a refcount mismatch somewhere */ ASSERT(AdapterContext->OpenCount == 0); + + /* Free all pending packet entries */ + CurrentEntry = AdapterContext->PacketList.Flink; + while (CurrentEntry != &AdapterContext->PacketList) + { + PacketEntry = CONTAINING_RECORD(CurrentEntry, NDISUIO_PACKET_ENTRY, ListEntry); + + /* Move to the next entry */ + CurrentEntry = CurrentEntry->Flink; + + /* Free the packet entry */ + ExFreePool(PacketEntry); + } /* Send the close request */ NdisCloseAdapter(&Status, @@ -287,6 +315,8 @@ PNDISUIO_ADAPTER_CONTEXT AdapterContext; UINT SelectedMedium; NDIS_STATUS Status; + + DPRINT("Binding adapter %wZ\n", &AdapterContext->DeviceName); /* Allocate the adapter context */ AdapterContext = ExAllocatePool(NonPagedPool, sizeof(*AdapterContext)); @@ -313,15 +343,42 @@ return NDIS_STATUS_RESOURCES; } + /* Copy the device name into the adapter context */ RtlCopyMemory(AdapterContext->DeviceName.Buffer, DeviceName->Buffer, DeviceName->Length); - + + /* Create the buffer pool */ + NdisAllocateBufferPool(&Status, + &AdapterContext->BufferPoolHandle, + 50); + if (Status != NDIS_STATUS_SUCCESS) + { + DPRINT1("Failed to allocate buffer pool with status 0x%x\n", Status); + RtlFreeUnicodeString(&AdapterContext->DeviceName); + ExFreePool(AdapterContext); + return Status; + } + + /* Create the packet pool */ + NdisAllocatePacketPool(&Status, + &AdapterContext->PacketPoolHandle, + 25, + PROTOCOL_RESERVED_SIZE_IN_PACKET); + if (Status != NDIS_STATUS_SUCCESS) + { + DPRINT1("Failed to allocate packet pool with status 0x%x\n", Status); + NdisFreeBufferPool(AdapterContext->BufferPoolHandle); + RtlFreeUnicodeString(&AdapterContext->DeviceName); + ExFreePool(AdapterContext); + return Status; + } + /* Send the open request */ NdisOpenAdapter(&Status, &OpenErrorStatus, &AdapterContext->BindingHandle, &SelectedMedium, - SupportedMedia, - sizeof(SupportedMedia), + &SupportedMedia[0], + 1, GlobalProtocolHandle, AdapterContext, DeviceName, @@ -343,6 +400,9 @@ if (Status != NDIS_STATUS_SUCCESS) { DPRINT1("Failed to open adapter for bind with status 0x%x\n", Status); + NdisFreePacketPool(AdapterContext->PacketPoolHandle); + NdisFreeBufferPool(AdapterContext->BufferPoolHandle); + RtlFreeUnicodeString(&AdapterContext->DeviceName); ExFreePool(AdapterContext); return Status; } Modified: branches/wlan-bringup/drivers/network/ndisuio/readwrite.c URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
============================================================================== --- branches/wlan-bringup/drivers/network/ndisuio/readwrite.c [iso-8859-1] (original) +++ branches/wlan-bringup/drivers/network/ndisuio/readwrite.c [iso-8859-1] Fri Jan 6 19:43:15 2012 @@ -167,7 +167,8 @@ ASSERT(DeviceObject == GlobalDeviceObject); /* Create a packet and buffer descriptor for this user buffer */ - Packet = CreatePacketFromPoolBuffer(Irp->AssociatedIrp.SystemBuffer, + Packet = CreatePacketFromPoolBuffer(AdapterContext, + Irp->AssociatedIrp.SystemBuffer, IrpSp->Parameters.Write.Length); if (Packet) { @@ -191,7 +192,7 @@ if (Status == NDIS_STATUS_SUCCESS) BytesCopied = IrpSp->Parameters.Write.Length; - CleanupAndFreePacket(Packet, TRUE); + CleanupAndFreePacket(Packet, FALSE); } else {
12 years, 11 months
1
0
0
0
[janderwald] 54854: [USB-BRINGUP] - Partial trunk sync
by janderwald@svn.reactos.org
Author: janderwald Date: Fri Jan 6 19:40:46 2012 New Revision: 54854 URL:
http://svn.reactos.org/svn/reactos?rev=54854&view=rev
Log: [USB-BRINGUP] - Partial trunk sync Added: branches/usb-bringup/configure.sh (props changed) - copied unchanged from r54852, trunk/reactos/configure.sh branches/usb-bringup/toolchain-gcc.cmake (props changed) - copied unchanged from r54852, trunk/reactos/toolchain-gcc.cmake Modified: branches/usb-bringup/CMakeLists.txt (props changed) branches/usb-bringup/CMakeMacros.cmake (props changed) branches/usb-bringup/COPYING (props changed) branches/usb-bringup/COPYING.ARM (props changed) branches/usb-bringup/COPYING.LIB (props changed) branches/usb-bringup/COPYING3 (props changed) branches/usb-bringup/COPYING3.LIB (props changed) branches/usb-bringup/CREDITS (contents, props changed) branches/usb-bringup/Doxyfile (props changed) branches/usb-bringup/INSTALL (props changed) branches/usb-bringup/PreLoad.cmake (props changed) branches/usb-bringup/README (props changed) branches/usb-bringup/apistatus.lst (props changed) branches/usb-bringup/baseaddress.cmake (props changed) branches/usb-bringup/cmake/ (props changed) branches/usb-bringup/cmake/Platform/ (props changed) branches/usb-bringup/cmake/Platform/Windows-cl.cmake (props changed) branches/usb-bringup/cmake/Platform/Windows.cmake (props changed) branches/usb-bringup/cmake/idl-support.cmake (props changed) branches/usb-bringup/config-amd64.cmake (props changed) branches/usb-bringup/config-arm.cmake (props changed) branches/usb-bringup/config.cmake (props changed) branches/usb-bringup/configure.cmd (props changed) branches/usb-bringup/depmap.xsl (props changed) branches/usb-bringup/gcc.cmake (props changed) branches/usb-bringup/global.lds (props changed) branches/usb-bringup/msc.cmake (props changed) branches/usb-bringup/ros_cd.cmake (props changed) branches/usb-bringup/rosbuild.bat (props changed) branches/usb-bringup/toolchain-mingw32.cmake (props changed) branches/usb-bringup/toolchain-msvc.cmake (props changed) branches/usb-bringup/vreport.xsl (props changed) Propchange: branches/usb-bringup/CMakeLists.txt ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/CMakeMacros.cmake ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/COPYING ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/COPYING.ARM ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/COPYING.LIB ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/COPYING3 ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/COPYING3.LIB ------------------------------------------------------------------------------ svn:mergeinfo = Modified: branches/usb-bringup/CREDITS URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/CREDITS?rev=54854&r…
============================================================================== --- branches/usb-bringup/CREDITS [iso-8859-1] (original) +++ branches/usb-bringup/CREDITS [iso-8859-1] Fri Jan 6 19:40:46 2012 @@ -58,6 +58,7 @@ Peter Ward <dralnix(a)gmail.com> Pierre Schweitzer <pschweitzer(a)reactos.org> Phillip Susi <phreak(a)iag.net> +Rafal Harabien <rafalh(a)reactos.org> Rex Jolliff <rex(a)lvcablemodem.com> Richard Campbell <betam4x(a)gmail.com> Robert Bergkvist <fragdance(a)hotmail.com> Propchange: branches/usb-bringup/CREDITS ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/Doxyfile ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/INSTALL ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/PreLoad.cmake ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/README ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/apistatus.lst ------------------------------------------------------------------------------ --- svn:executable (original) +++ svn:executable (removed) @@ -1,1 +1,0 @@ -* Propchange: branches/usb-bringup/apistatus.lst ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/baseaddress.cmake ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/cmake/ ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/cmake/Platform/ ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/cmake/Platform/Windows-cl.cmake ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/cmake/Platform/Windows.cmake ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/cmake/idl-support.cmake ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/config-amd64.cmake ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/config-arm.cmake ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/config.cmake ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/configure.cmd ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/configure.sh ------------------------------------------------------------------------------ svn:eol-style = native Propchange: branches/usb-bringup/configure.sh ------------------------------------------------------------------------------ svn:executable = * Propchange: branches/usb-bringup/configure.sh ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/depmap.xsl ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/gcc.cmake ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/global.lds ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/msc.cmake ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/ros_cd.cmake ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/rosbuild.bat ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/toolchain-gcc.cmake ------------------------------------------------------------------------------ svn:eol-style = native Propchange: branches/usb-bringup/toolchain-gcc.cmake ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/toolchain-mingw32.cmake ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/toolchain-msvc.cmake ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: branches/usb-bringup/vreport.xsl ------------------------------------------------------------------------------ svn:mergeinfo =
12 years, 11 months
1
0
0
0
[spetreolle] 54853: [NDISUIO] Add missing include path.
by spetreolle@svn.reactos.org
Author: spetreolle Date: Fri Jan 6 19:32:05 2012 New Revision: 54853 URL:
http://svn.reactos.org/svn/reactos?rev=54853&view=rev
Log: [NDISUIO] Add missing include path. Modified: branches/wlan-bringup/drivers/network/ndisuio/ndisuio.rbuild Modified: branches/wlan-bringup/drivers/network/ndisuio/ndisuio.rbuild URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
============================================================================== --- branches/wlan-bringup/drivers/network/ndisuio/ndisuio.rbuild [iso-8859-1] (original) +++ branches/wlan-bringup/drivers/network/ndisuio/ndisuio.rbuild [iso-8859-1] Fri Jan 6 19:32:05 2012 @@ -2,6 +2,7 @@ <!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd"> <module name="ndisuio" type="kernelmodedriver" installbase="system32/drivers" installname="ndisuio.sys"> <include base="ndisuio">.</include> + <include base="ReactOS">include/reactos/drivers/ndisuio</include> <define name="NDIS50" /> <define name="_NTDRIVER_" /> <library>ndis</library>
12 years, 11 months
1
0
0
0
[janderwald] 54852: [USB-BRINGUP] - Implement IOCTL_KEYBOARD_QUERY_ATTRIBUTES, IOCTL_INTERNAL_KEYBOARD_CONNECT, IOCTL_INTERNAL_KEYBOARD_DISCONNECT, IOCTL_INTERNAL_KEYBOARD_ENABLE, IOCTL_INTERNAL_KE...
by janderwald@svn.reactos.org
Author: janderwald Date: Fri Jan 6 18:32:35 2012 New Revision: 54852 URL:
http://svn.reactos.org/svn/reactos?rev=54852&view=rev
Log: [USB-BRINGUP] - Implement IOCTL_KEYBOARD_QUERY_ATTRIBUTES, IOCTL_INTERNAL_KEYBOARD_CONNECT, IOCTL_INTERNAL_KEYBOARD_DISCONNECT, IOCTL_INTERNAL_KEYBOARD_ENABLE, IOCTL_INTERNAL_KEYBOARD_DISABLE Modified: branches/usb-bringup/drivers/hid/kbdhid/kbdhid.c branches/usb-bringup/drivers/hid/kbdhid/kbdhid.h Modified: branches/usb-bringup/drivers/hid/kbdhid/kbdhid.c URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/hid/kbdhid/…
============================================================================== --- branches/usb-bringup/drivers/hid/kbdhid/kbdhid.c [iso-8859-1] (original) +++ branches/usb-bringup/drivers/hid/kbdhid/kbdhid.c [iso-8859-1] Fri Jan 6 18:32:35 2012 @@ -249,6 +249,8 @@ { PIO_STACK_LOCATION IoStack; PKBDHID_DEVICE_EXTENSION DeviceExtension; + PCONNECT_DATA Data; + PKEYBOARD_ATTRIBUTES Attributes; /* get current stack location */ IoStack = IoGetCurrentIrpStackLocation(Irp); @@ -258,9 +260,131 @@ /* get device extension */ DeviceExtension = (PKBDHID_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_KEYBOARD_QUERY_ATTRIBUTES) + { + /* verify output buffer length */ + if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(MOUSE_ATTRIBUTES)) + { + /* invalid request */ + DPRINT1("[MOUHID] IOCTL_MOUSE_QUERY_ATTRIBUTES Buffer too small\n"); + Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return STATUS_BUFFER_TOO_SMALL; + } + + /* get output buffer */ + Attributes = (PKEYBOARD_ATTRIBUTES)Irp->AssociatedIrp.SystemBuffer; + + /* copy attributes */ + RtlCopyMemory(Attributes, &DeviceExtension->Attributes, sizeof(KEYBOARD_ATTRIBUTES)); + + /* complete request */ + Irp->IoStatus.Information = sizeof(MOUSE_ATTRIBUTES); + Irp->IoStatus.Status = STATUS_SUCCESS; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return STATUS_SUCCESS; + } + else if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_INTERNAL_KEYBOARD_CONNECT) + { + /* verify input buffer length */ + if (IoStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(CONNECT_DATA)) + { + /* invalid request */ + Irp->IoStatus.Status = STATUS_INVALID_PARAMETER; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return STATUS_INVALID_PARAMETER; + } + + /* is it already connected */ + if (DeviceExtension->ClassService) + { + /* already connected */ + Irp->IoStatus.Status = STATUS_SHARING_VIOLATION; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return STATUS_SHARING_VIOLATION; + } + + /* get connect data */ + Data = (PCONNECT_DATA)IoStack->Parameters.DeviceIoControl.Type3InputBuffer; + + /* store connect details */ + DeviceExtension->ClassDeviceObject = Data->ClassDeviceObject; + DeviceExtension->ClassService = Data->ClassService; + + /* completed successfully */ + Irp->IoStatus.Status = STATUS_SUCCESS; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return STATUS_SUCCESS; + } + else if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_INTERNAL_KEYBOARD_DISCONNECT) + { + /* not implemented */ + Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return STATUS_NOT_IMPLEMENTED; + } + else if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_INTERNAL_KEYBOARD_ENABLE) + { + /* not supported */ + Irp->IoStatus.Status = STATUS_NOT_SUPPORTED; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return STATUS_NOT_SUPPORTED; + } + else if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_INTERNAL_KEYBOARD_DISABLE) + { + /* not supported */ + Irp->IoStatus.Status = STATUS_NOT_SUPPORTED; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return STATUS_NOT_SUPPORTED; + } + else if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_KEYBOARD_QUERY_INDICATORS) + { + /* not implemented */ + DPRINT1("IOCTL_KEYBOARD_QUERY_INDICATORS not implemented\n"); + ASSERT(FALSE); + Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return STATUS_NOT_IMPLEMENTED; + } + else if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_KEYBOARD_QUERY_TYPEMATIC) + { + /* not implemented */ + DPRINT1("IOCTL_KEYBOARD_QUERY_TYPEMATIC not implemented\n"); + ASSERT(FALSE); + Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return STATUS_NOT_IMPLEMENTED; + } + else if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_KEYBOARD_SET_INDICATORS) + { + /* not implemented */ + DPRINT1("IOCTL_KEYBOARD_SET_INDICATORS not implemented\n"); + ASSERT(FALSE); + Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return STATUS_NOT_IMPLEMENTED; + } + else if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_KEYBOARD_SET_TYPEMATIC) + { + /* not implemented */ + DPRINT1("IOCTL_KEYBOARD_SET_TYPEMATIC not implemented\n"); + ASSERT(FALSE); + Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return STATUS_NOT_IMPLEMENTED; + } + else if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION) + { + /* not implemented */ + DPRINT1("IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION not implemented\n"); + ASSERT(FALSE); + Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return STATUS_NOT_IMPLEMENTED; + } + + /* unknown control code */ DPRINT1("[KBDHID] Unknown DeviceControl %x\n", IoStack->Parameters.DeviceIoControl.IoControlCode); - - ASSERT(FALSE); /* unknown request not supported */ Irp->IoStatus.Status = STATUS_NOT_SUPPORTED; IoCompleteRequest(Irp, IO_NO_INCREMENT); @@ -624,6 +748,20 @@ /* init device extension */ DeviceExtension->NextDeviceObject = NextDeviceObject; KeInitializeEvent(&DeviceExtension->ReadCompletionEvent, NotificationEvent, FALSE); + + /* init keyboard attributes */ + DeviceExtension->Attributes.KeyboardIdentifier.Type = KEYBOARD_TYPE_UNKNOWN; + DeviceExtension->Attributes.KeyboardIdentifier.Subtype = MICROSOFT_KBD_101_TYPE; + DeviceExtension->Attributes.NumberOfFunctionKeys = MICROSOFT_KBD_FUNC; + DeviceExtension->Attributes.NumberOfIndicators = 3; // caps, num lock, scroll lock + DeviceExtension->Attributes.NumberOfKeysTotal = 101; + DeviceExtension->Attributes.InputDataQueueLength = 1; + DeviceExtension->Attributes.KeyRepeatMinimum.Rate = KEYBOARD_TYPEMATIC_RATE_MINIMUM; + DeviceExtension->Attributes.KeyRepeatMinimum.Delay = KEYBOARD_TYPEMATIC_DELAY_MINIMUM; + DeviceExtension->Attributes.KeyRepeatMaximum.Rate = KEYBOARD_TYPEMATIC_RATE_DEFAULT; + DeviceExtension->Attributes.KeyRepeatMaximum.Delay = KEYBOARD_TYPEMATIC_DELAY_MAXIMUM; + + /* allocate irp */ DeviceExtension->Irp = IoAllocateIrp(NextDeviceObject->StackSize, FALSE); /* FIXME handle allocation error */ Modified: branches/usb-bringup/drivers/hid/kbdhid/kbdhid.h URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/hid/kbdhid/…
============================================================================== --- branches/usb-bringup/drivers/hid/kbdhid/kbdhid.h [iso-8859-1] (original) +++ branches/usb-bringup/drivers/hid/kbdhid/kbdhid.h [iso-8859-1] Fri Jan 6 18:32:35 2012 @@ -6,8 +6,9 @@ #include <hidpddi.h> #include <hidpi.h> #include <debug.h> -#include <ntddmou.h> #include <kbdmou.h> +//#include <kbd.h> +#include <ntddkbd.h> #include <debug.h> @@ -98,9 +99,30 @@ // UCHAR StopReadReport; + // + // keyboard attributes + // + KEYBOARD_ATTRIBUTES Attributes; + }KBDHID_DEVICE_EXTENSION, *PKBDHID_DEVICE_EXTENSION; + +/* defaults from kbfiltr.h */ +#define KEYBOARD_TYPEMATIC_RATE_MINIMUM 2 +#define KEYBOARD_TYPEMATIC_RATE_MAXIMUM 30 +#define KEYBOARD_TYPEMATIC_RATE_DEFAULT 30 +#define KEYBOARD_TYPEMATIC_DELAY_MINIMUM 250 +#define KEYBOARD_TYPEMATIC_DELAY_MAXIMUM 1000 +#define KEYBOARD_TYPEMATIC_DELAY_DEFAULT 250 + +/* FIXME: write kbd.h */ +#define MICROSOFT_KBD_FUNC 12 +#define KEYBOARD_TYPE_UNKNOWN (0x51) +#define MICROSOFT_KBD_101_TYPE 0 + + NTSTATUS KbdHid_InitiateRead( IN PKBDHID_DEVICE_EXTENSION DeviceExtension); +
12 years, 11 months
1
0
0
0
[tkreuzer] 54851: [SAL.h] Add definitions for declspec based sal
by tkreuzer@svn.reactos.org
Author: tkreuzer Date: Fri Jan 6 17:02:57 2012 New Revision: 54851 URL:
http://svn.reactos.org/svn/reactos?rev=54851&view=rev
Log: [SAL.h] Add definitions for declspec based sal Modified: trunk/reactos/include/psdk/sal.h Modified: trunk/reactos/include/psdk/sal.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/sal.h?rev=548…
============================================================================== --- trunk/reactos/include/psdk/sal.h [iso-8859-1] (original) +++ trunk/reactos/include/psdk/sal.h [iso-8859-1] Fri Jan 6 17:02:57 2012 @@ -31,7 +31,7 @@ #ifdef _PREFAST_ #ifndef _USE_DECLSPECS_FOR_SAL -#define _USE_DECLSPECS_FOR_SAL 0 +#define _USE_DECLSPECS_FOR_SAL 1 #endif #if !defined(_USE_ATTRIBUTES_FOR_SAL) || _USE_DECLSPECS_FOR_SAL @@ -192,6 +192,8 @@ #define __count_c_impl(size) ValidElementsConst=size #define __count_impl(size) ValidElements=NL_(size) #define __count_x_impl(size) ValidElements="\n@"#size +#define __inner_exceptthat [SAL_except] +#define __inner_typefix(ctype) [SAL_typefix(p1=_SA_SPECSTRIZE(ctype))] #define __maybenull_impl Null=SA_Maybe #define __maybenull_impl_notref Null=SA_Maybe,Notref=1 #define __maybevalid_impl Valid=SA_Maybe @@ -210,9 +212,6 @@ #define __writeaccess_impl Access=SA_Write #define __writeaccess_impl_notref Access=SA_Write,Notref=1 #define __zterm_impl NullTerminated=SA_Yes - -#define __inner_exceptthat [SAL_except] -#define __inner_typefix(ctype) [SAL_typefix(p1=_SA_SPECSTRIZE(ctype))] #define _Check_return_impl_ [returnvalue:SA_Post(MustCheck=SA_Yes)] #define _Deref_in_bound_impl_ [SA_PreBound(Deref=1)] #define _Deref_in_range_impl_(min,max) [SA_PreRange(Deref=1,MinVal=#min,MaxVal=#max)] @@ -234,6 +233,7 @@ #define _Deref2_ret1_impl_(p1) [returnvalue:SA_Post(Deref=2,Notref=1,p1)] #define _In_bound_impl_ [SA_PreBound(Deref=0)] #define _In_range_impl_(min,max) [SA_PreRange(MinVal=#min,MaxVal=#max)] +#define _Notref_impl_ _SA_annotes0(SAL_notref) #define _Out_bound_impl_ [SA_PostBound(Deref=0)] #define _Out_range_impl_(min,max) [SA_PostRange(MinVal=#min,MaxVal=#max)] #define _Post1_impl_(p1) [SA_Post(p1)] @@ -258,9 +258,93 @@ #else /* #if _USE_DECLSPECS_FOR_SAL */ -#error unimplemented - +#define __bytecap_c_impl(size) _SA_annotes1(SAL_writableTo,byteCount(size)) +#define __bytecap_impl(size) _SA_annotes1(SAL_writableTo,byteCount(size)) +#define __bytecap_x_impl(size) _SA_annotes1(SAL_writableTo,inexpressibleCount(#size)) +#define __bytecount_c_impl(size) _SA_annotes1(SAL_readableTo,byteCount(size)) +#define __bytecount_impl(size) _SA_annotes1(SAL_readableTo,byteCount(size)) +#define __bytecount_x_impl(size) _SA_annotes1(SAL_readableTo,inexpressibleCount(#size)) +#define __cap_c_impl(size) _SA_annotes1(SAL_writableTo,elementCount(size)) +#define __cap_c_one_notref_impl _Notref_ _SA_annotes1(SAL_writableTo,elementCount(1)) +#define __cap_for_impl(param) _SA_annotes1(SAL_writableTo,inexpressibleCount(sizeof(param))) +#define __cap_impl(size) _SA_annotes1(SAL_writableTo,elementCount(size)) +#define __cap_x_impl(size) _SA_annotes1(SAL_writableTo,inexpressibleCount(#size)) +#define __count_c_impl(size) _SA_annotes1(SAL_readableTo,elementCount(size)) +#define __count_impl(size) _SA_annotes1(SAL_readableTo,elementCount(size)) +#define __count_x_impl(size) _SA_annotes1(SAL_readableTo,inexpressibleCount(#size)) +#define __inner_exceptthat _SA_annotes0(SAL_except) +#define __inner_typefix(ctype) _SA_annotes1(SAL_typefix, ctype) +#define __maybenull_impl _SA_annotes0(SAL_maybenull) +#define __maybenull_impl_notref _Notref_ _Maybenull_impl_ +#define __maybevalid_impl _SA_annotes0(SAL_maybevalid) // _SA_annotes1(SAL_valid, __maybe) +#define __maybezterm_impl _SA_annotes1(SAL_nullTerminated, __maybe) +#define __maybzterm_impl _SA_annotes1(SAL_nullTerminated, __maybe) +#define __mult_impl(mult,size) _SA_annotes1(SAL_writableTo,(mult)*(size)) +#define __notnull_impl _SA_annotes0(SAL_notnull) // _SA_annotes1(SAL_null, __no) +#define __notnull_impl_notref _Notref_ _Notnull_impl_ +#define __notvalid_impl _SA_annotes0(SAL_notvalid) // _SA_annotes1(SAL_valid, __no) +#define __null_impl _SA_annotes0(SAL_null) // _SA_annotes1(SAL_null, __yes) +#define __null_impl_notref _Notref_ _Null_impl_ +#define __notzterm_impl _SA_annotes1(SAL_nullTerminated, __no) +#define __readaccess_impl _SA_annotes0(SAL_readonly) //_SA_annotes1(SAL_access, 0x1) +#define __readaccess_impl_notref _Notref_ _SA_annotes0(SAL_readonly) //_SA_annotes1(SAL_access, 0x1) +#define __valid_impl _SA_annotes0(SAL_valid) // _SA_annotes1(SAL_valid, __yes) +#define __writeaccess_impl _SA_annotes0(SAL_notreadonly) // _SA_annotes1(SAL_access, 0x2) +#define __writeaccess_impl_notref _Notref_ _SA_annotes0(SAL_notreadonly) // _SA_annotes1(SAL_access, 0x2) +#define __zterm_impl _SA_annotes1(SAL_nullTerminated, __yes) +#define _Check_return_impl_ __post _SA_annotes0(SAL_checkReturn) +#define _Deref_in_bound_impl_ _Deref_pre_impl_ _Bound_impl_ +#define _Deref_in_range_impl_(min,max) _Deref_pre_impl_ _Range_impl_(min,max) +#define _Deref_out_bound_impl_ _Deref_post_impl_ _Bound_impl_ +#define _Deref_out_range_impl_(min,max) _Deref_post_impl_ _Range_impl_(min,max) +#define _Deref_post_impl_ _Post_impl_ _Notref_impl_ _Deref_impl_ +#define _Deref_post1_impl_(p1) _Deref_post_impl_ p1 +#define _Deref_post2_impl_(p1,p2) _Deref_post_impl_ p1 _Deref_post_impl_ p2 +#define _Deref_post3_impl_(p1,p2,p3) _Deref_post_impl_ p1 _Deref_post_impl_ p2 _Deref_post_impl_ p3 +#define _Deref_pre_impl_ _Pre_impl_ _Notref_impl_ _Deref_impl_ +#define _Deref_pre1_impl_(p1) _Deref_pre_impl_ p1 +#define _Deref_pre2_impl_(p1,p2) _Deref_pre_impl_ p1 _Deref_pre_impl_ p2 +#define _Deref_pre3_impl_(p1,p2,p3) _Deref_pre_impl_ p1 _Deref_pre_impl_ p2 _Deref_pre_impl_ p3 +#define _Deref_ret_bound_impl_ _Deref_post_impl_ _Bound_impl_ +#define _Deref_ret_range_impl_(min,max) _Deref_post_impl_ _Range_impl_(min,max) +#define _Deref_ret1_impl_(p1) _Deref_post_impl_ p1 +#define _Deref_ret2_impl_(p1,p2) _Deref_post_impl_ p1 _Deref_post_impl_ p2 +#define _Deref_ret3_impl_(p1,p2,p3) _Deref_post_impl_ p1 _Deref_post_impl_ p2 _Deref_post_impl_ p3 +#define _Deref2_post1_impl_(p1) _Deref_post_impl_ _Notref_impl_ _Deref_impl_ p1 +#define _Deref2_pre1_impl_(p1) _Deref_pre_impl_ _Notref_impl_ _Deref_impl_ p1 +#define _Deref2_ret1_impl_(p1) _Deref_post_impl_ _Notref_impl_ _Deref_impl_ p1 +#define _In_bound_impl_ _Pre_impl_ _Bound_impl_ +#define _In_range_impl_(min,max) _Pre_impl_ _Range_impl_(min,max) +#if (_MSC_VER > 1600) // CHECKME: doesn't work with WDK 7600 +#define _Notref_impl_ _SA_annotes0(SAL_notref) +#else +#define _Notref_impl_ #endif +#define _Out_bound_impl_ _Post_impl_ _Bound_impl_ +#define _Out_range_impl_(min,max) _Post_impl_ _Range_impl_(min,max) +#define _Post1_impl_(p1) _Post_impl_ p1 +#define _Post2_impl_(p1,p2) _Post_impl_ p1 _Post_impl_ p2 +#define _Post3_impl_(p1,p2,p3) _Post_impl_ p1 _Post_impl_ p2 _Post_impl_ p3 +#define _Pre1_impl_(p1) _Pre_impl_ p1 +#define _Pre2_impl_(p1,p2) _Pre_impl_ p1 _Pre_impl_ p2 +#define _Pre3_impl_(p1,p2,p3) _Pre_impl_ p1 _Pre_impl_ p2 _Pre_impl_ p3 +#define _Printf_format_string_impl_ _SA_annotes1(SAL_IsFormatString, "printf") +#define _Ret_bound_impl_ _Post_impl_ _Bound_impl_ +#define _Ret_range_impl_(min,max) _Post_impl_ _Range_impl_(min,max) +#define _Ret1_impl_(p1) _Post_impl_ p1 +#define _Ret2_impl_(p1,p2) _Post_impl_ p1 _Post_impl_ p2 +#define _Ret3_impl_(p1,p2,p3) _Post_impl_ p1 _Post_impl_ p2 _Post_impl_ p3 +#define _SA_annotes0(n) __declspec(#n) +#define _SA_annotes1(n,pp1) __declspec(#n "(" _SA_SPECSTRIZE(pp1) ")" ) +#define _SA_annotes2(n,pp1,pp2) __declspec(#n "(" _SA_SPECSTRIZE(pp1) "," _SA_SPECSTRIZE(pp2) ")") +#define _SA_annotes3(n,pp1,pp2,pp3) __declspec(#n "(" _SA_SPECSTRIZE(pp1) "," _SA_SPECSTRIZE(pp2) "," _SA_SPECSTRIZE(pp3) ")") +#define _Scanf_format_string_impl_ _SA_annotes1(SAL_IsFormatString, "scanf") +#define _Scanf_s_format_string_impl_ _SA_annotes1(SAL_IsFormatString, "scanf_s") +#define _Use_decl_anno_impl_ __declspec("SAL_useHeader()") // this is a special case! + +#endif + +#define _SA_SPECSTRIZE(x) #x /* Common definitions */ #define _At_(target, annos) _At_impl_(target, annos _SAL_nop_impl_) @@ -279,7 +363,6 @@ #define _Must_inspect_impl_ _Post_impl_ _SA_annotes0(SAL_mustInspect) #define _Notliteral_impl_ _SA_annotes1(SAL_constant, __no) #define _Notnull_impl_ _SA_annotes1(SAL_null, __no) -#define _Notref_impl_ _SA_annotes0(SAL_notref) #define _Notvalid_impl_ _SA_annotes1(SAL_valid, __no) #define _Null_impl_ _SA_annotes1(SAL_null, __yes) #define _Null_terminated_impl_ _SA_annotes1(SAL_nullTerminated, __yes) @@ -1560,5 +1643,5 @@ #define _Writable_bytes_(size) #define _Writable_elements_(size) -#endif /* _USE_ATTRIBUTES_FOR_SAL || _USE_ATTRIBUTES_FOR_SAL */ - +#endif /* _USE_ATTRIBUTES_FOR_SAL || _USE_DECLSPECS_FOR_SAL */ +
12 years, 11 months
1
0
0
0
[janderwald] 54850: [USB-BRINGUP] - Add keyboard hid driver template ripped off from mouhid driver - Implement keyboard driver initialization
by janderwald@svn.reactos.org
Author: janderwald Date: Fri Jan 6 16:35:55 2012 New Revision: 54850 URL:
http://svn.reactos.org/svn/reactos?rev=54850&view=rev
Log: [USB-BRINGUP] - Add keyboard hid driver template ripped off from mouhid driver - Implement keyboard driver initialization Added: branches/usb-bringup/drivers/hid/kbdhid/ (with props) branches/usb-bringup/drivers/hid/kbdhid/CMakeLists.txt (with props) branches/usb-bringup/drivers/hid/kbdhid/kbdhid.c (with props) branches/usb-bringup/drivers/hid/kbdhid/kbdhid.h (with props) branches/usb-bringup/drivers/hid/kbdhid/kbdhid.rc (with props) Modified: branches/usb-bringup/drivers/hid/CMakeLists.txt branches/usb-bringup/drivers/hid/mouhid/mouhid.rc Modified: branches/usb-bringup/drivers/hid/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/hid/CMakeLi…
============================================================================== --- branches/usb-bringup/drivers/hid/CMakeLists.txt [iso-8859-1] (original) +++ branches/usb-bringup/drivers/hid/CMakeLists.txt [iso-8859-1] Fri Jan 6 16:35:55 2012 @@ -1,4 +1,5 @@ add_subdirectory(hidclass) add_subdirectory(hidparse) add_subdirectory(hidusb) +add_subdirectory(kbdhid) add_subdirectory(mouhid) Propchange: branches/usb-bringup/drivers/hid/kbdhid/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Fri Jan 6 16:35:55 2012 @@ -1,0 +1,2 @@ +([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))? +(\d+) Propchange: branches/usb-bringup/drivers/hid/kbdhid/ ------------------------------------------------------------------------------ bugtraq:message = See issue #%BUGID% for more details. Propchange: branches/usb-bringup/drivers/hid/kbdhid/ ------------------------------------------------------------------------------ bugtraq:url =
http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Propchange: branches/usb-bringup/drivers/hid/kbdhid/ ------------------------------------------------------------------------------ tsvn:logminsize = 10 Added: branches/usb-bringup/drivers/hid/kbdhid/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/hid/kbdhid/…
============================================================================== --- branches/usb-bringup/drivers/hid/kbdhid/CMakeLists.txt (added) +++ branches/usb-bringup/drivers/hid/kbdhid/CMakeLists.txt [iso-8859-1] Fri Jan 6 16:35:55 2012 @@ -1,0 +1,13 @@ + +add_definitions(-DDEBUG_MODE) + +include_directories(${REACTOS_SOURCE_DIR}/ntoskrnl/include) + +add_library(kbdhid SHARED kbdhid.c kbdhid.rc) + +set_module_type(kbdhid kernelmodedriver) +add_importlibs(kbdhid ntoskrnl hal hidparse) +add_cab_target(kbdhid 2) + +add_cab_target(kbdhid 2) + Propchange: branches/usb-bringup/drivers/hid/kbdhid/CMakeLists.txt ------------------------------------------------------------------------------ svn:eol-style = native Added: branches/usb-bringup/drivers/hid/kbdhid/kbdhid.c URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/hid/kbdhid/…
============================================================================== --- branches/usb-bringup/drivers/hid/kbdhid/kbdhid.c (added) +++ branches/usb-bringup/drivers/hid/kbdhid/kbdhid.c [iso-8859-1] Fri Jan 6 16:35:55 2012 @@ -1,0 +1,674 @@ +/* + * PROJECT: ReactOS HID Stack + * LICENSE: GPL - See COPYING in the top level directory + * FILE: drivers/hid/kbdhid/kbdhid.c + * PURPOSE: Keyboard HID Driver + * PROGRAMMERS: + * Michael Martin (michael.martin(a)reactos.org) + * Johannes Anderwald (johannes.anderwald(a)reactos.org) + */ + +#include "kbdhid.h" + +VOID +KbdHid_DispatchInputData( + IN PKBDHID_DEVICE_EXTENSION DeviceExtension, + IN PKEYBOARD_INPUT_DATA InputData, + IN ULONG InputDataLength) +{ + KIRQL OldIrql; + ULONG InputDataConsumed; + + if (!DeviceExtension->ClassService) + return; + + /* sanity check */ + ASSERT(DeviceExtension->ClassService); + ASSERT(DeviceExtension->ClassDeviceObject); + + /* raise irql */ + KeRaiseIrql(DISPATCH_LEVEL, &OldIrql); + + /* dispatch input data */ + (*(PSERVICE_CALLBACK_ROUTINE)DeviceExtension->ClassService)(DeviceExtension->ClassDeviceObject, InputData, InputData + InputDataLength + 1, &InputDataConsumed); + + /* lower irql to previous level */ + KeLowerIrql(OldIrql); +} + +NTSTATUS +NTAPI +KbdHid_ReadCompletion( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp, + IN PVOID Context) +{ + PKBDHID_DEVICE_EXTENSION DeviceExtension; + + /* get device extension */ + DeviceExtension = (PKBDHID_DEVICE_EXTENSION)Context; + + if (Irp->IoStatus.Status == STATUS_PRIVILEGE_NOT_HELD || + Irp->IoStatus.Status == STATUS_DEVICE_NOT_CONNECTED || + Irp->IoStatus.Status == STATUS_CANCELLED || + DeviceExtension->StopReadReport) + { + /* failed to read or should be stopped*/ + DPRINT1("[KBDHID] ReadCompletion terminating read Status %x\n", Irp->IoStatus.Status); + + /* report no longer active */ + DeviceExtension->ReadReportActive = FALSE; + + /* request stopping of the report cycle */ + DeviceExtension->StopReadReport = FALSE; + + /* signal completion event */ + KeSetEvent(&DeviceExtension->ReadCompletionEvent, 0, 0); + return STATUS_MORE_PROCESSING_REQUIRED; + } + + UNIMPLEMENTED + ASSERT(FALSE); + + /* dispatch mouse action */ + //KbdHid_DispatchInputData(DeviceExtension, &InputData); + + /* re-init read */ + KbdHid_InitiateRead(DeviceExtension); + + /* stop completion */ + return STATUS_MORE_PROCESSING_REQUIRED; +} + +NTSTATUS +KbdHid_InitiateRead( + IN PKBDHID_DEVICE_EXTENSION DeviceExtension) +{ + PIO_STACK_LOCATION IoStack; + NTSTATUS Status; + + /* re-use irp */ + IoReuseIrp(DeviceExtension->Irp, STATUS_SUCCESS); + + /* init irp */ + DeviceExtension->Irp->MdlAddress = DeviceExtension->ReportMDL; + + /* get next stack location */ + IoStack = IoGetNextIrpStackLocation(DeviceExtension->Irp); + + /* init stack location */ + IoStack->Parameters.Read.Length = DeviceExtension->ReportLength; + IoStack->Parameters.Read.Key = 0; + IoStack->Parameters.Read.ByteOffset.QuadPart = 0LL; + IoStack->MajorFunction = IRP_MJ_READ; + IoStack->FileObject = DeviceExtension->FileObject; + + /* set completion routine */ + IoSetCompletionRoutine(DeviceExtension->Irp, KbdHid_ReadCompletion, DeviceExtension, TRUE, TRUE, TRUE); + + /* read is active */ + DeviceExtension->ReadReportActive = TRUE; + + /* start the read */ + Status = IoCallDriver(DeviceExtension->NextDeviceObject, DeviceExtension->Irp); + + /* done */ + return Status; +} + +NTSTATUS +NTAPI +KbdHid_CreateCompletion( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp, + IN PVOID Context) +{ + KeSetEvent((PKEVENT)Context, 0, FALSE); + return STATUS_MORE_PROCESSING_REQUIRED; +} + + +NTSTATUS +NTAPI +KbdHid_Create( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + PIO_STACK_LOCATION IoStack; + NTSTATUS Status; + KEVENT Event; + PKBDHID_DEVICE_EXTENSION DeviceExtension; + + DPRINT1("[KBDHID]: IRP_MJ_CREATE\n"); + + /* get device extension */ + DeviceExtension = (PKBDHID_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + + /* get stack location */ + IoStack = IoGetCurrentIrpStackLocation(Irp); + + /* copy stack location to next */ + IoCopyCurrentIrpStackLocationToNext(Irp); + + /* init event */ + KeInitializeEvent(&Event, NotificationEvent, FALSE); + + /* prepare irp */ + IoSetCompletionRoutine(Irp, KbdHid_CreateCompletion, &Event, TRUE, TRUE, TRUE); + + /* call lower driver */ + Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp); + if (Status == STATUS_PENDING) + { + /* request pending */ + KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); + } + + /* check for success */ + if (!NT_SUCCESS(Status)) + { + /* failed */ + Irp->IoStatus.Status = Status; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return Status; + } + + /* is the driver already in use */ + if (DeviceExtension->FileObject == NULL) + { + /* did the caller specify correct attributes */ + ASSERT(IoStack->Parameters.Create.SecurityContext); + if (IoStack->Parameters.Create.SecurityContext->DesiredAccess) + { + /* store file object */ + DeviceExtension->FileObject = IoStack->FileObject; + + /* reset event */ + KeResetEvent(&DeviceExtension->ReadCompletionEvent); + + /* initiating read */ + Status = KbdHid_InitiateRead(DeviceExtension); + DPRINT1("[KBDHID] KbdHid_InitiateRead: status %x\n", Status); + if (Status == STATUS_PENDING) + { + /* report irp is pending */ + Status = STATUS_SUCCESS; + } + } + } + + /* complete request */ + Irp->IoStatus.Status = Status; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return Status; +} + + +NTSTATUS +NTAPI +KbdHid_Close( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + PKBDHID_DEVICE_EXTENSION DeviceExtension; + + /* get device extension */ + DeviceExtension = (PKBDHID_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + + DPRINT("[KBDHID] IRP_MJ_CLOSE ReadReportActive %x\n", DeviceExtension->ReadReportActive); + + if (DeviceExtension->ReadReportActive) + { + /* request stopping of the report cycle */ + DeviceExtension->StopReadReport = TRUE; + + /* wait until the reports have been read */ + KeWaitForSingleObject(&DeviceExtension->ReadCompletionEvent, Executive, KernelMode, FALSE, NULL); + + /* cancel irp */ + IoCancelIrp(DeviceExtension->Irp); + } + + DPRINT("[KBDHID] IRP_MJ_CLOSE ReadReportActive %x\n", DeviceExtension->ReadReportActive); + + /* remove file object */ + DeviceExtension->FileObject = NULL; + + /* skip location */ + IoSkipCurrentIrpStackLocation(Irp); + + /* pass irp to down the stack */ + return IoCallDriver(DeviceExtension->NextDeviceObject, Irp); +} + +NTSTATUS +NTAPI +KbdHid_InternalDeviceControl( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + PIO_STACK_LOCATION IoStack; + PKBDHID_DEVICE_EXTENSION DeviceExtension; + + /* get current stack location */ + IoStack = IoGetCurrentIrpStackLocation(Irp); + + DPRINT1("[KBDHID] InternalDeviceControl %x\n", IoStack->Parameters.DeviceIoControl.IoControlCode); + + /* get device extension */ + DeviceExtension = (PKBDHID_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + + DPRINT1("[KBDHID] Unknown DeviceControl %x\n", IoStack->Parameters.DeviceIoControl.IoControlCode); + + ASSERT(FALSE); + /* unknown request not supported */ + Irp->IoStatus.Status = STATUS_NOT_SUPPORTED; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return STATUS_NOT_SUPPORTED; +} + +NTSTATUS +NTAPI +KbdHid_DeviceControl( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + PKBDHID_DEVICE_EXTENSION DeviceExtension; + + /* get device extension */ + DeviceExtension = (PKBDHID_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + + /* skip stack location */ + IoSkipCurrentIrpStackLocation(Irp); + + /* pass and forget */ + return IoCallDriver(DeviceExtension->NextDeviceObject, Irp); +} + +NTSTATUS +NTAPI +KbdHid_Power( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + UNIMPLEMENTED + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +KbdHid_SubmitRequest( + PDEVICE_OBJECT DeviceObject, + ULONG IoControlCode, + ULONG InputBufferSize, + PVOID InputBuffer, + ULONG OutputBufferSize, + PVOID OutputBuffer) +{ + KEVENT Event; + PKBDHID_DEVICE_EXTENSION DeviceExtension; + PIRP Irp; + NTSTATUS Status; + IO_STATUS_BLOCK IoStatus; + + /* get device extension */ + DeviceExtension = (PKBDHID_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + + /* init event */ + KeInitializeEvent(&Event, NotificationEvent, FALSE); + + /* build request */ + Irp = IoBuildDeviceIoControlRequest(IoControlCode, DeviceExtension->NextDeviceObject, InputBuffer, InputBufferSize, OutputBuffer, OutputBufferSize, FALSE, &Event, &IoStatus); + if (!Irp) + { + /* no memory */ + return STATUS_INSUFFICIENT_RESOURCES; + } + + /* send request */ + Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp); + if (Status == STATUS_PENDING) + { + /* wait for request to complete */ + KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); + Status = IoStatus.Status; + } + + /* done */ + return Status; +} + +NTSTATUS +NTAPI +KbdHid_StartDevice( + IN PDEVICE_OBJECT DeviceObject) +{ + NTSTATUS Status; + ULONG Buttons; + HID_COLLECTION_INFORMATION Information; + PHIDP_PREPARSED_DATA PreparsedData; + HIDP_CAPS Capabilities; + PKBDHID_DEVICE_EXTENSION DeviceExtension; + PUSAGE_AND_PAGE Buffer; + + /* get device extension */ + DeviceExtension = (PKBDHID_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + + /* query collection information */ + Status = KbdHid_SubmitRequest(DeviceObject, IOCTL_HID_GET_COLLECTION_INFORMATION, 0, NULL, sizeof(HID_COLLECTION_INFORMATION), &Information); + if (!NT_SUCCESS(Status)) + { + /* failed to query collection information */ + DPRINT1("[KBDHID] failed to obtain collection information with %x\n", Status); + return Status; + } + + /* lets allocate space for preparsed data */ + PreparsedData = (PHIDP_PREPARSED_DATA)ExAllocatePool(NonPagedPool, Information.DescriptorSize); + if (!PreparsedData) + { + /* no memory */ + DPRINT1("[KBDHID] no memory size %u\n", Information.DescriptorSize); + return STATUS_INSUFFICIENT_RESOURCES; + } + + /* now obtain the preparsed data */ + Status = KbdHid_SubmitRequest(DeviceObject, IOCTL_HID_GET_COLLECTION_DESCRIPTOR, 0, NULL, Information.DescriptorSize, PreparsedData); + if (!NT_SUCCESS(Status)) + { + /* failed to get preparsed data */ + DPRINT1("[KBDHID] failed to obtain collection information with %x\n", Status); + ExFreePool(PreparsedData); + return Status; + } + + /* lets get the caps */ + Status = HidP_GetCaps(PreparsedData, &Capabilities); + if (Status != HIDP_STATUS_SUCCESS) + { + /* failed to get capabilities */ + DPRINT1("[KBDHID] failed to obtain caps with %x\n", Status); + ExFreePool(PreparsedData); + return Status; + } + + DPRINT1("[KBDHID] Usage %x UsagePage %x InputReportLength %lu\n", Capabilities.Usage, Capabilities.UsagePage, Capabilities.InputReportByteLength); + + /* init input report*/ + DeviceExtension->ReportLength = Capabilities.InputReportByteLength; + ASSERT(DeviceExtension->ReportLength); + DeviceExtension->Report = (PUCHAR)ExAllocatePool(NonPagedPool, DeviceExtension->ReportLength); + ASSERT(DeviceExtension->Report); + RtlZeroMemory(DeviceExtension->Report, DeviceExtension->ReportLength); + + /* build mdl */ + DeviceExtension->ReportMDL = IoAllocateMdl(DeviceExtension->Report, DeviceExtension->ReportLength, FALSE, FALSE, NULL); + ASSERT(DeviceExtension->ReportMDL); + + /* init mdl */ + MmBuildMdlForNonPagedPool(DeviceExtension->ReportMDL); + + /* get max number of buttons */ + Buttons = HidP_MaxUsageListLength(HidP_Input, HID_USAGE_PAGE_BUTTON, PreparsedData); + DPRINT1("[KBDHID] Buttons %lu\n", Buttons); + ASSERT(Buttons > 0); + + /* now allocate an array for those buttons */ + Buffer = (PUSAGE_AND_PAGE)ExAllocatePool(NonPagedPool, sizeof(USAGE_AND_PAGE) * 4 * Buttons); + if (!Buffer) + { + /* no memory */ + ExFreePool(PreparsedData); + return STATUS_INSUFFICIENT_RESOURCES; + } + + /* init usage lists */ + RtlZeroMemory(Buffer, sizeof(USAGE_AND_PAGE) * 4 * Buttons); + DeviceExtension->CurrentUsageList = Buffer; + Buffer += Buttons; + DeviceExtension->PreviousUsageList = Buffer; + Buffer += Buttons; + DeviceExtension->MakeUsageList = Buffer; + Buffer += Buttons; + DeviceExtension->BreakUsageList = Buffer; + + // + // FIMXE: implement device hacks + // + // UsageMappings + // KeyboardTypeOverride + // KeyboardSubTypeOverride + // KeyboardNumberTotalKeysOverride + // KeyboardNumberFunctionKeysOverride + // KeyboardNumberIndicatorsOverride + + /* store number of buttons */ + DeviceExtension->UsageListLength = (USHORT)Buttons; + + /* store preparsed data */ + DeviceExtension->PreparsedData = PreparsedData; + + /* completed successfully */ + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +KbdHid_StartDeviceCompletion( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp, + IN PVOID Context) +{ + KeSetEvent((PKEVENT)Context, 0, FALSE); + return STATUS_MORE_PROCESSING_REQUIRED; +} + +NTSTATUS +NTAPI +KbdHid_Flush( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + PIO_STACK_LOCATION IoStack; + PKBDHID_DEVICE_EXTENSION DeviceExtension; + + /* get device extension */ + DeviceExtension = (PKBDHID_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + + /* skip current stack location */ + IoSkipCurrentIrpStackLocation(Irp); + + /* get next stack location */ + IoStack = IoGetNextIrpStackLocation(Irp); + + /* change request to hid flush queue request */ + IoStack->MajorFunction = IRP_MJ_DEVICE_CONTROL; + IoStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_HID_FLUSH_QUEUE; + + /* call device */ + return IoCallDriver(DeviceExtension->NextDeviceObject, Irp); +} + +NTSTATUS +NTAPI +KbdHid_Pnp( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + PIO_STACK_LOCATION IoStack; + KEVENT Event; + NTSTATUS Status; + PKBDHID_DEVICE_EXTENSION DeviceExtension; + + /* get device extension */ + DeviceExtension = (PKBDHID_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + + /* get current irp stack */ + IoStack = IoGetCurrentIrpStackLocation(Irp); + DPRINT1("[KBDHID] IRP_MJ_PNP Request: %x\n", IoStack->MinorFunction); + + if (IoStack->MinorFunction == IRP_MN_STOP_DEVICE || IoStack->MinorFunction == IRP_MN_CANCEL_REMOVE_DEVICE || IoStack->MinorFunction == IRP_MN_QUERY_STOP_DEVICE || IoStack->MinorFunction == IRP_MN_CANCEL_STOP_DEVICE) + { + /* indicate success */ + Irp->IoStatus.Status = STATUS_SUCCESS; + + /* skip irp stack location */ + IoSkipCurrentIrpStackLocation(Irp); + + /* dispatch to lower device */ + return IoCallDriver(DeviceExtension->NextDeviceObject, Irp); + } + else if (IoStack->MinorFunction == IRP_MN_REMOVE_DEVICE) + { + /* FIXME synchronization */ + + /* cancel irp */ + IoCancelIrp(DeviceExtension->Irp); + + /* indicate success */ + Irp->IoStatus.Status = STATUS_SUCCESS; + + /* skip irp stack location */ + IoSkipCurrentIrpStackLocation(Irp); + + /* dispatch to lower device */ + Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp); + + IoFreeIrp(DeviceExtension->Irp); + IoDetachDevice(DeviceExtension->NextDeviceObject); + IoDeleteDevice(DeviceObject); + return Status; + } + else if (IoStack->MinorFunction == IRP_MN_START_DEVICE) + { + /* init event */ + KeInitializeEvent(&Event, NotificationEvent, FALSE); + + /* copy stack location */ + IoCopyCurrentIrpStackLocationToNext (Irp); + + /* set completion routine */ + IoSetCompletionRoutine(Irp, KbdHid_StartDeviceCompletion, &Event, TRUE, TRUE, TRUE); + Irp->IoStatus.Status = 0; + + /* pass request */ + Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp); + if (Status == STATUS_PENDING) + { + KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); + Status = Irp->IoStatus.Status; + } + + if (!NT_SUCCESS(Status)) + { + /* failed */ + Irp->IoStatus.Status = Status; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return Status; + } + + /* lets start the device */ + Status = KbdHid_StartDevice(DeviceObject); + DPRINT1("KbdHid_StartDevice %x\n", Status); + + /* complete request */ + Irp->IoStatus.Status = Status; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + + /* done */ + return Status; + } + else + { + /* skip irp stack location */ + IoSkipCurrentIrpStackLocation(Irp); + + /* dispatch to lower device */ + return IoCallDriver(DeviceExtension->NextDeviceObject, Irp); + } +} + +NTSTATUS +NTAPI +KbdHid_AddDevice( + IN PDRIVER_OBJECT DriverObject, + IN PDEVICE_OBJECT PhysicalDeviceObject) +{ + NTSTATUS Status; + PDEVICE_OBJECT DeviceObject, NextDeviceObject; + PKBDHID_DEVICE_EXTENSION DeviceExtension; + POWER_STATE State; + + /* create device object */ + Status = IoCreateDevice(DriverObject, sizeof(KBDHID_DEVICE_EXTENSION), NULL, FILE_DEVICE_KEYBOARD, 0, FALSE, &DeviceObject); + if (!NT_SUCCESS(Status)) + { + /* failed to create device object */ + return Status; + } + + /* now attach it */ + NextDeviceObject = IoAttachDeviceToDeviceStack(DeviceObject, PhysicalDeviceObject); + if (!NextDeviceObject) + { + /* failed to attach */ + IoDeleteDevice(DeviceObject); + return STATUS_DEVICE_NOT_CONNECTED; + } + + /* get device extension */ + DeviceExtension = (PKBDHID_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + + /* zero extension */ + RtlZeroMemory(DeviceExtension, sizeof(KBDHID_DEVICE_EXTENSION)); + + /* init device extension */ + DeviceExtension->NextDeviceObject = NextDeviceObject; + KeInitializeEvent(&DeviceExtension->ReadCompletionEvent, NotificationEvent, FALSE); + DeviceExtension->Irp = IoAllocateIrp(NextDeviceObject->StackSize, FALSE); + + /* FIXME handle allocation error */ + ASSERT(DeviceExtension->Irp); + + /* set power state to D0 */ + State.DeviceState = PowerDeviceD0; + PoSetPowerState(DeviceObject, DevicePowerState, State); + + /* init device object */ + DeviceObject->Flags |= DO_BUFFERED_IO | DO_POWER_PAGABLE; + DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING; + + /* completed successfully */ + return STATUS_SUCCESS; +} + +VOID +NTAPI +KbdHid_Unload( + IN PDRIVER_OBJECT DriverObject) +{ + UNIMPLEMENTED +} + + +NTSTATUS +NTAPI +DriverEntry( + IN PDRIVER_OBJECT DriverObject, + IN PUNICODE_STRING RegPath) +{ + /* initialize driver object */ + DriverObject->DriverUnload = KbdHid_Unload; + DriverObject->DriverExtension->AddDevice = KbdHid_AddDevice; + DriverObject->MajorFunction[IRP_MJ_CREATE] = KbdHid_Create; + DriverObject->MajorFunction[IRP_MJ_CLOSE] = KbdHid_Close; + DriverObject->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = KbdHid_Flush; + DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = KbdHid_DeviceControl; + DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = KbdHid_InternalDeviceControl; + DriverObject->MajorFunction[IRP_MJ_POWER] = KbdHid_Power; + DriverObject->MajorFunction[IRP_MJ_PNP] = KbdHid_Pnp; + DriverObject->DriverUnload = KbdHid_Unload; + DriverObject->DriverExtension->AddDevice = KbdHid_AddDevice; + + /* done */ + return STATUS_SUCCESS; +} Propchange: branches/usb-bringup/drivers/hid/kbdhid/kbdhid.c ------------------------------------------------------------------------------ svn:eol-style = native Added: branches/usb-bringup/drivers/hid/kbdhid/kbdhid.h URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/hid/kbdhid/…
============================================================================== --- branches/usb-bringup/drivers/hid/kbdhid/kbdhid.h (added) +++ branches/usb-bringup/drivers/hid/kbdhid/kbdhid.h [iso-8859-1] Fri Jan 6 16:35:55 2012 @@ -1,0 +1,106 @@ +#pragma once + +#define _HIDPI_NO_FUNCTION_MACROS_ +#include <ntddk.h> +#include <hidclass.h> +#include <hidpddi.h> +#include <hidpi.h> +#include <debug.h> +#include <ntddmou.h> +#include <kbdmou.h> +#include <debug.h> + + +typedef struct +{ + // + // lower device object + // + PDEVICE_OBJECT NextDeviceObject; + + // + // irp which is used for reading input reports + // + PIRP Irp; + + // + // event + // + KEVENT ReadCompletionEvent; + + // + // device object for class callback + // + PDEVICE_OBJECT ClassDeviceObject; + + // + // class callback + // + PVOID ClassService; + + // + // usage list length + // + USHORT UsageListLength; + + // + // current usage list length + // + PUSAGE_AND_PAGE CurrentUsageList; + + // + // previous usage list + // + PUSAGE_AND_PAGE PreviousUsageList; + + // + // removed usage item list + // + PUSAGE_AND_PAGE BreakUsageList; + + // + // new item usage list + // + PUSAGE_AND_PAGE MakeUsageList; + + // + // preparsed data + // + PVOID PreparsedData; + + // + // mdl for reading input report + // + PMDL ReportMDL; + + // + // input report buffer + // + PUCHAR Report; + + // + // input report length + // + ULONG ReportLength; + + // + // file object the device is reading reports from + // + PFILE_OBJECT FileObject; + + // + // report read is active + // + UCHAR ReadReportActive; + + // + // stop reading flag + // + UCHAR StopReadReport; + +}KBDHID_DEVICE_EXTENSION, *PKBDHID_DEVICE_EXTENSION; + + +NTSTATUS +KbdHid_InitiateRead( + IN PKBDHID_DEVICE_EXTENSION DeviceExtension); Propchange: branches/usb-bringup/drivers/hid/kbdhid/kbdhid.h ------------------------------------------------------------------------------ svn:eol-style = native Added: branches/usb-bringup/drivers/hid/kbdhid/kbdhid.rc URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/hid/kbdhid/…
============================================================================== --- branches/usb-bringup/drivers/hid/kbdhid/kbdhid.rc (added) +++ branches/usb-bringup/drivers/hid/kbdhid/kbdhid.rc [iso-8859-1] Fri Jan 6 16:35:55 2012 @@ -1,0 +1,5 @@ +#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "Keyboard HID Class Driver\0" +#define REACTOS_STR_INTERNAL_NAME "kbdhid\0" +#define REACTOS_STR_ORIGINAL_FILENAME "kbdhid.sys\0" +#include <reactos/version.rc> Propchange: branches/usb-bringup/drivers/hid/kbdhid/kbdhid.rc ------------------------------------------------------------------------------ svn:eol-style = native Modified: branches/usb-bringup/drivers/hid/mouhid/mouhid.rc URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/hid/mouhid/…
============================================================================== --- branches/usb-bringup/drivers/hid/mouhid/mouhid.rc [iso-8859-1] (original) +++ branches/usb-bringup/drivers/hid/mouhid/mouhid.rc [iso-8859-1] Fri Jan 6 16:35:55 2012 @@ -1,5 +1,5 @@ #define REACTOS_VERSION_DLL -#define REACTOS_STR_FILE_DESCRIPTION "USB HID Parser\0" -#define REACTOS_STR_INTERNAL_NAME "hidparse\0" -#define REACTOS_STR_ORIGINAL_FILENAME "hidparse.sys\0" +#define REACTOS_STR_FILE_DESCRIPTION "Mouse HID Class Driver\0" +#define REACTOS_STR_INTERNAL_NAME "mouhid\0" +#define REACTOS_STR_ORIGINAL_FILENAME "mouhid.sys\0" #include <reactos/version.rc>
12 years, 11 months
1
0
0
0
[cgutman] 54849: [NDISUIO] - Build fixes
by cgutman@svn.reactos.org
Author: cgutman Date: Fri Jan 6 05:59:56 2012 New Revision: 54849 URL:
http://svn.reactos.org/svn/reactos?rev=54849&view=rev
Log: [NDISUIO] - Build fixes Added: branches/wlan-bringup/include/reactos/drivers/ndisuio/ branches/wlan-bringup/include/reactos/drivers/ndisuio/nuiouser.h (with props) Modified: branches/wlan-bringup/drivers/network/CMakeLists.txt branches/wlan-bringup/drivers/network/directory.rbuild branches/wlan-bringup/drivers/network/ndisuio/CMakeLists.txt branches/wlan-bringup/drivers/network/ndisuio/createclose.c branches/wlan-bringup/drivers/network/ndisuio/ioctl.c branches/wlan-bringup/drivers/network/ndisuio/main.c branches/wlan-bringup/drivers/network/ndisuio/misc.c branches/wlan-bringup/drivers/network/ndisuio/ndisuio.h branches/wlan-bringup/drivers/network/ndisuio/protocol.c branches/wlan-bringup/drivers/network/ndisuio/readwrite.c Modified: branches/wlan-bringup/drivers/network/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/CM…
============================================================================== --- branches/wlan-bringup/drivers/network/CMakeLists.txt [iso-8859-1] (original) +++ branches/wlan-bringup/drivers/network/CMakeLists.txt [iso-8859-1] Fri Jan 6 05:59:56 2012 @@ -2,5 +2,6 @@ add_subdirectory(afd) add_subdirectory(dd) add_subdirectory(ndis) +add_subdirectory(ndisuio) add_subdirectory(tcpip) add_subdirectory(tdi) Modified: branches/wlan-bringup/drivers/network/directory.rbuild URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/di…
============================================================================== --- branches/wlan-bringup/drivers/network/directory.rbuild [iso-8859-1] (original) +++ branches/wlan-bringup/drivers/network/directory.rbuild [iso-8859-1] Fri Jan 6 05:59:56 2012 @@ -10,6 +10,9 @@ <directory name="ndis"> <xi:include href="ndis/ndis.rbuild" /> </directory> +<directory name="ndisuio"> + <xi:include href="ndisuio/ndisuio.rbuild" /> +</directory> <directory name="tcpip"> <xi:include href="tcpip/tcpip.rbuild" /> </directory> Modified: branches/wlan-bringup/drivers/network/ndisuio/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
============================================================================== --- branches/wlan-bringup/drivers/network/ndisuio/CMakeLists.txt [iso-8859-1] (original) +++ branches/wlan-bringup/drivers/network/ndisuio/CMakeLists.txt [iso-8859-1] Fri Jan 6 05:59:56 2012 @@ -1,6 +1,10 @@ add_definitions( -DNDIS50 -D_NTDRIVER_) + +include_directories( + BEFORE include + ${REACTOS_SOURCE_DIR}/include/reactos/drivers/ndisuio) list(APPEND SOURCE createclose.c Modified: branches/wlan-bringup/drivers/network/ndisuio/createclose.c URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
============================================================================== --- branches/wlan-bringup/drivers/network/ndisuio/createclose.c [iso-8859-1] (original) +++ branches/wlan-bringup/drivers/network/ndisuio/createclose.c [iso-8859-1] Fri Jan 6 05:59:56 2012 @@ -41,7 +41,6 @@ PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp); PNDISUIO_ADAPTER_CONTEXT AdapterContext = IrpSp->FileObject->FsContext; PNDISUIO_OPEN_ENTRY OpenEntry = IrpSp->FileObject->FsContext2; - KIRQL OldIrql; ASSERT(DeviceObject == GlobalDeviceObject); Modified: branches/wlan-bringup/drivers/network/ndisuio/ioctl.c URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
============================================================================== --- branches/wlan-bringup/drivers/network/ndisuio/ioctl.c [iso-8859-1] (original) +++ branches/wlan-bringup/drivers/network/ndisuio/ioctl.c [iso-8859-1] Fri Jan 6 05:59:56 2012 @@ -11,7 +11,7 @@ #define NDEBUG #include <debug.h> - +static NTSTATUS WaitForBind(PIRP Irp, PIO_STACK_LOCATION IrpSp) { @@ -28,6 +28,7 @@ return STATUS_SUCCESS; } +static NTSTATUS QueryBinding(PIRP Irp, PIO_STACK_LOCATION IrpSp) { @@ -96,6 +97,8 @@ return Status; } +#if 0 +static NTSTATUS CancelPacketRead(PIRP Irp, PIO_STACK_LOCATION IrpSp) { @@ -129,13 +132,15 @@ return Status; } - +#endif + +static NTSTATUS SetAdapterOid(PIRP Irp, PIO_STACK_LOCATION IrpSp) { PNDISUIO_ADAPTER_CONTEXT AdapterContext = IrpSp->FileObject->FsContext; PNDISUIO_SET_OID SetOidRequest; - NDIS_REQUEST NdisRequest; + NDIS_REQUEST Request; ULONG RequestLength; NDIS_STATUS Status; @@ -143,18 +148,18 @@ SetOidRequest = IrpSp->Parameters.DeviceIoControl.Type3InputBuffer; RequestLength = IrpSp->Parameters.DeviceIoControl.InputBufferLength; - if (QueryOidRequest && RequestLength >= sizeof(NDIS_OID)) + if (SetOidRequest && RequestLength >= sizeof(NDIS_OID)) { /* Setup the NDIS request */ - NdisRequest.RequestType = NdisRequestSetInformation; - NdisRequest.Oid = SetOidRequest->Oid; - NdisRequest.InformationBuffer = SetOidRequest->Data; - NdisRequest.InformationBufferLength = RequestLength - sizeof(NDIS_OID); + Request.RequestType = NdisRequestSetInformation; + Request.DATA.SET_INFORMATION.Oid = SetOidRequest->Oid; + Request.DATA.SET_INFORMATION.InformationBuffer = SetOidRequest->Data; + Request.DATA.SET_INFORMATION.InformationBufferLength = RequestLength - sizeof(NDIS_OID); /* Dispatch the request */ NdisRequest(&Status, AdapterContext->BindingHandle, - &NdisRequest); + &Request); /* Wait for the request */ if (Status == NDIS_STATUS_PENDING) @@ -168,7 +173,7 @@ } /* Return the bytes read */ - if (NT_SUCCESS(Status)) Irp->IoStatus.Information = NdisRequest.BytesRead; + if (NT_SUCCESS(Status)) Irp->IoStatus.Information = Request.DATA.SET_INFORMATION.BytesRead; } else { @@ -183,12 +188,13 @@ return Status; } +static NTSTATUS QueryAdapterOid(PIRP Irp, PIO_STACK_LOCATION IrpSp) { PNDISUIO_ADAPTER_CONTEXT AdapterContext = IrpSp->FileObject->FsContext; PNDISUIO_QUERY_OID QueryOidRequest; - NDIS_REQUEST NdisRequest; + NDIS_REQUEST Request; ULONG RequestLength; NDIS_STATUS Status; @@ -199,15 +205,15 @@ if (QueryOidRequest && RequestLength >= sizeof(NDIS_OID)) { /* Setup the NDIS request */ - NdisRequest.RequestType = NdisRequestQueryInformation; - NdisRequest.Oid = QueryOidRequest->Oid; - NdisRequest.InformationBuffer = QueryOidRequest->Data; - NdisRequest.InformationBufferLength = RequestLength - sizeof(NDIS_OID); + Request.RequestType = NdisRequestQueryInformation; + Request.DATA.QUERY_INFORMATION.Oid = QueryOidRequest->Oid; + Request.DATA.QUERY_INFORMATION.InformationBuffer = QueryOidRequest->Data; + Request.DATA.QUERY_INFORMATION.InformationBufferLength = RequestLength - sizeof(NDIS_OID); /* Dispatch the request */ NdisRequest(&Status, AdapterContext->BindingHandle, - &NdisRequest); + &Request); /* Wait for the request */ if (Status == NDIS_STATUS_PENDING) @@ -221,7 +227,7 @@ } /* Return the bytes written */ - if (NT_SUCCESS(Status)) Irp->IoStatus.Information = NdisRequest.BytesWritten; + if (NT_SUCCESS(Status)) Irp->IoStatus.Information = Request.DATA.QUERY_INFORMATION.BytesWritten; } else { @@ -236,6 +242,7 @@ return Status; } +static NTSTATUS OpenDeviceReadWrite(PIRP Irp, PIO_STACK_LOCATION IrpSp) { @@ -307,7 +314,7 @@ { /* Remove the reference we added */ KeReleaseSpinLock(&AdapterContext->Spinlock, OldIrql); - DereferenceAdapterContext(AdapterContext, NULL); + DereferenceAdapterContextWithOpenEntry(AdapterContext, NULL); Status = STATUS_NO_MEMORY; } } @@ -326,6 +333,8 @@ return Status; } +#if 0 +static NTSTATUS OpenDeviceWrite(PIRP Irp, PIO_STACK_LOCATION IrpSp) { @@ -404,6 +413,7 @@ return Status; } +#endif NTSTATUS NTAPI @@ -420,10 +430,10 @@ { case IOCTL_NDISUIO_OPEN_DEVICE: return OpenDeviceReadWrite(Irp, IrpSp); - +#if 0 case IOCTL_NDISUIO_OPEN_WRITE_DEVICE: return OpenDeviceWrite(Irp, IrpSp); - +#endif case IOCTL_NDISUIO_BIND_WAIT: return WaitForBind(Irp, IrpSp); @@ -461,8 +471,10 @@ switch (IrpSp->Parameters.DeviceIoControl.IoControlCode) { +#if 0 case IOCTL_CANCEL_READ: return CancelPacketRead(Irp, IrpSp); +#endif case IOCTL_NDISUIO_QUERY_OID_VALUE: return QueryAdapterOid(Irp, IrpSp); @@ -472,7 +484,7 @@ Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED; Irp->IoStatus.Information = 0; IoCompleteRequest(Irp, IO_NO_INCREMENT); - break; + return STATUS_NOT_IMPLEMENTED; } } break; Modified: branches/wlan-bringup/drivers/network/ndisuio/main.c URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
============================================================================== --- branches/wlan-bringup/drivers/network/ndisuio/main.c [iso-8859-1] (original) +++ branches/wlan-bringup/drivers/network/ndisuio/main.c [iso-8859-1] Fri Jan 6 05:59:56 2012 @@ -13,12 +13,16 @@ PDEVICE_OBJECT GlobalDeviceObject; NDIS_HANDLE GlobalProtocolHandle; +KSPIN_LOCK GlobalAdapterListLock; +LIST_ENTRY GlobalAdapterList; +NDIS_HANDLE GlobalPacketPoolHandle; +NDIS_HANDLE GlobalBufferPoolHandle; + +NDIS_STRING ProtocolName = RTL_CONSTANT_STRING(L"NDISUIO"); VOID NTAPI NduUnload(PDRIVER_OBJECT DriverObject) -{ - IoDeleteDevice(GlobalDeviceObject); - - DPRINT("NDISUIO: Unloaded\n"); +{ + DPRINT1("NDISUIO: Unloaded\n"); } NTSTATUS @@ -26,8 +30,10 @@ DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath) { - NTSTATUS Status; + NDIS_STATUS Status; NDIS_PROTOCOL_CHARACTERISTICS Chars; + UNICODE_STRING NtDeviceName = RTL_CONSTANT_STRING(NDISUIO_DEVICE_NAME_NT); + UNICODE_STRING DosDeviceName = RTL_CONSTANT_STRING(NDISUIO_DEVICE_NAME_DOS); /* Setup dispatch functions */ DriverObject->MajorFunction[IRP_MJ_CREATE] = NduDispatchCreate; @@ -36,13 +42,17 @@ DriverObject->MajorFunction[IRP_MJ_READ] = NduDispatchRead; DriverObject->MajorFunction[IRP_MJ_WRITE] = NduDispatchWrite; DriverObject->DriverUnload = NduUnload; + + /* Setup global state */ + InitializeListHead(&GlobalAdapterList); + KeInitializeSpinLock(&GlobalAdapterListLock); /* Create the NDISUIO device object */ Status = IoCreateDevice(DriverObject, 0, - NULL, // FIXME - NDISUIO_DEVICE_NAME, + &NtDeviceName, FILE_DEVICE_SECURE_OPEN, + 0, FALSE, &GlobalDeviceObject); if (!NT_SUCCESS(Status)) @@ -51,6 +61,41 @@ return Status; } + /* Create a symbolic link into the DOS devices namespace */ + Status = IoCreateSymbolicLink(&DosDeviceName, &NtDeviceName); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to create symbolic link with status 0x%x\n", Status); + IoDeleteDevice(GlobalDeviceObject); + return Status; + } + + /* Create the buffer pool */ + NdisAllocateBufferPool(&Status, + &GlobalBufferPoolHandle, + 100); + if (Status != NDIS_STATUS_SUCCESS) + { + DPRINT1("Failed to allocate buffer pool with status 0x%x\n", Status); + IoDeleteSymbolicLink(&DosDeviceName); + IoDeleteDevice(GlobalDeviceObject); + return Status; + } + + /* Create the packet pool */ + NdisAllocatePacketPool(&Status, + &GlobalPacketPoolHandle, + 50, + 0); + if (Status != NDIS_STATUS_SUCCESS) + { + DPRINT1("Failed to allocate packet pool with status 0x%x\n", Status); + NdisFreeBufferPool(GlobalBufferPoolHandle); + IoDeleteSymbolicLink(&DosDeviceName); + IoDeleteDevice(GlobalDeviceObject); + return Status; + } + /* Register the protocol with NDIS */ RtlZeroMemory(&Chars, sizeof(Chars)); Chars.MajorNdisVersion = NDIS_MAJOR_VERSION; @@ -62,14 +107,12 @@ Chars.ResetCompleteHandler = NduResetComplete; Chars.RequestCompleteHandler = NduRequestComplete; Chars.ReceiveHandler = NduReceive; - Chars.ReceiveComplete = NduReceiveComplete; + Chars.ReceiveCompleteHandler = NduReceiveComplete; Chars.StatusHandler = NduStatus; Chars.StatusCompleteHandler = NduStatusComplete; - Chars.Name = NULL; //FIXME - Chars.ReceivePacketHandler = NULL; //NduReceivePacket + Chars.Name = ProtocolName; Chars.BindAdapterHandler = NduBindAdapter; Chars.UnbindAdapterHandler = NduUnbindAdapter; - Chars.PnPEventHandler = NduPnPEvent; NdisRegisterProtocol(&Status, &GlobalProtocolHandle, @@ -78,11 +121,14 @@ if (Status != NDIS_STATUS_SUCCESS) { DPRINT1("Failed to register protocol with status 0x%x\n", Status); + NdisFreePacketPool(GlobalPacketPoolHandle); + NdisFreeBufferPool(GlobalBufferPoolHandle); + IoDeleteSymbolicLink(&DosDeviceName); IoDeleteDevice(GlobalDeviceObject); return Status; } - DPRINT("NDISUIO: Loaded\n"); + DPRINT1("NDISUIO: Loaded\n"); return STATUS_SUCCESS; } Modified: branches/wlan-bringup/drivers/network/ndisuio/misc.c URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
============================================================================== --- branches/wlan-bringup/drivers/network/ndisuio/misc.c [iso-8859-1] (original) +++ branches/wlan-bringup/drivers/network/ndisuio/misc.c [iso-8859-1] Fri Jan 6 05:59:56 2012 @@ -15,13 +15,14 @@ AllocateAndChainBuffer(PNDIS_PACKET Packet, PVOID Buffer, ULONG BufferSize, BOOLEAN Front) { NDIS_STATUS Status; + PNDIS_BUFFER NdisBuffer; /* Allocate the NDIS buffer mapping the pool */ NdisAllocateBuffer(&Status, - &Buffer, + &NdisBuffer, GlobalBufferPoolHandle, Buffer, - Length); + BufferSize); if (Status != NDIS_STATUS_SUCCESS) { DPRINT1("No free buffer descriptors\n"); @@ -31,12 +32,12 @@ if (Front) { /* Chain the buffer to front */ - NdisChainBufferAtFront(Packet, Buffer); + NdisChainBufferAtFront(Packet, NdisBuffer); } else { /* Chain the buffer to back */ - NdisChainBufferAtBack(Packet, Buffer); + NdisChainBufferAtBack(Packet, NdisBuffer); } /* Return success */ Modified: branches/wlan-bringup/drivers/network/ndisuio/ndisuio.h URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
============================================================================== --- branches/wlan-bringup/drivers/network/ndisuio/ndisuio.h [iso-8859-1] (original) +++ branches/wlan-bringup/drivers/network/ndisuio/ndisuio.h [iso-8859-1] Fri Jan 6 05:59:56 2012 @@ -9,11 +9,16 @@ #include <wdm.h> #include <ndis.h> -//#include <nuiouser.h> -#include <ndistapi.h> -#include <ndisguid.h> - -struct _NDISUIO_ADAPTER_CONTEXT +#include <nuiouser.h> + +extern PDEVICE_OBJECT GlobalDeviceObject; +extern NDIS_HANDLE GlobalProtocolHandle; +extern LIST_ENTRY GlobalAdapterList; +extern KSPIN_LOCK GlobalAdapterListLock; +extern NDIS_HANDLE GlobalPacketPoolHandle; +extern NDIS_HANDLE GlobalBufferPoolHandle; + +typedef struct _NDISUIO_ADAPTER_CONTEXT { /* Asynchronous completion */ NDIS_STATUS AsyncStatus; @@ -30,6 +35,9 @@ LIST_ENTRY PacketList; KEVENT PacketReadEvent; + /* Device name */ + UNICODE_STRING DeviceName; + /* Global list entry */ LIST_ENTRY ListEntry; @@ -37,7 +45,7 @@ KSPIN_LOCK Spinlock; } NDISUIO_ADAPTER_CONTEXT, *PNDISUIO_ADAPTER_CONTEXT; -struct _NDISUIO_OPEN_ENTRY +typedef struct _NDISUIO_OPEN_ENTRY { /* File object */ PFILE_OBJECT FileObject; @@ -49,7 +57,7 @@ LIST_ENTRY ListEntry; } NDISUIO_OPEN_ENTRY, *PNDISUIO_OPEN_ENTRY; -struct _NDISUIO_PACKET_ENTRY +typedef struct _NDISUIO_PACKET_ENTRY { /* Length of data at the end of the struct */ ULONG PacketLength; @@ -62,7 +70,134 @@ } NDISUIO_PACKET_ENTRY, *PNDISUIO_PACKET_ENTRY; /* NDIS version info */ -#define NDIS_MAJOR_VERISON 5 +#define NDIS_MAJOR_VERSION 5 #define NDIS_MINOR_VERSION 0 +/* createclose.c */ +NTSTATUS +NTAPI +NduDispatchCreate(PDEVICE_OBJECT DeviceObject, + PIRP Irp); + +NTSTATUS +NTAPI +NduDispatchClose(PDEVICE_OBJECT DeviceObject, + PIRP Irp); + +/* ioctl.c */ +NTSTATUS +NTAPI +NduDispatchDeviceControl(PDEVICE_OBJECT DeviceObject, + PIRP Irp); + +/* misc.c */ +NDIS_STATUS +AllocateAndChainBuffer(PNDIS_PACKET Packet, + PVOID Buffer, + ULONG BufferSize, + BOOLEAN Front); + +PNDIS_PACKET +CreatePacketFromPoolBuffer(PVOID Buffer, + ULONG BufferSize); + +VOID +CleanupAndFreePacket(PNDIS_PACKET Packet, + BOOLEAN FreePool); + +PNDISUIO_ADAPTER_CONTEXT +FindAdapterContextByName(PNDIS_STRING DeviceName); + +VOID +ReferenceAdapterContext(PNDISUIO_ADAPTER_CONTEXT AdapterContext); + +VOID +DereferenceAdapterContextWithOpenEntry(PNDISUIO_ADAPTER_CONTEXT AdapterContext, + PNDISUIO_OPEN_ENTRY OpenEntry); + +/* protocol.c */ +VOID +NTAPI +NduOpenAdapterComplete(NDIS_HANDLE ProtocolBindingContext, + NDIS_STATUS Status, + NDIS_STATUS OpenStatus); + +VOID +NTAPI +NduCloseAdapterComplete(NDIS_HANDLE ProtocolBindingContext, + NDIS_STATUS Status); + +VOID +NTAPI +NduSendComplete(NDIS_HANDLE ProtocolBindingContext, + PNDIS_PACKET Packet, + NDIS_STATUS Status); + +VOID +NTAPI +NduTransferDataComplete(NDIS_HANDLE ProtocolBindingContext, + PNDIS_PACKET Packet, + NDIS_STATUS Status, + UINT BytesTransferred); + +VOID +NTAPI +NduResetComplete(NDIS_HANDLE ProtocolBindingContext, + NDIS_STATUS Status); + +VOID +NTAPI +NduRequestComplete(NDIS_HANDLE ProtocolBindingContext, + PNDIS_REQUEST NdisRequest, + NDIS_STATUS Status); + +NDIS_STATUS +NTAPI +NduReceive(NDIS_HANDLE ProtocolBindingContext, + NDIS_HANDLE MacReceiveContext, + PVOID HeaderBuffer, + UINT HeaderBufferSize, + PVOID LookAheadBuffer, + UINT LookaheadBufferSize, + UINT PacketSize); + +VOID +NTAPI +NduReceiveComplete(NDIS_HANDLE ProtocolBindingContext); + +VOID +NTAPI +NduStatus(NDIS_HANDLE ProtocolBindingContext, + NDIS_STATUS GeneralStatus, + PVOID StatusBuffer, + UINT StatusBufferSize); + +VOID +NTAPI +NduStatusComplete(NDIS_HANDLE ProtocolBindingContext); + +VOID +NTAPI +NduBindAdapter(PNDIS_STATUS Status, + NDIS_HANDLE BindContext, + PNDIS_STRING DeviceName, + PVOID SystemSpecific1, + PVOID SystemSpecific2); + +VOID +NTAPI +NduUnbindAdapter(PNDIS_STATUS Status, + NDIS_HANDLE ProtocolBindingContext, + NDIS_HANDLE UnbindContext); + +/* readwrite.c */ +NTSTATUS +NTAPI +NduDispatchRead(PDEVICE_OBJECT DeviceObject, + PIRP Irp); + +NTSTATUS +NTAPI +NduDispatchWrite(PDEVICE_OBJECT DeviceObject, + PIRP Irp); #endif /* __NDISUIO_H */ Modified: branches/wlan-bringup/drivers/network/ndisuio/protocol.c URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
============================================================================== --- branches/wlan-bringup/drivers/network/ndisuio/protocol.c [iso-8859-1] (original) +++ branches/wlan-bringup/drivers/network/ndisuio/protocol.c [iso-8859-1] Fri Jan 6 05:59:56 2012 @@ -113,10 +113,11 @@ UINT PacketSize) { PNDISUIO_ADAPTER_CONTEXT AdapterContext = ProtocolBindingContext; + PNDISUIO_PACKET_ENTRY PacketEntry; PVOID PacketBuffer; PNDIS_PACKET Packet; NDIS_STATUS Status; - ULONG BytesTransferred; + UINT BytesTransferred; /* Allocate a buffer to hold the packet data and header */ PacketBuffer = ExAllocatePool(NonPagedPool, PacketSize); @@ -138,6 +139,7 @@ MacReceiveContext, 0, PacketSize, + Packet, &BytesTransferred); if (Status == NDIS_STATUS_PENDING) { @@ -214,12 +216,14 @@ /* FIXME: Implement status tracking */ } +static NDIS_STATUS UnbindAdapterByContext(PNDISUIO_ADAPTER_CONTEXT AdapterContext) { KIRQL OldIrql; PLIST_ENTRY CurrentOpenEntry; PNDISUIO_OPEN_ENTRY OpenEntry; + NDIS_STATUS Status; /* Remove the adapter context from the global list */ KeAcquireSpinLock(&GlobalAdapterListLock, &OldIrql); @@ -255,27 +259,29 @@ ASSERT(AdapterContext->OpenCount == 0); /* Send the close request */ - NdisCloseAdapter(Status, + NdisCloseAdapter(&Status, AdapterContext->BindingHandle); /* Wait for a pending close */ - if (*Status == NDIS_STATUS_PENDING) + if (Status == NDIS_STATUS_PENDING) { KeWaitForSingleObject(&AdapterContext->AsyncEvent, Executive, KernelMode, FALSE, NULL); - *Status = AdapterContext->AsyncStatus; + Status = AdapterContext->AsyncStatus; } /* Free the context */ ExFreePool(AdapterContext); -} - - + + return Status; +} + +static NDIS_STATUS -BindAdapterByName(PNDIS_STRING DeviceName, PNDISUIO_ADAPTER_CONTEXT *Context) +BindAdapterByName(PNDIS_STRING DeviceName) { NDIS_STATUS OpenErrorStatus; PNDISUIO_ADAPTER_CONTEXT AdapterContext; @@ -298,6 +304,17 @@ InitializeListHead(&AdapterContext->OpenEntryList); AdapterContext->OpenCount = 0; + AdapterContext->DeviceName.Length = + AdapterContext->DeviceName.MaximumLength = DeviceName->Length; + AdapterContext->DeviceName.Buffer = ExAllocatePool(NonPagedPool, DeviceName->Length); + if (!AdapterContext->DeviceName.Buffer) + { + ExFreePool(AdapterContext); + return NDIS_STATUS_RESOURCES; + } + + RtlCopyMemory(AdapterContext->DeviceName.Buffer, DeviceName->Buffer, DeviceName->Length); + /* Send the open request */ NdisOpenAdapter(&Status, &OpenErrorStatus, @@ -325,18 +342,16 @@ /* Check the final status */ if (Status != NDIS_STATUS_SUCCESS) { - DPRINT1("Failed to open adapter for bind with status 0x%x\n", *Status); + DPRINT1("Failed to open adapter for bind with status 0x%x\n", Status); ExFreePool(AdapterContext); - return; + return Status; } /* Add the adapter context to the global list */ ExInterlockedInsertTailList(&GlobalAdapterList, &AdapterContext->ListEntry, &GlobalAdapterListLock); - - /* Return the context */ - *Context = AdapterContext; + return STATUS_SUCCESS; } Modified: branches/wlan-bringup/drivers/network/ndisuio/readwrite.c URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/nd…
============================================================================== --- branches/wlan-bringup/drivers/network/ndisuio/readwrite.c [iso-8859-1] (original) +++ branches/wlan-bringup/drivers/network/ndisuio/readwrite.c [iso-8859-1] Fri Jan 6 05:59:56 2012 @@ -11,10 +11,12 @@ #define NDEBUG #include <debug.h> +static VOID NTAPI ReadIrpCancel(PDEVICE_OBJECT DeviceObject, PIRP Irp) { + PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp); PNDISUIO_ADAPTER_CONTEXT AdapterContext = IrpSp->FileObject->FsContext; PNDISUIO_PACKET_ENTRY PacketEntry; @@ -22,7 +24,7 @@ IoReleaseCancelSpinLock(Irp->CancelIrql); /* Indicate a 0-byte packet on the queue to cancel the read */ - PacketEntry = ExAllocatePool(PagedPool, sizeof(NDISUIO_PACKET_ENTRY)); + PacketEntry = ExAllocatePool(NonPagedPool, sizeof(NDISUIO_PACKET_ENTRY)); if (PacketEntry) { PacketEntry->PacketLength = 0; @@ -131,7 +133,7 @@ /* Copy the packet */ RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer, - &PacketEntry->PacketBuffer[0], + &PacketEntry->PacketData[0], BytesCopied); /* Free the packet entry */ @@ -189,7 +191,7 @@ if (Status == NDIS_STATUS_SUCCESS) BytesCopied = IrpSp->Parameters.Write.Length; - CleanupAndFreePacket(Packet); + CleanupAndFreePacket(Packet, TRUE); } else { Added: branches/wlan-bringup/include/reactos/drivers/ndisuio/nuiouser.h URL:
http://svn.reactos.org/svn/reactos/branches/wlan-bringup/include/reactos/dr…
============================================================================== --- branches/wlan-bringup/include/reactos/drivers/ndisuio/nuiouser.h (added) +++ branches/wlan-bringup/include/reactos/drivers/ndisuio/nuiouser.h [iso-8859-1] Fri Jan 6 05:59:56 2012 @@ -1,0 +1,59 @@ +#ifndef __NUIOUSER_H +#define __NUIOUSER_H + +/* Device names (NT and DOS style) */ +#define NDISUIO_DEVICE_NAME_NT L"\\Device\\Ndisuio" +#define NDISUIO_DEVICE_NAME_DOS L"\\DosDevices\\Ndisuio" + +/* Device name for user apps */ +#define NDISUIO_DEVICE_NAME L"\\\\.\\\\Ndisuio" + +/* Links a file handle with a bound NIC */ +#define IOCTL_NDISUIO_OPEN_DEVICE \ + CTL_CODE(FILE_DEVICE_NETWORK, 0x200, METHOD_BUFFERED, FILE_ANY_ACCESS) + +/* Queries an OID for the bound NIC */ +#define IOCTL_NDISUIO_QUERY_OID_VALUE \ + CTL_CODE(FILE_DEVICE_NETWORK, 0x201, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_NDISUIO_SET_ETHER_TYPE \ + CTL_CODE(FILE_DEVICE_NETWORK, 0x202, METHOD_BUFFERED, FILE_ANY_ACCESS) + +/* Queries binding information during enumeration */ +#define IOCTL_NDISUIO_QUERY_BINDING \ + CTL_CODE(FILE_DEVICE_NETWORK, 0x203, METHOD_BUFFERED, FILE_ANY_ACCESS) + +/* Waits for any pending bindings */ +#define IOCTL_NDISUIO_BIND_WAIT \ + CTL_CODE(FILE_DEVICE_NETWORK, 0x204, METHOD_BUFFERED, FILE_ANY_ACCESS) + +/* Sets an OID for a bound NIC */ +#define IOCTL_NDISUIO_SET_OID_VALUE \ + CTL_CODE(FILE_DEVICE_NETWORK, 0x205, METHOD_BUFFERED, FILE_ANY_ACCESS) + +/* Passed as a parameter to IOCTL_NDISUIO_QUERY_OID_VALUE */ +typedef struct _NDISUIO_QUERY_OID +{ + NDIS_OID Oid; + UCHAR Data[sizeof(ULONG)]; +} NDISUIO_QUERY_OID, *PNDISUIO_QUERY_OID; + +/* Passed as a parameter to IOCTL_NDISUIO_SET_OID_VALUE */ +typedef struct _NDISUIO_SET_OID +{ + NDIS_OID Oid; + UCHAR Data[sizeof(ULONG)]; +} NDISUIO_SET_OID, *PNDISUIO_SET_OID; + +/* Passed as a parameter to IOCTL_NDISUIO_QUERY_BINDING */ +typedef struct _NDISUIO_QUERY_BINDING +{ + ULONG BindingIndex; + ULONG DeviceNameOffset; + ULONG DeviceNameLength; + ULONG DeviceDescrOffset; + ULONG DeviceDescrLength; +} NDISUIO_QUERY_BINDING, *PNDISUIO_QUERY_BINDING; + +#endif + Propchange: branches/wlan-bringup/include/reactos/drivers/ndisuio/nuiouser.h ------------------------------------------------------------------------------ svn:eol-style = native Propchange: branches/wlan-bringup/include/reactos/drivers/ndisuio/nuiouser.h ------------------------------------------------------------------------------ svn:executable = *
12 years, 11 months
1
0
0
0
[rharabien] 54848: [SHELL32] - Fix few leaks and possible buffer overflows in New menu code - Add icons of folder and shortcut to New menu - Display message if file can't be created
by rharabien@svn.reactos.org
Author: rharabien Date: Thu Jan 5 23:04:06 2012 New Revision: 54848 URL:
http://svn.reactos.org/svn/reactos?rev=54848&view=rev
Log: [SHELL32] - Fix few leaks and possible buffer overflows in New menu code - Add icons of folder and shortcut to New menu - Display message if file can't be created Modified: trunk/reactos/dll/win32/shell32/newmenu.cpp trunk/reactos/dll/win32/shell32/newmenu.h Modified: trunk/reactos/dll/win32/shell32/newmenu.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/newmenu.…
============================================================================== --- trunk/reactos/dll/win32/shell32/newmenu.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/newmenu.cpp [iso-8859-1] Thu Jan 5 23:04:06 2012 @@ -23,172 +23,194 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell); -static WCHAR szNew[MAX_PATH]; - CNewMenu::CNewMenu() { - szPath = NULL; - s_SnHead = NULL; - fSite = NULL; -} - + m_wszPath = NULL; + m_pShellItems = NULL; + m_pSite = NULL; +} CNewMenu::~CNewMenu() { UnloadShellItems(); -} - -void CNewMenu::UnloadItem(SHELLNEW_ITEM *item) + if (m_hSubMenu) + CleanupMenu(); +} + +void CNewMenu::CleanupMenu() +{ + INT Count, Index; + MENUITEMINFOW mii; + + /* get item count */ + Count = GetMenuItemCount(m_hSubMenu); + if (Count == -1) + return; + + /* setup menuitem info */ + ZeroMemory(&mii, sizeof(mii)); + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_DATA | MIIM_FTYPE | MIIM_CHECKMARKS; + + for(Index = 0; Index < Count; Index++) + { + if (GetMenuItemInfoW(m_hSubMenu, Index, TRUE, &mii)) + { + if (mii.hbmpChecked) + DeleteObject(mii.hbmpChecked); + } + } +} + +void CNewMenu::UnloadItem(SHELLNEW_ITEM *pItem) { // bail if the item is clearly invalid - if (NULL == item) + if (NULL == pItem) return; - if (NULL != item->szTarget) - free(item->szTarget); - - free(item->szDesc); - free(item->szIcon); - free(item->szExt); - - HeapFree(GetProcessHeap(), 0, item); + if (NULL != pItem->pwszTarget) + free(pItem->pwszTarget); + + free(pItem->pwszDesc); + free(pItem->pwszIcon); + free(pItem->pwszExt); + + HeapFree(GetProcessHeap(), 0, pItem); } void CNewMenu::UnloadShellItems() { SHELLNEW_ITEM *pCurItem; - while (s_SnHead) - { - pCurItem = s_SnHead; - s_SnHead = s_SnHead->Next; + while (m_pShellItems) + { + pCurItem = m_pShellItems; + m_pShellItems = m_pShellItems->pNext; UnloadItem(pCurItem); } - - s_SnHead = NULL; -} - -static -BOOL -GetKeyDescription(LPWSTR szKeyName, LPWSTR szResult) +} + +BOOL CNewMenu::GetKeyDescription(LPCWSTR pwszExt, LPWSTR pwszResult) { HKEY hKey; - DWORD dwDesc, dwError; - WCHAR szDesc[100]; - - TRACE("GetKeyDescription: keyname %s\n", debugstr_w(szKeyName)); - - if (RegOpenKeyExW(HKEY_CLASSES_ROOT, szKeyName, 0, KEY_READ | KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS) + DWORD cbDesc; + WCHAR wszDesc[100]; + LONG Result; + + TRACE("GetKeyDescription: keyname %s\n", debugstr_w(pwszExt)); + + if (RegOpenKeyExW(HKEY_CLASSES_ROOT, pwszExt, 0, KEY_READ, &hKey) != ERROR_SUCCESS) return FALSE; - if (RegLoadMUIStringW(hKey, L"\\FriendlyTypeName", szResult, MAX_PATH, &dwDesc, 0, NULL) == ERROR_SUCCESS) - { - TRACE("result %s\n", debugstr_w(szResult)); + /* Get user friendly name */ + if (RegLoadMUIStringW(hKey, L"\\FriendlyTypeName", pwszResult, MAX_PATH, &cbDesc, 0, NULL) == ERROR_SUCCESS) + { + TRACE("result %s\n", debugstr_w(pwszResult)); RegCloseKey(hKey); return TRUE; } - /* fetch default value */ - dwDesc = sizeof(szDesc); - dwError = RegGetValueW(hKey, NULL, NULL, RRF_RT_REG_SZ, NULL, szDesc, &dwDesc); - if(dwError == ERROR_SUCCESS) - { - if (wcsncmp(szKeyName, szDesc, dwDesc / sizeof(WCHAR))) + + /* Fetch default value */ + cbDesc = sizeof(wszDesc); + Result = RegGetValueW(hKey, NULL, L"", RRF_RT_REG_SZ, NULL, wszDesc, &cbDesc); + if(Result == ERROR_SUCCESS) + { + if (wcscmp(pwszExt, wszDesc) != 0) { /* recurse for to a linked key */ - if (!GetKeyDescription(szDesc, szResult)) + if (!GetKeyDescription(wszDesc, pwszResult)) { /* use description */ - wcscpy(szResult, szDesc); + wcscpy(pwszResult, wszDesc); } } else { /* use default value as description */ - wcscpy(szResult, szDesc); + wcscpy(pwszResult, wszDesc); } } else { /* registry key w/o default key?? */ - TRACE("RegGetValue failed with %x\n", dwError); - wcscpy(szResult, szKeyName); + ERR("RegGetValue failed with %x\n", Result); + wcscpy(pwszResult, pwszExt); } RegCloseKey(hKey); return TRUE; } -CNewMenu::SHELLNEW_ITEM *CNewMenu::LoadItem(LPWSTR szKeyName) +CNewMenu::SHELLNEW_ITEM *CNewMenu::LoadItem(LPCWSTR pwszExt) { HKEY hKey; DWORD dwIndex = 0; - WCHAR szName[MAX_PATH]; - WCHAR szCommand[MAX_PATH]; - WCHAR szDesc[MAX_PATH] = L""; - WCHAR szIcon[MAX_PATH] = L""; - DWORD dwName, dwCommand; - LONG result; + WCHAR wszBuf[MAX_PATH]; + WCHAR wszCommand[MAX_PATH]; + WCHAR wszDesc[MAX_PATH] = L""; + WCHAR wszIcon[MAX_PATH] = L""; + DWORD cchName, cbCommand; SHELLNEW_ITEM *pNewItem = NULL; - wcscpy(szName, szKeyName); - GetKeyDescription(szKeyName, szDesc); - wcscat(szName, L"\\ShellNew"); - result = RegOpenKeyExW(HKEY_CLASSES_ROOT, szName, 0, KEY_READ, &hKey); - - TRACE("LoadItem dwName %d keyname %s szName %s szDesc %s szIcon %s\n", dwName, debugstr_w(szKeyName), debugstr_w(szName), debugstr_w(szDesc), debugstr_w(szIcon)); - - if (result != ERROR_SUCCESS) + StringCbPrintfW(wszBuf, sizeof(wszBuf), L"%s\\ShellNew", pwszExt); + + TRACE("LoadItem Keyname %s Name %s\n", debugstr_w(pwszExt), debugstr_w(wszBuf)); + + if (RegOpenKeyExW(HKEY_CLASSES_ROOT, wszBuf, 0, KEY_READ, &hKey) != ERROR_SUCCESS) { TRACE("Failed to open key\n"); return NULL; } - do - { - dwName = MAX_PATH; - dwCommand = MAX_PATH; - result = RegEnumValueW(hKey, dwIndex, szName, &dwName, NULL, NULL, (LPBYTE)szCommand, &dwCommand); - if (result == ERROR_SUCCESS) - { - SHELLNEW_TYPE type = SHELLNEW_TYPE_INVALID; - LPWSTR szTarget = szCommand; - - TRACE("szName %s szCommand %s\n", debugstr_w(szName), debugstr_w(szCommand)); - - if (!wcsicmp(szName, L"Command")) - type = SHELLNEW_TYPE_COMMAND; - else if (!wcsicmp(szName, L"Data")) - type = SHELLNEW_TYPE_DATA; - else if (!wcsicmp(szName, L"FileName")) - type = SHELLNEW_TYPE_FILENAME; - else if (!wcsicmp(szName, L"NullFile")) - { - type = SHELLNEW_TYPE_NULLFILE; - szTarget = NULL; - } - - if (type != SHELLNEW_TYPE_INVALID) - { - pNewItem = (SHELLNEW_ITEM *)HeapAlloc(GetProcessHeap(), 0, sizeof(SHELLNEW_ITEM)); - if (!pNewItem) - break; - - pNewItem->Type = type; - if (szTarget) - pNewItem->szTarget = _wcsdup(szTarget); - else - pNewItem->szTarget = NULL; - - pNewItem->szDesc = _wcsdup(szDesc); - pNewItem->szIcon = _wcsdup(szIcon); - pNewItem->szExt = _wcsdup(szKeyName); - pNewItem->Next = NULL; + /* Find first valid value */ + while (TRUE) + { + cchName = _countof(wszBuf); + cbCommand = sizeof(wszCommand); + if (RegEnumValueW(hKey, dwIndex++, wszBuf, &cchName, NULL, NULL, (LPBYTE)wszCommand, &cbCommand) != ERROR_SUCCESS) + break; + + SHELLNEW_TYPE Type = SHELLNEW_TYPE_INVALID; + LPWSTR pwszTarget = wszCommand; + + TRACE("wszBuf %s wszCommand %s\n", debugstr_w(wszBuf), debugstr_w(wszCommand)); + + /* Handle different types */ + if (!wcsicmp(wszBuf, L"Command")) + Type = SHELLNEW_TYPE_COMMAND; + else if (!wcsicmp(wszBuf, L"Data")) + Type = SHELLNEW_TYPE_DATA; + else if (!wcsicmp(wszBuf, L"FileName")) + Type = SHELLNEW_TYPE_FILENAME; + else if (!wcsicmp(wszBuf, L"NullFile")) + { + Type = SHELLNEW_TYPE_NULLFILE; + pwszTarget = NULL; + } + + /* Create new item */ + if (Type != SHELLNEW_TYPE_INVALID) + { + pNewItem = (SHELLNEW_ITEM *)HeapAlloc(GetProcessHeap(), 0, sizeof(SHELLNEW_ITEM)); + if (!pNewItem) break; - } - } - dwIndex++; - } while(result != ERROR_NO_MORE_ITEMS); + + pNewItem->Type = Type; + if (pwszTarget) + pNewItem->pwszTarget = _wcsdup(pwszTarget); + else + pNewItem->pwszTarget = NULL; + + GetKeyDescription(pwszExt, wszDesc); + pNewItem->pwszDesc = _wcsdup(wszDesc); + pNewItem->pwszIcon = _wcsdup(wszIcon); + pNewItem->pwszExt = _wcsdup(pwszExt); + pNewItem->pNext = NULL; + break; + } + } + RegCloseKey(hKey); return pNewItem; } @@ -196,71 +218,87 @@ BOOL CNewMenu::LoadShellNewItems() { - DWORD dwIndex; - WCHAR szName[MAX_PATH]; - LONG result; + DWORD dwIndex = 0; + WCHAR wszName[MAX_PATH]; SHELLNEW_ITEM *pNewItem; SHELLNEW_ITEM *pCurItem = NULL; - /* insert do new folder action */ - if (!LoadStringW(shell32_hInstance, FCIDM_SHVIEW_NEW, szNew, sizeof(szNew) / sizeof(WCHAR))) - szNew[0] = 0; - + /* If there are any unload them */ UnloadShellItems(); - dwIndex = 0; - do - { - result = RegEnumKeyW(HKEY_CLASSES_ROOT, dwIndex, szName, MAX_PATH); - if (result == ERROR_SUCCESS) - { - pNewItem = LoadItem(szName); - if (pNewItem) - { - if (!wcsicmp(pNewItem->szExt, L".lnk")) + /* Enumerate all extesions */ + while (RegEnumKeyW(HKEY_CLASSES_ROOT, dwIndex++, wszName, _countof(wszName)) == ERROR_SUCCESS) + { + if (wszName[0] != '.' || wcsicmp(wszName, L".lnk") == 0) + continue; + + pNewItem = LoadItem(wszName); + if (pNewItem) + { + if (!wcsicmp(pNewItem->pwszExt, L".lnk")) + { + /* FIXME: Should we load them? + Add lnk handlers to begin of the list */ + if (m_pShellItems) { - if (s_SnHead) - { - pNewItem->Next = s_SnHead; - s_SnHead = pNewItem; - } - else - { - s_SnHead = pCurItem = pNewItem; - } + pNewItem->pNext = m_pShellItems; + m_pShellItems = pNewItem; } else + m_pShellItems = pCurItem = pNewItem; + } + else + { + /* Add at the end of list */ + if (pCurItem) { - if (pCurItem) - { - pCurItem->Next = pNewItem; - pCurItem = pNewItem; - } - else - { - pCurItem = s_SnHead = pNewItem; - } + pCurItem->pNext = pNewItem; + pCurItem = pNewItem; } - } - } - dwIndex++; - } while(result != ERROR_NO_MORE_ITEMS); - - if (s_SnHead == NULL) + else + pCurItem = m_pShellItems = pNewItem; + } + } + } + + if (m_pShellItems == NULL) return FALSE; else return TRUE; } +static HBITMAP IconToBitmap(HICON hIcon) +{ + HDC hdc, hdcScr; + HBITMAP hbm, hbmOld; + RECT rc; + + hdcScr = GetDC(NULL); + hdc = CreateCompatibleDC(hdcScr); + SetRect(&rc, 0, 0, GetSystemMetrics(SM_CXMENUCHECK), GetSystemMetrics(SM_CYMENUCHECK)); + hbm = CreateCompatibleBitmap(hdcScr, rc.right, rc.bottom); + ReleaseDC(NULL, hdcScr); + + hbmOld = (HBITMAP)SelectObject(hdc, hbm); + FillRect(hdc, &rc, (HBRUSH)(COLOR_MENU + 1)); + if (!DrawIconEx(hdc, 0, 0, hIcon, rc.right, rc.bottom, 0, NULL, DI_NORMAL)) + ERR("DrawIcon failed: %x\n", GetLastError()); + SelectObject(hdc, hbmOld); + + DeleteDC(hdc); + + return hbm; +} + UINT -CNewMenu::InsertShellNewItems(HMENU hMenu, UINT idFirst, UINT idMenu) +CNewMenu::InsertShellNewItems(HMENU hMenu, UINT idCmdFirst, UINT Pos) { MENUITEMINFOW mii; - SHELLNEW_ITEM *pCurItem; - UINT i; - WCHAR szBuffer[MAX_PATH]; - - if (s_SnHead == NULL) + WCHAR wszBuf[256]; + HICON hIcon; + UINT idCmd = idCmdFirst; + + if (m_pShellItems == NULL) { if (!LoadShellNewItems()) return 0; @@ -269,334 +307,279 @@ ZeroMemory(&mii, sizeof(mii)); mii.cbSize = sizeof(mii); - /* insert do new shortcut action */ - if (!LoadStringW(shell32_hInstance, FCIDM_SHVIEW_NEWFOLDER, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]))) - szBuffer[0] = 0; - szBuffer[MAX_PATH-1] = 0; + /* Insert new folder action */ + if (!LoadStringW(shell32_hInstance, FCIDM_SHVIEW_NEWFOLDER, wszBuf, _countof(wszBuf))) + wszBuf[0] = 0; mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE | MIIM_DATA; mii.fType = MFT_STRING; - mii.dwTypeData = szBuffer; + mii.dwTypeData = wszBuf; mii.cch = wcslen(mii.dwTypeData); - mii.wID = idFirst++; - InsertMenuItemW(hMenu, idMenu++, TRUE, &mii); - - /* insert do new shortcut action */ - if (!LoadStringW(shell32_hInstance, FCIDM_SHVIEW_NEWLINK, szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]))) - szBuffer[0] = 0; - szBuffer[MAX_PATH-1] = 0; - mii.dwTypeData = szBuffer; + mii.wID = idCmd; + hIcon = (HICON)LoadImage(shell32_hInstance, MAKEINTRESOURCE(IDI_SHELL_FOLDER), IMAGE_ICON, 0, 0, 0); + if (hIcon) + { + mii.fMask |= MIIM_CHECKMARKS; + mii.hbmpChecked = mii.hbmpUnchecked = IconToBitmap(hIcon); + } + if (InsertMenuItemW(hMenu, Pos++, TRUE, &mii)) + ++idCmd; + + /* Insert new shortcut action */ + if (!LoadStringW(shell32_hInstance, FCIDM_SHVIEW_NEWLINK, wszBuf, _countof(wszBuf))) + wszBuf[0] = 0; + mii.dwTypeData = wszBuf; mii.cch = wcslen(mii.dwTypeData); - mii.wID = idFirst++; - InsertMenuItemW(hMenu, idMenu++, TRUE, &mii); - - /* insert seperator for custom new action */ + mii.wID = idCmdFirst++; + hIcon = (HICON)LoadImage(shell32_hInstance, MAKEINTRESOURCE(IDI_SHELL_SHORTCUT), IMAGE_ICON, 0, 0, 0); + if (hIcon) + { + mii.fMask |= MIIM_CHECKMARKS; + mii.hbmpChecked = mii.hbmpUnchecked = IconToBitmap(hIcon); + } + if (InsertMenuItemW(hMenu, Pos++, TRUE, &mii)) + ++idCmd; + + /* Insert seperator for custom new action */ mii.fMask = MIIM_TYPE | MIIM_ID; mii.fType = MFT_SEPARATOR; mii.wID = -1; - InsertMenuItemW(hMenu, idMenu++, TRUE, &mii); - + InsertMenuItemW(hMenu, Pos++, TRUE, &mii); + + /* Insert rest of items */ mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE | MIIM_DATA; /* - * FIXME + * FIXME: * implement loading of icons * and using MFT_OWNERDRAWN */ mii.fType = MFT_STRING; mii.fState = MFS_ENABLED; - pCurItem = s_SnHead; - i = 0; - - while(pCurItem) - { - if (i >= 1) - { - TRACE("szDesc %s\n", debugstr_w(pCurItem->szDesc)); - mii.dwTypeData = pCurItem->szDesc; - mii.cch = wcslen(mii.dwTypeData); - mii.wID = idFirst++; - InsertMenuItemW(hMenu, idMenu++, TRUE, &mii); - } - pCurItem = pCurItem->Next; - i++; - } - return (i + 2); + SHELLNEW_ITEM *pCurItem = m_pShellItems; + while (pCurItem) + { + TRACE("szDesc %s\n", debugstr_w(pCurItem->pwszDesc)); + mii.dwTypeData = pCurItem->pwszDesc; + mii.cch = wcslen(mii.dwTypeData); + mii.wID = idCmd; + if (InsertMenuItemW(hMenu, Pos++, TRUE, &mii)) + ++idCmd; + pCurItem = pCurItem->pNext; + } + + return idCmd - idCmdFirst; } HRESULT CNewMenu::DoShellNewCmd(LPCMINVOKECOMMANDINFO lpcmi, IShellView *psv) { - SHELLNEW_ITEM *pCurItem = s_SnHead; - IPersistFolder3 * psf; + SHELLNEW_ITEM *pCurItem = m_pShellItems; LPITEMIDLIST pidl; STRRET strTemp; - WCHAR szTemp[MAX_PATH]; - WCHAR szBuffer[MAX_PATH]; - WCHAR szPath[MAX_PATH]; - STARTUPINFOW sInfo; - PROCESS_INFORMATION pi; - UINT i, target; - HANDLE hFile; - DWORD dwWritten, dwError; - CComPtr<IFolderView> folderView; - CComPtr<IShellFolder> parentFolder; - HRESULT hResult; - - i = 1; - target = LOWORD(lpcmi->lpVerb); - - while(pCurItem) - { - if (i == target) + WCHAR wszBuf[MAX_PATH]; + WCHAR wszPath[MAX_PATH]; + UINT i, idCmd = LOWORD(lpcmi->lpVerb); + CComPtr<IFolderView> pFolderView; + CComPtr<IShellFolder> pParentFolder; + CComPtr<IPersistFolder3> psf; + HRESULT hr; + + /* Find shell new item */ + for (i = 1; pCurItem; ++i) + { + if (i == idCmd) break; - pCurItem = pCurItem->Next; - i++; + pCurItem = pCurItem->pNext; } if (!pCurItem) return E_UNEXPECTED; - - //if (fSite == NULL) + //if (m_pSite == NULL) // return E_FAIL; - hResult = IUnknown_QueryService(psv, SID_IFolderView, IID_IFolderView, (void **)&folderView); - if (FAILED(hResult)) - return hResult; - hResult = folderView->GetFolder(IID_IShellFolder, (void **)&parentFolder); - if (FAILED(hResult)) - return hResult; - - if (parentFolder->QueryInterface(IID_IPersistFolder2, (LPVOID*)&psf) != S_OK) + + /* Get current folder */ + hr = IUnknown_QueryService(psv, SID_IFolderView, IID_IFolderView, (void **)&pFolderView); + if (FAILED(hr)) + return hr; + + hr = pFolderView->GetFolder(IID_IShellFolder, (void **)&pParentFolder); + if (FAILED(hr)) + return hr; + + if (pParentFolder->QueryInterface(IID_IPersistFolder2, (LPVOID*)&psf) != S_OK) { ERR("Failed to get interface IID_IPersistFolder2\n"); return E_FAIL; } + if (psf->GetCurFolder(&pidl) != S_OK) { ERR("IPersistFolder2_GetCurFolder failed\n"); return E_FAIL; } - if (parentFolder == NULL || parentFolder->GetDisplayNameOf(pidl, SHGDN_FORPARSING, &strTemp) != S_OK) + /* Get folder path */ + if (pParentFolder == NULL || pParentFolder->GetDisplayNameOf(pidl, SHGDN_FORPARSING, &strTemp) != S_OK) { ERR("IShellFolder_GetDisplayNameOf failed\n"); return E_FAIL; } - StrRetToBufW(&strTemp, pidl, szPath, MAX_PATH); - - switch(pCurItem->Type) + StrRetToBufW(&strTemp, pidl, wszPath, _countof(wszPath)); + + switch (pCurItem->Type) { case SHELLNEW_TYPE_COMMAND: { - LPWSTR ptr; - LPWSTR szCmd; - - if (!ExpandEnvironmentStringsW(pCurItem->szTarget, szBuffer, MAX_PATH)) + LPWSTR Ptr, pwszCmd; + WCHAR wszTemp[MAX_PATH]; + STARTUPINFOW si; + PROCESS_INFORMATION pi; + + if (!ExpandEnvironmentStringsW(pCurItem->pwszTarget, wszBuf, MAX_PATH)) { TRACE("ExpandEnvironmentStrings failed\n"); break; } - ptr = wcsstr(szBuffer, L"%1"); - if (ptr) - { - ptr[1] = 's'; - swprintf(szTemp, szBuffer, szPath); - ptr = szTemp; + /* Expand command parameter, FIXME: there can be more modifiers */ + Ptr = wcsstr(wszBuf, L"%1"); + if (Ptr) + { + Ptr[1] = 's'; + StringCbPrintfW(wszTemp, sizeof(wszTemp), wszBuf, wszPath); + pwszCmd = wszTemp; } else - { - ptr = szBuffer; - } - - ZeroMemory(&sInfo, sizeof(sInfo)); - sInfo.cb = sizeof(sInfo); - szCmd = _wcsdup(ptr); - if (!szCmd) - break; - if (CreateProcessW(NULL, szCmd, NULL, NULL, FALSE, 0, NULL, NULL, &sInfo, &pi)) - { - CloseHandle( pi.hProcess ); - CloseHandle( pi.hThread ); - } - free(szCmd); + pwszCmd = wszBuf; + + /* Create process */ + ZeroMemory(&si, sizeof(si)); + si.cb = sizeof(si); + if (CreateProcessW(NULL, pwszCmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) + { + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); + } else + ERR("Failed to create process\n"); break; } case SHELLNEW_TYPE_DATA: case SHELLNEW_TYPE_FILENAME: case SHELLNEW_TYPE_NULLFILE: { - i = 2; - - PathAddBackslashW(szPath); - wcscat(szPath, szNew); - wcscat(szPath, L" "); - wcscat(szPath, pCurItem->szDesc); - wcscpy(szBuffer, szPath); - wcscat(szBuffer, pCurItem->szExt); - do - { - hFile = CreateFileW(szBuffer, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); + BOOL bSuccess = TRUE; + LPWSTR pwszFilename = NULL; + size_t cchFilenameMax = 0; + + /* Build new file name */ + LoadStringW(shell32_hInstance, FCIDM_SHVIEW_NEW, wszBuf, _countof(wszBuf)); + StringCchCatExW(wszPath, _countof(wszPath), L"\\", &pwszFilename, &cchFilenameMax, 0); + StringCchPrintfW(pwszFilename, cchFilenameMax, L"%s %s%s", wszBuf, pCurItem->pwszDesc, pCurItem->pwszExt); + + /* Find unique name */ + for (i = 2; PathFileExistsW(wszPath); ++i) + { + StringCchPrintfW(pwszFilename, cchFilenameMax, L"%s %s (%u)%s", wszBuf, pCurItem->pwszDesc, i, pCurItem->pwszExt); + TRACE("New Filename %ls\n", pwszFilename); + } + + if (pCurItem->Type == SHELLNEW_TYPE_DATA || pCurItem->Type == SHELLNEW_TYPE_NULLFILE) + { + /* Create new file */ + HANDLE hFile = CreateFileW(wszPath, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile != INVALID_HANDLE_VALUE) - break; - dwError = GetLastError(); - - TRACE("FileName %s szBuffer %s i %u error %x\n", debugstr_w(szBuffer), debugstr_w(szPath), i, dwError); - swprintf(szBuffer, L"%s (%d)%s", szPath, i, pCurItem->szExt); - i++; - } while(hFile == INVALID_HANDLE_VALUE && dwError == ERROR_FILE_EXISTS); - - if (hFile == INVALID_HANDLE_VALUE) - return E_FAIL; - - if (pCurItem->Type == SHELLNEW_TYPE_DATA) - { - i = WideCharToMultiByte(CP_ACP, 0, pCurItem->szTarget, -1, (LPSTR)szTemp, MAX_PATH * 2, NULL, NULL); - if (i) { - WriteFile(hFile, (LPCVOID)szTemp, i, &dwWritten, NULL); + if (pCurItem->Type == SHELLNEW_TYPE_DATA) + { + /* Write a content */ + CHAR szTemp[256]; + DWORD cbWritten, cbTemp = WideCharToMultiByte(CP_ACP, 0, pCurItem->pwszTarget, -1, szTemp, _countof(szTemp), NULL, NULL); + if (cbTemp) + WriteFile(hFile, (LPCVOID)szTemp, cbTemp, &cbWritten, NULL); + else + ERR("WideCharToMultiByte failed\n"); + } + + /* Close file now */ + CloseHandle(hFile); } - } - CloseHandle(hFile); - if (pCurItem->Type == SHELLNEW_TYPE_FILENAME) - { - if (!CopyFileW(pCurItem->szTarget, szBuffer, FALSE)) - break; - } - TRACE("Notifying fs %s\n", debugstr_w(szBuffer)); - SHChangeNotify(SHCNE_CREATE, SHCNF_PATHW, (LPCVOID)szBuffer, NULL); + else bSuccess = FALSE; + } + else if (pCurItem->Type == SHELLNEW_TYPE_FILENAME) + { + /* Copy file */ + bSuccess = CopyFileW(pCurItem->pwszTarget, wszPath, FALSE); + } + + /* Show message if we failed */ + if (bSuccess) + { + TRACE("Notifying fs %s\n", debugstr_w(wszPath)); + SHChangeNotify(SHCNE_CREATE, SHCNF_PATHW, (LPCVOID)wszPath, NULL); + } + else + { + StringCbPrintfW(wszBuf, sizeof(wszBuf), L"Cannot create file: %s", pwszFilename); + MessageBoxW(NULL, wszBuf, L"Cannot create file", MB_OK|MB_ICONERROR); // FIXME + } break; - case SHELLNEW_TYPE_INVALID: - break; - } + } + case SHELLNEW_TYPE_INVALID: + ERR("Invalid type\n"); + break; } return S_OK; } -/************************************************************************** -* DoMeasureItem -*/ -HRESULT -CNewMenu::DoMeasureItem(HWND hWnd, MEASUREITEMSTRUCT * lpmis) -{ - SHELLNEW_ITEM *pCurItem; - SHELLNEW_ITEM *pItem; - UINT i; - HDC hDC; - SIZE size; - - TRACE("DoMeasureItem entered with id %x\n", lpmis->itemID); - - pCurItem = s_SnHead; - - i = 1; - pItem = NULL; - while(pCurItem) - { - if (i == lpmis->itemID) - { - pItem = pCurItem; - break; - } - pCurItem = pCurItem->Next; - i++; - } - - if (!pItem) - { - TRACE("DoMeasureItem no item found\n"); - return E_FAIL; - } - hDC = GetDC(hWnd); - GetTextExtentPoint32W(hDC, pCurItem->szDesc, wcslen(pCurItem->szDesc), &size); - lpmis->itemWidth = size.cx + 32; - lpmis->itemHeight = max(size.cy, 20); - ReleaseDC (hWnd, hDC); - return S_OK; -} -/************************************************************************** -* DoDrawItem -*/ -HRESULT -CNewMenu::DoDrawItem(HWND hWnd, DRAWITEMSTRUCT * drawItem) -{ - SHELLNEW_ITEM *pCurItem; - SHELLNEW_ITEM *pItem; - UINT i; - pCurItem = s_SnHead; - - TRACE("DoDrawItem entered with id %x\n", drawItem->itemID); - - i = 1; - pItem = NULL; - while(pCurItem) - { - if (i == drawItem->itemID) - { - pItem = pCurItem; - break; - } - pCurItem = pCurItem->Next; - i++; - } - - if (!pItem) - return E_FAIL; - - drawItem->rcItem.left += 20; - - DrawTextW(drawItem->hDC, pCurItem->szDesc, wcslen(pCurItem->szDesc), &drawItem->rcItem, 0); - return S_OK; -} - -/************************************************************************** -* DoNewFolder -*/ -void CNewMenu::DoNewFolder( - IShellView *psv) -{ - ISFHelper *psfhlp; + +void CNewMenu::CreateNewFolder(IShellView *psv) +{ WCHAR wszName[MAX_PATH]; - CComPtr<IFolderView> folderView; - CComPtr<IShellFolder> parentFolder; - HRESULT hResult; - - //if (fSite == NULL) + CComPtr<ISFHelper> psfhlp; + CComPtr<IFolderView> pFolderView; + CComPtr<IShellFolder> pParentFolder; + HRESULT hr; + + //if (m_pSite == NULL) // return; - hResult = IUnknown_QueryService(psv, SID_IFolderView, IID_IFolderView, (void **)&folderView); - if (FAILED(hResult)) + + /* Get current folder */ + hr = IUnknown_QueryService(psv, SID_IFolderView, IID_IFolderView, (void **)&pFolderView); + if (FAILED(hr)) return; - hResult = folderView->GetFolder(IID_IShellFolder, (void **)&parentFolder); - if (FAILED(hResult)) + + hr = pFolderView->GetFolder(IID_IShellFolder, (void **)&pParentFolder); + if (FAILED(hr)) return; - parentFolder->QueryInterface(IID_ISFHelper, (LPVOID*)&psfhlp); - if (psfhlp) + hr = pParentFolder->QueryInterface(IID_ISFHelper, (LPVOID*)&psfhlp); + if (SUCCEEDED(hr)) { LPITEMIDLIST pidl; - if (psfhlp->GetUniqueName(wszName, MAX_PATH) != S_OK) + /* Get unique name and create a folder */ + if (psfhlp->GetUniqueName(wszName, _countof(wszName)) != S_OK) return; if (psfhlp->AddFolder(0, wszName, &pidl) != S_OK) + { + WCHAR wszBuf[256]; + StringCbPrintfW(wszBuf, sizeof(wszBuf), L"Cannot create folder: %s", wszName); + MessageBoxW(NULL, wszBuf, L"Cannot create folder", MB_OK|MB_ICONERROR); return; - - if(psv) - { - psv->Refresh(); - /* if we are in a shellview do labeledit */ - psv->SelectItem( - pidl, (SVSI_DESELECTOTHERS | SVSI_EDIT | SVSI_ENSUREVISIBLE - | SVSI_FOCUSED | SVSI_SELECT)); - psv->Refresh(); - } + } + + /* Do a labeledit */ + psv->Refresh(); + psv->SelectItem(pidl, SVSI_DESELECTOTHERS | SVSI_EDIT | SVSI_ENSUREVISIBLE | + SVSI_FOCUSED | SVSI_SELECT); + SHFree(pidl); - - psfhlp->Release(); } } HRESULT STDMETHODCALLTYPE CNewMenu::SetSite(IUnknown *pUnkSite) { - fSite = pUnkSite; + m_pSite = pUnkSite; return S_OK; } @@ -604,52 +587,51 @@ { if (ppvSite == NULL) return E_POINTER; - *ppvSite = fSite; - if (fSite != NULL) - fSite->AddRef(); + *ppvSite = m_pSite; + if (m_pSite != NULL) + m_pSite->AddRef(); return S_OK; } HRESULT WINAPI -CNewMenu::QueryContextMenu(HMENU hmenu, +CNewMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) { - WCHAR szBuffer[200]; + WCHAR wszNew[200]; MENUITEMINFOW mii; - HMENU hSubMenu; - int id = 1; + UINT cItems = 0; TRACE("%p %p %u %u %u %u\n", this, - hmenu, indexMenu, idCmdFirst, idCmdLast, uFlags ); - - if (!LoadStringW(shell32_hInstance, FCIDM_SHVIEW_NEW, szBuffer, _countof(szBuffer))) - szBuffer[0] = 0; - - hSubMenu = CreateMenu(); - memset( &mii, 0, sizeof(mii) ); - mii.cbSize = sizeof (mii); + hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags); + + if (!LoadStringW(shell32_hInstance, FCIDM_SHVIEW_NEW, wszNew, _countof(wszNew))) + return E_FAIL; + + m_hSubMenu = CreateMenu(); + memset(&mii, 0, sizeof(mii)); + mii.cbSize = sizeof(mii); mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE; mii.fType = MFT_STRING; - mii.wID = idCmdFirst + id++; - mii.dwTypeData = szBuffer; + mii.wID = -1; + mii.dwTypeData = wszNew; mii.cch = wcslen(mii.dwTypeData); mii.fState = MFS_ENABLED; - if (hSubMenu) - { - id += InsertShellNewItems(hSubMenu, idCmdFirst, 0); + if (m_hSubMenu) + { + cItems = InsertShellNewItems(m_hSubMenu, idCmdFirst, 0); mii.fMask |= MIIM_SUBMENU; - mii.hSubMenu = hSubMenu; - } - - if (!InsertMenuItemW(hmenu, indexMenu, TRUE, &mii)) + mii.hSubMenu = m_hSubMenu; + } + + if (!InsertMenuItemW(hMenu, indexMenu, TRUE, &mii)) return E_FAIL; - return MAKE_HRESULT(SEVERITY_SUCCESS, 0, id); + return MAKE_HRESULT(SEVERITY_SUCCESS, 0, cItems); } HRESULT @@ -660,24 +642,21 @@ LPSHELLVIEW lpSV = NULL; HRESULT hr; - if((lpSB = (LPSHELLBROWSER)SendMessageA(lpici->hwnd, CWM_GETISHELLBROWSER, 0, 0))) - { + lpSB = (LPSHELLBROWSER)SendMessageA(lpici->hwnd, CWM_GETISHELLBROWSER, 0, 0); + if (lpSB) lpSB->QueryActiveShellView(&lpSV); - } if (LOWORD(lpici->lpVerb) == 0) { - DoNewFolder(lpSV); + CreateNewFolder(lpSV); return S_OK; } hr = DoShellNewCmd(lpici, lpSV); if (SUCCEEDED(hr) && lpSV) - { lpSV->Refresh(); - } - - TRACE("INewItem_IContextMenu_fnInvokeCommand %x\n", hr); + + TRACE("CNewMenu::InvokeCommand %x\n", hr); return hr; } @@ -685,7 +664,7 @@ WINAPI CNewMenu::GetCommandString(UINT_PTR idCmd, UINT uType, - UINT* pwReserved, + UINT *pwReserved, LPSTR pszName, UINT cchMax) { @@ -701,29 +680,13 @@ WPARAM wParam, LPARAM lParam) { - DRAWITEMSTRUCT *lpids = (DRAWITEMSTRUCT*) lParam; - MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*) lParam; - - TRACE("INewItem_IContextMenu_fnHandleMenuMsg (%p)->(msg=%x wp=%lx lp=%lx)\n", this, uMsg, wParam, lParam); - - switch(uMsg) - { - case WM_MEASUREITEM: - return DoMeasureItem((HWND)wParam, lpmis); - break; - case WM_DRAWITEM: - return DoDrawItem((HWND)wParam, lpids); - break; - } + UNIMPLEMENTED; return S_OK; - - return E_UNEXPECTED; } HRESULT WINAPI CNewMenu::Initialize(LPCITEMIDLIST pidlFolder, - IDataObject *pdtobj, HKEY hkeyProgID ) -{ - + IDataObject *pdtobj, HKEY hkeyProgID) +{ return S_OK; } Modified: trunk/reactos/dll/win32/shell32/newmenu.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/newmenu.…
============================================================================== --- trunk/reactos/dll/win32/shell32/newmenu.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/newmenu.h [iso-8859-1] Thu Jan 5 23:04:06 2012 @@ -41,29 +41,32 @@ struct SHELLNEW_ITEM { - SHELLNEW_TYPE Type; - LPWSTR szExt; - LPWSTR szTarget; - LPWSTR szDesc; - LPWSTR szIcon; - SHELLNEW_ITEM *Next; + SHELLNEW_TYPE Type; + LPWSTR pwszExt; + LPWSTR pwszTarget; + LPWSTR pwszDesc; + LPWSTR pwszIcon; + SHELLNEW_ITEM *pNext; }; - LPWSTR szPath; - SHELLNEW_ITEM *s_SnHead; - IUnknown* fSite; + LPWSTR m_wszPath; + SHELLNEW_ITEM *m_pShellItems; + IUnknown *m_pSite; + HMENU m_hSubMenu; + + void CleanupMenu(); + static BOOL GetKeyDescription(LPCWSTR pwszExt, LPWSTR pwszResult); + SHELLNEW_ITEM *LoadItem(LPCWSTR pwszExt); + void UnloadItem(SHELLNEW_ITEM *pItem); + void UnloadShellItems(); + BOOL LoadShellNewItems(); + UINT InsertShellNewItems(HMENU hMenu, UINT idFirst, UINT idMenu); + HRESULT DoShellNewCmd(LPCMINVOKECOMMANDINFO lpcmi, IShellView *psv); + void CreateNewFolder(IShellView *psv); + public: CNewMenu(); ~CNewMenu(); - SHELLNEW_ITEM *LoadItem(LPWSTR szKeyName); - void UnloadItem(SHELLNEW_ITEM *item); - void UnloadShellItems(); - BOOL LoadShellNewItems(); - UINT InsertShellNewItems(HMENU hMenu, UINT idFirst, UINT idMenu); - HRESULT DoShellNewCmd(LPCMINVOKECOMMANDINFO lpcmi, IShellView * psv); - HRESULT DoMeasureItem(HWND hWnd, MEASUREITEMSTRUCT *lpmis); - HRESULT DoDrawItem(HWND hWnd, DRAWITEMSTRUCT *drawItem); - void DoNewFolder(IShellView *psv); // IObjectWithSite virtual HRESULT STDMETHODCALLTYPE SetSite(IUnknown *pUnkSite); @@ -72,7 +75,7 @@ // IContextMenu virtual HRESULT WINAPI QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags); virtual HRESULT WINAPI InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi); - virtual HRESULT WINAPI GetCommandString(UINT_PTR idCommand,UINT uFlags, UINT *lpReserved, LPSTR lpszName, UINT uMaxNameLen); + virtual HRESULT WINAPI GetCommandString(UINT_PTR idCommand, UINT uFlags, UINT *lpReserved, LPSTR lpszName, UINT uMaxNameLen); // IContextMenu2 virtual HRESULT WINAPI HandleMenuMsg(UINT uMsg, WPARAM wParam, LPARAM lParam);
12 years, 11 months
1
0
0
0
← Newer
1
...
48
49
50
51
52
53
54
55
56
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Results per page:
10
25
50
100
200