From 912704ceb87cec9705e6ff8901749e87086aad7a Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 14 Aug 2010 14:55:12 +0000 Subject: [PATCH 01/76] [NTOSKRNL] - Move to the next entry in the thread IRP list before calling IoCancelIrp because if everything works as expected and IoCompleteRequest is called, we could end up with the IRP ripped out from under us before can move to the next element - See issue #5550 for details. svn path=/trunk/; revision=48546 --- reactos/ntoskrnl/io/iomgr/irp.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/reactos/ntoskrnl/io/iomgr/irp.c b/reactos/ntoskrnl/io/iomgr/irp.c index a578e89731a..bd0eb8881d6 100644 --- a/reactos/ntoskrnl/io/iomgr/irp.c +++ b/reactos/ntoskrnl/io/iomgr/irp.c @@ -1047,14 +1047,12 @@ IoCancelThreadIo(IN PETHREAD Thread) NextEntry = ListHead->Flink; while (ListHead != NextEntry) { - /* Get the IRP */ + /* Get the IRP and move to the next entry */ Irp = CONTAINING_RECORD(NextEntry, IRP, ThreadListEntry); + NextEntry = NextEntry->Flink; /* Cancel it */ IoCancelIrp(Irp); - - /* Move to the next entry */ - NextEntry = NextEntry->Flink; } /* Wait 100 milliseconds */ From af01479fbfc43d41eb62ef48643a4451d861f240 Mon Sep 17 00:00:00 2001 From: evb Date: Sat, 14 Aug 2010 17:09:20 +0000 Subject: [PATCH 02/76] - Add support for PnP IRP to PDO: IRP_MN_QUERY_BUS_INFORMATION (PciQueryBusInformation), IRP_MN_QUERY_ID (PciQueryId), IRP_MN_QUERY_DEVICE_TEXT (PciQueryDeviceText), IRP_MN_QUERY_CAPABILITIES (PciQueryCapabilities), IRP_MN_QUERY_DEVICE_RELATIONS (PciQueryTargetDeviceRelations implement, PciQueryEjectionRelations, stub) - Stub support for PnP IRP to PDO: IRP_MN_QUERY_RESOURCE_REQUIREMENTS (PciQueryRequirements), IRP_MN_QUERY_RESOURCES(PciQueryResources) - Add support for PnP IRP to FDO: IRP_MN_QUERY_CAPABILITIES (handle in PciFdoIrpQueryDeviceCapabilities) - Build device capability UI number (PciDetermineSlotNumber), use PIR$ (seem support broken, need to check loader) or device property for bus not root - Use parent attachee device and this PDO for build device/system wake states, latency, device/system power mappings - PCI-ID manage support: PciInitIdBuffer, PciIdPrintf, PciIdPrintfAppend - Debug helper: PciDebugDumpQueryCapabilities - Thanks richard for advise + beer PCI-X driver now pass 10000 codes lines! svn path=/trunk/; revision=48548 --- reactos/drivers/bus/pcix/debug.c | 57 ++++ reactos/drivers/bus/pcix/enum.c | 61 ++++ reactos/drivers/bus/pcix/fdo.c | 20 +- reactos/drivers/bus/pcix/pci.h | 85 ++++++ reactos/drivers/bus/pcix/pci/id.c | 351 +++++++++++++++++++++++ reactos/drivers/bus/pcix/pdo.c | 85 ++++-- reactos/drivers/bus/pcix/utils.c | 451 ++++++++++++++++++++++++++++++ 7 files changed, 1086 insertions(+), 24 deletions(-) diff --git a/reactos/drivers/bus/pcix/debug.c b/reactos/drivers/bus/pcix/debug.c index f3a9930a880..1f119c274db 100644 --- a/reactos/drivers/bus/pcix/debug.c +++ b/reactos/drivers/bus/pcix/debug.c @@ -49,6 +49,26 @@ PCHAR PoCodes[] = "QUERY_POWER", }; +PCHAR SystemPowerStates[] = +{ + "Unspecified", + "Working", + "Sleeping1", + "Sleeping2", + "Sleeping3", + "Hibernate", + "Shutdown" +}; + +PCHAR DevicePowerStates[] = +{ + "Unspecified", + "D0", + "D1", + "D2", + "D3" +}; + ULONG PciBreakOnPdoPowerIrp, PciBreakOnFdoPowerIrp; ULONG PciBreakOnPdoPnpIrp, PciBreakOnFdoPnpIrp; @@ -194,4 +214,41 @@ PciDebugDumpCommonConfig(IN PPCI_COMMON_HEADER PciData) } } +VOID +NTAPI +PciDebugDumpQueryCapabilities(IN PDEVICE_CAPABILITIES DeviceCaps) +{ + ULONG i; + + /* Dump the capabilities */ + DPRINT1("Capabilities\n Lock:%d, Eject:%d, Remove:%d, Dock:%d, UniqueId:%d\n", + DeviceCaps->LockSupported, + DeviceCaps->EjectSupported, + DeviceCaps->Removable, + DeviceCaps->DockDevice, + DeviceCaps->UniqueID); + DbgPrint(" SilentInstall:%d, RawOk:%d, SurpriseOk:%d\n", + DeviceCaps->SilentInstall, + DeviceCaps->RawDeviceOK, + DeviceCaps->SurpriseRemovalOK); + DbgPrint(" Address %08x, UINumber %08x, Latencies D1 %d, D2 %d, D3 %d\n", + DeviceCaps->Address, + DeviceCaps->UINumber, + DeviceCaps->D1Latency, + DeviceCaps->D2Latency, + DeviceCaps->D3Latency); + + /* Dump and convert the wake levels */ + DbgPrint(" System Wake: %s, Device Wake: %s\n DeviceState[PowerState] [", + SystemPowerStates[min(DeviceCaps->SystemWake, PowerSystemMaximum)], + DevicePowerStates[min(DeviceCaps->DeviceWake, PowerDeviceMaximum)]); + + /* Dump and convert the power state mappings */ + for (i = PowerSystemWorking; i < PowerSystemMaximum; i++) + DbgPrint(" %s", DevicePowerStates[DeviceCaps->DeviceState[i]]); + + /* Finish the dump */ + DbgPrint(" ]\n"); +} + /* EOF */ diff --git a/reactos/drivers/bus/pcix/enum.c b/reactos/drivers/bus/pcix/enum.c index a4d53dd9fec..3caa9882232 100644 --- a/reactos/drivers/bus/pcix/enum.c +++ b/reactos/drivers/bus/pcix/enum.c @@ -14,6 +14,8 @@ /* GLOBALS ********************************************************************/ +PIO_RESOURCE_REQUIREMENTS_LIST PciZeroIoResourceRequirements; + PCI_CONFIGURATOR PciConfigurators[] = { { @@ -47,6 +49,65 @@ PCI_CONFIGURATOR PciConfigurators[] = /* FUNCTIONS ******************************************************************/ +NTSTATUS +NTAPI +PciQueryResources(IN PPCI_PDO_EXTENSION PdoExtension, + OUT PCM_RESOURCE_LIST *Buffer) +{ + /* Not yet implemented */ + UNIMPLEMENTED; + while (TRUE); + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +PciQueryTargetDeviceRelations(IN PPCI_PDO_EXTENSION PdoExtension, + IN OUT PDEVICE_RELATIONS *pDeviceRelations) +{ + PDEVICE_RELATIONS DeviceRelations; + PAGED_CODE(); + + /* If there were existing relations, free them */ + if (*pDeviceRelations) ExFreePoolWithTag(*pDeviceRelations, 0); + + /* Allocate a new structure for the relations */ + DeviceRelations = ExAllocatePoolWithTag(NonPagedPool, + sizeof(DEVICE_RELATIONS), + 'BicP'); + if (!DeviceRelations) return STATUS_INSUFFICIENT_RESOURCES; + + /* Only one relation: the PDO */ + DeviceRelations->Count = 1; + DeviceRelations->Objects[0] = PdoExtension->PhysicalDeviceObject; + ObReferenceObject(DeviceRelations->Objects[0]); + + /* Return the new relations */ + *pDeviceRelations = DeviceRelations; + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +PciQueryEjectionRelations(IN PPCI_PDO_EXTENSION PdoExtension, + IN OUT PDEVICE_RELATIONS *pDeviceRelations) +{ + /* Not yet implemented */ + UNIMPLEMENTED; + while (TRUE); +} + +NTSTATUS +NTAPI +PciQueryRequirements(IN PPCI_PDO_EXTENSION PdoExtension, + IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *RequirementsList) +{ + /* Not yet implemented */ + UNIMPLEMENTED; + while (TRUE); + return STATUS_SUCCESS; +} + /* * 7. The IO/MEM/Busmaster decodes are disabled for the device. * 8. The PCI bus driver sets the operating mode bits of the Programming diff --git a/reactos/drivers/bus/pcix/fdo.c b/reactos/drivers/bus/pcix/fdo.c index 256df1a3f4d..bfad380aca4 100644 --- a/reactos/drivers/bus/pcix/fdo.c +++ b/reactos/drivers/bus/pcix/fdo.c @@ -295,9 +295,23 @@ PciFdoIrpQueryCapabilities(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_FDO_EXTENSION DeviceExtension) { - UNIMPLEMENTED; - while (TRUE); - return STATUS_NOT_SUPPORTED; + PDEVICE_CAPABILITIES Capabilities; + PAGED_CODE(); + ASSERT_FDO(DeviceExtension); + + /* Get the capabilities */ + Capabilities = IoStackLocation->Parameters.DeviceCapabilities.Capabilities; + + /* Inherit wake levels and power mappings from the higher-up capabilities */ + DeviceExtension->PowerState.SystemWakeLevel = Capabilities->SystemWake; + DeviceExtension->PowerState.DeviceWakeLevel = Capabilities->DeviceWake; + RtlCopyMemory(DeviceExtension->PowerState.SystemStateMapping, + Capabilities->DeviceState, + sizeof(DeviceExtension->PowerState.SystemStateMapping)); + + /* Dump the capabilities and return success */ + PciDebugDumpQueryCapabilities(Capabilities); + return STATUS_SUCCESS; } NTSTATUS diff --git a/reactos/drivers/bus/pcix/pci.h b/reactos/drivers/bus/pcix/pci.h index 93a5f140276..87b1c44a13c 100644 --- a/reactos/drivers/bus/pcix/pci.h +++ b/reactos/drivers/bus/pcix/pci.h @@ -79,6 +79,11 @@ // #define PCI_VERIFIER_CODES 0x04 +// +// PCI ID Buffer ANSI Strings +// +#define MAX_ANSI_STRINGS 0x08 + // // Device Extension, Interface, Translator and Arbiter Signatures // @@ -410,6 +415,19 @@ typedef struct _PCI_VERIFIER_DATA PCHAR DebuggerMessageText; } PCI_VERIFIER_DATA, *PPCI_VERIFIER_DATA; +// +// PCI ID Buffer Descriptor +// +typedef struct _PCI_ID_BUFFER +{ + ULONG Count; + ANSI_STRING Strings[MAX_ANSI_STRINGS]; + ULONG StringSize[MAX_ANSI_STRINGS]; + ULONG TotalLength; + PCHAR CharBuffer; + CHAR BufferData[256]; +} PCI_ID_BUFFER, *PPCI_ID_BUFFER; + // // PCI Configuration Callbacks // @@ -1111,6 +1129,20 @@ PciDecodeEnable( OUT PUSHORT Command ); +NTSTATUS +NTAPI +PciQueryBusInformation( + IN PPCI_PDO_EXTENSION PdoExtension, + IN PPNP_BUS_INFORMATION* Buffer +); + +NTSTATUS +NTAPI +PciQueryCapabilities( + IN PPCI_PDO_EXTENSION PdoExtension, + IN OUT PDEVICE_CAPABILITIES DeviceCapability +); + // // Configuration Routines // @@ -1217,6 +1249,12 @@ PciDebugDumpCommonConfig( IN PPCI_COMMON_HEADER PciData ); +VOID +NTAPI +PciDebugDumpQueryCapabilities( + IN PDEVICE_CAPABILITIES DeviceCaps +); + // // Interface Support // @@ -1452,6 +1490,34 @@ PciQueryDeviceRelations( IN OUT PDEVICE_RELATIONS *pDeviceRelations ); +NTSTATUS +NTAPI +PciQueryResources( + IN PPCI_PDO_EXTENSION PdoExtension, + OUT PCM_RESOURCE_LIST *Buffer +); + +NTSTATUS +NTAPI +PciQueryTargetDeviceRelations( + IN PPCI_PDO_EXTENSION PdoExtension, + IN OUT PDEVICE_RELATIONS *pDeviceRelations +); + +NTSTATUS +NTAPI +PciQueryEjectionRelations( + IN PPCI_PDO_EXTENSION PdoExtension, + IN OUT PDEVICE_RELATIONS *pDeviceRelations +); + +NTSTATUS +NTAPI +PciQueryRequirements( + IN PPCI_PDO_EXTENSION PdoExtension, + IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *RequirementsList +); + // // Identification Functions // @@ -1462,6 +1528,23 @@ PciGetDeviceDescriptionMessage( IN UCHAR SubClass ); +NTSTATUS +NTAPI +PciQueryDeviceText( + IN PPCI_PDO_EXTENSION PdoExtension, + IN DEVICE_TEXT_TYPE QueryType, + IN ULONG Locale, + OUT PWCHAR *Buffer +); + +NTSTATUS +NTAPI +PciQueryId( + IN PPCI_PDO_EXTENSION DeviceExtension, + IN BUS_QUERY_ID_TYPE QueryType, + OUT PWCHAR *Buffer +); + // // CardBUS Support // @@ -1627,6 +1710,8 @@ extern PWATCHDOG_TABLE WdTable; extern PPCI_HACK_ENTRY PciHackTable; extern BOOLEAN PciAssignBusNumbers; extern BOOLEAN PciEnableNativeModeATA; +extern PPCI_IRQ_ROUTING_TABLE PciIrqRoutingTable; +extern BOOLEAN PciRunningDatacenter; /* Exported by NTOS, should this go in the NDK? */ extern NTSYSAPI BOOLEAN InitSafeBootMode; diff --git a/reactos/drivers/bus/pcix/pci/id.c b/reactos/drivers/bus/pcix/pci/id.c index c1d711b086f..9db7d703fb0 100644 --- a/reactos/drivers/bus/pcix/pci/id.c +++ b/reactos/drivers/bus/pcix/pci/id.c @@ -11,6 +11,7 @@ #include #define NDEBUG #include +#include "stdio.h" /* GLOBALS ********************************************************************/ @@ -107,4 +108,354 @@ PciGetDeviceDescriptionMessage(IN UCHAR BaseClass, return Message; } +VOID +NTAPI +PciInitIdBuffer(IN PPCI_ID_BUFFER IdBuffer) +{ + /* Initialize the sizes to zero and the pointer to the start of the buffer */ + IdBuffer->TotalLength = 0; + IdBuffer->Count = 0; + IdBuffer->CharBuffer = IdBuffer->BufferData; +} + +ULONG +NTAPI +PciIdPrintf(IN PPCI_ID_BUFFER IdBuffer, + IN PCCH Format, + ...) +{ + ULONG Size, Length; + PANSI_STRING AnsiString; + va_list va; + va_start(va, Format); + ASSERT(IdBuffer->Count < MAX_ANSI_STRINGS); + + /* Do the actual string formatting into the character buffer */ + vsprintf(IdBuffer->CharBuffer, Format, va); + + /* Initialize the ANSI_STRING that will hold this string buffer */ + AnsiString = &IdBuffer->Strings[IdBuffer->Count]; + RtlInitAnsiString(AnsiString, IdBuffer->CharBuffer); + + /* Calculate the final size of the string, in Unicode */ + Size = RtlAnsiStringToUnicodeSize(AnsiString); + + /* Update hte buffer with the size,and update the character pointer */ + IdBuffer->StringSize[IdBuffer->Count] = Size; + IdBuffer->TotalLength += Size; + Length = AnsiString->Length + sizeof(ANSI_NULL); + IdBuffer->CharBuffer += Length; + + /* Move to the next string for next time */ + IdBuffer->Count++; + + /* Return the length */ + return Length; +} + +ULONG +NTAPI +PciIdPrintfAppend(IN PPCI_ID_BUFFER IdBuffer, + IN PCCH Format, + ...) +{ + ULONG NextId, Size, Length, MaxLength; + PANSI_STRING AnsiString; + va_list va; + va_start(va, Format); + ASSERT(IdBuffer->Count); + + /* Choose the next static ANSI_STRING to use */ + NextId = IdBuffer->Count - 1; + + /* Max length is from the end of the buffer up until the current pointer */ + MaxLength = (PCHAR)(IdBuffer + 1) - IdBuffer->CharBuffer; + + /* Do the actual append, and return the length this string took */ + Length = vsprintf(IdBuffer->CharBuffer - 1, Format, va); + ASSERT(Length < MaxLength); + + /* Select the static ANSI_STRING, and update its length information */ + AnsiString = &IdBuffer->Strings[NextId]; + AnsiString->Length += Length; + AnsiString->MaximumLength += Length; + + /* Calculate the final size of the string, in Unicode */ + Size = RtlAnsiStringToUnicodeSize(AnsiString); + + /* Update the buffer with the size, and update the character pointer */ + IdBuffer->StringSize[NextId] = Size; + IdBuffer->TotalLength += Size; + IdBuffer->CharBuffer += Length; + + /* Return the size */ + return Size; +} + +NTSTATUS +NTAPI +PciQueryId(IN PPCI_PDO_EXTENSION DeviceExtension, + IN BUS_QUERY_ID_TYPE QueryType, + OUT PWCHAR *Buffer) +{ + ULONG SubsysId; + CHAR VendorString[22]; + PPCI_PDO_EXTENSION PdoExtension; + PPCI_FDO_EXTENSION ParentExtension; + PWCHAR StringBuffer; + ULONG i, Size; + NTSTATUS Status; + PANSI_STRING NextString; + UNICODE_STRING DestinationString; + PCI_ID_BUFFER IdBuffer; + PAGED_CODE(); + + /* Assume failure */ + Status = STATUS_SUCCESS; + *Buffer = NULL; + + /* Start with the genric vendor string, which is the vendor ID + device ID */ + sprintf(VendorString, + "PCI\\VEN_%04X&DEV_%04X", + DeviceExtension->VendorId, + DeviceExtension->DeviceId); + + /* Initialize the PCI ID Buffer */ + PciInitIdBuffer(&IdBuffer); + + /* Build the subsystem ID as shown in PCI ID Strings */ + SubsysId = DeviceExtension->SubsystemVendorId | (DeviceExtension->SubsystemId << 16); + + /* Check what the caller is requesting */ + switch (QueryType) + { + case BusQueryDeviceID: + + /* A single ID, the vendor string + the revision ID */ + PciIdPrintf(&IdBuffer, + "%s&SUBSYS_%08X&REV_%02X", + VendorString, + SubsysId, + DeviceExtension->RevisionId); + break; + + case BusQueryHardwareIDs: + + /* First the vendor string + the subsystem ID + the revision ID */ + PciIdPrintf(&IdBuffer, + "%s&SUBSYS_%08X&REV_%02X", + VendorString, + SubsysId, + DeviceExtension->RevisionId); + + /* Next, without the revision */ + PciIdPrintf(&IdBuffer, + "%s&SUBSYS_%08X", + VendorString, + SubsysId); + + /* Next, the vendor string + the base class + sub class + progif */ + PciIdPrintf(&IdBuffer, + "%s&CC_%02X%02X%02X", + VendorString, + DeviceExtension->BaseClass, + DeviceExtension->SubClass, + DeviceExtension->ProgIf); + + /* Next, without the progif */ + PciIdPrintf(&IdBuffer, + "%s&CC_%02X%02X", + VendorString, + DeviceExtension->BaseClass, + DeviceExtension->SubClass); + + /* And finally, a terminator */ + PciIdPrintf(&IdBuffer, "\0"); + break; + + case BusQueryCompatibleIDs: + + /* First, the vendor + revision ID only */ + PciIdPrintf(&IdBuffer, + "%s&REV_%02X", + VendorString, + DeviceExtension->RevisionId); + + /* Next, the vendor string alone */ + PciIdPrintf(&IdBuffer, "%s", VendorString); + + /* Next, the vendor ID + the base class + the sub class + progif */ + PciIdPrintf(&IdBuffer, + "PCI\\VEN_%04X&CC_%02X%02X%02X", + DeviceExtension->VendorId, + DeviceExtension->BaseClass, + DeviceExtension->SubClass, + DeviceExtension->ProgIf); + + /* Now without the progif */ + PciIdPrintf(&IdBuffer, + "PCI\\VEN_%04X&CC_%02X%02X", + DeviceExtension->VendorId, + DeviceExtension->BaseClass, + DeviceExtension->SubClass); + + /* And then just the vendor ID itself */ + PciIdPrintf(&IdBuffer, + "PCI\\VEN_%04X", + DeviceExtension->VendorId); + + /* Then the base class + subclass + progif, without any vendor */ + PciIdPrintf(&IdBuffer, + "PCI\\CC_%02X%02X%02X", + DeviceExtension->BaseClass, + DeviceExtension->SubClass, + DeviceExtension->ProgIf); + + /* Next, without the progif */ + PciIdPrintf(&IdBuffer, + "PCI\\CC_%02X%02X", + DeviceExtension->BaseClass, + DeviceExtension->SubClass); + + /* And finally, a terminator */ + PciIdPrintf(&IdBuffer, "\0"); + break; + + case BusQueryInstanceID: + + /* Start with a terminator */ + PciIdPrintf(&IdBuffer, "\0"); + + /* And then encode the device and function number */ + PciIdPrintfAppend(&IdBuffer, + "%02X", + (DeviceExtension->Slot.u.bits.DeviceNumber << 3) | + DeviceExtension->Slot.u.bits.FunctionNumber); + + /* Loop every parent until the root */ + ParentExtension = DeviceExtension->ParentFdoExtension; + while (!PCI_IS_ROOT_FDO(ParentExtension)) + { + /* And encode the parent's device and function number as well */ + PdoExtension = ParentExtension->PhysicalDeviceObject->DeviceExtension; + PciIdPrintfAppend(&IdBuffer, + "%02X", + (PdoExtension->Slot.u.bits.DeviceNumber << 3) | + PdoExtension->Slot.u.bits.FunctionNumber); + } + break; + + default: + + /* Unknown query type */ + DPRINT1("PciQueryId expected ID type = %d\n", QueryType); + return STATUS_NOT_SUPPORTED; + } + + /* Something should've been generated if this has been reached */ + ASSERT(IdBuffer.Count > 0); + + /* Allocate the final string buffer to hold the ID */ + StringBuffer = ExAllocatePoolWithTag(PagedPool, IdBuffer.TotalLength, 'BicP'); + if (!StringBuffer) return STATUS_INSUFFICIENT_RESOURCES; + + /* Build the UNICODE_STRING structure for it */ + DPRINT1("PciQueryId(%d)\n", QueryType); + DestinationString.Buffer = StringBuffer; + DestinationString.MaximumLength = IdBuffer.TotalLength; + + /* Loop every ID in the buffer */ + for (i = 0; i < IdBuffer.Count; i++) + { + /* Select the ANSI_STRING for the ID */ + NextString = &IdBuffer.Strings[i]; + DPRINT1(" <- \"%s\"\n", NextString->Buffer); + + /* Convert it to a UNICODE_STRING */ + Status = RtlAnsiStringToUnicodeString(&DestinationString, NextString, FALSE); + ASSERT(NT_SUCCESS(Status)); + + /* Add it into the final destination buffer */ + Size = IdBuffer.StringSize[i]; + DestinationString.MaximumLength -= Size; + DestinationString.Buffer += (Size / sizeof(WCHAR)); + } + + /* Return the buffer to the caller and return status (should be success) */ + *Buffer = StringBuffer; + return Status; +} + +NTSTATUS +NTAPI +PciQueryDeviceText(IN PPCI_PDO_EXTENSION PdoExtension, + IN DEVICE_TEXT_TYPE QueryType, + IN ULONG Locale, + OUT PWCHAR *Buffer) +{ + PWCHAR MessageBuffer, LocationBuffer; + ULONG Length; + NTSTATUS Status; + + /* Check what the caller is requesting */ + switch (QueryType) + { + case DeviceTextDescription: + + /* Get the message from the resource section */ + MessageBuffer = PciGetDeviceDescriptionMessage(PdoExtension->BaseClass, + PdoExtension->SubClass); + + /* Return it to the caller, and select proper status code */ + *Buffer = MessageBuffer; + Status = MessageBuffer ? STATUS_SUCCESS : STATUS_NOT_SUPPORTED; + break; + + case DeviceTextLocationInformation: + + /* Get the message from the resource section */ + MessageBuffer = PciGetDescriptionMessage(0x10000, &Length); + if (!MessageBuffer) + { + /* It should be there, but fail if it wasn't found for some reason */ + Status = STATUS_NOT_SUPPORTED; + break; + } + + /* Add space for a null-terminator, and allocate the buffer */ + Length += 2 * sizeof(UNICODE_NULL); + LocationBuffer = ExAllocatePoolWithTag(PagedPool, + Length * sizeof(WCHAR), + 'BicP'); + *Buffer = LocationBuffer; + + /* Check if the allocation succeeded */ + if (LocationBuffer) + { + /* Build the location string based on bus, function, and device */ + swprintf(LocationBuffer, + MessageBuffer, + PdoExtension->ParentFdoExtension->BaseBus, + PdoExtension->Slot.u.bits.FunctionNumber, + PdoExtension->Slot.u.bits.DeviceNumber); + } + + /* Free the original string from the resource section */ + ExFreePoolWithTag(MessageBuffer, 0); + + /* Select the correct status */ + Status = LocationBuffer ? STATUS_SUCCESS : STATUS_INSUFFICIENT_RESOURCES; + break; + + default: + + /* Anything else is unsupported */ + Status = STATUS_NOT_SUPPORTED; + break; + } + + /* Return whether or not a device text string was indeed found */ + return Status; +} + /* EOF */ diff --git a/reactos/drivers/bus/pcix/pdo.c b/reactos/drivers/bus/pcix/pdo.c index 2e2bd57bc1f..8ed578c1251 100644 --- a/reactos/drivers/bus/pcix/pdo.c +++ b/reactos/drivers/bus/pcix/pdo.c @@ -200,9 +200,32 @@ PciPdoIrpQueryDeviceRelations(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension) { - UNIMPLEMENTED; - while (TRUE); - return STATUS_NOT_SUPPORTED; + NTSTATUS Status; + PAGED_CODE(); + + /* Are ejection relations being queried? */ + if (IoStackLocation->Parameters.QueryDeviceRelations.Type == EjectionRelations) + { + /* Call the worker function */ + Status = PciQueryEjectionRelations(DeviceExtension, + (PDEVICE_RELATIONS*)&Irp-> + IoStatus.Information); + } + else if (IoStackLocation->Parameters.QueryDeviceRelations.Type == TargetDeviceRelation) + { + /* The only other relation supported is the target device relation */ + Status = PciQueryTargetDeviceRelations(DeviceExtension, + (PDEVICE_RELATIONS*)&Irp-> + IoStatus.Information); + } + else + { + /* All other relations are unsupported */ + Status = STATUS_NOT_SUPPORTED; + } + + /* Return either the result of the worker function, or unsupported status */ + return Status; } NTSTATUS @@ -211,9 +234,12 @@ PciPdoIrpQueryCapabilities(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension) { - UNIMPLEMENTED; - while (TRUE); - return STATUS_NOT_SUPPORTED; + PAGED_CODE(); + + /* Call the worker function */ + return PciQueryCapabilities(DeviceExtension, + IoStackLocation-> + Parameters.DeviceCapabilities.Capabilities); } NTSTATUS @@ -222,9 +248,11 @@ PciPdoIrpQueryResources(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension) { - UNIMPLEMENTED; - while (TRUE); - return STATUS_NOT_SUPPORTED; + PAGED_CODE(); + + /* Call the worker function */ + return PciQueryResources(DeviceExtension, + (PCM_RESOURCE_LIST*)&Irp->IoStatus.Information); } NTSTATUS @@ -233,9 +261,12 @@ PciPdoIrpQueryResourceRequirements(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension) { - UNIMPLEMENTED; - while (TRUE); - return STATUS_NOT_SUPPORTED; + PAGED_CODE(); + + /* Call the worker function */ + return PciQueryRequirements(DeviceExtension, + (PIO_RESOURCE_REQUIREMENTS_LIST*)&Irp-> + IoStatus.Information); } NTSTATUS @@ -244,9 +275,15 @@ PciPdoIrpQueryDeviceText(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension) { - UNIMPLEMENTED; - while (TRUE); - return STATUS_NOT_SUPPORTED; + PAGED_CODE(); + + /* Call the worker function */ + return PciQueryDeviceText(DeviceExtension, + IoStackLocation-> + Parameters.QueryDeviceText.DeviceTextType, + IoStackLocation-> + Parameters.QueryDeviceText.LocaleId, + (PWCHAR*)&Irp->IoStatus.Information); } NTSTATUS @@ -255,9 +292,12 @@ PciPdoIrpQueryId(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension) { - UNIMPLEMENTED; - while (TRUE); - return STATUS_NOT_SUPPORTED; + PAGED_CODE(); + + /* Call the worker function */ + return PciQueryId(DeviceExtension, + IoStackLocation->Parameters.QueryId.IdType, + (PWCHAR*)&Irp->IoStatus.Information); } NTSTATUS @@ -266,9 +306,12 @@ PciPdoIrpQueryBusInformation(IN PIRP Irp, IN PIO_STACK_LOCATION IoStackLocation, IN PPCI_PDO_EXTENSION DeviceExtension) { - UNIMPLEMENTED; - while (TRUE); - return STATUS_NOT_SUPPORTED; + PAGED_CODE(); + + /* Call the worker function */ + return PciQueryBusInformation(DeviceExtension, + (PPNP_BUS_INFORMATION*)&Irp-> + IoStatus.Information); } NTSTATUS diff --git a/reactos/drivers/bus/pcix/utils.c b/reactos/drivers/bus/pcix/utils.c index f450a261a74..fa0d91ecfdf 100644 --- a/reactos/drivers/bus/pcix/utils.c +++ b/reactos/drivers/bus/pcix/utils.c @@ -1306,4 +1306,455 @@ PciDecodeEnable(IN PPCI_PDO_EXTENSION PdoExtension, } } +NTSTATUS +NTAPI +PciQueryBusInformation(IN PPCI_PDO_EXTENSION PdoExtension, + IN PPNP_BUS_INFORMATION* Buffer) +{ + PPNP_BUS_INFORMATION BusInfo; + + /* Allocate a structure for the bus information */ + BusInfo = ExAllocatePoolWithTag(PagedPool, + sizeof(PNP_BUS_INFORMATION), + 'BicP'); + if (!BusInfo) return STATUS_INSUFFICIENT_RESOURCES; + + /* Write the correct GUID and bus type identifier, and fill the bus number */ + BusInfo->BusTypeGuid = GUID_BUS_TYPE_PCI; + BusInfo->LegacyBusType = PCIBus; + BusInfo->BusNumber = PdoExtension->ParentFdoExtension->BaseBus; + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +PciDetermineSlotNumber(IN PPCI_PDO_EXTENSION PdoExtension, + OUT PULONG SlotNumber) +{ + PPCI_FDO_EXTENSION ParentExtension; + ULONG ResultLength; + NTSTATUS Status; + PSLOT_INFO SlotInfo; + + /* Check if a $PIR from the BIOS is used (legacy IRQ routing) */ + ParentExtension = PdoExtension->ParentFdoExtension; + DPRINT1("Slot lookup for %d.%d.%d\n", + ParentExtension ? ParentExtension->BaseBus : -1, + PdoExtension->Slot.u.bits.DeviceNumber, + PdoExtension->Slot.u.bits.FunctionNumber); + if ((PciIrqRoutingTable) && (ParentExtension)) + { + /* Read every slot information entry */ + SlotInfo = &PciIrqRoutingTable->Slot[0]; + DPRINT1("PIR$ %p is %lx bytes, slot 0 is at: %lx\n", + PciIrqRoutingTable, PciIrqRoutingTable->TableSize, SlotInfo); + while (SlotInfo < (PSLOT_INFO)((ULONG_PTR)PciIrqRoutingTable + + PciIrqRoutingTable->TableSize)) + { + DPRINT1("Slot Info: %d.%d->#%d\n", + SlotInfo->BusNumber, + SlotInfo->DeviceNumber, + SlotInfo->SlotNumber); + + /* Check if this slot information matches the PDO being queried */ + if ((ParentExtension->BaseBus == SlotInfo->BusNumber) && + (PdoExtension->Slot.u.bits.DeviceNumber == SlotInfo->DeviceNumber >> 3) && + (SlotInfo->SlotNumber)) + { + /* We found it, return it and return success */ + *SlotNumber = SlotInfo->SlotNumber; + return STATUS_SUCCESS; + } + + /* Try the next slot */ + SlotInfo++; + } + } + + /* Otherwise, grab the parent FDO and check if it's the root */ + if (PCI_IS_ROOT_FDO(ParentExtension)) + { + /* The root FDO doesn't have a slot number */ + Status = STATUS_UNSUCCESSFUL; + } + else + { + /* Otherwise, query the slot/UI address/number as a device property */ + Status = IoGetDeviceProperty(ParentExtension->PhysicalDeviceObject, + DevicePropertyUINumber, + sizeof(ULONG), + SlotNumber, + &ResultLength); + } + + /* Return the status of this endeavour */ + return Status; +} + +NTSTATUS +NTAPI +PciGetDeviceCapabilities(IN PDEVICE_OBJECT DeviceObject, + IN OUT PDEVICE_CAPABILITIES DeviceCapability) +{ + PIRP Irp; + NTSTATUS Status; + KEVENT Event; + PDEVICE_OBJECT AttachedDevice; + PIO_STACK_LOCATION IoStackLocation; + IO_STATUS_BLOCK IoStatusBlock; + PAGED_CODE(); + + /* Zero out capabilities and set undefined values to start with */ + RtlZeroMemory(DeviceCapability, sizeof(DEVICE_CAPABILITIES)); + DeviceCapability->Size = sizeof(DEVICE_CAPABILITIES); + DeviceCapability->Version = 1; + DeviceCapability->Address = -1; + DeviceCapability->UINumber = -1; + + /* Build the wait event for the IOCTL */ + KeInitializeEvent(&Event, SynchronizationEvent, FALSE); + + /* Find the device the PDO is attached to */ + AttachedDevice = IoGetAttachedDeviceReference(DeviceObject); + + /* And build an IRP for it */ + Irp = IoBuildSynchronousFsdRequest(IRP_MJ_PNP, + AttachedDevice, + NULL, + 0, + NULL, + &Event, + &IoStatusBlock); + if (!Irp) + { + /* The IRP failed, fail the request as well */ + ObDereferenceObject(AttachedDevice); + return STATUS_INSUFFICIENT_RESOURCES; + } + + /* Set default status */ + Irp->IoStatus.Information = 0; + Irp->IoStatus.Status = STATUS_NOT_SUPPORTED; + + /* Get a stack location in this IRP */ + IoStackLocation = IoGetNextIrpStackLocation(Irp); + ASSERT(IoStackLocation); + + /* Initialize it as a query capabilities IRP, with no completion routine */ + RtlZeroMemory(IoStackLocation, sizeof(IO_STACK_LOCATION)); + IoStackLocation->MajorFunction = IRP_MJ_PNP; + IoStackLocation->MinorFunction = IRP_MN_QUERY_CAPABILITIES; + IoStackLocation->Parameters.DeviceCapabilities.Capabilities = DeviceCapability; + IoSetCompletionRoutine(Irp, NULL, NULL, FALSE, FALSE, FALSE); + + /* Send the IOCTL to the driver */ + Status = IoCallDriver(AttachedDevice, Irp); + if (Status == STATUS_PENDING) + { + /* Wait for a response and update the actual status */ + KeWaitForSingleObject(&Event, + Executive, + KernelMode, + FALSE, + NULL); + Status = Irp->IoStatus.Status; + } + + /* Done, dereference the attached device and return the final result */ + ObDereferenceObject(AttachedDevice); + return Status; +} + +NTSTATUS +NTAPI +PciQueryPowerCapabilities(IN PPCI_PDO_EXTENSION PdoExtension, + IN PDEVICE_CAPABILITIES DeviceCapability) +{ + PDEVICE_OBJECT DeviceObject; + NTSTATUS Status; + DEVICE_CAPABILITIES AttachedCaps; + DEVICE_POWER_STATE NewPowerState, DevicePowerState, DeviceWakeLevel, DeviceWakeState; + SYSTEM_POWER_STATE SystemWakeState, DeepestWakeState, CurrentState; + + /* Nothing is known at first */ + DeviceWakeState = PowerDeviceUnspecified; + SystemWakeState = DeepestWakeState = PowerSystemUnspecified; + + /* Get the PCI capabilities for the parent PDO */ + DeviceObject = PdoExtension->ParentFdoExtension->PhysicalDeviceObject; + Status = PciGetDeviceCapabilities(DeviceObject, &AttachedCaps); + ASSERT(NT_SUCCESS(Status)); + if (!NT_SUCCESS(Status)) return Status; + + /* Check if there's not an existing device state for S0 */ + if (!AttachedCaps.DeviceState[PowerSystemWorking]) + { + /* Set D0<->S0 mapping */ + AttachedCaps.DeviceState[PowerSystemWorking] = PowerDeviceD0; + } + + /* Check if there's not an existing device state for S3 */ + if (!AttachedCaps.DeviceState[PowerSystemShutdown]) + { + /* Set D3<->S3 mapping */ + AttachedCaps.DeviceState[PowerSystemShutdown] = PowerDeviceD3; + } + + /* Check for a PDO with broken, or no, power capabilities */ + if (PdoExtension->HackFlags & PCI_HACK_NO_PM_CAPS) + { + /* Unknown wake device states */ + DeviceCapability->DeviceWake = PowerDeviceUnspecified; + DeviceCapability->SystemWake = PowerSystemUnspecified; + + /* No device state support */ + DeviceCapability->DeviceD1 = FALSE; + DeviceCapability->DeviceD2 = FALSE; + + /* No waking from any low-power device state is supported */ + DeviceCapability->WakeFromD0 = FALSE; + DeviceCapability->WakeFromD1 = FALSE; + DeviceCapability->WakeFromD2 = FALSE; + DeviceCapability->WakeFromD3 = FALSE; + + /* For the rest, copy whatever the parent PDO had */ + RtlCopyMemory(DeviceCapability->DeviceState, + AttachedCaps.DeviceState, + sizeof(DeviceCapability->DeviceState)); + return STATUS_SUCCESS; + } + + /* The PCI Device has power capabilities, so read which ones are supported */ + DeviceCapability->DeviceD1 = PdoExtension->PowerCapabilities.Support.D1; + DeviceCapability->DeviceD2 = PdoExtension->PowerCapabilities.Support.D2; + DeviceCapability->WakeFromD0 = PdoExtension->PowerCapabilities.Support.PMED0; + DeviceCapability->WakeFromD1 = PdoExtension->PowerCapabilities.Support.PMED1; + DeviceCapability->WakeFromD2 = PdoExtension->PowerCapabilities.Support.PMED2; + + /* Can the attached device wake from D3? */ + if (AttachedCaps.DeviceWake != PowerDeviceD3) + { + /* It can't, so check if this PDO supports hot D3 wake */ + DeviceCapability->WakeFromD3 = PdoExtension->PowerCapabilities.Support.PMED3Hot; + } + else + { + /* It can, is this the root bus? */ + if (PCI_IS_ROOT_FDO(PdoExtension->ParentFdoExtension)) + { + /* This is the root bus, so just check if it supports hot D3 wake */ + DeviceCapability->WakeFromD3 = PdoExtension->PowerCapabilities.Support.PMED3Hot; + } + else + { + /* Take the minimums? -- need to check with briang at work */ + UNIMPLEMENTED; + } + } + + /* Now loop each system power state to determine its device state mapping */ + for (CurrentState = PowerSystemWorking; + CurrentState < PowerSystemMaximum; + CurrentState++) + { + /* Read the current mapping from the attached device */ + DevicePowerState = AttachedCaps.DeviceState[CurrentState]; + NewPowerState = DevicePowerState; + + /* The attachee suports D1, but this PDO does not */ + if ((NewPowerState == PowerDeviceD1) && + !(PdoExtension->PowerCapabilities.Support.D1)) + { + /* Fall back to D2 */ + NewPowerState = PowerDeviceD2; + } + + /* The attachee supports D2, but this PDO does not */ + if ((NewPowerState == PowerDeviceD2) && + !(PdoExtension->PowerCapabilities.Support.D2)) + { + /* Fall back to D3 */ + NewPowerState = PowerDeviceD3; + } + + /* Set the mapping based on the best state supported */ + DeviceCapability->DeviceState[CurrentState] = NewPowerState; + + /* Check if sleep states are being processed, and a mapping was found */ + if ((CurrentState < PowerSystemHibernate) && + (NewPowerState != PowerDeviceUnspecified)) + { + /* Save this state as being the deepest one found until now */ + DeepestWakeState = CurrentState; + } + + /* + * Finally, check if the computed sleep state is within the states that + * this device can wake the system from, and if it's higher or equal to + * the sleep state mapping that came from the attachee, assuming that it + * had a valid mapping to begin with. + * + * It this is the case, then make sure that the computed sleep state is + * matched by the device's ability to actually wake from that state. + * + * For devices that support D3, the PCI device only needs Hot D3 as long + * as the attachee's state is less than D3. Otherwise, if the attachee + * might also be at D3, this would require a Cold D3 wake, so check that + * the device actually support this. + */ + if ((CurrentState < AttachedCaps.SystemWake) && + (NewPowerState >= DevicePowerState) && + (DevicePowerState != PowerDeviceUnspecified) && + (((NewPowerState == PowerDeviceD0) && (DeviceCapability->WakeFromD0)) || + ((NewPowerState == PowerDeviceD1) && (DeviceCapability->WakeFromD1)) || + ((NewPowerState == PowerDeviceD2) && (DeviceCapability->WakeFromD2)) || + ((NewPowerState == PowerDeviceD3) && + (PdoExtension->PowerCapabilities.Support.PMED3Hot) && + ((DevicePowerState < PowerDeviceD3) || + (PdoExtension->PowerCapabilities.Support.PMED3Cold))))) + { + /* The mapping is valid, so this will be the lowest wake state */ + SystemWakeState = CurrentState; + DeviceWakeState = NewPowerState; + } + } + + /* Read the current wake level */ + DeviceWakeLevel = PdoExtension->PowerState.DeviceWakeLevel; + + /* Check if the attachee's wake levels are valid, and the PDO's is higher */ + if ((AttachedCaps.SystemWake != PowerSystemUnspecified) && + (AttachedCaps.DeviceWake != PowerDeviceUnspecified) && + (DeviceWakeLevel != PowerDeviceUnspecified) && + (DeviceWakeLevel >= AttachedCaps.DeviceWake)) + { + /* Inherit the system wake from the attachee, and this PDO's wake level */ + DeviceCapability->SystemWake = AttachedCaps.SystemWake; + DeviceCapability->DeviceWake = DeviceWakeLevel; + + /* Now check if the wake level is D0, but the PDO doesn't support it */ + if ((DeviceCapability->DeviceWake == PowerDeviceD0) && + !(DeviceCapability->WakeFromD0)) + { + /* Bump to D1 */ + DeviceCapability->DeviceWake = PowerDeviceD1; + } + + /* Now check if the wake level is D1, but the PDO doesn't support it */ + if ((DeviceCapability->DeviceWake == PowerDeviceD1) && + !(DeviceCapability->WakeFromD1)) + { + /* Bump to D2 */ + DeviceCapability->DeviceWake = PowerDeviceD2; + } + + /* Now check if the wake level is D2, but the PDO doesn't support it */ + if ((DeviceCapability->DeviceWake == PowerDeviceD2) && + !(DeviceCapability->WakeFromD2)) + { + /* Bump it to D3 */ + DeviceCapability->DeviceWake = PowerDeviceD3; + } + + /* Now check if the wake level is D3, but the PDO doesn't support it */ + if ((DeviceCapability->DeviceWake == PowerDeviceD3) && + !(DeviceCapability->WakeFromD3)) + { + /* Then no valid wake state exists */ + DeviceCapability->DeviceWake = PowerDeviceUnspecified; + DeviceCapability->SystemWake = PowerSystemUnspecified; + } + + /* Check if no valid wake state was found */ + if ((DeviceCapability->DeviceWake == PowerDeviceUnspecified) || + (DeviceCapability->SystemWake == PowerSystemUnspecified)) + { + /* Check if one was computed earlier */ + if ((SystemWakeState != PowerSystemUnspecified) && + (DeviceWakeState != PowerDeviceUnspecified)) + { + /* Use the wake state that had been computed earlier */ + DeviceCapability->DeviceWake = DeviceWakeState; + DeviceCapability->SystemWake = SystemWakeState; + + /* If that state was D3, then the device supports Hot/Cold D3 */ + if (DeviceWakeState == PowerDeviceD3) DeviceCapability->WakeFromD3 = TRUE; + } + } + + /* + * Finally, check for off states (lower than S3, such as hibernate) and + * make sure that the device both supports waking from D3 as well as + * supports a Cold wake + */ + if ((DeviceCapability->SystemWake > PowerSystemSleeping3) && + ((DeviceCapability->DeviceWake != PowerDeviceD3) || + !(PdoExtension->PowerCapabilities.Support.PMED3Cold))) + { + /* It doesn't, so pick the computed lowest wake state from earlier */ + DeviceCapability->SystemWake = DeepestWakeState; + } + + /* Set the PCI Specification mandated maximum latencies for transitions */ + DeviceCapability->D1Latency = 0; + DeviceCapability->D2Latency = 2; + DeviceCapability->D3Latency = 100; + + /* Sanity check */ + ASSERT(DeviceCapability->DeviceState[PowerSystemWorking] == PowerDeviceD0); + } + else + { + /* No valid sleep states, no latencies to worry about */ + DeviceCapability->D1Latency = 0; + DeviceCapability->D2Latency = 0; + DeviceCapability->D3Latency = 0; + } + + /* This function always succeeds, even without power management support */ + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +PciQueryCapabilities(IN PPCI_PDO_EXTENSION PdoExtension, + IN OUT PDEVICE_CAPABILITIES DeviceCapability) +{ + NTSTATUS Status; + + /* A PDO ID is never unique, and its address is its function and device */ + DeviceCapability->UniqueID = FALSE; + DeviceCapability->Address = PdoExtension->Slot.u.bits.FunctionNumber | + (PdoExtension->Slot.u.bits.DeviceNumber << 16); + + /* Check for host bridges */ + if ((PdoExtension->BaseClass == PCI_CLASS_BRIDGE_DEV) && + (PdoExtension->SubClass == PCI_SUBCLASS_BR_HOST)) + { + /* Raw device opens to a host bridge are acceptable */ + DeviceCapability->RawDeviceOK = TRUE; + } + else + { + /* Otherwise, other PDOs cannot be directly opened */ + DeviceCapability->RawDeviceOK = FALSE; + } + + /* PCI PDOs are pretty fixed things */ + DeviceCapability->LockSupported = FALSE; + DeviceCapability->EjectSupported = FALSE; + DeviceCapability->Removable = FALSE; + DeviceCapability->DockDevice = FALSE; + + /* The slot number is stored as a device property, go query it */ + PciDetermineSlotNumber(PdoExtension, &DeviceCapability->UINumber); + + /* Finally, query and power capabilities and convert them for PnP usage */ + Status = PciQueryPowerCapabilities(PdoExtension, DeviceCapability); + + /* Dump the capabilities if it all worked, and return the status */ + if (NT_SUCCESS(Status)) PciDebugDumpQueryCapabilities(DeviceCapability); + return Status; +} + /* EOF */ From d9bd0072a1708d70a4fac79faf7ec8ea6ee3118b Mon Sep 17 00:00:00 2001 From: evb Date: Sat, 14 Aug 2010 17:33:10 +0000 Subject: [PATCH 03/76] - IRP_MN_QUERY_RESOURCES support for PDO (PciQueryResources, PciAllocateCmResourceList), now remain IRP_MN_QUERY_RESOURCE_REQUIREMENTS to last device stack interogration from PNPMGR svn path=/trunk/; revision=48549 --- reactos/drivers/bus/pcix/enum.c | 182 ++++++++++++++++++++++++++++++- reactos/drivers/bus/pcix/utils.c | 40 +++---- 2 files changed, 199 insertions(+), 23 deletions(-) diff --git a/reactos/drivers/bus/pcix/enum.c b/reactos/drivers/bus/pcix/enum.c index 3caa9882232..37bf55bcb7c 100644 --- a/reactos/drivers/bus/pcix/enum.c +++ b/reactos/drivers/bus/pcix/enum.c @@ -49,14 +49,190 @@ PCI_CONFIGURATOR PciConfigurators[] = /* FUNCTIONS ******************************************************************/ +PCM_RESOURCE_LIST +NTAPI +PciAllocateCmResourceList(IN ULONG Count, + IN ULONG BusNumber) +{ + SIZE_T Size; + PCM_RESOURCE_LIST ResourceList; + + /* Calculate the final size of the list, including each descriptor */ + Size = sizeof(CM_RESOURCE_LIST); + if (Count > 1) Size = sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) * (Count - 1) + + sizeof(CM_RESOURCE_LIST); + + /* Allocate the list */ + ResourceList = ExAllocatePoolWithTag(PagedPool, Size, 'BicP'); + if (!ResourceList) return NULL; + + /* Initialize it */ + RtlZeroMemory(ResourceList, Size); + ResourceList->Count = 1; + ResourceList->List[0].BusNumber = BusNumber; + ResourceList->List[0].InterfaceType = PCIBus; + ResourceList->List[0].PartialResourceList.Version = 1; + ResourceList->List[0].PartialResourceList.Revision = 1; + ResourceList->List[0].PartialResourceList.Count = Count; + + /* Return it */ + return ResourceList; +} + NTSTATUS NTAPI PciQueryResources(IN PPCI_PDO_EXTENSION PdoExtension, OUT PCM_RESOURCE_LIST *Buffer) { - /* Not yet implemented */ - UNIMPLEMENTED; - while (TRUE); + PPCI_FUNCTION_RESOURCES PciResources; + BOOLEAN HaveVga, HaveMemSpace, HaveIoSpace; + USHORT BridgeControl, PciCommand; + ULONG Count, i; + PCM_PARTIAL_RESOURCE_DESCRIPTOR Partial, Resource, LastResource; + PCM_RESOURCE_LIST ResourceList; + UCHAR InterruptLine; + PAGED_CODE(); + + /* Assume failure */ + Count = 0; + HaveVga = FALSE; + *Buffer = NULL; + + /* Make sure there's some resources to query */ + PciResources = PdoExtension->Resources; + if (!PciResources) return STATUS_SUCCESS; + + /* Read the decodes */ + PciReadDeviceConfig(PdoExtension, + &PciCommand, + FIELD_OFFSET(PCI_COMMON_HEADER, Command), + sizeof(USHORT)); + + /* Check which ones are turned on */ + HaveIoSpace = PciCommand & PCI_ENABLE_IO_SPACE; + HaveMemSpace = PciCommand & PCI_ENABLE_MEMORY_SPACE; + + /* Loop maximum possible descriptors */ + for (i = 0; i < 7; i++) + { + /* Check if the decode for this descriptor is actually turned on */ + Partial = &PciResources->Current[i]; + if (((HaveMemSpace) && (Partial->Type == CmResourceTypeMemory)) || + ((HaveIoSpace) && (Partial->Type == CmResourceTypePort))) + { + /* One more fully active descriptor */ + Count++; + } + } + + /* If there's an interrupt pin associated, check at least one decode is on */ + if ((PdoExtension->InterruptPin) && ((HaveMemSpace) || (HaveIoSpace))) + { + /* Read the interrupt line for the pin, add a descriptor if it's valid */ + InterruptLine = PdoExtension->AdjustedInterruptLine; + if ((InterruptLine) && (InterruptLine != -1)) Count++; + } + + /* Check for PCI bridge */ + if (PdoExtension->HeaderType == PCI_BRIDGE_TYPE) + { + /* Read bridge settings, check if VGA is present */ + PciReadDeviceConfig(PdoExtension, + &BridgeControl, + FIELD_OFFSET(PCI_COMMON_HEADER, u.type1.BridgeControl), + sizeof(USHORT)); + if (BridgeControl & PCI_ENABLE_BRIDGE_VGA) + { + /* Remember for later */ + HaveVga = TRUE; + + /* One memory descriptor for 0xA0000, plus the two I/O port ranges */ + if (HaveMemSpace) Count++; + if (HaveIoSpace) Count += 2; + } + } + + /* If there's no descriptors in use, there's no resources, so return */ + if (!Count) return STATUS_SUCCESS; + + /* Allocate a resource list to hold the resources */ + ResourceList = PciAllocateCmResourceList(Count, + PdoExtension->ParentFdoExtension->BaseBus); + if (!ResourceList) return STATUS_INSUFFICIENT_RESOURCES; + + /* This is where the descriptors will be copied into */ + Resource = ResourceList->List[0].PartialResourceList.PartialDescriptors; + LastResource = Resource + Count + 1; + + /* Loop maximum possible descriptors */ + for (i = 0; i < 7; i++) + { + /* Check if the decode for this descriptor is actually turned on */ + Partial = &PciResources->Current[i]; + if (((HaveMemSpace) && (Partial->Type == CmResourceTypeMemory)) || + ((HaveIoSpace) && (Partial->Type == CmResourceTypePort))) + { + /* Copy the descriptor into the resource list */ + *Resource++ = *Partial; + } + } + + /* Check if earlier the code detected this was a PCI bridge with VGA on it */ + if (HaveVga) + { + /* Are the memory decodes enabled? */ + if (HaveMemSpace) + { + /* Build a memory descriptor for a 128KB framebuffer at 0xA0000 */ + Resource->Flags = CM_RESOURCE_MEMORY_READ_WRITE; + Resource->u.Generic.Start.HighPart = 0; + Resource->Type = CmResourceTypeMemory; + Resource->u.Generic.Start.LowPart = 0xA0000; + Resource->u.Generic.Length = 0x20000; + Resource++; + } + + /* Are the I/O decodes enabled? */ + if (HaveIoSpace) + { + /* Build an I/O descriptor for the graphic ports at 0x3B0 */ + Resource->Type = CmResourceTypePort; + Resource->Flags = CM_RESOURCE_PORT_POSITIVE_DECODE | CM_RESOURCE_PORT_10_BIT_DECODE; + Resource->u.Port.Start.QuadPart = 0x3B0u; + Resource->u.Port.Length = 0xC; + Resource++; + + /* Build an I/O descriptor for the graphic ports at 0x3C0 */ + Resource->Type = CmResourceTypePort; + Resource->Flags = CM_RESOURCE_PORT_POSITIVE_DECODE | CM_RESOURCE_PORT_10_BIT_DECODE; + Resource->u.Port.Start.QuadPart = 0x3C0u; + Resource->u.Port.Length = 0x20; + Resource++; + } + } + + /* If there's an interrupt pin associated, check at least one decode is on */ + if ((PdoExtension->InterruptPin) && ((HaveMemSpace) || (HaveIoSpace))) + { + /* Read the interrupt line for the pin, check if it's valid */ + InterruptLine = PdoExtension->AdjustedInterruptLine; + if ((InterruptLine) && (InterruptLine != -1)) + { + /* Make sure there's still space */ + ASSERT(Resource < LastResource); + + /* Add the interrupt descriptor */ + Resource->Flags = CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE; + Resource->Type = CmResourceTypeInterrupt; + Resource->ShareDisposition = CmResourceShareShared; + Resource->u.Interrupt.Affinity = -1; + Resource->u.Interrupt.Level = InterruptLine; + Resource->u.Interrupt.Vector = InterruptLine; + } + } + + /* Return the resouce list */ + *Buffer = ResourceList; return STATUS_SUCCESS; } diff --git a/reactos/drivers/bus/pcix/utils.c b/reactos/drivers/bus/pcix/utils.c index fa0d91ecfdf..031b732c669 100644 --- a/reactos/drivers/bus/pcix/utils.c +++ b/reactos/drivers/bus/pcix/utils.c @@ -1355,7 +1355,7 @@ PciDetermineSlotNumber(IN PPCI_PDO_EXTENSION PdoExtension, SlotInfo->BusNumber, SlotInfo->DeviceNumber, SlotInfo->SlotNumber); - + /* Check if this slot information matches the PDO being queried */ if ((ParentExtension->BaseBus == SlotInfo->BusNumber) && (PdoExtension->Slot.u.bits.DeviceNumber == SlotInfo->DeviceNumber >> 3) && @@ -1365,7 +1365,7 @@ PciDetermineSlotNumber(IN PPCI_PDO_EXTENSION PdoExtension, *SlotNumber = SlotInfo->SlotNumber; return STATUS_SUCCESS; } - + /* Try the next slot */ SlotInfo++; } @@ -1475,7 +1475,7 @@ PciQueryPowerCapabilities(IN PPCI_PDO_EXTENSION PdoExtension, DEVICE_CAPABILITIES AttachedCaps; DEVICE_POWER_STATE NewPowerState, DevicePowerState, DeviceWakeLevel, DeviceWakeState; SYSTEM_POWER_STATE SystemWakeState, DeepestWakeState, CurrentState; - + /* Nothing is known at first */ DeviceWakeState = PowerDeviceUnspecified; SystemWakeState = DeepestWakeState = PowerSystemUnspecified; @@ -1523,7 +1523,7 @@ PciQueryPowerCapabilities(IN PPCI_PDO_EXTENSION PdoExtension, sizeof(DeviceCapability->DeviceState)); return STATUS_SUCCESS; } - + /* The PCI Device has power capabilities, so read which ones are supported */ DeviceCapability->DeviceD1 = PdoExtension->PowerCapabilities.Support.D1; DeviceCapability->DeviceD2 = PdoExtension->PowerCapabilities.Support.D2; @@ -1560,7 +1560,7 @@ PciQueryPowerCapabilities(IN PPCI_PDO_EXTENSION PdoExtension, /* Read the current mapping from the attached device */ DevicePowerState = AttachedCaps.DeviceState[CurrentState]; NewPowerState = DevicePowerState; - + /* The attachee suports D1, but this PDO does not */ if ((NewPowerState == PowerDeviceD1) && !(PdoExtension->PowerCapabilities.Support.D1)) @@ -1568,7 +1568,7 @@ PciQueryPowerCapabilities(IN PPCI_PDO_EXTENSION PdoExtension, /* Fall back to D2 */ NewPowerState = PowerDeviceD2; } - + /* The attachee supports D2, but this PDO does not */ if ((NewPowerState == PowerDeviceD2) && !(PdoExtension->PowerCapabilities.Support.D2)) @@ -1576,10 +1576,10 @@ PciQueryPowerCapabilities(IN PPCI_PDO_EXTENSION PdoExtension, /* Fall back to D3 */ NewPowerState = PowerDeviceD3; } - + /* Set the mapping based on the best state supported */ DeviceCapability->DeviceState[CurrentState] = NewPowerState; - + /* Check if sleep states are being processed, and a mapping was found */ if ((CurrentState < PowerSystemHibernate) && (NewPowerState != PowerDeviceUnspecified)) @@ -1587,8 +1587,8 @@ PciQueryPowerCapabilities(IN PPCI_PDO_EXTENSION PdoExtension, /* Save this state as being the deepest one found until now */ DeepestWakeState = CurrentState; } - - /* + + /* * Finally, check if the computed sleep state is within the states that * this device can wake the system from, and if it's higher or equal to * the sleep state mapping that came from the attachee, assuming that it @@ -1618,10 +1618,10 @@ PciQueryPowerCapabilities(IN PPCI_PDO_EXTENSION PdoExtension, DeviceWakeState = NewPowerState; } } - + /* Read the current wake level */ DeviceWakeLevel = PdoExtension->PowerState.DeviceWakeLevel; - + /* Check if the attachee's wake levels are valid, and the PDO's is higher */ if ((AttachedCaps.SystemWake != PowerSystemUnspecified) && (AttachedCaps.DeviceWake != PowerDeviceUnspecified) && @@ -1639,7 +1639,7 @@ PciQueryPowerCapabilities(IN PPCI_PDO_EXTENSION PdoExtension, /* Bump to D1 */ DeviceCapability->DeviceWake = PowerDeviceD1; } - + /* Now check if the wake level is D1, but the PDO doesn't support it */ if ((DeviceCapability->DeviceWake == PowerDeviceD1) && !(DeviceCapability->WakeFromD1)) @@ -1647,7 +1647,7 @@ PciQueryPowerCapabilities(IN PPCI_PDO_EXTENSION PdoExtension, /* Bump to D2 */ DeviceCapability->DeviceWake = PowerDeviceD2; } - + /* Now check if the wake level is D2, but the PDO doesn't support it */ if ((DeviceCapability->DeviceWake == PowerDeviceD2) && !(DeviceCapability->WakeFromD2)) @@ -1655,7 +1655,7 @@ PciQueryPowerCapabilities(IN PPCI_PDO_EXTENSION PdoExtension, /* Bump it to D3 */ DeviceCapability->DeviceWake = PowerDeviceD3; } - + /* Now check if the wake level is D3, but the PDO doesn't support it */ if ((DeviceCapability->DeviceWake == PowerDeviceD3) && !(DeviceCapability->WakeFromD3)) @@ -1676,12 +1676,12 @@ PciQueryPowerCapabilities(IN PPCI_PDO_EXTENSION PdoExtension, /* Use the wake state that had been computed earlier */ DeviceCapability->DeviceWake = DeviceWakeState; DeviceCapability->SystemWake = SystemWakeState; - + /* If that state was D3, then the device supports Hot/Cold D3 */ if (DeviceWakeState == PowerDeviceD3) DeviceCapability->WakeFromD3 = TRUE; } } - + /* * Finally, check for off states (lower than S3, such as hibernate) and * make sure that the device both supports waking from D3 as well as @@ -1694,12 +1694,12 @@ PciQueryPowerCapabilities(IN PPCI_PDO_EXTENSION PdoExtension, /* It doesn't, so pick the computed lowest wake state from earlier */ DeviceCapability->SystemWake = DeepestWakeState; } - + /* Set the PCI Specification mandated maximum latencies for transitions */ DeviceCapability->D1Latency = 0; DeviceCapability->D2Latency = 2; DeviceCapability->D3Latency = 100; - + /* Sanity check */ ASSERT(DeviceCapability->DeviceState[PowerSystemWorking] == PowerDeviceD0); } @@ -1710,7 +1710,7 @@ PciQueryPowerCapabilities(IN PPCI_PDO_EXTENSION PdoExtension, DeviceCapability->D2Latency = 0; DeviceCapability->D3Latency = 0; } - + /* This function always succeeds, even without power management support */ return STATUS_SUCCESS; } From fd24107d7d572decdc9cdf26d67bca437d148558 Mon Sep 17 00:00:00 2001 From: evb Date: Sat, 14 Aug 2010 18:06:19 +0000 Subject: [PATCH 04/76] - IRP_MN_QUERY_RESOURCE_REQUIREMENTS half support now, PciQueryRequirements, PciAllocateIoRequrementsList, full implement, but PciBuildRequirementsList return 0 always for now - Debug helpers: PciDebugPrintIoResReqList, PciDebugPrintIoResource, PciDebugCmResourceTypeToText Now hit assert Assertion '(DeviceNode->Flags & DNF_ADDED)' failed at ntoskrnl/io/pnpmgr/pnpmgr.c line 201, too night to debug, maybe tomorow svn path=/trunk/; revision=48550 --- reactos/drivers/bus/pcix/debug.c | 92 +++++++++++++++++++++++++- reactos/drivers/bus/pcix/enum.c | 110 ++++++++++++++++++++++++++++++- reactos/drivers/bus/pcix/pci.h | 6 ++ 3 files changed, 204 insertions(+), 4 deletions(-) diff --git a/reactos/drivers/bus/pcix/debug.c b/reactos/drivers/bus/pcix/debug.c index 1f119c274db..8f1ed81616b 100644 --- a/reactos/drivers/bus/pcix/debug.c +++ b/reactos/drivers/bus/pcix/debug.c @@ -246,9 +246,99 @@ PciDebugDumpQueryCapabilities(IN PDEVICE_CAPABILITIES DeviceCaps) /* Dump and convert the power state mappings */ for (i = PowerSystemWorking; i < PowerSystemMaximum; i++) DbgPrint(" %s", DevicePowerStates[DeviceCaps->DeviceState[i]]); - + /* Finish the dump */ DbgPrint(" ]\n"); } +PCHAR +NTAPI +PciDebugCmResourceTypeToText(IN UCHAR Type) +{ + /* What kind of resource it this? */ + switch (Type) + { + /* Pick the correct identifier string based on the type */ + case CmResourceTypeDeviceSpecific: return "CmResourceTypeDeviceSpecific"; + case CmResourceTypePort: return "CmResourceTypePort"; + case CmResourceTypeInterrupt: return "CmResourceTypeInterrupt"; + case CmResourceTypeMemory: return "CmResourceTypeMemory"; + case CmResourceTypeDma: return "CmResourceTypeDma"; + case CmResourceTypeBusNumber: return "CmResourceTypeBusNumber"; + case CmResourceTypeConfigData: return "CmResourceTypeConfigData"; + case CmResourceTypeDevicePrivate: return "CmResourceTypeDevicePrivate"; + case CmResourceTypePcCardConfig: return "CmResourceTypePcCardConfig"; + default: return "*** INVALID RESOURCE TYPE ***"; + } +} + +VOID +NTAPI +PciDebugPrintIoResource(IN PIO_RESOURCE_DESCRIPTOR Descriptor) +{ + ULONG i; + PULONG Data; + + /* Print out the header */ + DPRINT1(" IoResource Descriptor dump: Descriptor @0x%x\n", Descriptor); + DPRINT1(" Option = 0x%x\n", Descriptor->Option); + DPRINT1(" Type = %d (%s)\n", Descriptor->Type, PciDebugCmResourceTypeToText(Descriptor->Type)); + DPRINT1(" ShareDisposition = %d\n", Descriptor->ShareDisposition); + DPRINT1(" Flags = 0x%04X\n", Descriptor->Flags); + + /* Loop private data */ + Data = (PULONG)&Descriptor->u.DevicePrivate; + for (i = 0; i < 6; i += 3) + { + /* Dump it in 32-bit triplets */ + DPRINT1(" Data[%d] = %08x %08x %08x\n", i, Data[0], Data[1], Data[2]); + } +} + +VOID +NTAPI +PciDebugPrintIoResReqList(IN PIO_RESOURCE_REQUIREMENTS_LIST Requirements) +{ + ULONG AlternativeLists; + PIO_RESOURCE_LIST List; + ULONG Count; + PIO_RESOURCE_DESCRIPTOR Descriptor; + + /* Make sure there's a list */ + if (!Requirements) return; + + /* Grab the main list and the alternates as well */ + AlternativeLists = Requirements->AlternativeLists; + List = Requirements->List; + + /* Print out the initial header*/ + DPRINT1(" IO_RESOURCE_REQUIREMENTS_LIST (PCI Bus Driver)\n"); + DPRINT1(" InterfaceType %d\n", Requirements->InterfaceType); + DPRINT1(" BusNumber 0x%x\n", Requirements->BusNumber); + DPRINT1(" SlotNumber %d (0x%x), (d/f = 0x%x/0x%x)\n", + Requirements->SlotNumber, + Requirements->SlotNumber, + ((PCI_SLOT_NUMBER*)&Requirements->SlotNumber)->u.bits.DeviceNumber, + ((PCI_SLOT_NUMBER*)&Requirements->SlotNumber)->u.bits.FunctionNumber); + DPRINT1(" AlternativeLists %d\n", AlternativeLists); + + /* Scan alternative lists */ + while (AlternativeLists--) + { + /* Get the descriptor array, and the count of descriptors */ + Descriptor = List->Descriptors; + Count = List->Count; + + /* Print out each descriptor */ + DPRINT1("\n List[%d].Count = %d\n", AlternativeLists, Count); + while (Count--) PciDebugPrintIoResource(Descriptor++); + + /* Should've reached a new list now */ + List = (PIO_RESOURCE_LIST)Descriptor; + } + + /* Terminate the dump */ + DPRINT1("\n"); +} + /* EOF */ diff --git a/reactos/drivers/bus/pcix/enum.c b/reactos/drivers/bus/pcix/enum.c index 37bf55bcb7c..4e17a7f700a 100644 --- a/reactos/drivers/bus/pcix/enum.c +++ b/reactos/drivers/bus/pcix/enum.c @@ -49,6 +49,39 @@ PCI_CONFIGURATOR PciConfigurators[] = /* FUNCTIONS ******************************************************************/ +PIO_RESOURCE_REQUIREMENTS_LIST +NTAPI +PciAllocateIoRequirementsList(IN ULONG Count, + IN ULONG BusNumber, + IN ULONG SlotNumber) +{ + SIZE_T Size; + PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList; + + /* Calculate the final size of the list, including each descriptor */ + Size = sizeof(IO_RESOURCE_REQUIREMENTS_LIST); + if (Count > 1) Size = sizeof(IO_RESOURCE_DESCRIPTOR) * (Count - 1) + + sizeof(IO_RESOURCE_REQUIREMENTS_LIST); + + /* Allocate the list */ + RequirementsList = ExAllocatePoolWithTag(PagedPool, Size, 'BicP'); + if (!RequirementsList) return NULL; + + /* Initialize it */ + RtlZeroMemory(RequirementsList, Size); + RequirementsList->AlternativeLists = 1; + RequirementsList->BusNumber = BusNumber; + RequirementsList->SlotNumber = SlotNumber; + RequirementsList->InterfaceType = PCIBus; + RequirementsList->ListSize = Size; + RequirementsList->List[0].Count = Count; + RequirementsList->List[0].Version = 1; + RequirementsList->List[0].Revision = 1; + + /* Return it */ + return RequirementsList; +} + PCM_RESOURCE_LIST NTAPI PciAllocateCmResourceList(IN ULONG Count, @@ -273,14 +306,85 @@ PciQueryEjectionRelations(IN PPCI_PDO_EXTENSION PdoExtension, while (TRUE); } +NTSTATUS +NTAPI +PciBuildRequirementsList(IN PPCI_PDO_EXTENSION PdoExtension, + IN PPCI_COMMON_HEADER PciData, + OUT PIO_RESOURCE_REQUIREMENTS_LIST* Buffer) +{ + PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList; + { + /* There aren't, so use the zero descriptor */ + RequirementsList = PciZeroIoResourceRequirements; + + /* Does it actually exist yet? */ + if (!PciZeroIoResourceRequirements) + { + /* Allocate it, and use it for future use */ + RequirementsList = PciAllocateIoRequirementsList(0, 0, 0); + PciZeroIoResourceRequirements = RequirementsList; + if (!PciZeroIoResourceRequirements) return STATUS_INSUFFICIENT_RESOURCES; + } + + /* Return the zero requirements list to the caller */ + *Buffer = RequirementsList; + DPRINT1("PCI - build resource reqs - early out, 0 resources\n"); + return STATUS_SUCCESS; + } + return STATUS_SUCCESS; +} + NTSTATUS NTAPI PciQueryRequirements(IN PPCI_PDO_EXTENSION PdoExtension, IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *RequirementsList) { - /* Not yet implemented */ - UNIMPLEMENTED; - while (TRUE); + NTSTATUS Status; + PCI_COMMON_HEADER PciHeader; + PAGED_CODE(); + + /* Check if the PDO has any resources, or at least an interrupt pin */ + if ((PdoExtension->Resources) || (PdoExtension->InterruptPin)) + { + /* Read the current PCI header */ + PciReadDeviceConfig(PdoExtension, &PciHeader, 0, PCI_COMMON_HDR_LENGTH); + + /* Use it to build a list of requirements */ + Status = PciBuildRequirementsList(PdoExtension, &PciHeader, RequirementsList); + if (!NT_SUCCESS(Status)) return Status; + + /* Is this a Compaq PCI Hotplug Controller (r17) on a PAE system ? */ + if ((PciHeader.VendorID == 0xE11) && + (PciHeader.DeviceID == 0xA0F7) && + (PciHeader.RevisionID == 17) && + (ExIsProcessorFeaturePresent(PF_PAE_ENABLED))) + { + /* Have not tested this on eVb's machine yet */ + UNIMPLEMENTED; + while (TRUE); + } + + /* Check if the requirements are actually the zero list */ + if (*RequirementsList == PciZeroIoResourceRequirements) + { + /* A simple NULL will sufficie for the PnP Manager */ + *RequirementsList = NULL; + DPRINT1("Returning NULL requirements list\n"); + } + else + { + /* Otherwise, print out the requirements list */ + PciDebugPrintIoResReqList(*RequirementsList); + } + } + else + { + /* There aren't any resources, so simply return NULL */ + DPRINT1("PciQueryRequirements returning NULL requirements list\n"); + *RequirementsList = NULL; + } + + /* This call always succeeds (but maybe with no requirements) */ return STATUS_SUCCESS; } diff --git a/reactos/drivers/bus/pcix/pci.h b/reactos/drivers/bus/pcix/pci.h index 87b1c44a13c..866784ac87f 100644 --- a/reactos/drivers/bus/pcix/pci.h +++ b/reactos/drivers/bus/pcix/pci.h @@ -1255,6 +1255,12 @@ PciDebugDumpQueryCapabilities( IN PDEVICE_CAPABILITIES DeviceCaps ); +VOID +NTAPI +PciDebugPrintIoResReqList( + IN PIO_RESOURCE_REQUIREMENTS_LIST Requirements +); + // // Interface Support // From a81b1fdd76f2183c701e6e4c8d75519f1f7a6181 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Sun, 15 Aug 2010 08:48:03 +0000 Subject: [PATCH 05/76] [NTOSKRNL] - Revert 48546. The code was correct, and there is more of same code in other places which firstly cancels the IRP and then moves to the next entry. The actual bug is somewhere else. See issue #5550 for more details. svn path=/trunk/; revision=48551 --- reactos/ntoskrnl/io/iomgr/irp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/reactos/ntoskrnl/io/iomgr/irp.c b/reactos/ntoskrnl/io/iomgr/irp.c index bd0eb8881d6..a578e89731a 100644 --- a/reactos/ntoskrnl/io/iomgr/irp.c +++ b/reactos/ntoskrnl/io/iomgr/irp.c @@ -1047,12 +1047,14 @@ IoCancelThreadIo(IN PETHREAD Thread) NextEntry = ListHead->Flink; while (ListHead != NextEntry) { - /* Get the IRP and move to the next entry */ + /* Get the IRP */ Irp = CONTAINING_RECORD(NextEntry, IRP, ThreadListEntry); - NextEntry = NextEntry->Flink; /* Cancel it */ IoCancelIrp(Irp); + + /* Move to the next entry */ + NextEntry = NextEntry->Flink; } /* Wait 100 milliseconds */ From d35828af5a1025e5510599906dbee0ce319d967d Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 16 Aug 2010 00:06:55 +0000 Subject: [PATCH 06/76] [user32_winetest] Skip 2 tests that hang on reactos. Patch by Giannis Adamopoulos svn path=/trunk/; revision=48554 --- rostests/winetests/user32/msg.c | 6 ++++-- rostests/winetests/user32/win.c | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/rostests/winetests/user32/msg.c b/rostests/winetests/user32/msg.c index e0494ef2a06..1a595c77c5f 100755 --- a/rostests/winetests/user32/msg.c +++ b/rostests/winetests/user32/msg.c @@ -12572,7 +12572,8 @@ START_TEST(msg) test_paint_messages(); test_interthread_messages(); test_message_conversion(); - test_accelerators(); + skip("skipping test_accelerators, that hangs on reactos\n"); + //test_accelerators(); test_timers(); test_timers_no_wnd(); if (hCBT_hook) test_set_hook(); @@ -12593,7 +12594,8 @@ START_TEST(msg) test_dialog_messages(); test_nullCallback(); test_dbcs_wm_char(); - test_menu_messages(); + skip("skipping test_menu_messages, that hangs on reactos\n"); + //test_menu_messages(); test_paintingloop(); test_defwinproc(); test_clipboard_viewers(); diff --git a/rostests/winetests/user32/win.c b/rostests/winetests/user32/win.c index eadad3ac44d..af048515ef9 100644 --- a/rostests/winetests/user32/win.c +++ b/rostests/winetests/user32/win.c @@ -6058,7 +6058,9 @@ START_TEST(win) test_capture_1(); test_capture_2(); test_capture_3(hwndMain, hwndMain2); - test_capture_4(); + + skip("skipping test_capture_4, that hangs on reactos\n"); + //test_capture_4(); test_CreateWindow(); test_parent_owner(); From 40f30e94229cef614c800b0409d4b39b31af87e6 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 16 Aug 2010 01:29:13 +0000 Subject: [PATCH 07/76] [WIN32K] - Remove IntEngExtEscape stub. This function is completely useless. If the driver doesn't provide a DrvEscape, the function should simply fail and must return 0, not -1. - If a NULL surface is passed, pass on NULL pso to the driver function See issue #4563 for more details. svn path=/trunk/; revision=48555 --- .../subsystems/win32/win32k/objects/print.c | 31 ++----------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/reactos/subsystems/win32/win32k/objects/print.c b/reactos/subsystems/win32/win32k/objects/print.c index bf21047292f..6377c5e9cae 100644 --- a/reactos/subsystems/win32/win32k/objects/print.c +++ b/reactos/subsystems/win32/win32k/objects/print.c @@ -87,23 +87,6 @@ NtGdiEscape(HDC hDC, return ret; } -INT -APIENTRY -IntEngExtEscape( - SURFOBJ *Surface, - INT Escape, - INT InSize, - LPVOID InData, - INT OutSize, - LPVOID OutData) -{ - if (Escape == QUERYESCSUPPORT) - return FALSE; - - DPRINT1("IntEngExtEscape is unimplemented. - Keep going and have a nice day\n"); - return -1; -} - INT APIENTRY IntGdiExtEscape( @@ -117,22 +100,14 @@ IntGdiExtEscape( SURFACE *psurf = dc->dclevel.pSurface; INT Result; - /* FIXME - Handle psurf == NULL !!!!!! */ - - if ( NULL == dc->ppdev->DriverFunctions.Escape ) + if (!dc->ppdev->DriverFunctions.Escape) { - Result = IntEngExtEscape( - &psurf->SurfObj, - Escape, - InSize, - (PVOID)((ULONG_PTR)InData), - OutSize, - (PVOID)OutData); + Result = 0; } else { Result = dc->ppdev->DriverFunctions.Escape( - &psurf->SurfObj, + psurf ? &psurf->SurfObj : NULL, Escape, InSize, (PVOID)InData, From 49a96cdea9a3f24cd883eb10e4fe93b51846c428 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 16 Aug 2010 01:57:09 +0000 Subject: [PATCH 08/76] [NTDLL] LdrPerformRelocations: Delta is a LONG_PTR rather than ULONG_PTR See issue #5577 for more details. svn path=/trunk/; revision=48556 --- reactos/dll/ntdll/ldr/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/dll/ntdll/ldr/utils.c b/reactos/dll/ntdll/ldr/utils.c index 14512194832..e4b1a61a587 100644 --- a/reactos/dll/ntdll/ldr/utils.c +++ b/reactos/dll/ntdll/ldr/utils.c @@ -1388,7 +1388,7 @@ LdrPerformRelocations(PIMAGE_NT_HEADERS NTHeaders, ULONG Count, ProtectSize, OldProtect, OldProtect2; PVOID Page, ProtectPage, ProtectPage2; PUSHORT TypeOffset; - ULONG_PTR Delta; + LONG_PTR Delta; NTSTATUS Status; if (NTHeaders->FileHeader.Characteristics & IMAGE_FILE_RELOCS_STRIPPED) From 2ded5adf7ce90b5febcc72c1cdafc419035bb1fe Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 16 Aug 2010 20:18:25 +0000 Subject: [PATCH 09/76] [NTOSKRNL] - Fixed IoGetRequestorProcess, IoGetRequestorProcessId, IoGetRequestorSessionId - Pass user buffer in NtNotifyChangeDirectoryFile - Fixed magic value in IoGetPagingIoPriority Patch by Pierre Schweitzer svn path=/trunk/; revision=48557 --- reactos/include/ddk/wdm.h | 2 ++ reactos/include/xdk/iotypes.h | 3 +++ reactos/ntoskrnl/io/iomgr/iofunc.c | 1 + reactos/ntoskrnl/io/iomgr/irp.c | 31 ++++++++++++++++++++++++------ 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/reactos/include/ddk/wdm.h b/reactos/include/ddk/wdm.h index b1475afb4d0..daffb9b1fd5 100644 --- a/reactos/include/ddk/wdm.h +++ b/reactos/include/ddk/wdm.h @@ -5456,6 +5456,8 @@ typedef struct _IO_COMPLETION_CONTEXT { #define IRP_DEFER_IO_COMPLETION 0x00000800 #define IRP_OB_QUERY_NAME 0x00001000 #define IRP_HOLD_DEVICE_QUEUE 0x00002000 +#define IRP_RETRY_IO_COMPLETION 0x00004000 +#define IRP_CLASS_CACHE_OPERATION 0x00008000 #define IRP_QUOTA_CHARGED 0x01 #define IRP_ALLOCATED_MUST_SUCCEED 0x02 diff --git a/reactos/include/xdk/iotypes.h b/reactos/include/xdk/iotypes.h index 55673244e1a..9e1446c2245 100644 --- a/reactos/include/xdk/iotypes.h +++ b/reactos/include/xdk/iotypes.h @@ -1793,6 +1793,9 @@ $if (_WDMDDK_) #define IRP_DEFER_IO_COMPLETION 0x00000800 #define IRP_OB_QUERY_NAME 0x00001000 #define IRP_HOLD_DEVICE_QUEUE 0x00002000 +/* The following 2 are missing in latest WDK */ +#define IRP_RETRY_IO_COMPLETION 0x00004000 +#define IRP_CLASS_CACHE_OPERATION 0x00008000 #define IRP_QUOTA_CHARGED 0x01 #define IRP_ALLOCATED_MUST_SUCCEED 0x02 diff --git a/reactos/ntoskrnl/io/iomgr/iofunc.c b/reactos/ntoskrnl/io/iomgr/iofunc.c index c40e7c9d789..6a3bfbc2862 100644 --- a/reactos/ntoskrnl/io/iomgr/iofunc.c +++ b/reactos/ntoskrnl/io/iomgr/iofunc.c @@ -1175,6 +1175,7 @@ NtNotifyChangeDirectoryFile(IN HANDLE FileHandle, Irp->RequestorMode = PreviousMode; Irp->UserIosb = IoStatusBlock; Irp->UserEvent = Event; + Irp->UserBuffer = Buffer; Irp->Tail.Overlay.Thread = PsGetCurrentThread(); Irp->Tail.Overlay.OriginalFileObject = FileObject; Irp->Overlay.AsynchronousParameters.UserApcRoutine = ApcRoutine; diff --git a/reactos/ntoskrnl/io/iomgr/irp.c b/reactos/ntoskrnl/io/iomgr/irp.c index a578e89731a..53649f1de70 100644 --- a/reactos/ntoskrnl/io/iomgr/irp.c +++ b/reactos/ntoskrnl/io/iomgr/irp.c @@ -1415,7 +1415,6 @@ IofCompleteRequest(IN PIRP Irp, else { /* The IRP just got canceled... does a thread still own it? */ - Thread = Irp->Tail.Overlay.Thread; if (Thread) { /* Yes! There is still hope! Initialize the APC */ @@ -1576,7 +1575,7 @@ IoGetPagingIoPriority(IN PIRP Irp) Flags = Irp->Flags; /* Check what priority it has */ - if (Flags & 0x8000) // FIXME: Undocumented flag + if (Flags & IRP_CLASS_CACHE_OPERATION) { /* High priority */ Priority = IoPagingPriorityHigh; @@ -1604,7 +1603,12 @@ NTAPI IoGetRequestorProcess(IN PIRP Irp) { /* Return the requestor process */ - return Irp->Tail.Overlay.Thread->ThreadsProcess; + if (Irp->Tail.Overlay.Thread) + { + return Irp->Tail.Overlay.Thread->ThreadsProcess; + } + + return NULL; } /* @@ -1614,8 +1618,15 @@ ULONG NTAPI IoGetRequestorProcessId(IN PIRP Irp) { + PEPROCESS Process; + /* Return the requestor process' id */ - return PtrToUlong(IoGetRequestorProcess(Irp)->UniqueProcessId); + if ((Process = IoGetRequestorProcess(Irp))) + { + return PtrToUlong(Process->UniqueProcessId); + } + + return 0; } /* @@ -1626,9 +1637,17 @@ NTAPI IoGetRequestorSessionId(IN PIRP Irp, OUT PULONG pSessionId) { + PEPROCESS Process; + /* Return the session */ - *pSessionId = IoGetRequestorProcess(Irp)->Session; - return STATUS_SUCCESS; + if ((Process = IoGetRequestorProcess(Irp))) + { + *pSessionId = Process->Session; + return STATUS_SUCCESS; + } + + *pSessionId = (ULONG)-1; + return STATUS_UNSUCCESSFUL; } /* From 3d5db91752dccba0eb83217f27b3fd21fa7c2a8c Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 17 Aug 2010 16:04:46 +0000 Subject: [PATCH 10/76] [NTOSKRNL] - Simplified IopGetRelatedTargetDevice implementation - Added notification in case of success in NtSetVolumeInformationFile() Patch by Pierre Schweitzer svn path=/trunk/; revision=48559 --- reactos/ntoskrnl/io/iomgr/device.c | 13 +++++-------- reactos/ntoskrnl/io/iomgr/iofunc.c | 27 +++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/reactos/ntoskrnl/io/iomgr/device.c b/reactos/ntoskrnl/io/iomgr/device.c index ec6de6c770a..88e5ba4fa67 100644 --- a/reactos/ntoskrnl/io/iomgr/device.c +++ b/reactos/ntoskrnl/io/iomgr/device.c @@ -671,7 +671,6 @@ IopGetRelatedTargetDevice(IN PFILE_OBJECT FileObject, { NTSTATUS Status; IO_STACK_LOCATION Stack = {0}; - IO_STATUS_BLOCK IoStatusBlock; PDEVICE_RELATIONS DeviceRelations; PDEVICE_OBJECT DeviceObject = NULL; @@ -682,19 +681,17 @@ IopGetRelatedTargetDevice(IN PFILE_OBJECT FileObject, if (!DeviceObject) return STATUS_NO_SUCH_DEVICE; /* Define input parameters */ + Stack.MajorFunction = IRP_MJ_PNP; + Stack.MinorFunction = IRP_MN_QUERY_DEVICE_RELATIONS; Stack.Parameters.QueryDeviceRelations.Type = TargetDeviceRelation; Stack.FileObject = FileObject; /* Call the driver to query all relations (IRP_MJ_PNP) */ - Status = IopInitiatePnpIrp(DeviceObject, - &IoStatusBlock, - IRP_MN_QUERY_DEVICE_RELATIONS, - &Stack); + Status = IopSynchronousCall(DeviceObject, + &Stack, + (PVOID)&DeviceRelations); if (!NT_SUCCESS(Status)) return Status; - /* Get returned pointer to DEVICE_RELATIONS */ - DeviceRelations = (PDEVICE_RELATIONS)IoStatusBlock.Information; - /* Make sure it's not NULL and contains only one object */ ASSERT(DeviceRelations); ASSERT(DeviceRelations->Count == 1); diff --git a/reactos/ntoskrnl/io/iomgr/iofunc.c b/reactos/ntoskrnl/io/iomgr/iofunc.c index 6a3bfbc2862..22e8710a4e3 100644 --- a/reactos/ntoskrnl/io/iomgr/iofunc.c +++ b/reactos/ntoskrnl/io/iomgr/iofunc.c @@ -11,6 +11,7 @@ /* INCLUDES *****************************************************************/ #include +#include #define NDEBUG #include #include "internal/io_i.h" @@ -3223,12 +3224,13 @@ NtSetVolumeInformationFile(IN HANDLE FileHandle, PFILE_OBJECT FileObject; PIRP Irp; PIO_STACK_LOCATION StackPtr; - PDEVICE_OBJECT DeviceObject; + PDEVICE_OBJECT DeviceObject, TargetDeviceObject; PKEVENT Event = NULL; BOOLEAN LocalEvent = FALSE; KPROCESSOR_MODE PreviousMode = KeGetPreviousMode(); NTSTATUS Status; IO_STATUS_BLOCK KernelIosb; + TARGET_DEVICE_CUSTOM_NOTIFICATION NotificationStructure; PAGED_CODE(); IOTRACE(IO_API_DEBUG, "FileHandle: %p\n", FileHandle); @@ -3277,6 +3279,10 @@ NtSetVolumeInformationFile(IN HANDLE FileHandle, NULL); if (!NT_SUCCESS(Status)) return Status; + /* Get target device for notification */ + Status = IoGetRelatedTargetDevice(FileObject, &TargetDeviceObject); + if (!NT_SUCCESS(Status)) TargetDeviceObject = NULL; + /* Check if we should use Sync IO or not */ if (FileObject->Flags & FO_SYNCHRONOUS_IO) { @@ -3290,6 +3296,7 @@ NtSetVolumeInformationFile(IN HANDLE FileHandle, if (!Event) { ObDereferenceObject(FileObject); + if (TargetDeviceObject) ObDereferenceObject(TargetDeviceObject); return STATUS_INSUFFICIENT_RESOURCES; } KeInitializeEvent(Event, SynchronizationEvent, FALSE); @@ -3304,7 +3311,11 @@ NtSetVolumeInformationFile(IN HANDLE FileHandle, /* Allocate the IRP */ Irp = IoAllocateIrp(DeviceObject->StackSize, FALSE); - if (!Irp) return IopCleanupFailedIrp(FileObject, NULL, Event); + if (!Irp) + { + if (TargetDeviceObject) ObDereferenceObject(TargetDeviceObject); + return IopCleanupFailedIrp(FileObject, NULL, Event); + } /* Set up the IRP */ Irp->RequestorMode = PreviousMode; @@ -3339,6 +3350,7 @@ NtSetVolumeInformationFile(IN HANDLE FileHandle, { /* Allocating failed, clean up and return the exception code */ IopCleanupAfterException(FileObject, Irp, NULL, Event); + if (TargetDeviceObject) ObDereferenceObject(TargetDeviceObject); _SEH2_YIELD(return _SEH2_GetExceptionCode()); } _SEH2_END; @@ -3371,6 +3383,17 @@ NtSetVolumeInformationFile(IN HANDLE FileHandle, IoStatusBlock); } + if (TargetDeviceObject && NT_SUCCESS(Status)) + { + /* Time to report change */ + NotificationStructure.Version = 1; + NotificationStructure.Size = sizeof(TARGET_DEVICE_CUSTOM_NOTIFICATION); + NotificationStructure.Event = GUID_IO_VOLUME_NAME_CHANGE; + NotificationStructure.FileObject = NULL; + NotificationStructure.NameBufferOffset = - 1; + Status = IoReportTargetDeviceChange(TargetDeviceObject, &NotificationStructure); + } + /* Return status */ return Status; } From 1cbf4c405723c8446bb9af7cbe788c8bcf8d4fc3 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 18 Aug 2010 23:21:15 +0000 Subject: [PATCH 11/76] [FASTFAT] Make our FAT driver PNP aware. On PNP requests it should handle, it will return STATUS_NOT_IMPLEMENTED. On the others, it will pass them to lower driver. This is the first step outside the kernel into getting IoGetRelatedTargetDevice (and so notifications) working. It doesn't work at the moment, as class2 doesn't handle PNP. [NTOSKRNL] Some fixes to IRP cancelation process: - Renamed IopRemoveThreadIrp() to IopDisassociateThreadIrp() to match Windows 2k3 - Made dead IRP global, to make its debug easier. - IopDisassociateThreadIrp(), Handle dead IRP at dispatch level, using IoCompletionLock. - IopDisassociateThreadIrp(), Use the proper error code to write the entry to logs. - IoCancelIrp(), removed non needed ASSERT, which is even not present on Windows, removed corresponding var as well. - IoCancelIrp(), fixed parameters to KeBugCheckEx() call. - IoCancelThreadIo() is pageable. - IoCancelThreadIo() under Windows isn't using given thread, but using current. Do the same here. All that stuff doesn't fix bug #5550, it comes from outside. Patch by Pierre Schweitzer, modified by me to make it compile. If it breaks anything, don't blame me! svn path=/trunk/; revision=48560 --- reactos/drivers/filesystems/fastfat/iface.c | 1 + reactos/drivers/filesystems/fastfat/misc.c | 2 + reactos/drivers/filesystems/fastfat/pnp.c | 42 +++++++++++++++++++ reactos/drivers/filesystems/fastfat/vfat.h | 3 ++ .../drivers/filesystems/fastfat/vfatfs.rbuild | 1 + reactos/ntoskrnl/io/iomgr/irp.c | 40 +++++++++++------- 6 files changed, 73 insertions(+), 16 deletions(-) create mode 100644 reactos/drivers/filesystems/fastfat/pnp.c diff --git a/reactos/drivers/filesystems/fastfat/iface.c b/reactos/drivers/filesystems/fastfat/iface.c index 6bf97159deb..de9bb165a33 100644 --- a/reactos/drivers/filesystems/fastfat/iface.c +++ b/reactos/drivers/filesystems/fastfat/iface.c @@ -100,6 +100,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject, DriverObject->MajorFunction[IRP_MJ_LOCK_CONTROL] = VfatBuildRequest; DriverObject->MajorFunction[IRP_MJ_CLEANUP] = VfatBuildRequest; DriverObject->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = VfatBuildRequest; + DriverObject->MajorFunction[IRP_MJ_PNP] = VfatBuildRequest; DriverObject->DriverUnload = NULL; diff --git a/reactos/drivers/filesystems/fastfat/misc.c b/reactos/drivers/filesystems/fastfat/misc.c index 688086acec2..71d94b5acb7 100644 --- a/reactos/drivers/filesystems/fastfat/misc.c +++ b/reactos/drivers/filesystems/fastfat/misc.c @@ -127,6 +127,8 @@ VfatDispatchRequest (IN PVFAT_IRP_CONTEXT IrpContext) return VfatCleanup(IrpContext); case IRP_MJ_FLUSH_BUFFERS: return VfatFlush(IrpContext); + case IRP_MJ_PNP: + return VfatPnp(IrpContext); default: DPRINT1 ("Unexpected major function %x\n", IrpContext->MajorFunction); IrpContext->Irp->IoStatus.Status = STATUS_DRIVER_INTERNAL_ERROR; diff --git a/reactos/drivers/filesystems/fastfat/pnp.c b/reactos/drivers/filesystems/fastfat/pnp.c new file mode 100644 index 00000000000..a1e909e7da9 --- /dev/null +++ b/reactos/drivers/filesystems/fastfat/pnp.c @@ -0,0 +1,42 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: drivers/filesystems/fastfat/pnp.c + * PURPOSE: VFAT Filesystem + * PROGRAMMER: Pierre Schweitzer + * + */ + +/* INCLUDES *****************************************************************/ + +#define NDEBUG +#include "vfat.h" + +/* FUNCTIONS ****************************************************************/ + +NTSTATUS VfatPnp(PVFAT_IRP_CONTEXT IrpContext) +{ + PVCB Vcb = NULL; + NTSTATUS Status; + + /* PRECONDITION */ + ASSERT(IrpContext); + + switch (IrpContext->Stack->MinorFunction) + { + case IRP_MN_QUERY_REMOVE_DEVICE: + case IRP_MN_SURPRISE_REMOVAL: + case IRP_MN_REMOVE_DEVICE: + case IRP_MN_CANCEL_REMOVE_DEVICE: + Status = STATUS_NOT_IMPLEMENTED; + break; + default: + IoSkipCurrentIrpStackLocation(IrpContext->Irp); + Vcb = (PVCB)IrpContext->Stack->DeviceObject->DeviceExtension; + Status = IoCallDriver(Vcb->StorageDevice, IrpContext->Irp); + } + + VfatFreeIrpContext(IrpContext); + + return Status; +} diff --git a/reactos/drivers/filesystems/fastfat/vfat.h b/reactos/drivers/filesystems/fastfat/vfat.h index e9c37da3d63..3521d31a36d 100644 --- a/reactos/drivers/filesystems/fastfat/vfat.h +++ b/reactos/drivers/filesystems/fastfat/vfat.h @@ -775,5 +775,8 @@ NTSTATUS VfatFlush(PVFAT_IRP_CONTEXT IrpContext); NTSTATUS VfatFlushVolume(PDEVICE_EXTENSION DeviceExt, PVFATFCB VolumeFcb); +/* --------------------------------------------------------------- pnp.c */ + +NTSTATUS VfatPnp(PVFAT_IRP_CONTEXT IrpContext); /* EOF */ diff --git a/reactos/drivers/filesystems/fastfat/vfatfs.rbuild b/reactos/drivers/filesystems/fastfat/vfatfs.rbuild index 56ca836973c..a8e81d2c2c3 100644 --- a/reactos/drivers/filesystems/fastfat/vfatfs.rbuild +++ b/reactos/drivers/filesystems/fastfat/vfatfs.rbuild @@ -21,6 +21,7 @@ fsctl.c iface.c misc.c + pnp.c rw.c shutdown.c string.c diff --git a/reactos/ntoskrnl/io/iomgr/irp.c b/reactos/ntoskrnl/io/iomgr/irp.c index 53649f1de70..55d316adf55 100644 --- a/reactos/ntoskrnl/io/iomgr/irp.c +++ b/reactos/ntoskrnl/io/iomgr/irp.c @@ -18,6 +18,8 @@ #undef IoCallDriver #undef IoCompleteRequest +PIRP IopDeadIrp; + /* PRIVATE FUNCTIONS ********************************************************/ VOID @@ -112,10 +114,9 @@ IopAbortInterruptedIrp(IN PKEVENT EventObject, VOID NTAPI -IopRemoveThreadIrp(VOID) +IopDisassociateThreadIrp(VOID) { - KIRQL OldIrql; - PIRP DeadIrp; + KIRQL OldIrql, LockIrql; PETHREAD IrpThread; PLIST_ENTRY IrpEntry; PIO_ERROR_LOG_PACKET ErrorLogEntry; @@ -134,36 +135,41 @@ IopRemoveThreadIrp(VOID) return; } + /* Ensure no one will come disturb */ + LockIrql = KeAcquireQueuedSpinLock(LockQueueIoCompletionLock); + /* Get the misbehaving IRP */ IrpEntry = IrpThread->IrpList.Flink; - DeadIrp = CONTAINING_RECORD(IrpEntry, IRP, ThreadListEntry); + IopDeadIrp = CONTAINING_RECORD(IrpEntry, IRP, ThreadListEntry); IOTRACE(IO_IRP_DEBUG, "%s - Deassociating IRP %p for %p\n", __FUNCTION__, - DeadIrp, + IopDeadIrp, IrpThread); /* Don't cancel the IRP if it's already been completed far */ - if (DeadIrp->CurrentLocation == (DeadIrp->StackCount + 2)) + if (IopDeadIrp->CurrentLocation == (IopDeadIrp->StackCount + 2)) { /* Return */ + KeReleaseQueuedSpinLock(LockQueueIoCompletionLock, LockIrql); KeLowerIrql(OldIrql); return; } /* Disown the IRP! */ - DeadIrp->Tail.Overlay.Thread = NULL; + IopDeadIrp->Tail.Overlay.Thread = NULL; RemoveHeadList(&IrpThread->IrpList); - InitializeListHead(&DeadIrp->ThreadListEntry); + InitializeListHead(&IopDeadIrp->ThreadListEntry); /* Get the stack location and check if it's valid */ - IoStackLocation = IoGetCurrentIrpStackLocation(DeadIrp); - if (DeadIrp->CurrentLocation <= DeadIrp->StackCount) + IoStackLocation = IoGetCurrentIrpStackLocation(IopDeadIrp); + if (IopDeadIrp->CurrentLocation <= IopDeadIrp->StackCount) { /* Get the device object */ DeviceObject = IoStackLocation->DeviceObject; } + KeReleaseQueuedSpinLock(LockQueueIoCompletionLock, LockIrql); /* Lower IRQL now, since we have the pointers we need */ KeLowerIrql(OldIrql); @@ -176,7 +182,7 @@ IopRemoveThreadIrp(VOID) if (ErrorLogEntry) { /* Write the entry */ - ErrorLogEntry->ErrorCode = 0xBAADF00D; /* FIXME */ + ErrorLogEntry->ErrorCode = IO_DRIVER_CANCEL_TIMEOUT; IoWriteErrorLogEntry(ErrorLogEntry); } } @@ -982,14 +988,12 @@ NTAPI IoCancelIrp(IN PIRP Irp) { KIRQL OldIrql; - KIRQL IrqlAtEntry; PDRIVER_CANCEL CancelRoutine; IOTRACE(IO_IRP_DEBUG, "%s - Canceling IRP %p\n", __FUNCTION__, Irp); ASSERT(Irp->Type == IO_TYPE_IRP); - IrqlAtEntry = KeGetCurrentIrql(); /* Acquire the cancel lock and cancel the IRP */ IoAcquireCancelSpinLock(&OldIrql); @@ -1005,7 +1009,7 @@ IoCancelIrp(IN PIRP Irp) /* It is, bugcheck */ KeBugCheckEx(CANCEL_STATE_IN_COMPLETED_IRP, (ULONG_PTR)Irp, - 0, + (ULONG_PTR)CancelRoutine, 0, 0); } @@ -1013,7 +1017,6 @@ IoCancelIrp(IN PIRP Irp) /* Set the cancel IRQL And call the routine */ Irp->CancelIrql = OldIrql; CancelRoutine(IoGetCurrentIrpStackLocation(Irp)->DeviceObject, Irp); - ASSERT(IrqlAtEntry == KeGetCurrentIrql()); return TRUE; } @@ -1034,6 +1037,11 @@ IoCancelThreadIo(IN PETHREAD Thread) LARGE_INTEGER Interval; PLIST_ENTRY ListHead, NextEntry; PIRP Irp; + PAGED_CODE(); + + /* Windows isn't using given thread, but using current. */ + Thread = PsGetCurrentThread(); + IOTRACE(IO_IRP_DEBUG, "%s - Canceling IRPs for Thread %p\n", __FUNCTION__, @@ -1077,7 +1085,7 @@ IoCancelThreadIo(IN PETHREAD Thread) { /* Print out a message and remove the IRP */ DPRINT1("Broken driver did not complete!\n"); - IopRemoveThreadIrp(); + IopDisassociateThreadIrp(); } /* Raise the IRQL Again */ From 8f474295b55851af4bf0f5e65b64795ae64beff9 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 19 Aug 2010 02:41:54 +0000 Subject: [PATCH 12/76] [IP] - Fix a major bug in socket closure. Prior to this, a socket with pending IRPs that could not be satisfied when the socket was closed would be destroyed without completing the pending requests. Now, we check all of our IRP queues if we get a SEL_FIN signal and kill all the requests that cannot be satisfied immediately. - Maybe it's just me but Firefox 2 seems much more responsive after this fix (like actually usable!) svn path=/trunk/; revision=48561 --- reactos/lib/drivers/ip/transport/tcp/tcp.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/reactos/lib/drivers/ip/transport/tcp/tcp.c b/reactos/lib/drivers/ip/transport/tcp/tcp.c index e8ea9bb290f..b432ab83f79 100644 --- a/reactos/lib/drivers/ip/transport/tcp/tcp.c +++ b/reactos/lib/drivers/ip/transport/tcp/tcp.c @@ -35,20 +35,20 @@ VOID HandleSignalledConnection(PCONNECTION_ENDPOINT Connection) Connection, Connection->SocketContext)); /* Things that can happen when we try the initial connection */ - if( Connection->SignalState & SEL_CONNECT ) { + if( Connection->SignalState & (SEL_CONNECT | SEL_FIN) ) { while (!IsListEmpty(&Connection->ConnectRequest)) { Entry = RemoveHeadList( &Connection->ConnectRequest ); Bucket = CONTAINING_RECORD( Entry, TDI_BUCKET, Entry ); - Bucket->Status = STATUS_SUCCESS; + Bucket->Status = (Connection->SignalState & SEL_CONNECT) ? STATUS_SUCCESS : STATUS_CANCELLED; Bucket->Information = 0; InsertTailList(&Connection->CompletionQueue, &Bucket->Entry); } } - if( Connection->SignalState & SEL_ACCEPT ) { + if( Connection->SignalState & (SEL_ACCEPT | SEL_FIN) ) { /* Handle readable on a listening socket -- * TODO: Implement filtering */ @@ -90,7 +90,7 @@ VOID HandleSignalledConnection(PCONNECTION_ENDPOINT Connection) } /* Things that happen after we're connected */ - if( Connection->SignalState & SEL_READ ) { + if( Connection->SignalState & (SEL_READ | SEL_FIN) ) { TI_DbgPrint(DEBUG_TCP,("Readable: irp list %s\n", IsListEmpty(&Connection->ReceiveRequest) ? "empty" : "nonempty")); @@ -145,7 +145,7 @@ VOID HandleSignalledConnection(PCONNECTION_ENDPOINT Connection) } } } - if( Connection->SignalState & SEL_WRITE ) { + if( Connection->SignalState & (SEL_WRITE | SEL_FIN) ) { TI_DbgPrint(DEBUG_TCP,("Writeable: irp list %s\n", IsListEmpty(&Connection->SendRequest) ? "empty" : "nonempty")); From 5ae5a357267c2c2b293db571b7c549eb46cd85b2 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Thu, 19 Aug 2010 05:10:16 +0000 Subject: [PATCH 13/76] [NTOSKRNL] - Initialize the Parent member of the new Vad to NULL. This also initializes the Balance to 0 aka RtlBalancedAvlTree Should fix the failed assertion that randomly occurs. svn path=/trunk/; revision=48562 --- reactos/ntoskrnl/mm/ARM3/procsup.c | 1 + 1 file changed, 1 insertion(+) diff --git a/reactos/ntoskrnl/mm/ARM3/procsup.c b/reactos/ntoskrnl/mm/ARM3/procsup.c index 816c7d191ea..25df25937df 100644 --- a/reactos/ntoskrnl/mm/ARM3/procsup.c +++ b/reactos/ntoskrnl/mm/ARM3/procsup.c @@ -121,6 +121,7 @@ AfterFound: Vad->EndingVpn = ((*Base) + Size - 1) >> PAGE_SHIFT; Vad->u3.Secured.StartVpn = *Base; Vad->u3.Secured.EndVpn = (Vad->EndingVpn << PAGE_SHIFT) | (PAGE_SIZE - 1); + Vad->u1.Parent = NULL; /* FIXME: Should setup VAD bitmap */ Status = STATUS_SUCCESS; From f2d4e1a828a93528d5e89da35b6a42fecdf9952a Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 19 Aug 2010 06:05:35 +0000 Subject: [PATCH 14/76] [IPHLPAPI] - Copy our TCP table into the caller's buffer if we actually get one (not yet!) - Return ERROR_NO_DATA if we fail to get anything from TCP/IP - Fixes bug #4185 svn path=/trunk/; revision=48563 --- reactos/dll/win32/iphlpapi/iphlpapi_main.c | 33 +++++++++++++++------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/reactos/dll/win32/iphlpapi/iphlpapi_main.c b/reactos/dll/win32/iphlpapi/iphlpapi_main.c index 717fd2dee67..ebb73ad6017 100644 --- a/reactos/dll/win32/iphlpapi/iphlpapi_main.c +++ b/reactos/dll/win32/iphlpapi/iphlpapi_main.c @@ -1747,7 +1747,7 @@ static int TcpTableSorter(const void *a, const void *b) */ DWORD WINAPI GetTcpTable(PMIB_TCPTABLE pTcpTable, PDWORD pdwSize, BOOL bOrder) { - DWORD ret = NO_ERROR; + DWORD ret = ERROR_NO_DATA; TRACE("pTcpTable %p, pdwSize %p, bOrder %d\n", pTcpTable, pdwSize, (DWORD)bOrder); @@ -1764,18 +1764,31 @@ DWORD WINAPI GetTcpTable(PMIB_TCPTABLE pTcpTable, PDWORD pdwSize, BOOL bOrder) ret = ERROR_INSUFFICIENT_BUFFER; } else { - PMIB_TCPTABLE pTcpTable = getTcpTable(); - if (pTcpTable) + PMIB_TCPTABLE pOurTcpTable = getTcpTable(); + if (pOurTcpTable) { size = sizeof(MIB_TCPTABLE); - if (pTcpTable->dwNumEntries > 1) - size += (pTcpTable->dwNumEntries - 1) * sizeof(MIB_TCPROW); - *pdwSize = size; + if (pOurTcpTable->dwNumEntries > 1) + size += (pOurTcpTable->dwNumEntries - 1) * sizeof(MIB_TCPROW); + + if (*pdwSize < size) + { + *pdwSize = size; - if (bOrder) - qsort(pTcpTable->table, pTcpTable->dwNumEntries, - sizeof(MIB_TCPROW), TcpTableSorter); - ret = NO_ERROR; + ret = ERROR_INSUFFICIENT_BUFFER; + } + else + { + memcpy(pTcpTable, pOurTcpTable, size); + + if (bOrder) + qsort(pTcpTable->table, pTcpTable->dwNumEntries, + sizeof(MIB_TCPROW), TcpTableSorter); + + ret = NO_ERROR; + } + + free(pOurTcpTable); } } } From 44e8a7f7b62bf6995fa000464b9ae6532857af25 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 19 Aug 2010 06:25:20 +0000 Subject: [PATCH 15/76] [NETSTAT] - Allocate memory for the TCP table properly - Only netstat -a should show UDP connections - Patch by Jan Roeloffzen [jroeloffzen at hotmail dot com] svn path=/trunk/; revision=48564 --- .../applications/network/netstat/netstat.c | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/reactos/base/applications/network/netstat/netstat.c b/reactos/base/applications/network/netstat/netstat.c index fbffe08db8e..d491d081813 100644 --- a/reactos/base/applications/network/netstat/netstat.c +++ b/reactos/base/applications/network/netstat/netstat.c @@ -237,12 +237,13 @@ BOOL DisplayOutput() ShowUdpStatistics(); return EXIT_SUCCESS; } - else //if (bDoShowAllCons) + else { _tprintf(_T("\nActive Connections\n")); _tprintf(_T("\n Proto Local Address Foreign Address State\n")); ShowTcpTable(); - ShowUdpTable(); + if (bDoShowAllCons) + ShowUdpTable(); } return EXIT_SUCCESS; } @@ -422,23 +423,24 @@ VOID ShowTcpTable() CHAR Remote[ADDRESSLEN]; /* Get the table of TCP endpoints */ - dwSize = 0; - error = GetTcpTable(NULL, &dwSize, TRUE); - if (error != ERROR_INSUFFICIENT_BUFFER) + dwSize = sizeof (MIB_TCPTABLE); + /* Should also work when we get new connections between 2 GetTcpTable() + * calls: */ + do + { + tcpTable = (PMIB_TCPTABLE) HeapAlloc(GetProcessHeap(), 0, dwSize); + error = GetTcpTable(tcpTable, &dwSize, TRUE); + if ( error != NO_ERROR ) + HeapFree(GetProcessHeap(), 0, tcpTable); + } + while ( error == ERROR_INSUFFICIENT_BUFFER ); + + if (error != NO_ERROR) { printf("Failed to snapshot TCP endpoints.\n"); DoFormatMessage(error); exit(EXIT_FAILURE); } - tcpTable = (PMIB_TCPTABLE) HeapAlloc(GetProcessHeap(), 0, dwSize); - error = GetTcpTable(tcpTable, &dwSize, TRUE ); - if (error) - { - printf("Failed to snapshot TCP endpoints table.\n"); - DoFormatMessage(error); - HeapFree(GetProcessHeap(), 0, tcpTable); - exit(EXIT_FAILURE); - } /* Dump the TCP table */ for (i = 0; i < tcpTable->dwNumEntries; i++) From 6fb40574c2fad0cea01392ff75fbc15f422fffbc Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Thu, 19 Aug 2010 08:50:23 +0000 Subject: [PATCH 16/76] [NTOSKRNL] - Implement support for /BURNMEMORY option. - Don't stop boot on bad memory type Patch by Jay Smith, modified by Aleksey, even more modified by me. See issue #4957 for more details. svn path=/trunk/; revision=48565 --- reactos/ntoskrnl/ex/init.c | 52 +++++++++++++++++++++++++++---- reactos/ntoskrnl/mm/ARM3/mminit.c | 3 +- 2 files changed, 47 insertions(+), 8 deletions(-) diff --git a/reactos/ntoskrnl/ex/init.c b/reactos/ntoskrnl/ex/init.c index b44b58976b2..18dd8aa2b10 100644 --- a/reactos/ntoskrnl/ex/init.c +++ b/reactos/ntoskrnl/ex/init.c @@ -815,6 +815,51 @@ ExpLoadBootSymbols(IN PLOADER_PARAMETER_BLOCK LoaderBlock) } } +VOID +NTAPI +ExBurnMemory(IN PLOADER_PARAMETER_BLOCK LoaderBlock, + IN ULONG PagesToDestroy, + IN TYPE_OF_MEMORY MemoryType) +{ + PLIST_ENTRY ListEntry; + PMEMORY_ALLOCATION_DESCRIPTOR MemDescriptor; + + DPRINT1("Burn RAM amount: %d pages\n", PagesToDestroy); + + /* Loop the memory descriptors, beginning at the end */ + for (ListEntry = LoaderBlock->MemoryDescriptorListHead.Blink; + ListEntry != &LoaderBlock->MemoryDescriptorListHead; + ListEntry = ListEntry->Blink) + { + /* Get the memory descriptor structure */ + MemDescriptor = CONTAINING_RECORD(ListEntry, + MEMORY_ALLOCATION_DESCRIPTOR, + ListEntry); + + /* Is memory free there or is it temporary? */ + if (MemDescriptor->MemoryType == LoaderFree || + MemDescriptor->MemoryType == LoaderFirmwareTemporary) + { + /* Check if the descriptor has more pages than we want */ + if (MemDescriptor->PageCount > PagesToDestroy) + { + /* Change block's page count, ntoskrnl doesn't care much */ + MemDescriptor->PageCount -= PagesToDestroy; + break; + } + else + { + /* Change block type */ + MemDescriptor->MemoryType = MemoryType; + PagesToDestroy -= MemDescriptor->PageCount; + + /* Check if we are done */ + if (PagesToDestroy == 0) break; + } + } + } +} + VOID NTAPI ExpInitializeExecutive(IN ULONG Cpu, @@ -919,12 +964,7 @@ ExpInitializeExecutive(IN ULONG Cpu, { /* Read the number of pages we'll use */ PerfMemUsed = atol(PerfMem + 1) * (1024 * 1024 / PAGE_SIZE); - if (PerfMem) - { - /* FIXME: TODO */ - DPRINT1("Burnable memory support not yet present." - "/BURNMEM option ignored.\n"); - } + if (PerfMemUsed) ExBurnMemory(LoaderBlock, PerfMemUsed, LoaderBad); } } } diff --git a/reactos/ntoskrnl/mm/ARM3/mminit.c b/reactos/ntoskrnl/mm/ARM3/mminit.c index 9f9f1b4c974..e7bb328d784 100644 --- a/reactos/ntoskrnl/mm/ARM3/mminit.c +++ b/reactos/ntoskrnl/mm/ARM3/mminit.c @@ -831,8 +831,7 @@ MiBuildPfnDatabaseFromLoaderBlock(IN PLOADER_PARAMETER_BLOCK LoaderBlock) /* Check for bad RAM */ case LoaderBad: - DPRINT1("You have damaged RAM modules. Stopping boot\n"); - while (TRUE); + DPRINT1("You either have specified /BURNMEMORY or damaged RAM modules.\n"); break; /* Check for free RAM */ From 681307ff21f0b2c81898ba5d1ffd7c9ce94bf1e9 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Thu, 19 Aug 2010 09:03:36 +0000 Subject: [PATCH 17/76] [NTOSKRNL] Fix handling of next instruction in kdbg. Patch by Daniel Zimmermann, modified by Aleksey Bragin See issue #4457 for more details. svn path=/trunk/; revision=48566 --- reactos/ntoskrnl/kdbg/kdb.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/reactos/ntoskrnl/kdbg/kdb.c b/reactos/ntoskrnl/kdbg/kdb.c index 30eb071c2d1..683904433c3 100644 --- a/reactos/ntoskrnl/kdbg/kdb.c +++ b/reactos/ntoskrnl/kdbg/kdb.c @@ -1413,6 +1413,8 @@ KdbEnterDebuggerException( /* Delete the temporary breakpoint which was used to step over or into the instruction. */ KdbpDeleteBreakPoint(-1, BreakPoint); + TrapFrame->Eip--; + if (--KdbNumSingleSteps > 0) { if ((KdbSingleStepOver && !KdbpStepOverInstruction(TrapFrame->Eip)) || @@ -1681,8 +1683,11 @@ continue_execution: /* Clear dr6 status flags. */ TrapFrame->Dr6 &= ~0x0000e00f; - /* Skip the current instruction */ - Context->Eip++; + if (!KdbEnteredOnSingleStep && KdbSingleStepOver) + { + /* Skip the current instruction */ + Context->Eip++; + } } return ContinueType; From f87ad01e1a2db1df3464a56f8cf0fd2159950770 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Thu, 19 Aug 2010 10:03:03 +0000 Subject: [PATCH 18/76] [NTOSKRNL] - Add missing parentheses. Fixes "cont" svn path=/trunk/; revision=48567 --- reactos/ntoskrnl/kdbg/kdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/kdbg/kdb.c b/reactos/ntoskrnl/kdbg/kdb.c index 683904433c3..bc7e01864b0 100644 --- a/reactos/ntoskrnl/kdbg/kdb.c +++ b/reactos/ntoskrnl/kdbg/kdb.c @@ -1683,7 +1683,7 @@ continue_execution: /* Clear dr6 status flags. */ TrapFrame->Dr6 &= ~0x0000e00f; - if (!KdbEnteredOnSingleStep && KdbSingleStepOver) + if (!(KdbEnteredOnSingleStep && KdbSingleStepOver)) { /* Skip the current instruction */ Context->Eip++; From 6a0074f795711327b29b82e153a564a4eba4833f Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Thu, 19 Aug 2010 10:52:36 +0000 Subject: [PATCH 19/76] [Win32k] - For SetTimer nIDEvent can be 0 in which case return 1. Zero still needs to be used for nIDEvent when killing the timer. Fixes bug 5553. - Modify windowless timers to use IDEvent values decrementing from the max number of windowless timers vice incrementing from 1. Done to match windows behavior. svn path=/trunk/; revision=48568 --- .../subsystems/win32/win32k/ntuser/timer.c | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/reactos/subsystems/win32/win32k/ntuser/timer.c b/reactos/subsystems/win32/win32k/ntuser/timer.c index 984b206a6b8..2f4e2189f3f 100644 --- a/reactos/subsystems/win32/win32k/ntuser/timer.c +++ b/reactos/subsystems/win32/win32k/ntuser/timer.c @@ -30,7 +30,7 @@ static LONG TimeLast = 0; static FAST_MUTEX Mutex; static RTL_BITMAP WindowLessTimersBitMap; static PVOID WindowLessTimersBitMapBuffer; -static ULONG HintIndex = 0; +static ULONG HintIndex = 1; ERESOURCE TimerLock; @@ -97,9 +97,11 @@ RemoveTimer(PTIMER pTmr) RemoveEntryList(&pTmr->ptmrList); if ((pTmr->pWnd == NULL) && (!(pTmr->flags & TMRF_SYSTEM))) { - DPRINT("Clearing Bit %d)\n", pTmr->nID); + UINT_PTR IDEvent; + + IDEvent = NUM_WINDOW_LESS_TIMERS - pTmr->nID; IntLockWindowlessTimerBitmap(); - RtlClearBit(&WindowLessTimersBitMap, pTmr->nID); + RtlClearBit(&WindowLessTimersBitMap, IDEvent); IntUnlockWindowlessTimerBitmap(); } UserDereferenceObject(pTmr); @@ -155,7 +157,7 @@ FindSystemTimer(PMSG pMsg) break; pLE = pTmr->ptmrList.Flink; - pTmr = CONTAINING_RECORD(pLE, TIMER, ptmrList); + pTmr = CONTAINING_RECORD(pLE, TIMER, ptmrList); } while (pTmr != FirstpTmr); TimerLeave(); @@ -200,7 +202,7 @@ IntSetTimer( PWINDOW_OBJECT Window, INT Type) { PTIMER pTmr; - UINT Ret= IDEvent; + UINT Ret = IDEvent; LARGE_INTEGER DueTime; DueTime.QuadPart = (LONGLONG)(-5000000); @@ -227,8 +229,10 @@ IntSetTimer( PWINDOW_OBJECT Window, Elapse = 10; } + /* Passing an IDEvent of 0 and the SetTimer returns 1. + It will create the timer with an ID of 0 */ if ((Window) && (IDEvent == 0)) - IDEvent = 1; + Ret = 1; pTmr = FindTimer(Window, IDEvent, Type); @@ -243,11 +247,13 @@ IntSetTimer( PWINDOW_OBJECT Window, IntUnlockWindowlessTimerBitmap(); DPRINT1("Unable to find a free window-less timer id\n"); SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES); + ASSERT(FALSE); return 0; } + IDEvent = NUM_WINDOW_LESS_TIMERS - IDEvent; Ret = IDEvent; - //HintIndex = IDEvent + 1; + IntUnlockWindowlessTimerBitmap(); } @@ -271,7 +277,7 @@ IntSetTimer( PWINDOW_OBJECT Window, pTmr->cmsRate = Elapse; pTmr->pfn = TimerFunc; pTmr->nID = IDEvent; - pTmr->flags = Type|TMRF_INIT; // Set timer to Init mode. + pTmr->flags = Type|TMRF_INIT; } else { @@ -319,6 +325,7 @@ SystemTimerSet( PWINDOW_OBJECT Window, if (Window && Window->pti->pEThread->ThreadsProcess != PsGetCurrentProcess()) { SetLastWin32Error(ERROR_ACCESS_DENIED); + DPRINT("SysemTimerSet: Access Denied!\n"); return 0; } return IntSetTimer( Window, nIDEvent, uElapse, lpTimerFunc, TMRF_SYSTEM); @@ -509,9 +516,6 @@ IntKillTimer(PWINDOW_OBJECT Window, UINT_PTR IDEvent, BOOL SystemTimer) DPRINT("IntKillTimer Window %x id %p systemtimer %s\n", Window, IDEvent, SystemTimer ? "TRUE" : "FALSE"); - if ((Window) && (IDEvent == 0)) - IDEvent = 1; - pTmr = FindTimer(Window, IDEvent, SystemTimer ? TMRF_SYSTEM : 0); if (pTmr) @@ -532,7 +536,7 @@ InitTimerImpl(VOID) ExInitializeFastMutex(&Mutex); BitmapBytes = ROUND_UP(NUM_WINDOW_LESS_TIMERS, sizeof(ULONG) * 8) / 8; - WindowLessTimersBitMapBuffer = ExAllocatePoolWithTag(PagedPool, BitmapBytes, TAG_TIMERBMP); + WindowLessTimersBitMapBuffer = ExAllocatePoolWithTag(NonPagedPool, BitmapBytes, TAG_TIMERBMP); if (WindowLessTimersBitMapBuffer == NULL) { return STATUS_UNSUCCESSFUL; From 8d8399c2e52d80faf7bbe9b8e29568abafe1201a Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 19 Aug 2010 22:15:58 +0000 Subject: [PATCH 20/76] [OSKITTCP] - Disable routing because oskit needs to let our code do that - Comment out the ACK hack and restore the default BSD behavior svn path=/trunk/; revision=48569 --- .../lib/drivers/oskittcp/oskittcp/interface.c | 1 + .../lib/drivers/oskittcp/oskittcp/tcp_input.c | 23 +++++++++++++++++++ .../lib/drivers/oskittcp/oskittcp/tcp_subr.c | 6 ++++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/reactos/lib/drivers/oskittcp/oskittcp/interface.c b/reactos/lib/drivers/oskittcp/oskittcp/interface.c index 3c589e7b255..db0b3a87185 100644 --- a/reactos/lib/drivers/oskittcp/oskittcp/interface.c +++ b/reactos/lib/drivers/oskittcp/oskittcp/interface.c @@ -129,6 +129,7 @@ int OskitTCPSocket( void *context, if( !error ) { so->so_connection = context; so->so_state |= SS_NBIO; + so->so_options |= SO_DONTROUTE; *aso = so; } OSKUnlock(); diff --git a/reactos/lib/drivers/oskittcp/oskittcp/tcp_input.c b/reactos/lib/drivers/oskittcp/oskittcp/tcp_input.c index 1811476e9cf..ed2759a0c39 100644 --- a/reactos/lib/drivers/oskittcp/oskittcp/tcp_input.c +++ b/reactos/lib/drivers/oskittcp/oskittcp/tcp_input.c @@ -84,6 +84,7 @@ struct inpcbinfo tcbinfo; * Set DELACK for segments received in order, but ack immediately * when segments are out of order (so fast retransmit can work). */ +#ifdef TCP_ACK_HACK #define TCP_REASS(tp, ti, m, so, flags) { \ if ((ti)->ti_seq == (tp)->rcv_nxt && \ (tp)->seg_next == (struct tcpiphdr *)(tp) && \ @@ -103,6 +104,24 @@ struct inpcbinfo tcbinfo; tp->t_flags |= TF_ACKNOW; \ } \ } +#else +#define TCP_REASS(tp, ti, m, so, flags) { \ + if ((ti)->ti_seq == (tp)->rcv_nxt && \ + (tp)->seg_next == (struct tcpiphdr *)(tp) && \ + (tp)->t_state == TCPS_ESTABLISHED) { \ + tp->t_flags |= TF_DELACK; \ + (tp)->rcv_nxt += (ti)->ti_len; \ + flags = (ti)->ti_flags & TH_FIN; \ + tcpstat.tcps_rcvpack++;\ + tcpstat.tcps_rcvbyte += (ti)->ti_len;\ + sbappend(&(so)->so_rcv, (m)); \ + sorwakeup(so); \ + } else { \ + (flags) = tcp_reass((tp), (ti), (m)); \ + tp->t_flags |= TF_ACKNOW; \ + } \ +} +#endif #ifndef TUBA_INCLUDE int @@ -573,6 +592,7 @@ findpcb: */ sbappend(&so->so_rcv, m); sorwakeup(so); +#ifdef TCP_ACK_HACK /* * If this is a short packet, then ACK now - with Nagel * congestion avoidance sender won't send more until @@ -584,6 +604,9 @@ findpcb: } else { tp->t_flags |= TF_DELACK; } +#else + tp->t_flags |= TF_DELACK; +#endif return; } } diff --git a/reactos/lib/drivers/oskittcp/oskittcp/tcp_subr.c b/reactos/lib/drivers/oskittcp/oskittcp/tcp_subr.c index 4632b688ef1..b9c215140e2 100644 --- a/reactos/lib/drivers/oskittcp/oskittcp/tcp_subr.c +++ b/reactos/lib/drivers/oskittcp/oskittcp/tcp_subr.c @@ -560,6 +560,7 @@ struct rtentry * tcp_rtlookup(inp) struct inpcb *inp; { +#ifndef __REACTOS__ struct route *ro; struct rtentry *rt; @@ -576,7 +577,10 @@ tcp_rtlookup(inp) rt = ro->ro_rt; } } - return rt; + return rt; +#else + return NULL; +#endif } /* From ab9dae987d87f2598db44a0265767a3809de4e7e Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 19 Aug 2010 23:26:44 +0000 Subject: [PATCH 21/76] [NTOSKRNL] - Add a special case to IopInitializeDevice for raw devices - Call IopInitializeDevice to set up our device node and ready it to start - Fixes assertions hit by ACPI and PCIX svn path=/trunk/; revision=48570 --- reactos/ntoskrnl/io/pnpmgr/pnpmgr.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c index e0ad64b7c72..57215910c0e 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c @@ -64,6 +64,13 @@ IopInitializeDevice(PDEVICE_NODE DeviceNode, { PDEVICE_OBJECT Fdo; NTSTATUS Status; + + if (!DriverObject) + { + /* Special case for bus driven devices */ + DeviceNode->Flags |= DNF_ADDED; + return STATUS_SUCCESS; + } if (!DriverObject->DriverExtension->AddDevice) { @@ -1897,11 +1904,15 @@ IopActionInitChildServices(PDEVICE_NODE DeviceNode, { /* We don't need to worry about loading the driver because we're * being driven in raw mode so our parent must be loaded to get here */ - Status = IopStartDevice(DeviceNode); - if (!NT_SUCCESS(Status)) + Status = IopInitializeDevice(DeviceNode, NULL); + if (NT_SUCCESS(Status)) { - DPRINT1("IopStartDevice(%wZ) failed with status 0x%08x\n", - &DeviceNode->InstancePath, Status); + Status = IopStartDevice(DeviceNode); + if (!NT_SUCCESS(Status)) + { + DPRINT1("IopStartDevice(%wZ) failed with status 0x%08x\n", + &DeviceNode->InstancePath, Status); + } } } else From 62f520433c7d72854ff10255b7af41af8b3cf06e Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 20 Aug 2010 02:27:05 +0000 Subject: [PATCH 22/76] [NTOSKRNL] - Shutdown the system if we receive a SYS_BUTTON_POWER event - Register for GUID_DEVICE_LID arrival events so we can receive lid events svn path=/trunk/; revision=48572 --- reactos/ntoskrnl/include/internal/po.h | 1 + reactos/ntoskrnl/po/events.c | 9 +++++++++ reactos/ntoskrnl/po/power.c | 12 +++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/include/internal/po.h b/reactos/ntoskrnl/include/internal/po.h index 01ddf3b5c37..ef4ee1a5ff1 100644 --- a/reactos/ntoskrnl/include/internal/po.h +++ b/reactos/ntoskrnl/include/internal/po.h @@ -6,6 +6,7 @@ * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org) */ +#include "initguid.h" #include // diff --git a/reactos/ntoskrnl/po/events.c b/reactos/ntoskrnl/po/events.c index 8417f2760cc..efbcc104d61 100644 --- a/reactos/ntoskrnl/po/events.c +++ b/reactos/ntoskrnl/po/events.c @@ -79,6 +79,15 @@ PopGetSysButtonCompletion( if (SysButton & SYS_BUTTON_LID) DbgPrint(" LID"); if (SysButton == 0) DbgPrint(" WAKE"); DbgPrint(" )\n"); + + if (SysButton & SYS_BUTTON_POWER) + { + /* FIXME: Read registry for the action we should perform here */ + DPRINT1("Initiating shutdown after power button event\n"); + + ZwShutdownSystem(ShutdownNoReboot); + } + } /* Allocate a new workitem to send the next IOCTL_GET_SYS_BUTTON_EVENT */ diff --git a/reactos/ntoskrnl/po/power.c b/reactos/ntoskrnl/po/power.c index e8d37b855fd..d745d76e777 100644 --- a/reactos/ntoskrnl/po/power.c +++ b/reactos/ntoskrnl/po/power.c @@ -136,7 +136,7 @@ PoInitSystem(IN ULONG BootPhase) /* Check if this is phase 1 init */ if (BootPhase == 1) { - /* Registry power button notification */ + /* Register power button notification */ IoRegisterPlugPlayNotification(EventCategoryDeviceInterfaceChange, PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES, (PVOID)&GUID_DEVICE_SYS_BUTTON, @@ -145,6 +145,16 @@ PoInitSystem(IN ULONG BootPhase) PopAddRemoveSysCapsCallback, NULL, &NotificationEntry); + + /* Register lid notification */ + IoRegisterPlugPlayNotification(EventCategoryDeviceInterfaceChange, + PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES, + (PVOID)&GUID_DEVICE_LID, + IopRootDeviceNode-> + PhysicalDeviceObject->DriverObject, + PopAddRemoveSysCapsCallback, + NULL, + &NotificationEntry); return TRUE; } From 1883a6f208f6cbe16188e92e54b8dd23a10fd71f Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 20 Aug 2010 03:08:50 +0000 Subject: [PATCH 23/76] [ACPI] - Do all of the work inside the DPC so we don't have IRQL issues when entering the memory manager - This is a slight hack but we can be assured that data won't be over 24 bits unless somebody wants to push the power/sleep button over 16 million times svn path=/trunk/; revision=48573 --- reactos/drivers/bus/acpi/busmgr/bus.c | 33 ++++++++++++++++----------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/reactos/drivers/bus/acpi/busmgr/bus.c b/reactos/drivers/bus/acpi/busmgr/bus.c index 9860055873a..0c46bb8a339 100644 --- a/reactos/drivers/bus/acpi/busmgr/bus.c +++ b/reactos/drivers/bus/acpi/busmgr/bus.c @@ -463,8 +463,19 @@ acpi_bus_generate_event_dpc(PKDPC Dpc, PVOID SystemArgument1, PVOID SystemArgument2) { - struct acpi_bus_event *event = SystemArgument1; + struct acpi_bus_event *event; + struct acpi_device *device = SystemArgument1; + ULONG_PTR TypeData = (ULONG_PTR)SystemArgument2; KIRQL OldIrql; + + event = ExAllocatePool(NonPagedPool,sizeof(struct acpi_bus_event)); + if (!event) + return; + + sprintf(event->device_class, "%s", device->pnp.device_class); + sprintf(event->bus_id, "%s", device->pnp.bus_id); + event->type = (TypeData & 0xFF000000) >> 24; + event->data = (TypeData & 0x00FFFFFF); KeAcquireSpinLock(&acpi_bus_event_lock, &OldIrql); list_add_tail(&event->node, &acpi_bus_event_list); @@ -479,7 +490,7 @@ acpi_bus_generate_event ( UINT8 type, int data) { - struct acpi_bus_event *event = NULL; + ULONG_PTR TypeData = 0; DPRINT("acpi_bus_generate_event"); @@ -489,18 +500,14 @@ acpi_bus_generate_event ( /* drop event on the floor if no one's listening */ if (!event_is_open) return_VALUE(0); + + /* Data shouldn't even get near 24 bits */ + ASSERT(!(data & 0xFF000000)); + + TypeData = data; + TypeData |= type << 24; - event = ExAllocatePool(NonPagedPool,sizeof(struct acpi_bus_event)); - if (!event) - return_VALUE(-4); - - sprintf(event->device_class, "%s", device->pnp.device_class); - sprintf(event->bus_id, "%s", device->pnp.bus_id); - event->type = type; - event->data = data; - - if (!KeInsertQueueDpc(&event_dpc, event, NULL)) - ExFreePool(event); + KeInsertQueueDpc(&event_dpc, device, (PVOID)TypeData); return_VALUE(0); } From 5122323eb8cb4824b3396ecdfbc0ff75fe234bcd Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 20 Aug 2010 04:45:25 +0000 Subject: [PATCH 24/76] [NTOSKRNL] - The trailing NULL is NOT included in the string length - IopNotifyPlugPlayNotification needs a pointer to an actual GUID not a UNICODE_STRING - The Power Manager can now see ACPI power devices again - ROS will now do a graceful shutdown and power off if the power button is pressed and ACPI is enabled svn path=/trunk/; revision=48574 --- reactos/ntoskrnl/io/iomgr/deviface.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/reactos/ntoskrnl/io/iomgr/deviface.c b/reactos/ntoskrnl/io/iomgr/deviface.c index dcc086eb659..0a52f2aaf8d 100644 --- a/reactos/ntoskrnl/io/iomgr/deviface.c +++ b/reactos/ntoskrnl/io/iomgr/deviface.c @@ -731,11 +731,6 @@ IoGetDeviceInterfaces(IN CONST GUID *InterfaceClassGuid, } KeyName.Length = KeyName.MaximumLength = (USHORT)bip->DataLength - 4 * sizeof(WCHAR); KeyName.Buffer = &((PWSTR)bip->Data)[4]; - if (KeyName.Length && KeyName.Buffer[KeyName.Length / sizeof(WCHAR)] == UNICODE_NULL) - { - /* Remove trailing NULL */ - KeyName.Length -= sizeof(WCHAR); - } /* Add new symbolic link to symbolic link list */ if (ReturnBuffer.Length + KeyName.Length + sizeof(WCHAR) > ReturnBuffer.MaximumLength) @@ -1232,6 +1227,7 @@ IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, UNICODE_STRING KeyName; OBJECT_ATTRIBUTES ObjectAttributes; ULONG LinkedValue; + GUID DeviceGuid; if (SymbolicLinkName == NULL) return STATUS_INVALID_PARAMETER_1; @@ -1309,13 +1305,20 @@ IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, DPRINT1("IoGetDeviceObjectPointer() failed with status 0x%08lx\n", Status); return Status; } + + Status = RtlGUIDFromString(&GuidString, &DeviceGuid); + if (!NT_SUCCESS(Status)) + { + DPRINT1("RtlGUIDFromString() failed with status 0x%08lx\n", Status); + return Status; + } EventGuid = Enable ? &GUID_DEVICE_INTERFACE_ARRIVAL : &GUID_DEVICE_INTERFACE_REMOVAL; IopNotifyPlugPlayNotification( PhysicalDeviceObject, EventCategoryDeviceInterfaceChange, EventGuid, - &GuidString, + &DeviceGuid, (PVOID)SymbolicLinkName); ObDereferenceObject(FileObject); From ca4003c9f8cb4c57917a5f8e6771a1f9a4179565 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Fri, 20 Aug 2010 16:55:33 +0000 Subject: [PATCH 25/76] [PSDK] - Add missing DISPLAY_BRIGHTNESS and some related definitions. svn path=/trunk/; revision=48575 --- reactos/include/psdk/ntddvdeo.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/reactos/include/psdk/ntddvdeo.h b/reactos/include/psdk/ntddvdeo.h index 2aa4774382e..6bf65a42a17 100644 --- a/reactos/include/psdk/ntddvdeo.h +++ b/reactos/include/psdk/ntddvdeo.h @@ -468,6 +468,15 @@ typedef struct _ENG_EVENT ULONG fFlags; } ENG_EVENT, *PENG_EVENT; +typedef struct _DISPLAY_BRIGHTNESS { + UCHAR ucDisplayPolicy; + UCHAR ucACBrightness; + UCHAR ucDCBrightness; +} DISPLAY_BRIGHTNESS, *PDISPLAY_BRIGHTNESS; + +#define DISPLAYPOLICY_AC 0x00000001 +#define DISPLAYPOLICY_DC 0x00000002 +#define DISPLAYPOLICY_BOTH 0x00000003 #ifdef __cplusplus } From 02cb45ab9c7aaf4feece55190430b9c9d6a6aed0 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Fri, 20 Aug 2010 19:24:48 +0000 Subject: [PATCH 26/76] [WIN32K] - co_IntTranslateMouseMessage: properly initialize *HitTest and only send WM_NCHITTEST when the message is going to be removed - co_IntPeekMessage: Prevent possible use of uninitialized HitTest by ProcessMouseMessage() - Patch by Jan Roeloffzen [jroeloffzen at hotmail dot com] - Fixes bug 2139 svn path=/trunk/; revision=48576 --- reactos/subsystems/win32/win32k/ntuser/message.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/reactos/subsystems/win32/win32k/ntuser/message.c b/reactos/subsystems/win32/win32k/ntuser/message.c index 5d1cf8ef9d2..b6ed7e5d1aa 100644 --- a/reactos/subsystems/win32/win32k/ntuser/message.c +++ b/reactos/subsystems/win32/win32k/ntuser/message.c @@ -579,14 +579,20 @@ co_IntTranslateMouseMessage( return TRUE; } + *HitTest = HTCLIENT; + UserRefObjectCo(Window, &Ref); if ( ThreadQueue == Window->pti->MessageQueue && ThreadQueue->CaptureWindow != Window->hSelf) { /* only send WM_NCHITTEST messages if we're not capturing the window! */ - *HitTest = co_IntSendMessage(Window->hSelf, WM_NCHITTEST, 0, - MAKELONG(Msg->pt.x, Msg->pt.y)); + if (Remove ) + { + *HitTest = co_IntSendMessage(Window->hSelf, WM_NCHITTEST, 0, + MAKELONG(Msg->pt.x, Msg->pt.y)); + } + /* else we are going to see this message again, but then with Remove == TRUE */ if (*HitTest == (USHORT)HTTRANSPARENT) { @@ -626,10 +632,6 @@ co_IntTranslateMouseMessage( } } } - else - { - *HitTest = HTCLIENT; - } if ( gspv.bMouseClickLock && ( (Msg->message == WM_LBUTTONUP) || @@ -801,6 +803,8 @@ co_IntPeekMessage( PUSER_MESSAGE Msg, */ CheckMessages: + HitTest = HTNOWHERE; + Present = FALSE; KeQueryTickCount(&LargeTickCount); From 80cc3a0e8883180b83507250425b8b3896500710 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sat, 21 Aug 2010 19:55:09 +0000 Subject: [PATCH 27/76] [WIN32K] - Allocate the DCs prgnVis in DC_AllocDC, instead of "on demand" in GdiSelectVisRgn and properly handle failure case. This fixes a possible crash, when running out of gdi handles. svn path=/trunk/; revision=48579 --- .../subsystems/win32/win32k/objects/cliprgn.c | 6 +----- .../subsystems/win32/win32k/objects/dclife.c | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/reactos/subsystems/win32/win32k/objects/cliprgn.c b/reactos/subsystems/win32/win32k/objects/cliprgn.c index 7bfcf807fbe..4156ba79d39 100644 --- a/reactos/subsystems/win32/win32k/objects/cliprgn.c +++ b/reactos/subsystems/win32/win32k/objects/cliprgn.c @@ -107,11 +107,7 @@ GdiSelectVisRgn(HDC hdc, HRGN hrgn) dc->fs &= ~DC_FLAG_DIRTY_RAO; - if (dc->prgnVis == NULL) - { - dc->prgnVis = IntSysCreateRectpRgn(0, 0, 0, 0); - GDIOBJ_CopyOwnership(hdc, ((PROSRGNDATA)dc->prgnVis)->BaseObject.hHmgr); - } + ASSERT (dc->prgnVis != NULL); retval = NtGdiCombineRgn(((PROSRGNDATA)dc->prgnVis)->BaseObject.hHmgr, hrgn, 0, RGN_COPY); if ( retval != ERROR ) diff --git a/reactos/subsystems/win32/win32k/objects/dclife.c b/reactos/subsystems/win32/win32k/objects/dclife.c index 1710dba108d..af048cd87c2 100644 --- a/reactos/subsystems/win32/win32k/objects/dclife.c +++ b/reactos/subsystems/win32/win32k/objects/dclife.c @@ -49,6 +49,18 @@ DC_AllocDC(PUNICODE_STRING Driver) hDC = NewDC->BaseObject.hHmgr; + /* Allocate a Vis region */ + NewDC->prgnVis = IntSysCreateRectpRgn(0, 0, 1, 1); + if (!NewDC->prgnVis) + { + DPRINT1("IntSysCreateRectpRgn failed\n"); + if (!GDIOBJ_FreeObjByHandle(hDC, GDI_OBJECT_TYPE_DC)) + { + ASSERT(FALSE); + } + return NULL; + } + NewDC->pdcattr = &NewDC->dcattr; DC_AllocateDcAttr(hDC); @@ -661,7 +673,6 @@ NtGdiCreateCompatibleDC(HDC hDC) PDC pdcNew, pdcOld; PDC_ATTR pdcattrNew, pdcattrOld; HDC hdcNew, DisplayDC = NULL; - HRGN hVisRgn; UNICODE_STRING DriverName; DWORD Layout = 0; HSURF hsurf; @@ -742,12 +753,6 @@ NtGdiCreateCompatibleDC(HDC hDC) NtGdiDeleteObjectApp(DisplayDC); } - hVisRgn = IntSysCreateRectRgn(0, 0, 1, 1); - if (hVisRgn) - { - GdiSelectVisRgn(hdcNew, hVisRgn); - REGION_FreeRgnByHandle(hVisRgn); - } if (Layout) NtGdiSetLayout(hdcNew, -1, Layout); DC_InitDC(hdcNew); From 68eef5481fa9a21ac6d0b4c4840ac7e3d2203467 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 21 Aug 2010 21:25:07 +0000 Subject: [PATCH 28/76] [NTOSKRNL] - Append the DLL name and NULL terminate the string more nicely svn path=/trunk/; revision=48580 --- reactos/ntoskrnl/mm/ARM3/sysldr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/reactos/ntoskrnl/mm/ARM3/sysldr.c b/reactos/ntoskrnl/mm/ARM3/sysldr.c index b9fce2d56e9..8a86c91ed22 100644 --- a/reactos/ntoskrnl/mm/ARM3/sysldr.c +++ b/reactos/ntoskrnl/mm/ARM3/sysldr.c @@ -1135,9 +1135,9 @@ CheckDllState: ImageFileDirectory->Length); /* Now add the import name and null-terminate it */ - RtlAppendStringToString((PSTRING)&DllName, - (PSTRING)&NameString); - DllName.Buffer[(DllName.MaximumLength - 1) / sizeof(WCHAR)] = UNICODE_NULL; + RtlAppendUnicodeStringToString(&DllName, + &NameString); + DllName.Buffer[DllName.Length / sizeof(WCHAR)] = UNICODE_NULL; /* Load the image */ Status = MmLoadSystemImage(&DllName, From 0d3516871bf2bbc7483e3da0e20599994051821c Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 21 Aug 2010 21:39:53 +0000 Subject: [PATCH 29/76] [NTOSKRNL] - Don't overwrite the ACPI hardware key on every boot svn path=/trunk/; revision=48581 --- reactos/ntoskrnl/io/pnpmgr/pnpmgr.c | 36 +++++++++++++++++------------ 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c index 57215910c0e..2fb93e2209f 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c @@ -2621,6 +2621,7 @@ IopUpdateRootKey(VOID) OBJECT_ATTRIBUTES ObjectAttributes; HANDLE hEnum, hRoot, hHalAcpiDevice, hHalAcpiId, hLogConf; NTSTATUS Status; + ULONG Disposition; InitializeObjectAttributes(&ObjectAttributes, &EnumU, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, NULL, NULL); Status = ZwCreateKey(&hEnum, KEY_CREATE_SUB_KEY, &ObjectAttributes, 0, NULL, 0, NULL); @@ -2642,27 +2643,32 @@ IopUpdateRootKey(VOID) if (IopIsAcpiComputer()) { InitializeObjectAttributes(&ObjectAttributes, &HalAcpiDevice, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, hRoot, NULL); - Status = ZwCreateKey(&hHalAcpiDevice, KEY_CREATE_SUB_KEY, &ObjectAttributes, 0, NULL, 0, NULL); + Status = ZwCreateKey(&hHalAcpiDevice, KEY_CREATE_SUB_KEY, &ObjectAttributes, 0, NULL, 0, &Disposition); ZwClose(hRoot); if (!NT_SUCCESS(Status)) return Status; - InitializeObjectAttributes(&ObjectAttributes, &HalAcpiId, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, hHalAcpiDevice, NULL); - Status = ZwCreateKey(&hHalAcpiId, KEY_CREATE_SUB_KEY, &ObjectAttributes, 0, NULL, 0, NULL); - ZwClose(hHalAcpiDevice); - if (!NT_SUCCESS(Status)) - return Status; - Status = ZwSetValueKey(hHalAcpiId, &DeviceDescU, 0, REG_SZ, HalAcpiDeviceDesc.Buffer, HalAcpiDeviceDesc.MaximumLength); - if (NT_SUCCESS(Status)) - Status = ZwSetValueKey(hHalAcpiId, &HardwareIDU, 0, REG_MULTI_SZ, HalAcpiHardwareID.Buffer, HalAcpiHardwareID.MaximumLength); - if (NT_SUCCESS(Status)) + if (Disposition == REG_CREATED_NEW_KEY) { - InitializeObjectAttributes(&ObjectAttributes, &LogConfU, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, hHalAcpiId, NULL); - Status = ZwCreateKey(&hLogConf, 0, &ObjectAttributes, 0, NULL, REG_OPTION_VOLATILE, NULL); + InitializeObjectAttributes(&ObjectAttributes, &HalAcpiId, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, hHalAcpiDevice, NULL); + Status = ZwCreateKey(&hHalAcpiId, KEY_CREATE_SUB_KEY, &ObjectAttributes, 0, NULL, 0, NULL); + ZwClose(hHalAcpiDevice); + if (!NT_SUCCESS(Status)) + return Status; + Status = ZwSetValueKey(hHalAcpiId, &DeviceDescU, 0, REG_SZ, HalAcpiDeviceDesc.Buffer, HalAcpiDeviceDesc.MaximumLength); if (NT_SUCCESS(Status)) - ZwClose(hLogConf); + Status = ZwSetValueKey(hHalAcpiId, &HardwareIDU, 0, REG_MULTI_SZ, HalAcpiHardwareID.Buffer, HalAcpiHardwareID.MaximumLength); + if (NT_SUCCESS(Status)) + { + InitializeObjectAttributes(&ObjectAttributes, &LogConfU, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, hHalAcpiId, NULL); + Status = ZwCreateKey(&hLogConf, 0, &ObjectAttributes, 0, NULL, REG_OPTION_VOLATILE, NULL); + if (NT_SUCCESS(Status)) + ZwClose(hLogConf); + } + ZwClose(hHalAcpiId); + return Status; } - ZwClose(hHalAcpiId); - return Status; + ZwClose(hHalAcpiDevice); + return STATUS_SUCCESS; } else { From 9280f1e1c355ff54eabe94481341a229e7a03c31 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sat, 21 Aug 2010 22:00:50 +0000 Subject: [PATCH 30/76] [WIN32K] Use the object type index, not the shifted full object type to decide what to do with an object in NtGdiDeleteObjectApp. Fixes leaking derived types such as pens. svn path=/trunk/; revision=48582 --- reactos/subsystems/win32/win32k/objects/dclife.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/subsystems/win32/win32k/objects/dclife.c b/reactos/subsystems/win32/win32k/objects/dclife.c index af048cd87c2..a766d7d9706 100644 --- a/reactos/subsystems/win32/win32k/objects/dclife.c +++ b/reactos/subsystems/win32/win32k/objects/dclife.c @@ -773,7 +773,7 @@ NtGdiDeleteObjectApp(HANDLE DCHandle) if (IsObjectDead((HGDIOBJ)DCHandle)) return TRUE; - ObjType = GDI_HANDLE_GET_TYPE(DCHandle) >> GDI_ENTRY_UPPER_SHIFT; + ObjType = GDI_OBJECT_GET_TYPE_INDEX((ULONG_PTR)DCHandle); if (GreGetObjectOwner( DCHandle, ObjType)) { From 7f865763fa4894d3313729d7bee1a8df21adc58a Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 21 Aug 2010 22:08:00 +0000 Subject: [PATCH 31/76] [NTOSKRNL] - Fix a typo that broke handling of DevicePropertyEnumeratorName inside IoGetDeviceProperty svn path=/trunk/; revision=48583 --- reactos/ntoskrnl/io/pnpmgr/pnpmgr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c index 2fb93e2209f..e8fb4cf5026 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c @@ -3327,8 +3327,8 @@ IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, ASSERT(EnumeratorNameEnd); /* This is the format of the returned data */ - PIP_RETURN_DATA((EnumeratorNameEnd - DeviceInstanceName) * 2, - &DeviceNode->ChildBusNumber); + PIP_RETURN_DATA((EnumeratorNameEnd - DeviceInstanceName) * sizeof(WCHAR), + DeviceInstanceName); case DevicePropertyAddress: From f8199cb9e028ef25392b7e66f8b2e97f4252ea4e Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Sun, 22 Aug 2010 13:25:10 +0000 Subject: [PATCH 32/76] [PSDK] - Improve _MSC_VER related conditions. - Comment on #endif (for readability). - DECLSPEC_ALIGN : moar underscores ! - Apply a consistent formatting. svn path=/trunk/; revision=48590 --- reactos/include/psdk/ntdef.h | 353 +++++++++++++++++------------------ 1 file changed, 175 insertions(+), 178 deletions(-) diff --git a/reactos/include/psdk/ntdef.h b/reactos/include/psdk/ntdef.h index aaf5182d9d3..be71648f18b 100644 --- a/reactos/include/psdk/ntdef.h +++ b/reactos/include/psdk/ntdef.h @@ -194,7 +194,7 @@ #if defined(_MSC_VER) && (_MSC_VER >= 1300) #define TYPE_ALIGNMENT(t) __alignof(t) #else -#define TYPE_ALIGNMENT(t) FIELD_OFFSET( struct { char x; t test; }, test ) +#define TYPE_ALIGNMENT(t) FIELD_OFFSET(struct { char x; t test; }, test) #endif /* Calling Conventions */ @@ -219,7 +219,7 @@ #else #define DECLSPEC_ADDRSAFE #endif -#endif +#endif /* DECLSPEC_ADDRSAFE */ #if !defined(_NTSYSTEM_) #define NTSYSAPI DECLSPEC_IMPORT @@ -235,14 +235,14 @@ /* Inlines */ #ifndef FORCEINLINE -#if (_MSC_VER >= 1200) +#if defined(_MSC_VER) && (_MSC_VER >= 1200) #define FORCEINLINE __forceinline -#elif (_MSC_VER) +#elif defined(_MSC_VER) #define FORCEINLINE __inline -#else +#else /* __GNUC__ */ #define FORCEINLINE extern __inline__ __attribute__((always_inline)) #endif -#endif +#endif /* FORCEINLINE */ #ifndef DECLSPEC_NOINLINE #if (_MSC_VER >= 1300) @@ -252,7 +252,7 @@ #else #define DECLSPEC_NOINLINE #endif -#endif +#endif /* DECLSPEC_NOINLINE */ #if !defined(_M_CEE_PURE) #define NTAPI_INLINE NTAPI @@ -265,11 +265,11 @@ #if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS) #define DECLSPEC_ALIGN(x) __declspec(align(x)) #elif defined(__GNUC__) -#define DECLSPEC_ALIGN(x) __attribute__((aligned(x))) +#define DECLSPEC_ALIGN(x) __attribute__ ((__aligned__ (x))) #else #define DECLSPEC_ALIGN(x) #endif -#endif +#endif /* DECLSPEC_ALIGN */ /* Use to silence unused variable warnings when it is intentional */ #define UNREFERENCED_PARAMETER(P) {(P)=(P);} @@ -507,7 +507,7 @@ typedef struct _STRING64 { #define MAKELCID(lgid, srtid) ((ULONG)((((ULONG)((USHORT)(srtid))) << 16) | \ ((ULONG)((USHORT)(lgid))))) -#define MAKESORTLCID(lgid, srtid, ver) \ +#define MAKESORTLCID(lgid, srtid, ver) \ ((ULONG)((MAKELCID(lgid, srtid)) | \ (((ULONG)((USHORT)(ver))) << 20))) #define LANGIDFROMLCID(lcid) ((USHORT)(lcid)) @@ -549,9 +549,9 @@ typedef CONST OBJECT_ATTRIBUTES *PCOBJECT_ATTRIBUTES; /* Product Types */ typedef enum _NT_PRODUCT_TYPE { - NtProductWinNt = 1, - NtProductLanManNt, - NtProductServer + NtProductWinNt = 1, + NtProductLanManNt, + NtProductServer } NT_PRODUCT_TYPE, *PNT_PRODUCT_TYPE; typedef enum _EVENT_TYPE { @@ -560,8 +560,8 @@ typedef enum _EVENT_TYPE { } EVENT_TYPE; typedef enum _TIMER_TYPE { - NotificationTimer, - SynchronizationTimer + NotificationTimer, + SynchronizationTimer } TIMER_TYPE; typedef enum _WAIT_TYPE { @@ -571,25 +571,23 @@ typedef enum _WAIT_TYPE { /* Doubly Linked Lists */ typedef struct _LIST_ENTRY { - struct _LIST_ENTRY *Flink; - struct _LIST_ENTRY *Blink; + struct _LIST_ENTRY *Flink; + struct _LIST_ENTRY *Blink; } LIST_ENTRY, *PLIST_ENTRY, *RESTRICTED_POINTER PRLIST_ENTRY; -typedef struct LIST_ENTRY32 -{ - ULONG Flink; - ULONG Blink; +typedef struct LIST_ENTRY32 { + ULONG Flink; + ULONG Blink; } LIST_ENTRY32, *PLIST_ENTRY32; -typedef struct LIST_ENTRY64 -{ - ULONGLONG Flink; - ULONGLONG Blink; +typedef struct LIST_ENTRY64 { + ULONGLONG Flink; + ULONGLONG Blink; } LIST_ENTRY64, *PLIST_ENTRY64; /* Singly Linked Lists */ typedef struct _SINGLE_LIST_ENTRY { - struct _SINGLE_LIST_ENTRY *Next; + struct _SINGLE_LIST_ENTRY *Next; } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY; typedef struct _PROCESSOR_NUMBER { @@ -603,10 +601,10 @@ struct _EXCEPTION_RECORD; typedef EXCEPTION_DISPOSITION (NTAPI *PEXCEPTION_ROUTINE)( - IN struct _EXCEPTION_RECORD *ExceptionRecord, - IN PVOID EstablisherFrame, - IN OUT struct _CONTEXT *ContextRecord, - IN OUT PVOID DispatcherContext); + struct _EXCEPTION_RECORD *ExceptionRecord, + PVOID EstablisherFrame, + struct _CONTEXT *ContextRecord, + PVOID DispatcherContext); typedef struct _GROUP_AFFINITY { KAFFINITY Mask; @@ -650,155 +648,154 @@ typedef struct _GROUP_AFFINITY { /* C_ASSERT Definition */ #define C_ASSERT(expr) extern char (*c_assert(void)) [(expr) ? 1 : -1] +#define VER_WORKSTATION_NT 0x40000000 +#define VER_SERVER_NT 0x80000000 +#define VER_SUITE_SMALLBUSINESS 0x00000001 +#define VER_SUITE_ENTERPRISE 0x00000002 +#define VER_SUITE_BACKOFFICE 0x00000004 +#define VER_SUITE_COMMUNICATIONS 0x00000008 +#define VER_SUITE_TERMINAL 0x00000010 +#define VER_SUITE_SMALLBUSINESS_RESTRICTED 0x00000020 +#define VER_SUITE_EMBEDDEDNT 0x00000040 +#define VER_SUITE_DATACENTER 0x00000080 +#define VER_SUITE_SINGLEUSERTS 0x00000100 +#define VER_SUITE_PERSONAL 0x00000200 +#define VER_SUITE_BLADE 0x00000400 +#define VER_SUITE_EMBEDDED_RESTRICTED 0x00000800 +#define VER_SUITE_SECURITY_APPLIANCE 0x00001000 +#define VER_SUITE_STORAGE_SERVER 0x00002000 +#define VER_SUITE_COMPUTE_SERVER 0x00004000 +#define VER_SUITE_WH_SERVER 0x00008000 + /* Primary language IDs. */ -#define LANG_NEUTRAL 0x00 -#define LANG_INVARIANT 0x7f +#define LANG_NEUTRAL 0x00 +#define LANG_INVARIANT 0x7f -#define LANG_AFRIKAANS 0x36 -#define LANG_ALBANIAN 0x1c -#define LANG_ALSATIAN 0x84 -#define LANG_AMHARIC 0x5e -#define LANG_ARABIC 0x01 -#define LANG_ARMENIAN 0x2b -#define LANG_ASSAMESE 0x4d -#define LANG_AZERI 0x2c -#define LANG_BASHKIR 0x6d -#define LANG_BASQUE 0x2d -#define LANG_BELARUSIAN 0x23 -#define LANG_BENGALI 0x45 -#define LANG_BRETON 0x7e -#define LANG_BOSNIAN 0x1a -#define LANG_BOSNIAN_NEUTRAL 0x781a -#define LANG_BULGARIAN 0x02 -#define LANG_CATALAN 0x03 -#define LANG_CHINESE 0x04 -#define LANG_CHINESE_SIMPLIFIED 0x04 -#define LANG_CHINESE_TRADITIONAL 0x7c04 -#define LANG_CORSICAN 0x83 -#define LANG_CROATIAN 0x1a -#define LANG_CZECH 0x05 -#define LANG_DANISH 0x06 -#define LANG_DARI 0x8c -#define LANG_DIVEHI 0x65 -#define LANG_DUTCH 0x13 -#define LANG_ENGLISH 0x09 -#define LANG_ESTONIAN 0x25 -#define LANG_FAEROESE 0x38 -#define LANG_FARSI 0x29 -#define LANG_FILIPINO 0x64 -#define LANG_FINNISH 0x0b -#define LANG_FRENCH 0x0c -#define LANG_FRISIAN 0x62 -#define LANG_GALICIAN 0x56 -#define LANG_GEORGIAN 0x37 -#define LANG_GERMAN 0x07 -#define LANG_GREEK 0x08 -#define LANG_GREENLANDIC 0x6f -#define LANG_GUJARATI 0x47 -#define LANG_HAUSA 0x68 -#define LANG_HEBREW 0x0d -#define LANG_HINDI 0x39 -#define LANG_HUNGARIAN 0x0e -#define LANG_ICELANDIC 0x0f -#define LANG_IGBO 0x70 -#define LANG_INDONESIAN 0x21 -#define LANG_INUKTITUT 0x5d -#define LANG_IRISH 0x3c -#define LANG_ITALIAN 0x10 -#define LANG_JAPANESE 0x11 -#define LANG_KANNADA 0x4b -#define LANG_KASHMIRI 0x60 -#define LANG_KAZAK 0x3f -#define LANG_KHMER 0x53 -#define LANG_KICHE 0x86 -#define LANG_KINYARWANDA 0x87 -#define LANG_KONKANI 0x57 -#define LANG_KOREAN 0x12 -#define LANG_KYRGYZ 0x40 -#define LANG_LAO 0x54 -#define LANG_LATVIAN 0x26 -#define LANG_LITHUANIAN 0x27 -#define LANG_LOWER_SORBIAN 0x2e -#define LANG_LUXEMBOURGISH 0x6e -#define LANG_MACEDONIAN 0x2f -#define LANG_MALAY 0x3e -#define LANG_MALAYALAM 0x4c -#define LANG_MALTESE 0x3a -#define LANG_MANIPURI 0x58 -#define LANG_MAORI 0x81 -#define LANG_MAPUDUNGUN 0x7a -#define LANG_MARATHI 0x4e -#define LANG_MOHAWK 0x7c -#define LANG_MONGOLIAN 0x50 -#define LANG_NEPALI 0x61 -#define LANG_NORWEGIAN 0x14 -#define LANG_OCCITAN 0x82 -#define LANG_ORIYA 0x48 -#define LANG_PASHTO 0x63 -#define LANG_PERSIAN 0x29 -#define LANG_POLISH 0x15 -#define LANG_PORTUGUESE 0x16 -#define LANG_PUNJABI 0x46 -#define LANG_QUECHUA 0x6b -#define LANG_ROMANIAN 0x18 -#define LANG_ROMANSH 0x17 -#define LANG_RUSSIAN 0x19 -#define LANG_SAMI 0x3b -#define LANG_SANSKRIT 0x4f -#define LANG_SERBIAN 0x1a -#define LANG_SERBIAN_NEUTRAL 0x7c1a -#define LANG_SINDHI 0x59 -#define LANG_SINHALESE 0x5b -#define LANG_SLOVAK 0x1b -#define LANG_SLOVENIAN 0x24 -#define LANG_SOTHO 0x6c -#define LANG_SPANISH 0x0a -#define LANG_SWAHILI 0x41 -#define LANG_SWEDISH 0x1d -#define LANG_SYRIAC 0x5a -#define LANG_TAJIK 0x28 -#define LANG_TAMAZIGHT 0x5f -#define LANG_TAMIL 0x49 -#define LANG_TATAR 0x44 -#define LANG_TELUGU 0x4a -#define LANG_THAI 0x1e -#define LANG_TIBETAN 0x51 -#define LANG_TIGRIGNA 0x73 -#define LANG_TSWANA 0x32 -#define LANG_TURKISH 0x1f -#define LANG_TURKMEN 0x42 -#define LANG_UIGHUR 0x80 -#define LANG_UKRAINIAN 0x22 -#define LANG_UPPER_SORBIAN 0x2e -#define LANG_URDU 0x20 -#define LANG_UZBEK 0x43 -#define LANG_VIETNAMESE 0x2a -#define LANG_WELSH 0x52 -#define LANG_WOLOF 0x88 -#define LANG_XHOSA 0x34 -#define LANG_YAKUT 0x85 -#define LANG_YI 0x78 -#define LANG_YORUBA 0x6a -#define LANG_ZULU 0x35 - -#define VER_WORKSTATION_NT 0x40000000 -#define VER_SERVER_NT 0x80000000 - -#define VER_SUITE_SMALLBUSINESS 1 -#define VER_SUITE_ENTERPRISE 2 -#define VER_SUITE_BACKOFFICE 4 -#define VER_SUITE_COMMUNICATIONS 8 -#define VER_SUITE_TERMINAL 16 -#define VER_SUITE_SMALLBUSINESS_RESTRICTED 32 -#define VER_SUITE_EMBEDDEDNT 64 -#define VER_SUITE_DATACENTER 128 -#define VER_SUITE_SINGLEUSERTS 256 -#define VER_SUITE_PERSONAL 512 -#define VER_SUITE_BLADE 1024 -#define VER_SUITE_EMBEDDED_RESTRICTED 2048 -#define VER_SUITE_SECURITY_APPLIANCE 4096 -#define VER_SUITE_STORAGE_SERVER 8192 -#define VER_SUITE_COMPUTE_SERVER 16384 -#define VER_SUITE_WH_SERVER 32768 +#define LANG_AFRIKAANS 0x36 +#define LANG_ALBANIAN 0x1c +#define LANG_ALSATIAN 0x84 +#define LANG_AMHARIC 0x5e +#define LANG_ARABIC 0x01 +#define LANG_ARMENIAN 0x2b +#define LANG_ASSAMESE 0x4d +#define LANG_AZERI 0x2c +#define LANG_BASHKIR 0x6d +#define LANG_BASQUE 0x2d +#define LANG_BELARUSIAN 0x23 +#define LANG_BENGALI 0x45 +#define LANG_BRETON 0x7e +#define LANG_BOSNIAN 0x1a +#define LANG_BOSNIAN_NEUTRAL 0x781a +#define LANG_BULGARIAN 0x02 +#define LANG_CATALAN 0x03 +#define LANG_CHINESE 0x04 +#define LANG_CHINESE_SIMPLIFIED 0x04 +#define LANG_CHINESE_TRADITIONAL 0x7c04 +#define LANG_CORSICAN 0x83 +#define LANG_CROATIAN 0x1a +#define LANG_CZECH 0x05 +#define LANG_DANISH 0x06 +#define LANG_DARI 0x8c +#define LANG_DIVEHI 0x65 +#define LANG_DUTCH 0x13 +#define LANG_ENGLISH 0x09 +#define LANG_ESTONIAN 0x25 +#define LANG_FAEROESE 0x38 +#define LANG_FARSI 0x29 +#define LANG_FILIPINO 0x64 +#define LANG_FINNISH 0x0b +#define LANG_FRENCH 0x0c +#define LANG_FRISIAN 0x62 +#define LANG_GALICIAN 0x56 +#define LANG_GEORGIAN 0x37 +#define LANG_GERMAN 0x07 +#define LANG_GREEK 0x08 +#define LANG_GREENLANDIC 0x6f +#define LANG_GUJARATI 0x47 +#define LANG_HAUSA 0x68 +#define LANG_HEBREW 0x0d +#define LANG_HINDI 0x39 +#define LANG_HUNGARIAN 0x0e +#define LANG_ICELANDIC 0x0f +#define LANG_IGBO 0x70 +#define LANG_INDONESIAN 0x21 +#define LANG_INUKTITUT 0x5d +#define LANG_IRISH 0x3c +#define LANG_ITALIAN 0x10 +#define LANG_JAPANESE 0x11 +#define LANG_KANNADA 0x4b +#define LANG_KASHMIRI 0x60 +#define LANG_KAZAK 0x3f +#define LANG_KHMER 0x53 +#define LANG_KICHE 0x86 +#define LANG_KINYARWANDA 0x87 +#define LANG_KONKANI 0x57 +#define LANG_KOREAN 0x12 +#define LANG_KYRGYZ 0x40 +#define LANG_LAO 0x54 +#define LANG_LATVIAN 0x26 +#define LANG_LITHUANIAN 0x27 +#define LANG_LOWER_SORBIAN 0x2e +#define LANG_LUXEMBOURGISH 0x6e +#define LANG_MACEDONIAN 0x2f +#define LANG_MALAY 0x3e +#define LANG_MALAYALAM 0x4c +#define LANG_MALTESE 0x3a +#define LANG_MANIPURI 0x58 +#define LANG_MAORI 0x81 +#define LANG_MAPUDUNGUN 0x7a +#define LANG_MARATHI 0x4e +#define LANG_MOHAWK 0x7c +#define LANG_MONGOLIAN 0x50 +#define LANG_NEPALI 0x61 +#define LANG_NORWEGIAN 0x14 +#define LANG_OCCITAN 0x82 +#define LANG_ORIYA 0x48 +#define LANG_PASHTO 0x63 +#define LANG_PERSIAN 0x29 +#define LANG_POLISH 0x15 +#define LANG_PORTUGUESE 0x16 +#define LANG_PUNJABI 0x46 +#define LANG_QUECHUA 0x6b +#define LANG_ROMANIAN 0x18 +#define LANG_ROMANSH 0x17 +#define LANG_RUSSIAN 0x19 +#define LANG_SAMI 0x3b +#define LANG_SANSKRIT 0x4f +#define LANG_SERBIAN 0x1a +#define LANG_SERBIAN_NEUTRAL 0x7c1a +#define LANG_SINDHI 0x59 +#define LANG_SINHALESE 0x5b +#define LANG_SLOVAK 0x1b +#define LANG_SLOVENIAN 0x24 +#define LANG_SOTHO 0x6c +#define LANG_SPANISH 0x0a +#define LANG_SWAHILI 0x41 +#define LANG_SWEDISH 0x1d +#define LANG_SYRIAC 0x5a +#define LANG_TAJIK 0x28 +#define LANG_TAMAZIGHT 0x5f +#define LANG_TAMIL 0x49 +#define LANG_TATAR 0x44 +#define LANG_TELUGU 0x4a +#define LANG_THAI 0x1e +#define LANG_TIBETAN 0x51 +#define LANG_TIGRIGNA 0x73 +#define LANG_TSWANA 0x32 +#define LANG_TURKISH 0x1f +#define LANG_TURKMEN 0x42 +#define LANG_UIGHUR 0x80 +#define LANG_UKRAINIAN 0x22 +#define LANG_UPPER_SORBIAN 0x2e +#define LANG_URDU 0x20 +#define LANG_UZBEK 0x43 +#define LANG_VIETNAMESE 0x2a +#define LANG_WELSH 0x52 +#define LANG_WOLOF 0x88 +#define LANG_XHOSA 0x34 +#define LANG_YAKUT 0x85 +#define LANG_YI 0x78 +#define LANG_YORUBA 0x6a +#define LANG_ZULU 0x35 #endif /* _NTDEF_ */ From 617f243c3f9fe4e28f14f2f088a6202b69612b51 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 22 Aug 2010 22:22:27 +0000 Subject: [PATCH 33/76] [DHCPCSVC] - Write the DNS servers in a REG_MULTI_SZ value [IPHLPAPI] - Rewrite the registry reading code - Use HeapFree to free memory from the allocated from heap svn path=/trunk/; revision=48593 --- reactos/dll/win32/dhcpcsvc/dhcp/dhclient.c | 11 +- reactos/dll/win32/iphlpapi/iphlpapi_private.h | 1 + reactos/dll/win32/iphlpapi/registry.c | 126 ++++++++++++++++-- reactos/dll/win32/iphlpapi/resinfo_reactos.c | 51 ++----- 4 files changed, 133 insertions(+), 56 deletions(-) diff --git a/reactos/dll/win32/dhcpcsvc/dhcp/dhclient.c b/reactos/dll/win32/dhcpcsvc/dhcp/dhclient.c index 3b60e1ad95d..120fd6c01e9 100644 --- a/reactos/dll/win32/dhcpcsvc/dhcp/dhclient.c +++ b/reactos/dll/win32/dhcpcsvc/dhcp/dhclient.c @@ -507,24 +507,25 @@ void set_name_servers( PDHCP_ADAPTER Adapter, struct client_lease *new_lease ) { char *nsbuf; int i, addrs = new_lease->options[DHO_DOMAIN_NAME_SERVERS].len / sizeof(ULONG); + int len = 0; - nsbuf = malloc( addrs * sizeof(IP_ADDRESS_STRING) ); + nsbuf = malloc( addrs * sizeof(IP_ADDRESS_STRING) + 1 ); if( nsbuf) { - nsbuf[0] = 0; + memset(nsbuf, 0, addrs * sizeof(IP_ADDRESS_STRING) + 1); for( i = 0; i < addrs; i++ ) { nameserver.len = sizeof(ULONG); memcpy( nameserver.iabuf, new_lease->options[DHO_DOMAIN_NAME_SERVERS].data + (i * sizeof(ULONG)), sizeof(ULONG) ); strcat( nsbuf, piaddr(nameserver) ); - if( i != addrs-1 ) strcat( nsbuf, "," ); + len += strlen(nsbuf) + 1; } DH_DbgPrint(MID_TRACE,("Setting DhcpNameserver: %s\n", nsbuf)); - RegSetValueExA( RegKey, "DhcpNameServer", 0, REG_SZ, - (LPBYTE)nsbuf, strlen(nsbuf) + 1 ); + RegSetValueExA( RegKey, "DhcpNameServer", 0, REG_MULTI_SZ, + (LPBYTE)nsbuf, len + 1 ); free( nsbuf ); } diff --git a/reactos/dll/win32/iphlpapi/iphlpapi_private.h b/reactos/dll/win32/iphlpapi/iphlpapi_private.h index 2cb747f2a80..6ba198a301c 100644 --- a/reactos/dll/win32/iphlpapi/iphlpapi_private.h +++ b/reactos/dll/win32/iphlpapi/iphlpapi_private.h @@ -139,6 +139,7 @@ LONG OpenChildKeyRead( HANDLE RegHandle, PWCHAR GetNthChildKeyName( HANDLE RegHandle, DWORD n ); void ConsumeChildKeyName( PWCHAR Name ); PWCHAR QueryRegistryValueString( HANDLE RegHandle, PWCHAR ValueName ); +PWCHAR *QueryRegistryValueStringMulti( HANDLE RegHandle, PWCHAR ValueName ); void ConsumeRegValueString( PWCHAR NameServer ); BOOL isInterface( TDIEntityID *if_maybe ); BOOL hasArp( HANDLE tcpFile, TDIEntityID *arp_maybe ); diff --git a/reactos/dll/win32/iphlpapi/registry.c b/reactos/dll/win32/iphlpapi/registry.c index 64b0f1f98bb..e83fde95281 100644 --- a/reactos/dll/win32/iphlpapi/registry.c +++ b/reactos/dll/win32/iphlpapi/registry.c @@ -66,25 +66,123 @@ void ConsumeChildKeyName( PWCHAR Name ) { if (Name) HeapFree( GetProcessHeap(), 0, Name ); } -PWCHAR QueryRegistryValueString( HANDLE RegHandle, PWCHAR ValueName ) { - PWCHAR Name; - DWORD ReturnedSize = 0; +PVOID QueryRegistryValue(HANDLE RegHandle, PWCHAR ValueName, LPDWORD RegistryType, LPDWORD Length) +{ + PVOID ReadValue = NULL; + DWORD Error; - if (RegQueryValueExW( RegHandle, ValueName, NULL, NULL, NULL, - &ReturnedSize ) != 0) { - return 0; - } else { - Name = malloc( ReturnedSize); - RegQueryValueExW( RegHandle, ValueName, NULL, NULL, (PVOID)Name, - &ReturnedSize ); - return Name; - } + *Length = 0; + *RegistryType = REG_NONE; + + while (TRUE) + { + Error = RegQueryValueExW(RegHandle, ValueName, NULL, RegistryType, ReadValue, Length); + if (Error == ERROR_SUCCESS) + { + if (ReadValue) break; + } + else if (Error == ERROR_MORE_DATA) + { + HeapFree(GetProcessHeap(), 0, ReadValue); + } + else break; + + ReadValue = HeapAlloc(GetProcessHeap(), 0, *Length); + if (!ReadValue) return NULL; + } + + if (Error != ERROR_SUCCESS) + { + if (ReadValue) HeapFree(GetProcessHeap(), 0, ReadValue); + + *Length = 0; + *RegistryType = REG_NONE; + ReadValue = NULL; + } + + return ReadValue; +} + +PWCHAR TerminateReadString(PWCHAR String, DWORD Length) +{ + PWCHAR TerminatedString; + + TerminatedString = HeapAlloc(GetProcessHeap(), 0, Length + sizeof(WCHAR)); + if (TerminatedString == NULL) + return NULL; + + memcpy(TerminatedString, String, Length); + + TerminatedString[Length / sizeof(WCHAR)] = UNICODE_NULL; + + return TerminatedString; +} + +PWCHAR QueryRegistryValueString( HANDLE RegHandle, PWCHAR ValueName ) +{ + PWCHAR String, TerminatedString; + DWORD Type, Length; + + String = QueryRegistryValue(RegHandle, ValueName, &Type, &Length); + if (!String) return NULL; + if (Type != REG_SZ) + { + DbgPrint("Type mismatch for %S (%d != %d)\n", ValueName, Type, REG_SZ); + //HeapFree(GetProcessHeap(), 0, String); + //return NULL; + } + + TerminatedString = TerminateReadString(String, Length); + HeapFree(GetProcessHeap(), 0, String); + if (!TerminatedString) return NULL; + + return TerminatedString; } void ConsumeRegValueString( PWCHAR Value ) { - if (Value) free(Value); + if (Value) HeapFree(GetProcessHeap(), 0, Value); } PWCHAR *QueryRegistryValueStringMulti( HANDLE RegHandle, PWCHAR ValueName ) { - return 0; /* FIXME if needed */ + PWCHAR String, TerminatedString, Tmp; + PWCHAR *Table; + DWORD Type, Length, i, j; + + String = QueryRegistryValue(RegHandle, ValueName, &Type, &Length); + if (!String) return NULL; + if (Type != REG_MULTI_SZ) + { + DbgPrint("Type mismatch for %S (%d != %d)\n", ValueName, Type, REG_MULTI_SZ); + //HeapFree(GetProcessHeap(), 0, String); + //return NULL; + } + + TerminatedString = TerminateReadString(String, Length); + HeapFree(GetProcessHeap(), 0, String); + if (!TerminatedString) return NULL; + + for (Tmp = TerminatedString, i = 0; *Tmp; Tmp++, i++) while (*Tmp) Tmp++; + + Table = HeapAlloc(GetProcessHeap(), 0, (i + 1) * sizeof(PWCHAR)); + if (!Table) + { + HeapFree(GetProcessHeap(), 0, TerminatedString); + return NULL; + } + + for (Tmp = TerminatedString, j = 0; *Tmp; Tmp++, j++) + { + PWCHAR Orig = Tmp; + + for (i = 0; *Tmp; i++, Tmp++); + + Table[j] = HeapAlloc(GetProcessHeap(), 0, i * sizeof(WCHAR)); + memcpy(Table[j], Orig, i * sizeof(WCHAR)); + } + + Table[j] = NULL; + + HeapFree(GetProcessHeap(), 0, TerminatedString); + + return Table; } diff --git a/reactos/dll/win32/iphlpapi/resinfo_reactos.c b/reactos/dll/win32/iphlpapi/resinfo_reactos.c index 02bcb3b9129..154170d0836 100644 --- a/reactos/dll/win32/iphlpapi/resinfo_reactos.c +++ b/reactos/dll/win32/iphlpapi/resinfo_reactos.c @@ -122,47 +122,24 @@ static void EnumInterfaces( PVOID Data, EnumInterfacesFunc cb ) { void EnumNameServers( HANDLE RegHandle, PWCHAR Interface, PVOID Data, EnumNameServersFunc cb ) { - PWCHAR NameServerString = - QueryRegistryValueString(RegHandle, L"DhcpNameServer"); + PWCHAR *NameServerString = + QueryRegistryValueStringMulti(RegHandle, L"DhcpNameServer"); + DWORD i; if (!NameServerString) - NameServerString = QueryRegistryValueString(RegHandle, L"NameServer"); - - if (NameServerString) { - /* Now, count the non-empty comma separated */ - DWORD ch; - DWORD LastNameStart = 0; - for (ch = 0; NameServerString[ch]; ch++) { - if (NameServerString[ch] == ',') { - if (ch - LastNameStart > 0) { /* Skip empty entries */ - PWCHAR NameServer = - malloc(((ch - LastNameStart) + 1) * sizeof(WCHAR)); - if (NameServer) { - memcpy(NameServer,NameServerString + LastNameStart, - (ch - LastNameStart) * sizeof(WCHAR)); - NameServer[ch - LastNameStart] = 0; - cb( Interface, NameServer, Data ); - free(NameServer); - LastNameStart = ch +1; - } - } - LastNameStart = ch + 1; /* The first one after the comma */ - } - } - if (ch - LastNameStart > 0) { /* A last name? */ - PWCHAR NameServer = malloc(((ch - LastNameStart) + 1) * sizeof(WCHAR)); - if (NameServer) { - memcpy(NameServer,NameServerString + LastNameStart, - (ch - LastNameStart) * sizeof(WCHAR)); - NameServer[ch - LastNameStart] = 0; - cb( Interface, NameServer, Data ); - free(NameServer); - } - } - ConsumeRegValueString(NameServerString); + NameServerString = QueryRegistryValueStringMulti(RegHandle, L"NameServer"); + + if (!NameServerString) return; + + for (i = 0; NameServerString[i]; i++) + { + cb(Interface, NameServerString[i], Data); + + HeapFree(GetProcessHeap(), 0, NameServerString[i]); } + + HeapFree(GetProcessHeap(), 0, NameServerString); } - static void CreateNameServerListEnumNamesFuncCount( PWCHAR Interface, PWCHAR Server, PVOID _Data ) { From dfce6bb843eb7241bd5f10ca34f3d43dd97c68de Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 22 Aug 2010 22:44:36 +0000 Subject: [PATCH 34/76] [WIN32K] - When doing a cleanup for a DC, check, if the default brushes are set, before dereferencing them. Fixes a possible kernel mode crash. - Remove some obsolete casts svn path=/trunk/; revision=48595 --- reactos/subsystems/win32/win32k/objects/dclife.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/reactos/subsystems/win32/win32k/objects/dclife.c b/reactos/subsystems/win32/win32k/objects/dclife.c index a766d7d9706..8e7e223900d 100644 --- a/reactos/subsystems/win32/win32k/objects/dclife.c +++ b/reactos/subsystems/win32/win32k/objects/dclife.c @@ -165,8 +165,10 @@ DC_Cleanup(PVOID ObjectBody) DC_vSelectPalette(pDC, NULL); /* Dereference default brushes */ - BRUSH_ShareUnlockBrush(pDC->eboText.pbrush); - BRUSH_ShareUnlockBrush(pDC->eboBackground.pbrush); + if (pDC->eboText.pbrush) + BRUSH_ShareUnlockBrush(pDC->eboText.pbrush); + if (pDC->eboBackground.pbrush) + BRUSH_ShareUnlockBrush(pDC->eboBackground.pbrush); /* Cleanup the dc brushes */ EBRUSHOBJ_vCleanup(&pDC->eboFill); @@ -205,12 +207,12 @@ DC_SetOwnership(HDC hDC, PEPROCESS Owner) } if (pDC->prgnVis) { // FIXME! HAX!!! - Index = GDI_HANDLE_GET_INDEX(((PROSRGNDATA)pDC->prgnVis)->BaseObject.hHmgr); + Index = GDI_HANDLE_GET_INDEX(pDC->prgnVis->BaseObject.hHmgr); Entry = &GdiHandleTable->Entries[Index]; if (Entry->UserData) FreeObjectAttr(Entry->UserData); Entry->UserData = NULL; // - if (!GDIOBJ_SetOwnership(((PROSRGNDATA)pDC->prgnVis)->BaseObject.hHmgr, Owner)) return FALSE; + if (!GDIOBJ_SetOwnership(pDC->prgnVis->BaseObject.hHmgr, Owner)) return FALSE; } if (pDC->rosdc.hGCClipRgn) { // FIXME! HAX!!! From 314e02e2f044d435a6dda22f70d21f74188650f5 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 22 Aug 2010 23:38:02 +0000 Subject: [PATCH 35/76] [WIN32K] / [GDI32] - GetTextExtentExPointI and GetTextExtentPointI take an array of glyph indices, not characters. Pass a flag GTEF_INDICES (This is a reactos specific definition and not exactly like on Windows XP, but the real names/values are undocumented and this is the easiest way.) to NtGdiGetTextExtent/NtGdiGetTextExtentExW and handle this flag in TextIntGetTextExtentPoint to account for this. Fixes bug 3481 svn path=/trunk/; revision=48597 --- reactos/dll/win32/gdi32/objects/text.c | 6 ++--- reactos/include/reactos/win32k/ntgdityp.h | 3 +++ .../subsystems/win32/win32k/include/text.h | 2 +- .../subsystems/win32/win32k/objects/font.c | 7 +++--- .../win32/win32k/objects/freetype.c | 22 ++++++++++++------- .../subsystems/win32/win32k/objects/text.c | 13 +++++++---- 6 files changed, 34 insertions(+), 19 deletions(-) diff --git a/reactos/dll/win32/gdi32/objects/text.c b/reactos/dll/win32/gdi32/objects/text.c index d64e01262f2..b84e948abad 100644 --- a/reactos/dll/win32/gdi32/objects/text.c +++ b/reactos/dll/win32/gdi32/objects/text.c @@ -173,7 +173,7 @@ GetTextExtentPointW( LPSIZE lpSize ) { - return NtGdiGetTextExtent(hdc, (LPWSTR)lpString, cchString, lpSize, 1); + return NtGdiGetTextExtent(hdc, (LPWSTR)lpString, cchString, lpSize, 0); } @@ -299,7 +299,7 @@ GetTextExtentExPointI(HDC hdc, LPINT alpDx, LPSIZE lpSize) { - return NtGdiGetTextExtentExW(hdc,pgiIn,cgi,nMaxExtent,(ULONG *)lpnFit, (PULONG) alpDx,lpSize,1); + return NtGdiGetTextExtentExW(hdc,pgiIn,cgi,nMaxExtent,(ULONG *)lpnFit, (PULONG) alpDx,lpSize,GTEF_INDICES); } /* @@ -312,7 +312,7 @@ GetTextExtentPointI(HDC hdc, int cgi, LPSIZE lpSize) { - return NtGdiGetTextExtent(hdc,pgiIn,cgi,lpSize,2); + return NtGdiGetTextExtent(hdc,pgiIn,cgi,lpSize,GTEF_INDICES); } /* diff --git a/reactos/include/reactos/win32k/ntgdityp.h b/reactos/include/reactos/win32k/ntgdityp.h index 1aedf765dbc..667060b87d6 100644 --- a/reactos/include/reactos/win32k/ntgdityp.h +++ b/reactos/include/reactos/win32k/ntgdityp.h @@ -192,6 +192,9 @@ typedef DWORD LFTYPE; #define GCABCW_NOFLOAT 0x0001 #define GCABCW_INDICES 0x0002 +// NtGdiGetTextExtent* flags (reactos own) +#define GTEF_INDICES 0x1 + /* CAPS1 support */ #define CAPS1 94 //#define C1_TRANSPARENT 0x0001 diff --git a/reactos/subsystems/win32/win32k/include/text.h b/reactos/subsystems/win32/win32k/include/text.h index a9a05779055..9dc6510fd6e 100644 --- a/reactos/subsystems/win32/win32k/include/text.h +++ b/reactos/subsystems/win32/win32k/include/text.h @@ -96,7 +96,7 @@ INT FASTCALL IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristi ULONG FASTCALL ftGdiGetGlyphOutline(PDC,WCHAR,UINT,LPGLYPHMETRICS,ULONG,PVOID,LPMAT2,BOOL); INT FASTCALL IntGetOutlineTextMetrics(PFONTGDI,UINT,OUTLINETEXTMETRICW *); BOOL FASTCALL ftGdiGetRasterizerCaps(LPRASTERIZER_STATUS); -BOOL FASTCALL TextIntGetTextExtentPoint(PDC,PTEXTOBJ,LPCWSTR,INT,ULONG,LPINT,LPINT,LPSIZE); +BOOL FASTCALL TextIntGetTextExtentPoint(PDC,PTEXTOBJ,LPCWSTR,INT,ULONG,LPINT,LPINT,LPSIZE,FLONG); BOOL FASTCALL ftGdiGetTextMetricsW(HDC,PTMW_INTERNAL); DWORD FASTCALL IntGetFontLanguageInfo(PDC); INT FASTCALL ftGdiGetTextCharsetInfo(PDC,PFONTSIGNATURE,DWORD); diff --git a/reactos/subsystems/win32/win32k/objects/font.c b/reactos/subsystems/win32/win32k/objects/font.c index a0837e1d24a..520f256b312 100644 --- a/reactos/subsystems/win32/win32k/objects/font.c +++ b/reactos/subsystems/win32/win32k/objects/font.c @@ -75,7 +75,7 @@ GreGetKerningPairs( return Count; } - +#if 0 DWORD FASTCALL GreGetCharacterPlacementW( @@ -90,13 +90,14 @@ GreGetCharacterPlacementW( if (!pgcpw) { - if (GreGetTextExtentW( hdc, pwsz, nCount, &Size, 1)) + if (GreGetTextExtentW( hdc, pwsz, nCount, &Size, 0)) return MAKELONG(Size.cx, Size.cy); return 0; } UNIMPLEMENTED; return 0; } +#endif INT FASTCALL @@ -167,7 +168,7 @@ IntGetCharDimensions(HDC hdc, PTEXTMETRICW ptm, PDWORD height) DC_UnlockDc(pdc); return 0; } - Good = TextIntGetTextExtentPoint(pdc, TextObj, alphabet, 52, 0, NULL, 0, &sz); + Good = TextIntGetTextExtentPoint(pdc, TextObj, alphabet, 52, 0, NULL, 0, &sz, 0); TEXTOBJ_UnlockText(TextObj); DC_UnlockDc(pdc); diff --git a/reactos/subsystems/win32/win32k/objects/freetype.c b/reactos/subsystems/win32/win32k/objects/freetype.c index 1c111e28fd8..7475847d234 100644 --- a/reactos/subsystems/win32/win32k/objects/freetype.c +++ b/reactos/subsystems/win32/win32k/objects/freetype.c @@ -2123,7 +2123,8 @@ TextIntGetTextExtentPoint(PDC dc, ULONG MaxExtent, LPINT Fit, LPINT Dx, - LPSIZE Size) + LPSIZE Size, + FLONG fl) { PFONTGDI FontGDI; FT_Face face; @@ -2195,7 +2196,11 @@ TextIntGetTextExtentPoint(PDC dc, for (i = 0; i < Count; i++) { - glyph_index = FT_Get_Char_Index(face, *String); + if (fl & GTEF_INDICES) + glyph_index = *String; + else + glyph_index = FT_Get_Char_Index(face, *String); + if (!(realglyph = ftGdiGlyphCacheGet(face, glyph_index, TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfHeight))) { @@ -4238,16 +4243,17 @@ NtGdiGetGlyphIndicesW( IntLockFreeType; face = FontGDI->face; + if (DefChar == 0xffff && FT_IS_SFNT(face)) + { + TT_OS2 *pOS2 = FT_Get_Sfnt_Table(face, ft_sfnt_os2); + DefChar = (pOS2->usDefaultChar ? FT_Get_Char_Index(face, pOS2->usDefaultChar) : 0); + } + for (i = 0; i < cwc; i++) { - Buffer[i] = FT_Get_Char_Index(face, UnSafepwc[i]); + Buffer[i] = FT_Get_Char_Index(face, UnSafepwc[i]); // FIXME: unsafe! if (Buffer[i] == 0) { - if (DefChar == 0xffff && FT_IS_SFNT(face)) - { - TT_OS2 *pOS2 = FT_Get_Sfnt_Table(face, ft_sfnt_os2); - DefChar = (pOS2->usDefaultChar ? FT_Get_Char_Index(face, pOS2->usDefaultChar) : 0); - } Buffer[i] = DefChar; } } diff --git a/reactos/subsystems/win32/win32k/objects/text.c b/reactos/subsystems/win32/win32k/objects/text.c index 07cf12dcf21..b39ee850b39 100644 --- a/reactos/subsystems/win32/win32k/objects/text.c +++ b/reactos/subsystems/win32/win32k/objects/text.c @@ -15,6 +15,7 @@ /** Functions *****************************************************************/ +#if 0 /* flOpts : GetTextExtentPoint32W = 0 @@ -60,7 +61,8 @@ GreGetTextExtentW( 0, NULL, 0, - psize); + psize, + flOpts); TEXTOBJ_UnlockText(TextObj); } else @@ -123,7 +125,8 @@ GreGetTextExtentExW( MaxExtent, (LPINT)Fit, (LPINT)Dx, - pSize); + pSize, + fl); TEXTOBJ_UnlockText(TextObj); } else @@ -132,6 +135,7 @@ GreGetTextExtentExW( DC_UnlockDc(pdc); return Result; } +#endif DWORD APIENTRY @@ -347,7 +351,8 @@ NtGdiGetTextExtentExW( MaxExtent, NULL == UnsafeFit ? NULL : &Fit, Dx, - &Size); + &Size, + fl); TEXTOBJ_UnlockText(TextObj); } else @@ -420,7 +425,7 @@ NtGdiGetTextExtent(HDC hdc, LPSIZE psize, UINT flOpts) { - return NtGdiGetTextExtentExW(hdc, lpwsz, cwc, 0, NULL, NULL, psize, 0); + return NtGdiGetTextExtentExW(hdc, lpwsz, cwc, 0, NULL, NULL, psize, flOpts); } BOOL From 3957ae157251b71bcf823f35923b1e9faa0c2d2a Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Mon, 23 Aug 2010 00:02:06 +0000 Subject: [PATCH 36/76] [FAULTREP] - Fix a typo. svn path=/trunk/; revision=48600 --- reactos/dll/win32/faultrep/faultrep.rbuild | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/dll/win32/faultrep/faultrep.rbuild b/reactos/dll/win32/faultrep/faultrep.rbuild index aeeb3afeca5..0c886fc2038 100644 --- a/reactos/dll/win32/faultrep/faultrep.rbuild +++ b/reactos/dll/win32/faultrep/faultrep.rbuild @@ -1,6 +1,6 @@ - . + . include/reactos/wine wine From ca6ff51038da2c8db2580605218f6df5b17ae8be Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 23 Aug 2010 01:16:42 +0000 Subject: [PATCH 37/76] [NTDLL] - Call LdrProcessRelocationBlockLongLong from LdrProcessRelocationBlock instead of duplicating the code svn path=/trunk/; revision=48601 --- reactos/dll/ntdll/ldr/utils.c | 67 ++++++++--------------------------- 1 file changed, 14 insertions(+), 53 deletions(-) diff --git a/reactos/dll/ntdll/ldr/utils.c b/reactos/dll/ntdll/ldr/utils.c index e4b1a61a587..fcbd21f800d 100644 --- a/reactos/dll/ntdll/ldr/utils.c +++ b/reactos/dll/ntdll/ldr/utils.c @@ -88,10 +88,10 @@ static __inline LONG LdrpDecrementLoadCount(PLDR_DATA_TABLE_ENTRY Module, BOOLEA RtlEnterCriticalSection (NtCurrentPeb()->LoaderLock); } LoadCount = Module->LoadCount; - if (Module->LoadCount > 0 && Module->LoadCount != LDRP_PROCESS_CREATION_TIME) - { + if (Module->LoadCount > 0 && Module->LoadCount != LDRP_PROCESS_CREATION_TIME) + { Module->LoadCount--; - } + } if (!Locked) { RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); @@ -107,10 +107,10 @@ static __inline LONG LdrpIncrementLoadCount(PLDR_DATA_TABLE_ENTRY Module, BOOLEA RtlEnterCriticalSection (NtCurrentPeb()->LoaderLock); } LoadCount = Module->LoadCount; - if (Module->LoadCount != LDRP_PROCESS_CREATION_TIME) - { + if (Module->LoadCount != LDRP_PROCESS_CREATION_TIME) + { Module->LoadCount++; - } + } if (!Locked) { RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); @@ -3464,54 +3464,15 @@ LdrQueryImageFileExecutionOptions (IN PUNICODE_STRING SubKey, } -PIMAGE_BASE_RELOCATION NTAPI -LdrProcessRelocationBlock(IN ULONG_PTR Address, - IN ULONG Count, - IN PUSHORT TypeOffset, - IN LONG_PTR Delta) +PIMAGE_BASE_RELOCATION +NTAPI +LdrProcessRelocationBlock( + IN ULONG_PTR Address, + IN ULONG Count, + IN PUSHORT TypeOffset, + IN LONG_PTR Delta) { - SHORT Offset; - USHORT Type; - USHORT i; - PUSHORT ShortPtr; - PULONG LongPtr; - - for (i = 0; i < Count; i++) - { - Offset = *TypeOffset & 0xFFF; - Type = *TypeOffset >> 12; - - switch (Type) - { - case IMAGE_REL_BASED_ABSOLUTE: - break; - - case IMAGE_REL_BASED_HIGH: - ShortPtr = (PUSHORT)((ULONG_PTR)Address + Offset); - *ShortPtr += HIWORD(Delta); - break; - - case IMAGE_REL_BASED_LOW: - ShortPtr = (PUSHORT)((ULONG_PTR)Address + Offset); - *ShortPtr += LOWORD(Delta); - break; - - case IMAGE_REL_BASED_HIGHLOW: - LongPtr = (PULONG)((ULONG_PTR)Address + Offset); - *LongPtr += Delta; - break; - - case IMAGE_REL_BASED_HIGHADJ: - case IMAGE_REL_BASED_MIPS_JMPADDR: - default: - DPRINT1("Unknown/unsupported fixup type %hu.\n", Type); - return NULL; - } - - TypeOffset++; - } - - return (PIMAGE_BASE_RELOCATION)TypeOffset; + return LdrProcessRelocationBlockLongLong(Address, Count, TypeOffset, Delta); } NTSTATUS From 8d77a3fe00c894645eca60e170c7f19fc99e75e2 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 23 Aug 2010 01:17:41 +0000 Subject: [PATCH 38/76] [TCPIP] - Read the IP information from the interface key inside the Tcpip service key (confirmed on XP) - Fix a logic error in my code (no idea how I missed it) - Restores static IP functionality (still waiting on janderwald to fix netcfgx's DNS value writing) svn path=/trunk/; revision=48602 --- reactos/drivers/network/tcpip/datalink/lan.c | 22 +++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/reactos/drivers/network/tcpip/datalink/lan.c b/reactos/drivers/network/tcpip/datalink/lan.c index 2d449550bb0..3883235b6a0 100644 --- a/reactos/drivers/network/tcpip/datalink/lan.c +++ b/reactos/drivers/network/tcpip/datalink/lan.c @@ -569,9 +569,7 @@ VOID NTAPI ProtocolBindAdapter( * SystemSpecific1: Pointer to a registry path with protocol-specific configuration information * SystemSpecific2: Unused & must not be touched */ -{ - /* XXX confirm that this is still true, or re-word the following comment */ - /* we get to ignore BindContext because we will never pend an operation with NDIS */ +{ TI_DbgPrint(DEBUG_DATALINK, ("Called with registry path %wZ for %wZ\n", SystemSpecific1, DeviceName)); *Status = LANRegisterAdapter(DeviceName, SystemSpecific1); } @@ -952,10 +950,13 @@ BOOLEAN BindAdapter( OBJECT_ATTRIBUTES ObjectAttributes; HANDLE ParameterHandle; PKEY_VALUE_PARTIAL_INFORMATION KeyValueInfo; + WCHAR Buffer[150]; UNICODE_STRING IPAddress = RTL_CONSTANT_STRING(L"IPAddress"); UNICODE_STRING Netmask = RTL_CONSTANT_STRING(L"SubnetMask"); UNICODE_STRING Gateway = RTL_CONSTANT_STRING(L"DefaultGateway"); UNICODE_STRING EnableDhcp = RTL_CONSTANT_STRING(L"EnableDHCP"); + UNICODE_STRING Prefix = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\"); + UNICODE_STRING TcpipRegistryPath; UNICODE_STRING RegistryDataU; ANSI_STRING RegistryDataA; @@ -1009,9 +1010,19 @@ BOOLEAN BindAdapter( TI_DbgPrint(DEBUG_DATALINK,("Adapter Description: %wZ\n", &IF->Description)); + + TcpipRegistryPath.MaximumLength = sizeof(WCHAR) * 150; + TcpipRegistryPath.Length = 0; + TcpipRegistryPath.Buffer = Buffer; + + RtlAppendUnicodeStringToString(&TcpipRegistryPath, + &Prefix); + + RtlAppendUnicodeStringToString(&TcpipRegistryPath, + &IF->Name); InitializeObjectAttributes(&ObjectAttributes, - RegistryPath, + &TcpipRegistryPath, OBJ_CASE_INSENSITIVE, 0, NULL); @@ -1019,6 +1030,7 @@ BOOLEAN BindAdapter( AddrInitIPv4(&DefaultMask, 0); Status = ZwOpenKey(&ParameterHandle, KEY_READ, &ObjectAttributes); + if (!NT_SUCCESS(Status)) { IF->Unicast = DefaultMask; @@ -1040,7 +1052,7 @@ BOOLEAN BindAdapter( KeyValueInfo, sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(ULONG), &Unused); - if (NT_SUCCESS(Status) && KeyValueInfo->DataLength == sizeof(ULONG) && (*(PULONG)KeyValueInfo->Data) != 0) + if (NT_SUCCESS(Status) && KeyValueInfo->DataLength == sizeof(ULONG) && (*(PULONG)KeyValueInfo->Data) == 0) { RegistryDataU.MaximumLength = 16 + sizeof(WCHAR); RegistryDataU.Buffer = (PWCHAR)KeyValueInfo->Data; From 35eedf67493d1682ed628f36019f4bc402aa146e Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 23 Aug 2010 01:18:09 +0000 Subject: [PATCH 39/76] [NDK] Add LdrProcessRelocationBlockLongLong. Fixes build, sorry. svn path=/trunk/; revision=48603 --- reactos/include/ndk/ldrfuncs.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/reactos/include/ndk/ldrfuncs.h b/reactos/include/ndk/ldrfuncs.h index 8943a099ad2..743d213b87e 100644 --- a/reactos/include/ndk/ldrfuncs.h +++ b/reactos/include/ndk/ldrfuncs.h @@ -109,4 +109,13 @@ LdrVerifyMappedImageMatchesChecksum( IN ULONG FileLength ); +PIMAGE_BASE_RELOCATION +NTAPI +LdrProcessRelocationBlockLongLong( + IN ULONG_PTR Address, + IN ULONG Count, + IN PUSHORT TypeOffset, + IN LONGLONG Delta +); + #endif From 7aa6c115ead9a6015aad62ddf9a71f4dac5ca8d5 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 23 Aug 2010 01:39:28 +0000 Subject: [PATCH 40/76] [WIN32K] Move the allocation of the vis region of the DC to a later position, so that all mandatory fields are initialized before we try to delete the DC in failure case. Fixes yet another possible crash. svn path=/trunk/; revision=48604 --- .../subsystems/win32/win32k/objects/dclife.c | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/reactos/subsystems/win32/win32k/objects/dclife.c b/reactos/subsystems/win32/win32k/objects/dclife.c index 8e7e223900d..0dffdd41193 100644 --- a/reactos/subsystems/win32/win32k/objects/dclife.c +++ b/reactos/subsystems/win32/win32k/objects/dclife.c @@ -49,18 +49,6 @@ DC_AllocDC(PUNICODE_STRING Driver) hDC = NewDC->BaseObject.hHmgr; - /* Allocate a Vis region */ - NewDC->prgnVis = IntSysCreateRectpRgn(0, 0, 1, 1); - if (!NewDC->prgnVis) - { - DPRINT1("IntSysCreateRectpRgn failed\n"); - if (!GDIOBJ_FreeObjByHandle(hDC, GDI_OBJECT_TYPE_DC)) - { - ASSERT(FALSE); - } - return NULL; - } - NewDC->pdcattr = &NewDC->dcattr; DC_AllocateDcAttr(hDC); @@ -146,6 +134,18 @@ DC_AllocDC(PUNICODE_STRING Driver) hsurf = (HBITMAP)PrimarySurface.pSurface; // <- what kind of haxx0ry is that? NewDC->dclevel.pSurface = SURFACE_ShareLockSurface(hsurf); + /* Allocate a Vis region */ + NewDC->prgnVis = IntSysCreateRectpRgn(0, 0, 1, 1); + if (!NewDC->prgnVis) + { + DPRINT1("IntSysCreateRectpRgn failed\n"); + if (!GDIOBJ_FreeObjByHandle(hDC, GDI_OBJECT_TYPE_DC)) + { + ASSERT(FALSE); + } + return NULL; + } + return NewDC; } From b8e0dc9948d6bd5682edc57ebdecebde22f5659f Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 23 Aug 2010 01:41:56 +0000 Subject: [PATCH 41/76] [WIN32K] Seperate DC_vSetLayout from NtGdiSetLayout and save the old value before setting the new one. svn path=/trunk/; revision=48605 --- .../subsystems/win32/win32k/objects/coord.c | 83 ++++++++++--------- 1 file changed, 46 insertions(+), 37 deletions(-) diff --git a/reactos/subsystems/win32/win32k/objects/coord.c b/reactos/subsystems/win32/win32k/objects/coord.c index 7310dcb1adc..12cb42a024b 100644 --- a/reactos/subsystems/win32/win32k/objects/coord.c +++ b/reactos/subsystems/win32/win32k/objects/coord.c @@ -886,6 +886,46 @@ IntMirrorWindowOrg(PDC dc) return; } +VOID +NTAPI +DC_vSetLayout( + IN PDC pdc, + IN LONG wox, + IN DWORD dwLayout) +{ + PDC_ATTR pdcattr = pdc->pdcattr; + + pdcattr->dwLayout = dwLayout; + + if (!(dwLayout & LAYOUT_ORIENTATIONMASK)) return; + + if (dwLayout & LAYOUT_RTL) + { + pdcattr->iMapMode = MM_ANISOTROPIC; + } + + pdcattr->szlWindowExt.cy = -pdcattr->szlWindowExt.cy; + pdcattr->ptlWindowOrg.x = -pdcattr->ptlWindowOrg.x; + + if (wox == -1) + IntMirrorWindowOrg(pdc); + else + pdcattr->ptlWindowOrg.x = wox - pdcattr->ptlWindowOrg.x; + + if (!(pdcattr->flTextAlign & TA_CENTER)) pdcattr->flTextAlign |= TA_RIGHT; + + if (pdc->dclevel.flPath & DCPATH_CLOCKWISE) + pdc->dclevel.flPath &= ~DCPATH_CLOCKWISE; + else + pdc->dclevel.flPath |= DCPATH_CLOCKWISE; + + pdcattr->flXform |= (PAGE_EXTENTS_CHANGED | + INVALIDATE_ATTRIBUTES | + DEVICE_TO_WORLD_INVALID); + +// DC_UpdateXforms(pdc); +} + // NtGdiSetLayout // // The default is left to right. This function changes it to right to left, which @@ -901,53 +941,22 @@ NtGdiSetLayout( IN LONG wox, IN DWORD dwLayout) { - PDC dc; + PDC pdc; PDC_ATTR pdcattr; DWORD oLayout; - dc = DC_LockDc(hdc); - if (!dc) + pdc = DC_LockDc(hdc); + if (!pdc) { SetLastWin32Error(ERROR_INVALID_HANDLE); return GDI_ERROR; } - pdcattr = dc->pdcattr; + pdcattr = pdc->pdcattr; - pdcattr->dwLayout = dwLayout; oLayout = pdcattr->dwLayout; + DC_vSetLayout(pdc, wox, dwLayout); - if (!(dwLayout & LAYOUT_ORIENTATIONMASK)) - { - DC_UnlockDc(dc); - return oLayout; - } - - if (dwLayout & LAYOUT_RTL) - { - pdcattr->iMapMode = MM_ANISOTROPIC; - } - - pdcattr->szlWindowExt.cy = -pdcattr->szlWindowExt.cy; - pdcattr->ptlWindowOrg.x = -pdcattr->ptlWindowOrg.x; - - if (wox == -1) - IntMirrorWindowOrg(dc); - else - pdcattr->ptlWindowOrg.x = wox - pdcattr->ptlWindowOrg.x; - - if (!(pdcattr->flTextAlign & TA_CENTER)) pdcattr->flTextAlign |= TA_RIGHT; - - if (dc->dclevel.flPath & DCPATH_CLOCKWISE) - dc->dclevel.flPath &= ~DCPATH_CLOCKWISE; - else - dc->dclevel.flPath |= DCPATH_CLOCKWISE; - - pdcattr->flXform |= (PAGE_EXTENTS_CHANGED | - INVALIDATE_ATTRIBUTES | - DEVICE_TO_WORLD_INVALID); - -// DC_UpdateXforms(dc); - DC_UnlockDc(dc); + DC_UnlockDc(pdc); return oLayout; } From 2ddee306776f97976205bcd97e45d09fbfc0cdc4 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 23 Aug 2010 03:00:03 +0000 Subject: [PATCH 42/76] [NTOSKRNL] - Rewrite MiFindEmptyAddressRangeDownTree. The old implementation's "most awesome loop" duplicated both the initialization and the interation steps. It was also overcomplicated. The new implementation additionally returns the parent for the following table insertion, so this doesnt need to be done in an extra search. The return value is changed from NTSTATUS to TABLE_SEARCH_RESULT - Modify MiInsertNode to accept a parent and TABLE_SEARCH_RESULT instead of searching for a free location. - Modify MiCreatePebOrTeb to make use of the new features - Handle failed allocation of the PEB/TEB - Fixes a failed assertion that Olaf got - I tested this code quite some time and no problems were found svn path=/trunk/; revision=48606 --- reactos/ntoskrnl/mm/ARM3/miarm.h | 9 +- reactos/ntoskrnl/mm/ARM3/procsup.c | 45 +++---- reactos/ntoskrnl/mm/ARM3/vadnode.c | 186 ++++++++++++----------------- 3 files changed, 110 insertions(+), 130 deletions(-) diff --git a/reactos/ntoskrnl/mm/ARM3/miarm.h b/reactos/ntoskrnl/mm/ARM3/miarm.h index 59aac80d99a..f97ea6962b9 100644 --- a/reactos/ntoskrnl/mm/ARM3/miarm.h +++ b/reactos/ntoskrnl/mm/ARM3/miarm.h @@ -1050,21 +1050,24 @@ MiCheckForConflictingNode( IN PMM_AVL_TABLE Table ); -NTSTATUS +TABLE_SEARCH_RESULT NTAPI MiFindEmptyAddressRangeDownTree( IN SIZE_T Length, IN ULONG_PTR BoundaryAddress, IN ULONG_PTR Alignment, IN PMM_AVL_TABLE Table, - OUT PULONG_PTR Base + OUT PULONG_PTR Base, + OUT PMMADDRESS_NODE *Parent ); VOID NTAPI MiInsertNode( + IN PMM_AVL_TABLE Table, IN PMMADDRESS_NODE NewNode, - IN PMM_AVL_TABLE Table + PMMADDRESS_NODE Parent, + TABLE_SEARCH_RESULT Result ); VOID diff --git a/reactos/ntoskrnl/mm/ARM3/procsup.c b/reactos/ntoskrnl/mm/ARM3/procsup.c index 25df25937df..dd79e2cddc2 100644 --- a/reactos/ntoskrnl/mm/ARM3/procsup.c +++ b/reactos/ntoskrnl/mm/ARM3/procsup.c @@ -55,6 +55,8 @@ MiCreatePebOrTeb(IN PEPROCESS Process, ULONG RandomCoeff; ULONG_PTR StartAddress, EndAddress; LARGE_INTEGER CurrentTime; + TABLE_SEARCH_RESULT Result = TableFoundNode; + PMMADDRESS_NODE Parent; /* Allocate a VAD */ Vad = ExAllocatePoolWithTag(NonPagedPool, sizeof(MMVAD_LONG), 'ldaV'); @@ -93,26 +95,29 @@ MiCreatePebOrTeb(IN PEPROCESS Process, StartAddress -= RandomCoeff; EndAddress = StartAddress + ROUND_TO_PAGES(Size) - 1; - /* See if this VA range can be obtained */ - if (!MiCheckForConflictingNode(StartAddress >> PAGE_SHIFT, - EndAddress >> PAGE_SHIFT, - &Process->VadRoot)) - { - /* No conflict, use this address */ - *Base = StartAddress; - goto AfterFound; - } + /* Try to find something below the random upper margin */ + Result = MiFindEmptyAddressRangeDownTree(ROUND_TO_PAGES(Size), + EndAddress, + PAGE_SIZE, + &Process->VadRoot, + Base, + &Parent); + } + + /* Check for success. TableFoundNode means nothing free. */ + if (Result == TableFoundNode) + { + /* For TEBs, or if a PEB location couldn't be found, scan the VAD root */ + Result = MiFindEmptyAddressRangeDownTree(ROUND_TO_PAGES(Size), + (ULONG_PTR)MM_HIGHEST_VAD_ADDRESS + 1, + PAGE_SIZE, + &Process->VadRoot, + Base, + &Parent); + /* Bail out, if still nothing free was found */ + if (Result == TableFoundNode) return STATUS_NO_MEMORY; } - /* For TEBs, or if a PEB location couldn't be found, scan the VAD root */ - Status = MiFindEmptyAddressRangeDownTree(ROUND_TO_PAGES(Size), - (ULONG_PTR)MM_HIGHEST_VAD_ADDRESS + 1, - PAGE_SIZE, - &Process->VadRoot, - Base); - ASSERT(NT_SUCCESS(Status)); - -AfterFound: /* Validate that it came from the VAD ranges */ ASSERT(*Base >= (ULONG_PTR)MI_LOWEST_VAD_ADDRESS); @@ -132,8 +137,8 @@ AfterFound: /* Insert the VAD */ ASSERT(Vad->EndingVpn >= Vad->StartingVpn); Process->VadRoot.NodeHint = Vad; - MiInsertNode((PVOID)Vad, &Process->VadRoot); - + MiInsertNode(&Process->VadRoot, (PVOID)Vad, Parent, Result); + /* Release the working set */ MiUnlockProcessWorkingSet(Process, Thread); diff --git a/reactos/ntoskrnl/mm/ARM3/vadnode.c b/reactos/ntoskrnl/mm/ARM3/vadnode.c index c6f8be6ff86..b75f2dc6589 100644 --- a/reactos/ntoskrnl/mm/ARM3/vadnode.c +++ b/reactos/ntoskrnl/mm/ARM3/vadnode.c @@ -4,6 +4,7 @@ * FILE: ntoskrnl/mm/ARM3/vadnode.c * PURPOSE: ARM Memory Manager VAD Node Algorithms * PROGRAMMERS: ReactOS Portable Systems Group + * Timo Kreuzer (timo.kreuzer@reactos.org) */ /* INCLUDES *******************************************************************/ @@ -92,19 +93,14 @@ MiCheckForConflictingNode(IN ULONG_PTR StartVpn, VOID NTAPI -MiInsertNode(IN PMMADDRESS_NODE NewNode, - IN PMM_AVL_TABLE Table) +MiInsertNode( + IN PMM_AVL_TABLE Table, + IN PMMADDRESS_NODE NewNode, + PMMADDRESS_NODE Parent, + TABLE_SEARCH_RESULT Result) { - PMMADDRESS_NODE NodeOrParent = NULL; - TABLE_SEARCH_RESULT Result; - - /* Find the node's parent, and where to insert this node */ - Result = RtlpFindAvlTableNodeOrParent(Table, - (PVOID)NewNode->StartingVpn, - &NodeOrParent); - /* Insert it into the tree */ - RtlpInsertAvlTreeNode(Table, NewNode, NodeOrParent, Result); + RtlpInsertAvlTreeNode(Table, NewNode, Parent, Result); } VOID @@ -155,17 +151,18 @@ MiGetPreviousNode(IN PMMADDRESS_NODE Node) return NULL; } -NTSTATUS +TABLE_SEARCH_RESULT NTAPI -MiFindEmptyAddressRangeDownTree(IN SIZE_T Length, - IN ULONG_PTR BoundaryAddress, - IN ULONG_PTR Alignment, - IN PMM_AVL_TABLE Table, - OUT PULONG_PTR Base) +MiFindEmptyAddressRangeDownTree( + IN SIZE_T Length, + IN ULONG_PTR BoundaryAddress, + IN ULONG_PTR Alignment, + IN PMM_AVL_TABLE Table, + OUT PULONG_PTR Base, + OUT PMMADDRESS_NODE *Parent) { - PMMADDRESS_NODE Node, PreviousNode; - ULONG_PTR CandidateAddress, EndAddress; - ULONG AlignEndVpn, CandidateVpn, BoundaryVpn, LowestVpn, StartVpn, EndVpn; + PMMADDRESS_NODE Node, LowestNode, Child; + ULONG LowVpn, HighVpn; PFN_NUMBER PageCount; /* Sanity checks */ @@ -174,107 +171,82 @@ MiFindEmptyAddressRangeDownTree(IN SIZE_T Length, /* Compute page length, make sure the boundary address is valid */ Length = PAGE_ROUND_UP(Length); + PageCount = Length >> PAGE_SHIFT; if ((BoundaryAddress + 1) < Length) return STATUS_NO_MEMORY; - - /* Compute the highest address to start at */ - CandidateAddress = ROUND_UP(BoundaryAddress + 1 - Length, Alignment); /* Check if the table is empty */ - if (!Table->NumberGenericTableElements) + if (Table->NumberGenericTableElements == 0) { /* Tree is empty, the candidate address is already the best one */ - *Base = CandidateAddress; - return STATUS_SUCCESS; + *Base = ROUND_DOWN(BoundaryAddress + 1 - Length, Alignment); + return TableEmptyTree; } - /* Starting from the root, go down until the right-most child */ - Node = RtlRightChildAvl(&Table->BalancedRoot); - while (RtlRightChildAvl(Node)) Node = RtlRightChildAvl(Node); + /* Calculate the initial upper margin */ + HighVpn = BoundaryAddress >> PAGE_SHIFT; - /* Get the aligned ending address of this VPN */ - EndAddress = ROUND_UP((Node->EndingVpn << PAGE_SHIFT) | (PAGE_SIZE - 1), - Alignment); + /* Starting from the root, go down until the right-most child, + trying to stay below the boundary. */ + LowestNode = Node = RtlRightChildAvl(&Table->BalancedRoot); + while ( (Child = RtlRightChildAvl(Node)) && + Child->EndingVpn < HighVpn ) Node = Child; - /* Can we fit the address without overflowing into the node? */ - if ((EndAddress < BoundaryAddress) && - ((BoundaryAddress - EndAddress) > Length)) + /* Now loop the Vad nodes */ + while (Node) + { + /* Keep track of the lowest node */ + LowestNode = Node; + + /* Calculate the lower margin */ + LowVpn = ROUND_UP(Node->EndingVpn + 1, Alignment >> PAGE_SHIFT); + + /* Check if the current bounds are suitable */ + if ((HighVpn > LowVpn) && ((HighVpn - LowVpn) >= PageCount)) + { + /* There is enough space to add our node */ + LowVpn = HighVpn - PageCount; + *Base = LowVpn << PAGE_SHIFT; + + /* Can we use the current node as parent? */ + Child = RtlRightChildAvl(Node); + if (!Child) + { + /* Node has no right child, so use it as parent */ + *Parent = Node; + return TableInsertAsRight; + } + else + { + /* Node has a right child, find most left grand child */ + Node = Child; + while ((Child = RtlLeftChildAvl(Node))) Node = Child; + *Parent = Node; + return TableInsertAsLeft; + } + } + + /* Update the upper margin if neccessary */ + if (Node->StartingVpn < HighVpn) HighVpn = Node->StartingVpn; + + /* Go to the next lower node */ + Node = MiGetPreviousNode(Node); + } + + /* Check if there's enough space before the lowest Vad */ + LowVpn = ROUND_UP((ULONG_PTR)MI_LOWEST_VAD_ADDRESS, Alignment) >> PAGE_SHIFT; + if ((HighVpn > LowVpn) && ((HighVpn - LowVpn) >= PageCount)) { /* There is enough space to add our address */ - *Base = ROUND_UP(BoundaryAddress - Length, Alignment); - return STATUS_SUCCESS; - } - - PageCount = Length >> PAGE_SHIFT; - CandidateVpn = CandidateAddress >> PAGE_SHIFT; - BoundaryVpn = BoundaryAddress >> PAGE_SHIFT; - LowestVpn = (ULONG_PTR)MI_LOWEST_VAD_ADDRESS >> PAGE_SHIFT; - - PreviousNode = MiGetPreviousNode(Node); - - StartVpn = Node->StartingVpn; - EndVpn = PreviousNode ? PreviousNode->EndingVpn : 0; - AlignEndVpn = ROUND_UP(EndVpn + 1, Alignment >> PAGE_SHIFT); - - /* Loop until a gap is found */ - for (PageCount = Length >> PAGE_SHIFT, - CandidateVpn = CandidateAddress >> PAGE_SHIFT, - BoundaryVpn = BoundaryAddress >> PAGE_SHIFT, - LowestVpn = (ULONG_PTR)MI_LOWEST_VAD_ADDRESS >> PAGE_SHIFT, - PreviousNode = MiGetPreviousNode(Node), - StartVpn = Node->StartingVpn, - EndVpn = PreviousNode ? PreviousNode->EndingVpn : 0, - AlignEndVpn = ROUND_UP(EndVpn + 1, Alignment >> PAGE_SHIFT); - PreviousNode; - Node = PreviousNode, - PreviousNode = MiGetPreviousNode(Node), - StartVpn = Node->StartingVpn, - EndVpn = PreviousNode ? PreviousNode->EndingVpn : 0, - AlignEndVpn = ROUND_UP(EndVpn + 1, Alignment >> PAGE_SHIFT)) - { - /* Can we fit the address without overflowing into the node? */ - if ((StartVpn < CandidateVpn) && ((StartVpn - AlignEndVpn) >= PageCount)) - { - /* Check if we can get our candidate address */ - if ((CandidateVpn > EndVpn) && (BoundaryVpn < StartVpn)) - { - /* Use it */ - *Base = CandidateAddress; - return STATUS_SUCCESS; - } - - /* Otherwise, can we fit it by changing the start address? */ - if (StartVpn > AlignEndVpn) - { - /* It'll fit, compute the new base address for that to work */ - *Base = ROUND_UP((StartVpn << PAGE_SHIFT) - Length, Alignment); - return STATUS_SUCCESS; - } - } - - PreviousNode = MiGetPreviousNode(Node); - StartVpn = Node->StartingVpn; - EndVpn = PreviousNode ? PreviousNode->EndingVpn : 0; - AlignEndVpn = ROUND_UP(EndVpn + 1, Alignment >> PAGE_SHIFT); + LowVpn = HighVpn - PageCount; + *Base = LowVpn << PAGE_SHIFT; + *Parent = LowestNode; + return TableInsertAsLeft; } - /* See if we could squeeze into the last descriptor */ - if ((StartVpn > LowestVpn) && ((StartVpn - LowestVpn) >= PageCount)) - { - /* Check if we can try our candidate address */ - if (BoundaryVpn < StartVpn) - { - /* Use it */ - *Base = CandidateAddress; - return STATUS_SUCCESS; - } - - /* Otherwise, change the base address to what's needed to fit in */ - *Base = ROUND_UP((StartVpn << PAGE_SHIFT) - Length, Alignment); - return STATUS_SUCCESS; - } - /* No address space left at all */ - return STATUS_NO_MEMORY; + *Base = 0; + *Parent = NULL; + return TableFoundNode; } /* EOF */ From 0ea1a11d0de47ff551e3e6eae87390a041d655a1 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 23 Aug 2010 21:11:01 +0000 Subject: [PATCH 43/76] - Revert the change from REG_SZ to REG_MULTI_SZ because it turns out that Windows does it this same way (research fail?) svn path=/trunk/; revision=48611 --- reactos/dll/win32/dhcpcsvc/dhcp/dhclient.c | 11 ++--- reactos/dll/win32/iphlpapi/resinfo_reactos.c | 51 ++++++++++++++------ 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/reactos/dll/win32/dhcpcsvc/dhcp/dhclient.c b/reactos/dll/win32/dhcpcsvc/dhcp/dhclient.c index 120fd6c01e9..3b60e1ad95d 100644 --- a/reactos/dll/win32/dhcpcsvc/dhcp/dhclient.c +++ b/reactos/dll/win32/dhcpcsvc/dhcp/dhclient.c @@ -507,25 +507,24 @@ void set_name_servers( PDHCP_ADAPTER Adapter, struct client_lease *new_lease ) { char *nsbuf; int i, addrs = new_lease->options[DHO_DOMAIN_NAME_SERVERS].len / sizeof(ULONG); - int len = 0; - nsbuf = malloc( addrs * sizeof(IP_ADDRESS_STRING) + 1 ); + nsbuf = malloc( addrs * sizeof(IP_ADDRESS_STRING) ); if( nsbuf) { - memset(nsbuf, 0, addrs * sizeof(IP_ADDRESS_STRING) + 1); + nsbuf[0] = 0; for( i = 0; i < addrs; i++ ) { nameserver.len = sizeof(ULONG); memcpy( nameserver.iabuf, new_lease->options[DHO_DOMAIN_NAME_SERVERS].data + (i * sizeof(ULONG)), sizeof(ULONG) ); strcat( nsbuf, piaddr(nameserver) ); - len += strlen(nsbuf) + 1; + if( i != addrs-1 ) strcat( nsbuf, "," ); } DH_DbgPrint(MID_TRACE,("Setting DhcpNameserver: %s\n", nsbuf)); - RegSetValueExA( RegKey, "DhcpNameServer", 0, REG_MULTI_SZ, - (LPBYTE)nsbuf, len + 1 ); + RegSetValueExA( RegKey, "DhcpNameServer", 0, REG_SZ, + (LPBYTE)nsbuf, strlen(nsbuf) + 1 ); free( nsbuf ); } diff --git a/reactos/dll/win32/iphlpapi/resinfo_reactos.c b/reactos/dll/win32/iphlpapi/resinfo_reactos.c index 154170d0836..02bcb3b9129 100644 --- a/reactos/dll/win32/iphlpapi/resinfo_reactos.c +++ b/reactos/dll/win32/iphlpapi/resinfo_reactos.c @@ -122,24 +122,47 @@ static void EnumInterfaces( PVOID Data, EnumInterfacesFunc cb ) { void EnumNameServers( HANDLE RegHandle, PWCHAR Interface, PVOID Data, EnumNameServersFunc cb ) { - PWCHAR *NameServerString = - QueryRegistryValueStringMulti(RegHandle, L"DhcpNameServer"); - DWORD i; + PWCHAR NameServerString = + QueryRegistryValueString(RegHandle, L"DhcpNameServer"); if (!NameServerString) - NameServerString = QueryRegistryValueStringMulti(RegHandle, L"NameServer"); - - if (!NameServerString) return; - - for (i = 0; NameServerString[i]; i++) - { - cb(Interface, NameServerString[i], Data); - - HeapFree(GetProcessHeap(), 0, NameServerString[i]); + NameServerString = QueryRegistryValueString(RegHandle, L"NameServer"); + + if (NameServerString) { + /* Now, count the non-empty comma separated */ + DWORD ch; + DWORD LastNameStart = 0; + for (ch = 0; NameServerString[ch]; ch++) { + if (NameServerString[ch] == ',') { + if (ch - LastNameStart > 0) { /* Skip empty entries */ + PWCHAR NameServer = + malloc(((ch - LastNameStart) + 1) * sizeof(WCHAR)); + if (NameServer) { + memcpy(NameServer,NameServerString + LastNameStart, + (ch - LastNameStart) * sizeof(WCHAR)); + NameServer[ch - LastNameStart] = 0; + cb( Interface, NameServer, Data ); + free(NameServer); + LastNameStart = ch +1; + } + } + LastNameStart = ch + 1; /* The first one after the comma */ + } + } + if (ch - LastNameStart > 0) { /* A last name? */ + PWCHAR NameServer = malloc(((ch - LastNameStart) + 1) * sizeof(WCHAR)); + if (NameServer) { + memcpy(NameServer,NameServerString + LastNameStart, + (ch - LastNameStart) * sizeof(WCHAR)); + NameServer[ch - LastNameStart] = 0; + cb( Interface, NameServer, Data ); + free(NameServer); + } + } + ConsumeRegValueString(NameServerString); } - - HeapFree(GetProcessHeap(), 0, NameServerString); } + static void CreateNameServerListEnumNamesFuncCount( PWCHAR Interface, PWCHAR Server, PVOID _Data ) { From 337a1faad61f51ef2bb918e969f06272d1d3280f Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 24 Aug 2010 05:19:31 +0000 Subject: [PATCH 44/76] [WINGDI.H] Add missing GetCharWidthI, GetTextExtentExPointI, GetTextExtentPointI svn path=/trunk/; revision=48614 --- reactos/include/psdk/wingdi.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/reactos/include/psdk/wingdi.h b/reactos/include/psdk/wingdi.h index 641aeb31684..550ef68c626 100644 --- a/reactos/include/psdk/wingdi.h +++ b/reactos/include/psdk/wingdi.h @@ -3022,6 +3022,7 @@ BOOL WINAPI GetCharWidth32A(HDC,UINT,UINT,LPINT); BOOL WINAPI GetCharWidth32W(HDC,UINT,UINT,LPINT); BOOL WINAPI GetCharWidthA(HDC,UINT,UINT,LPINT); BOOL WINAPI GetCharWidthW(HDC,UINT,UINT,LPINT); +BOOL WINAPI GetCharWidthI(HDC,UINT,UINT,LPWORD,LPINT); BOOL WINAPI GetCharWidthFloatA(HDC,UINT,UINT,PFLOAT); BOOL WINAPI GetCharWidthFloatW(HDC,UINT,UINT,PFLOAT); int WINAPI GetClipBox(HDC,LPRECT); @@ -3097,9 +3098,11 @@ int WINAPI GetTextCharset(HDC); int WINAPI GetTextCharsetInfo(HDC,LPFONTSIGNATURE,DWORD); COLORREF WINAPI GetTextColor(HDC); BOOL WINAPI GetTextExtentExPointA(HDC,LPCSTR,int,int,LPINT,LPINT,LPSIZE); -BOOL WINAPI GetTextExtentExPointW( HDC,LPCWSTR,int,int,LPINT,LPINT,LPSIZE ); +BOOL WINAPI GetTextExtentExPointW(HDC,LPCWSTR,int,int,LPINT,LPINT,LPSIZE); +BOOL WINAPI GetTextExtentExPointI(HDC,LPWORD,int,int,LPINT,LPINT,LPSIZE); BOOL WINAPI GetTextExtentPointA(HDC,LPCSTR,int,LPSIZE); BOOL WINAPI GetTextExtentPointW(HDC,LPCWSTR,int,LPSIZE); +BOOL WINAPI GetTextExtentPointI(HDC,LPWORD,int,LPSIZE); BOOL WINAPI GetTextExtentPoint32A(HDC,LPCSTR,int,LPSIZE); BOOL WINAPI GetTextExtentPoint32W( HDC,LPCWSTR,int,LPSIZE); int WINAPI GetTextFaceA(HDC,int,LPSTR); From fdd4f2b50b3bc44f55c74ec0a30147569e2af202 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 24 Aug 2010 05:20:16 +0000 Subject: [PATCH 45/76] [REGTESTS] Add bugs_regtest. This can be used to create testcases / regression tests for already fixed bugs. I added a first test for bug 3481 svn path=/trunk/; revision=48615 --- rostests/regtests/bugs/bug3481.c | 72 ++++++++++++++++++++++ rostests/regtests/bugs/bugs_regtest.rbuild | 12 ++++ rostests/regtests/bugs/testlist.c | 17 +++++ rostests/regtests/directory.rbuild | 3 + 4 files changed, 104 insertions(+) create mode 100644 rostests/regtests/bugs/bug3481.c create mode 100644 rostests/regtests/bugs/bugs_regtest.rbuild create mode 100644 rostests/regtests/bugs/testlist.c diff --git a/rostests/regtests/bugs/bug3481.c b/rostests/regtests/bugs/bug3481.c new file mode 100644 index 00000000000..4cef4346d57 --- /dev/null +++ b/rostests/regtests/bugs/bug3481.c @@ -0,0 +1,72 @@ +/* + * PROJECT: ReactOS CRT regression tests + * LICENSE: GPL - See COPYING in the top level directory + * FILE: rostests/regtests/crt/time.c + * PURPOSE: Test for bug 3481 + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include + +#define COUNT 26 + +void Test_bug3481() +{ + const char text[COUNT] = "abcdefghijklmnopqrstuvmxyz"; + WORD agi[COUNT]; + INT i, aiWidth1[COUNT], aiWidth2[COUNT]; + BOOL result; + HDC hdc; + SIZE size1, size2; + + /* Create a DC */ + hdc = CreateCompatibleDC(NULL); + + SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT)); + + /* Convert the charcaters into glyph indices */ + result = GetGlyphIndicesA(hdc, text, COUNT, agi, 0); + ok(result != 0, "result=%d, GetLastError()=%ld\n", result, GetLastError()); + + /* Get the size of the string */ + result = GetTextExtentPoint32A(hdc, text, COUNT, &size1); + ok(result != 0, "result=%d, GetLastError()=%ld\n", result, GetLastError()); + + /* Get the size from glyph indices */ + result = GetTextExtentPointI(hdc, agi, COUNT, &size2); + ok(result != 0, "result=%d, GetLastError()=%ld\n", result, GetLastError()); + + /* Compare sizes */ + ok(size1.cx == size2.cx, "Sizes don't match. size1.cx=%ld, size2.cx=%ld\n", size1.cx, size2.cx); + ok(size1.cy == size2.cy, "Sizes don't match. size1.cy=%ld, size2.cy=%ld\n", size1.cy, size2.cy); + + /* Get the size of the string */ + result = GetTextExtentExPointA(hdc, text, COUNT, MAXLONG, NULL, aiWidth1, &size1); + ok(result != 0, "result=%d, GetLastError()=%ld\n", result, GetLastError()); + + /* Get the size from glyph indices */ + result = GetTextExtentExPointI(hdc, agi, COUNT, MAXLONG, NULL, aiWidth2, &size2); + ok(result != 0, "result=%d, GetLastError()=%ld\n", result, GetLastError()); + + /* Compare sizes */ + ok(size1.cx == size2.cx, "Sizes don't match. size1.cx=%ld, size2.cx=%ld\n", size1.cx, size2.cx); + ok(size1.cy == size2.cy, "Sizes don't match. size1.cy=%ld, size2.cy=%ld\n", size1.cy, size2.cy); + + /* Loop all characters */ + for (i = 0; i < COUNT; i++) + { + /* Check if we got identical spacing values */ + ok(aiWidth1[i] == aiWidth2[i], "wrong spacing, i=%d, char:%d, index:%d\n", i, aiWidth1[i], aiWidth2[i]); + } + + /* Cleanup */ + DeleteDC(hdc); +} + +START_TEST(bug3481) +{ + Test_bug3481(); +} + diff --git a/rostests/regtests/bugs/bugs_regtest.rbuild b/rostests/regtests/bugs/bugs_regtest.rbuild new file mode 100644 index 00000000000..a02c69012b2 --- /dev/null +++ b/rostests/regtests/bugs/bugs_regtest.rbuild @@ -0,0 +1,12 @@ + + + + + . + wine + gdi32 + testlist.c + + bug3481.c + + diff --git a/rostests/regtests/bugs/testlist.c b/rostests/regtests/bugs/testlist.c new file mode 100644 index 00000000000..501e5c968f5 --- /dev/null +++ b/rostests/regtests/bugs/testlist.c @@ -0,0 +1,17 @@ +/* Automatically generated file; DO NOT EDIT!! */ + +#define WIN32_LEAN_AND_MEAN +#define __ROS_LONG64__ +#include + +#define STANDALONE +#include "wine/test.h" + +extern void func_bug3481(void); + +const struct test winetest_testlist[] = +{ + { "bug3481", func_bug3481 }, + { 0, 0 } +}; + diff --git a/rostests/regtests/directory.rbuild b/rostests/regtests/directory.rbuild index acbe991bc01..5264d803af9 100644 --- a/rostests/regtests/directory.rbuild +++ b/rostests/regtests/directory.rbuild @@ -7,4 +7,7 @@ + + + From bc064d7ed41d155ce82270d3bab178155413124e Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 24 Aug 2010 05:27:39 +0000 Subject: [PATCH 46/76] Fix copy paste error in file header svn path=/trunk/; revision=48616 --- rostests/regtests/bugs/bug3481.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rostests/regtests/bugs/bug3481.c b/rostests/regtests/bugs/bug3481.c index 4cef4346d57..aae9ed6c5b7 100644 --- a/rostests/regtests/bugs/bug3481.c +++ b/rostests/regtests/bugs/bug3481.c @@ -1,7 +1,7 @@ /* - * PROJECT: ReactOS CRT regression tests + * PROJECT: ReactOS bug regression tests * LICENSE: GPL - See COPYING in the top level directory - * FILE: rostests/regtests/crt/time.c + * FILE: rostests/regtests/bugs/bug3481.c * PURPOSE: Test for bug 3481 * PROGRAMMERS: Timo Kreuzer */ From e3a2103631394965729d208ee8c86610947f4267 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 24 Aug 2010 13:54:10 +0000 Subject: [PATCH 47/76] Convert gdi32api into wine style test svn path=/trunk/; revision=48617 --- rostests/apitests/directory.rbuild | 4 +- rostests/apitests/gdi32/AddFontResource.c | 96 ++++ rostests/apitests/gdi32/AddFontResourceEx.c | 66 +++ rostests/apitests/gdi32/BeginPath.c | 37 ++ .../tests => gdi32}/CreateBitmapIndirect.c | 29 +- rostests/apitests/gdi32/CreateCompatibleDC.c | 72 +++ rostests/apitests/gdi32/CreateFont.c | 38 ++ .../tests => gdi32}/CreateFontIndirect.c | 95 ++-- .../{gdi32api/tests => gdi32}/CreatePen.c | 52 +- rostests/apitests/gdi32/CreateRectRgn.c | 21 + rostests/apitests/gdi32/EngAcquireSemaphore.c | 60 +++ rostests/apitests/gdi32/EngCreateSemaphore.c | 45 ++ rostests/apitests/gdi32/EngDeleteSemaphore.c | 70 +++ rostests/apitests/gdi32/EngReleaseSemaphore.c | 48 ++ rostests/apitests/gdi32/ExtCreatePen.c | 45 ++ rostests/apitests/gdi32/GdiConvertBitmap.c | 26 + rostests/apitests/gdi32/GdiConvertBrush.c | 26 + rostests/apitests/gdi32/GdiConvertDC.c | 26 + rostests/apitests/gdi32/GdiConvertFont.c | 26 + rostests/apitests/gdi32/GdiConvertPalette.c | 26 + rostests/apitests/gdi32/GdiConvertRegion.c | 26 + rostests/apitests/gdi32/GdiDeleteLocalDC.c | 26 + .../apitests/gdi32/GdiGetCharDimensions.c | 47 ++ rostests/apitests/gdi32/GdiGetLocalBrush.c | 26 + rostests/apitests/gdi32/GdiGetLocalDC.c | 26 + rostests/apitests/gdi32/GdiReleaseLocalDC.c | 26 + rostests/apitests/gdi32/GdiSetAttrs.c | 26 + rostests/apitests/gdi32/GetClipRgn.c | 44 ++ rostests/apitests/gdi32/GetCurrentObject.c | 154 ++++++ .../{gdi32api/tests => gdi32}/GetDIBits.c | 30 +- rostests/apitests/gdi32/GetObject.c | 462 ++++++++++++++++++ .../tests => gdi32}/GetStockObject.c | 28 +- .../tests => gdi32}/GetTextExtentExPoint.c | 29 +- .../{gdi32api/tests => gdi32}/GetTextFace.c | 43 +- .../{gdi32api/tests => gdi32}/SelectObject.c | 69 ++- rostests/apitests/gdi32/SetDCPenColor.c | 68 +++ .../{gdi32api/tests => gdi32}/SetMapMode.c | 53 +- .../{gdi32api/tests => gdi32}/SetSysColors.c | 25 +- .../tests => gdi32}/SetWindowExtEx.c | 104 ++-- rostests/apitests/gdi32/SetWorldTransform.c | 51 ++ rostests/apitests/gdi32/gdi32_apitest.rbuild | 53 ++ rostests/apitests/gdi32/testlist.c | 92 ++++ rostests/apitests/gdi32api/Notes.txt | 7 - rostests/apitests/gdi32api/gdi.h | 54 -- rostests/apitests/gdi32api/gdi32api.c | 52 -- rostests/apitests/gdi32api/gdi32api.h | 27 - rostests/apitests/gdi32api/gdi32api.rbuild | 9 - rostests/apitests/gdi32api/testlist.c | 100 ---- .../apitests/gdi32api/tests/AddFontResource.c | 74 --- .../gdi32api/tests/AddFontResourceEx.c | 36 -- rostests/apitests/gdi32api/tests/BeginPath.c | 24 - .../gdi32api/tests/CreateCompatibleDC.c | 53 -- rostests/apitests/gdi32api/tests/CreateFont.c | 22 - .../apitests/gdi32api/tests/CreateRectRgn.c | 8 - .../gdi32api/tests/EngAcquireSemaphore.c | 45 -- .../gdi32api/tests/EngCreateSemaphore.c | 31 -- .../gdi32api/tests/EngDeleteSemaphore.c | 51 -- .../gdi32api/tests/EngReleaseSemaphore.c | 56 --- .../apitests/gdi32api/tests/ExtCreatePen.c | 29 -- .../gdi32api/tests/GdiConvertBitmap.c | 10 - .../apitests/gdi32api/tests/GdiConvertBrush.c | 9 - .../apitests/gdi32api/tests/GdiConvertDC.c | 10 - .../apitests/gdi32api/tests/GdiConvertFont.c | 9 - .../gdi32api/tests/GdiConvertPalette.c | 9 - .../gdi32api/tests/GdiConvertRegion.c | 12 - .../gdi32api/tests/GdiDeleteLocalDC.c | 9 - .../gdi32api/tests/GdiGetCharDimensions.c | 27 - .../gdi32api/tests/GdiGetLocalBrush.c | 11 - .../apitests/gdi32api/tests/GdiGetLocalDC.c | 11 - .../gdi32api/tests/GdiReleaseLocalDC.c | 9 - .../apitests/gdi32api/tests/GdiSetAttrs.c | 9 - rostests/apitests/gdi32api/tests/GetClipRgn.c | 31 -- .../gdi32api/tests/GetCurrentObject.c | 139 ------ rostests/apitests/gdi32api/tests/GetObject.c | 453 ----------------- .../apitests/gdi32api/tests/SetDCPenColor.c | 51 -- .../gdi32api/tests/SetWorldTransform.c | 20 - 76 files changed, 2219 insertions(+), 1704 deletions(-) create mode 100644 rostests/apitests/gdi32/AddFontResource.c create mode 100644 rostests/apitests/gdi32/AddFontResourceEx.c create mode 100644 rostests/apitests/gdi32/BeginPath.c rename rostests/apitests/{gdi32api/tests => gdi32}/CreateBitmapIndirect.c (68%) create mode 100644 rostests/apitests/gdi32/CreateCompatibleDC.c create mode 100644 rostests/apitests/gdi32/CreateFont.c rename rostests/apitests/{gdi32api/tests => gdi32}/CreateFontIndirect.c (64%) rename rostests/apitests/{gdi32api/tests => gdi32}/CreatePen.c (50%) create mode 100644 rostests/apitests/gdi32/CreateRectRgn.c create mode 100644 rostests/apitests/gdi32/EngAcquireSemaphore.c create mode 100644 rostests/apitests/gdi32/EngCreateSemaphore.c create mode 100644 rostests/apitests/gdi32/EngDeleteSemaphore.c create mode 100644 rostests/apitests/gdi32/EngReleaseSemaphore.c create mode 100644 rostests/apitests/gdi32/ExtCreatePen.c create mode 100644 rostests/apitests/gdi32/GdiConvertBitmap.c create mode 100644 rostests/apitests/gdi32/GdiConvertBrush.c create mode 100644 rostests/apitests/gdi32/GdiConvertDC.c create mode 100644 rostests/apitests/gdi32/GdiConvertFont.c create mode 100644 rostests/apitests/gdi32/GdiConvertPalette.c create mode 100644 rostests/apitests/gdi32/GdiConvertRegion.c create mode 100644 rostests/apitests/gdi32/GdiDeleteLocalDC.c create mode 100644 rostests/apitests/gdi32/GdiGetCharDimensions.c create mode 100644 rostests/apitests/gdi32/GdiGetLocalBrush.c create mode 100644 rostests/apitests/gdi32/GdiGetLocalDC.c create mode 100644 rostests/apitests/gdi32/GdiReleaseLocalDC.c create mode 100644 rostests/apitests/gdi32/GdiSetAttrs.c create mode 100644 rostests/apitests/gdi32/GetClipRgn.c create mode 100644 rostests/apitests/gdi32/GetCurrentObject.c rename rostests/apitests/{gdi32api/tests => gdi32}/GetDIBits.c (85%) create mode 100644 rostests/apitests/gdi32/GetObject.c rename rostests/apitests/{gdi32api/tests => gdi32}/GetStockObject.c (82%) rename rostests/apitests/{gdi32api/tests => gdi32}/GetTextExtentExPoint.c (59%) rename rostests/apitests/{gdi32api/tests => gdi32}/GetTextFace.c (51%) rename rostests/apitests/{gdi32api/tests => gdi32}/SelectObject.c (71%) create mode 100644 rostests/apitests/gdi32/SetDCPenColor.c rename rostests/apitests/{gdi32api/tests => gdi32}/SetMapMode.c (83%) rename rostests/apitests/{gdi32api/tests => gdi32}/SetSysColors.c (62%) rename rostests/apitests/{gdi32api/tests => gdi32}/SetWindowExtEx.c (78%) create mode 100644 rostests/apitests/gdi32/SetWorldTransform.c create mode 100644 rostests/apitests/gdi32/gdi32_apitest.rbuild create mode 100644 rostests/apitests/gdi32/testlist.c delete mode 100644 rostests/apitests/gdi32api/Notes.txt delete mode 100644 rostests/apitests/gdi32api/gdi.h delete mode 100644 rostests/apitests/gdi32api/gdi32api.c delete mode 100644 rostests/apitests/gdi32api/gdi32api.h delete mode 100644 rostests/apitests/gdi32api/gdi32api.rbuild delete mode 100644 rostests/apitests/gdi32api/testlist.c delete mode 100644 rostests/apitests/gdi32api/tests/AddFontResource.c delete mode 100644 rostests/apitests/gdi32api/tests/AddFontResourceEx.c delete mode 100644 rostests/apitests/gdi32api/tests/BeginPath.c delete mode 100644 rostests/apitests/gdi32api/tests/CreateCompatibleDC.c delete mode 100644 rostests/apitests/gdi32api/tests/CreateFont.c delete mode 100644 rostests/apitests/gdi32api/tests/CreateRectRgn.c delete mode 100644 rostests/apitests/gdi32api/tests/EngAcquireSemaphore.c delete mode 100644 rostests/apitests/gdi32api/tests/EngCreateSemaphore.c delete mode 100644 rostests/apitests/gdi32api/tests/EngDeleteSemaphore.c delete mode 100644 rostests/apitests/gdi32api/tests/EngReleaseSemaphore.c delete mode 100644 rostests/apitests/gdi32api/tests/ExtCreatePen.c delete mode 100644 rostests/apitests/gdi32api/tests/GdiConvertBitmap.c delete mode 100644 rostests/apitests/gdi32api/tests/GdiConvertBrush.c delete mode 100644 rostests/apitests/gdi32api/tests/GdiConvertDC.c delete mode 100644 rostests/apitests/gdi32api/tests/GdiConvertFont.c delete mode 100644 rostests/apitests/gdi32api/tests/GdiConvertPalette.c delete mode 100644 rostests/apitests/gdi32api/tests/GdiConvertRegion.c delete mode 100644 rostests/apitests/gdi32api/tests/GdiDeleteLocalDC.c delete mode 100644 rostests/apitests/gdi32api/tests/GdiGetCharDimensions.c delete mode 100644 rostests/apitests/gdi32api/tests/GdiGetLocalBrush.c delete mode 100644 rostests/apitests/gdi32api/tests/GdiGetLocalDC.c delete mode 100644 rostests/apitests/gdi32api/tests/GdiReleaseLocalDC.c delete mode 100644 rostests/apitests/gdi32api/tests/GdiSetAttrs.c delete mode 100644 rostests/apitests/gdi32api/tests/GetClipRgn.c delete mode 100644 rostests/apitests/gdi32api/tests/GetCurrentObject.c delete mode 100644 rostests/apitests/gdi32api/tests/GetObject.c delete mode 100644 rostests/apitests/gdi32api/tests/SetDCPenColor.c delete mode 100644 rostests/apitests/gdi32api/tests/SetWorldTransform.c diff --git a/rostests/apitests/directory.rbuild b/rostests/apitests/directory.rbuild index 797394febdf..319878f83d2 100644 --- a/rostests/apitests/directory.rbuild +++ b/rostests/apitests/directory.rbuild @@ -10,8 +10,8 @@ - - + + diff --git a/rostests/apitests/gdi32/AddFontResource.c b/rostests/apitests/gdi32/AddFontResource.c new file mode 100644 index 00000000000..b69f4d69d22 --- /dev/null +++ b/rostests/apitests/gdi32/AddFontResource.c @@ -0,0 +1,96 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for AddFontResource + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include + +#define COUNT 26 + +void Test_AddFontResourceA() +{ + CHAR szFileNameA[MAX_PATH]; + CHAR szFileNameFont1A[MAX_PATH]; + CHAR szFileNameFont2A[MAX_PATH]; + int result; + + GetCurrentDirectoryA(MAX_PATH,szFileNameA); + + memcpy(szFileNameFont1A,szFileNameA,MAX_PATH ); + strcat(szFileNameFont1A, "\\testdata\\test.ttf"); + + memcpy(szFileNameFont2A,szFileNameA,MAX_PATH ); + strcat(szFileNameFont2A, "\\testdata\\test.otf"); + + RtlZeroMemory(szFileNameA,MAX_PATH); + + /* + * Start testing Ansi version + * + */ + + /* Testing NULL pointer */ + SetLastError(ERROR_SUCCESS); + result = AddFontResourceA(NULL); + ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result); + ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError()); + + /* Testing -1 pointer */ + SetLastError(ERROR_SUCCESS); + result = AddFontResourceA((CHAR*)-1); + ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result); + ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError()); + + /* Testing address 1 pointer */ + SetLastError(ERROR_SUCCESS); + result = AddFontResourceA((CHAR*)1); + ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result); + ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError()); + + /* Testing address empty string */ + SetLastError(ERROR_SUCCESS); + result = AddFontResourceA(""); + ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()=%ld\n", GetLastError()); + + /* Testing one ttf font */ + SetLastError(ERROR_SUCCESS); + result = AddFontResourceA(szFileNameFont1A); + ok(result == 1, "AddFontResourceA(\"%s\") failed, result=%d\n", szFileNameFont1A, result); + ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError()); + + /* Testing one otf font */ + SetLastError(ERROR_SUCCESS); + result = AddFontResourceA(szFileNameFont2A); + ok(result == 1, "AddFontResourceA failed, result=%d\n", result); + ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError()); + + /* Testing two fonts */ + SetLastError(ERROR_SUCCESS); + sprintf(szFileNameA,"%s|%s",szFileNameFont1A, szFileNameFont2A); + result = AddFontResourceA(szFileNameA); + ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result); + ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError()); + + SetLastError(ERROR_SUCCESS); + sprintf(szFileNameA,"%s |%s",szFileNameFont1A, szFileNameFont2A); + result = AddFontResourceA(szFileNameA); + ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result); + ok(GetLastError() == ERROR_SUCCESS, "GetLastError()=%ld\n", GetLastError()); + + SetLastError(ERROR_SUCCESS); + sprintf(szFileNameA,"%s | %s",szFileNameFont1A, szFileNameFont2A); + result = AddFontResourceA(szFileNameA); + ok(result == 0, "AddFontResourceA succeeded, result=%d\n", result); + ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError()=%ld\n", GetLastError()); +} + +START_TEST(AddFontResource) +{ + Test_AddFontResourceA(); +} + diff --git a/rostests/apitests/gdi32/AddFontResourceEx.c b/rostests/apitests/gdi32/AddFontResourceEx.c new file mode 100644 index 00000000000..228aa4ccab7 --- /dev/null +++ b/rostests/apitests/gdi32/AddFontResourceEx.c @@ -0,0 +1,66 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for AddFontResourceEx + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include +#include + +void Test_AddFontResourceExW() +{ + WCHAR szFileName[MAX_PATH]; + int result; + + /* Test NULL filename */ + SetLastError(ERROR_SUCCESS); + + /* Windows crashes, need SEH here */ + _SEH2_TRY + { + result = AddFontResourceExW(NULL, 0, 0); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + result = -1; + SetLastError(_SEH2_GetExceptionCode()); + } + _SEH2_END + ok(result == -1, "AddFontResourceExW should throw an exception!, result == %d", result); + ok(GetLastError() == 0xc0000005, "GetLastError()==%lx\n", GetLastError()); + + /* Test "" filename */ + SetLastError(ERROR_SUCCESS); + result = AddFontResourceExW(L"", 0, 0); + ok(result == 0, "AddFontResourceExW(L"", 0, 0) succeeded, result==%d\n", result); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()==%ld\n", GetLastError()); + + GetEnvironmentVariableW(L"systemroot", szFileName, MAX_PATH); + wcscat(szFileName, L"\\Fonts\\cour.ttf"); + + /* Test flags = 0 */ + SetLastError(ERROR_SUCCESS); + result = AddFontResourceExW(szFileName, 0, 0); + ok(result == 1, "AddFontResourceExW(L"", 0, 0) failed, result==%d\n", result); + ok(GetLastError() == ERROR_SUCCESS, "GetLastError()==%ld\n", GetLastError()); + + SetLastError(ERROR_SUCCESS); + result = AddFontResourceExW(szFileName, 256, 0); + ok(result == 0, "AddFontResourceExW(L"", 0, 0) failed, result==%d\n", result); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()==%ld\n", GetLastError()); + + /* Test invalid pointer as last parameter */ + result = AddFontResourceExW(szFileName, 0, (void*)-1); + ok(result != 0, "AddFontResourceExW(L"", 0, 0) failed, result==%d\n", result); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError()==%ld\n", GetLastError()); + +} + +START_TEST(AddFontResourceEx) +{ + Test_AddFontResourceExW(); +} + diff --git a/rostests/apitests/gdi32/BeginPath.c b/rostests/apitests/gdi32/BeginPath.c new file mode 100644 index 00000000000..aba1201b014 --- /dev/null +++ b/rostests/apitests/gdi32/BeginPath.c @@ -0,0 +1,37 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for BeginPath + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include + +void Test_BeginPath() +{ + HDC hdc; + BOOL ret; + + SetLastError(0); + ret = BeginPath(0); + ok(ret == 0, "BeginPath(0) succeeded, ret == %d\n", ret); + ok(GetLastError() == ERROR_INVALID_HANDLE, "GetLastError() == %ld\n", GetLastError()); + + hdc = CreateCompatibleDC(NULL); + + SetLastError(0); + ret = BeginPath(hdc); + ok(ret == 1, "BeginPath(hdc) failed, ret == %d\n", ret); + ok(GetLastError() == 0, "GetLastError() == %ld\n", GetLastError()); + + DeleteDC(hdc); + +} + +START_TEST(BeginPath) +{ + Test_BeginPath(); +} + diff --git a/rostests/apitests/gdi32api/tests/CreateBitmapIndirect.c b/rostests/apitests/gdi32/CreateBitmapIndirect.c similarity index 68% rename from rostests/apitests/gdi32api/tests/CreateBitmapIndirect.c rename to rostests/apitests/gdi32/CreateBitmapIndirect.c index c2d9ea95c4a..24cf5c68411 100644 --- a/rostests/apitests/gdi32api/tests/CreateBitmapIndirect.c +++ b/rostests/apitests/gdi32/CreateBitmapIndirect.c @@ -1,8 +1,15 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for CreateBitmapIndirect + * PROGRAMMERS: Magnus Olsen + */ +#include +#include +#include - -INT -Test_CreateBitmapIndirect(PTESTINFO pti) +void Test_CreateBitmapIndirect() { HBITMAP win_hBmp; BITMAP win_bitmap; @@ -15,7 +22,7 @@ Test_CreateBitmapIndirect(PTESTINFO pti) win_bitmap.bmWidth = 0; win_bitmap.bmWidthBytes = 2; win_hBmp = CreateBitmapIndirect(&win_bitmap); - RTEST(win_hBmp != 0); + ok(win_hBmp != 0, "CreateBitmapIndirect failed\n"); DeleteObject(win_hBmp); @@ -28,7 +35,7 @@ Test_CreateBitmapIndirect(PTESTINFO pti) win_bitmap.bmWidth = 0; win_bitmap.bmWidthBytes = 1; win_hBmp = CreateBitmapIndirect(&win_bitmap); - RTEST(win_hBmp == 0); + ok(win_hBmp == 0, "CreateBitmapIndirect succeeded\n"); RtlZeroMemory(&win_bitmap,sizeof(BITMAP)); win_bitmap.bmBits = 0; @@ -39,7 +46,7 @@ Test_CreateBitmapIndirect(PTESTINFO pti) win_bitmap.bmWidth = 0; win_bitmap.bmWidthBytes = 3; win_hBmp = CreateBitmapIndirect(&win_bitmap); - RTEST(win_hBmp == 0); + ok(win_hBmp == 0, "CreateBitmapIndirect succeeded\n"); RtlZeroMemory(&win_bitmap,sizeof(BITMAP)); win_bitmap.bmBits = 0; @@ -50,9 +57,13 @@ Test_CreateBitmapIndirect(PTESTINFO pti) win_bitmap.bmWidth = 0; win_bitmap.bmWidthBytes = 4; win_hBmp = CreateBitmapIndirect(&win_bitmap); - RTEST(win_hBmp != 0); + ok(win_hBmp != 0, "CreateBitmapIndirect failed\n"); DeleteObject(win_hBmp); - - return APISTATUS_NORMAL; } + +START_TEST(CreateBitmapIndirect) +{ + Test_CreateBitmapIndirect(); +} + diff --git a/rostests/apitests/gdi32/CreateCompatibleDC.c b/rostests/apitests/gdi32/CreateCompatibleDC.c new file mode 100644 index 00000000000..59c66df6493 --- /dev/null +++ b/rostests/apitests/gdi32/CreateCompatibleDC.c @@ -0,0 +1,72 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for CreateCompatibleDC + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include + +void Test_CreateCompatibleDC() +{ + HDC hdcScreen, hOldDC, hdc, hdc2; + HPEN hOldPen; + COLORREF color; + + /* Get screen DC */ + hdcScreen = GetDC(NULL); + + /* Test NULL DC handle */ + SetLastError(ERROR_SUCCESS); + hdc = CreateCompatibleDC(NULL); + ok(hdc != NULL, "CreateCompatibleDC(NULL) failed\n"); + ok(GetLastError() == ERROR_SUCCESS, "GetLastError() == %ld\n", GetLastError()); + if(hdc) DeleteDC(hdc); + + /* Test invalid DC handle */ + SetLastError(ERROR_SUCCESS); + hdc = CreateCompatibleDC((HDC)0x123456); + ok(hdc == NULL, "Expected NULL, got %p\n", hdc); + ok(GetLastError() == ERROR_SUCCESS, "GetLastError() == %ld\n", GetLastError()); + if(hdc) DeleteDC(hdc); + + hdc = CreateCompatibleDC(hdcScreen); + ok(hdc != NULL, "CreateCompatibleDC failed\n"); + + // Test if first selected pen is BLACK_PEN (? or same as screen DC's pen?) + hOldPen = SelectObject(hdc, GetStockObject(DC_PEN)); + ok (hOldPen == GetStockObject(BLACK_PEN), "hOldPen == %p\n", hOldPen); + hOldPen = SelectObject(hdc, GetStockObject(BLACK_PEN)); + ok (hOldPen == GetStockObject(DC_PEN), "hOldPen == %p\n", hOldPen); + + /* Test for the starting Color == RGB(0,0,0) */ + color = SetDCPenColor(hdc, RGB(1,2,3)); + ok(color == RGB(0,0,0), "color == %lx\n", color); + + /* Check for reuse counter */ + hOldDC = hdc; + DeleteDC(hdc); + hdc = CreateCompatibleDC(hdcScreen); + hdc2 = CreateCompatibleDC(hOldDC); + ok(hdc2 == NULL, "Expected NULL, got %p\n", hdc); + if (hdc2 != NULL) DeleteDC(hdc2); + + /* Check map mode */ + hdc = CreateCompatibleDC(hdcScreen); + SetMapMode(hdc, MM_ISOTROPIC); + hdc2 = CreateCompatibleDC(hdc); + ok(GetMapMode(hdc2) == MM_TEXT, "GetMapMode(hdc2)==%d\n", GetMapMode(hdc2)); + + /* cleanup */ + DeleteDC(hdc); + + ReleaseDC(NULL, hdcScreen); +} + +START_TEST(CreateCompatibleDC) +{ + Test_CreateCompatibleDC(); +} + diff --git a/rostests/apitests/gdi32/CreateFont.c b/rostests/apitests/gdi32/CreateFont.c new file mode 100644 index 00000000000..3c77eef52ba --- /dev/null +++ b/rostests/apitests/gdi32/CreateFont.c @@ -0,0 +1,38 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for CreateFont + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include + +#define INVALIDFONT "ThisFontDoesNotExist" + +void Test_CreateFontA() +{ + HFONT hFont; + LOGFONTA logfonta; + INT result; + + /* Test invalid font name */ + hFont = CreateFontA(15, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, + DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, + DEFAULT_QUALITY, DEFAULT_PITCH, INVALIDFONT); + ok(hFont != 0, "CreateFontA failed\n"); + + result = GetObjectA(hFont, sizeof(LOGFONTA), &logfonta); + ok(result == sizeof(LOGFONTA), "result = %d", result); + + ok(memcmp(logfonta.lfFaceName, INVALIDFONT, strlen(INVALIDFONT)) == 0, "not equal\n"); + ok(logfonta.lfWeight == FW_DONTCARE, "lfWeight=%ld\n", logfonta.lfWeight); + +} + +START_TEST(CreateFont) +{ + Test_CreateFontA(); +} + diff --git a/rostests/apitests/gdi32api/tests/CreateFontIndirect.c b/rostests/apitests/gdi32/CreateFontIndirect.c similarity index 64% rename from rostests/apitests/gdi32api/tests/CreateFontIndirect.c rename to rostests/apitests/gdi32/CreateFontIndirect.c index 0202c3c703d..cac0a933567 100644 --- a/rostests/apitests/gdi32api/tests/CreateFontIndirect.c +++ b/rostests/apitests/gdi32/CreateFontIndirect.c @@ -1,6 +1,17 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for CreateFontIndirect + * PROGRAMMERS: Timo Kreuzer + */ -INT -Test_CreateFontIndirectA(PTESTINFO pti) +#include +#include +#include + + +void +Test_CreateFontIndirectA(void) { LOGFONTA logfont; HFONT hFont; @@ -22,19 +33,17 @@ Test_CreateFontIndirectA(PTESTINFO pti) logfont.lfPitchAndFamily = DEFAULT_PITCH; memset(logfont.lfFaceName, 'A', LF_FACESIZE); hFont = CreateFontIndirectA(&logfont); - TEST(hFont != 0); + ok(hFont != 0, "CreateFontIndirectA failed\n"); memset(&elfedv2, 0, sizeof(elfedv2)); ret = GetObjectW(hFont, sizeof(elfedv2), &elfedv2); - TEST(ret == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD)); - TEST(elfedv2.elfEnumLogfontEx.elfLogFont.lfFaceName[LF_FACESIZE-1] == 0); - TEST(elfedv2.elfEnumLogfontEx.elfFullName[0] == 0); - - return APISTATUS_NORMAL; + ok(ret == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "ret = %ld\n", ret); + ok(elfedv2.elfEnumLogfontEx.elfLogFont.lfFaceName[LF_FACESIZE-1] == 0, "\n"); + ok(elfedv2.elfEnumLogfontEx.elfFullName[0] == 0, "\n"); } -INT -Test_CreateFontIndirectW(PTESTINFO pti) +void +Test_CreateFontIndirectW(void) { LOGFONTW logfont; HFONT hFont; @@ -56,20 +65,18 @@ Test_CreateFontIndirectW(PTESTINFO pti) logfont.lfPitchAndFamily = DEFAULT_PITCH; memset(logfont.lfFaceName, 'A', LF_FACESIZE * 2); hFont = CreateFontIndirectW(&logfont); - TEST(hFont != 0); + ok(hFont != 0, "CreateFontIndirectW failed\n"); memset(&elfedv2, 0, sizeof(elfedv2)); ret = GetObjectW(hFont, sizeof(elfedv2), &elfedv2); - TEST(ret == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD)); - TEST(elfedv2.elfEnumLogfontEx.elfLogFont.lfFaceName[LF_FACESIZE-1] == ((WCHAR)'A' << 8) + 'A'); - TEST(elfedv2.elfEnumLogfontEx.elfFullName[0] == 0); + ok(ret == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); + ok(elfedv2.elfEnumLogfontEx.elfLogFont.lfFaceName[LF_FACESIZE-1] == ((WCHAR)'A' << 8) + 'A', "\n"); + ok(elfedv2.elfEnumLogfontEx.elfFullName[0] == 0, "\n"); /* Theres a bunch of data in elfFullName ... */ - - return APISTATUS_NORMAL; } -INT -Test_CreateFontIndirectExA(PTESTINFO pti) +void +Test_CreateFontIndirectExA(void) { ENUMLOGFONTEXDVA elfedva, elfedva2; ENUMLOGFONTEXDVW elfedvw; @@ -100,24 +107,22 @@ Test_CreateFontIndirectExA(PTESTINFO pti) memset(penumlfa->elfFullName, 'B', LF_FULLFACESIZE * sizeof(WCHAR)); hFont = CreateFontIndirectExA(&elfedva); - TEST(hFont != 0); + ok(hFont != 0, "CreateFontIndirectExA failed\n"); ret = GetObjectW(hFont, sizeof(elfedvw), &elfedvw); - TEST(ret == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD)); - TEST(elfedvw.elfEnumLogfontEx.elfLogFont.lfFaceName[LF_FACESIZE-1] == 0); - TEST(elfedvw.elfEnumLogfontEx.elfFullName[LF_FULLFACESIZE-1] == 0); + ok(ret == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); + ok(elfedvw.elfEnumLogfontEx.elfLogFont.lfFaceName[LF_FACESIZE-1] == 0, "\n"); + ok(elfedvw.elfEnumLogfontEx.elfFullName[LF_FULLFACESIZE-1] == 0, "\n"); memset(&elfedva2, 0, sizeof(elfedva2)); ret = GetObjectA(hFont, sizeof(elfedva2), &elfedva2); - TEST(ret == sizeof(ENUMLOGFONTEXDVA)); - TEST(elfedva2.elfEnumLogfontEx.elfLogFont.lfFaceName[LF_FACESIZE-1] == 0); - TEST(elfedva2.elfEnumLogfontEx.elfFullName[LF_FULLFACESIZE-1] == 0); - - return APISTATUS_NORMAL; + ok(ret == sizeof(ENUMLOGFONTEXDVA), "ret = %ld\n", ret); + ok(elfedva2.elfEnumLogfontEx.elfLogFont.lfFaceName[LF_FACESIZE-1] == 0, "\n"); + ok(elfedva2.elfEnumLogfontEx.elfFullName[LF_FULLFACESIZE-1] == 0, "\n"); } -INT -Test_CreateFontIndirectExW(PTESTINFO pti) +void +Test_CreateFontIndirectExW(void) { ENUMLOGFONTEXDVW elfedv, elfedv2; ENUMLOGFONTEXDVA elfedva; @@ -148,33 +153,27 @@ Test_CreateFontIndirectExW(PTESTINFO pti) memset(penumlfw->elfFullName, 'B', LF_FULLFACESIZE * sizeof(WCHAR)); hFont = CreateFontIndirectExW(&elfedv); - TEST(hFont != 0); + ok(hFont != 0, "CreateFontIndirectExW failed\n"); memset(&elfedv2, 0, sizeof(elfedv2)); ret = GetObjectW(hFont, sizeof(elfedv2), &elfedv2); - TEST(ret == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD)); - TEST(elfedv2.elfEnumLogfontEx.elfLogFont.lfFaceName[LF_FACESIZE-1] == ((WCHAR)'A' << 8) + 'A'); - TEST(elfedv2.elfEnumLogfontEx.elfFullName[LF_FULLFACESIZE-1] == ((WCHAR)'B' << 8) + 'B'); + ok(ret == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); + ok(elfedv2.elfEnumLogfontEx.elfLogFont.lfFaceName[LF_FACESIZE-1] == ((WCHAR)'A' << 8) + 'A', "\n"); + ok(elfedv2.elfEnumLogfontEx.elfFullName[LF_FULLFACESIZE-1] == ((WCHAR)'B' << 8) + 'B', "\n"); memset(&elfedva, 0, sizeof(elfedva)); ret = GetObjectA(hFont, sizeof(elfedva), &elfedva); - TEST(ret == sizeof(ENUMLOGFONTEXDVA)); - TEST(elfedva.elfEnumLogfontEx.elfLogFont.lfFaceName[LF_FACESIZE-1] == '?'); - TEST(elfedva.elfEnumLogfontEx.elfFullName[LF_FULLFACESIZE-1] == 0); - - return APISTATUS_NORMAL; + ok(ret == sizeof(ENUMLOGFONTEXDVA), "\n"); + ok(elfedva.elfEnumLogfontEx.elfLogFont.lfFaceName[LF_FACESIZE-1] == '?', "\n"); + ok(elfedva.elfEnumLogfontEx.elfFullName[LF_FULLFACESIZE-1] == 0, "\n"); } -INT -Test_CreateFontIndirect(PTESTINFO pti) +START_TEST(CreateFontIndirect) { - - Test_CreateFontIndirectA(pti); - Test_CreateFontIndirectW(pti); - Test_CreateFontIndirectExA(pti); - Test_CreateFontIndirectExW(pti); - - - return APISTATUS_NORMAL; + Test_CreateFontIndirectA(); + Test_CreateFontIndirectW(); + Test_CreateFontIndirectExA(); + Test_CreateFontIndirectExW(); } + diff --git a/rostests/apitests/gdi32api/tests/CreatePen.c b/rostests/apitests/gdi32/CreatePen.c similarity index 50% rename from rostests/apitests/gdi32api/tests/CreatePen.c rename to rostests/apitests/gdi32/CreatePen.c index bb1cc4476fa..d45d17194be 100644 --- a/rostests/apitests/gdi32api/tests/CreatePen.c +++ b/rostests/apitests/gdi32/CreatePen.c @@ -1,56 +1,72 @@ -INT -Test_CreatePen(PTESTINFO pti) +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for CreatePen + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include +#include +#include +#include + +void Test_CreatePen() { HPEN hPen; LOGPEN logpen; SetLastError(ERROR_SUCCESS); hPen = CreatePen(PS_DASHDOT, 5, RGB(1,2,3)); - RTEST(hPen); + ok(hPen != 0, "\n"); /* Test if we have a PEN */ - RTEST(GDI_HANDLE_GET_TYPE(hPen) == GDI_OBJECT_TYPE_PEN); + ok(GDI_HANDLE_GET_TYPE(hPen) == GDI_OBJECT_TYPE_PEN, "\n"); GetObject(hPen, sizeof(logpen), &logpen); - RTEST(logpen.lopnStyle == PS_DASHDOT); - RTEST(logpen.lopnWidth.x == 5); - RTEST(logpen.lopnColor == RGB(1,2,3)); + ok(logpen.lopnStyle == PS_DASHDOT, "\n"); + ok(logpen.lopnWidth.x == 5, "\n"); + ok(logpen.lopnColor == RGB(1,2,3), "\n"); DeleteObject(hPen); /* PS_GEOMETRIC | PS_DASHDOT = 0x00001011 will become PS_SOLID */ logpen.lopnStyle = 22; hPen = CreatePen(PS_GEOMETRIC | PS_DASHDOT, 5, RGB(1,2,3)); - RTEST(hPen); + ok(hPen != 0, "\n"); GetObject(hPen, sizeof(logpen), &logpen); - RTEST(logpen.lopnStyle == PS_SOLID); + ok(logpen.lopnStyle == PS_SOLID, "\n"); DeleteObject(hPen); /* PS_USERSTYLE will become PS_SOLID */ logpen.lopnStyle = 22; hPen = CreatePen(PS_USERSTYLE, 5, RGB(1,2,3)); - RTEST(hPen); + ok(hPen != 0, "\n"); GetObject(hPen, sizeof(logpen), &logpen); - RTEST(logpen.lopnStyle == PS_SOLID); + ok(logpen.lopnStyle == PS_SOLID, "\n"); DeleteObject(hPen); /* PS_ALTERNATE will become PS_SOLID */ logpen.lopnStyle = 22; hPen = CreatePen(PS_ALTERNATE, 5, RGB(1,2,3)); - RTEST(hPen); + ok(hPen != 0, "\n"); GetObject(hPen, sizeof(logpen), &logpen); - RTEST(logpen.lopnStyle == PS_SOLID); + ok(logpen.lopnStyle == PS_SOLID, "\n"); DeleteObject(hPen); /* PS_INSIDEFRAME is ok */ logpen.lopnStyle = 22; hPen = CreatePen(PS_INSIDEFRAME, 5, RGB(1,2,3)); - RTEST(hPen); + ok(hPen != 0, "\n"); GetObject(hPen, sizeof(logpen), &logpen); - RTEST(logpen.lopnStyle == PS_INSIDEFRAME); + ok(logpen.lopnStyle == PS_INSIDEFRAME, "\n"); DeleteObject(hPen); - RTEST(GetLastError() == ERROR_SUCCESS); - - return APISTATUS_NORMAL; + ok(GetLastError() == ERROR_SUCCESS, "\n"); +} + +START_TEST(CreatePen) +{ + Test_CreatePen(); } diff --git a/rostests/apitests/gdi32/CreateRectRgn.c b/rostests/apitests/gdi32/CreateRectRgn.c new file mode 100644 index 00000000000..3f5c70b80f1 --- /dev/null +++ b/rostests/apitests/gdi32/CreateRectRgn.c @@ -0,0 +1,21 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for CreateRectRgn + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include + +void Test_CreateRectRgn() +{ + +} + +START_TEST(CreateRectRgn) +{ + Test_CreateRectRgn(); +} + diff --git a/rostests/apitests/gdi32/EngAcquireSemaphore.c b/rostests/apitests/gdi32/EngAcquireSemaphore.c new file mode 100644 index 00000000000..9dea204121a --- /dev/null +++ b/rostests/apitests/gdi32/EngAcquireSemaphore.c @@ -0,0 +1,60 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for EngAcquireSemaphore + * PROGRAMMERS: Magnus Olsen + */ + +#include +#include +#include +#include + +void Test_EngAcquireSemaphore() +{ + HSEMAPHORE hsem; + PRTL_CRITICAL_SECTION lpcrit; + + hsem = EngCreateSemaphore(); + ok(hsem != NULL, "EngCreateSemaphore failed\n"); + if (!hsem) return; + lpcrit = (PRTL_CRITICAL_SECTION)hsem; + + /* real data test */ + EngAcquireSemaphore(hsem); +// ok(lpcrit->LockCount == -2); doesn't work on XP + ok(lpcrit->RecursionCount == 1, "lpcrit->RecursionCount=%ld\n", lpcrit->RecursionCount); + ok(lpcrit->OwningThread != 0, "lpcrit->OwningThread=%p\n", lpcrit->OwningThread); + ok(lpcrit->LockSemaphore == 0, "lpcrit->LockSemaphore=%p\n", lpcrit->LockSemaphore); + ok(lpcrit->SpinCount == 0, "lpcrit->SpinCount=%ld\n", lpcrit->SpinCount); + + ok(lpcrit->DebugInfo != NULL, "no DebugInfo\n"); + if (lpcrit->DebugInfo) + { + ok(lpcrit->DebugInfo->Type == 0, "DebugInfo->Type=%d\n", lpcrit->DebugInfo->Type); + ok(lpcrit->DebugInfo->CreatorBackTraceIndex == 0, "DebugInfo->CreatorBackTraceIndex=%d\n", lpcrit->DebugInfo->CreatorBackTraceIndex); + ok(lpcrit->DebugInfo->EntryCount == 0, "DebugInfo->EntryCount=%ld\n", lpcrit->DebugInfo->EntryCount); + ok(lpcrit->DebugInfo->ContentionCount == 0, "DebugInfo->ContentionCount=%ld\n", lpcrit->DebugInfo->ContentionCount); + } + + EngReleaseSemaphore(hsem); + EngDeleteSemaphore(hsem); + + /* NULL pointer test */ + // Note NULL pointer test crash in Vista */ + // EngAcquireSemaphore(NULL); + + /* negtive pointer test */ + // Note negtive pointer test crash in Vista */ + // EngAcquireSemaphore((HSEMAPHORE)-1); + + /* try with deleted Semaphore */ + // Note deleted Semaphore pointer test does freze the whole program in Vista */ + // EngAcquireSemaphore(hsem); +} + +START_TEST(EngAcquireSemaphore) +{ + Test_EngAcquireSemaphore(); +} + diff --git a/rostests/apitests/gdi32/EngCreateSemaphore.c b/rostests/apitests/gdi32/EngCreateSemaphore.c new file mode 100644 index 00000000000..478ed9161fe --- /dev/null +++ b/rostests/apitests/gdi32/EngCreateSemaphore.c @@ -0,0 +1,45 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for EngCreateSemaphore + * PROGRAMMERS: Magnus Olsen + */ + +#include +#include +#include +#include + +void Test_EngCreateSemaphore() +{ + HSEMAPHORE hsem; + PRTL_CRITICAL_SECTION lpcrit; + + hsem = EngCreateSemaphore(); + ok(hsem != NULL, "EngCreateSemaphore failed\n"); + if (!hsem) return; + lpcrit = (PRTL_CRITICAL_SECTION)hsem; + + ok(lpcrit->LockCount == -1, "lpcrit->LockCount=%ld\n", lpcrit->LockCount); + ok(lpcrit->RecursionCount == 0, "lpcrit->RecursionCount=%ld\n", lpcrit->RecursionCount); + ok(lpcrit->OwningThread == 0, "lpcrit->OwningThread=%p\n", lpcrit->OwningThread); + ok(lpcrit->LockSemaphore == 0, "lpcrit->LockSemaphore=%p\n", lpcrit->LockSemaphore); + ok(lpcrit->SpinCount == 0, "lpcrit->SpinCount=%ld\n", lpcrit->SpinCount); + + ok(lpcrit->DebugInfo != NULL, "no DebugInfo\n"); + if (lpcrit->DebugInfo) + { + ok(lpcrit->DebugInfo->Type == 0, "DebugInfo->Type=%d\n", lpcrit->DebugInfo->Type); + ok(lpcrit->DebugInfo->CreatorBackTraceIndex == 0, "DebugInfo->CreatorBackTraceIndex=%d\n", lpcrit->DebugInfo->CreatorBackTraceIndex); + ok(lpcrit->DebugInfo->EntryCount == 0, "DebugInfo->EntryCount=%ld\n", lpcrit->DebugInfo->EntryCount); + ok(lpcrit->DebugInfo->ContentionCount == 0, "DebugInfo->ContentionCount=%ld\n", lpcrit->DebugInfo->ContentionCount); + } + + EngDeleteSemaphore(hsem); +} + +START_TEST(EngCreateSemaphore) +{ + Test_EngCreateSemaphore(); +} + diff --git a/rostests/apitests/gdi32/EngDeleteSemaphore.c b/rostests/apitests/gdi32/EngDeleteSemaphore.c new file mode 100644 index 00000000000..e2cb40911d8 --- /dev/null +++ b/rostests/apitests/gdi32/EngDeleteSemaphore.c @@ -0,0 +1,70 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for EngDeleteSemaphore + * PROGRAMMERS: Magnus Olsen + */ + +#include +#include +#include +#include + +void Test_EngDeleteSemaphore() +{ + HSEMAPHORE hsem; + PRTL_CRITICAL_SECTION lpcrit; + + /* test Create then delete */ + hsem = EngCreateSemaphore(); + ok(hsem != NULL, "EngCreateSemaphore failed\n"); + if (!hsem) return; + lpcrit = (PRTL_CRITICAL_SECTION)hsem; + EngDeleteSemaphore(hsem); + +// ok(lpcrit->LockCount > 0); doesn't work on XP + ok(lpcrit->RecursionCount == 0, "lpcrit->RecursionCount=%ld\n", lpcrit->RecursionCount); + ok(lpcrit->OwningThread == 0, "lpcrit->OwningThread=%p\n", lpcrit->OwningThread); + ok(lpcrit->LockSemaphore == 0, "lpcrit->LockSemaphore=%p\n", lpcrit->LockSemaphore); + ok(lpcrit->SpinCount == 0, "lpcrit->SpinCount=%ld\n", lpcrit->SpinCount); + + //ok(lpcrit->DebugInfo != NULL, "no DebugInfo\n"); + if (lpcrit->DebugInfo) + { + ok(lpcrit->DebugInfo->Type != 0, "DebugInfo->Type=%d\n", lpcrit->DebugInfo->Type); + ok(lpcrit->DebugInfo->CreatorBackTraceIndex != 0, "DebugInfo->CreatorBackTraceIndex=%d\n", lpcrit->DebugInfo->CreatorBackTraceIndex); + ok(lpcrit->DebugInfo->EntryCount != 0, "DebugInfo->EntryCount=%ld\n", lpcrit->DebugInfo->EntryCount); + ok(lpcrit->DebugInfo->ContentionCount != 0, "DebugInfo->ContentionCount=%ld\n", lpcrit->DebugInfo->ContentionCount); + } + + /* test EngAcquireSemaphore and release it, then delete it */ + hsem = EngCreateSemaphore(); + ok(hsem != NULL, "EngCreateSemaphore failed\n"); + if (!hsem) return; + lpcrit = (PRTL_CRITICAL_SECTION)hsem; + + EngAcquireSemaphore(hsem); + EngReleaseSemaphore(hsem); + EngDeleteSemaphore(hsem); + + //ok(lpcrit->LockCount > 0, "lpcrit->LockCount=%ld\n", lpcrit->LockCount); + ok(lpcrit->RecursionCount == 0, "lpcrit->RecursionCount=%ld\n", lpcrit->RecursionCount); + ok(lpcrit->OwningThread == 0, "lpcrit->OwningThread=%p\n", lpcrit->OwningThread); + ok(lpcrit->LockSemaphore == 0, "lpcrit->LockSemaphore=%p\n", lpcrit->LockSemaphore); + ok(lpcrit->SpinCount == 0, "lpcrit->SpinCount=%ld\n", lpcrit->SpinCount); + + //ok(lpcrit->DebugInfo != NULL, "no DebugInfo\n"); + if (lpcrit->DebugInfo) + { + ok(lpcrit->DebugInfo->Type != 0, "DebugInfo->Type=%d\n", lpcrit->DebugInfo->Type); + ok(lpcrit->DebugInfo->CreatorBackTraceIndex != 0, "DebugInfo->CreatorBackTraceIndex=%d\n", lpcrit->DebugInfo->CreatorBackTraceIndex); + ok(lpcrit->DebugInfo->EntryCount != 0, "DebugInfo->EntryCount=%ld\n", lpcrit->DebugInfo->EntryCount); + ok(lpcrit->DebugInfo->ContentionCount != 0, "DebugInfo->ContentionCount=%ld\n", lpcrit->DebugInfo->ContentionCount); + } +} + +START_TEST(EngDeleteSemaphore) +{ + Test_EngDeleteSemaphore(); +} + diff --git a/rostests/apitests/gdi32/EngReleaseSemaphore.c b/rostests/apitests/gdi32/EngReleaseSemaphore.c new file mode 100644 index 00000000000..9efdc60816a --- /dev/null +++ b/rostests/apitests/gdi32/EngReleaseSemaphore.c @@ -0,0 +1,48 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for EngReleaseSemaphore + * PROGRAMMERS: Magnus Olsen + */ + +#include +#include +#include +#include + +void Test_EngReleaseSemaphore() +{ + HSEMAPHORE hsem; + PRTL_CRITICAL_SECTION lpcrit; + + hsem = EngCreateSemaphore(); + ok(hsem != NULL, "EngCreateSemaphore failed\n"); + if (!hsem) return; + lpcrit = (PRTL_CRITICAL_SECTION)hsem; + + EngAcquireSemaphore(hsem); + EngReleaseSemaphore(hsem); + + ok(lpcrit->LockCount != 0, "lpcrit->LockCount=%ld\n", lpcrit->LockCount); + ok(lpcrit->RecursionCount == 0, "lpcrit->RecursionCount=%ld\n", lpcrit->RecursionCount); + ok(lpcrit->OwningThread == 0, "lpcrit->OwningThread=%p\n", lpcrit->OwningThread); + ok(lpcrit->LockSemaphore == 0, "lpcrit->LockSemaphore=%p\n", lpcrit->LockSemaphore); + ok(lpcrit->SpinCount == 0, "lpcrit->SpinCount=%ld\n", lpcrit->SpinCount); + + ok(lpcrit->DebugInfo != NULL, "no DebugInfo\n"); + if (lpcrit->DebugInfo) + { + ok(lpcrit->DebugInfo->Type == 0, "DebugInfo->Type=%d\n", lpcrit->DebugInfo->Type); + ok(lpcrit->DebugInfo->CreatorBackTraceIndex == 0, "DebugInfo->CreatorBackTraceIndex=%d\n", lpcrit->DebugInfo->CreatorBackTraceIndex); + ok(lpcrit->DebugInfo->EntryCount == 0, "DebugInfo->EntryCount=%ld\n", lpcrit->DebugInfo->EntryCount); + ok(lpcrit->DebugInfo->ContentionCount == 0, "DebugInfo->ContentionCount=%ld\n", lpcrit->DebugInfo->ContentionCount); + } + + EngDeleteSemaphore(hsem); +} + +START_TEST(EngReleaseSemaphore) +{ + Test_EngReleaseSemaphore(); +} + diff --git a/rostests/apitests/gdi32/ExtCreatePen.c b/rostests/apitests/gdi32/ExtCreatePen.c new file mode 100644 index 00000000000..bb4be4962fe --- /dev/null +++ b/rostests/apitests/gdi32/ExtCreatePen.c @@ -0,0 +1,45 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for ExtCreatePen + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include +#include +#include +#include + +void Test_ExtCreatePen() +{ + HPEN hPen; + LOGBRUSH logbrush; + DWORD dwStyles[17] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17}; + + logbrush.lbStyle = BS_SOLID; + logbrush.lbColor = RGB(1,2,3); + logbrush.lbHatch = 0; + hPen = ExtCreatePen(PS_COSMETIC, 1,&logbrush, 0, 0); + ok(hPen != 0, "ExtCreatePen failed\n"); + if (!hPen) return; + + /* Test if we have an EXTPEN */ + ok(GDI_HANDLE_GET_TYPE(hPen) == GDI_OBJECT_TYPE_EXTPEN, "hPen=%p\n", hPen); + DeleteObject(hPen); + + /* test userstyles */ + hPen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE, 5, &logbrush, 17, (CONST DWORD*)&dwStyles); + ok(hPen == 0, "\n"); + hPen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE, 5, &logbrush, 16, (CONST DWORD*)&dwStyles); + ok(hPen != 0, "\n"); + + DeleteObject(hPen); +} + +START_TEST(ExtCreatePen) +{ + Test_ExtCreatePen(); +} + diff --git a/rostests/apitests/gdi32/GdiConvertBitmap.c b/rostests/apitests/gdi32/GdiConvertBitmap.c new file mode 100644 index 00000000000..7799485b943 --- /dev/null +++ b/rostests/apitests/gdi32/GdiConvertBitmap.c @@ -0,0 +1,26 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for GdiConvertBitmap + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include + +HBITMAP WINAPI GdiConvertBitmap(HBITMAP hbm); + +void Test_GdiConvertBitmap() +{ + ok(GdiConvertBitmap((HBITMAP)-1) == (HBITMAP)-1, "\n"); + ok(GdiConvertBitmap((HBITMAP)0) == (HBITMAP)0, "\n"); + ok(GdiConvertBitmap((HBITMAP)1) == (HBITMAP)1, "\n"); + ok(GdiConvertBitmap((HBITMAP)2) == (HBITMAP)2, "\n"); +} + +START_TEST(GdiConvertBitmap) +{ + Test_GdiConvertBitmap(); +} + diff --git a/rostests/apitests/gdi32/GdiConvertBrush.c b/rostests/apitests/gdi32/GdiConvertBrush.c new file mode 100644 index 00000000000..259fe93d9eb --- /dev/null +++ b/rostests/apitests/gdi32/GdiConvertBrush.c @@ -0,0 +1,26 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for GdiConvertBrush + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include + +HBRUSH WINAPI GdiConvertBrush(HBRUSH hbr); + +void Test_GdiConvertBrush() +{ + ok(GdiConvertBrush((HBRUSH)-1) == (HBRUSH)-1, "\n"); + ok(GdiConvertBrush((HBRUSH)0) == (HBRUSH)0, "\n"); + ok(GdiConvertBrush((HBRUSH)1) == (HBRUSH)1, "\n"); + ok(GdiConvertBrush((HBRUSH)2) == (HBRUSH)2, "\n"); +} + +START_TEST(GdiConvertBrush) +{ + Test_GdiConvertBrush(); +} + diff --git a/rostests/apitests/gdi32/GdiConvertDC.c b/rostests/apitests/gdi32/GdiConvertDC.c new file mode 100644 index 00000000000..e6b2d545492 --- /dev/null +++ b/rostests/apitests/gdi32/GdiConvertDC.c @@ -0,0 +1,26 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for GdiConvertDC + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include + +HDC WINAPI GdiConvertDC(HDC hdc); + +void Test_GdiConvertDC() +{ + ok(GdiConvertDC((HDC)-1) == (HDC)-1, "\n"); + ok(GdiConvertDC((HDC)0) == (HDC)0, "\n"); + ok(GdiConvertDC((HDC)1) == (HDC)1, "\n"); + ok(GdiConvertDC((HDC)2) == (HDC)2, "\n"); +} + +START_TEST(GdiConvertDC) +{ + Test_GdiConvertDC(); +} + diff --git a/rostests/apitests/gdi32/GdiConvertFont.c b/rostests/apitests/gdi32/GdiConvertFont.c new file mode 100644 index 00000000000..0e20dd345f0 --- /dev/null +++ b/rostests/apitests/gdi32/GdiConvertFont.c @@ -0,0 +1,26 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for GdiConvertFont + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include + +HFONT WINAPI GdiConvertFont(HFONT); + +void Test_GdiConvertFont() +{ + ok(GdiConvertFont((HFONT)-1) == (HFONT)-1, "\n"); + ok(GdiConvertFont((HFONT)0) == (HFONT)0, "\n"); + ok(GdiConvertFont((HFONT)1) == (HFONT)1, "\n"); + ok(GdiConvertFont((HFONT)2) == (HFONT)2, "\n"); +} + +START_TEST(GdiConvertFont) +{ + Test_GdiConvertFont(); +} + diff --git a/rostests/apitests/gdi32/GdiConvertPalette.c b/rostests/apitests/gdi32/GdiConvertPalette.c new file mode 100644 index 00000000000..b98eff89bd9 --- /dev/null +++ b/rostests/apitests/gdi32/GdiConvertPalette.c @@ -0,0 +1,26 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for GdiConvertPalette + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include + +HPALETTE WINAPI GdiConvertPalette(HPALETTE); + +void Test_GdiConvertPalette() +{ + ok(GdiConvertPalette((HPALETTE)-1) == (HPALETTE)-1, "\n"); + ok(GdiConvertPalette((HPALETTE)0) == (HPALETTE)0, "\n"); + ok(GdiConvertPalette((HPALETTE)1) == (HPALETTE)1, "\n"); + ok(GdiConvertPalette((HPALETTE)2) == (HPALETTE)2, "\n"); +} + +START_TEST(GdiConvertPalette) +{ + Test_GdiConvertPalette(); +} + diff --git a/rostests/apitests/gdi32/GdiConvertRegion.c b/rostests/apitests/gdi32/GdiConvertRegion.c new file mode 100644 index 00000000000..1db7e16d6cc --- /dev/null +++ b/rostests/apitests/gdi32/GdiConvertRegion.c @@ -0,0 +1,26 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for GdiConvertRegion + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include + +HRGN WINAPI GdiConvertRegion(HRGN); + +void Test_GdiConvertRegion() +{ + ok(GdiConvertRegion((HRGN)-1) == (HRGN)-1, "\n"); + ok(GdiConvertRegion((HRGN)0) == (HRGN)0, "\n"); + ok(GdiConvertRegion((HRGN)1) == (HRGN)1, "\n"); + ok(GdiConvertRegion((HRGN)2) == (HRGN)2, "\n"); +} + +START_TEST(GdiConvertRegion) +{ + Test_GdiConvertRegion(); +} + diff --git a/rostests/apitests/gdi32/GdiDeleteLocalDC.c b/rostests/apitests/gdi32/GdiDeleteLocalDC.c new file mode 100644 index 00000000000..5eec2d1e62e --- /dev/null +++ b/rostests/apitests/gdi32/GdiDeleteLocalDC.c @@ -0,0 +1,26 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for GdiDeleteLocalDC + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include + +BOOL WINAPI GdiDeleteLocalDC(HDC); + +void Test_GdiDeleteLocalDC() +{ + ok(GdiDeleteLocalDC((HDC)-1) == TRUE, "\n"); + ok(GdiDeleteLocalDC((HDC)0) == TRUE, "\n"); + ok(GdiDeleteLocalDC((HDC)1) == TRUE, "\n"); + ok(GdiDeleteLocalDC((HDC)2) == TRUE, "\n"); +} + +START_TEST(GdiDeleteLocalDC) +{ + Test_GdiDeleteLocalDC(); +} + diff --git a/rostests/apitests/gdi32/GdiGetCharDimensions.c b/rostests/apitests/gdi32/GdiGetCharDimensions.c new file mode 100644 index 00000000000..600ee7d7848 --- /dev/null +++ b/rostests/apitests/gdi32/GdiGetCharDimensions.c @@ -0,0 +1,47 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for GdiGetCharDimensions + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include + +void Test_GdiGetCharDimensions() +{ + LOGFONT logfont = {-11, 0, 0, 0, 400, + 0, 0, 0, 0, 0, 0, 0, 0, + "MS Shell Dlg 2"}; + HFONT hFont, hOldFont; + HDC hdc; + LONG x, y, x2; + TEXTMETRICW tm; + SIZE size; + static const WCHAR alphabet[] = { + 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q', + 'r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H', + 'I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',0}; + + hFont = CreateFontIndirect(&logfont); + hdc = CreateCompatibleDC(NULL); + hOldFont = SelectObject(hdc, hFont); + + x = GdiGetCharDimensions(hdc, &tm, &y); + GetTextExtentPointW(hdc, alphabet, 52, &size); + x2 = (size.cx / 26 + 1) / 2; + + ok(x == x2, "x=%ld, x2=%ld\n", x, x2); + ok(y == tm.tmHeight, "y = %ld, tm.tmHeight = %ld\n", y, tm.tmHeight); + + SelectObject(hdc, hOldFont); + DeleteObject(hFont); + DeleteDC(hdc); +} + +START_TEST(GdiGetCharDimensions) +{ + Test_GdiGetCharDimensions(); +} + diff --git a/rostests/apitests/gdi32/GdiGetLocalBrush.c b/rostests/apitests/gdi32/GdiGetLocalBrush.c new file mode 100644 index 00000000000..7a8f182cf04 --- /dev/null +++ b/rostests/apitests/gdi32/GdiGetLocalBrush.c @@ -0,0 +1,26 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for GdiGetLocalBrush + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include + +HBRUSH WINAPI GdiGetLocalBrush(HBRUSH hbr); + +void Test_GdiGetLocalBrush() +{ + ok(GdiGetLocalBrush((HBRUSH)-1) == (HBRUSH)-1, "\n"); + ok(GdiGetLocalBrush((HBRUSH)0) == (HBRUSH)0, "\n"); + ok(GdiGetLocalBrush((HBRUSH)1) == (HBRUSH)1, "\n"); + ok(GdiGetLocalBrush((HBRUSH)2) == (HBRUSH)2, "\n"); +} + +START_TEST(GdiGetLocalBrush) +{ + Test_GdiGetLocalBrush(); +} + diff --git a/rostests/apitests/gdi32/GdiGetLocalDC.c b/rostests/apitests/gdi32/GdiGetLocalDC.c new file mode 100644 index 00000000000..e8de9c0d032 --- /dev/null +++ b/rostests/apitests/gdi32/GdiGetLocalDC.c @@ -0,0 +1,26 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for GdiGetLocalDC + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include + +HDC WINAPI GdiGetLocalDC(HDC); + +void Test_GdiGetLocalDC() +{ + ok(GdiGetLocalDC((HDC)-1) == (HDC)-1, "\n"); + ok(GdiGetLocalDC((HDC)0) == (HDC)0, "\n"); + ok(GdiGetLocalDC((HDC)1) == (HDC)1, "\n"); + ok(GdiGetLocalDC((HDC)2) == (HDC)2, "\n"); +} + +START_TEST(GdiGetLocalDC) +{ + Test_GdiGetLocalDC(); +} + diff --git a/rostests/apitests/gdi32/GdiReleaseLocalDC.c b/rostests/apitests/gdi32/GdiReleaseLocalDC.c new file mode 100644 index 00000000000..8eea7d76b64 --- /dev/null +++ b/rostests/apitests/gdi32/GdiReleaseLocalDC.c @@ -0,0 +1,26 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for GdiReleaseLocalDC + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include + +BOOL WINAPI GdiReleaseLocalDC(HDC); + +void Test_GdiReleaseLocalDC() +{ + ok(GdiReleaseLocalDC((HDC)-1) == TRUE, "\n"); + ok(GdiReleaseLocalDC((HDC)0) == TRUE, "\n"); + ok(GdiReleaseLocalDC((HDC)1) == TRUE, "\n"); + ok(GdiReleaseLocalDC((HDC)2) == TRUE, "\n"); +} + +START_TEST(GdiReleaseLocalDC) +{ + Test_GdiReleaseLocalDC(); +} + diff --git a/rostests/apitests/gdi32/GdiSetAttrs.c b/rostests/apitests/gdi32/GdiSetAttrs.c new file mode 100644 index 00000000000..b0bd6b249e0 --- /dev/null +++ b/rostests/apitests/gdi32/GdiSetAttrs.c @@ -0,0 +1,26 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for GdiSetAttrs + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include + +BOOL WINAPI GdiSetAttrs(HDC); + +void Test_GdiSetAttrs() +{ + ok(GdiSetAttrs((HDC)-1) == TRUE, "\n"); + ok(GdiSetAttrs((HDC)0) == TRUE, "\n"); + ok(GdiSetAttrs((HDC)1) == TRUE, "\n"); + ok(GdiSetAttrs((HDC)2) == TRUE, "\n"); +} + +START_TEST(GdiSetAttrs) +{ + Test_GdiSetAttrs(); +} + diff --git a/rostests/apitests/gdi32/GetClipRgn.c b/rostests/apitests/gdi32/GetClipRgn.c new file mode 100644 index 00000000000..7ca818773fa --- /dev/null +++ b/rostests/apitests/gdi32/GetClipRgn.c @@ -0,0 +1,44 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for GetClipRgn + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include + +void Test_GetClipRgn() +{ + HWND hWnd; + HDC hDC; + HRGN hrgn;//, hrgn2; + + /* Create a window */ + hWnd = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW | WS_VISIBLE, + CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, + NULL, NULL, 0, 0); + + hDC = GetDC(hWnd); + hrgn = CreateRectRgn(0,0,0,0); + + /* Test invalid DC */ + SetLastError(ERROR_SUCCESS); + ok(GetClipRgn((HDC)0x12345, hrgn) == -1, "\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "\n"); + + /* Test invalid hrgn */ + SetLastError(ERROR_SUCCESS); + ok(GetClipRgn(hDC, (HRGN)0x12345) == 0, "\n"); + ok(GetLastError() == ERROR_SUCCESS, "\n"); + + ReleaseDC(hWnd, hDC); + DestroyWindow(hWnd); +} + +START_TEST(GetClipRgn) +{ + Test_GetClipRgn(); +} + diff --git a/rostests/apitests/gdi32/GetCurrentObject.c b/rostests/apitests/gdi32/GetCurrentObject.c new file mode 100644 index 00000000000..c8389ebf20e --- /dev/null +++ b/rostests/apitests/gdi32/GetCurrentObject.c @@ -0,0 +1,154 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for GetCurrentObject + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include +#include +#include +#include + +void Test_GetCurrentObject() +{ + HWND hWnd; + HDC hDC; + HBITMAP hBmp; + + /* Create a window */ + hWnd = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW | WS_VISIBLE, + CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, + NULL, NULL, 0, 0); + /* Get the DC */ + hDC = GetDC(hWnd); + + /* Test NULL DC */ + SetLastError(ERROR_SUCCESS); + ok(GetCurrentObject(NULL, 0) == 0, "\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "\n"); + + SetLastError(ERROR_SUCCESS); + ok(GetCurrentObject(NULL, OBJ_BITMAP) == 0, "\n"); + ok(GetCurrentObject(NULL, OBJ_BRUSH) == 0, "\n"); + ok(GetCurrentObject(NULL, OBJ_COLORSPACE) == 0, "\n"); + ok(GetCurrentObject(NULL, OBJ_FONT) == 0, "\n"); + ok(GetCurrentObject(NULL, OBJ_PAL) == 0, "\n"); + ok(GetCurrentObject(NULL, OBJ_PEN) == 0, "\n"); + ok(GetLastError() == ERROR_SUCCESS, "\n"); + + /* Test invalid DC handle */ + SetLastError(ERROR_SUCCESS); + ok(GetCurrentObject((HDC)-123, 0) == 0, "\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "\n"); + + SetLastError(ERROR_SUCCESS); + ok(GetCurrentObject((HDC)-123, OBJ_BITMAP) == 0, "\n"); + ok(GetLastError() == ERROR_SUCCESS, "\n"); + + /* Test invalid types */ + SetLastError(ERROR_SUCCESS); + ok(GetCurrentObject(hDC, 0) == 0, "\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "\n"); + + SetLastError(ERROR_SUCCESS); + ok(GetCurrentObject(hDC, 3) == 0, "\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "\n"); + + SetLastError(ERROR_SUCCESS); + ok(GetCurrentObject(hDC, 4) == 0, "\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "\n"); + + SetLastError(ERROR_SUCCESS); + ok(GetCurrentObject(hDC, 8) == 0, "\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "\n"); + + SetLastError(ERROR_SUCCESS); + ok(GetCurrentObject(hDC, 9) == 0, "\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "\n"); + + SetLastError(ERROR_SUCCESS); + ok(GetCurrentObject(hDC, 10) == 0, "\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "\n"); + + SetLastError(ERROR_SUCCESS); + ok(GetCurrentObject(hDC, 12) == 0, "\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "\n"); + + SetLastError(ERROR_SUCCESS); + ok(GetCurrentObject(hDC, 13) == 0, "\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "\n"); + + /* Default bitmap */ + SetLastError(ERROR_SUCCESS); + hBmp = GetCurrentObject(hDC, OBJ_BITMAP); + ok(GDI_HANDLE_GET_TYPE(hBmp) == GDI_OBJECT_TYPE_BITMAP, "\n"); + ok(GetLastError() == ERROR_SUCCESS, "\n"); + + /* Other bitmap */ + SetLastError(ERROR_SUCCESS); + SelectObject(hDC, GetStockObject(21)); + ok(hBmp == GetCurrentObject(hDC, OBJ_BITMAP), "\n"); + ok(GDI_HANDLE_GET_TYPE(hBmp) == GDI_OBJECT_TYPE_BITMAP, "\n"); + ok(GetLastError() == ERROR_SUCCESS, "\n"); + + /* Default brush */ + SetLastError(ERROR_SUCCESS); + ok(GetCurrentObject(hDC, OBJ_BRUSH) == GetStockObject(WHITE_BRUSH), "\n"); + ok(GetLastError() == ERROR_SUCCESS, "\n"); + + /* Other brush */ + SetLastError(ERROR_SUCCESS); + SelectObject(hDC, GetStockObject(BLACK_BRUSH)); + ok(GetCurrentObject(hDC, OBJ_BRUSH) == GetStockObject(BLACK_BRUSH), "\n"); + ok(GetLastError() == ERROR_SUCCESS, "\n"); + + /* Default colorspace */ + SetLastError(ERROR_SUCCESS); + ok(GetCurrentObject(hDC, OBJ_COLORSPACE) == GetStockObject(20), "\n"); + ok(GetLastError() == ERROR_SUCCESS, "\n"); + + /* Default font */ + SetLastError(ERROR_SUCCESS); + ok(GetCurrentObject(hDC, OBJ_FONT) == GetStockObject(SYSTEM_FONT), "\n"); + ok(GetLastError() == ERROR_SUCCESS, "\n"); + + /* Other font */ + SetLastError(ERROR_SUCCESS); + SelectObject(hDC, GetStockObject(DEFAULT_GUI_FONT)); + ok(GetCurrentObject(hDC, OBJ_FONT) == GetStockObject(DEFAULT_GUI_FONT), "\n"); + ok(GetLastError() == ERROR_SUCCESS, "\n"); + + /* Default palette */ + SetLastError(ERROR_SUCCESS); + ok(GetCurrentObject(hDC, OBJ_PAL) == GetStockObject(DEFAULT_PALETTE), "\n"); + ok(GetLastError() == ERROR_SUCCESS, "\n"); + + /* Default pen */ + SetLastError(ERROR_SUCCESS); + ok(GetCurrentObject(hDC, OBJ_PEN) == GetStockObject(BLACK_PEN), "\n"); + ok(GetLastError() == ERROR_SUCCESS, "\n"); + + /* Other pen */ + SetLastError(ERROR_SUCCESS); + SelectObject(hDC, GetStockObject(WHITE_PEN)); + ok(GetCurrentObject(hDC, OBJ_PEN) == GetStockObject(WHITE_PEN), "\n"); + ok(GetLastError() == ERROR_SUCCESS, "\n"); + + /* DC pen */ + SetLastError(ERROR_SUCCESS); + SelectObject(hDC, GetStockObject(DC_PEN)); + ok(GetCurrentObject(hDC, OBJ_PEN) == GetStockObject(DC_PEN), "\n"); + ok(GetLastError() == ERROR_SUCCESS, "\n"); + + ReleaseDC(hWnd, hDC); + DestroyWindow(hWnd); +} + +START_TEST(GetCurrentObject) +{ + Test_GetCurrentObject(); +} + diff --git a/rostests/apitests/gdi32api/tests/GetDIBits.c b/rostests/apitests/gdi32/GetDIBits.c similarity index 85% rename from rostests/apitests/gdi32api/tests/GetDIBits.c rename to rostests/apitests/gdi32/GetDIBits.c index 3ed96bc233a..dad441c2786 100644 --- a/rostests/apitests/gdi32api/tests/GetDIBits.c +++ b/rostests/apitests/gdi32/GetDIBits.c @@ -1,5 +1,18 @@ -INT -Test_GetDIBits(PTESTINFO pti) +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for GetDIBits + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include + +#define TEST(x) ok(x, #x) +#define RTEST(x) ok(x, #x) + +void Test_GetDIBits() { HDC hDCScreen; HBITMAP hBitmap; @@ -7,10 +20,8 @@ Test_GetDIBits(PTESTINFO pti) INT ScreenBpp; hDCScreen = GetDC(NULL); - if (hDCScreen == NULL) - { - return FALSE; - } + ok(hDCScreen != 0, "GetDC failed, skipping tests\n"); + if (hDCScreen == NULL) return; hBitmap = CreateCompatibleBitmap(hDCScreen, 16, 16); RTEST(hBitmap != NULL); @@ -85,5 +96,10 @@ Test_GetDIBits(PTESTINFO pti) DeleteObject(hBitmap); ReleaseDC(NULL, hDCScreen); - return APISTATUS_NORMAL; } + +START_TEST(GetDIBits) +{ + Test_GetDIBits(); +} + diff --git a/rostests/apitests/gdi32/GetObject.c b/rostests/apitests/gdi32/GetObject.c new file mode 100644 index 00000000000..8f47010ac33 --- /dev/null +++ b/rostests/apitests/gdi32/GetObject.c @@ -0,0 +1,462 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for GetObject + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include +#include +#include +#include + +void +Test_General(void) +{ + struct + { + LOGBRUSH logbrush; + BYTE additional[5]; + } TestStruct; + PLOGBRUSH plogbrush; + HBRUSH hBrush; + + /* Test null pointer and invalid handles */ + SetLastError(ERROR_SUCCESS); + ok(GetObjectA(0, 0, NULL) == 0, "\n"); + ok(GetObjectA((HANDLE)-1, 0, NULL) == 0, "\n"); + ok(GetObjectA((HANDLE)0x00380000, 0, NULL) == 0, "\n"); + ok(GetLastError() == ERROR_SUCCESS, "\n"); + + SetLastError(ERROR_SUCCESS); + ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_DC, 0, NULL) == 0, "\n"); + ok(GetLastError() == ERROR_INVALID_HANDLE, "\n"); + SetLastError(ERROR_SUCCESS); + ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_DC, 0, NULL) == 0, "\n"); + ok(GetLastError() == ERROR_INVALID_HANDLE, "\n"); + SetLastError(ERROR_SUCCESS); + ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_REGION, 0, NULL) == 0, "\n"); + ok(GetLastError() == ERROR_INVALID_HANDLE, "\n"); + SetLastError(ERROR_SUCCESS); + ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_REGION, 0, NULL) == 0, "\n"); + ok(GetLastError() == ERROR_INVALID_HANDLE, "\n"); + SetLastError(ERROR_SUCCESS); + ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_EMF, 0, NULL) == 0, "\n"); + ok(GetLastError() == ERROR_INVALID_HANDLE, "\n"); + SetLastError(ERROR_SUCCESS); + ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_EMF, 0, NULL) == 0, "\n"); + ok(GetLastError() == ERROR_INVALID_HANDLE, "\n"); + SetLastError(ERROR_SUCCESS); + ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_METAFILE, 0, NULL) == 0, "\n"); + ok(GetLastError() == ERROR_INVALID_HANDLE, "\n"); + SetLastError(ERROR_SUCCESS); + ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_METAFILE, 0, NULL) == 0, "\n"); + ok(GetLastError() == ERROR_INVALID_HANDLE, "\n"); + SetLastError(ERROR_SUCCESS); + ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_ENHMETAFILE, 0, NULL) == 0, "\n"); + ok(GetLastError() == ERROR_INVALID_HANDLE, "\n"); + SetLastError(ERROR_SUCCESS); + ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_ENHMETAFILE, 0, NULL) == 0, "\n"); + ok(GetLastError() == ERROR_INVALID_HANDLE, "\n"); + + /* Test need of alignment */ + hBrush = GetStockObject(WHITE_BRUSH); + plogbrush = (PVOID)((ULONG_PTR)&TestStruct.logbrush); + ok(GetObject(hBrush, sizeof(LOGBRUSH), plogbrush) == sizeof(LOGBRUSH), "\n"); + plogbrush = (PVOID)((ULONG_PTR)&TestStruct.logbrush + 2); + ok(GetObject(hBrush, sizeof(LOGBRUSH), plogbrush) == sizeof(LOGBRUSH), "\n"); + plogbrush = (PVOID)((ULONG_PTR)&TestStruct.logbrush + 1); + ok(GetObject(hBrush, sizeof(LOGBRUSH), plogbrush) == 0, "\n"); +} + +void +Test_Bitmap(void) +{ + HBITMAP hBitmap; + BITMAP bitmap; + DIBSECTION dibsection; + BYTE bData[100] = {0}; + BYTE Buffer[100] = {48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,0}; + + FillMemory(&bitmap, sizeof(BITMAP), 0x77); + hBitmap = CreateBitmap(10,10,1,8,bData); + ok(hBitmap != 0, "CreateBitmap failed, skipping tests.\n"); + if (!hBitmap) return; + + SetLastError(ERROR_SUCCESS); + ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_BITMAP, 0, NULL) == sizeof(BITMAP), "\n"); + ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_BITMAP, 0, NULL) == sizeof(BITMAP), "\n"); + ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_BITMAP, sizeof(BITMAP), NULL) == sizeof(BITMAP), "\n"); + ok(GetObjectA(hBitmap, sizeof(DIBSECTION), NULL) == sizeof(BITMAP), "\n"); + ok(GetObjectA(hBitmap, 0, NULL) == sizeof(BITMAP), "\n"); + ok(GetObjectA((HANDLE)((UINT_PTR)hBitmap & 0x0000ffff), 0, NULL) == sizeof(BITMAP), "\n"); + ok(GetObjectA(hBitmap, 5, NULL) == sizeof(BITMAP), "\n"); + ok(GetObjectA(hBitmap, -5, NULL) == sizeof(BITMAP), "\n"); + ok(GetObjectA(hBitmap, 0, Buffer) == 0, "\n"); + ok(GetObjectA(hBitmap, 5, Buffer) == 0, "\n"); + ok(GetObjectA(hBitmap, sizeof(BITMAP), &bitmap) == sizeof(BITMAP), "\n"); + ok(GetObjectA(hBitmap, sizeof(BITMAP)+2, &bitmap) == sizeof(BITMAP), "\n"); + ok(GetObjectA(hBitmap, sizeof(DIBSECTION), &dibsection) == sizeof(BITMAP), "\n"); + ok(GetObjectA(hBitmap, -5, &bitmap) == sizeof(BITMAP), "\n"); + ok(GetLastError() == ERROR_SUCCESS, "\n"); + + // todo: test invalid handle + buffer + + DeleteObject(hBitmap); +} + +void +Test_Dibsection(void) +{ + BITMAPINFO bmi = {{sizeof(BITMAPINFOHEADER), 10, 9, 1, 8, BI_RGB, 0, 10, 10, 0,0}}; + HBITMAP hBitmap; + BITMAP bitmap; + DIBSECTION dibsection; + PVOID pData; + HDC hDC; + + FillMemory(&dibsection, sizeof(DIBSECTION), 0x77); + hDC = GetDC(0); + hBitmap = CreateDIBSection(hDC, &bmi, DIB_RGB_COLORS, &pData, NULL, 0); + ok(hBitmap != 0, "CreateDIBSection failed, skipping tests.\n"); + if (!hBitmap) return; + + SetLastError(ERROR_SUCCESS); + ok(GetObject(hBitmap, sizeof(DIBSECTION), NULL) == sizeof(BITMAP), "\n"); + ok(GetObject(hBitmap, 0, NULL) == sizeof(BITMAP), "\n"); + ok(GetObject(hBitmap, 5, NULL) == sizeof(BITMAP), "\n"); + ok(GetObject(hBitmap, -5, NULL) == sizeof(BITMAP), "\n"); + ok(GetObject(hBitmap, 0, &dibsection) == 0, "\n"); + ok(GetObject(hBitmap, 5, &dibsection) == 0, "\n"); + ok(GetObject(hBitmap, sizeof(BITMAP), &bitmap) == sizeof(BITMAP), "\n"); + ok(GetObject(hBitmap, sizeof(BITMAP)+2, &bitmap) == sizeof(BITMAP), "\n"); + ok(bitmap.bmType == 0, "\n"); + ok(bitmap.bmWidth == 10, "\n"); + ok(bitmap.bmHeight == 9, "\n"); + ok(bitmap.bmWidthBytes == 12, "\n"); + ok(bitmap.bmPlanes == 1, "\n"); + ok(bitmap.bmBitsPixel == 8, "\n"); + ok(bitmap.bmBits == pData, "\n"); + ok(GetObject(hBitmap, sizeof(DIBSECTION), &dibsection) == sizeof(DIBSECTION), "\n"); + ok(GetObject(hBitmap, sizeof(DIBSECTION)+2, &dibsection) == sizeof(DIBSECTION), "\n"); + ok(GetObject(hBitmap, -5, &dibsection) == sizeof(DIBSECTION), "\n"); + ok(GetLastError() == ERROR_SUCCESS, "\n"); + DeleteObject(hBitmap); + ReleaseDC(0, hDC); +} + +void +Test_Palette(void) +{ + LOGPALETTE logpal; + HPALETTE hPalette; + WORD wPalette; + + FillMemory(&wPalette, sizeof(WORD), 0x77); + logpal.palVersion = 0x0300; + logpal.palNumEntries = 1; + logpal.palPalEntry[0].peRed = 0; + logpal.palPalEntry[0].peGreen = 0; + logpal.palPalEntry[0].peBlue = 0; + logpal.palPalEntry[0].peFlags = PC_EXPLICIT; + hPalette = CreatePalette(&logpal); + ok(hPalette != 0, "CreatePalette failed, skipping tests.\n"); + if (!hPalette) return; + + SetLastError(ERROR_SUCCESS); + ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_PALETTE, 0, NULL) == sizeof(WORD), "\n"); + ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_PALETTE, 0, NULL) == sizeof(WORD), "\n"); + ok(GetObject(hPalette, sizeof(WORD), NULL) == sizeof(WORD), "\n"); + ok(GetObject(hPalette, 0, NULL) == sizeof(WORD), "\n"); + ok(GetObject(hPalette, 5, NULL) == sizeof(WORD), "\n"); + ok(GetObject(hPalette, -5, NULL) == sizeof(WORD), "\n"); + ok(GetObject(hPalette, sizeof(WORD), &wPalette) == sizeof(WORD), "\n"); + ok(GetObject(hPalette, sizeof(WORD)+2, &wPalette) == sizeof(WORD), "\n"); + ok(GetObject(hPalette, 0, &wPalette) == 0, "\n"); + ok(GetObject(hPalette, 1, &wPalette) == 0, "\n"); + ok(GetObject(hPalette, -1, &wPalette) == sizeof(WORD), "\n"); + ok(GetLastError() == ERROR_SUCCESS, "\n"); + DeleteObject(hPalette); +} + +void +Test_Brush(void) +{ + LOGBRUSH logbrush; + HBRUSH hBrush; + + FillMemory(&logbrush, sizeof(LOGBRUSH), 0x77); + hBrush = CreateSolidBrush(RGB(1,2,3)); + ok(hBrush != 0, "CreateSolidBrush failed, skipping tests.\n"); + if (!hBrush) return; + + SetLastError(ERROR_SUCCESS); + ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_BRUSH, 0, NULL) == sizeof(LOGBRUSH), "\n"); + ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_BRUSH, 0, NULL) == sizeof(LOGBRUSH), "\n"); + ok(GetObject(hBrush, sizeof(WORD), NULL) == sizeof(LOGBRUSH), "\n"); + ok(GetObject(hBrush, 0, NULL) == sizeof(LOGBRUSH), "\n"); + ok(GetObject(hBrush, 5, NULL) == sizeof(LOGBRUSH), "\n"); + ok(GetObject(hBrush, -5, NULL) == sizeof(LOGBRUSH), "\n"); + + ok(GetObject(hBrush, 0, &logbrush) == 0, "\n"); + ok(logbrush.lbStyle == 0x77777777, "\n"); + ok(GetObject(hBrush, 5, &logbrush) == sizeof(LOGBRUSH), "\n"); + ok(logbrush.lbStyle == 0, "\n"); + ok(logbrush.lbColor == 0x77777701, "\n"); + + ok(GetObject(hBrush, sizeof(LOGBRUSH), &logbrush) == sizeof(LOGBRUSH), "\n"); + ok(GetObject(hBrush, sizeof(LOGBRUSH)+2, &logbrush) == sizeof(LOGBRUSH), "\n"); + ok(GetObject(hBrush, -1, &logbrush) == sizeof(LOGBRUSH), "\n"); + // TODO: test all members + + ok(GetLastError() == ERROR_SUCCESS, "\n"); + DeleteObject(hBrush); +} + +void +Test_Pen(void) +{ + LOGPEN logpen; + HPEN hPen; + + FillMemory(&logpen, sizeof(LOGPEN), 0x77); + hPen = CreatePen(PS_SOLID, 3, RGB(4,5,6)); + ok(hPen != 0, "CreatePen failed, skipping tests.\n"); + if (!hPen) return; + SetLastError(ERROR_SUCCESS); + ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_PEN, 0, NULL) == sizeof(LOGPEN), "\n"); + ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_PEN, 0, NULL) == sizeof(LOGPEN), "\n"); + ok(GetObject(hPen, sizeof(BITMAP), NULL) == sizeof(LOGPEN), "\n"); + ok(GetObject(hPen, 0, NULL) == sizeof(LOGPEN), "\n"); + ok(GetObject(hPen, 5, NULL) == sizeof(LOGPEN), "\n"); + ok(GetObject(hPen, -5, NULL) == sizeof(LOGPEN), "\n"); + ok(GetObject(hPen, sizeof(LOGPEN), &logpen) == sizeof(LOGPEN), "\n"); + ok(GetObject(hPen, sizeof(LOGPEN)-1, &logpen) == 0, "\n"); + ok(GetObject(hPen, sizeof(LOGPEN)+2, &logpen) == sizeof(LOGPEN), "\n"); + ok(GetObject(hPen, 0, &logpen) == 0, "\n"); + ok(GetObject(hPen, -5, &logpen) == sizeof(LOGPEN), "\n"); + ok(GetLastError() == ERROR_SUCCESS, "\n"); + + /* test if the fields are filled correctly */ + ok(logpen.lopnStyle == PS_SOLID, "\n"); + + + DeleteObject(hPen); +} + +void +Test_ExtPen(void) +{ + HPEN hPen; + EXTLOGPEN extlogpen; + LOGBRUSH logbrush; + DWORD dwStyles[17] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; + struct + { + EXTLOGPEN extlogpen; + DWORD dwStyles[50]; + } elpUserStyle; + + SetLastError(ERROR_SUCCESS); + ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, NULL) == 0, "\n"); + ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, NULL) == 0, "\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "\n"); + + FillMemory(&extlogpen, sizeof(EXTLOGPEN), 0x77); + logbrush.lbStyle = BS_SOLID; + logbrush.lbColor = RGB(1,2,3); + logbrush.lbHatch = 22; + hPen = ExtCreatePen(PS_GEOMETRIC | PS_DASH, 5, &logbrush, 0, NULL); + + ok(GDI_HANDLE_GET_TYPE(hPen) == GDI_OBJECT_TYPE_EXTPEN, "\n"); + ok(GetObject((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, NULL) == 0, "\n"); + ok(GetObject(hPen, sizeof(EXTLOGPEN), NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n"); + ok(GetObject(hPen, 0, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n"); + ok(GetObject((HANDLE)GDI_HANDLE_GET_INDEX(hPen), 0, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n"); + ok(GetObject(hPen, 5, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n"); + ok(GetObject(hPen, -5, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n"); + ok(GetObject(hPen, 0, &extlogpen) == 0, "\n"); + ok(GetObject(hPen, 4, &extlogpen) == 0, "\n"); + + /* Nothing should be filled */ + ok(extlogpen.elpPenStyle == 0x77777777, "\n"); + ok(extlogpen.elpWidth == 0x77777777, "\n"); + + ok(GetObject(hPen, sizeof(EXTLOGPEN), &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n"); + ok(GetObject(hPen, sizeof(EXTLOGPEN)-sizeof(DWORD), &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n"); + ok(GetObject(hPen, sizeof(EXTLOGPEN)-sizeof(DWORD)-1, &extlogpen) == 0, "\n"); + ok(GetObject(hPen, sizeof(EXTLOGPEN)+2, &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n"); + ok(GetObject(hPen, -5, &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n"); + + /* test if the fields are filled correctly */ + ok(extlogpen.elpPenStyle == (PS_GEOMETRIC | PS_DASH), "\n"); + ok(extlogpen.elpWidth == 5, "\n"); + ok(extlogpen.elpBrushStyle == 0, "\n"); + ok(extlogpen.elpColor == RGB(1,2,3), "\n"); + ok(extlogpen.elpHatch == 22, "\n"); + ok(extlogpen.elpNumEntries == 0, "\n"); + DeleteObject(hPen); + + /* A maximum of 16 Styles is allowed */ + hPen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE, 5, &logbrush, 16, (CONST DWORD*)&dwStyles); + ok(GetObject(hPen, 0, NULL) == sizeof(EXTLOGPEN) + 15*sizeof(DWORD), "\n"); + ok(GetObject(hPen, sizeof(EXTLOGPEN) + 15*sizeof(DWORD), &elpUserStyle) == sizeof(EXTLOGPEN) + 15*sizeof(DWORD), "\n"); + ok(((EXTLOGPEN*)&elpUserStyle)->elpStyleEntry[0] == 0, "\n"); + ok(((EXTLOGPEN*)&elpUserStyle)->elpStyleEntry[1] == 1, "\n"); + ok(((EXTLOGPEN*)&elpUserStyle)->elpStyleEntry[15] == 15, "\n"); + DeleteObject(hPen); +} + +void +Test_Font(void) +{ + HFONT hFont; + LOGFONTA logfonta; + LOGFONTW logfontw; + EXTLOGFONTA extlogfonta; + EXTLOGFONTW extlogfontw; + ENUMLOGFONTEXA enumlogfontexa; + ENUMLOGFONTEXW enumlogfontexw; + ENUMLOGFONTEXDVA enumlogfontexdva; + ENUMLOGFONTEXDVW enumlogfontexdvw; + ENUMLOGFONTA enumlogfonta; + ENUMLOGFONTW enumlogfontw; + BYTE bData[270]; + + FillMemory(&logfonta, sizeof(LOGFONTA), 0x77); + hFont = CreateFontA(8, 8, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, + ANSI_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, + ANTIALIASED_QUALITY, DEFAULT_PITCH, "testfont"); + ok(hFont != 0, "\n"); + + SetLastError(ERROR_SUCCESS); + ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, 0, NULL) == sizeof(LOGFONTA), "\n"); + ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, 0, NULL) == sizeof(LOGFONTW), "\n"); + ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(LOGFONTA), NULL) == sizeof(LOGFONTA), "\n"); // 60 + ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTA), NULL) == sizeof(LOGFONTA), "\n"); // 156 + ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXA), NULL) == sizeof(LOGFONTA), "\n"); // 188 + ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(EXTLOGFONTA), NULL) == sizeof(LOGFONTA), "\n"); // 192 + ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVA), NULL) == sizeof(LOGFONTA), "\n"); // 260 + ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVA)+1, NULL) == sizeof(LOGFONTA), "\n"); // 260 + ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(LOGFONTW), NULL) == sizeof(LOGFONTW), "\n"); // 92 + ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTW), NULL) == sizeof(LOGFONTW), "\n"); // 284 + ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(EXTLOGFONTW), NULL) == sizeof(LOGFONTW), "\n"); // 320 + ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXW), NULL) == sizeof(LOGFONTW), "\n"); // 348 + ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVW), NULL) == sizeof(LOGFONTW), "\n"); // 420 + ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVW)+1, NULL) == sizeof(LOGFONTW), "\n"); // 356! + + ok(GetObjectA(hFont, sizeof(LOGFONTA), NULL) == sizeof(LOGFONTA), "\n"); + ok(GetObjectA(hFont, 0, NULL) == sizeof(LOGFONTA), "\n"); + ok(GetObjectA(hFont, 5, NULL) == sizeof(LOGFONTA), "\n"); + ok(GetObjectA(hFont, -5, NULL) == sizeof(LOGFONTA), "\n"); + ok(GetObjectA(hFont, 0, &logfonta) == 0, "\n"); + ok(logfonta.lfHeight == 0x77777777, "\n"); + + ok(GetObjectA(hFont, 5, &logfonta) == 5, "\n"); + ok(logfonta.lfHeight == 8, "\n"); + ok(logfonta.lfWidth == 0x77777708, "\n"); + + ok(GetObjectA(hFont, sizeof(LOGFONTA), &logfonta) == sizeof(LOGFONTA), "\n"); // 60 + ok(GetObjectA(hFont, sizeof(LOGFONTW), &logfontw) == sizeof(LOGFONTA), "\n"); // 92 + ok(GetObjectA(hFont, sizeof(EXTLOGFONTA), &extlogfonta) == sizeof(EXTLOGFONTA), "\n"); // 192 + ok(GetObjectA(hFont, sizeof(EXTLOGFONTA)+1, &extlogfonta) == sizeof(EXTLOGFONTA)+1, "\n"); // 192 + ok(GetObjectA(hFont, sizeof(EXTLOGFONTW), &extlogfontw) == sizeof(ENUMLOGFONTEXDVA), "\n"); // 320 + + ok(GetObjectA(hFont, 261, &bData) == 260, "\n"); // no + + /* LOGFONT / GetObjectW */ + FillMemory(&logfontw, sizeof(LOGFONTW), 0x77); + + ok(GetObjectW(hFont, sizeof(LOGFONTW), NULL) == sizeof(LOGFONTW), "\n"); + ok(GetObjectW(hFont, 0, NULL) == sizeof(LOGFONTW), "\n"); + ok(GetObjectW(hFont, 5, NULL) == sizeof(LOGFONTW), "\n"); + ok(GetObjectW(hFont, -5, NULL) == sizeof(LOGFONTW), "\n"); + ok(GetObjectW(hFont, 0, &logfontw) == 0, "\n"); + ok(logfontw.lfHeight == 0x77777777, "\n"); + + ok(GetObjectW(hFont, 5, &logfontw) == 5, "\n"); + ok(logfontw.lfHeight == 8, "\n"); + ok(logfontw.lfWidth == 0x77777708, "\n"); + + ok(GetObjectA(hFont, sizeof(LOGFONTA), &logfonta) == sizeof(LOGFONTA), "\n"); // 60 + ok(logfonta.lfHeight == 8, "\n"); + ok(GetObjectA(hFont, sizeof(ENUMLOGFONTA), &enumlogfonta) == sizeof(ENUMLOGFONTA), "\n"); // 156 + ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXA), &enumlogfontexa) == sizeof(ENUMLOGFONTEXA), "\n"); // 188 + ok(GetObjectA(hFont, sizeof(EXTLOGFONTA), &extlogfonta) == sizeof(EXTLOGFONTA), "\n"); // 192 + ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA), &enumlogfontexdva) == sizeof(ENUMLOGFONTEXDVA), "\n"); // 260 + ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA)+1, &enumlogfontexdva) == sizeof(ENUMLOGFONTEXDVA), "\n"); // 260 + + ok(GetObjectW(hFont, sizeof(LOGFONTW), &logfontw) == sizeof(LOGFONTW), "\n"); // 92 + ok(GetObjectW(hFont, sizeof(ENUMLOGFONTW), &enumlogfontw) == sizeof(ENUMLOGFONTW), "\n"); // 284 + ok(GetObjectW(hFont, sizeof(EXTLOGFONTW), &extlogfontw) == sizeof(EXTLOGFONTW), "\n"); // 320 + ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXW), &enumlogfontexw) == sizeof(ENUMLOGFONTEXW), "\n"); // 348 + ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXDVW), &enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 420 + ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXDVW)+1, &enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 356! + + ok(GetObjectW(hFont, 356, &bData) == 356, "\n"); + ok(GetLastError() == ERROR_SUCCESS, "\n"); + + DeleteObject(hFont); +} + +void +Test_Colorspace(void) +{ + SetLastError(ERROR_SUCCESS); + ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 0, NULL) == 60, "\n");// FIXME: what structure? + ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "\n"); + SetLastError(ERROR_SUCCESS); + ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 0, NULL) == 0, "\n"); + ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "\n"); +} + +void +Test_MetaDC(void) +{ + /* Windows does not SetLastError() on a metadc, but it doesn't seem to do anything with it */ + HDC hMetaDC; + BYTE buffer[100]; + + hMetaDC = CreateMetaFile(NULL); + ok(hMetaDC != 0, "CreateMetaFile failed, skipping tests.\n"); + if(!hMetaDC) return; + + ok(((UINT_PTR)hMetaDC & GDI_HANDLE_TYPE_MASK) == GDI_OBJECT_TYPE_METADC, "\n"); + + SetLastError(ERROR_SUCCESS); + ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_METADC, 0, NULL) == 0, "\n"); + ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_METADC, 100, &buffer) == 0, "\n"); + ok(GetObjectA(hMetaDC, 0, NULL) == 0, "\n"); + ok(GetObjectA(hMetaDC, 100, &buffer) == 0, "\n"); + ok(GetLastError() == ERROR_SUCCESS, "\n"); +} + +void +Test_Region(void) +{ + HRGN hRgn; + hRgn = CreateRectRgn(0,0,5,5); + SetLastError(ERROR_SUCCESS); + ok(GetObjectW(hRgn, 0, NULL) == 0, "\n"); + ok(GetLastError() == ERROR_INVALID_HANDLE, "\n"); + DeleteObject(hRgn); +} + +START_TEST(GetObject) +{ + + Test_Font(); + Test_Colorspace(); + Test_General(); + Test_Bitmap(); + Test_Dibsection(); + Test_Palette(); + Test_Brush(); + Test_Pen(); + Test_ExtPen(); // not implemented yet in ROS + Test_MetaDC(); + Test_Region(); +} + diff --git a/rostests/apitests/gdi32api/tests/GetStockObject.c b/rostests/apitests/gdi32/GetStockObject.c similarity index 82% rename from rostests/apitests/gdi32api/tests/GetStockObject.c rename to rostests/apitests/gdi32/GetStockObject.c index afcbae8df23..ab2b422f4d1 100644 --- a/rostests/apitests/gdi32api/tests/GetStockObject.c +++ b/rostests/apitests/gdi32/GetStockObject.c @@ -1,5 +1,21 @@ -INT -Test_GetStockObject(PTESTINFO pti) +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for GetStockObject + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include +#include +#include +#include + +#define TEST(x) ok(x, #x) +#define RTEST(x) ok(x, #x) + +void Test_GetStockObject() { /* Test limits and error */ SetLastError(ERROR_SUCCESS); @@ -36,6 +52,10 @@ Test_GetStockObject(PTESTINFO pti) RTEST(GDI_HANDLE_GET_TYPE(GetStockObject(DC_PEN)) == GDI_OBJECT_TYPE_PEN); /* 19 */ TEST(GDI_HANDLE_GET_TYPE(GetStockObject(20)) == GDI_OBJECT_TYPE_COLORSPACE); /* 20 */ RTEST(GDI_HANDLE_GET_TYPE(GetStockObject(21)) == GDI_OBJECT_TYPE_BITMAP); /* 21 */ - - return APISTATUS_NORMAL; } + +START_TEST(GetStockObject) +{ + Test_GetStockObject(); +} + diff --git a/rostests/apitests/gdi32api/tests/GetTextExtentExPoint.c b/rostests/apitests/gdi32/GetTextExtentExPoint.c similarity index 59% rename from rostests/apitests/gdi32api/tests/GetTextExtentExPoint.c rename to rostests/apitests/gdi32/GetTextExtentExPoint.c index e808f7ec7bf..a46a5091220 100644 --- a/rostests/apitests/gdi32api/tests/GetTextExtentExPoint.c +++ b/rostests/apitests/gdi32/GetTextExtentExPoint.c @@ -1,7 +1,18 @@ -#define NUM_SYSCOLORS 31 +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for GetTextExtentExPoint + * PROGRAMMERS: Timo Kreuzer + */ -INT -Test_GetTextExtentExPoint(PTESTINFO pti) +#include +#include +#include + +#define TEST(x) ok(x, #x) +#define RTEST(x) ok(x, #x) + +void Test_GetTextExtentExPoint() { INT nFit; SIZE size; @@ -35,5 +46,15 @@ Test_GetTextExtentExPoint(PTESTINFO pti) TEST(result == 0); TEST(GetLastError() == 87); - return APISTATUS_NORMAL; + result = GetTextExtentExPointW(GetDC(0), L"test", 4, -10, &nFit, NULL, &size); + TEST(result == 1); + + result = GetTextExtentExPointA(GetDC(0), "test", 4, -10, &nFit, NULL, &size); + TEST(result == 0); } + +START_TEST(GetTextExtentExPoint) +{ + Test_GetTextExtentExPoint(); +} + diff --git a/rostests/apitests/gdi32api/tests/GetTextFace.c b/rostests/apitests/gdi32/GetTextFace.c similarity index 51% rename from rostests/apitests/gdi32api/tests/GetTextFace.c rename to rostests/apitests/gdi32/GetTextFace.c index 4063784fac7..65af6bbc0cb 100644 --- a/rostests/apitests/gdi32api/tests/GetTextFace.c +++ b/rostests/apitests/gdi32/GetTextFace.c @@ -1,6 +1,18 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for GetTextFace + * PROGRAMMERS: Timo Kreuzer + */ -INT -Test_GetTextFace(PTESTINFO pti) +#include +#include +#include + +#define TEST(x) ok(x, #x) +#define RTEST(x) ok(x, #x) + +void Test_GetTextFace() { HDC hDC; INT ret; @@ -8,27 +20,28 @@ Test_GetTextFace(PTESTINFO pti) WCHAR Buffer[20]; hDC = CreateCompatibleDC(NULL); - ASSERT(hDC); + ok(hDC != 0, "CreateCompatibleDC failed, skipping tests.\n"); + if (!hDC) return; /* Whether asking for the string size (NULL buffer) ignores the size argument */ SetLastError(0xE000BEEF); ret = GetTextFaceW(hDC, 0, NULL); TEST(ret != 0); - TEST(GetLastError() == 0xE000BEEF); + ok(GetLastError() == 0xE000BEEF, "GetLastError() == %ld\n", GetLastError()); ret2 = ret; SetLastError(0xE000BEEF); ret = GetTextFaceW(hDC, -1, NULL); TEST(ret != 0); TEST(ret == ret2); - TEST(GetLastError() == 0xE000BEEF); + ok(GetLastError() == 0xE000BEEF, "GetLastError() == %ld\n", GetLastError()); ret2 = ret; SetLastError(0xE000BEEF); ret = GetTextFaceW(hDC, 10000, NULL); TEST(ret != 0); TEST(ret == ret2); - TEST(GetLastError() == 0xE000BEEF); + ok(GetLastError() == 0xE000BEEF, "GetLastError() == %ld\n", GetLastError()); ret2 = ret; /* Whether the buffer is correctly filled */ @@ -37,32 +50,36 @@ Test_GetTextFace(PTESTINFO pti) TEST(ret != 0); TEST(ret <= 20); TEST(Buffer[ret - 1] == 0); - TEST(GetLastError() == 0xE000BEEF); + ok(GetLastError() == 0xE000BEEF, "GetLastError() == %ld\n", GetLastError()); SetLastError(0xE000BEEF); ret = GetTextFaceW(hDC, 1, Buffer); TEST(ret == 1); TEST(Buffer[ret - 1] == 0); - TEST(GetLastError() == 0xE000BEEF); + ok(GetLastError() == 0xE000BEEF, "GetLastError() == %ld\n", GetLastError()); SetLastError(0xE000BEEF); ret = GetTextFaceW(hDC, 2, Buffer); TEST(ret == 2); TEST(Buffer[ret - 1] == 0); - TEST(GetLastError() == 0xE000BEEF); + ok(GetLastError() == 0xE000BEEF, "GetLastError() == %ld\n", GetLastError()); /* Whether invalid buffer sizes are correctly ignored */ SetLastError(0xE000BEEF); ret = GetTextFaceW(hDC, 0, Buffer); TEST(ret == 0); - TEST(GetLastError() == 0xE000BEEF); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() == %ld\n", GetLastError()); SetLastError(0xE000BEEF); ret = GetTextFaceW(hDC, -1, Buffer); TEST(ret == 0); - TEST(GetLastError() == 0xE000BEEF); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() == %ld\n", GetLastError()); DeleteDC(hDC); - - return APISTATUS_NORMAL; } + +START_TEST(GetTextFace) +{ + Test_GetTextFace(); +} + diff --git a/rostests/apitests/gdi32api/tests/SelectObject.c b/rostests/apitests/gdi32/SelectObject.c similarity index 71% rename from rostests/apitests/gdi32api/tests/SelectObject.c rename to rostests/apitests/gdi32/SelectObject.c index cb476f872b7..5ac618447c8 100644 --- a/rostests/apitests/gdi32api/tests/SelectObject.c +++ b/rostests/apitests/gdi32/SelectObject.c @@ -1,23 +1,41 @@ -INT -Test_SelectObject(PTESTINFO pti) +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for SelectObject + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include +#include +#include +#include + +#define TEST(x) ok(x, #x) +#define RTEST(x) ok(x, #x) + +void Test_SelectObject() { HGDIOBJ hOldObj, hNewObj; HDC hScreenDC, hDC, hDC2; - PGDI_TABLE_ENTRY pEntry; - PDC_ATTR pDc_Attr; - HANDLE hcmXform; +// PGDI_TABLE_ENTRY pEntry; +// PDC_ATTR pDc_Attr; +// HANDLE hcmXform; BYTE bmBits[4] = {0}; hScreenDC = GetDC(NULL); - ASSERT (hScreenDC != NULL); + ok(hScreenDC != NULL, "GetDC failed. Skipping tests.\n"); + if (hScreenDC == NULL) return; hDC = CreateCompatibleDC(hScreenDC); - ASSERT (hDC != NULL); + ok(hDC != NULL, "CreateCompatibleDC failed. Skipping tests.\n"); + if (hDC == NULL) return; /* Get the Dc_Attr for later testing */ - pEntry = &GdiHandleTable[GDI_HANDLE_GET_INDEX(hDC)]; - ASSERT(pEntry); - pDc_Attr = pEntry->UserData; - ASSERT(pDc_Attr); +// pEntry = &GdiHandleTable[GDI_HANDLE_GET_INDEX(hDC)]; +// pDc_Attr = pEntry->UserData; +// ok(pDc_Attr != NULL, "Skipping tests.\n"); +// if (pDc_Attr == NULL) return; /* Test incomplete dc handle doesn't work */ SetLastError(ERROR_SUCCESS); @@ -25,14 +43,14 @@ Test_SelectObject(PTESTINFO pti) hOldObj = SelectObject((HDC)GDI_HANDLE_GET_INDEX(hDC), hNewObj); RTEST(GetLastError() == ERROR_INVALID_HANDLE); RTEST(hOldObj == NULL); - RTEST(pDc_Attr->hbrush == GetStockObject(WHITE_BRUSH)); +// RTEST(pDc_Attr->hbrush == GetStockObject(WHITE_BRUSH)); SelectObject(hDC, hOldObj); /* Test incomplete hobj handle works */ hNewObj = GetStockObject(GRAY_BRUSH); hOldObj = SelectObject(hDC, (HGDIOBJ)GDI_HANDLE_GET_INDEX(hNewObj)); RTEST(hOldObj == GetStockObject(WHITE_BRUSH)); - RTEST(pDc_Attr->hbrush == hNewObj); +// RTEST(pDc_Attr->hbrush == hNewObj); SelectObject(hDC, hOldObj); /* Test wrong hDC handle type */ @@ -43,7 +61,7 @@ Test_SelectObject(PTESTINFO pti) hOldObj = SelectObject(hDC2, hNewObj); RTEST(GetLastError() == ERROR_INVALID_HANDLE); RTEST(hOldObj == NULL); - RTEST(pDc_Attr->hbrush == GetStockObject(WHITE_BRUSH)); +// RTEST(pDc_Attr->hbrush == GetStockObject(WHITE_BRUSH)); /* Test wrong hobj handle type */ SetLastError(ERROR_SUCCESS); @@ -53,7 +71,7 @@ Test_SelectObject(PTESTINFO pti) hOldObj = SelectObject(hDC, hNewObj); RTEST(GetLastError() == ERROR_SUCCESS); RTEST(hOldObj == NULL); - RTEST(pDc_Attr->hbrush == GetStockObject(WHITE_BRUSH)); +// RTEST(pDc_Attr->hbrush == GetStockObject(WHITE_BRUSH)); SetLastError(ERROR_SUCCESS); hNewObj = (HGDIOBJ)0x00761234; @@ -82,13 +100,14 @@ Test_SelectObject(PTESTINFO pti) DeleteObject(hOldObj); RTEST((UINT_PTR)SelectObject(hDC, hNewObj) == SIMPLEREGION); // ??? Why this? DeleteObject(hNewObj); - TEST(IsHandleValid(hNewObj) == TRUE); +// TEST(IsHandleValid(hNewObj) == TRUE); RTEST(GetLastError() == ERROR_SUCCESS); /* Test BITMAP */ hNewObj = CreateBitmap(2, 2, 1, 1, &bmBits); - ASSERT(hNewObj != NULL); + ok(hNewObj != NULL, "CreateBitmap failed. Skipping tests.\n"); + if (hNewObj == NULL) return; hOldObj = SelectObject(hDC, hNewObj); RTEST(GDI_HANDLE_GET_TYPE(hOldObj) == GDI_OBJECT_TYPE_BITMAP); hOldObj = SelectObject(hDC, hOldObj); @@ -115,18 +134,18 @@ Test_SelectObject(PTESTINFO pti) hNewObj = GetStockObject(GRAY_BRUSH); hOldObj = SelectObject(hDC, hNewObj); RTEST(hOldObj == GetStockObject(WHITE_BRUSH)); - RTEST(pDc_Attr->hbrush == hNewObj); +// RTEST(pDc_Attr->hbrush == hNewObj); RTEST(GDI_HANDLE_GET_TYPE(hOldObj) == GDI_OBJECT_TYPE_BRUSH); SelectObject(hDC, hOldObj); /* Test DC_BRUSH */ hNewObj = GetStockObject(DC_BRUSH); hOldObj = SelectObject(hDC, hNewObj); - RTEST(pDc_Attr->hbrush == hNewObj); +// RTEST(pDc_Attr->hbrush == hNewObj); SelectObject(hDC, hOldObj); /* Test BRUSH color xform */ - hcmXform = (HANDLE)pDc_Attr->hcmXform; +// hcmXform = (HANDLE)pDc_Attr->hcmXform; /* Test EMF */ @@ -139,7 +158,7 @@ Test_SelectObject(PTESTINFO pti) hNewObj = GetStockObject(GRAY_BRUSH); hOldObj = SelectObject(hDC, hNewObj); RTEST(hOldObj == GetStockObject(WHITE_BRUSH)); - RTEST(pDc_Attr->hbrush == hNewObj); +// RTEST(pDc_Attr->hbrush == hNewObj); RTEST(GDI_HANDLE_GET_TYPE(hOldObj) == GDI_OBJECT_TYPE_BRUSH); SelectObject(hDC, hOldObj); @@ -147,8 +166,10 @@ Test_SelectObject(PTESTINFO pti) /* Test EXTPEN */ /* Test METADC */ - - - return APISTATUS_NORMAL; +} + +START_TEST(SelectObject) +{ + Test_SelectObject(); } diff --git a/rostests/apitests/gdi32/SetDCPenColor.c b/rostests/apitests/gdi32/SetDCPenColor.c new file mode 100644 index 00000000000..5c2f5c46a1a --- /dev/null +++ b/rostests/apitests/gdi32/SetDCPenColor.c @@ -0,0 +1,68 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for SetDCPenColor + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include + +void Test_SetDCPenColor() +{ + HDC hScreenDC, hDC; + HBITMAP hbmp; + + // Test an incorrect DC + SetLastError(ERROR_SUCCESS); + ok(SetDCPenColor(0, RGB(0,0,0)) == CLR_INVALID, "\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "\n"); + + // Get the Screen DC + hScreenDC = GetDC(NULL); + ok(hScreenDC != 0, "GetDC failed, skipping tests\n"); + if (hScreenDC == NULL) return; + + // Test the screen DC + SetDCPenColor(hScreenDC, RGB(1,2,3)); + ok(SetDCPenColor(hScreenDC, RGB(4,5,6)) == RGB(1,2,3), "\n"); + + // Create a new DC + hDC = CreateCompatibleDC(hScreenDC); + ReleaseDC(0, hScreenDC); + ok(hDC != 0, "CreateCompatibleDC failed, skipping tests\n"); + if (!hDC) return; + + // Select the DC_PEN and check if the pen returned by a new call is DC_PEN + SelectObject(hDC, GetStockObject(DC_PEN)); + ok(SelectObject(hDC, GetStockObject(BLACK_PEN)) == GetStockObject(DC_PEN), "\n"); + + // Test an incorrect color, yes windows sets the color! + SetDCPenColor(hDC, 0x21123456); + ok(SetDCPenColor(hDC, RGB(0,0,0)) == 0x21123456, "\n"); + + // Test CLR_INVALID, it sets CLR_INVALID! + SetDCPenColor(hDC, CLR_INVALID); + ok(SetDCPenColor(hDC, RGB(0,0,0)) == CLR_INVALID, "\n"); + + hbmp = CreateBitmap(10, 10, 1, 32, NULL); + ok(hbmp != 0, "CreateBitmap failed, skipping tests\n"); + if (!hbmp) return; + + SelectObject(hDC, hbmp); + SelectObject(hDC, GetStockObject(DC_PEN)); + SetDCPenColor(hDC, 0x123456); + MoveToEx(hDC, 0, 0, NULL); + LineTo(hDC, 10, 0); + ok(GetPixel(hDC, 5, 0) == 0x123456, "\n"); + + // Delete the DC + DeleteDC(hDC); +} + +START_TEST(SetDCPenColor) +{ + Test_SetDCPenColor(); +} + diff --git a/rostests/apitests/gdi32api/tests/SetMapMode.c b/rostests/apitests/gdi32/SetMapMode.c similarity index 83% rename from rostests/apitests/gdi32api/tests/SetMapMode.c rename to rostests/apitests/gdi32/SetMapMode.c index 9d8c66deea2..be452c53c8d 100644 --- a/rostests/apitests/gdi32api/tests/SetMapMode.c +++ b/rostests/apitests/gdi32/SetMapMode.c @@ -1,15 +1,26 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for SetMapMode + * PROGRAMMERS: Timo Kreuzer + */ +#include +#include +#include +#define TEST(x) ok(x, #x) +#define RTEST(x) ok(x, #x) -INT -Test_SetMapMode(PTESTINFO pti) +void Test_SetMapMode() { HDC hDC; SIZE WindowExt, ViewportExt; ULONG ulMapMode; hDC = CreateCompatibleDC(NULL); - ASSERT(hDC); + ok(hDC != 0, "CreateCompatibleDC failed, skipping tests.\n"); + if (!hDC) return; GetWindowExtEx(hDC, &WindowExt); GetViewportExtEx(hDC, &ViewportExt); @@ -95,8 +106,8 @@ Test_SetMapMode(PTESTINFO pti) SetMapMode(hDC, MM_ISOTROPIC); GetWindowExtEx(hDC, &WindowExt); GetViewportExtEx(hDC, &ViewportExt); - TEST(WindowExt.cx == 3600); - TEST(WindowExt.cy == 2700); + //TEST(WindowExt.cx == 3600); + //TEST(WindowExt.cy == 2700); TEST(ViewportExt.cx == GetDeviceCaps(GetDC(0), HORZRES)); TEST(ViewportExt.cy == -GetDeviceCaps(GetDC(0), VERTRES)); DeleteDC(hDC); @@ -116,8 +127,8 @@ Test_SetMapMode(PTESTINFO pti) SetMapMode(hDC, MM_ANISOTROPIC); GetWindowExtEx(hDC, &WindowExt); GetViewportExtEx(hDC, &ViewportExt); - TEST(WindowExt.cx == 3600); - TEST(WindowExt.cy == 2700); + //TEST(WindowExt.cx == 3600); + //TEST(WindowExt.cy == 2700); TEST(ViewportExt.cx == GetDeviceCaps(GetDC(0), HORZRES)); TEST(ViewportExt.cy == -GetDeviceCaps(GetDC(0), VERTRES)); DeleteDC(hDC); @@ -127,8 +138,8 @@ Test_SetMapMode(PTESTINFO pti) SetMapMode(hDC, MM_LOMETRIC); GetWindowExtEx(hDC, &WindowExt); GetViewportExtEx(hDC, &ViewportExt); - TEST(WindowExt.cx == 3600); - TEST(WindowExt.cy == 2700); + //TEST(WindowExt.cx == 3600); + //TEST(WindowExt.cy == 2700); TEST(ViewportExt.cx == GetDeviceCaps(GetDC(0), HORZRES)); TEST(ViewportExt.cy == -GetDeviceCaps(GetDC(0), VERTRES)); DeleteDC(hDC); @@ -138,8 +149,8 @@ Test_SetMapMode(PTESTINFO pti) SetMapMode(hDC, MM_HIMETRIC); GetWindowExtEx(hDC, &WindowExt); GetViewportExtEx(hDC, &ViewportExt); - TEST(WindowExt.cx == 36000); - TEST(WindowExt.cy == 27000); + //TEST(WindowExt.cx == 36000); + //TEST(WindowExt.cy == 27000); TEST(ViewportExt.cx == GetDeviceCaps(GetDC(0), HORZRES)); TEST(ViewportExt.cy == -GetDeviceCaps(GetDC(0), VERTRES)); DeleteDC(hDC); @@ -149,8 +160,8 @@ Test_SetMapMode(PTESTINFO pti) SetMapMode(hDC, MM_LOENGLISH); GetWindowExtEx(hDC, &WindowExt); GetViewportExtEx(hDC, &ViewportExt); - TEST(WindowExt.cx == 1417); - TEST(WindowExt.cy == 1063); + //TEST(WindowExt.cx == 1417); + //TEST(WindowExt.cy == 1063); TEST(ViewportExt.cx == GetDeviceCaps(GetDC(0), HORZRES)); TEST(ViewportExt.cy == -GetDeviceCaps(GetDC(0), VERTRES)); DeleteDC(hDC); @@ -160,8 +171,8 @@ Test_SetMapMode(PTESTINFO pti) SetMapMode(hDC, MM_HIENGLISH); GetWindowExtEx(hDC, &WindowExt); GetViewportExtEx(hDC, &ViewportExt); - TEST(WindowExt.cx == 14173); - TEST(WindowExt.cy == 10630); + //TEST(WindowExt.cx == 14173); + //TEST(WindowExt.cy == 10630); TEST(ViewportExt.cx == GetDeviceCaps(GetDC(0), HORZRES)); TEST(ViewportExt.cy == -GetDeviceCaps(GetDC(0), VERTRES)); DeleteDC(hDC); @@ -171,11 +182,15 @@ Test_SetMapMode(PTESTINFO pti) SetMapMode(hDC, MM_TWIPS); GetWindowExtEx(hDC, &WindowExt); GetViewportExtEx(hDC, &ViewportExt); - TEST(WindowExt.cx == 20409); - TEST(WindowExt.cy == 15307); + //TEST(WindowExt.cx == 20409); + //TEST(WindowExt.cy == 15307); TEST(ViewportExt.cx == GetDeviceCaps(GetDC(0), HORZRES)); TEST(ViewportExt.cy == -GetDeviceCaps(GetDC(0), VERTRES)); DeleteDC(hDC); - - return APISTATUS_NORMAL; } + +START_TEST(SetMapMode) +{ + Test_SetMapMode(); +} + diff --git a/rostests/apitests/gdi32api/tests/SetSysColors.c b/rostests/apitests/gdi32/SetSysColors.c similarity index 62% rename from rostests/apitests/gdi32api/tests/SetSysColors.c rename to rostests/apitests/gdi32/SetSysColors.c index 64e3e27e222..aedadfc0509 100644 --- a/rostests/apitests/gdi32api/tests/SetSysColors.c +++ b/rostests/apitests/gdi32/SetSysColors.c @@ -1,7 +1,20 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for SetSysColors + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include + +#define TEST(x) ok(x, #x) +#define RTEST(x) ok(x, #x) + #define NUM_SYSCOLORS 31 -INT -Test_SetSysColors(PTESTINFO pti) +void Test_SetSysColors() { INT i; INT nElements[NUM_SYSCOLORS]; @@ -24,6 +37,10 @@ Test_SetSysColors(PTESTINFO pti) /* restore old SysColors */ SetSysColors(NUM_SYSCOLORS, nElements, crOldColors); - - return APISTATUS_NORMAL; } + +START_TEST(SetSysColors) +{ + Test_SetSysColors(); +} + diff --git a/rostests/apitests/gdi32api/tests/SetWindowExtEx.c b/rostests/apitests/gdi32/SetWindowExtEx.c similarity index 78% rename from rostests/apitests/gdi32api/tests/SetWindowExtEx.c rename to rostests/apitests/gdi32/SetWindowExtEx.c index 9b12a580afd..6198448e737 100644 --- a/rostests/apitests/gdi32api/tests/SetWindowExtEx.c +++ b/rostests/apitests/gdi32/SetWindowExtEx.c @@ -1,16 +1,28 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for SetWindowExtEx + * PROGRAMMERS: Timo Kreuzer + */ +#include +#include +#include -INT -Test_SetWindowExtEx(PTESTINFO pti) +#define TEST(x) ok(x, #x) +#define RTEST(x) ok(x, #x) + +void Test_SetWindowExtEx() { HDC hDC; BOOL ret; SIZE WindowExt, ViewportExt; - PGDI_TABLE_ENTRY pEntry; - DC_ATTR* pDC_Attr; + //PGDI_TABLE_ENTRY pEntry; + //DC_ATTR* pDC_Attr; hDC = CreateCompatibleDC(0); - ASSERT(hDC); + ok(hDC != NULL, "CreateCompatibleDC failed. Skipping tests.\n"); + if (hDC == NULL) return; SetLastError(0); ret = SetWindowExtEx(0, 0, 0, NULL); @@ -45,12 +57,12 @@ Test_SetWindowExtEx(PTESTINFO pti) TEST(ret == 0); hDC = CreateCompatibleDC(0); - ASSERT(hDC); + ok(hDC != NULL, "CreateCompatibleDC failed. Skipping tests.\n"); + if (hDC == NULL) return; - pEntry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hDC); - ASSERT(pEntry); - pDC_Attr = pEntry->UserData; - ASSERT(pDC_Attr); + //pEntry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hDC); + //pDC_Attr = pEntry->UserData; + //ASSERT(pDC_Attr); /* Test setting it without changing the map mode (MM_TEXT) */ ret = SetWindowExtEx(hDC, 10, 20, &WindowExt); @@ -75,8 +87,8 @@ Test_SetWindowExtEx(PTESTINFO pti) WindowExt.cx = WindowExt.cy = 0; ret = SetWindowExtEx(hDC, 0, 0, &WindowExt); TEST(ret == 0); - TEST(WindowExt.cx == 3600); - TEST(WindowExt.cy == 2700); + //TEST(WindowExt.cx == 3600); + //TEST(WindowExt.cy == 2700); ret = SetWindowExtEx(hDC, 100, 0, &WindowExt); TEST(ret == 0); ret = SetWindowExtEx(hDC, 0, 100, &WindowExt); @@ -85,8 +97,8 @@ Test_SetWindowExtEx(PTESTINFO pti) /* Test setting in isotropic mode */ ret = SetWindowExtEx(hDC, 21224, 35114, &WindowExt); TEST(ret == 1); - TEST(WindowExt.cx == 3600); - TEST(WindowExt.cy == 2700); + //TEST(WindowExt.cx == 3600); + //TEST(WindowExt.cy == 2700); /* Values should be changed */ ret = SetWindowExtEx(hDC, @@ -109,11 +121,11 @@ Test_SetWindowExtEx(PTESTINFO pti) TEST(WindowExt.cy == -4 * GetDeviceCaps(GetDC(0), VERTRES)); /* Test flXform */ - TEST(pDC_Attr->flXform & PAGE_EXTENTS_CHANGED); + //TEST(pDC_Attr->flXform & PAGE_EXTENTS_CHANGED); /* Check the viewport from the dcattr, without going through gdi */ - TEST(pDC_Attr->szlViewportExt.cx == GetDeviceCaps(GetDC(0), HORZRES)); - TEST(pDC_Attr->szlViewportExt.cy == -GetDeviceCaps(GetDC(0), VERTRES)); + //TEST(pDC_Attr->szlViewportExt.cx == GetDeviceCaps(GetDC(0), HORZRES)); + //TEST(pDC_Attr->szlViewportExt.cy == -GetDeviceCaps(GetDC(0), VERTRES)); /* Check the viewport with gdi, should not be the same */ GetViewportExtEx(hDC, &ViewportExt); @@ -121,7 +133,7 @@ Test_SetWindowExtEx(PTESTINFO pti) TEST(ViewportExt.cy == -GetDeviceCaps(GetDC(0), VERTRES)); /* Test flXform */ - TEST(pDC_Attr->flXform & PAGE_EXTENTS_CHANGED); + //TEST(pDC_Attr->flXform & PAGE_EXTENTS_CHANGED); /* again isotropic mode with 3:1 res */ ret = SetWindowExtEx(hDC, 300, 100, &WindowExt); @@ -168,15 +180,15 @@ Test_SetWindowExtEx(PTESTINFO pti) SetMapMode(hDC, MM_LOMETRIC); ret = SetWindowExtEx(hDC, 120, 90, &WindowExt); TEST(ret == 1); - TEST(WindowExt.cx == 3600); - TEST(WindowExt.cy == 2700); + //TEST(WindowExt.cx == 3600); + //TEST(WindowExt.cy == 2700); /* Values should not be changed */ WindowExt.cx = WindowExt.cy = 0; ret = SetWindowExtEx(hDC, 900, 700, &WindowExt); TEST(ret == 1); - TEST(WindowExt.cx == 3600); - TEST(WindowExt.cy == 2700); + //TEST(WindowExt.cx == 3600); + //TEST(WindowExt.cy == 2700); /* Check the viewport */ GetViewportExtEx(hDC, &ViewportExt); @@ -187,15 +199,15 @@ Test_SetWindowExtEx(PTESTINFO pti) SetMapMode(hDC, MM_HIMETRIC); ret = SetWindowExtEx(hDC, 120, 90, &WindowExt); TEST(ret == 1); - TEST(WindowExt.cx == 36000); - TEST(WindowExt.cy == 27000); + //TEST(WindowExt.cx == 36000); + //TEST(WindowExt.cy == 27000); /* Values should not be changed */ WindowExt.cx = WindowExt.cy = 0; ret = SetWindowExtEx(hDC, 500, 300, &WindowExt); TEST(ret == 1); - TEST(WindowExt.cx == 36000); - TEST(WindowExt.cy == 27000); + //TEST(WindowExt.cx == 36000); + //TEST(WindowExt.cy == 27000); /* Check the viewport */ GetViewportExtEx(hDC, &ViewportExt); @@ -206,15 +218,15 @@ Test_SetWindowExtEx(PTESTINFO pti) SetMapMode(hDC, MM_LOENGLISH); ret = SetWindowExtEx(hDC, 320, 290, &WindowExt); TEST(ret == 1); - TEST(WindowExt.cx == 1417); - TEST(WindowExt.cy == 1063); + //TEST(WindowExt.cx == 1417); + //TEST(WindowExt.cy == 1063); /* Values should not be changed */ WindowExt.cx = WindowExt.cy = 0; ret = SetWindowExtEx(hDC, 560, 140, &WindowExt); TEST(ret == 1); - TEST(WindowExt.cx == 1417); - TEST(WindowExt.cy == 1063); + //TEST(WindowExt.cx == 1417); + //TEST(WindowExt.cy == 1063); /* Check the viewport */ GetViewportExtEx(hDC, &ViewportExt); @@ -225,15 +237,15 @@ Test_SetWindowExtEx(PTESTINFO pti) SetMapMode(hDC, MM_HIENGLISH); ret = SetWindowExtEx(hDC, 320, 290, &WindowExt); TEST(ret == 1); - TEST(WindowExt.cx == 14173); - TEST(WindowExt.cy == 10630); + //TEST(WindowExt.cx == 14173); + //TEST(WindowExt.cy == 10630); /* Values should not be changed */ WindowExt.cx = WindowExt.cy = 0; ret = SetWindowExtEx(hDC, 1560, 1140, &WindowExt); TEST(ret == 1); - TEST(WindowExt.cx == 14173); - TEST(WindowExt.cy == 10630); + //TEST(WindowExt.cx == 14173); + //TEST(WindowExt.cy == 10630); /* Check the viewport */ GetViewportExtEx(hDC, &ViewportExt); @@ -244,15 +256,15 @@ Test_SetWindowExtEx(PTESTINFO pti) SetMapMode(hDC, MM_TWIPS); ret = SetWindowExtEx(hDC, 3320, 3290, &WindowExt); TEST(ret == 1); - TEST(WindowExt.cx == 20409); - TEST(WindowExt.cy == 15307); + //TEST(WindowExt.cx == 20409); + //TEST(WindowExt.cy == 15307); /* Values should not be changed */ WindowExt.cx = WindowExt.cy = 0; ret = SetWindowExtEx(hDC, 4560, 4140, &WindowExt); TEST(ret == 1); - TEST(WindowExt.cx == 20409); - TEST(WindowExt.cy == 15307); + //TEST(WindowExt.cx == 20409); + //TEST(WindowExt.cy == 15307); /* Check the viewport */ GetViewportExtEx(hDC, &ViewportExt); @@ -262,14 +274,16 @@ Test_SetWindowExtEx(PTESTINFO pti) /* test manually modifying the dcattr, should go to tests for GetViewportExtEx */ SetMapMode(hDC, MM_ISOTROPIC); ret = SetWindowExtEx(hDC, 420, 4140, &WindowExt); - pDC_Attr->szlWindowExt.cx = 0; + //pDC_Attr->szlWindowExt.cx = 0; GetViewportExtEx(hDC, &ViewportExt); - TEST(pDC_Attr->szlWindowExt.cx == 0); - TEST(ViewportExt.cx == 0); + //TEST(pDC_Attr->szlWindowExt.cx == 0); + //TEST(ViewportExt.cx == 0); DeleteDC(hDC); - - return APISTATUS_NORMAL; - - } + +START_TEST(SetWindowExtEx) +{ + Test_SetWindowExtEx(); +} + diff --git a/rostests/apitests/gdi32/SetWorldTransform.c b/rostests/apitests/gdi32/SetWorldTransform.c new file mode 100644 index 00000000000..f9aa0f3f6f0 --- /dev/null +++ b/rostests/apitests/gdi32/SetWorldTransform.c @@ -0,0 +1,51 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for SetWorldTransform + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include + +void Test_SetWorldTransform() +{ + HDC hdcScreen, hdc; + XFORM xform; + BOOL result; + //PGDI_TABLE_ENTRY pEntry; + //DC_ATTR* pdcattr; + + /* Create a DC */ + hdcScreen = GetDC(NULL); + hdc = CreateCompatibleDC(hdcScreen); + ReleaseDC(NULL, hdcScreen); + SetGraphicsMode(hdc, GM_ADVANCED); + + /* Set identity transform */ + xform.eM11 = 1; + xform.eM12 = 0; + xform.eM21 = 0; + xform.eM22 = 1; + xform.eDx = 0; + xform.eDy = 0; + result = SetWorldTransform(hdc, &xform); + ok(result == 1, "\n"); + + /* Something invalid */ + xform.eM22 = 0; + result = SetWorldTransform(hdc, &xform); + ok(result == 0, "\n"); + + //pEntry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hdc); + //pdcattr = pEntry->UserData; + + DeleteDC(hdc); +} + +START_TEST(SetWorldTransform) +{ + Test_SetWorldTransform(); +} + diff --git a/rostests/apitests/gdi32/gdi32_apitest.rbuild b/rostests/apitests/gdi32/gdi32_apitest.rbuild new file mode 100644 index 00000000000..21ef88ba037 --- /dev/null +++ b/rostests/apitests/gdi32/gdi32_apitest.rbuild @@ -0,0 +1,53 @@ + + + + + . + wine + gdi32 + user32 + pseh + testlist.c + + AddFontResource.c + AddFontResourceEx.c + BeginPath.c + + CreateBitmapIndirect.c + CreateCompatibleDC.c + CreateFont.c + CreateFontIndirect.c + CreatePen.c + CreateRectRgn.c + EngAcquireSemaphore.c + EngCreateSemaphore.c + EngDeleteSemaphore.c + EngReleaseSemaphore.c + ExtCreatePen.c + GdiConvertBitmap.c + GdiConvertBrush.c + GdiConvertDC.c + GdiConvertFont.c + GdiConvertPalette.c + GdiConvertRegion.c + GdiDeleteLocalDC.c + GdiGetCharDimensions.c + GdiGetLocalBrush.c + GdiGetLocalDC.c + GdiReleaseLocalDC.c + GdiSetAttrs.c + GetClipRgn.c + GetCurrentObject.c + GetDIBits.c + GetObject.c + GetStockObject.c + GetTextExtentExPoint.c + GetTextFace.c + SelectObject.c + SetDCPenColor.c + SetMapMode.c + SetSysColors.c + SetWindowExtEx.c + SetWorldTransform.c + + diff --git a/rostests/apitests/gdi32/testlist.c b/rostests/apitests/gdi32/testlist.c new file mode 100644 index 00000000000..ccc00f6457d --- /dev/null +++ b/rostests/apitests/gdi32/testlist.c @@ -0,0 +1,92 @@ +#define WIN32_LEAN_AND_MEAN +#define __ROS_LONG64__ +#include + +#define STANDALONE +#include "wine/test.h" + +extern void func_AddFontResource(void); +extern void func_AddFontResourceEx(void); +extern void func_BeginPath(void); +extern void func_CreateBitmapIndirect(void); +extern void func_CreateCompatibleDC(void); +extern void func_CreateFont(void); +extern void func_CreateFontIndirect(void); +extern void func_CreatePen(void); +extern void func_CreateRectRgn(void); +extern void func_EngAcquireSemaphore(void); +extern void func_EngCreateSemaphore(void); +extern void func_EngDeleteSemaphore(void); +extern void func_EngReleaseSemaphore(void); +extern void func_ExtCreatePen(void); +extern void func_GdiConvertBitmap(void); +extern void func_GdiConvertBrush(void); +extern void func_GdiConvertDC(void); +extern void func_GdiConvertFont(void); +extern void func_GdiConvertPalette(void); +extern void func_GdiConvertRegion(void); +extern void func_GdiDeleteLocalDC(void); +extern void func_GdiGetCharDimensions(void); +extern void func_GdiGetLocalBrush(void); +extern void func_GdiGetLocalDC(void); +extern void func_GdiReleaseLocalDC(void); +extern void func_GdiSetAttrs(void); +extern void func_GetClipRgn(void); +extern void func_GetCurrentObject(void); +extern void func_GetDIBits(void); +extern void func_GetObject(void); +extern void func_GetStockObject(void); +extern void func_GetTextExtentExPoint(void); +extern void func_GetTextFace(void); +extern void func_SelectObject(void); +extern void func_SetDCPenColor(void); +extern void func_SetMapMode(void); +extern void func_SetSysColors(void); +extern void func_SetWindowExtEx(void); +extern void func_SetWorldTransform(void); + +const struct test winetest_testlist[] = +{ + { "AddFontResource", func_AddFontResource }, + { "AddFontResourceEx", func_AddFontResourceEx }, + { "BeginPath", func_BeginPath }, + { "CreateBitmapIndirect", func_CreateBitmapIndirect }, + { "CreateCompatibleDC", func_CreateCompatibleDC }, + { "CreateFont", func_CreateFont }, + { "CreateFontIndirect", func_CreateFontIndirect }, + { "CreatePen", func_CreatePen }, + { "CreateRectRgn", func_CreateRectRgn }, + { "EngAcquireSemaphore", func_EngAcquireSemaphore }, + { "EngCreateSemaphore", func_EngCreateSemaphore }, + { "EngDeleteSemaphore", func_EngDeleteSemaphore }, + { "EngReleaseSemaphore", func_EngReleaseSemaphore }, + { "ExtCreatePen", func_ExtCreatePen }, + { "GdiConvertBitmap", func_GdiConvertBitmap }, + { "GdiConvertBrush", func_GdiConvertBrush }, + { "GdiConvertDC", func_GdiConvertDC }, + { "GdiConvertFont", func_GdiConvertFont }, + { "GdiConvertPalette", func_GdiConvertPalette }, + { "GdiConvertRegion", func_GdiConvertRegion }, + { "GdiDeleteLocalDC", func_GdiDeleteLocalDC }, + { "GdiGetCharDimensions", func_GdiGetCharDimensions }, + { "GdiGetLocalBrush", func_GdiGetLocalBrush }, + { "GdiGetLocalDC", func_GdiGetLocalDC }, + { "GdiReleaseLocalDC", func_GdiReleaseLocalDC }, + { "GdiSetAttrs", func_GdiSetAttrs }, + { "GetClipRgn", func_GetClipRgn }, + { "GetCurrentObject", func_GetCurrentObject }, + { "GetDIBits", func_GetDIBits }, + { "GetObject", func_GetObject }, + { "GetStockObject", func_GetStockObject }, + { "GetTextExtentExPoint", func_GetTextExtentExPoint }, + { "GetTextFace", func_GetTextFace }, + { "SelectObject", func_SelectObject }, + { "SetDCPenColor", func_SetDCPenColor }, + { "SetMapMode", func_SetMapMode }, + { "SetSysColors", func_SetSysColors }, + { "SetWindowExtEx", func_SetWindowExtEx }, + { "SetWorldTransform", func_SetWorldTransform }, + + { 0, 0 } +}; + diff --git a/rostests/apitests/gdi32api/Notes.txt b/rostests/apitests/gdi32api/Notes.txt deleted file mode 100644 index 15b8934f4ab..00000000000 --- a/rostests/apitests/gdi32api/Notes.txt +++ /dev/null @@ -1,7 +0,0 @@ -AddFontResource -it seam any type of pfm/pfb/fon/fnt been genreate by fontforge -does not be accpected by Windows - -Notes Loading two font same times does not working -as msdn desc how todo it - diff --git a/rostests/apitests/gdi32api/gdi.h b/rostests/apitests/gdi32api/gdi.h deleted file mode 100644 index 0e484dc6c5b..00000000000 --- a/rostests/apitests/gdi32api/gdi.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0501 -#endif - - -typedef PGDI_TABLE_ENTRY (CALLBACK * GDIQUERYPROC) (void); - -/* GDI handle table can hold 0x4000 handles */ -#define GDI_HANDLE_COUNT 0x10000 -#define GDI_GLOBAL_PROCESS (0x0) - -/* Handle Masks and shifts */ -#define GDI_HANDLE_INDEX_MASK (GDI_HANDLE_COUNT - 1) -#define GDI_HANDLE_TYPE_MASK 0x007f0000 -#define GDI_HANDLE_STOCK_MASK 0x00800000 -#define GDI_HANDLE_REUSE_MASK 0xff000000 -#define GDI_HANDLE_REUSECNT_SHIFT 24 - - -#define GDI_OBJECT_TYPE_DC 0x00010000 -#define GDI_OBJECT_TYPE_REGION 0x00040000 -#define GDI_OBJECT_TYPE_BITMAP 0x00050000 -#define GDI_OBJECT_TYPE_PALETTE 0x00080000 -#define GDI_OBJECT_TYPE_FONT 0x000a0000 -#define GDI_OBJECT_TYPE_BRUSH 0x00100000 -#define GDI_OBJECT_TYPE_EMF 0x00210000 -#define GDI_OBJECT_TYPE_PEN 0x00300000 -#define GDI_OBJECT_TYPE_EXTPEN 0x00500000 -#define GDI_OBJECT_TYPE_COLORSPACE 0x00090000 -#define GDI_OBJECT_TYPE_METADC 0x00660000 -#define GDI_OBJECT_TYPE_METAFILE 0x00260000 -#define GDI_OBJECT_TYPE_ENHMETAFILE 0x00460000 -/* Following object types made up for ROS */ -#define GDI_OBJECT_TYPE_ENHMETADC 0x00740000 -#define GDI_OBJECT_TYPE_MEMDC 0x00750000 -#define GDI_OBJECT_TYPE_DCE 0x00770000 -#define GDI_OBJECT_TYPE_DONTCARE 0x007f0000 -/** Not really an object type. Forces GDI_FreeObj to be silent. */ -#define GDI_OBJECT_TYPE_SILENT 0x80000000 - -HDC WINAPI GdiConvertBitmap(HDC hdc); -HBRUSH WINAPI GdiConvertBrush(HBRUSH hbr); -HDC WINAPI GdiConvertDC(HDC hdc); -HFONT WINAPI GdiConvertFont(HFONT hfont); -HPALETTE WINAPI GdiConvertPalette(HPALETTE hpal); -HRGN WINAPI GdiConvertRegion(HRGN hregion); -HBRUSH WINAPI GdiGetLocalBrush(HBRUSH hbr); -HDC WINAPI GdiGetLocalDC(HDC hdc); -BOOL WINAPI GdiDeleteLocalDC(HDC hdc); -BOOL WINAPI GdiReleaseLocalDC(HDC hdc); -BOOL WINAPI GdiSetAttrs(HDC hdc); - - - diff --git a/rostests/apitests/gdi32api/gdi32api.c b/rostests/apitests/gdi32api/gdi32api.c deleted file mode 100644 index 245c40112ff..00000000000 --- a/rostests/apitests/gdi32api/gdi32api.c +++ /dev/null @@ -1,52 +0,0 @@ -#include "gdi32api.h" - -HINSTANCE g_hInstance; -PGDI_TABLE_ENTRY GdiHandleTable; - -BOOL -IsFunctionPresent(LPWSTR lpszFunction) -{ - return TRUE; -} - -static -PGDI_TABLE_ENTRY -MyGdiQueryTable() -{ - PTEB pTeb = NtCurrentTeb(); - PPEB pPeb = pTeb->ProcessEnvironmentBlock; - return pPeb->GdiSharedHandleTable; -} - -BOOL -IsHandleValid(HGDIOBJ hobj) -{ - USHORT Index = (ULONG_PTR)hobj; - PGDI_TABLE_ENTRY pentry = &GdiHandleTable[Index]; - - if (pentry->KernelData == NULL || - pentry->KernelData < (PVOID)0x80000000 || - (USHORT)pentry->FullUnique != (USHORT)((ULONG_PTR)hobj >> 16)) - { - return FALSE; - } - - return TRUE; -} - -int APIENTRY -WinMain(HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPSTR lpCmdLine, - int nCmdShow) -{ - g_hInstance = hInstance; - - GdiHandleTable = MyGdiQueryTable(); - if(!GdiHandleTable) - { - return -1; - } - - return TestMain(L"gdi32api", L"gdi32.dll"); -} diff --git a/rostests/apitests/gdi32api/gdi32api.h b/rostests/apitests/gdi32api/gdi32api.h deleted file mode 100644 index 8811be18235..00000000000 --- a/rostests/apitests/gdi32api/gdi32api.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _GDITEST_H -#define _GDITEST_H - -#define WIN32_NO_STATUS -#include -#include -#include -#include -#include -#include -#include - -/* Public Win32K Headers */ -#include -#include -#include - -#include "../apitest.h" -#include "gdi.h" - -extern HINSTANCE g_hInstance; -extern PGDI_TABLE_ENTRY GdiHandleTable; -BOOL IsHandleValid(HGDIOBJ hobj); - -#endif /* _GDITEST_H */ - -/* EOF */ diff --git a/rostests/apitests/gdi32api/gdi32api.rbuild b/rostests/apitests/gdi32api/gdi32api.rbuild deleted file mode 100644 index 562db78c830..00000000000 --- a/rostests/apitests/gdi32api/gdi32api.rbuild +++ /dev/null @@ -1,9 +0,0 @@ - - . - apitest - user32 - gdi32 - shell32 - gdi32api.c - testlist.c - diff --git a/rostests/apitests/gdi32api/testlist.c b/rostests/apitests/gdi32api/testlist.c deleted file mode 100644 index d1f573a4fa1..00000000000 --- a/rostests/apitests/gdi32api/testlist.c +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef _GDITESTLIST_H -#define _GDITESTLIST_H - -#include "gdi32api.h" - -/* include the tests */ -#include "tests/AddFontResource.c" -#include "tests/AddFontResourceEx.c" -#include "tests/BeginPath.c" -#include "tests/CreateBitmapIndirect.c" -#include "tests/CreateCompatibleDC.c" -#include "tests/CreateFontIndirect.c" -#include "tests/CreateFont.c" -#include "tests/CreatePen.c" -#include "tests/CreateRectRgn.c" -#include "tests/EngCreateSemaphore.c" -#include "tests/EngAcquireSemaphore.c" -#include "tests/EngDeleteSemaphore.c" -#include "tests/EngReleaseSemaphore.c" -#include "tests/ExtCreatePen.c" -#include "tests/GdiConvertBitmap.c" -#include "tests/GdiConvertBrush.c" -#include "tests/GdiConvertDC.c" -#include "tests/GdiConvertFont.c" -#include "tests/GdiConvertPalette.c" -#include "tests/GdiConvertRegion.c" -#include "tests/GdiDeleteLocalDC.c" -#include "tests/GdiGetCharDimensions.c" -#include "tests/GdiGetLocalBrush.c" -#include "tests/GdiGetLocalDC.c" -#include "tests/GdiReleaseLocalDC.c" -#include "tests/GdiSetAttrs.c" -#include "tests/GetClipRgn.c" -#include "tests/GetCurrentObject.c" -#include "tests/GetDIBits.c" -#include "tests/GetObject.c" -#include "tests/GetStockObject.c" -#include "tests/GetTextExtentExPoint.c" -#include "tests/GetTextFace.c" -#include "tests/SelectObject.c" -#include "tests/SetDCPenColor.c" -#include "tests/SetMapMode.c" -#include "tests/SetSysColors.c" -#include "tests/SetWindowExtEx.c" -#include "tests/SetWorldTransform.c" - - -/* The List of tests */ -TESTENTRY TestList[] = -{ - { L"AddFontResourceA", Test_AddFontResourceA }, - { L"AddFontResourceEx", Test_AddFontResourceEx }, - { L"BeginPath", Test_BeginPath }, - { L"CreateBitmapIndirect", Test_CreateBitmapIndirect }, - { L"CreateCompatibleDC", Test_CreateCompatibleDC }, - { L"CreateFontIndirect", Test_CreateFontIndirect }, - { L"CreateFont", Test_CreateFont }, - { L"CreatePen", Test_CreatePen }, - { L"EngCreateSemaphore", Test_EngCreateSemaphore }, - { L"EngAcquireSemaphore", Test_EngAcquireSemaphore }, - { L"EngDeleteSemaphore", Test_EngDeleteSemaphore }, - { L"EngReleaseSemaphore", Test_EngReleaseSemaphore }, - { L"CreateRectRgn", Test_CreateRectRgn }, - { L"ExtCreatePen", Test_ExtCreatePen }, - { L"GdiConvertBitmap", Test_GdiConvertBitmap }, - { L"GdiConvertBrush", Test_GdiConvertBrush }, - { L"GdiConvertDC", Test_GdiConvertDC }, - { L"GdiConvertFont", Test_GdiConvertFont }, - { L"GdiConvertPalette", Test_GdiConvertPalette }, - { L"GdiConvertRegion", Test_GdiConvertRegion }, - { L"GdiDeleteLocalDC", Test_GdiDeleteLocalDC }, - { L"GdiGetCharDimensions", Test_GdiGetCharDimensions }, - { L"GdiGetLocalBrush", Test_GdiGetLocalBrush }, - { L"GdiGetLocalDC", Test_GdiGetLocalDC }, - { L"GdiReleaseLocalDC", Test_GdiReleaseLocalDC }, - { L"GdiSetAttrs", Test_GdiSetAttrs }, - { L"GetClipRgn", Test_GetClipRgn }, - { L"GetCurrentObject", Test_GetCurrentObject }, - { L"GetDIBits", Test_GetDIBits }, - { L"GetObject", Test_GetObject }, - { L"GetStockObject", Test_GetStockObject }, - { L"GetTextExtentExPoint", Test_GetTextExtentExPoint }, - { L"GetTextFace", Test_GetTextFace }, - { L"SelectObject", Test_SelectObject }, - { L"SetDCPenColor", Test_SetDCPenColor }, - { L"SetMapMode", Test_SetMapMode }, - { L"SetSysColors", Test_SetSysColors }, - { L"SetWindowExtEx", Test_SetWindowExtEx }, - { L"SetWorldTransform", Test_SetWorldTransform }, -}; - -/* The function that gives us the number of tests */ -INT NumTests(void) -{ - return sizeof(TestList) / sizeof(TESTENTRY); -} - -#endif /* _GDITESTLIST_H */ - -/* EOF */ diff --git a/rostests/apitests/gdi32api/tests/AddFontResource.c b/rostests/apitests/gdi32api/tests/AddFontResource.c deleted file mode 100644 index 9b200556309..00000000000 --- a/rostests/apitests/gdi32api/tests/AddFontResource.c +++ /dev/null @@ -1,74 +0,0 @@ - -INT -Test_AddFontResourceA(PTESTINFO pti) -{ - CHAR szFileNameA[MAX_PATH]; - CHAR szFileNameFont1A[MAX_PATH]; - CHAR szFileNameFont2A[MAX_PATH]; - - GetCurrentDirectoryA(MAX_PATH,szFileNameA); - - memcpy(szFileNameFont1A,szFileNameA,MAX_PATH ); - strcat(szFileNameFont1A, "\\testdata\\test.ttf"); - - memcpy(szFileNameFont2A,szFileNameA,MAX_PATH ); - strcat(szFileNameFont2A, "\\testdata\\test.otf"); - - RtlZeroMemory(szFileNameA,MAX_PATH); - - /* - * Start testing Ansi version - * - */ - - /* Testing NULL pointer */ - SetLastError(ERROR_SUCCESS); - RTEST(AddFontResourceA(NULL) == 0); - RTEST(GetLastError() == ERROR_SUCCESS); - - /* Testing -1 pointer */ - SetLastError(ERROR_SUCCESS); - RTEST(AddFontResourceA((CHAR*)-1) == 0); - RTEST(GetLastError() == ERROR_SUCCESS); - - /* Testing address 1 pointer */ - SetLastError(ERROR_SUCCESS); - RTEST(AddFontResourceA((CHAR*)1) == 0); - RTEST(GetLastError() == ERROR_SUCCESS); - - /* Testing address empty string */ - SetLastError(ERROR_SUCCESS); - RTEST(AddFontResourceA("") == 0); - TEST(GetLastError() == ERROR_INVALID_PARAMETER); - - /* Testing one ttf font */ - SetLastError(ERROR_SUCCESS); - TEST(AddFontResourceA(szFileNameFont1A) == 1); - RTEST(GetLastError() == ERROR_SUCCESS); - - /* Testing one otf font */ - SetLastError(ERROR_SUCCESS); - TEST(AddFontResourceA(szFileNameFont2A) == 1); - RTEST(GetLastError() == ERROR_SUCCESS); - - /* Testing two fonts */ - SetLastError(ERROR_SUCCESS); - sprintf(szFileNameA,"%s|%s",szFileNameFont1A, szFileNameFont2A); - TEST(AddFontResourceA(szFileNameA) == 0); - TEST(GetLastError() == ERROR_SUCCESS); - - SetLastError(ERROR_SUCCESS); - sprintf(szFileNameA,"%s |%s",szFileNameFont1A, szFileNameFont2A); - TEST(AddFontResourceA(szFileNameA) == 0); - TEST(GetLastError() == ERROR_SUCCESS); - - SetLastError(ERROR_SUCCESS); - sprintf(szFileNameA,"%s | %s",szFileNameFont1A, szFileNameFont2A); - TEST(AddFontResourceA(szFileNameA) == 0); - TEST(GetLastError() == ERROR_FILE_NOT_FOUND); - - return APISTATUS_NORMAL; -} - - - diff --git a/rostests/apitests/gdi32api/tests/AddFontResourceEx.c b/rostests/apitests/gdi32api/tests/AddFontResourceEx.c deleted file mode 100644 index 7b6f52b9d35..00000000000 --- a/rostests/apitests/gdi32api/tests/AddFontResourceEx.c +++ /dev/null @@ -1,36 +0,0 @@ -#define STAMP_DESIGNVECTOR (0x8000000 + 'd' + ('v' << 8)) - -INT -Test_AddFontResourceEx(PTESTINFO pti) -{ - WCHAR szFileName[MAX_PATH]; - - /* Test NULL filename */ - SetLastError(ERROR_SUCCESS); - /* Windows crashes, would need SEH here */ -// TEST(AddFontResourceExW(NULL, 0, 0) != 0); -// TEST(GetLastError() == ERROR_SUCCESS); - - /* Test "" filename */ - SetLastError(ERROR_SUCCESS); - RTEST(AddFontResourceExW(L"", 0, 0) == 0); - TEST(GetLastError() == ERROR_INVALID_PARAMETER); - - GetEnvironmentVariableW(L"systemroot", szFileName, MAX_PATH); - wcscat(szFileName, L"\\Fonts\\cour.ttf"); - - /* Test flags = 0 */ - SetLastError(ERROR_SUCCESS); - TEST(AddFontResourceExW(szFileName, 0, 0) != 0); - RTEST(GetLastError() == ERROR_SUCCESS); - - SetLastError(ERROR_SUCCESS); - RTEST(AddFontResourceExW(szFileName, 256, 0) == 0); - RTEST(GetLastError() == ERROR_INVALID_PARAMETER); - - /* Test invalid pointer as last parameter */ - TEST(AddFontResourceExW(szFileName, 0, (void*)-1) != 0); - - - return APISTATUS_NORMAL; -} diff --git a/rostests/apitests/gdi32api/tests/BeginPath.c b/rostests/apitests/gdi32api/tests/BeginPath.c deleted file mode 100644 index f4671207dfe..00000000000 --- a/rostests/apitests/gdi32api/tests/BeginPath.c +++ /dev/null @@ -1,24 +0,0 @@ - - -INT -Test_BeginPath(PTESTINFO pti) -{ - HDC hDC; - BOOL ret; - - SetLastError(0); - ret = BeginPath(0); - TEST(ret == 0); - TEST(GetLastError() == ERROR_INVALID_HANDLE); - - hDC = CreateCompatibleDC(NULL); - - SetLastError(0); - ret = BeginPath(hDC); - TEST(ret == 1); - TEST(GetLastError() == 0); - - DeleteDC(hDC); - - return APISTATUS_NORMAL; -} diff --git a/rostests/apitests/gdi32api/tests/CreateCompatibleDC.c b/rostests/apitests/gdi32api/tests/CreateCompatibleDC.c deleted file mode 100644 index 2cfb508f778..00000000000 --- a/rostests/apitests/gdi32api/tests/CreateCompatibleDC.c +++ /dev/null @@ -1,53 +0,0 @@ -INT -Test_CreateCompatibleDC(PTESTINFO pti) -{ - HDC hDCScreen, hOldDC, hDC, hDC2; - - /* Get screen DC */ - hDCScreen = GetDC(NULL); - ASSERT(hDCScreen != NULL); - - /* Test NULL DC handle */ - SetLastError(ERROR_SUCCESS); - hDC = CreateCompatibleDC(NULL); - RTEST(hDC != NULL); - RTEST(GetLastError() == ERROR_SUCCESS); - if(hDC) DeleteDC(hDC); - - /* Test invalid DC handle */ - SetLastError(ERROR_SUCCESS); - hDC = CreateCompatibleDC((HDC)0x123456); - RTEST(hDC == NULL); - RTEST(GetLastError() == ERROR_SUCCESS); - if(hDC) DeleteDC(hDC); - - hDC = CreateCompatibleDC(hDCScreen); - RTEST(hDC != NULL); - - // Test if first selected pen is BLACK_PEN (? or same as screen DC's pen?) - RTEST(SelectObject(hDC, GetStockObject(DC_PEN)) == GetStockObject(BLACK_PEN)); - RTEST(SelectObject(hDC, GetStockObject(BLACK_PEN)) == GetStockObject(DC_PEN)); - - // Test for the starting Color == RGB(0,0,0) - RTEST(SetDCPenColor(hDC, RGB(1,2,3)) == RGB(0,0,0)); - - // Check for reuse counter - hOldDC = hDC; - DeleteDC(hDC); - hDC = CreateCompatibleDC(hDCScreen); - hDC2 = CreateCompatibleDC(hOldDC); - RTEST(hDC2 == NULL); - if (hDC2 != NULL) DeleteDC(hDC2); - - /* Check map mode */ - hDC = CreateCompatibleDC(hDCScreen); - SetMapMode(hDC, MM_ISOTROPIC); - hDC2 = CreateCompatibleDC(hDC); - TEST(GetMapMode(hDC2) == MM_TEXT); - - // cleanup - DeleteDC(hDC); - - ReleaseDC(NULL, hDCScreen); - return APISTATUS_NORMAL; -} diff --git a/rostests/apitests/gdi32api/tests/CreateFont.c b/rostests/apitests/gdi32api/tests/CreateFont.c deleted file mode 100644 index cb70720b9bd..00000000000 --- a/rostests/apitests/gdi32api/tests/CreateFont.c +++ /dev/null @@ -1,22 +0,0 @@ -#define INVALIDFONT "ThisFontDoesNotExist" - -INT -Test_CreateFont(PTESTINFO pti) -{ - HFONT hFont; - LOGFONTA logfonta; - - /* Test invalid font name */ - hFont = CreateFontA(15, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, - DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, - DEFAULT_QUALITY, DEFAULT_PITCH, INVALIDFONT); - RTEST(hFont); - RTEST(GetObjectA(hFont, sizeof(LOGFONTA), &logfonta) == sizeof(LOGFONTA)); - RTEST(memcmp(logfonta.lfFaceName, INVALIDFONT, strlen(INVALIDFONT)) == 0); - RTEST(logfonta.lfWeight == FW_DONTCARE); - - - return APISTATUS_NORMAL; -} - - diff --git a/rostests/apitests/gdi32api/tests/CreateRectRgn.c b/rostests/apitests/gdi32api/tests/CreateRectRgn.c deleted file mode 100644 index 879ac0204bc..00000000000 --- a/rostests/apitests/gdi32api/tests/CreateRectRgn.c +++ /dev/null @@ -1,8 +0,0 @@ -INT -Test_CreateRectRgn(PTESTINFO pti) -{ -// HRGN hRgn; - -// hRgn = CreateRectRgn( - return APISTATUS_NORMAL; -} diff --git a/rostests/apitests/gdi32api/tests/EngAcquireSemaphore.c b/rostests/apitests/gdi32api/tests/EngAcquireSemaphore.c deleted file mode 100644 index 3648c278137..00000000000 --- a/rostests/apitests/gdi32api/tests/EngAcquireSemaphore.c +++ /dev/null @@ -1,45 +0,0 @@ -/* Simple test of EngAcquireSemaphore only check if we got a lock or not */ -INT -Test_EngAcquireSemaphore(PTESTINFO pti) -{ - - HSEMAPHORE hsem; - PRTL_CRITICAL_SECTION lpcrit; - - hsem = EngCreateSemaphore(); - RTEST ( hsem != NULL ); - ASSERT(hsem != NULL); - lpcrit = (PRTL_CRITICAL_SECTION) hsem; - - /* real data test */ - EngAcquireSemaphore(hsem); -// RTEST (lpcrit->LockCount == -2); doesn't work on XP - RTEST (lpcrit->RecursionCount == 1); - RTEST (lpcrit->OwningThread != 0); - RTEST (lpcrit->LockSemaphore == 0); - RTEST (lpcrit->SpinCount == 0); - - ASSERT(lpcrit->DebugInfo != NULL); - RTEST (lpcrit->DebugInfo->Type == 0); - RTEST (lpcrit->DebugInfo->CreatorBackTraceIndex == 0); - RTEST (lpcrit->DebugInfo->EntryCount == 0); - RTEST (lpcrit->DebugInfo->ContentionCount == 0); - - EngReleaseSemaphore(hsem); - EngDeleteSemaphore(hsem); - - /* NULL pointer test */ - // Note NULL pointer test crash in Vista */ - // EngAcquireSemaphore(NULL); - - /* negtive pointer test */ - // Note negtive pointer test crash in Vista */ - // EngAcquireSemaphore((HSEMAPHORE)-1); - - /* try with deleted Semaphore */ - // Note deleted Semaphore pointer test does freze the whole program in Vista */ - // EngAcquireSemaphore(hsem); - - return APISTATUS_NORMAL; -} - diff --git a/rostests/apitests/gdi32api/tests/EngCreateSemaphore.c b/rostests/apitests/gdi32api/tests/EngCreateSemaphore.c deleted file mode 100644 index 23a1d9a48c7..00000000000 --- a/rostests/apitests/gdi32api/tests/EngCreateSemaphore.c +++ /dev/null @@ -1,31 +0,0 @@ -/* Simple test of EngAcquireSemaphore only check if we got a lock or not */ -INT -Test_EngCreateSemaphore(PTESTINFO pti) -{ - - HSEMAPHORE hsem; - PRTL_CRITICAL_SECTION lpcrit; - - hsem = EngCreateSemaphore(); - RTEST ( hsem != NULL ); - ASSERT(hsem != NULL); - - lpcrit = (PRTL_CRITICAL_SECTION) hsem; - RTEST ( lpcrit->DebugInfo != NULL); - RTEST (lpcrit->LockCount == -1); - RTEST (lpcrit->RecursionCount == 0); - RTEST (lpcrit->OwningThread == 0); - RTEST (lpcrit->LockSemaphore == 0); - RTEST (lpcrit->SpinCount == 0); - - ASSERT(lpcrit->DebugInfo != NULL); - RTEST (lpcrit->DebugInfo->Type == 0); - RTEST (lpcrit->DebugInfo->CreatorBackTraceIndex == 0); - RTEST (lpcrit->DebugInfo->EntryCount == 0); - RTEST (lpcrit->DebugInfo->ContentionCount == 0); - - EngDeleteSemaphore(hsem); - - return APISTATUS_NORMAL; -} - diff --git a/rostests/apitests/gdi32api/tests/EngDeleteSemaphore.c b/rostests/apitests/gdi32api/tests/EngDeleteSemaphore.c deleted file mode 100644 index a8c35dc84f4..00000000000 --- a/rostests/apitests/gdi32api/tests/EngDeleteSemaphore.c +++ /dev/null @@ -1,51 +0,0 @@ - -INT -Test_EngDeleteSemaphore(PTESTINFO pti) -{ - - HSEMAPHORE hsem; - PRTL_CRITICAL_SECTION lpcrit; - - /* test Create then delete */ - hsem = EngCreateSemaphore(); - ASSERT(hsem != NULL); - lpcrit = (PRTL_CRITICAL_SECTION) hsem; - EngDeleteSemaphore(hsem); - -// RTEST (lpcrit->LockCount > 0); doesn't work on XP - RTEST (lpcrit->RecursionCount == 0); - RTEST (lpcrit->OwningThread == 0); - RTEST (lpcrit->LockSemaphore == 0); - RTEST (lpcrit->SpinCount == 0); - -// ASSERT(lpcrit->DebugInfo != NULL); doesn't work on XP - RTEST (lpcrit->DebugInfo->Type != 0); - RTEST (lpcrit->DebugInfo->CreatorBackTraceIndex != 0); - RTEST (lpcrit->DebugInfo->EntryCount != 0); - RTEST (lpcrit->DebugInfo->ContentionCount != 0); - - - /* test EngAcquireSemaphore and release it, then delete it */ - hsem = EngCreateSemaphore(); - ASSERT(hsem != NULL); - lpcrit = (PRTL_CRITICAL_SECTION) hsem; - - EngAcquireSemaphore(hsem); - EngReleaseSemaphore(hsem); - EngDeleteSemaphore(hsem); - - RTEST (lpcrit->LockCount > 0); - RTEST (lpcrit->RecursionCount == 0); - RTEST (lpcrit->OwningThread == 0); - RTEST (lpcrit->LockSemaphore == 0); - RTEST (lpcrit->SpinCount == 0); - - ASSERT(lpcrit->DebugInfo != NULL); - RTEST (lpcrit->DebugInfo->Type != 0); - RTEST (lpcrit->DebugInfo->CreatorBackTraceIndex != 0); - RTEST (lpcrit->DebugInfo->EntryCount != 0); - RTEST (lpcrit->DebugInfo->ContentionCount != 0); - - return APISTATUS_NORMAL; -} - diff --git a/rostests/apitests/gdi32api/tests/EngReleaseSemaphore.c b/rostests/apitests/gdi32api/tests/EngReleaseSemaphore.c deleted file mode 100644 index 05a9f528c2e..00000000000 --- a/rostests/apitests/gdi32api/tests/EngReleaseSemaphore.c +++ /dev/null @@ -1,56 +0,0 @@ -/* Simple test of EngAcquireSemaphore only check if we got a lock or not */ -INT -Test_EngReleaseSemaphore(PTESTINFO pti) -{ - - HSEMAPHORE hsem; - PRTL_CRITICAL_SECTION lpcrit; - - hsem = EngCreateSemaphore(); - ASSERT(hsem != NULL); - - lpcrit = (PRTL_CRITICAL_SECTION) hsem; - - EngAcquireSemaphore(hsem); - EngReleaseSemaphore(hsem); - - RTEST (lpcrit->LockCount != 0); - RTEST (lpcrit->RecursionCount == 0); - RTEST (lpcrit->OwningThread == 0); - RTEST (lpcrit->LockSemaphore == 0); - RTEST (lpcrit->SpinCount == 0); - - ASSERT(lpcrit->DebugInfo != NULL); - RTEST (lpcrit->DebugInfo->Type == 0); - RTEST (lpcrit->DebugInfo->CreatorBackTraceIndex == 0); - RTEST (lpcrit->DebugInfo->EntryCount == 0); - RTEST (lpcrit->DebugInfo->ContentionCount == 0); - - EngDeleteSemaphore(hsem); - - /* try with deleted Semaphore */ -// EngReleaseSemaphore(hsem); -> this leads to heap correuption -// RTEST (lpcrit->LockCount > 0); -// RTEST (lpcrit->RecursionCount != 0); -// RTEST (lpcrit->OwningThread == 0); -// RTEST (lpcrit->LockSemaphore == 0); -// RTEST (lpcrit->SpinCount == 0); - -// ASSERT(lpcrit->DebugInfo != NULL); -// RTEST (lpcrit->DebugInfo->Type != 0); -// RTEST (lpcrit->DebugInfo->CreatorBackTraceIndex != 0); -// RTEST (lpcrit->DebugInfo->EntryCount != 0); -// RTEST (lpcrit->DebugInfo->ContentionCount != 0); - - /* NULL pointer test */ - // Note NULL pointer test crash in Vista */ - // EngReleaseSemaphore(NULL); - - /* negtive pointer test */ - // Note negtive pointer test crash in Vista */ - // EngReleaseSemaphore((HSEMAPHORE)-1); - - - return APISTATUS_NORMAL; -} - diff --git a/rostests/apitests/gdi32api/tests/ExtCreatePen.c b/rostests/apitests/gdi32api/tests/ExtCreatePen.c deleted file mode 100644 index 1507e95401d..00000000000 --- a/rostests/apitests/gdi32api/tests/ExtCreatePen.c +++ /dev/null @@ -1,29 +0,0 @@ -INT -Test_ExtCreatePen(PTESTINFO pti) -{ - HPEN hPen; - LOGBRUSH logbrush; - DWORD dwStyles[17] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17}; - - logbrush.lbStyle = BS_SOLID; - logbrush.lbColor = RGB(1,2,3); - logbrush.lbHatch = 0; - hPen = ExtCreatePen(PS_COSMETIC, 1,&logbrush, 0, 0); - if (!hPen) return FALSE; - - /* Test if we have an EXTPEN */ - RTEST(GDI_HANDLE_GET_TYPE(hPen) == GDI_OBJECT_TYPE_EXTPEN); - DeleteObject(hPen); - - /* test userstyles */ - hPen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE, 5, &logbrush, 17, (CONST DWORD*)&dwStyles); - RTEST(hPen == 0); - hPen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE, 5, &logbrush, 16, (CONST DWORD*)&dwStyles); - RTEST(hPen != 0); - - DeleteObject(hPen); - - return APISTATUS_NORMAL; -} - - diff --git a/rostests/apitests/gdi32api/tests/GdiConvertBitmap.c b/rostests/apitests/gdi32api/tests/GdiConvertBitmap.c deleted file mode 100644 index bdbd4f9ab46..00000000000 --- a/rostests/apitests/gdi32api/tests/GdiConvertBitmap.c +++ /dev/null @@ -1,10 +0,0 @@ -INT -Test_GdiConvertBitmap(PTESTINFO pti) -{ - RTEST(GdiConvertBitmap((HDC)-1) == (HDC)-1); - RTEST(GdiConvertBitmap((HDC)0) == (HDC)0); - RTEST(GdiConvertBitmap((HDC)1) == (HDC)1); - RTEST(GdiConvertBitmap((HDC)2) == (HDC)2); - return APISTATUS_NORMAL; -} - diff --git a/rostests/apitests/gdi32api/tests/GdiConvertBrush.c b/rostests/apitests/gdi32api/tests/GdiConvertBrush.c deleted file mode 100644 index 20ea326e47e..00000000000 --- a/rostests/apitests/gdi32api/tests/GdiConvertBrush.c +++ /dev/null @@ -1,9 +0,0 @@ -INT -Test_GdiConvertBrush(PTESTINFO pti) -{ - RTEST(GdiConvertBrush((HBRUSH)-1) == (HBRUSH)-1); - RTEST(GdiConvertBrush((HBRUSH)0) == (HBRUSH)0); - RTEST(GdiConvertBrush((HBRUSH)1) == (HBRUSH)1); - RTEST(GdiConvertBrush((HBRUSH)2) == (HBRUSH)2); - return APISTATUS_NORMAL; -} diff --git a/rostests/apitests/gdi32api/tests/GdiConvertDC.c b/rostests/apitests/gdi32api/tests/GdiConvertDC.c deleted file mode 100644 index 302d1cb8b16..00000000000 --- a/rostests/apitests/gdi32api/tests/GdiConvertDC.c +++ /dev/null @@ -1,10 +0,0 @@ -INT -Test_GdiConvertDC(PTESTINFO pti) -{ - RTEST(GdiConvertDC((HDC)-1) == (HDC)-1); - RTEST(GdiConvertDC((HDC)0) == (HDC)0); - RTEST(GdiConvertDC((HDC)1) == (HDC)1); - RTEST(GdiConvertDC((HDC)2) == (HDC)2); - return APISTATUS_NORMAL; -} - diff --git a/rostests/apitests/gdi32api/tests/GdiConvertFont.c b/rostests/apitests/gdi32api/tests/GdiConvertFont.c deleted file mode 100644 index 7bb778d62a7..00000000000 --- a/rostests/apitests/gdi32api/tests/GdiConvertFont.c +++ /dev/null @@ -1,9 +0,0 @@ -INT -Test_GdiConvertFont(PTESTINFO pti) -{ - RTEST(GdiConvertFont((HFONT)-1) == (HFONT)-1); - RTEST(GdiConvertFont((HFONT)0) == (HFONT)0); - RTEST(GdiConvertFont((HFONT)1) == (HFONT)1); - RTEST(GdiConvertFont((HFONT)2) == (HFONT)2); - return APISTATUS_NORMAL; -} diff --git a/rostests/apitests/gdi32api/tests/GdiConvertPalette.c b/rostests/apitests/gdi32api/tests/GdiConvertPalette.c deleted file mode 100644 index 5ccec307571..00000000000 --- a/rostests/apitests/gdi32api/tests/GdiConvertPalette.c +++ /dev/null @@ -1,9 +0,0 @@ -INT -Test_GdiConvertPalette(PTESTINFO pti) -{ - RTEST(GdiConvertPalette((HPALETTE)-1) == (HPALETTE)-1); - RTEST(GdiConvertPalette((HPALETTE)0) == (HPALETTE)0); - RTEST(GdiConvertPalette((HPALETTE)1) == (HPALETTE)1); - RTEST(GdiConvertPalette((HPALETTE)2) == (HPALETTE)2); - return APISTATUS_NORMAL; -} diff --git a/rostests/apitests/gdi32api/tests/GdiConvertRegion.c b/rostests/apitests/gdi32api/tests/GdiConvertRegion.c deleted file mode 100644 index 34f1081b238..00000000000 --- a/rostests/apitests/gdi32api/tests/GdiConvertRegion.c +++ /dev/null @@ -1,12 +0,0 @@ -INT -Test_GdiConvertRegion(PTESTINFO pti) -{ - RTEST(GdiConvertRegion((HRGN)-1) == (HRGN)-1); - RTEST(GdiConvertRegion((HRGN)0) == (HRGN)0); - RTEST(GdiConvertRegion((HRGN)1) == (HRGN)1); - RTEST(GdiConvertRegion((HRGN)2) == (HRGN)2); - RTEST(GdiConvertRegion((HRGN)3) == (HRGN)3); - RTEST(GdiConvertRegion((HRGN)4) == (HRGN)4); - return APISTATUS_NORMAL; -} - diff --git a/rostests/apitests/gdi32api/tests/GdiDeleteLocalDC.c b/rostests/apitests/gdi32api/tests/GdiDeleteLocalDC.c deleted file mode 100644 index efeb214c35a..00000000000 --- a/rostests/apitests/gdi32api/tests/GdiDeleteLocalDC.c +++ /dev/null @@ -1,9 +0,0 @@ -INT -Test_GdiDeleteLocalDC(PTESTINFO pti) -{ - RTEST(GdiDeleteLocalDC((HDC)-1) == TRUE); - RTEST(GdiDeleteLocalDC((HDC)0) == TRUE); - RTEST(GdiDeleteLocalDC((HDC)1) == TRUE); - RTEST(GdiDeleteLocalDC((HDC)2) == TRUE); - return APISTATUS_NORMAL; -} diff --git a/rostests/apitests/gdi32api/tests/GdiGetCharDimensions.c b/rostests/apitests/gdi32api/tests/GdiGetCharDimensions.c deleted file mode 100644 index f5874f49903..00000000000 --- a/rostests/apitests/gdi32api/tests/GdiGetCharDimensions.c +++ /dev/null @@ -1,27 +0,0 @@ -LONG WINAPI GdiGetCharDimensions(HDC, LPTEXTMETRICW, LONG *); - -INT -Test_GdiGetCharDimensions(PTESTINFO pti) -{ - LOGFONT logfont = {-11, 0, 0, 0, 400, - 0, 0, 0, 0, 0, 0, 0, 0, - "MS Shell Dlg 2"}; - HFONT hFont, hOldFont; - HDC hDC; - LONG x,y; - TEXTMETRICW tm; - - hFont = CreateFontIndirect(&logfont); - hDC = CreateCompatibleDC(NULL); - hOldFont = SelectObject(hDC, hFont); - - x = GdiGetCharDimensions(hDC, &tm, &y); - - RTEST(y == tm.tmHeight); - - SelectObject(hDC, hOldFont); - DeleteObject(hFont); - DeleteDC(hDC); - - return APISTATUS_NORMAL; -} diff --git a/rostests/apitests/gdi32api/tests/GdiGetLocalBrush.c b/rostests/apitests/gdi32api/tests/GdiGetLocalBrush.c deleted file mode 100644 index 45b134b1e66..00000000000 --- a/rostests/apitests/gdi32api/tests/GdiGetLocalBrush.c +++ /dev/null @@ -1,11 +0,0 @@ -INT -Test_GdiGetLocalBrush(PTESTINFO pti) -{ - RTEST(GdiGetLocalBrush((HBRUSH)-1) == (HBRUSH)-1); - RTEST(GdiGetLocalBrush((HBRUSH)0) == (HBRUSH)0); - RTEST(GdiGetLocalBrush((HBRUSH)1) == (HBRUSH)1); - RTEST(GdiGetLocalBrush((HBRUSH)2) == (HBRUSH)2); - RTEST(GdiGetLocalBrush((HBRUSH)3) == (HBRUSH)3); - RTEST(GdiGetLocalBrush((HBRUSH)4) == (HBRUSH)4); - return APISTATUS_NORMAL; -} diff --git a/rostests/apitests/gdi32api/tests/GdiGetLocalDC.c b/rostests/apitests/gdi32api/tests/GdiGetLocalDC.c deleted file mode 100644 index ca62675c44d..00000000000 --- a/rostests/apitests/gdi32api/tests/GdiGetLocalDC.c +++ /dev/null @@ -1,11 +0,0 @@ -INT -Test_GdiGetLocalDC(PTESTINFO pti) -{ - RTEST(GdiGetLocalDC((HDC)-1) == (HDC)-1); - RTEST(GdiGetLocalDC((HDC)0) == (HDC)0); - RTEST(GdiGetLocalDC((HDC)1) == (HDC)1); - RTEST(GdiGetLocalDC((HDC)2) == (HDC)2); - RTEST(GdiGetLocalDC((HDC)3) == (HDC)3); - RTEST(GdiGetLocalDC((HDC)4) == (HDC)4); - return APISTATUS_NORMAL; -} diff --git a/rostests/apitests/gdi32api/tests/GdiReleaseLocalDC.c b/rostests/apitests/gdi32api/tests/GdiReleaseLocalDC.c deleted file mode 100644 index 5c4196c1a29..00000000000 --- a/rostests/apitests/gdi32api/tests/GdiReleaseLocalDC.c +++ /dev/null @@ -1,9 +0,0 @@ -INT -Test_GdiReleaseLocalDC(PTESTINFO pti) -{ - RTEST(GdiReleaseLocalDC((HDC)-1) == TRUE); - RTEST(GdiReleaseLocalDC((HDC)0) == TRUE); - RTEST(GdiReleaseLocalDC((HDC)1) == TRUE); - RTEST(GdiReleaseLocalDC((HDC)2) == TRUE); - return APISTATUS_NORMAL; -} diff --git a/rostests/apitests/gdi32api/tests/GdiSetAttrs.c b/rostests/apitests/gdi32api/tests/GdiSetAttrs.c deleted file mode 100644 index 9e534d5285d..00000000000 --- a/rostests/apitests/gdi32api/tests/GdiSetAttrs.c +++ /dev/null @@ -1,9 +0,0 @@ -INT -Test_GdiSetAttrs(PTESTINFO pti) -{ - RTEST(GdiSetAttrs((HDC)-1) == TRUE); - RTEST(GdiSetAttrs((HDC)0) == TRUE); - RTEST(GdiSetAttrs((HDC)1) == TRUE); - RTEST(GdiSetAttrs((HDC)2) == TRUE); - return APISTATUS_NORMAL; -} diff --git a/rostests/apitests/gdi32api/tests/GetClipRgn.c b/rostests/apitests/gdi32api/tests/GetClipRgn.c deleted file mode 100644 index 5f583ca154a..00000000000 --- a/rostests/apitests/gdi32api/tests/GetClipRgn.c +++ /dev/null @@ -1,31 +0,0 @@ -INT -Test_GetClipRgn(PTESTINFO pti) -{ - HWND hWnd; - HDC hDC; - HRGN hrgn;//, hrgn2; - - /* Create a window */ - hWnd = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW | WS_VISIBLE, - CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, - NULL, NULL, g_hInstance, 0); - - hDC = GetDC(hWnd); - hrgn = CreateRectRgn(0,0,0,0); - - /* Test invalid DC */ - SetLastError(ERROR_SUCCESS); - RTEST(GetClipRgn((HDC)0x12345, hrgn) == -1); - TEST(GetLastError() == ERROR_INVALID_PARAMETER); - - /* Test invalid hrgn */ - SetLastError(ERROR_SUCCESS); - RTEST(GetClipRgn(hDC, (HRGN)0x12345) == 0); - RTEST(GetLastError() == ERROR_SUCCESS); - - ReleaseDC(hWnd, hDC); - DestroyWindow(hWnd); - - return APISTATUS_NORMAL; -} - diff --git a/rostests/apitests/gdi32api/tests/GetCurrentObject.c b/rostests/apitests/gdi32api/tests/GetCurrentObject.c deleted file mode 100644 index b49f15cc7d7..00000000000 --- a/rostests/apitests/gdi32api/tests/GetCurrentObject.c +++ /dev/null @@ -1,139 +0,0 @@ - -INT -Test_GetCurrentObject(PTESTINFO pti) -{ - HWND hWnd; - HDC hDC; - HBITMAP hBmp; - - /* Create a window */ - hWnd = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW | WS_VISIBLE, - CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, - NULL, NULL, g_hInstance, 0); - /* Get the DC */ - hDC = GetDC(hWnd); - - /* Test NULL DC */ - SetLastError(ERROR_SUCCESS); - RTEST(GetCurrentObject(NULL, 0) == 0); - RTEST(GetLastError() == ERROR_INVALID_PARAMETER); - - SetLastError(ERROR_SUCCESS); - RTEST(GetCurrentObject(NULL, OBJ_BITMAP) == 0); - RTEST(GetCurrentObject(NULL, OBJ_BRUSH) == 0); - RTEST(GetCurrentObject(NULL, OBJ_COLORSPACE) == 0); - RTEST(GetCurrentObject(NULL, OBJ_FONT) == 0); - RTEST(GetCurrentObject(NULL, OBJ_PAL) == 0); - RTEST(GetCurrentObject(NULL, OBJ_PEN) == 0); - RTEST(GetLastError() == ERROR_SUCCESS); - - /* Test invalid DC handle */ - SetLastError(ERROR_SUCCESS); - RTEST(GetCurrentObject((HDC)-123, 0) == 0); - RTEST(GetLastError() == ERROR_INVALID_PARAMETER); - - SetLastError(ERROR_SUCCESS); - RTEST(GetCurrentObject((HDC)-123, OBJ_BITMAP) == 0); - TEST(GetLastError() == ERROR_SUCCESS); - - /* Test invalid types */ - SetLastError(ERROR_SUCCESS); - RTEST(GetCurrentObject(hDC, 0) == 0); - RTEST(GetLastError() == ERROR_INVALID_PARAMETER); - - SetLastError(ERROR_SUCCESS); - RTEST(GetCurrentObject(hDC, 3) == 0); - RTEST(GetLastError() == ERROR_INVALID_PARAMETER); - - SetLastError(ERROR_SUCCESS); - RTEST(GetCurrentObject(hDC, 4) == 0); - RTEST(GetLastError() == ERROR_INVALID_PARAMETER); - - SetLastError(ERROR_SUCCESS); - RTEST(GetCurrentObject(hDC, 8) == 0); - TEST(GetLastError() == ERROR_INVALID_PARAMETER); - - SetLastError(ERROR_SUCCESS); - RTEST(GetCurrentObject(hDC, 9) == 0); - RTEST(GetLastError() == ERROR_INVALID_PARAMETER); - - SetLastError(ERROR_SUCCESS); - RTEST(GetCurrentObject(hDC, 10) == 0); - RTEST(GetLastError() == ERROR_INVALID_PARAMETER); - - SetLastError(ERROR_SUCCESS); - RTEST(GetCurrentObject(hDC, 12) == 0); - RTEST(GetLastError() == ERROR_INVALID_PARAMETER); - - SetLastError(ERROR_SUCCESS); - RTEST(GetCurrentObject(hDC, 13) == 0); - RTEST(GetLastError() == ERROR_INVALID_PARAMETER); - - /* Default bitmap */ - SetLastError(ERROR_SUCCESS); - hBmp = GetCurrentObject(hDC, OBJ_BITMAP); - RTEST(GDI_HANDLE_GET_TYPE(hBmp) == GDI_OBJECT_TYPE_BITMAP); - RTEST(GetLastError() == ERROR_SUCCESS); - - /* Other bitmap */ - SetLastError(ERROR_SUCCESS); - SelectObject(hDC, GetStockObject(21)); - RTEST(hBmp == GetCurrentObject(hDC, OBJ_BITMAP)); - RTEST(GDI_HANDLE_GET_TYPE(hBmp) == GDI_OBJECT_TYPE_BITMAP); - RTEST(GetLastError() == ERROR_SUCCESS); - - /* Default brush */ - SetLastError(ERROR_SUCCESS); - RTEST(GetCurrentObject(hDC, OBJ_BRUSH) == GetStockObject(WHITE_BRUSH)); - RTEST(GetLastError() == ERROR_SUCCESS); - - /* Other brush */ - SetLastError(ERROR_SUCCESS); - SelectObject(hDC, GetStockObject(BLACK_BRUSH)); - RTEST(GetCurrentObject(hDC, OBJ_BRUSH) == GetStockObject(BLACK_BRUSH)); - RTEST(GetLastError() == ERROR_SUCCESS); - - /* Default colorspace */ - SetLastError(ERROR_SUCCESS); - RTEST(GetCurrentObject(hDC, OBJ_COLORSPACE) == GetStockObject(20)); - RTEST(GetLastError() == ERROR_SUCCESS); - - /* Default font */ - SetLastError(ERROR_SUCCESS); - RTEST(GetCurrentObject(hDC, OBJ_FONT) == GetStockObject(SYSTEM_FONT)); - RTEST(GetLastError() == ERROR_SUCCESS); - - /* Other font */ - SetLastError(ERROR_SUCCESS); - SelectObject(hDC, GetStockObject(DEFAULT_GUI_FONT)); - RTEST(GetCurrentObject(hDC, OBJ_FONT) == GetStockObject(DEFAULT_GUI_FONT)); - RTEST(GetLastError() == ERROR_SUCCESS); - - /* Default palette */ - SetLastError(ERROR_SUCCESS); - RTEST(GetCurrentObject(hDC, OBJ_PAL) == GetStockObject(DEFAULT_PALETTE)); - RTEST(GetLastError() == ERROR_SUCCESS); - - /* Default pen */ - SetLastError(ERROR_SUCCESS); - RTEST(GetCurrentObject(hDC, OBJ_PEN) == GetStockObject(BLACK_PEN)); - RTEST(GetLastError() == ERROR_SUCCESS); - - /* Other pen */ - SetLastError(ERROR_SUCCESS); - SelectObject(hDC, GetStockObject(WHITE_PEN)); - RTEST(GetCurrentObject(hDC, OBJ_PEN) == GetStockObject(WHITE_PEN)); - RTEST(GetLastError() == ERROR_SUCCESS); - - /* DC pen */ - SetLastError(ERROR_SUCCESS); - SelectObject(hDC, GetStockObject(DC_PEN)); - RTEST(GetCurrentObject(hDC, OBJ_PEN) == GetStockObject(DC_PEN)); - RTEST(GetLastError() == ERROR_SUCCESS); - - ReleaseDC(hWnd, hDC); - DestroyWindow(hWnd); - - return APISTATUS_NORMAL; -} - diff --git a/rostests/apitests/gdi32api/tests/GetObject.c b/rostests/apitests/gdi32api/tests/GetObject.c deleted file mode 100644 index 08b93d13064..00000000000 --- a/rostests/apitests/gdi32api/tests/GetObject.c +++ /dev/null @@ -1,453 +0,0 @@ -static INT -Test_General(PTESTINFO pti) -{ - struct - { - LOGBRUSH logbrush; - BYTE additional[5]; - } TestStruct; - PLOGBRUSH plogbrush; - HBRUSH hBrush; - - /* Test null pointer and invalid handles */ - SetLastError(ERROR_SUCCESS); - RTEST(GetObjectA(0, 0, NULL) == 0); - RTEST(GetObjectA((HANDLE)-1, 0, NULL) == 0); - RTEST(GetObjectA((HANDLE)0x00380000, 0, NULL) == 0); - RTEST(GetLastError() == ERROR_SUCCESS); - - SetLastError(ERROR_SUCCESS); - RTEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_DC, 0, NULL) == 0); - RTEST(GetLastError() == ERROR_INVALID_HANDLE); - SetLastError(ERROR_SUCCESS); - RTEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_DC, 0, NULL) == 0); - RTEST(GetLastError() == ERROR_INVALID_HANDLE); - SetLastError(ERROR_SUCCESS); - RTEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_REGION, 0, NULL) == 0); - RTEST(GetLastError() == ERROR_INVALID_HANDLE); - SetLastError(ERROR_SUCCESS); - RTEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_REGION, 0, NULL) == 0); - RTEST(GetLastError() == ERROR_INVALID_HANDLE); - SetLastError(ERROR_SUCCESS); - RTEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_EMF, 0, NULL) == 0); - RTEST(GetLastError() == ERROR_INVALID_HANDLE); - SetLastError(ERROR_SUCCESS); - RTEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_EMF, 0, NULL) == 0); - RTEST(GetLastError() == ERROR_INVALID_HANDLE); - SetLastError(ERROR_SUCCESS); - RTEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_METAFILE, 0, NULL) == 0); - RTEST(GetLastError() == ERROR_INVALID_HANDLE); - SetLastError(ERROR_SUCCESS); - RTEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_METAFILE, 0, NULL) == 0); - RTEST(GetLastError() == ERROR_INVALID_HANDLE); - SetLastError(ERROR_SUCCESS); - RTEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_ENHMETAFILE, 0, NULL) == 0); - RTEST(GetLastError() == ERROR_INVALID_HANDLE); - SetLastError(ERROR_SUCCESS); - RTEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_ENHMETAFILE, 0, NULL) == 0); - RTEST(GetLastError() == ERROR_INVALID_HANDLE); - - /* Test need of alignment */ - hBrush = GetStockObject(WHITE_BRUSH); - plogbrush = (PVOID)((ULONG_PTR)&TestStruct.logbrush); - RTEST(GetObject(hBrush, sizeof(LOGBRUSH), plogbrush) == sizeof(LOGBRUSH)); - plogbrush = (PVOID)((ULONG_PTR)&TestStruct.logbrush + 2); - RTEST(GetObject(hBrush, sizeof(LOGBRUSH), plogbrush) == sizeof(LOGBRUSH)); - plogbrush = (PVOID)((ULONG_PTR)&TestStruct.logbrush + 1); - RTEST(GetObject(hBrush, sizeof(LOGBRUSH), plogbrush) == 0); - - return TRUE; -} - -static INT -Test_Bitmap(PTESTINFO pti) -{ - HBITMAP hBitmap; - BITMAP bitmap; - DIBSECTION dibsection; - BYTE bData[100] = {0}; - BYTE Buffer[100] = {48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,0}; - - FillMemory(&bitmap, sizeof(BITMAP), 0x77); - hBitmap = CreateBitmap(10,10,1,8,bData); - if (!hBitmap) return FALSE; - - SetLastError(ERROR_SUCCESS); - RTEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_BITMAP, 0, NULL) == sizeof(BITMAP)); - RTEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_BITMAP, 0, NULL) == sizeof(BITMAP)); - RTEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_BITMAP, sizeof(BITMAP), NULL) == sizeof(BITMAP)); - RTEST(GetObjectA(hBitmap, sizeof(DIBSECTION), NULL) == sizeof(BITMAP)); - RTEST(GetObjectA(hBitmap, 0, NULL) == sizeof(BITMAP)); - RTEST(GetObjectA((HANDLE)((UINT_PTR)hBitmap & 0x0000ffff), 0, NULL) == sizeof(BITMAP)); - RTEST(GetObjectA(hBitmap, 5, NULL) == sizeof(BITMAP)); - RTEST(GetObjectA(hBitmap, -5, NULL) == sizeof(BITMAP)); - RTEST(GetObjectA(hBitmap, 0, Buffer) == 0); - RTEST(GetObjectA(hBitmap, 5, Buffer) == 0); - RTEST(GetObjectA(hBitmap, sizeof(BITMAP), &bitmap) == sizeof(BITMAP)); - RTEST(GetObjectA(hBitmap, sizeof(BITMAP)+2, &bitmap) == sizeof(BITMAP)); - RTEST(GetObjectA(hBitmap, sizeof(DIBSECTION), &dibsection) == sizeof(BITMAP)); - RTEST(GetObjectA(hBitmap, -5, &bitmap) == sizeof(BITMAP)); - RTEST(GetLastError() == ERROR_SUCCESS); - - // todo: test invalid handle + buffer - - DeleteObject(hBitmap); - return TRUE; -} - -static INT -Test_Dibsection(PTESTINFO pti) -{ - BITMAPINFO bmi = {{sizeof(BITMAPINFOHEADER), 10, 9, 1, 8, BI_RGB, 0, 10, 10, 0,0}}; - HBITMAP hBitmap; - BITMAP bitmap; - DIBSECTION dibsection; - PVOID pData; - HDC hDC; - - FillMemory(&dibsection, sizeof(DIBSECTION), 0x77); - hDC = GetDC(0); - hBitmap = CreateDIBSection(hDC, &bmi, DIB_RGB_COLORS, &pData, NULL, 0); - ASSERT(hBitmap); - - SetLastError(ERROR_SUCCESS); - RTEST(GetObject(hBitmap, sizeof(DIBSECTION), NULL) == sizeof(BITMAP)); - RTEST(GetObject(hBitmap, 0, NULL) == sizeof(BITMAP)); - RTEST(GetObject(hBitmap, 5, NULL) == sizeof(BITMAP)); - RTEST(GetObject(hBitmap, -5, NULL) == sizeof(BITMAP)); - RTEST(GetObject(hBitmap, 0, &dibsection) == 0); - RTEST(GetObject(hBitmap, 5, &dibsection) == 0); - RTEST(GetObject(hBitmap, sizeof(BITMAP), &bitmap) == sizeof(BITMAP)); - RTEST(GetObject(hBitmap, sizeof(BITMAP)+2, &bitmap) == sizeof(BITMAP)); - TEST(bitmap.bmType == 0); - TEST(bitmap.bmWidth == 10); - TEST(bitmap.bmHeight == 9); - TEST(bitmap.bmWidthBytes == 12); - TEST(bitmap.bmPlanes == 1); - TEST(bitmap.bmBitsPixel == 8); - TEST(bitmap.bmBits == pData); - RTEST(GetObject(hBitmap, sizeof(DIBSECTION), &dibsection) == sizeof(DIBSECTION)); - RTEST(GetObject(hBitmap, sizeof(DIBSECTION)+2, &dibsection) == sizeof(DIBSECTION)); - RTEST(GetObject(hBitmap, -5, &dibsection) == sizeof(DIBSECTION)); - RTEST(GetLastError() == ERROR_SUCCESS); - DeleteObject(hBitmap); - ReleaseDC(0, hDC); - - return TRUE; -} - -static INT -Test_Palette(PTESTINFO pti) -{ - LOGPALETTE logpal; - HPALETTE hPalette; - WORD wPalette; - - FillMemory(&wPalette, sizeof(WORD), 0x77); - logpal.palVersion = 0x0300; - logpal.palNumEntries = 1; - logpal.palPalEntry[0].peRed = 0; - logpal.palPalEntry[0].peGreen = 0; - logpal.palPalEntry[0].peBlue = 0; - logpal.palPalEntry[0].peFlags = PC_EXPLICIT; - hPalette = CreatePalette(&logpal); - if (!hPalette) return FALSE; - - SetLastError(ERROR_SUCCESS); - RTEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_PALETTE, 0, NULL) == sizeof(WORD)); - RTEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_PALETTE, 0, NULL) == sizeof(WORD)); - RTEST(GetObject(hPalette, sizeof(WORD), NULL) == sizeof(WORD)); - RTEST(GetObject(hPalette, 0, NULL) == sizeof(WORD)); - RTEST(GetObject(hPalette, 5, NULL) == sizeof(WORD)); - RTEST(GetObject(hPalette, -5, NULL) == sizeof(WORD)); - RTEST(GetObject(hPalette, sizeof(WORD), &wPalette) == sizeof(WORD)); - RTEST(GetObject(hPalette, sizeof(WORD)+2, &wPalette) == sizeof(WORD)); - RTEST(GetObject(hPalette, 0, &wPalette) == 0); - RTEST(GetObject(hPalette, 1, &wPalette) == 0); - RTEST(GetObject(hPalette, -1, &wPalette) == sizeof(WORD)); - RTEST(GetLastError() == ERROR_SUCCESS); - DeleteObject(hPalette); - return TRUE; -} - -static INT -Test_Brush(PTESTINFO pti) -{ - LOGBRUSH logbrush; - HBRUSH hBrush; - - FillMemory(&logbrush, sizeof(LOGBRUSH), 0x77); - hBrush = CreateSolidBrush(RGB(1,2,3)); - if (!hBrush) return FALSE; - - SetLastError(ERROR_SUCCESS); - RTEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_BRUSH, 0, NULL) == sizeof(LOGBRUSH)); - RTEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_BRUSH, 0, NULL) == sizeof(LOGBRUSH)); - RTEST(GetObject(hBrush, sizeof(WORD), NULL) == sizeof(LOGBRUSH)); - RTEST(GetObject(hBrush, 0, NULL) == sizeof(LOGBRUSH)); - RTEST(GetObject(hBrush, 5, NULL) == sizeof(LOGBRUSH)); - RTEST(GetObject(hBrush, -5, NULL) == sizeof(LOGBRUSH)); - - RTEST(GetObject(hBrush, 0, &logbrush) == 0); - RTEST(logbrush.lbStyle == 0x77777777); - RTEST(GetObject(hBrush, 5, &logbrush) == sizeof(LOGBRUSH)); - RTEST(logbrush.lbStyle == 0); - RTEST(logbrush.lbColor == 0x77777701); - - RTEST(GetObject(hBrush, sizeof(LOGBRUSH), &logbrush) == sizeof(LOGBRUSH)); - RTEST(GetObject(hBrush, sizeof(LOGBRUSH)+2, &logbrush) == sizeof(LOGBRUSH)); - RTEST(GetObject(hBrush, -1, &logbrush) == sizeof(LOGBRUSH)); - // TODO: test all members - - RTEST(GetLastError() == ERROR_SUCCESS); - DeleteObject(hBrush); - return TRUE; -} - -static INT -Test_Pen(PTESTINFO pti) -{ - LOGPEN logpen; - HPEN hPen; - - FillMemory(&logpen, sizeof(LOGPEN), 0x77); - hPen = CreatePen(PS_SOLID, 3, RGB(4,5,6)); - if (!hPen) return FALSE; - SetLastError(ERROR_SUCCESS); - RTEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_PEN, 0, NULL) == sizeof(LOGPEN)); - RTEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_PEN, 0, NULL) == sizeof(LOGPEN)); - RTEST(GetObject(hPen, sizeof(BITMAP), NULL) == sizeof(LOGPEN)); - RTEST(GetObject(hPen, 0, NULL) == sizeof(LOGPEN)); - RTEST(GetObject(hPen, 5, NULL) == sizeof(LOGPEN)); - RTEST(GetObject(hPen, -5, NULL) == sizeof(LOGPEN)); - RTEST(GetObject(hPen, sizeof(LOGPEN), &logpen) == sizeof(LOGPEN)); - RTEST(GetObject(hPen, sizeof(LOGPEN)-1, &logpen) == 0); - RTEST(GetObject(hPen, sizeof(LOGPEN)+2, &logpen) == sizeof(LOGPEN)); - RTEST(GetObject(hPen, 0, &logpen) == 0); - RTEST(GetObject(hPen, -5, &logpen) == sizeof(LOGPEN)); - RTEST(GetLastError() == ERROR_SUCCESS); - - /* test if the fields are filled correctly */ - RTEST(logpen.lopnStyle == PS_SOLID); - - - DeleteObject(hPen); - return TRUE; -} - -static INT -Test_ExtPen(PTESTINFO pti) -{ - HPEN hPen; - EXTLOGPEN extlogpen; - LOGBRUSH logbrush; - DWORD dwStyles[17] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; - struct - { - EXTLOGPEN extlogpen; - DWORD dwStyles[50]; - } elpUserStyle; - - SetLastError(ERROR_SUCCESS); - RTEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, NULL) == 0); - RTEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, NULL) == 0); - TEST(GetLastError() == ERROR_INVALID_PARAMETER); - - FillMemory(&extlogpen, sizeof(EXTLOGPEN), 0x77); - logbrush.lbStyle = BS_SOLID; - logbrush.lbColor = RGB(1,2,3); - logbrush.lbHatch = 22; - hPen = ExtCreatePen(PS_GEOMETRIC | PS_DASH, 5, &logbrush, 0, NULL); - - RTEST(GDI_HANDLE_GET_TYPE(hPen) == GDI_OBJECT_TYPE_EXTPEN); - RTEST(GetObject((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, NULL) == 0); - RTEST(GetObject(hPen, sizeof(EXTLOGPEN), NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD)); - RTEST(GetObject(hPen, 0, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD)); - RTEST(GetObject((HANDLE)GDI_HANDLE_GET_INDEX(hPen), 0, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD)); - RTEST(GetObject(hPen, 5, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD)); - RTEST(GetObject(hPen, -5, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD)); - RTEST(GetObject(hPen, 0, &extlogpen) == 0); - RTEST(GetObject(hPen, 4, &extlogpen) == 0); - - /* Nothing should be filled */ - RTEST(extlogpen.elpPenStyle == 0x77777777); - RTEST(extlogpen.elpWidth == 0x77777777); - - RTEST(GetObject(hPen, sizeof(EXTLOGPEN), &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD)); - RTEST(GetObject(hPen, sizeof(EXTLOGPEN)-sizeof(DWORD), &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD)); - RTEST(GetObject(hPen, sizeof(EXTLOGPEN)-sizeof(DWORD)-1, &extlogpen) == 0); - RTEST(GetObject(hPen, sizeof(EXTLOGPEN)+2, &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD)); - RTEST(GetObject(hPen, -5, &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD)); - - /* test if the fields are filled correctly */ - RTEST(extlogpen.elpPenStyle == (PS_GEOMETRIC | PS_DASH)); - RTEST(extlogpen.elpWidth == 5); - RTEST(extlogpen.elpBrushStyle == 0); - RTEST(extlogpen.elpColor == RGB(1,2,3)); - RTEST(extlogpen.elpHatch == 22); - RTEST(extlogpen.elpNumEntries == 0); - DeleteObject(hPen); - - /* A maximum of 16 Styles is allowed */ - hPen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE, 5, &logbrush, 16, (CONST DWORD*)&dwStyles); - RTEST(GetObject(hPen, 0, NULL) == sizeof(EXTLOGPEN) + 15*sizeof(DWORD)); - RTEST(GetObject(hPen, sizeof(EXTLOGPEN) + 15*sizeof(DWORD), &elpUserStyle) == sizeof(EXTLOGPEN) + 15*sizeof(DWORD)); - RTEST(((EXTLOGPEN*)&elpUserStyle)->elpStyleEntry[0] == 0); - RTEST(((EXTLOGPEN*)&elpUserStyle)->elpStyleEntry[1] == 1); - RTEST(((EXTLOGPEN*)&elpUserStyle)->elpStyleEntry[15] == 15); - DeleteObject(hPen); - - return TRUE; -} - -static INT -Test_Font(PTESTINFO pti) -{ - HFONT hFont; - LOGFONTA logfonta; - LOGFONTW logfontw; - EXTLOGFONTA extlogfonta; - EXTLOGFONTW extlogfontw; - ENUMLOGFONTEXA enumlogfontexa; - ENUMLOGFONTEXW enumlogfontexw; - ENUMLOGFONTEXDVA enumlogfontexdva; - ENUMLOGFONTEXDVW enumlogfontexdvw; - ENUMLOGFONTA enumlogfonta; - ENUMLOGFONTW enumlogfontw; - BYTE bData[270]; - - FillMemory(&logfonta, sizeof(LOGFONTA), 0x77); - hFont = CreateFontA(8, 8, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, - ANSI_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, - ANTIALIASED_QUALITY, DEFAULT_PITCH, "testfont"); - RTEST(hFont); - - SetLastError(ERROR_SUCCESS); - RTEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, 0, NULL) == sizeof(LOGFONTA)); - RTEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, 0, NULL) == sizeof(LOGFONTW)); - RTEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(LOGFONTA), NULL) == sizeof(LOGFONTA)); // 60 - RTEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTA), NULL) == sizeof(LOGFONTA)); // 156 - RTEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXA), NULL) == sizeof(LOGFONTA)); // 188 - RTEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(EXTLOGFONTA), NULL) == sizeof(LOGFONTA)); // 192 - RTEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVA), NULL) == sizeof(LOGFONTA)); // 260 - RTEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVA)+1, NULL) == sizeof(LOGFONTA)); // 260 - RTEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(LOGFONTW), NULL) == sizeof(LOGFONTW)); // 92 - RTEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTW), NULL) == sizeof(LOGFONTW)); // 284 - RTEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(EXTLOGFONTW), NULL) == sizeof(LOGFONTW)); // 320 - RTEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXW), NULL) == sizeof(LOGFONTW)); // 348 - RTEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVW), NULL) == sizeof(LOGFONTW)); // 420 - RTEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVW)+1, NULL) == sizeof(LOGFONTW)); // 356! - - RTEST(GetObjectA(hFont, sizeof(LOGFONTA), NULL) == sizeof(LOGFONTA)); - RTEST(GetObjectA(hFont, 0, NULL) == sizeof(LOGFONTA)); - RTEST(GetObjectA(hFont, 5, NULL) == sizeof(LOGFONTA)); - RTEST(GetObjectA(hFont, -5, NULL) == sizeof(LOGFONTA)); - RTEST(GetObjectA(hFont, 0, &logfonta) == 0); - RTEST(logfonta.lfHeight == 0x77777777); - - TEST(GetObjectA(hFont, 5, &logfonta) == 5); - TEST(logfonta.lfHeight == 8); - TEST(logfonta.lfWidth == 0x77777708); - - RTEST(GetObjectA(hFont, sizeof(LOGFONTA), &logfonta) == sizeof(LOGFONTA)); // 60 - TEST(GetObjectA(hFont, sizeof(LOGFONTW), &logfontw) == sizeof(LOGFONTA)); // 92 - RTEST(GetObjectA(hFont, sizeof(EXTLOGFONTA), &extlogfonta) == sizeof(EXTLOGFONTA)); // 192 - TEST(GetObjectA(hFont, sizeof(EXTLOGFONTA)+1, &extlogfonta) == sizeof(EXTLOGFONTA)+1); // 192 - TEST(GetObjectA(hFont, sizeof(EXTLOGFONTW), &extlogfontw) == sizeof(ENUMLOGFONTEXDVA)); // 320 - - TEST(GetObjectA(hFont, 261, &bData) == 260); // no - - /* LOGFONT / GetObjectW */ - FillMemory(&logfontw, sizeof(LOGFONTW), 0x77); - - RTEST(GetObjectW(hFont, sizeof(LOGFONTW), NULL) == sizeof(LOGFONTW)); - RTEST(GetObjectW(hFont, 0, NULL) == sizeof(LOGFONTW)); - RTEST(GetObjectW(hFont, 5, NULL) == sizeof(LOGFONTW)); - RTEST(GetObjectW(hFont, -5, NULL) == sizeof(LOGFONTW)); - RTEST(GetObjectW(hFont, 0, &logfontw) == 0); - RTEST(logfontw.lfHeight == 0x77777777); - - TEST(GetObjectW(hFont, 5, &logfontw) == 5); - TEST(logfontw.lfHeight == 8); - TEST(logfontw.lfWidth == 0x77777708); - - RTEST(GetObjectA(hFont, sizeof(LOGFONTA), &logfonta) == sizeof(LOGFONTA)); // 60 - RTEST(logfonta.lfHeight == 8); - RTEST(GetObjectA(hFont, sizeof(ENUMLOGFONTA), &enumlogfonta) == sizeof(ENUMLOGFONTA)); // 156 - RTEST(GetObjectA(hFont, sizeof(ENUMLOGFONTEXA), &enumlogfontexa) == sizeof(ENUMLOGFONTEXA)); // 188 - RTEST(GetObjectA(hFont, sizeof(EXTLOGFONTA), &extlogfonta) == sizeof(EXTLOGFONTA)); // 192 - RTEST(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA), &enumlogfontexdva) == sizeof(ENUMLOGFONTEXDVA)); // 260 - TEST(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA)+1, &enumlogfontexdva) == sizeof(ENUMLOGFONTEXDVA)); // 260 - - RTEST(GetObjectW(hFont, sizeof(LOGFONTW), &logfontw) == sizeof(LOGFONTW)); // 92 - RTEST(GetObjectW(hFont, sizeof(ENUMLOGFONTW), &enumlogfontw) == sizeof(ENUMLOGFONTW)); // 284 - RTEST(GetObjectW(hFont, sizeof(EXTLOGFONTW), &extlogfontw) == sizeof(EXTLOGFONTW)); // 320 - RTEST(GetObjectW(hFont, sizeof(ENUMLOGFONTEXW), &enumlogfontexw) == sizeof(ENUMLOGFONTEXW)); // 348 - TEST(GetObjectW(hFont, sizeof(ENUMLOGFONTEXDVW), &enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD)); // 420 - TEST(GetObjectW(hFont, sizeof(ENUMLOGFONTEXDVW)+1, &enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD)); // 356! - - TEST(GetObjectW(hFont, 356, &bData) == 356); - TEST(GetLastError() == ERROR_SUCCESS); - - DeleteObject(hFont); - - return TRUE; -} - -static INT -Test_Colorspace(PTESTINFO pti) -{ - SetLastError(ERROR_SUCCESS); - TEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 0, NULL) == 60);// FIXME: what structure? - TEST(GetLastError() == ERROR_INSUFFICIENT_BUFFER); - SetLastError(ERROR_SUCCESS); - RTEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 0, NULL) == 0); - TEST(GetLastError() == ERROR_INSUFFICIENT_BUFFER); - - return TRUE; -} - -static INT -Test_MetaDC(PTESTINFO pti) -{ - /* Windows does not SetLastError() on a metadc, but it doesn't seem to do anything with it */ - HDC hMetaDC; - BYTE buffer[100]; - - hMetaDC = CreateMetaFile(NULL); - if(!hMetaDC) return FALSE; - if(((UINT_PTR)hMetaDC & GDI_HANDLE_TYPE_MASK) != GDI_OBJECT_TYPE_METADC) return FALSE; - - SetLastError(ERROR_SUCCESS); - RTEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_METADC, 0, NULL) == 0); - RTEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_METADC, 100, &buffer) == 0); - RTEST(GetObjectA(hMetaDC, 0, NULL) == 0); - RTEST(GetObjectA(hMetaDC, 100, &buffer) == 0); - RTEST(GetLastError() == ERROR_SUCCESS); - return TRUE; -} - -INT -Test_GetObject(PTESTINFO pti) -{ - - HRGN hRgn; - hRgn = CreateRectRgn(0,0,5,5); - SetLastError(ERROR_SUCCESS); - RTEST(GetObjectW(hRgn, 0, NULL) == 0); - RTEST(GetLastError() == ERROR_INVALID_HANDLE); - DeleteObject(hRgn); - - Test_Font(pti); - Test_Colorspace(pti); - Test_General(pti); - Test_Bitmap(pti); - Test_Dibsection(pti); - Test_Palette(pti); - Test_Brush(pti); - Test_Pen(pti); - Test_ExtPen(pti); // not implemented yet in ROS - Test_MetaDC(pti); - - return APISTATUS_NORMAL; -} diff --git a/rostests/apitests/gdi32api/tests/SetDCPenColor.c b/rostests/apitests/gdi32api/tests/SetDCPenColor.c deleted file mode 100644 index d69b3dffa0c..00000000000 --- a/rostests/apitests/gdi32api/tests/SetDCPenColor.c +++ /dev/null @@ -1,51 +0,0 @@ -INT -Test_SetDCPenColor(PTESTINFO pti) -{ - HDC hScreenDC, hDC; - HBITMAP hbmp; - - // Test an incorrect DC - SetLastError(ERROR_SUCCESS); - RTEST(SetDCPenColor(0, RGB(0,0,0)) == CLR_INVALID); - RTEST(GetLastError() == ERROR_INVALID_PARAMETER); - - // Get the Screen DC - hScreenDC = GetDC(NULL); - if (hScreenDC == NULL) return FALSE; - - // Test the screen DC - SetDCPenColor(hScreenDC, RGB(1,2,3)); - RTEST(SetDCPenColor(hScreenDC, RGB(4,5,6)) == RGB(1,2,3)); - - // Create a new DC - hDC = CreateCompatibleDC(hScreenDC); - ReleaseDC(0, hScreenDC); - ASSERT(hDC); - - // Select the DC_PEN and check if the pen returned by a new call is DC_PEN - SelectObject(hDC, GetStockObject(DC_PEN)); - RTEST(SelectObject(hDC, GetStockObject(BLACK_PEN)) == GetStockObject(DC_PEN)); - - // Test an incorrect color, yes windows sets the color! - SetDCPenColor(hDC, 0x21123456); - RTEST(SetDCPenColor(hDC, RGB(0,0,0)) == 0x21123456); - - // Test CLR_INVALID, it sets CLR_INVALID! - SetDCPenColor(hDC, CLR_INVALID); - RTEST(SetDCPenColor(hDC, RGB(0,0,0)) == CLR_INVALID); - - hbmp = CreateBitmap(10, 10, 1, 32, NULL); - ASSERT(hbmp); - - SelectObject(hDC, hbmp); - SelectObject(hDC, GetStockObject(DC_PEN)); - SetDCPenColor(hDC, 0x123456); - MoveToEx(hDC, 0, 0, NULL); - LineTo(hDC, 10, 0); - TEST(GetPixel(hDC, 5, 0) == 0x123456); - - // Delete the DC - DeleteDC(hDC); - - return APISTATUS_NORMAL; -} diff --git a/rostests/apitests/gdi32api/tests/SetWorldTransform.c b/rostests/apitests/gdi32api/tests/SetWorldTransform.c deleted file mode 100644 index 7aa79d5cdea..00000000000 --- a/rostests/apitests/gdi32api/tests/SetWorldTransform.c +++ /dev/null @@ -1,20 +0,0 @@ -INT -Test_SetWorldTransform(PTESTINFO pti) -{ - PGDI_TABLE_ENTRY pEntry; - HDC hScreenDC, hDC; - DC_ATTR* pDC_Attr; - - /* Create a DC */ - hScreenDC = GetDC(NULL); - hDC = CreateCompatibleDC(hScreenDC); - ReleaseDC(NULL, hScreenDC); - SetGraphicsMode(hDC, GM_ADVANCED); - - pEntry = GdiHandleTable + GDI_HANDLE_GET_INDEX(hDC); - pDC_Attr = pEntry->UserData; - - DeleteDC(hDC); - - return APISTATUS_NORMAL; -} From 967f731f6aab8d82dc6db50fd9642a0129aead0d Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 25 Aug 2010 08:29:52 +0000 Subject: [PATCH 48/76] [FASTFAT] - "Fix for a stupid mistake" - patch by Pierre Schweitzer svn path=/trunk/; revision=48618 --- reactos/drivers/filesystems/fastfat/pnp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/reactos/drivers/filesystems/fastfat/pnp.c b/reactos/drivers/filesystems/fastfat/pnp.c index a1e909e7da9..b77c04ce142 100644 --- a/reactos/drivers/filesystems/fastfat/pnp.c +++ b/reactos/drivers/filesystems/fastfat/pnp.c @@ -29,6 +29,8 @@ NTSTATUS VfatPnp(PVFAT_IRP_CONTEXT IrpContext) case IRP_MN_REMOVE_DEVICE: case IRP_MN_CANCEL_REMOVE_DEVICE: Status = STATUS_NOT_IMPLEMENTED; + IrpContext->Irp->IoStatus.Status = Status; + IoCompleteRequest(IrpContext->Irp, IO_NO_INCREMENT); break; default: IoSkipCurrentIrpStackLocation(IrpContext->Irp); From ecc68049763a133d33a7c52ba7caa5af2b217bd8 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 25 Aug 2010 08:48:55 +0000 Subject: [PATCH 49/76] [APITESTS] Convert dciman32api, user32api and wa2_32 into wine style tests svn path=/trunk/; revision=48619 --- rostests/apitests/dciman32api/dciman32api.c | 19 - rostests/apitests/dciman32api/dciman32api.h | 22 - .../apitests/dciman32api/dciman32api.rbuild | 9 - rostests/apitests/dciman32api/testlist.c | 32 -- .../dciman32api/tests/DCICreatePrimary.c | 8 - rostests/apitests/directory.rbuild | 10 +- rostests/apitests/user32api/testlist.c | 33 -- .../user32api/tests/GetSystemMetrics.c | 396 ------------------ .../user32api/tests/InitializeLpkHooks.c | 96 ----- .../user32api/tests/RealGetWindowClass.c | 119 ------ rostests/apitests/user32api/tests/ScrollDC.c | 57 --- .../apitests/user32api/tests/ScrollWindowEx.c | 47 --- rostests/apitests/user32api/user32api.c | 18 - rostests/apitests/user32api/user32api.h | 10 - rostests/apitests/user32api/user32api.rbuild | 9 - rostests/apitests/ws2_32/helpers.c | 24 +- rostests/apitests/ws2_32/ioctlsocket.c | 98 +++++ rostests/apitests/ws2_32/{tests => }/recv.c | 68 +-- rostests/apitests/ws2_32/testlist.c | 39 +- rostests/apitests/ws2_32/tests/ioctlsocket.c | 83 ---- rostests/apitests/ws2_32/ws2_32.c | 24 -- rostests/apitests/ws2_32/ws2_32.h | 12 +- rostests/apitests/ws2_32/ws2_32.rbuild | 9 - .../apitests/ws2_32/ws2_32_apitest.rbuild | 18 + 24 files changed, 193 insertions(+), 1067 deletions(-) delete mode 100644 rostests/apitests/dciman32api/dciman32api.c delete mode 100644 rostests/apitests/dciman32api/dciman32api.h delete mode 100644 rostests/apitests/dciman32api/dciman32api.rbuild delete mode 100644 rostests/apitests/dciman32api/testlist.c delete mode 100644 rostests/apitests/dciman32api/tests/DCICreatePrimary.c delete mode 100644 rostests/apitests/user32api/testlist.c delete mode 100644 rostests/apitests/user32api/tests/GetSystemMetrics.c delete mode 100644 rostests/apitests/user32api/tests/InitializeLpkHooks.c delete mode 100644 rostests/apitests/user32api/tests/RealGetWindowClass.c delete mode 100644 rostests/apitests/user32api/tests/ScrollDC.c delete mode 100644 rostests/apitests/user32api/tests/ScrollWindowEx.c delete mode 100644 rostests/apitests/user32api/user32api.c delete mode 100644 rostests/apitests/user32api/user32api.h delete mode 100644 rostests/apitests/user32api/user32api.rbuild create mode 100644 rostests/apitests/ws2_32/ioctlsocket.c rename rostests/apitests/ws2_32/{tests => }/recv.c (51%) delete mode 100644 rostests/apitests/ws2_32/tests/ioctlsocket.c delete mode 100644 rostests/apitests/ws2_32/ws2_32.c delete mode 100644 rostests/apitests/ws2_32/ws2_32.rbuild create mode 100644 rostests/apitests/ws2_32/ws2_32_apitest.rbuild diff --git a/rostests/apitests/dciman32api/dciman32api.c b/rostests/apitests/dciman32api/dciman32api.c deleted file mode 100644 index f01aa41a64d..00000000000 --- a/rostests/apitests/dciman32api/dciman32api.c +++ /dev/null @@ -1,19 +0,0 @@ -#include "dciman32api.h" - -HINSTANCE g_hInstance; - -BOOL -IsFunctionPresent(LPWSTR lpszFunction) -{ - return TRUE; -} - -int APIENTRY -WinMain(HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPSTR lpCmdLine, - int nCmdShow) -{ - g_hInstance = hInstance; - return TestMain(L"dciman32api", L"dciman32.dll"); -} diff --git a/rostests/apitests/dciman32api/dciman32api.h b/rostests/apitests/dciman32api/dciman32api.h deleted file mode 100644 index 658e6bdd6b1..00000000000 --- a/rostests/apitests/dciman32api/dciman32api.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0501 -#endif - -#define WIN32_NO_STATUS -#include -#include -#include -#include -#include -#include -#include - -/* Public Win32K Headers */ -#include -#include -#include - -#include "../apitest.h" - - - diff --git a/rostests/apitests/dciman32api/dciman32api.rbuild b/rostests/apitests/dciman32api/dciman32api.rbuild deleted file mode 100644 index 7e6687be3f8..00000000000 --- a/rostests/apitests/dciman32api/dciman32api.rbuild +++ /dev/null @@ -1,9 +0,0 @@ - - . - apitest - user32 - gdi32 - shell32 - dciman32api.c - testlist.c - diff --git a/rostests/apitests/dciman32api/testlist.c b/rostests/apitests/dciman32api/testlist.c deleted file mode 100644 index 2726bb7352a..00000000000 --- a/rostests/apitests/dciman32api/testlist.c +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef _DCIMAN32TESTLIST_H -#define _DCIMAN32TESTLIST_H - -#include "dciman32api.h" - -/* include the tests */ -#include "tests/DCICreatePrimary.c" - - - - - - - - - - -/* The List of tests */ -TESTENTRY TestList[] = -{ - { L"DCICreatePrimary", Test_DCICreatePrimary } -}; - -/* The function that gives us the number of tests */ -INT NumTests(void) -{ - return sizeof(TestList) / sizeof(TESTENTRY); -} - -#endif - -/* EOF */ diff --git a/rostests/apitests/dciman32api/tests/DCICreatePrimary.c b/rostests/apitests/dciman32api/tests/DCICreatePrimary.c deleted file mode 100644 index 2590158c5e9..00000000000 --- a/rostests/apitests/dciman32api/tests/DCICreatePrimary.c +++ /dev/null @@ -1,8 +0,0 @@ - -INT -Test_DCICreatePrimary(PTESTINFO pti) -{ - - return APISTATUS_NORMAL; -} - diff --git a/rostests/apitests/directory.rbuild b/rostests/apitests/directory.rbuild index 319878f83d2..f5816b8aaf0 100644 --- a/rostests/apitests/directory.rbuild +++ b/rostests/apitests/directory.rbuild @@ -6,16 +6,16 @@ apitest.c - - + + - - + + @@ -29,6 +29,6 @@ - + diff --git a/rostests/apitests/user32api/testlist.c b/rostests/apitests/user32api/testlist.c deleted file mode 100644 index 0dc05131500..00000000000 --- a/rostests/apitests/user32api/testlist.c +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _USER32TESTLIST_H -#define _USER32TESTLIST_H - -#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) - -#include "user32api.h" - -/* include the tests */ -#include "tests/GetSystemMetrics.c" -#include "tests/InitializeLpkHooks.c" -#include "tests/ScrollDC.c" -#include "tests/ScrollWindowEx.c" -#include "tests/RealGetWindowClass.c" - -/* The List of tests */ -TESTENTRY TestList[] = -{ - { L"GetSystemMetrics", Test_GetSystemMetrics }, - { L"InitializeLpkHooks", Test_InitializeLpkHooks }, - { L"ScrollDC", Test_ScrollDC }, - { L"ScrollWindowEx", Test_ScrollWindowEx }, - { L"RealGetWindowClass", Test_RealGetWindowClass }, -}; - -/* The function that gives us the number of tests */ -INT NumTests(void) -{ - return ARRAY_SIZE(TestList); -} - -#endif /* _USER32TESTLIST_H */ - -/* EOF */ diff --git a/rostests/apitests/user32api/tests/GetSystemMetrics.c b/rostests/apitests/user32api/tests/GetSystemMetrics.c deleted file mode 100644 index 720f0f7a91d..00000000000 --- a/rostests/apitests/user32api/tests/GetSystemMetrics.c +++ /dev/null @@ -1,396 +0,0 @@ - -INT -Test_GetSystemMetrics(PTESTINFO pti) -{ - INT ret; - HDC hDC; - BOOL BoolVal; - UINT UintVal; - RECT rect; - - SetLastError(0); - hDC = GetDC(0); - - ret = GetSystemMetrics(0); - TEST(ret > 0); - - ret = GetSystemMetrics(64); - TEST(ret == 0); - ret = GetSystemMetrics(65); - TEST(ret == 0); - ret = GetSystemMetrics(66); - TEST(ret == 0); - - - ret = GetSystemMetrics(SM_CXSCREEN); - TEST(ret == GetDeviceCaps(hDC, HORZRES)); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYSCREEN); - TEST(ret == GetDeviceCaps(hDC, VERTRES)); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CXVSCROLL); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYHSCROLL); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYCAPTION); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CXBORDER); - SystemParametersInfoW(SPI_GETFOCUSBORDERWIDTH, 0, &UintVal, 0); - TEST(ret == UintVal); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYBORDER); - SystemParametersInfoW(SPI_GETFOCUSBORDERHEIGHT, 0, &UintVal, 0); - TEST(ret == UintVal); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CXDLGFRAME); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYDLGFRAME); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYVTHUMB); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CXHTHUMB); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CXICON); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYICON); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CXCURSOR); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYCURSOR); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYMENU); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - SystemParametersInfoW(SPI_GETWORKAREA, 0, &rect, 0); - ret = GetSystemMetrics(SM_CXFULLSCREEN); - TEST(ret == rect.right); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYFULLSCREEN); - TEST(ret == rect.bottom - rect.top - GetSystemMetrics(SM_CYCAPTION)); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYKANJIWINDOW); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_MOUSEPRESENT); - TEST(ret == 1); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYVSCROLL); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CXHSCROLL); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_DEBUG); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_SWAPBUTTON); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_RESERVED1); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_RESERVED2); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_RESERVED3); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_RESERVED4); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CXMIN); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYMIN); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CXSIZE); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYSIZE); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CXFRAME); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYFRAME); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CXMINTRACK); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYMINTRACK); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CXDOUBLECLK); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYDOUBLECLK); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CXICONSPACING); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYICONSPACING); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_MENUDROPALIGNMENT); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_PENWINDOWS); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_DBCSENABLED); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CMOUSEBUTTONS); -// TEST(ret == 0); - TEST(GetLastError() == 0); - -#if(WINVER >= 0x0400) - ret = GetSystemMetrics(SM_SECURE); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CXEDGE); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYEDGE); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CXMINSPACING); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYMINSPACING); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CXSMICON); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYSMICON); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYSMCAPTION); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CXSMSIZE); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYSMSIZE); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CXMENUSIZE); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYMENUSIZE); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_ARRANGE); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CXMINIMIZED); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYMINIMIZED); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CXMAXTRACK); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYMAXTRACK); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CXMAXIMIZED); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYMAXIMIZED); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_NETWORK); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CLEANBOOT); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CXDRAG); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYDRAG); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_SHOWSOUNDS); - SystemParametersInfoW(SPI_GETSHOWSOUNDS, 0, &BoolVal, 0); - TEST(ret == BoolVal); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CXMENUCHECK); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYMENUCHECK); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_SLOWMACHINE); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_MIDEASTENABLED); -// TEST(ret == 0); - TEST(GetLastError() == 0); -#endif - -#if (WINVER >= 0x0500) || (_WIN32_WINNT >= 0x0400) - ret = GetSystemMetrics(SM_MOUSEWHEELPRESENT); -// TEST(ret == 0); - TEST(GetLastError() == 0); -#endif - -#if(WINVER >= 0x0500) - ret = GetSystemMetrics(SM_XVIRTUALSCREEN); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_YVIRTUALSCREEN); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CXVIRTUALSCREEN); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYVIRTUALSCREEN); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CMONITORS); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_SAMEDISPLAYFORMAT); -// TEST(ret == 0); - TEST(GetLastError() == 0); -#endif - -#if(_WIN32_WINNT >= 0x0500) - ret = GetSystemMetrics(SM_IMMENABLED); - TEST(ret == 0); - TEST(GetLastError() == 0); -#endif - -#if(_WIN32_WINNT >= 0x0501) - ret = GetSystemMetrics(SM_CXFOCUSBORDER); - SystemParametersInfoW(SPI_GETFOCUSBORDERWIDTH, 0, &UintVal, 0); - TEST(ret == UintVal); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CYFOCUSBORDER); - SystemParametersInfoW(SPI_GETFOCUSBORDERHEIGHT, 0, &UintVal, 0); - TEST(ret == UintVal); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_TABLETPC); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_MEDIACENTER); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_STARTER); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_SERVERR2); -// TEST(ret == 0); - TEST(GetLastError() == 0); -#endif - -#if(_WIN32_WINNT >= 0x0600) - ret = GetSystemMetrics(SM_MOUSEHORIZONTALWHEELPRESENT); -// TEST(ret == 0); - TEST(GetLastError() == 0); - - ret = GetSystemMetrics(SM_CXPADDEDBORDER); -// TEST(ret == 0); - TEST(GetLastError() == 0); -#endif - - return APISTATUS_NORMAL; -} diff --git a/rostests/apitests/user32api/tests/InitializeLpkHooks.c b/rostests/apitests/user32api/tests/InitializeLpkHooks.c deleted file mode 100644 index 85e6d7a4667..00000000000 --- a/rostests/apitests/user32api/tests/InitializeLpkHooks.c +++ /dev/null @@ -1,96 +0,0 @@ - -typedef struct _LPK_LPEDITCONTROL_LIST -{ - PVOID EditCreate; - PVOID EditIchToXY; - PVOID EditMouseToIch; - PVOID EditCchInWidth; - PVOID EditGetLineWidth; - PVOID EditDrawText; - PVOID EditHScroll; - PVOID EditMoveSelection; - PVOID EditVerifyText; - PVOID EditNextWord; - PVOID EditSetMenu; - PVOID EditProcessMenu; - PVOID EditCreateCaret; - PVOID EditAdjustCaret; -} LPK_LPEDITCONTROL_LIST, *PLPK_LPEDITCONTROL_LIST; - - -DWORD (APIENTRY *fpLpkTabbedTextOut) (LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID); -DWORD (APIENTRY *fpLpkPSMTextOut) (LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID); -DWORD (APIENTRY *fpLpkDrawTextEx) (LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID); -PLPK_LPEDITCONTROL_LIST (APIENTRY *fpLpkEditControl) (); - -int Count_myLpkTabbedTextOut = 0; -int Count_myLpkPSMTextOut = 0; -int Count_myLpkDrawTextEx = 0; - -DWORD WINAPI myLpkTabbedTextOut (LPVOID x1,LPVOID x2,LPVOID x3, LPVOID x4, LPVOID x5, LPVOID x6, LPVOID x7, LPVOID x8, - LPVOID x9, LPVOID x10, LPVOID x11, LPVOID x12) -{ - Count_myLpkTabbedTextOut++; - return fpLpkTabbedTextOut(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12); -} - -DWORD myLpkPSMTextOut (LPVOID x1,LPVOID x2,LPVOID x3,LPVOID x4,LPVOID x5,LPVOID x6) -{ - Count_myLpkPSMTextOut++; - return fpLpkPSMTextOut ( x1, x2, x3, x4, x5, x6); -} - -DWORD myLpkDrawTextEx(LPVOID x1,LPVOID x2,LPVOID x3,LPVOID x4,LPVOID x5, LPVOID x6, LPVOID x7, LPVOID x8, LPVOID x9,LPVOID x10) -{ - Count_myLpkDrawTextEx++; - return fpLpkDrawTextEx(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10); -} - - -typedef struct _USER32_INTERN_INITALIZEHOOKS -{ - PVOID fpLpkTabbedTextOut; - PVOID fpLpkPSMTextOut; - PVOID fpLpkDrawTextEx; - PLPK_LPEDITCONTROL_LIST fpListLpkEditControl; -} USER32_INTERN_INITALIZEHOOKS, *PUSER32_INTERN_INITALIZEHOOKS; - -VOID WINAPI InitializeLpkHooks (PUSER32_INTERN_INITALIZEHOOKS); - -INT -Test_InitializeLpkHooks(PTESTINFO pti) -{ - USER32_INTERN_INITALIZEHOOKS setup; - HMODULE lib = LoadLibrary("LPK.DLL"); - - TEST(lib != NULL); - if (lib != NULL) - { - fpLpkTabbedTextOut = (DWORD (APIENTRY *) (LPVOID,LPVOID,LPVOID,LPVOID,LPVOID, LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID)) GetProcAddress(lib, "LpkTabbedTextOut"); - fpLpkPSMTextOut = (DWORD (APIENTRY *) (LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID)) GetProcAddress(lib, "fpLpkPSMTextOut"); - fpLpkDrawTextEx = (DWORD (APIENTRY *) (LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID)) GetProcAddress(lib, "LpkDrawTextEx"); - fpLpkEditControl = (PLPK_LPEDITCONTROL_LIST (APIENTRY *) (VOID)) GetProcAddress(lib, "LpkEditControl"); - - setup.fpLpkTabbedTextOut = myLpkTabbedTextOut; - setup.fpLpkPSMTextOut = myLpkPSMTextOut; - setup.fpLpkDrawTextEx = myLpkDrawTextEx; - - /* we have not add any test to this api */ - setup.fpListLpkEditControl = (PLPK_LPEDITCONTROL_LIST)fpLpkEditControl; - - /* use our own api that we just made */ - InitializeLpkHooks(&setup); - - /* FIXME add test now */ - - /* restore */ - setup.fpLpkTabbedTextOut = fpLpkTabbedTextOut; - setup.fpLpkPSMTextOut = fpLpkPSMTextOut; - setup.fpLpkDrawTextEx = fpLpkDrawTextEx; - setup.fpListLpkEditControl = (PLPK_LPEDITCONTROL_LIST)fpLpkEditControl; - InitializeLpkHooks(&setup); - } - - return APISTATUS_NORMAL; -} - diff --git a/rostests/apitests/user32api/tests/RealGetWindowClass.c b/rostests/apitests/user32api/tests/RealGetWindowClass.c deleted file mode 100644 index 25d94dc74b9..00000000000 --- a/rostests/apitests/user32api/tests/RealGetWindowClass.c +++ /dev/null @@ -1,119 +0,0 @@ -#include "../user32api.h" - -typedef struct _TestData -{ - BOOL OverrideWndProc; /* TRUE if lpfnWndProc should be overridden */ - LPCSTR ClassName; /* Name of the new class to register */ - DWORD WndExtra; /* Remove these WNDCLASS::cbWndExtra flags */ - BOOL ExpectsHwnd; /* TRUE if a HWND should be created to run tests on */ - LPCSTR ExpectedClassNameBefore; /* Expected class name before any dialog function is called */ - LPCSTR ExpectedClassNameAfter; /* Expected class name after any dialog function is called */ -} TestData; - -static TestData RealClassTestData[] = -{ - { - TRUE, - "OverrideWndProc_with_DLGWINDOWEXTRA_TRUE", - 0, - TRUE, - "OverrideWndProc_with_DLGWINDOWEXTRA_TRUE", - "#32770", - }, - { - TRUE, - "OverrideWndProc_without_DLGWINDOWEXTRA_TRUE", - DLGWINDOWEXTRA, - TRUE, - "OverrideWndProc_without_DLGWINDOWEXTRA_TRUE", - "OverrideWndProc_without_DLGWINDOWEXTRA_TRUE", - }, - { - FALSE, - "DefaultWndProc_with_DLGWINDOWEXTRA_FALSE", - 0, - TRUE, - "#32770", - "#32770", - }, - { - FALSE, - "DefaultWndProc_without_DLGWINDOWEXTRA_FALSE", - DLGWINDOWEXTRA, - FALSE, - "N/A", - "N/A", - }, -}; - -INT -Test_RealGetWindowClass(PTESTINFO pti) -{ - int testNo; - UINT Result; - CHAR Buffer[1024]; - - Result = RealGetWindowClass( NULL, Buffer, ARRAY_SIZE(Buffer) ); - TEST(Result == 0); - TEST(GetLastError() == ERROR_INVALID_WINDOW_HANDLE); - - for (testNo = 0; testNo < ARRAY_SIZE(RealClassTestData); testNo++) - { - ATOM atom; - WNDCLASSA cls; - HWND hWnd; - - /* Register classes, "derived" from built-in dialog, with and without the DLGWINDOWEXTRA flag set */ - GetClassInfoA(0, "#32770", &cls); - if (RealClassTestData[testNo].OverrideWndProc) - cls.lpfnWndProc = DefWindowProcA; - cls.lpszClassName = RealClassTestData[testNo].ClassName; - cls.cbWndExtra &= ~RealClassTestData[testNo].WndExtra; - atom = RegisterClassA (&cls); - ASSERT(atom != 0); - - /* Create a window */ - hWnd = CreateWindowEx( WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR | - WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE | WS_EX_CONTROLPARENT | WS_EX_APPWINDOW, - RealClassTestData[testNo].ClassName, - RealClassTestData[testNo].ClassName, - WS_POPUPWINDOW | WS_CLIPSIBLINGS | WS_DLGFRAME | WS_OVERLAPPED | - WS_MINIMIZEBOX | WS_MAXIMIZEBOX | DS_3DLOOK | DS_SETFONT | DS_MODALFRAME, - CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, - NULL, NULL, g_hInstance, 0); - - /* Do we expect a HWND at all? */ - if (RealClassTestData[testNo].ExpectsHwnd) - { - TEST(hWnd != NULL); - - if (hWnd != NULL) - { - /* Get the "real" class name */ - Result = RealGetWindowClass( hWnd, Buffer, ARRAY_SIZE(Buffer) ); - printf("Buffer: %s\nExpectedClassNameBefore(%d): %s\n", Buffer, testNo, RealClassTestData[testNo].ExpectedClassNameBefore); - TEST( Result != 0 ); - TEST( strcmp( Buffer, RealClassTestData[testNo].ExpectedClassNameBefore ) == 0 ); - - /* Call a function that requires a dialog window */ - DefDlgProcA( hWnd, DM_SETDEFID, IDCANCEL, 0 ); - - /* Get the "real" class name again */ - Result = RealGetWindowClass( hWnd, Buffer, ARRAY_SIZE(Buffer) ); - printf("Buffer: %s\nExpectedClassNameAfter(%d): %s\n", Buffer, testNo, RealClassTestData[testNo].ExpectedClassNameAfter); - TEST( Result != 0 ); - TEST( strcmp( Buffer, RealClassTestData[testNo].ExpectedClassNameAfter ) == 0 ); - } - } - else - { - TEST(hWnd == NULL); - } - - /* Cleanup */ - DestroyWindow(hWnd); - UnregisterClass(RealClassTestData[testNo].ClassName, g_hInstance); - } - - return APISTATUS_NORMAL; -} diff --git a/rostests/apitests/user32api/tests/ScrollDC.c b/rostests/apitests/user32api/tests/ScrollDC.c deleted file mode 100644 index 88be15372ac..00000000000 --- a/rostests/apitests/user32api/tests/ScrollDC.c +++ /dev/null @@ -1,57 +0,0 @@ -#include "../user32api.h" - -INT -Test_ScrollDC(PTESTINFO pti) -{ - HWND hWnd, hWnd2; - HDC hDC; - HRGN hrgn; - RECT rcClip; - - /* Create a window */ - hWnd = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW | WS_VISIBLE, - 100, 100, 100, 100, - NULL, NULL, g_hInstance, 0); - UpdateWindow(hWnd); - hDC = GetDC(hWnd); - - /* Assert that no update region is there */ - hrgn = CreateRectRgn(0,0,0,0); - ASSERT(GetUpdateRgn(hWnd, hrgn, FALSE) == NULLREGION); - - /* Test normal scrolling */ - TEST(ScrollDC(hDC, 0, 0, NULL, NULL, hrgn, NULL) == TRUE); - - /* Scroll with invalid update region */ - DeleteObject(hrgn); - TEST(ScrollDC(hDC, 50, 0, NULL, NULL, hrgn, NULL) == FALSE); - hrgn = CreateRectRgn(0,0,0,0); - TEST(GetUpdateRgn(hWnd, hrgn, FALSE) == NULLREGION); - - /* Scroll with invalid update rect pointer */ - TEST(ScrollDC(hDC, 50, 0, NULL, NULL, NULL, (PRECT)1) == 0); - TEST(GetUpdateRgn(hWnd, hrgn, FALSE) == NULLREGION); - - /* Scroll with a clip rect */ - rcClip.left = 50; rcClip.top = 0; rcClip.right = 100; rcClip.bottom = 100; - TEST(ScrollDC(hDC, 50, 0, NULL, &rcClip, hrgn, NULL) == TRUE); - TEST(GetUpdateRgn(hWnd, hrgn, FALSE) == NULLREGION); - - /* Scroll with a clip rect */ - rcClip.left = 50; rcClip.top = 0; rcClip.right = 100; rcClip.bottom = 100; - TEST(ScrollDC(hDC, 50, 50, NULL, &rcClip, hrgn, NULL) == TRUE); - TEST(GetUpdateRgn(hWnd, hrgn, FALSE) == NULLREGION); - - /* Overlap with another window */ - hWnd2 = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW | WS_VISIBLE, - 30, 160, 100, 100, - NULL, NULL, g_hInstance, 0); - UpdateWindow(hWnd2); - - /* Cleanup */ - ReleaseDC(hWnd, hDC); - DestroyWindow(hWnd); - DestroyWindow(hWnd2); - - return APISTATUS_NORMAL; -} diff --git a/rostests/apitests/user32api/tests/ScrollWindowEx.c b/rostests/apitests/user32api/tests/ScrollWindowEx.c deleted file mode 100644 index 2a6ed38dd0a..00000000000 --- a/rostests/apitests/user32api/tests/ScrollWindowEx.c +++ /dev/null @@ -1,47 +0,0 @@ -#include "../user32api.h" - -INT -Test_ScrollWindowEx(PTESTINFO pti) -{ - HWND hWnd; - HRGN hrgn; - int Result; - - /* Create a window */ - hWnd = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW | WS_VISIBLE, - CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, - NULL, NULL, g_hInstance, 0); - UpdateWindow(hWnd); - - /* Assert that no update region is there */ - hrgn = CreateRectRgn(0,0,0,0); - ASSERT(GetUpdateRgn(hWnd, hrgn, FALSE) == NULLREGION); - - Result = ScrollWindowEx(hWnd, 20, 0, NULL, NULL, NULL, NULL, 0); - TEST(Result == SIMPLEREGION); - TEST(GetUpdateRgn(hWnd, hrgn, FALSE) == NULLREGION); - - Result = ScrollWindowEx(hWnd, 20, 0, NULL, NULL, NULL, NULL, SW_INVALIDATE); - TEST(Result == SIMPLEREGION); - TEST(GetUpdateRgn(hWnd, hrgn, FALSE) == SIMPLEREGION); - UpdateWindow(hWnd); - - // test invalid update region - DeleteObject(hrgn); - Result = ScrollWindowEx(hWnd, 20, 0, NULL, NULL, hrgn, NULL, SW_INVALIDATE); - TEST(Result == ERROR); - hrgn = CreateRectRgn(0,0,0,0); - UpdateWindow(hWnd); - - // Test invalid updaterect pointer - Result = ScrollWindowEx(hWnd, 20, 0, NULL, NULL, NULL, (LPRECT)1, SW_INVALIDATE); - TEST(Result == ERROR); - TEST(GetUpdateRgn(hWnd, hrgn, FALSE) == SIMPLEREGION); - -// test for alignment of rects - - DeleteObject(hrgn); - DestroyWindow(hWnd); - - return APISTATUS_NORMAL; -} diff --git a/rostests/apitests/user32api/user32api.c b/rostests/apitests/user32api/user32api.c deleted file mode 100644 index b17e3aabc0c..00000000000 --- a/rostests/apitests/user32api/user32api.c +++ /dev/null @@ -1,18 +0,0 @@ -#include "user32api.h" - -HINSTANCE g_hInstance; - -BOOL -IsFunctionPresent(LPWSTR lpszFunction) -{ - return TRUE; -} - -int APIENTRY WinMain(HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPSTR lpCmdLine, - int nCmdShow) -{ - g_hInstance = hInstance; - return TestMain(L"user32api", L"user32.dll"); -} diff --git a/rostests/apitests/user32api/user32api.h b/rostests/apitests/user32api/user32api.h deleted file mode 100644 index 00115ac6351..00000000000 --- a/rostests/apitests/user32api/user32api.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _USER32TEST_H -#define _USER32TEST_H - -#include "../apitest.h" - -extern HINSTANCE g_hInstance; - -#endif /* _USER32TEST_H */ - -/* EOF */ diff --git a/rostests/apitests/user32api/user32api.rbuild b/rostests/apitests/user32api/user32api.rbuild deleted file mode 100644 index ea33d4e33ea..00000000000 --- a/rostests/apitests/user32api/user32api.rbuild +++ /dev/null @@ -1,9 +0,0 @@ - - . - apitest - user32 - gdi32 - shell32 - user32api.c - testlist.c - diff --git a/rostests/apitests/ws2_32/helpers.c b/rostests/apitests/ws2_32/helpers.c index 9033aed184f..44af7e93174 100644 --- a/rostests/apitests/ws2_32/helpers.c +++ b/rostests/apitests/ws2_32/helpers.c @@ -6,25 +6,27 @@ * COPYRIGHT: Copyright 2008 Colin Finck */ +#include +#include #include "ws2_32.h" -int CreateSocket(PTESTINFO pti, SOCKET* psck) +int CreateSocket(SOCKET* psck) { /* Create the socket */ *psck = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - TEST(*psck != INVALID_SOCKET); + ok(*psck != INVALID_SOCKET, "*psck = %d\n", *psck); if(*psck == INVALID_SOCKET) { printf("Winsock error code is %u\n", WSAGetLastError()); WSACleanup(); - return APISTATUS_ASSERTION_FAILED; + return 0; } - return APISTATUS_NORMAL; + return 1; } -int ConnectToReactOSWebsite(PTESTINFO pti, SOCKET sck) +int ConnectToReactOSWebsite(SOCKET sck) { int iResult; struct hostent* host; @@ -38,11 +40,11 @@ int ConnectToReactOSWebsite(PTESTINFO pti, SOCKET sck) sa.sin_port = htons(80); SCKTEST(connect(sck, (struct sockaddr *)&sa, sizeof(sa))); - - return APISTATUS_NORMAL; + + return 1; } -int GetRequestAndWait(PTESTINFO pti, SOCKET sck) +int GetRequestAndWait(SOCKET sck) { const char szGetRequest[] = "GET / HTTP/1.0\r\n\r\n"; int iResult; @@ -50,7 +52,7 @@ int GetRequestAndWait(PTESTINFO pti, SOCKET sck) /* Send the GET request */ SCKTEST(send(sck, szGetRequest, strlen(szGetRequest), 0)); - TEST(iResult == strlen(szGetRequest)); + ok(iResult == strlen(szGetRequest), "iResult = %d\n", iResult); /* Shutdown the SEND connection */ SCKTEST(shutdown(sck, SD_SEND)); @@ -60,6 +62,6 @@ int GetRequestAndWait(PTESTINFO pti, SOCKET sck) FD_SET(sck, &readable); SCKTEST(select(0, &readable, NULL, NULL, NULL)); - - return APISTATUS_NORMAL; + + return 1; } diff --git a/rostests/apitests/ws2_32/ioctlsocket.c b/rostests/apitests/ws2_32/ioctlsocket.c new file mode 100644 index 00000000000..83b0d05a00c --- /dev/null +++ b/rostests/apitests/ws2_32/ioctlsocket.c @@ -0,0 +1,98 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for ioctlsocket + * PROGRAMMERS: Colin Finck + */ + +#include +#include +#include +#include "ws2_32.h" + +int Test_ioctlsocket() +{ + LPSTR pszBuf; + int iResult; + SOCKET sck; + ULONG BytesAvailable; + ULONG BytesToRead; + WSADATA wdata; + + /* Start up Winsock */ + iResult = WSAStartup(MAKEWORD(2, 2), &wdata); + ok(iResult == 0, "WSAStartup failed. iResult = %d\n", iResult); + + /* If we call ioctlsocket without a socket, it should return with an error and do nothing. */ + BytesAvailable = 0xdeadbeef; + iResult = ioctlsocket(0, FIONREAD, &BytesAvailable); + ok(iResult == SOCKET_ERROR, "iResult = %d\n", iResult); + ok(BytesAvailable == 0xdeadbeef, "BytesAvailable = %ld\n", BytesAvailable); + + /* Create the socket */ + if (!CreateSocket(&sck)) + { + ok(0, "CreateSocket failed. Aborting test.\n"); + return 0; + } + + /* Now we can pass at least a socket, but we have no connection yet. The function should return 0. */ + BytesAvailable = 0xdeadbeef; + iResult = ioctlsocket(sck, FIONREAD, &BytesAvailable); + ok(iResult == 0, "iResult = %d\n", iResult); + ok(BytesAvailable == 0, "BytesAvailable = %ld\n", BytesAvailable); + + /* Connect to "www.reactos.org" */ + if (!ConnectToReactOSWebsite(sck)) + { + ok(0, "ConnectToReactOSWebsite failed. Aborting test.\n"); + return 0; + } + + /* Even with a connection, there shouldn't be any bytes available. */ + iResult = ioctlsocket(sck, FIONREAD, &BytesAvailable); + ok(iResult == 0, "iResult = %d\n", iResult); + ok(BytesAvailable == 0, "BytesAvailable = %ld\n", BytesAvailable); + + /* Send the GET request */ + if (!GetRequestAndWait(sck)) + { + ok(0, "GetRequestAndWait failed. Aborting test.\n"); + return 0; + } + + /* Try ioctlsocket with FIONREAD. There should be bytes available now. */ + SCKTEST(ioctlsocket(sck, FIONREAD, &BytesAvailable)); + ok(BytesAvailable != 0, "BytesAvailable = %ld\n", BytesAvailable); + + /* Get half of the data */ + BytesToRead = BytesAvailable / 2; + pszBuf = (LPSTR) HeapAlloc(GetProcessHeap(), 0, BytesToRead); + SCKTEST(recv(sck, pszBuf, BytesToRead, 0)); + HeapFree(GetProcessHeap(), 0, pszBuf); + + BytesToRead = BytesAvailable - BytesToRead; + + /* Now try ioctlsocket again. BytesAvailable should be at the value saved in BytesToRead now. */ + SCKTEST(ioctlsocket(sck, FIONREAD, &BytesAvailable)); + ok(BytesAvailable == BytesToRead, "BytesAvailable = %ld\n", BytesAvailable); + + /* Read those bytes */ + pszBuf = (LPSTR) HeapAlloc(GetProcessHeap(), 0, BytesToRead); + SCKTEST(recv(sck, pszBuf, BytesToRead, 0)); + HeapFree(GetProcessHeap(), 0, pszBuf); + + /* Try it for the last time. BytesAvailable should be at 0 now. */ + SCKTEST(ioctlsocket(sck, FIONREAD, &BytesAvailable)); + ok(BytesAvailable == 0, "BytesAvailable = %ld\n", BytesAvailable); + + closesocket(sck); + WSACleanup(); + return 1; +} + +START_TEST(ioctlsocket) +{ + Test_ioctlsocket(); +} + diff --git a/rostests/apitests/ws2_32/tests/recv.c b/rostests/apitests/ws2_32/recv.c similarity index 51% rename from rostests/apitests/ws2_32/tests/recv.c rename to rostests/apitests/ws2_32/recv.c index 4df6c0ecabd..aab7109a254 100644 --- a/rostests/apitests/ws2_32/tests/recv.c +++ b/rostests/apitests/ws2_32/recv.c @@ -1,20 +1,22 @@ /* - * PROJECT: ws2_32.dll API tests - * LICENSE: GPLv2 or any later version - * FILE: apitests/ws2_32/tests/recv.c - * PURPOSE: Tests for the recv function - * COPYRIGHT: Copyright 2008 Colin Finck + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for recv + * PROGRAMMERS: Colin Finck */ -#include "../ws2_32.h" +#include +#include +#include +#include "ws2_32.h" #define RECV_BUF 4 /* For valid test results, the ReactOS Website needs to return at least 8 bytes on a "GET / HTTP/1.0" request. Also the first 4 bytes and the last 4 bytes need to be different. Both factors usually apply on standard HTTP responses. */ -INT -Test_recv(PTESTINFO pti) + +int Test_recv() { const char szDummyBytes[RECV_BUF] = {0xFF, 0x00, 0xFF, 0x00}; @@ -25,45 +27,59 @@ Test_recv(PTESTINFO pti) WSADATA wdata; /* Start up Winsock */ - TEST(WSAStartup(MAKEWORD(2, 2), &wdata) == 0); + iResult = WSAStartup(MAKEWORD(2, 2), &wdata); + ok(iResult == 0, "WSAStartup failed, iResult == %d\n", iResult); /* If we call recv without a socket, it should return with an error and do nothing. */ memcpy(szBuf1, szDummyBytes, RECV_BUF); - TEST(recv(0, szBuf1, RECV_BUF, 0) == SOCKET_ERROR); - TEST(!memcmp(szBuf1, szDummyBytes, RECV_BUF)); + iResult = recv(0, szBuf1, RECV_BUF, 0); + ok(iResult == SOCKET_ERROR, "iRseult = %d\n", iResult); + ok(!memcmp(szBuf1, szDummyBytes, RECV_BUF), "not equal\n"); /* Create the socket */ - iResult = CreateSocket(pti, &sck); - if(iResult != APISTATUS_NORMAL) - return iResult; + if (!CreateSocket(&sck)) + { + ok(0, "CreateSocket failed. Aborting test.\n"); + return 0; + } /* Now we can pass at least a socket, but we have no connection yet. Should return with an error and do nothing. */ memcpy(szBuf1, szDummyBytes, RECV_BUF); - TEST(recv(sck, szBuf1, RECV_BUF, 0) == SOCKET_ERROR); - TEST(!memcmp(szBuf1, szDummyBytes, RECV_BUF)); + iResult = recv(sck, szBuf1, RECV_BUF, 0); + ok(iResult == SOCKET_ERROR, "iResult = %d\n", iResult); + ok(!memcmp(szBuf1, szDummyBytes, RECV_BUF), "not equal\n"); /* Connect to "www.reactos.org" */ - iResult = ConnectToReactOSWebsite(pti, sck); - if(iResult != APISTATUS_NORMAL) - return iResult; + if (!ConnectToReactOSWebsite(sck)) + { + ok(0, "ConnectToReactOSWebsite failed. Aborting test.\n"); + return 0; + } /* Send the GET request */ - iResult = GetRequestAndWait(pti, sck); - if(iResult != APISTATUS_NORMAL) - return iResult; + if (!GetRequestAndWait(sck)) + { + ok(0, "GetRequestAndWait failed. Aborting test.\n"); + return 0; + } /* Receive the data. MSG_PEEK will not change the internal number of bytes read, so that a subsequent request should return the same bytes again. */ SCKTEST(recv(sck, szBuf1, RECV_BUF, MSG_PEEK)); SCKTEST(recv(sck, szBuf2, RECV_BUF, 0)); - TEST(!memcmp(szBuf1, szBuf2, RECV_BUF)); + ok(!memcmp(szBuf1, szBuf2, RECV_BUF), "not equal\n"); /* The last recv() call moved the internal file pointer, so that the next request should return different data. */ SCKTEST(recv(sck, szBuf1, RECV_BUF, 0)); - TEST(memcmp(szBuf1, szBuf2, RECV_BUF)); + ok(memcmp(szBuf1, szBuf2, RECV_BUF), "equal\n"); closesocket(sck); WSACleanup(); - - return APISTATUS_NORMAL; + return 1; } + +START_TEST(recv) +{ + Test_recv(); +} + diff --git a/rostests/apitests/ws2_32/testlist.c b/rostests/apitests/ws2_32/testlist.c index fa579807f3f..e760096393e 100644 --- a/rostests/apitests/ws2_32/testlist.c +++ b/rostests/apitests/ws2_32/testlist.c @@ -1,33 +1,18 @@ -/* - * PROJECT: ws2_32.dll API tests - * LICENSE: GPLv2 or any later version - * FILE: apitests/ws2_32/testlist.c - * PURPOSE: Test list file - * COPYRIGHT: Copyright 2008 Colin Finck - */ +#define WIN32_LEAN_AND_MEAN +#define __ROS_LONG64__ +#include -#ifndef _WS2_32_TESTLIST_H -#define _WS2_32_TESTLIST_H +#define STANDALONE +#include "wine/test.h" -#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) +extern void func_ioctlsocket(void); +extern void func_recv(void); -#include "ws2_32.h" - -/* include the tests */ -#include "tests/ioctlsocket.c" -#include "tests/recv.c" - -/* The List of tests */ -TESTENTRY TestList[] = +const struct test winetest_testlist[] = { - { L"ioctlsocket", Test_ioctlsocket }, - { L"recv", Test_recv } + { "ioctlsocket", func_ioctlsocket }, + { "recv", func_recv }, + + { 0, 0 } }; -/* The function that gives us the number of tests */ -INT NumTests(void) -{ - return ARRAY_SIZE(TestList); -} - -#endif diff --git a/rostests/apitests/ws2_32/tests/ioctlsocket.c b/rostests/apitests/ws2_32/tests/ioctlsocket.c deleted file mode 100644 index 2d291f7eb4e..00000000000 --- a/rostests/apitests/ws2_32/tests/ioctlsocket.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * PROJECT: ws2_32.dll API tests - * LICENSE: GPLv2 or any later version - * FILE: apitests/ws2_32/tests/ioctlsocket.c - * PURPOSE: Tests for the ioctlsocket function - * COPYRIGHT: Copyright 2008 Colin Finck - */ - -#include "../ws2_32.h" - -/* For valid test results, the ReactOS Website needs to return at least 2 bytes on a "GET / HTTP/1.0" request. */ -INT -Test_ioctlsocket(PTESTINFO pti) -{ - LPSTR pszBuf; - int iResult; - SOCKET sck; - ULONG BytesAvailable; - ULONG BytesToRead; - WSADATA wdata; - - /* Start up Winsock */ - TEST(WSAStartup(MAKEWORD(2, 2), &wdata) == 0); - - /* If we call ioctlsocket without a socket, it should return with an error and do nothing. */ - BytesAvailable = 0xdeadbeef; - TEST(ioctlsocket(0, FIONREAD, &BytesAvailable) == SOCKET_ERROR); - TEST(BytesAvailable == 0xdeadbeef); - - /* Create the socket */ - iResult = CreateSocket(pti, &sck); - if(iResult != APISTATUS_NORMAL) - return iResult; - - /* Now we can pass at least a socket, but we have no connection yet. The function should return 0. */ - BytesAvailable = 0xdeadbeef; - TEST(ioctlsocket(sck, FIONREAD, &BytesAvailable) == 0); - TEST(BytesAvailable == 0); - - /* Connect to "www.reactos.org" */ - iResult = ConnectToReactOSWebsite(pti, sck); - if(iResult != APISTATUS_NORMAL) - return iResult; - - /* Even with a connection, there shouldn't be any bytes available. */ - TEST(ioctlsocket(sck, FIONREAD, &BytesAvailable) == 0); - TEST(BytesAvailable == 0); - - /* Send the GET request */ - iResult = GetRequestAndWait(pti, sck); - if(iResult != APISTATUS_NORMAL) - return iResult; - - /* Try ioctlsocket with FIONREAD. There should be bytes available now. */ - SCKTEST(ioctlsocket(sck, FIONREAD, &BytesAvailable)); - TEST(BytesAvailable != 0); - - /* Get half of the data */ - BytesToRead = BytesAvailable / 2; - pszBuf = (LPSTR) HeapAlloc(g_hHeap, 0, BytesToRead); - SCKTEST(recv(sck, pszBuf, BytesToRead, 0)); - HeapFree(g_hHeap, 0, pszBuf); - - BytesToRead = BytesAvailable - BytesToRead; - - /* Now try ioctlsocket again. BytesAvailable should be at the value saved in BytesToRead now. */ - SCKTEST(ioctlsocket(sck, FIONREAD, &BytesAvailable)); - TEST(BytesAvailable == BytesToRead); - - /* Read those bytes */ - pszBuf = (LPSTR) HeapAlloc(g_hHeap, 0, BytesToRead); - SCKTEST(recv(sck, pszBuf, BytesToRead, 0)); - HeapFree(g_hHeap, 0, pszBuf); - - /* Try it for the last time. BytesAvailable should be at 0 now. */ - SCKTEST(ioctlsocket(sck, FIONREAD, &BytesAvailable)); - TEST(BytesAvailable == 0); - - closesocket(sck); - WSACleanup(); - - return APISTATUS_NORMAL; -} diff --git a/rostests/apitests/ws2_32/ws2_32.c b/rostests/apitests/ws2_32/ws2_32.c deleted file mode 100644 index 42e8a9b68eb..00000000000 --- a/rostests/apitests/ws2_32/ws2_32.c +++ /dev/null @@ -1,24 +0,0 @@ -/* - * PROJECT: ws2_32.dll API tests - * LICENSE: GPLv2 or any later version - * FILE: apitests/ws2_32/ws2_32.c - * PURPOSE: Program entry point - * COPYRIGHT: Copyright 2008 Colin Finck - */ - -#include "ws2_32.h" - -HANDLE g_hHeap; - -BOOL -IsFunctionPresent(LPWSTR lpszFunction) -{ - return TRUE; -} - -int wmain() -{ - g_hHeap = GetProcessHeap(); - - return TestMain(L"ws2_32_apitests", L"ws2_32.dll"); -} diff --git a/rostests/apitests/ws2_32/ws2_32.h b/rostests/apitests/ws2_32/ws2_32.h index 6fe52408fe8..e6fedc264b4 100644 --- a/rostests/apitests/ws2_32/ws2_32.h +++ b/rostests/apitests/ws2_32/ws2_32.h @@ -11,24 +11,22 @@ #include -#include "../apitest.h" - /* Simple macro for executing a socket command and doing cleanup operations in case of a failure */ #define SCKTEST(_cmd_) \ iResult = _cmd_; \ - TEST(iResult != SOCKET_ERROR); \ + ok(iResult != SOCKET_ERROR, "iResult = %d\n", iResult); \ if(iResult == SOCKET_ERROR) \ { \ printf("Winsock error code is %u\n", WSAGetLastError()); \ closesocket(sck); \ WSACleanup(); \ - return APISTATUS_ASSERTION_FAILED; \ + return 0; \ } /* helpers.c */ -int CreateSocket(PTESTINFO pti, SOCKET* sck); -int ConnectToReactOSWebsite(PTESTINFO pti, SOCKET sck); -int GetRequestAndWait(PTESTINFO pti, SOCKET sck); +int CreateSocket(SOCKET* sck); +int ConnectToReactOSWebsite(SOCKET sck); +int GetRequestAndWait(SOCKET sck); /* ws2_32.c */ extern HANDLE g_hHeap; diff --git a/rostests/apitests/ws2_32/ws2_32.rbuild b/rostests/apitests/ws2_32/ws2_32.rbuild deleted file mode 100644 index c00e7a2ddaf..00000000000 --- a/rostests/apitests/ws2_32/ws2_32.rbuild +++ /dev/null @@ -1,9 +0,0 @@ - - apitest - user32 - shell32 - ws2_32 - helpers.c - testlist.c - ws2_32.c - diff --git a/rostests/apitests/ws2_32/ws2_32_apitest.rbuild b/rostests/apitests/ws2_32/ws2_32_apitest.rbuild new file mode 100644 index 00000000000..356425806ee --- /dev/null +++ b/rostests/apitests/ws2_32/ws2_32_apitest.rbuild @@ -0,0 +1,18 @@ + + + + + . + wine + gdi32 + user32 + pseh + ws2_32 + testlist.c + helpers.c + + ioctlsocket.c + recv.c + + + From 57434c8ebfea1166c828a52ddbb411483698fdb6 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 25 Aug 2010 08:50:10 +0000 Subject: [PATCH 50/76] Add missing files svn path=/trunk/; revision=48620 --- rostests/apitests/dciman32/DCICreatePrimary.c | 21 + .../apitests/dciman32/dciman32_apitest.rbuild | 15 + rostests/apitests/dciman32/testlist.c | 16 + rostests/apitests/user32/GetSystemMetrics.c | 410 ++++++++++++++++++ rostests/apitests/user32/InitializeLpkHooks.c | 110 +++++ rostests/apitests/user32/RealGetWindowClass.c | 134 ++++++ rostests/apitests/user32/ScrollDC.c | 72 +++ rostests/apitests/user32/ScrollWindowEx.c | 63 +++ rostests/apitests/user32/testlist.c | 24 + .../apitests/user32/user32_apitest.rbuild | 19 + 10 files changed, 884 insertions(+) create mode 100644 rostests/apitests/dciman32/DCICreatePrimary.c create mode 100644 rostests/apitests/dciman32/dciman32_apitest.rbuild create mode 100644 rostests/apitests/dciman32/testlist.c create mode 100644 rostests/apitests/user32/GetSystemMetrics.c create mode 100644 rostests/apitests/user32/InitializeLpkHooks.c create mode 100644 rostests/apitests/user32/RealGetWindowClass.c create mode 100644 rostests/apitests/user32/ScrollDC.c create mode 100644 rostests/apitests/user32/ScrollWindowEx.c create mode 100644 rostests/apitests/user32/testlist.c create mode 100644 rostests/apitests/user32/user32_apitest.rbuild diff --git a/rostests/apitests/dciman32/DCICreatePrimary.c b/rostests/apitests/dciman32/DCICreatePrimary.c new file mode 100644 index 00000000000..e6409e9794e --- /dev/null +++ b/rostests/apitests/dciman32/DCICreatePrimary.c @@ -0,0 +1,21 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for DCICreatePrimary + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include + +void Test_DCICreatePrimary() +{ + +} + +START_TEST(DCICreatePrimary) +{ + Test_DCICreatePrimary(); +} + diff --git a/rostests/apitests/dciman32/dciman32_apitest.rbuild b/rostests/apitests/dciman32/dciman32_apitest.rbuild new file mode 100644 index 00000000000..950bb1b1bd7 --- /dev/null +++ b/rostests/apitests/dciman32/dciman32_apitest.rbuild @@ -0,0 +1,15 @@ + + + + + . + wine + gdi32 + user32 + pseh + testlist.c + + DCICreatePrimary.c + + + diff --git a/rostests/apitests/dciman32/testlist.c b/rostests/apitests/dciman32/testlist.c new file mode 100644 index 00000000000..4dba1298ec4 --- /dev/null +++ b/rostests/apitests/dciman32/testlist.c @@ -0,0 +1,16 @@ +#define WIN32_LEAN_AND_MEAN +#define __ROS_LONG64__ +#include + +#define STANDALONE +#include "wine/test.h" + +extern void func_DCICreatePrimary(void); + +const struct test winetest_testlist[] = +{ + { "DCICreatePrimary", func_DCICreatePrimary }, + + { 0, 0 } +}; + diff --git a/rostests/apitests/user32/GetSystemMetrics.c b/rostests/apitests/user32/GetSystemMetrics.c new file mode 100644 index 00000000000..8a8a5cb378f --- /dev/null +++ b/rostests/apitests/user32/GetSystemMetrics.c @@ -0,0 +1,410 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for GetSystemMetrics + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include + +void Test_GetSystemMetrics() +{ + INT ret; + HDC hDC; + BOOL BoolVal; + UINT UintVal; + RECT rect; + + SetLastError(0); + hDC = GetDC(0); + + ret = GetSystemMetrics(0); + ok(ret > 0, "ret = %d", ret); + + ret = GetSystemMetrics(64); + ok(ret == 0, "ret = %d", ret); + ret = GetSystemMetrics(65); + ok(ret == 0, "ret = %d", ret); + ret = GetSystemMetrics(66); + ok(ret == 0, "ret = %d", ret); + + + ret = GetSystemMetrics(SM_CXSCREEN); + ok(ret == GetDeviceCaps(hDC, HORZRES), "ret = %d", ret); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYSCREEN); + ok(ret == GetDeviceCaps(hDC, VERTRES), "ret = %d", ret); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CXVSCROLL); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYHSCROLL); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYCAPTION); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CXBORDER); + SystemParametersInfoW(SPI_GETFOCUSBORDERWIDTH, 0, &UintVal, 0); + ok(ret == UintVal, "ret = %d", ret); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYBORDER); + SystemParametersInfoW(SPI_GETFOCUSBORDERHEIGHT, 0, &UintVal, 0); + ok(ret == UintVal, "ret = %d", ret); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CXDLGFRAME); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYDLGFRAME); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYVTHUMB); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CXHTHUMB); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CXICON); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYICON); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CXCURSOR); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYCURSOR); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYMENU); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + SystemParametersInfoW(SPI_GETWORKAREA, 0, &rect, 0); + ret = GetSystemMetrics(SM_CXFULLSCREEN); + ok(ret == rect.right, "ret = %d", ret); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYFULLSCREEN); + ok(ret == rect.bottom - rect.top - GetSystemMetrics(SM_CYCAPTION), "ret = %d", ret); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYKANJIWINDOW); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_MOUSEPRESENT); + ok(ret == 1, "ret = %d", ret); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYVSCROLL); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CXHSCROLL); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_DEBUG); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_SWAPBUTTON); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_RESERVED1); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_RESERVED2); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_RESERVED3); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_RESERVED4); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CXMIN); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYMIN); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CXSIZE); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYSIZE); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CXFRAME); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYFRAME); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CXMINTRACK); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYMINTRACK); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CXDOUBLECLK); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYDOUBLECLK); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CXICONSPACING); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYICONSPACING); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_MENUDROPALIGNMENT); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_PENWINDOWS); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_DBCSENABLED); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CMOUSEBUTTONS); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + +#if(WINVER >= 0x0400) + ret = GetSystemMetrics(SM_SECURE); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CXEDGE); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYEDGE); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CXMINSPACING); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYMINSPACING); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CXSMICON); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYSMICON); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYSMCAPTION); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CXSMSIZE); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYSMSIZE); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CXMENUSIZE); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYMENUSIZE); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_ARRANGE); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CXMINIMIZED); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYMINIMIZED); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CXMAXTRACK); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYMAXTRACK); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CXMAXIMIZED); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYMAXIMIZED); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_NETWORK); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CLEANBOOT); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CXDRAG); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYDRAG); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_SHOWSOUNDS); + SystemParametersInfoW(SPI_GETSHOWSOUNDS, 0, &BoolVal, 0); + ok(ret == BoolVal, "ret = %d", ret); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CXMENUCHECK); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYMENUCHECK); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_SLOWMACHINE); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_MIDEASTENABLED); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); +#endif + +#if (WINVER >= 0x0500) || (_WIN32_WINNT >= 0x0400) + ret = GetSystemMetrics(SM_MOUSEWHEELPRESENT); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); +#endif + +#if(WINVER >= 0x0500) + ret = GetSystemMetrics(SM_XVIRTUALSCREEN); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_YVIRTUALSCREEN); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CXVIRTUALSCREEN); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYVIRTUALSCREEN); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CMONITORS); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_SAMEDISPLAYFORMAT); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); +#endif + +#if(_WIN32_WINNT >= 0x0500) + ret = GetSystemMetrics(SM_IMMENABLED); + ok(ret == 0 || ret == 1, "ret = %d\n", ret); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); +#endif + +#if(_WIN32_WINNT >= 0x0501) + ret = GetSystemMetrics(SM_CXFOCUSBORDER); + SystemParametersInfoW(SPI_GETFOCUSBORDERWIDTH, 0, &UintVal, 0); + ok(ret == UintVal, "ret = %d", ret); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CYFOCUSBORDER); + SystemParametersInfoW(SPI_GETFOCUSBORDERHEIGHT, 0, &UintVal, 0); + ok(ret == UintVal, "ret = %d", ret); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_TABLETPC); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_MEDIACENTER); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_STARTER); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_SERVERR2); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); +#endif + +#if(_WIN32_WINNT >= 0x0600) + ret = GetSystemMetrics(SM_MOUSEHORIZONTALWHEELPRESENT); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); + + ret = GetSystemMetrics(SM_CXPADDEDBORDER); +// TEST(ret == 0); + ok(GetLastError() == 0, "GetLastError() = %ld\n", GetLastError()); +#endif + +} + +START_TEST(GetSystemMetrics) +{ + Test_GetSystemMetrics(); +} + diff --git a/rostests/apitests/user32/InitializeLpkHooks.c b/rostests/apitests/user32/InitializeLpkHooks.c new file mode 100644 index 00000000000..462b65c4c83 --- /dev/null +++ b/rostests/apitests/user32/InitializeLpkHooks.c @@ -0,0 +1,110 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for InitializeLpkHooks + * PROGRAMMERS: Magnus Olsen + */ + +#include +#include +#include + + +typedef struct _LPK_LPEDITCONTROL_LIST +{ + PVOID EditCreate; + PVOID EditIchToXY; + PVOID EditMouseToIch; + PVOID EditCchInWidth; + PVOID EditGetLineWidth; + PVOID EditDrawText; + PVOID EditHScroll; + PVOID EditMoveSelection; + PVOID EditVerifyText; + PVOID EditNextWord; + PVOID EditSetMenu; + PVOID EditProcessMenu; + PVOID EditCreateCaret; + PVOID EditAdjustCaret; +} LPK_LPEDITCONTROL_LIST, *PLPK_LPEDITCONTROL_LIST; + + +DWORD (APIENTRY *fpLpkTabbedTextOut) (LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID); +DWORD (APIENTRY *fpLpkPSMTextOut) (LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID); +DWORD (APIENTRY *fpLpkDrawTextEx) (LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID); +PLPK_LPEDITCONTROL_LIST (APIENTRY *fpLpkEditControl) (); + +int Count_myLpkTabbedTextOut = 0; +int Count_myLpkPSMTextOut = 0; +int Count_myLpkDrawTextEx = 0; + +DWORD WINAPI myLpkTabbedTextOut (LPVOID x1,LPVOID x2,LPVOID x3, LPVOID x4, LPVOID x5, LPVOID x6, LPVOID x7, LPVOID x8, + LPVOID x9, LPVOID x10, LPVOID x11, LPVOID x12) +{ + Count_myLpkTabbedTextOut++; + return fpLpkTabbedTextOut(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12); +} + +DWORD myLpkPSMTextOut (LPVOID x1,LPVOID x2,LPVOID x3,LPVOID x4,LPVOID x5,LPVOID x6) +{ + Count_myLpkPSMTextOut++; + return fpLpkPSMTextOut ( x1, x2, x3, x4, x5, x6); +} + +DWORD myLpkDrawTextEx(LPVOID x1,LPVOID x2,LPVOID x3,LPVOID x4,LPVOID x5, LPVOID x6, LPVOID x7, LPVOID x8, LPVOID x9,LPVOID x10) +{ + Count_myLpkDrawTextEx++; + return fpLpkDrawTextEx(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10); +} + + +typedef struct _USER32_INTERN_INITALIZEHOOKS +{ + PVOID fpLpkTabbedTextOut; + PVOID fpLpkPSMTextOut; + PVOID fpLpkDrawTextEx; + PLPK_LPEDITCONTROL_LIST fpListLpkEditControl; +} USER32_INTERN_INITALIZEHOOKS, *PUSER32_INTERN_INITALIZEHOOKS; + +VOID WINAPI InitializeLpkHooks (PUSER32_INTERN_INITALIZEHOOKS); + +void Test_InitializeLpkHooks() +{ + USER32_INTERN_INITALIZEHOOKS setup; + HMODULE lib = LoadLibrary("LPK.DLL"); + + ok(lib != NULL, "lib = 0\n"); + if (lib != NULL) + { + fpLpkTabbedTextOut = (DWORD (APIENTRY *) (LPVOID,LPVOID,LPVOID,LPVOID,LPVOID, LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID)) GetProcAddress(lib, "LpkTabbedTextOut"); + fpLpkPSMTextOut = (DWORD (APIENTRY *) (LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID)) GetProcAddress(lib, "fpLpkPSMTextOut"); + fpLpkDrawTextEx = (DWORD (APIENTRY *) (LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID,LPVOID)) GetProcAddress(lib, "LpkDrawTextEx"); + fpLpkEditControl = (PLPK_LPEDITCONTROL_LIST (APIENTRY *) (VOID)) GetProcAddress(lib, "LpkEditControl"); + + setup.fpLpkTabbedTextOut = myLpkTabbedTextOut; + setup.fpLpkPSMTextOut = myLpkPSMTextOut; + setup.fpLpkDrawTextEx = myLpkDrawTextEx; + + /* we have not add any test to this api */ + setup.fpListLpkEditControl = (PLPK_LPEDITCONTROL_LIST)fpLpkEditControl; + + /* use our own api that we just made */ + InitializeLpkHooks(&setup); + + /* FIXME add test now */ + + /* restore */ + setup.fpLpkTabbedTextOut = fpLpkTabbedTextOut; + setup.fpLpkPSMTextOut = fpLpkPSMTextOut; + setup.fpLpkDrawTextEx = fpLpkDrawTextEx; + setup.fpListLpkEditControl = (PLPK_LPEDITCONTROL_LIST)fpLpkEditControl; + InitializeLpkHooks(&setup); + } + +} + +START_TEST(InitializeLpkHooks) +{ + Test_InitializeLpkHooks(); +} + diff --git a/rostests/apitests/user32/RealGetWindowClass.c b/rostests/apitests/user32/RealGetWindowClass.c new file mode 100644 index 00000000000..a8fe9db85b2 --- /dev/null +++ b/rostests/apitests/user32/RealGetWindowClass.c @@ -0,0 +1,134 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for RealGetWindowClass + * PROGRAMMERS: Gregor Gullwi + */ + +#include +#include +#include + +#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) + +typedef struct _TestData +{ + BOOL OverrideWndProc; /* TRUE if lpfnWndProc should be overridden */ + LPCSTR ClassName; /* Name of the new class to register */ + DWORD WndExtra; /* Remove these WNDCLASS::cbWndExtra flags */ + BOOL ExpectsHwnd; /* TRUE if a HWND should be created to run tests on */ + LPCSTR ExpectedClassNameBefore; /* Expected class name before any dialog function is called */ + LPCSTR ExpectedClassNameAfter; /* Expected class name after any dialog function is called */ +} TestData; + +static TestData RealClassTestData[] = +{ + { + TRUE, + "OverrideWndProc_with_DLGWINDOWEXTRA_TRUE", + 0, + TRUE, + "OverrideWndProc_with_DLGWINDOWEXTRA_TRUE", + "#32770", + }, + { + TRUE, + "OverrideWndProc_without_DLGWINDOWEXTRA_TRUE", + DLGWINDOWEXTRA, + TRUE, + "OverrideWndProc_without_DLGWINDOWEXTRA_TRUE", + "OverrideWndProc_without_DLGWINDOWEXTRA_TRUE", + }, + { + FALSE, + "DefaultWndProc_with_DLGWINDOWEXTRA_FALSE", + 0, + TRUE, + "#32770", + "#32770", + }, + { + FALSE, + "DefaultWndProc_without_DLGWINDOWEXTRA_FALSE", + DLGWINDOWEXTRA, + FALSE, + "N/A", + "N/A", + }, +}; + +void Test_RealGetWindowClass() +{ + int testNo; + UINT Result; + CHAR Buffer[1024]; + + Result = RealGetWindowClass( NULL, Buffer, ARRAY_SIZE(Buffer) ); + ok(Result == 0, "Result = %d\n", Result); + ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "GetLastError() = %ld\n", GetLastError()); + + for (testNo = 0; testNo < ARRAY_SIZE(RealClassTestData); testNo++) + { + ATOM atom; + WNDCLASSA cls; + HWND hWnd; + + /* Register classes, "derived" from built-in dialog, with and without the DLGWINDOWEXTRA flag set */ + GetClassInfoA(0, "#32770", &cls); + if (RealClassTestData[testNo].OverrideWndProc) + cls.lpfnWndProc = DefWindowProcA; + cls.lpszClassName = RealClassTestData[testNo].ClassName; + cls.cbWndExtra &= ~RealClassTestData[testNo].WndExtra; + atom = RegisterClassA (&cls); + if (atom == 0) return; + + /* Create a window */ + hWnd = CreateWindowEx( WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR | + WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE | WS_EX_CONTROLPARENT | WS_EX_APPWINDOW, + RealClassTestData[testNo].ClassName, + RealClassTestData[testNo].ClassName, + WS_POPUPWINDOW | WS_CLIPSIBLINGS | WS_DLGFRAME | WS_OVERLAPPED | + WS_MINIMIZEBOX | WS_MAXIMIZEBOX | DS_3DLOOK | DS_SETFONT | DS_MODALFRAME, + CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, + NULL, NULL, 0, 0); + + /* Do we expect a HWND at all? */ + if (RealClassTestData[testNo].ExpectsHwnd) + { + ok(hWnd != NULL, "\n"); + + if (hWnd != NULL) + { + /* Get the "real" class name */ + Result = RealGetWindowClass( hWnd, Buffer, ARRAY_SIZE(Buffer) ); + printf("Buffer: %s\nExpectedClassNameBefore(%d): %s\n", Buffer, testNo, RealClassTestData[testNo].ExpectedClassNameBefore); + ok( Result != 0, "\n" ); + ok( strcmp( Buffer, RealClassTestData[testNo].ExpectedClassNameBefore ) == 0, "\n" ); + + /* Call a function that requires a dialog window */ + DefDlgProcA( hWnd, DM_SETDEFID, IDCANCEL, 0 ); + + /* Get the "real" class name again */ + Result = RealGetWindowClass( hWnd, Buffer, ARRAY_SIZE(Buffer) ); + printf("Buffer: %s\nExpectedClassNameAfter(%d): %s\n", Buffer, testNo, RealClassTestData[testNo].ExpectedClassNameAfter); + ok( Result != 0, "\n" ); + ok( strcmp( Buffer, RealClassTestData[testNo].ExpectedClassNameAfter ) == 0, "\n" ); + } + } + else + { + ok(hWnd == NULL, "\n"); + } + + /* Cleanup */ + DestroyWindow(hWnd); + UnregisterClass(RealClassTestData[testNo].ClassName, 0); + } + +} + +START_TEST(RealGetWindowClass) +{ + Test_RealGetWindowClass(); +} + diff --git a/rostests/apitests/user32/ScrollDC.c b/rostests/apitests/user32/ScrollDC.c new file mode 100644 index 00000000000..4697109e029 --- /dev/null +++ b/rostests/apitests/user32/ScrollDC.c @@ -0,0 +1,72 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for ScrollDC + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include + +void Test_ScrollDC() +{ + HWND hWnd, hWnd2; + HDC hDC; + HRGN hrgn; + RECT rcClip; + int iResult; + + /* Create a window */ + hWnd = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW | WS_VISIBLE, + 100, 100, 100, 100, + NULL, NULL, 0, 0); + UpdateWindow(hWnd); + hDC = GetDC(hWnd); + + /* Test that no update region is there */ + hrgn = CreateRectRgn(0,0,0,0); + iResult = GetUpdateRgn(hWnd, hrgn, FALSE); + ok (iResult == NULLREGION, "\n"); + + /* Test normal scrolling */ + ok(ScrollDC(hDC, 0, 0, NULL, NULL, hrgn, NULL) == TRUE, "\n"); + + /* Scroll with invalid update region */ + DeleteObject(hrgn); + ok(ScrollDC(hDC, 50, 0, NULL, NULL, hrgn, NULL) == FALSE, "\n"); + hrgn = CreateRectRgn(0,0,0,0); + ok(GetUpdateRgn(hWnd, hrgn, FALSE) == NULLREGION, "\n"); + + /* Scroll with invalid update rect pointer */ + ok(ScrollDC(hDC, 50, 0, NULL, NULL, NULL, (PRECT)1) == 0, "\n"); + ok(GetUpdateRgn(hWnd, hrgn, FALSE) == NULLREGION, "\n"); + + /* Scroll with a clip rect */ + rcClip.left = 50; rcClip.top = 0; rcClip.right = 100; rcClip.bottom = 100; + ok(ScrollDC(hDC, 50, 0, NULL, &rcClip, hrgn, NULL) == TRUE, "\n"); + ok(GetUpdateRgn(hWnd, hrgn, FALSE) == NULLREGION, "\n"); + + /* Scroll with a clip rect */ + rcClip.left = 50; rcClip.top = 0; rcClip.right = 100; rcClip.bottom = 100; + ok(ScrollDC(hDC, 50, 50, NULL, &rcClip, hrgn, NULL) == TRUE, "\n"); + ok(GetUpdateRgn(hWnd, hrgn, FALSE) == NULLREGION, "\n"); + + /* Overlap with another window */ + hWnd2 = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW | WS_VISIBLE, + 30, 160, 100, 100, + NULL, NULL, 0, 0); + UpdateWindow(hWnd2); + + /* Cleanup */ + ReleaseDC(hWnd, hDC); + DestroyWindow(hWnd); + DestroyWindow(hWnd2); + +} + +START_TEST(ScrollDC) +{ + Test_ScrollDC(); +} + diff --git a/rostests/apitests/user32/ScrollWindowEx.c b/rostests/apitests/user32/ScrollWindowEx.c new file mode 100644 index 00000000000..2fd3a9dc35e --- /dev/null +++ b/rostests/apitests/user32/ScrollWindowEx.c @@ -0,0 +1,63 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for ScrollWindowEx + * PROGRAMMERS: Timo Kreuzer + */ + +#include +#include +#include + +void Test_ScrollWindowEx() +{ + HWND hWnd; + HRGN hrgn; + int Result; + + /* Create a window */ + hWnd = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW | WS_VISIBLE, + CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, + NULL, NULL, 0, 0); + UpdateWindow(hWnd); + + /* Assert that no update region is there */ + hrgn = CreateRectRgn(0,0,0,0); + Result = GetUpdateRgn(hWnd, hrgn, FALSE); + ok(Result == NULLREGION, "Result = %d\n", Result); + + Result = ScrollWindowEx(hWnd, 20, 0, NULL, NULL, NULL, NULL, 0); + ok(Result == SIMPLEREGION, "Result = %d\n", Result); + Result = GetUpdateRgn(hWnd, hrgn, FALSE); + ok(Result == NULLREGION, "Result = %d\n", Result); + + Result = ScrollWindowEx(hWnd, 20, 0, NULL, NULL, NULL, NULL, SW_INVALIDATE); + ok(Result == SIMPLEREGION, "Result = %d\n", Result); + Result = GetUpdateRgn(hWnd, hrgn, FALSE); + ok(Result == SIMPLEREGION, "Result = %d\n", Result); + UpdateWindow(hWnd); + + // test invalid update region + DeleteObject(hrgn); + Result = ScrollWindowEx(hWnd, 20, 0, NULL, NULL, hrgn, NULL, SW_INVALIDATE); + ok(Result == ERROR, "Result = %d\n", Result); + hrgn = CreateRectRgn(0,0,0,0); + UpdateWindow(hWnd); + + // Test invalid updaterect pointer + Result = ScrollWindowEx(hWnd, 20, 0, NULL, NULL, NULL, (LPRECT)1, SW_INVALIDATE); + ok(Result == ERROR, "Result = %d\n", Result); + Result = GetUpdateRgn(hWnd, hrgn, FALSE); + ok(Result == SIMPLEREGION, "Result = %d\n", Result); + +// test for alignment of rects + + DeleteObject(hrgn); + DestroyWindow(hWnd); +} + +START_TEST(ScrollWindowEx) +{ + Test_ScrollWindowEx(); +} + diff --git a/rostests/apitests/user32/testlist.c b/rostests/apitests/user32/testlist.c new file mode 100644 index 00000000000..a81b5e40e6b --- /dev/null +++ b/rostests/apitests/user32/testlist.c @@ -0,0 +1,24 @@ +#define WIN32_LEAN_AND_MEAN +#define __ROS_LONG64__ +#include + +#define STANDALONE +#include "wine/test.h" + +extern void func_InitializeLpkHooks(void); +extern void func_RealGetWindowClass(void); +extern void func_ScrollDC(void); +extern void func_ScrollWindowEx(void); +extern void func_GetSystemMetrics(void); + +const struct test winetest_testlist[] = +{ + { "InitializeLpkHooks", func_InitializeLpkHooks }, + { "RealGetWindowClass", func_RealGetWindowClass }, + { "ScrollDC", func_ScrollDC }, + { "ScrollWindowEx", func_ScrollWindowEx }, + { "GetSystemMetrics", func_GetSystemMetrics }, + + { 0, 0 } +}; + diff --git a/rostests/apitests/user32/user32_apitest.rbuild b/rostests/apitests/user32/user32_apitest.rbuild new file mode 100644 index 00000000000..07a7d3049c9 --- /dev/null +++ b/rostests/apitests/user32/user32_apitest.rbuild @@ -0,0 +1,19 @@ + + + + + . + wine + gdi32 + user32 + pseh + testlist.c + + InitializeLpkHooks.c + RealGetWindowClass.c + ScrollDC.c + ScrollWindowEx.c + GetSystemMetrics.c + + + From 14d5a266b3791731adfab16cb0f1d27fdac87322 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 25 Aug 2010 10:15:01 +0000 Subject: [PATCH 51/76] [ROSTESTS] - Add wine style ntdll_apitest and move test for ZwContinue there svn path=/trunk/; revision=48621 --- rostests/apitests/directory.rbuild | 4 + rostests/apitests/ntdll/ZwContinue.c | 173 +++++++++++++++++++ rostests/apitests/ntdll/i386/ZwContinue.asm | 48 +++++ rostests/apitests/ntdll/ntdll_apitest.rbuild | 18 ++ rostests/apitests/ntdll/testlist.c | 16 ++ 5 files changed, 259 insertions(+) create mode 100644 rostests/apitests/ntdll/ZwContinue.c create mode 100644 rostests/apitests/ntdll/i386/ZwContinue.asm create mode 100644 rostests/apitests/ntdll/ntdll_apitest.rbuild create mode 100644 rostests/apitests/ntdll/testlist.c diff --git a/rostests/apitests/directory.rbuild b/rostests/apitests/directory.rbuild index f5816b8aaf0..14446375bef 100644 --- a/rostests/apitests/directory.rbuild +++ b/rostests/apitests/directory.rbuild @@ -14,6 +14,10 @@ + + + + diff --git a/rostests/apitests/ntdll/ZwContinue.c b/rostests/apitests/ntdll/ZwContinue.c new file mode 100644 index 00000000000..0b181e31be1 --- /dev/null +++ b/rostests/apitests/ntdll/ZwContinue.c @@ -0,0 +1,173 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for ZwContinue + * PROGRAMMER: + */ + +#include +#include +#include +#include + +#ifdef _M_IX86 +#define ZWC_SEGMENT_BITS (0xFFFF) +#define ZWC_EFLAGS_BITS (0x3C0CD5) +#endif + +void continuePoint(void); +LONG NTAPI ZwContinue(IN CONTEXT *, IN BOOLEAN); + +static jmp_buf jmpbuf; +static CONTEXT continueContext; +static unsigned int nRandBytes; + +static int initrand(void) +{ + unsigned int nRandMax; + unsigned int nRandMaxBits; + time_t tLoc; + + nRandMax = RAND_MAX; + for(nRandMaxBits = 0; nRandMax != 0; nRandMax >>= 1, ++ nRandMaxBits); + nRandBytes = nRandMaxBits / CHAR_BIT; + //assert(nRandBytes != 0); + srand((unsigned)(time(&tLoc) & UINT_MAX)); + return 1; +} + +static void randbytes(void * p, size_t n) +{ + unsigned char * b; + size_t i; + int r = rand(); + + b = (unsigned char *)p; + for(i = 0; i < n; ++ i) + { + if(i % nRandBytes == 0) + r = rand(); + b[i] = (unsigned char)(r & UCHAR_MAX); + r >>= CHAR_BIT; + } +} + +static ULONG randULONG(void) +{ + ULONG n; + randbytes(&n, sizeof(n)); + return n; +} + +void check(CONTEXT * pContext) +{ +#ifdef _M_IX86 + ok(pContext->ContextFlags == CONTEXT_FULL, + "ContextFlags=0x%lx\n", pContext->ContextFlags); + + /* Random data segments */ + ok((pContext->SegGs & ZWC_SEGMENT_BITS) == + (continueContext.SegGs & ZWC_SEGMENT_BITS), + "SegGs=0x%lx / 0x%lx\n", pContext->SegGs, continueContext.SegGs); + + ok((pContext->SegFs & ZWC_SEGMENT_BITS) == + (continueContext.SegFs & ZWC_SEGMENT_BITS), + "SegFs=0x%lx / 0x%lx\n", pContext->SegFs, continueContext.SegFs); + + ok((pContext->SegEs & ZWC_SEGMENT_BITS) == + (continueContext.SegEs & ZWC_SEGMENT_BITS), + "SegEs=0x%lx / 0x%lx\n", pContext->SegEs, continueContext.SegEs); + + ok((pContext->SegDs & ZWC_SEGMENT_BITS) == + (continueContext.SegDs & ZWC_SEGMENT_BITS), + "SegDs=0x%lx / 0x%lx\n", pContext->SegDs, continueContext.SegDs); + + /* Integer registers */ + ok(pContext->Edi == continueContext.Edi, + "Edi: 0x%lx != 0x%lx\n", pContext->Edi, continueContext.Edi); + ok(pContext->Esi == continueContext.Esi, + "Esi: 0x%lx != 0x%lx\n", pContext->Esi, continueContext.Esi); + ok(pContext->Ebx == continueContext.Ebx, + "Ebx: 0x%lx != 0x%lx\n", pContext->Ebx, continueContext.Ebx); + ok(pContext->Edx == continueContext.Edx, + "Edx: 0x%lx != 0x%lx\n", pContext->Edx, continueContext.Edx); + ok(pContext->Ecx == continueContext.Ecx, + "Ecx: 0x%lx != 0x%lx\n", pContext->Ecx, continueContext.Ecx); + ok(pContext->Eax == continueContext.Eax, + "Eax: 0x%lx != 0x%lx\n", pContext->Eax, continueContext.Eax); + + /* Control registers and segments */ + ok(pContext->Ebp == continueContext.Ebp, + "Ebp: 0x%lx != 0x%lx\n", pContext->Ebp, continueContext.Ebp); + ok(pContext->Eip == continueContext.Eip, + "Eip: 0x%lx != 0x%lx\n", pContext->Eip, continueContext.Eip); + ok(pContext->Esp == continueContext.Esp, + "Esp: 0x%lx != 0x%lx\n", pContext->Esp, continueContext.Esp); + + ok((pContext->SegCs & ZWC_SEGMENT_BITS) == + (continueContext.SegCs & ZWC_SEGMENT_BITS), + "SegCs: 0x%lx != 0x%lx\n", pContext->SegCs, continueContext.SegCs); + + ok((pContext->EFlags & ZWC_EFLAGS_BITS) == + (continueContext.EFlags & ZWC_EFLAGS_BITS), + "EFlags: 0x%lx != 0x%lx\n", pContext->EFlags, continueContext.EFlags); + + ok((pContext->SegSs & ZWC_SEGMENT_BITS) == + (continueContext.SegSs & ZWC_SEGMENT_BITS), + "SegSs: 0x%lx != 0x%lx\n", pContext->SegSs, continueContext.SegSs); +#endif + + /* Return where we came from */ + longjmp(jmpbuf, 1); +} + +void Test_ZwContinue() +{ + initrand(); + + /* First time */ + if(setjmp(jmpbuf) == 0) + { + CONTEXT bogus; + + continueContext.ContextFlags = CONTEXT_FULL; + GetThreadContext(GetCurrentThread(), &continueContext); + +#ifdef _M_IX86 + continueContext.ContextFlags = CONTEXT_FULL; + + /* Fill the integer registers with random values */ + continueContext.Edi = randULONG(); + continueContext.Esi = randULONG(); + continueContext.Ebx = randULONG(); + continueContext.Edx = randULONG(); + continueContext.Ecx = randULONG(); + continueContext.Eax = randULONG(); + continueContext.Ebp = randULONG(); + + /* Randomize all the allowed flags (determined experimentally with WinDbg) */ + continueContext.EFlags = randULONG() & 0x3C0CD5; + + /* Randomize the stack pointer as much as possible */ + continueContext.Esp = (ULONG)(((ULONG_PTR)&bogus) & 0xFFFFFFFF) + + sizeof(bogus) - (randULONG() & 0xF) * 4; + + /* continuePoint() is implemented in assembler */ + continueContext.Eip = (ULONG)((ULONG_PTR)continuePoint & 0xFFFFFFF); + + /* Can't do a lot about segments */ +#endif + + ZwContinue(&continueContext, FALSE); + ok(0, "should never get here\n"); + } + + /* Second time */ + return; +} + +START_TEST(ZwContinue) +{ + Test_ZwContinue(); +} + diff --git a/rostests/apitests/ntdll/i386/ZwContinue.asm b/rostests/apitests/ntdll/i386/ZwContinue.asm new file mode 100644 index 00000000000..829fd24285b --- /dev/null +++ b/rostests/apitests/ntdll/i386/ZwContinue.asm @@ -0,0 +1,48 @@ +; cpu 486 +segment .text use32 + +extern _check + +global _continuePoint +_continuePoint: + push ss + push dword 0 + pushfd + push cs + push dword _continuePoint + push ebp + + push eax + push ecx + push edx + push ebx + push esi + push edi + + push ds + push es + push fs + push gs + + ; TODO: floating point state + sub esp, 70h + + ; Debug registers + sub esp, 18h + + push dword 00010007h + + ; Fill the Esp field + lea eax, [esp+0CCh] + lea ecx, [esp+0C4h] + mov [ecx], eax + + ; Call the function that will compare the current context with the expected one + cld + push esp + call _check + + ; check() must not return + int 3 + +; EOF diff --git a/rostests/apitests/ntdll/ntdll_apitest.rbuild b/rostests/apitests/ntdll/ntdll_apitest.rbuild new file mode 100644 index 00000000000..f9e2d64de17 --- /dev/null +++ b/rostests/apitests/ntdll/ntdll_apitest.rbuild @@ -0,0 +1,18 @@ + + + + + . + wine + ntdll + pseh + testlist.c + + ZwContinue.c + + + ZwContinue.asm + + + + diff --git a/rostests/apitests/ntdll/testlist.c b/rostests/apitests/ntdll/testlist.c new file mode 100644 index 00000000000..0bd842dbc88 --- /dev/null +++ b/rostests/apitests/ntdll/testlist.c @@ -0,0 +1,16 @@ +#define WIN32_LEAN_AND_MEAN +#define __ROS_LONG64__ +#include + +#define STANDALONE +#include "wine/test.h" + +extern void func_ZwContinue(void); + +const struct test winetest_testlist[] = +{ + { "ZwContinue", func_ZwContinue }, + + { 0, 0 } +}; + From da3e12b4502931b11e8bb5e97392717b8e490af3 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 25 Aug 2010 10:15:34 +0000 Subject: [PATCH 52/76] delete old Zwcontinue test svn path=/trunk/; revision=48622 --- rostests/tests/directory.rbuild | 1 - rostests/tests/zwcontinue/i386/zwcontinue.asm | 48 ----- rostests/tests/zwcontinue/zwcontinue.c | 185 ------------------ rostests/tests/zwcontinue/zwcontinue.rbuild | 4 - 4 files changed, 238 deletions(-) delete mode 100644 rostests/tests/zwcontinue/i386/zwcontinue.asm delete mode 100644 rostests/tests/zwcontinue/zwcontinue.c delete mode 100644 rostests/tests/zwcontinue/zwcontinue.rbuild diff --git a/rostests/tests/directory.rbuild b/rostests/tests/directory.rbuild index 1659a6cafeb..d3b7849f510 100644 --- a/rostests/tests/directory.rbuild +++ b/rostests/tests/directory.rbuild @@ -268,5 +268,4 @@ - diff --git a/rostests/tests/zwcontinue/i386/zwcontinue.asm b/rostests/tests/zwcontinue/i386/zwcontinue.asm deleted file mode 100644 index 829fd24285b..00000000000 --- a/rostests/tests/zwcontinue/i386/zwcontinue.asm +++ /dev/null @@ -1,48 +0,0 @@ -; cpu 486 -segment .text use32 - -extern _check - -global _continuePoint -_continuePoint: - push ss - push dword 0 - pushfd - push cs - push dword _continuePoint - push ebp - - push eax - push ecx - push edx - push ebx - push esi - push edi - - push ds - push es - push fs - push gs - - ; TODO: floating point state - sub esp, 70h - - ; Debug registers - sub esp, 18h - - push dword 00010007h - - ; Fill the Esp field - lea eax, [esp+0CCh] - lea ecx, [esp+0C4h] - mov [ecx], eax - - ; Call the function that will compare the current context with the expected one - cld - push esp - call _check - - ; check() must not return - int 3 - -; EOF diff --git a/rostests/tests/zwcontinue/zwcontinue.c b/rostests/tests/zwcontinue/zwcontinue.c deleted file mode 100644 index 0b1aebaae4b..00000000000 --- a/rostests/tests/zwcontinue/zwcontinue.c +++ /dev/null @@ -1,185 +0,0 @@ -#define WIN32_LEAN_AND_MEAN -#define STRICT -#include - -#include -#include -#include -#include -#include -#include -#include - -static unsigned int nRandBytes; - -static int initrand(void) -{ - unsigned int nRandMax; - unsigned int nRandMaxBits; - time_t tLoc; - - nRandMax = RAND_MAX; - - for(nRandMaxBits = 0; nRandMax != 0; nRandMax >>= 1, ++ nRandMaxBits); - - nRandBytes = nRandMaxBits / CHAR_BIT; - - assert(nRandBytes != 0); - - srand((unsigned)(time(&tLoc) & UINT_MAX)); - - return 1; -} - -static void randbytes(void * p, size_t n) -{ - unsigned char * b; - size_t i; - int r = rand(); - - b = (unsigned char *)p; - - for(i = 0; i < n; ++ i) - { - if(i % nRandBytes == 0) - r = rand(); - - b[i] = (unsigned char)(r & UCHAR_MAX); - r >>= CHAR_BIT; - } -} - -static ULONG randULONG(void) -{ - ULONG n; - randbytes(&n, sizeof(n)); - return n; -} - -#ifdef _M_IX86 -#define ZWC_SEGMENT_BITS (0xFFFF) -#define ZWC_EFLAGS_BITS (0x3C0CD5) -#endif - -static jmp_buf jmpbuf; -static CONTEXT continueContext; - -extern void continuePoint(void); -extern void check(CONTEXT *); -extern LONG NTAPI ZwContinue(IN CONTEXT *, IN BOOLEAN); - -void check(CONTEXT * actualContext) -{ -#ifdef _M_IX86 - assert(actualContext->ContextFlags == CONTEXT_FULL); - - /* Random data segments */ - assert - ( - (actualContext->SegGs & ZWC_SEGMENT_BITS) == - (continueContext.SegGs & ZWC_SEGMENT_BITS) - ); - - assert - ( - (actualContext->SegFs & ZWC_SEGMENT_BITS) == - (continueContext.SegFs & ZWC_SEGMENT_BITS) - ); - - assert - ( - (actualContext->SegEs & ZWC_SEGMENT_BITS) == - (continueContext.SegEs & ZWC_SEGMENT_BITS) - ); - - assert - ( - (actualContext->SegDs & ZWC_SEGMENT_BITS) == - (continueContext.SegDs & ZWC_SEGMENT_BITS) - ); - - /* Integer registers */ - assert(actualContext->Edi == continueContext.Edi); - assert(actualContext->Esi == continueContext.Esi); - assert(actualContext->Ebx == continueContext.Ebx); - printf("%s %lX : %lX\n", "Edx", actualContext->Edx, continueContext.Edx); - //assert(actualContext->Edx == continueContext.Edx); - assert(actualContext->Ecx == continueContext.Ecx); - assert(actualContext->Eax == continueContext.Eax); - - /* Control registers and segments */ - assert(actualContext->Ebp == continueContext.Ebp); - assert(actualContext->Eip == continueContext.Eip); - - assert - ( - (actualContext->SegCs & ZWC_SEGMENT_BITS) == - (continueContext.SegCs & ZWC_SEGMENT_BITS) - ); - - assert - ( - (actualContext->EFlags & ZWC_EFLAGS_BITS) == - (continueContext.EFlags & ZWC_EFLAGS_BITS) - ); - - assert(actualContext->Esp == continueContext.Esp); - - assert - ( - (actualContext->SegSs & ZWC_SEGMENT_BITS) == - (continueContext.SegSs & ZWC_SEGMENT_BITS) - ); -#endif - - longjmp(jmpbuf, 1); -} - -int main(void) -{ - initrand(); - - /* First time */ - if(setjmp(jmpbuf) == 0) - { - CONTEXT bogus; - - continueContext.ContextFlags = CONTEXT_FULL; - GetThreadContext(GetCurrentThread(), &continueContext); - -#ifdef _M_IX86 - continueContext.ContextFlags = CONTEXT_FULL; - - /* Fill the integer registers with random values */ - continueContext.Edi = randULONG(); - continueContext.Esi = randULONG(); - continueContext.Ebx = randULONG(); - continueContext.Edx = randULONG(); - continueContext.Ecx = randULONG(); - continueContext.Eax = randULONG(); - continueContext.Ebp = randULONG(); - - /* Randomize all the allowed flags (determined experimentally with WinDbg) */ - continueContext.EFlags = randULONG() & 0x3C0CD5; - - /* Randomize the stack pointer as much as possible */ - continueContext.Esp = - (ULONG)(((ULONG_PTR)&bogus) & 0xFFFFFFFF) + - sizeof(bogus) - - (randULONG() & 0xF) * 4; - - /* continuePoint() is implemented in assembler */ - continueContext.Eip = (ULONG)((ULONG_PTR)continuePoint & 0xFFFFFFF); - - /* Can't do a lot about segments */ -#endif - - ZwContinue(&continueContext, FALSE); - } - /* Second time */ - else - return 0; - - assert(0); - return 1; -} diff --git a/rostests/tests/zwcontinue/zwcontinue.rbuild b/rostests/tests/zwcontinue/zwcontinue.rbuild deleted file mode 100644 index f4cba28443f..00000000000 --- a/rostests/tests/zwcontinue/zwcontinue.rbuild +++ /dev/null @@ -1,4 +0,0 @@ - - gdi32 - zwcontinue.c - From 1b2ab4ce3103d15f50ebcd4306dcde86cf786962 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Thu, 26 Aug 2010 02:29:19 +0000 Subject: [PATCH 53/76] [NTDLL_APITEST] - Add a test for RtlInitializeBitMap. svn path=/trunk/; revision=48623 --- rostests/apitests/ntdll/RtlInitializeBitMap.c | 44 +++++++++++++++++++ rostests/apitests/ntdll/ntdll_apitest.rbuild | 1 + rostests/apitests/ntdll/testlist.c | 2 + 3 files changed, 47 insertions(+) create mode 100644 rostests/apitests/ntdll/RtlInitializeBitMap.c diff --git a/rostests/apitests/ntdll/RtlInitializeBitMap.c b/rostests/apitests/ntdll/RtlInitializeBitMap.c new file mode 100644 index 00000000000..21a8c7395c6 --- /dev/null +++ b/rostests/apitests/ntdll/RtlInitializeBitMap.c @@ -0,0 +1,44 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: Test for RtlInitializeBitmap + * PROGRAMMERS: Timo Kreuzer + */ + +#define WIN32_NO_STATUS +#include +#include +#include + +void Test_RtlInitializeBitmap() +{ + RTL_BITMAP Bitmap; + ULONG Buffer[5]; + + Buffer[0] = 0x12345; + Buffer[1] = 0x23456; + Buffer[2] = 0x34567; + Buffer[3] = 0x45678; + Buffer[4] = 0x56789; + + RtlInitializeBitMap(&Bitmap, Buffer, 19); + ok(Bitmap.Buffer == Buffer, "Buffer=%p\n", Bitmap.Buffer); + ok(Bitmap.SizeOfBitMap == 19, "SizeOfBitMap=%ld\n", Bitmap.SizeOfBitMap); + + ok(Buffer[0] == 0x12345, "Buffer[0] == 0x%lx\n", Buffer[0]); + ok(Buffer[1] == 0x23456, "Buffer[1] == 0x%lx\n", Buffer[1]); + ok(Buffer[2] == 0x34567, "Buffer[2] == 0x%lx\n", Buffer[2]); + ok(Buffer[3] == 0x45678, "Buffer[3] == 0x%lx\n", Buffer[3]); + ok(Buffer[4] == 0x56789, "Buffer[4] == 0x%lx\n", Buffer[4]); + + RtlInitializeBitMap(&Bitmap, 0, -100); + ok(Bitmap.Buffer == 0, "Buffer=%p\n", Bitmap.Buffer); + ok(Bitmap.SizeOfBitMap == -100, "SizeOfBitMap=%ld\n", Bitmap.SizeOfBitMap); + +} + +START_TEST(RtlInitializeBitMap) +{ + Test_RtlInitializeBitmap(); +} + diff --git a/rostests/apitests/ntdll/ntdll_apitest.rbuild b/rostests/apitests/ntdll/ntdll_apitest.rbuild index f9e2d64de17..1931a740f73 100644 --- a/rostests/apitests/ntdll/ntdll_apitest.rbuild +++ b/rostests/apitests/ntdll/ntdll_apitest.rbuild @@ -8,6 +8,7 @@ pseh testlist.c + RtlInitializeBitmap.c ZwContinue.c diff --git a/rostests/apitests/ntdll/testlist.c b/rostests/apitests/ntdll/testlist.c index 0bd842dbc88..29c2002361a 100644 --- a/rostests/apitests/ntdll/testlist.c +++ b/rostests/apitests/ntdll/testlist.c @@ -5,10 +5,12 @@ #define STANDALONE #include "wine/test.h" +extern void func_RtlInitializeBitMap(void); extern void func_ZwContinue(void); const struct test winetest_testlist[] = { + { "RtlInitializeBitMap", func_RtlInitializeBitMap }, { "ZwContinue", func_ZwContinue }, { 0, 0 } From 0553d5160cf9d0731e6ae59f5b813b81b3795f58 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 26 Aug 2010 02:29:38 +0000 Subject: [PATCH 54/76] [OSKITTCP] - Prevent multiple wakeups for the same event which caused nasty problems for the SEL_FIN event because we dereferenced our connection context 3 times which not only caused the connection endpoint to be freed while holding its spin lock but made the reference count negative [TCPIP] - Disassociate the address file from the connection endpoint before dereferencing/closing it to avoid a double dereference of the address file (not as harmful in this case as in the connection endpoint case) [IP] - Dereference the connection endpoint again if it was associated with an address file as the connection endpoint to fix a reference leak svn path=/trunk/; revision=48624 --- .../drivers/network/tcpip/tcpip/fileobjs.c | 6 ++++ reactos/lib/drivers/ip/transport/tcp/tcp.c | 28 +++++++++++++++---- .../drivers/oskittcp/oskittcp/uipc_socket2.c | 8 ++++++ 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/reactos/drivers/network/tcpip/tcpip/fileobjs.c b/reactos/drivers/network/tcpip/tcpip/fileobjs.c index 70357fced9a..98cc4062d0d 100644 --- a/reactos/drivers/network/tcpip/tcpip/fileobjs.c +++ b/reactos/drivers/network/tcpip/tcpip/fileobjs.c @@ -379,9 +379,15 @@ NTSTATUS FileCloseAddress( LockObject(AddrFile, &OldIrql); /* We have to close this connection because we started it */ if( AddrFile->Listener ) + { + AddrFile->Listener->AddressFile = NULL; TCPClose( AddrFile->Listener ); + } if( AddrFile->Connection ) + { + AddrFile->Connection->AddressFile = NULL; DereferenceObject( AddrFile->Connection ); + } UnlockObject(AddrFile, OldIrql); DereferenceObject(AddrFile); diff --git a/reactos/lib/drivers/ip/transport/tcp/tcp.c b/reactos/lib/drivers/ip/transport/tcp/tcp.c index b432ab83f79..e980f6b1e15 100644 --- a/reactos/lib/drivers/ip/transport/tcp/tcp.c +++ b/reactos/lib/drivers/ip/transport/tcp/tcp.c @@ -234,7 +234,10 @@ VOID HandleSignalledConnection(PCONNECTION_ENDPOINT Connection) /* If the socket is dead, remove the reference we added for oskit */ if (Connection->SignalState & SEL_FIN) + { + Connection->SocketContext = NULL; DereferenceObject(Connection); + } } VOID ConnectionFree(PVOID Object) { @@ -663,17 +666,15 @@ NTSTATUS TCPClose KIRQL OldIrql; NTSTATUS Status; PVOID Socket; + PADDRESS_FILE AddressFile = NULL; + PCONNECTION_ENDPOINT AddressConnection = NULL; - /* We don't rely on SocketContext == NULL for socket - * closure anymore but we still need it to determine - * if we caused the closure - */ LockObject(Connection, &OldIrql); Socket = Connection->SocketContext; Connection->SocketContext = NULL; /* Don't try to close again if the other side closed us already */ - if (!(Connection->SignalState & SEL_FIN)) + if (Socket) { /* We need to close here otherwise oskit will never indicate * SEL_FIN and we will never fully close the connection */ @@ -693,11 +694,26 @@ NTSTATUS TCPClose } if (Connection->AddressFile) - DereferenceObject(Connection->AddressFile); + { + LockObjectAtDpcLevel(Connection->AddressFile); + if (Connection->AddressFile->Connection == Connection) + { + AddressConnection = Connection->AddressFile->Connection; + Connection->AddressFile->Connection = NULL; + } + UnlockObjectFromDpcLevel(Connection->AddressFile); + + AddressFile = Connection->AddressFile; + Connection->AddressFile = NULL; + } UnlockObject(Connection, OldIrql); DereferenceObject(Connection); + if (AddressConnection) + DereferenceObject(AddressConnection); + if (AddressFile) + DereferenceObject(AddressFile); return Status; } diff --git a/reactos/lib/drivers/oskittcp/oskittcp/uipc_socket2.c b/reactos/lib/drivers/oskittcp/oskittcp/uipc_socket2.c index d565910f289..4155922d804 100644 --- a/reactos/lib/drivers/oskittcp/oskittcp/uipc_socket2.c +++ b/reactos/lib/drivers/oskittcp/oskittcp/uipc_socket2.c @@ -118,8 +118,10 @@ soisconnected(so) wakeup(so, (caddr_t)&head->so_timeo); } else { wakeup(so, (caddr_t)&so->so_timeo); +#ifndef __REACTOS__ sorwakeup(so); sowwakeup(so); +#endif } } @@ -131,8 +133,10 @@ soisdisconnecting(so) so->so_state &= ~SS_ISCONNECTING; so->so_state |= (SS_ISDISCONNECTING|SS_CANTRCVMORE|SS_CANTSENDMORE); wakeup(so, (caddr_t)&so->so_timeo); +#ifndef __REACTOS__ sowwakeup(so); sorwakeup(so); +#endif } void @@ -144,8 +148,10 @@ soisdisconnected(so) so->so_state &= ~(SS_ISCONNECTING|SS_ISCONNECTED|SS_ISDISCONNECTING); so->so_state |= (SS_CANTRCVMORE|SS_CANTSENDMORE); wakeup(so, (caddr_t)&so->so_timeo); +#ifndef __REACTOS__ sowwakeup(so); sorwakeup(so); +#endif } /* @@ -192,7 +198,9 @@ sonewconn1(head, connstatus) return ((struct socket *)0); } if (connstatus) { +#ifndef __REACTOS__ sorwakeup(head); +#endif wakeup(head, (caddr_t)&head->so_timeo); so->so_state |= connstatus; } From 6ddec3f063642be11f8c4fe99590d8711d96f7f6 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Thu, 26 Aug 2010 02:48:03 +0000 Subject: [PATCH 55/76] Fix build svn path=/trunk/; revision=48625 --- rostests/apitests/ntdll/ntdll_apitest.rbuild | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rostests/apitests/ntdll/ntdll_apitest.rbuild b/rostests/apitests/ntdll/ntdll_apitest.rbuild index 1931a740f73..2ed30fe8b14 100644 --- a/rostests/apitests/ntdll/ntdll_apitest.rbuild +++ b/rostests/apitests/ntdll/ntdll_apitest.rbuild @@ -8,7 +8,7 @@ pseh testlist.c - RtlInitializeBitmap.c + RtlInitializeBitMap.c ZwContinue.c From e04ebf1980ce2cb806a7ccefa6644ff519cc5d7d Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Thu, 26 Aug 2010 15:25:33 +0000 Subject: [PATCH 56/76] [NTOSKRNL] - Fix to PpSetCustomTargetEvent(), not to make caller wait forever in case it provided an event it waits for - Patch by Pierre Schweitzer svn path=/trunk/; revision=48626 --- reactos/ntoskrnl/io/pnpmgr/pnpreport.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/reactos/ntoskrnl/io/pnpmgr/pnpreport.c b/reactos/ntoskrnl/io/pnpmgr/pnpreport.c index 18d75ab4eb7..165b0b06f59 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnpreport.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnpreport.c @@ -132,12 +132,25 @@ PpSetCustomTargetEvent(IN PDEVICE_OBJECT DeviceObject, ASSERT(NotificationStructure != NULL); ASSERT(DeviceObject != NULL); + if (SyncEvent) + { + ASSERT(SyncStatus); + *SyncStatus = STATUS_PENDING; + } + /* That call is totally wrong but notifications handler must be fixed first */ IopNotifyPlugPlayNotification(DeviceObject, EventCategoryTargetDeviceChange, &GUID_PNP_CUSTOM_NOTIFICATION, NotificationStructure, NULL); + + if (SyncEvent) + { + KeSetEvent(SyncEvent, IO_NO_INCREMENT, FALSE); + *SyncStatus = STATUS_SUCCESS; + } + return STATUS_SUCCESS; } From 9f187ad465590c9d07560b2dcdc7ab9134624404 Mon Sep 17 00:00:00 2001 From: Colin Finck Date: Thu, 26 Aug 2010 18:33:46 +0000 Subject: [PATCH 57/76] Fix building on newer Linux systems (particularly Fedora 13) Thanks to James, Sylvain and ErVito for testing! See http://reactos.org/pipermail/ros-dev/2010-August/013338.html for more details svn path=/trunk/; revision=48627 --- reactos/tools/cabman/cabinet.cxx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/reactos/tools/cabman/cabinet.cxx b/reactos/tools/cabman/cabinet.cxx index a45f3401426..5d834a9bb07 100755 --- a/reactos/tools/cabman/cabinet.cxx +++ b/reactos/tools/cabman/cabinet.cxx @@ -20,10 +20,9 @@ #include #if !defined(WIN32) # include -#endif -#if defined(__FreeBSD__) || defined(__APPLE__) # include -#endif // __FreeBSD__ +# include +#endif #include "cabinet.h" #include "raw.h" #include "mszip.h" From b0a5ac396e0395cd24691314717311d06ca3ddb9 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 27 Aug 2010 04:46:04 +0000 Subject: [PATCH 58/76] [OSKITTCP] - Only tell the caller how much we sent/received if it completed successfully - Set SO_DONTROUTE on accepted sockets too - Disable the core routing code - Make our MSS calculation much better by sharing the existing code svn path=/trunk/; revision=48628 --- .../lib/drivers/oskittcp/oskittcp/interface.c | 16 ++++++--- reactos/lib/drivers/oskittcp/oskittcp/route.c | 4 +++ .../lib/drivers/oskittcp/oskittcp/tcp_input.c | 33 +++++++++++-------- 3 files changed, 34 insertions(+), 19 deletions(-) diff --git a/reactos/lib/drivers/oskittcp/oskittcp/interface.c b/reactos/lib/drivers/oskittcp/oskittcp/interface.c index db0b3a87185..1959e679ac8 100644 --- a/reactos/lib/drivers/oskittcp/oskittcp/interface.c +++ b/reactos/lib/drivers/oskittcp/oskittcp/interface.c @@ -114,6 +114,12 @@ void OskitDumpBuffer( OSK_PCHAR Data, OSK_UINT Len ) DbgPrint ( line ); } +void InitializeSocketFlags(struct socket *so) +{ + so->so_state |= SS_NBIO; + so->so_options |= SO_DONTROUTE; +} + /* From uipc_syscalls.c */ int OskitTCPSocket( void *context, @@ -128,8 +134,7 @@ int OskitTCPSocket( void *context, int error = socreate(domain, &so, type, proto); if( !error ) { so->so_connection = context; - so->so_state |= SS_NBIO; - so->so_options |= SO_DONTROUTE; + InitializeSocketFlags(so); *aso = so; } OSKUnlock(); @@ -171,7 +176,7 @@ int OskitTCPRecv( void *connection, &tcp_flags ); OSKUnlock(); - *OutLen = Len - uio.uio_resid; + if (error == 0) *OutLen = Len - uio.uio_resid; return error; } @@ -318,7 +323,7 @@ int OskitTCPSend( void *socket, OSK_PCHAR Data, OSK_UINT Len, error = sosend( socket, NULL, &uio, NULL, NULL, 0 ); OSKUnlock(); - *OutLen = Len - uio.uio_resid; + if (error == 0) *OutLen = Len - uio.uio_resid; return error; } @@ -400,7 +405,8 @@ int OskitTCPAccept( void *socket, if (error) goto out; - so->so_state |= SS_NBIO | SS_ISCONNECTED; + InitializeSocketFlags(so); + so->so_state |= SS_ISCONNECTED; so->so_q = so->so_q0 = NULL; so->so_qlen = so->so_q0len = 0; so->so_head = 0; diff --git a/reactos/lib/drivers/oskittcp/oskittcp/route.c b/reactos/lib/drivers/oskittcp/oskittcp/route.c index 8ba57da7e3e..59311a4648c 100644 --- a/reactos/lib/drivers/oskittcp/oskittcp/route.c +++ b/reactos/lib/drivers/oskittcp/oskittcp/route.c @@ -106,6 +106,7 @@ rtalloc1(dst, report, ignflags) int report; u_long ignflags; { +#ifndef __REACTOS__ register struct radix_node_head *rnh = rt_tables[dst->sa_family]; register struct rtentry *rt; register struct radix_node *rn; @@ -142,6 +143,9 @@ rtalloc1(dst, report, ignflags) } splx(s); return (newrt); +#else + return NULL; +#endif } void diff --git a/reactos/lib/drivers/oskittcp/oskittcp/tcp_input.c b/reactos/lib/drivers/oskittcp/oskittcp/tcp_input.c index ed2759a0c39..39116abf15f 100644 --- a/reactos/lib/drivers/oskittcp/oskittcp/tcp_input.c +++ b/reactos/lib/drivers/oskittcp/oskittcp/tcp_input.c @@ -1973,31 +1973,26 @@ tcp_mss(tp, offer) struct tcpcb *tp; int offer; { +#ifndef __REACTOS__ register struct rtentry *rt; struct ifnet *ifp = NULL; - register int rtt, mss; + struct rmxp_tao *taop; + register int rtt; +#endif + register int mss; u_long bufsize; struct inpcb *inp; struct socket *so; - struct rmxp_tao *taop; int origoffer = offer; inp = tp->t_inpcb; - if ((rt = tcp_rtlookup(inp)) == NULL) { + so = inp->inp_socket; #ifndef __REACTOS__ + if ((rt = tcp_rtlookup(inp)) == NULL) { tp->t_maxopd = tp->t_maxseg = tcp_mssdflt; -#else - if (offer < tcp_mssdflt) - tp->t_maxopd = tp->t_maxseg = tcp_mssdflt; - else - tp->t_maxopd = tp->t_maxseg = min(offer, tcp_mssopt(tp)); -#endif return; } -#ifndef __REACTOS__ ifp = rt->rt_ifp; -#endif - so = inp->inp_socket; taop = rmx_taop(rt->rt_rmx); /* @@ -2006,6 +2001,7 @@ tcp_mss(tp, offer) */ if (offer == -1) offer = taop->tao_mssopt; +#endif /* * Offer == 0 means that there was no MSS on the SYN segment, * in this case we use tcp_mssdflt. @@ -2020,6 +2016,7 @@ tcp_mss(tp, offer) * funny things may happen in tcp_output. */ offer = max(offer, 64); +#ifndef __REACTOS__ taop->tao_mssopt = offer; /* @@ -2060,6 +2057,10 @@ tcp_mss(tp, offer) if (!in_localaddr(inp->inp_faddr)) mss = min(mss, tcp_mssdflt); } +#else + mss = tcp_mssopt(tp); + mss = min(mss, tcp_mssdflt); +#endif mss = min(mss, offer); /* * maxopd stores the maximum length of data AND options @@ -2097,7 +2098,7 @@ tcp_mss(tp, offer) * number of mss units; if the mss is larger than * the socket buffer, decrease the mss. */ -#ifdef RTV_SPIPE +#if defined(RTV_SPIPE) && !defined(__REACTOS__) if ((bufsize = rt->rt_rmx.rmx_sendpipe) == 0) #endif bufsize = so->so_snd.sb_hiwat; @@ -2111,7 +2112,7 @@ tcp_mss(tp, offer) } tp->t_maxseg = mss; -#ifdef RTV_RPIPE +#if defined(RTV_RPIPE) && !defined(__REACTOS__) if ((bufsize = rt->rt_rmx.rmx_recvpipe) == 0) #endif bufsize = so->so_rcv.sb_hiwat; @@ -2121,12 +2122,15 @@ tcp_mss(tp, offer) bufsize = sb_max; (void)sbreserve(&so->so_rcv, bufsize); } +#ifndef __REACTOS__ /* * Don't force slow-start on local network. */ if (!in_localaddr(inp->inp_faddr)) +#endif tp->snd_cwnd = mss; +#ifndef __REACTOS__ if (rt->rt_rmx.rmx_ssthresh) { /* * There's some sort of gateway or interface @@ -2137,6 +2141,7 @@ tcp_mss(tp, offer) tp->snd_ssthresh = max(2 * mss, rt->rt_rmx.rmx_ssthresh); tcpstat.tcps_usedssthresh++; } +#endif } /* From cb6ae2faabd68c3e515bca4452bef7640cc82754 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Fri, 27 Aug 2010 10:20:25 +0000 Subject: [PATCH 59/76] [USER32] - Revert r47238 as requested by Giannis: "this commit breaks any program that wants to subclass mdi client windows" svn path=/trunk/; revision=48629 --- reactos/dll/win32/user32/windows/window.c | 30 ----------------------- 1 file changed, 30 deletions(-) diff --git a/reactos/dll/win32/user32/windows/window.c b/reactos/dll/win32/user32/windows/window.c index 5f2826a0cdf..468536ee290 100644 --- a/reactos/dll/win32/user32/windows/window.c +++ b/reactos/dll/win32/user32/windows/window.c @@ -342,18 +342,6 @@ CreateWindowExA(DWORD dwExStyle, POINT mPos[2]; UINT id = 0; HWND top_child; - PWND WndParent; - PCLS pcls; - - if(!(WndParent = ValidateHwnd(hWndParent)) || - !(pcls = DesktopPtrToUser(WndParent->pcls))) - return 0; - - if (pcls->fnid != FNID_MDICLIENT) - { - ERR("WS_EX_MDICHILD, but parent %p is not MDIClient\n", hWndParent); - return 0; - } /* lpParams of WM_[NC]CREATE is different for MDI children. * MDICREATESTRUCT members have the originally passed values. @@ -466,24 +454,6 @@ CreateWindowExW(DWORD dwExStyle, POINT mPos[2]; UINT id = 0; HWND top_child; - PWND WndParent; - PCLS pcls; - - WndParent = ValidateHwnd(hWndParent); - - if(!WndParent) - return 0; - - pcls = DesktopPtrToUser(WndParent->pcls); - - if(!pcls) - return 0; - - if (pcls->fnid != FNID_MDICLIENT) - { - ERR("WS_EX_MDICHILD, but parent %p is not MDIClient\n", hWndParent); - return 0; - } /* lpParams of WM_[NC]CREATE is different for MDI children. * MDICREATESTRUCT members have the originally passed values. From 3a325683bc8747512a25e4be8319eb7221e99612 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Fri, 27 Aug 2010 10:57:54 +0000 Subject: [PATCH 60/76] [WIN32K] - Rework EngSetPointerShape, to first allocate the neccessary surfaces, before deleting the old ones. Also check in IntShowMousePointer if a saving surface is present. This way a failure to allocate a surface will not result in a crash, but keep the old mouse pointer. See issue #5402 for more details. svn path=/trunk/; revision=48630 --- reactos/subsystems/win32/win32k/eng/mouse.c | 230 +++++++++++--------- 1 file changed, 122 insertions(+), 108 deletions(-) diff --git a/reactos/subsystems/win32/win32k/eng/mouse.c b/reactos/subsystems/win32/win32k/eng/mouse.c index f5f6b2f30ca..93ab14d4f6d 100644 --- a/reactos/subsystems/win32/win32k/eng/mouse.c +++ b/reactos/subsystems/win32/win32k/eng/mouse.c @@ -209,6 +209,9 @@ IntShowMousePointer(PDEVOBJ *ppdev, SURFOBJ *psoDest) pgp->Enabled = TRUE; + /* Check if we have any mouse pointer */ + if (!pgp->psurfSave) return; + /* Calculate pointer coordinates */ pt.x = ppdev->ptlPointer.x - pgp->HotSpot.x; pt.y = ppdev->ptlPointer.y - pgp->HotSpot.y; @@ -318,42 +321,117 @@ EngSetPointerShape( { PDEVOBJ *ppdev; GDIPOINTER *pgp; - LONG lDelta; - HBITMAP hbmp; - RECTL rcl; + LONG lDelta = 0; + HBITMAP hbmSave = NULL, hbmColor = NULL, hbmMask = NULL; + PSURFACE psurfSave = NULL, psurfColor = NULL, psurfMask = NULL; + RECTL rectl; + SIZEL sizel = {0, 0}; ASSERT(pso); ppdev = GDIDEV(pso); pgp = &ppdev->Pointer; + /* Do we have any bitmap at all? */ + if (psoColor || psoMask) + { + /* Get the size of the new pointer */ + if (psoColor) + { + sizel.cx = psoColor->sizlBitmap.cx; + sizel.cy = psoColor->sizlBitmap.cy; + } + else// if (psoMask) + { + sizel.cx = psoMask->sizlBitmap.cx; + sizel.cy = psoMask->sizlBitmap.cy / 2; + } + + rectl.left = 0; + rectl.top = 0; + rectl.right = sizel.cx; + rectl.bottom = sizel.cy; + + /* Calculate lDelta for our surfaces. */ + lDelta = DIB_GetDIBWidthBytes(sizel.cx, + BitsPerFormat(pso->iBitmapFormat)); + + /* Create a bitmap for saving the pixels under the cursor. */ + hbmSave = EngCreateBitmap(sizel, + lDelta, + pso->iBitmapFormat, + BMF_TOPDOWN | BMF_NOZEROINIT, + NULL); + psurfSave = SURFACE_ShareLockSurface(hbmSave); + if (!psurfSave) goto failure; + } + if (psoColor) { - pgp->Size.cx = psoColor->sizlBitmap.cx; - pgp->Size.cy = psoColor->sizlBitmap.cy; - if (psoMask) - { - // CHECKME: Is this really required? if we have a color surface, - // we only need the AND part of the mask. - /* Check if the sizes match as they should */ - if (psoMask->sizlBitmap.cx != psoColor->sizlBitmap.cx || - psoMask->sizlBitmap.cy != psoColor->sizlBitmap.cy * 2) - { - DPRINT("Sizes of mask (%ld,%ld) and color (%ld,%ld) don't match\n", - psoMask->sizlBitmap.cx, psoMask->sizlBitmap.cy, - psoColor->sizlBitmap.cx, psoColor->sizlBitmap.cy); -// return SPS_ERROR; - } - } - } - else if (psoMask) - { - pgp->Size.cx = psoMask->sizlBitmap.cx; - pgp->Size.cy = psoMask->sizlBitmap.cy / 2; + /* Color bitmap must have the same format as the dest surface */ + if (psoColor->iBitmapFormat != pso->iBitmapFormat) goto failure; + + /* Create a bitmap to copy the color bitmap to */ + hbmColor = EngCreateBitmap(psoColor->sizlBitmap, + lDelta, + pso->iBitmapFormat, + BMF_TOPDOWN | BMF_NOZEROINIT, + NULL); + psurfColor = SURFACE_ShareLockSurface(hbmColor); + if (!psurfColor) goto failure; + + /* Now copy the given bitmap */ + rectl.bottom = psoColor->sizlBitmap.cy; + IntEngCopyBits(&psurfColor->SurfObj, + psoColor, + NULL, + pxlo, + &rectl, + (POINTL*)&rectl); } + /* Create a mask surface */ + if (psoMask) + { + EXLATEOBJ exlo; + PPALETTE ppal; + + /* Create a bitmap for the mask */ + hbmMask = EngCreateBitmap(psoMask->sizlBitmap, + lDelta, + pso->iBitmapFormat, + BMF_TOPDOWN | BMF_NOZEROINIT, + NULL); + psurfMask = SURFACE_ShareLockSurface(hbmMask); + if (!psurfMask) goto failure; + + /* Initialize an EXLATEOBJ */ + ppal = PALETTE_LockPalette(ppdev->devinfo.hpalDefault); + EXLATEOBJ_vInitialize(&exlo, + &gpalMono, + ppal, + 0, + RGB(0xff,0xff,0xff), + RGB(0,0,0)); + + /* Copy the mask bitmap */ + rectl.bottom = psoMask->sizlBitmap.cy; + IntEngCopyBits(&psurfMask->SurfObj, + psoMask, + NULL, + &exlo.xlo, + &rectl, + (POINTL*)&rectl); + + /* Cleanup */ + EXLATEOBJ_vCleanup(&exlo); + if (ppal) PALETTE_UnlockPalette(ppal); + } + + /* Hide mouse pointer */ IntHideMousePointer(ppdev, pso); + /* Free old color bitmap */ if (pgp->psurfColor) { EngDeleteSurface(pgp->psurfColor->BaseObject.hHmgr); @@ -361,6 +439,7 @@ EngSetPointerShape( pgp->psurfColor = NULL; } + /* Free old mask bitmap */ if (pgp->psurfMask) { EngDeleteSurface(pgp->psurfMask->BaseObject.hHmgr); @@ -368,7 +447,8 @@ EngSetPointerShape( pgp->psurfMask = NULL; } - if (pgp->psurfSave != NULL) + /* Free old save bitmap */ + if (pgp->psurfSave) { EngDeleteSurface(pgp->psurfSave->BaseObject.hHmgr); SURFACE_ShareUnlockSurface(pgp->psurfSave); @@ -378,94 +458,17 @@ EngSetPointerShape( /* See if we are being asked to hide the pointer. */ if (psoMask == NULL && psoColor == NULL) { + /* We're done */ return SPS_ACCEPT_NOEXCLUDE; } + /* Now set the new cursor */ + pgp->psurfColor = psurfColor; + pgp->psurfMask = psurfMask; + pgp->psurfSave = psurfSave; pgp->HotSpot.x = xHot; pgp->HotSpot.y = yHot; - - /* Calculate lDelta for our surfaces. */ - lDelta = DIB_GetDIBWidthBytes(pgp->Size.cx, - BitsPerFormat(pso->iBitmapFormat)); - - rcl.left = 0; - rcl.top = 0; - rcl.right = pgp->Size.cx; - rcl.bottom = pgp->Size.cy; - - /* Create surface for saving the pixels under the cursor. */ - hbmp = EngCreateBitmap(pgp->Size, - lDelta, - pso->iBitmapFormat, - BMF_TOPDOWN | BMF_NOZEROINIT, - NULL); - pgp->psurfSave = SURFACE_ShareLockSurface(hbmp); - - /* Create a mask surface */ - if (psoMask) - { - EXLATEOBJ exlo; - PPALETTE ppal; - - hbmp = EngCreateBitmap(psoMask->sizlBitmap, - lDelta, - pso->iBitmapFormat, - BMF_TOPDOWN | BMF_NOZEROINIT, - NULL); - pgp->psurfMask = SURFACE_ShareLockSurface(hbmp); - - if(pgp->psurfMask) - { - ppal = PALETTE_LockPalette(ppdev->devinfo.hpalDefault); - EXLATEOBJ_vInitialize(&exlo, - &gpalMono, - ppal, - 0, - RGB(0xff,0xff,0xff), - RGB(0,0,0)); - - rcl.bottom = psoMask->sizlBitmap.cy; - IntEngCopyBits(&pgp->psurfMask->SurfObj, - psoMask, - NULL, - &exlo.xlo, - &rcl, - (POINTL*)&rcl); - - EXLATEOBJ_vCleanup(&exlo); - if (ppal) - PALETTE_UnlockPalette(ppal); - } - } - else - { - pgp->psurfMask = NULL; - } - - /* Create a color surface */ - if (psoColor) - { - hbmp = EngCreateBitmap(psoColor->sizlBitmap, - lDelta, - pso->iBitmapFormat, - BMF_TOPDOWN | BMF_NOZEROINIT, - NULL); - pgp->psurfColor = SURFACE_ShareLockSurface(hbmp); - if (pgp->psurfColor) - { - rcl.bottom = psoColor->sizlBitmap.cy; - IntEngCopyBits(&pgp->psurfColor->SurfObj, - psoColor, - NULL, - pxlo, - &rcl, - (POINTL*)&rcl); - } - } - else - { - pgp->psurfColor = NULL; - } + pgp->Size = sizel; if (x != -1) { @@ -488,6 +491,17 @@ EngSetPointerShape( } return SPS_ACCEPT_NOEXCLUDE; + +failure: + /* Cleanup surfaces */ + if (hbmMask) EngDeleteSurface(hbmMask); + if (psurfMask) SURFACE_ShareUnlockSurface(psurfMask); + if (hbmColor) EngDeleteSurface(hbmColor); + if (psurfColor) SURFACE_ShareUnlockSurface(psurfColor); + if (hbmSave) EngDeleteSurface(hbmSave); + if (psurfSave) SURFACE_ShareUnlockSurface(psurfSave); + + return SPS_ERROR; } /* From a9e0dc23a4095e06d690da8b1a696d974a99a7f4 Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Fri, 27 Aug 2010 22:18:10 +0000 Subject: [PATCH 61/76] [ntoskrnl/ps] - Acquire and Release RundownProtection on the Parent Pocess not the newly created Pcess when setting the SectionObject. svn path=/trunk/; revision=48631 --- reactos/ntoskrnl/ps/process.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reactos/ntoskrnl/ps/process.c b/reactos/ntoskrnl/ps/process.c index fea26c938c0..0c557c3699e 100644 --- a/reactos/ntoskrnl/ps/process.c +++ b/reactos/ntoskrnl/ps/process.c @@ -469,14 +469,14 @@ PspCreateProcess(OUT PHANDLE ProcessHandle, if (Parent != PsInitialSystemProcess) { /* It's not, so acquire the process rundown */ - if (ExAcquireRundownProtection(&Process->RundownProtect)) + if (ExAcquireRundownProtection(&Parent->RundownProtect)) { /* If the parent has a section, use it */ SectionObject = Parent->SectionObject; if (SectionObject) ObReferenceObject(SectionObject); /* Release process rundown */ - ExReleaseRundownProtection(&Process->RundownProtect); + ExReleaseRundownProtection(&Parent->RundownProtect); } /* If we don't have a section object */ From 87e8d75f00bdd59658fb578bd45f91625925e686 Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Sat, 28 Aug 2010 00:26:02 +0000 Subject: [PATCH 62/76] [ntoskrnl/ps] - When deleting a Process remove the Process from the MmProcessList. Fixes random NonPaged Pool corruptions. Thanks aicom for assistance. svn path=/trunk/; revision=48632 --- reactos/ntoskrnl/ps/kill.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/reactos/ntoskrnl/ps/kill.c b/reactos/ntoskrnl/ps/kill.c index b1ea95fb361..c1f9ce33cb6 100644 --- a/reactos/ntoskrnl/ps/kill.c +++ b/reactos/ntoskrnl/ps/kill.c @@ -301,6 +301,8 @@ PspDeleteProcess(IN PVOID ObjectBody) /* Detach */ KeUnstackDetachProcess(&ApcState); + RemoveEntryList(&Process->MmProcessLinks); + /* Completely delete the Address Space */ MmDeleteProcessAddressSpace(Process); } From a5bab7504ed54799ad297b760a4a1d3bb803ff2e Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Sat, 28 Aug 2010 23:23:43 +0000 Subject: [PATCH 63/76] [input/i8042prt] - Fix a check when queuing the mouse packet. Check that the buffer size (MouseInBuffer) is not greater or equal to MouseDataQueueSize. Fixes a NonPagedPool corruption that occurs when the mouse is moved before the desktop window is up and running. svn path=/trunk/; revision=48635 --- reactos/drivers/input/i8042prt/mouse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/drivers/input/i8042prt/mouse.c b/reactos/drivers/input/i8042prt/mouse.c index 11838134667..efa73093244 100644 --- a/reactos/drivers/input/i8042prt/mouse.c +++ b/reactos/drivers/input/i8042prt/mouse.c @@ -49,7 +49,7 @@ i8042MouQueuePacket( DeviceExtension->MouseComplete = TRUE; DeviceExtension->MouseInBuffer++; - if (DeviceExtension->MouseInBuffer > DeviceExtension->Common.PortDeviceExtension->Settings.MouseDataQueueSize) + if (DeviceExtension->MouseInBuffer >= DeviceExtension->Common.PortDeviceExtension->Settings.MouseDataQueueSize) { WARN_(I8042PRT, "Mouse buffer overflow\n"); DeviceExtension->MouseInBuffer--; From a3370efc0a1f8632e99bd3d1b56d98496be4571e Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Sat, 28 Aug 2010 23:55:27 +0000 Subject: [PATCH 64/76] [win32k] - Mouse messages can be sent before the desktop is initialized. Check for this and return false if its not. FIxes assert when moving mouse before desktop is up. svn path=/trunk/; revision=48636 --- reactos/subsystems/win32/win32k/ntuser/msgqueue.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/reactos/subsystems/win32/win32k/ntuser/msgqueue.c b/reactos/subsystems/win32/win32k/ntuser/msgqueue.c index dc315b5ccaf..b7cba1d7dd0 100644 --- a/reactos/subsystems/win32/win32k/ntuser/msgqueue.c +++ b/reactos/subsystems/win32/win32k/ntuser/msgqueue.c @@ -350,6 +350,10 @@ co_MsqTranslateMouseMessage(PUSER_MESSAGE_QUEUE MessageQueue, PWINDOW_OBJECT Win PWINDOW_OBJECT CaptureWindow = NULL; HWND hCaptureWin; + /* FIXME: Mouse message can be sent before the Desktop is up and running in which case ScopeWin (Desktop) is 0. + Is this the best fix? */ + if (ScopeWin == 0) return FALSE; + ASSERT_REFS_CO(ScopeWin); /* From c8ff03d6822f013ebc4a955de5f10b4cbf7bc681 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 29 Aug 2010 02:29:10 +0000 Subject: [PATCH 65/76] [TCPIP] - Don't allocate pool if there is nothing in the route table - Fixes bug 5493 svn path=/trunk/; revision=48637 --- reactos/drivers/network/tcpip/tcpip/ninfo.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/reactos/drivers/network/tcpip/tcpip/ninfo.c b/reactos/drivers/network/tcpip/tcpip/ninfo.c index 293eb19a027..f78d4b40062 100644 --- a/reactos/drivers/network/tcpip/tcpip/ninfo.c +++ b/reactos/drivers/network/tcpip/tcpip/ninfo.c @@ -21,15 +21,21 @@ TDI_STATUS InfoTdiQueryGetRouteTable( PIP_INTERFACE IF, PNDIS_BUFFER Buffer, PUI KIRQL OldIrql; UINT RtCount = CountFIBs(IF); UINT Size = sizeof( IPROUTE_ENTRY ) * RtCount; - PFIB_ENTRY RCache = - ExAllocatePool( NonPagedPool, sizeof( FIB_ENTRY ) * RtCount ), - RCacheCur = RCache; - PIPROUTE_ENTRY RouteEntries = ExAllocatePool( NonPagedPool, Size ), - RtCurrent = RouteEntries; + PFIB_ENTRY RCache, RCacheCur; + PIPROUTE_ENTRY RouteEntries, RtCurrent; UINT i; - TI_DbgPrint(DEBUG_INFO, ("Called, routes = %d, RCache = %08x\n", - RtCount, RCache)); + TI_DbgPrint(DEBUG_INFO, ("Called, routes = %d\n", + RtCount)); + + if (RtCount == 0) + return InfoCopyOut(NULL, 0, NULL, BufferSize); + + RouteEntries = ExAllocatePool( NonPagedPool, Size ); + RtCurrent = RouteEntries; + + RCache = ExAllocatePool( NonPagedPool, sizeof( FIB_ENTRY ) * RtCount ); + RCacheCur = RCache; if( !RCache || !RouteEntries ) { if( RCache ) ExFreePool( RCache ); From 2450e46a564d513c381d725b2684a2422552ffc8 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 29 Aug 2010 03:48:59 +0000 Subject: [PATCH 66/76] [NTOSKRNL] - Fix a regression in ACPI function from r48581 - Enable ACPI for testing purposes (will be disabled next commit) svn path=/trunk/; revision=48638 --- reactos/ntoskrnl/io/pnpmgr/pnpmgr.c | 34 ++++++++++++++--------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c index e8fb4cf5026..174f356523b 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c @@ -13,7 +13,7 @@ #define NDEBUG #include -//#define ENABLE_ACPI +#define ENABLE_ACPI /* GLOBALS *******************************************************************/ @@ -2643,32 +2643,30 @@ IopUpdateRootKey(VOID) if (IopIsAcpiComputer()) { InitializeObjectAttributes(&ObjectAttributes, &HalAcpiDevice, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, hRoot, NULL); - Status = ZwCreateKey(&hHalAcpiDevice, KEY_CREATE_SUB_KEY, &ObjectAttributes, 0, NULL, 0, &Disposition); + Status = ZwCreateKey(&hHalAcpiDevice, KEY_CREATE_SUB_KEY, &ObjectAttributes, 0, NULL, 0, NULL); ZwClose(hRoot); if (!NT_SUCCESS(Status)) return Status; + InitializeObjectAttributes(&ObjectAttributes, &HalAcpiId, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, hHalAcpiDevice, NULL); + Status = ZwCreateKey(&hHalAcpiId, KEY_CREATE_SUB_KEY | KEY_SET_VALUE, &ObjectAttributes, 0, NULL, 0, &Disposition); + ZwClose(hHalAcpiDevice); + if (!NT_SUCCESS(Status)) + return Status; if (Disposition == REG_CREATED_NEW_KEY) { - InitializeObjectAttributes(&ObjectAttributes, &HalAcpiId, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, hHalAcpiDevice, NULL); - Status = ZwCreateKey(&hHalAcpiId, KEY_CREATE_SUB_KEY, &ObjectAttributes, 0, NULL, 0, NULL); - ZwClose(hHalAcpiDevice); - if (!NT_SUCCESS(Status)) - return Status; Status = ZwSetValueKey(hHalAcpiId, &DeviceDescU, 0, REG_SZ, HalAcpiDeviceDesc.Buffer, HalAcpiDeviceDesc.MaximumLength); if (NT_SUCCESS(Status)) Status = ZwSetValueKey(hHalAcpiId, &HardwareIDU, 0, REG_MULTI_SZ, HalAcpiHardwareID.Buffer, HalAcpiHardwareID.MaximumLength); - if (NT_SUCCESS(Status)) - { - InitializeObjectAttributes(&ObjectAttributes, &LogConfU, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, hHalAcpiId, NULL); - Status = ZwCreateKey(&hLogConf, 0, &ObjectAttributes, 0, NULL, REG_OPTION_VOLATILE, NULL); - if (NT_SUCCESS(Status)) - ZwClose(hLogConf); - } - ZwClose(hHalAcpiId); - return Status; } - ZwClose(hHalAcpiDevice); - return STATUS_SUCCESS; + if (NT_SUCCESS(Status)) + { + InitializeObjectAttributes(&ObjectAttributes, &LogConfU, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, hHalAcpiId, NULL); + Status = ZwCreateKey(&hLogConf, 0, &ObjectAttributes, 0, NULL, REG_OPTION_VOLATILE, NULL); + if (NT_SUCCESS(Status)) + ZwClose(hLogConf); + } + ZwClose(hHalAcpiId); + return Status; } else { From 73e641d29b682f55f5f16d3e6bd040af5f871dcc Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 29 Aug 2010 03:51:21 +0000 Subject: [PATCH 67/76] - Disable ACPI again svn path=/trunk/; revision=48639 --- reactos/ntoskrnl/io/pnpmgr/pnpmgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c index 174f356523b..35e8efcc080 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c @@ -13,7 +13,7 @@ #define NDEBUG #include -#define ENABLE_ACPI +//#define ENABLE_ACPI /* GLOBALS *******************************************************************/ From 690399c881f2702bee3acd6f8f9bda1d2cfbf916 Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Sun, 29 Aug 2010 07:00:52 +0000 Subject: [PATCH 68/76] [ntoskrnl] - When a node is removed, check the NodeHint of the table to see if it matches the one being removed. If so update the NodeHint to the PreviousNode. FIxes VAD corruption messages. svn path=/trunk/; revision=48640 --- reactos/ntoskrnl/mm/ARM3/vadnode.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/reactos/ntoskrnl/mm/ARM3/vadnode.c b/reactos/ntoskrnl/mm/ARM3/vadnode.c index b75f2dc6589..79b962855b6 100644 --- a/reactos/ntoskrnl/mm/ARM3/vadnode.c +++ b/reactos/ntoskrnl/mm/ARM3/vadnode.c @@ -108,6 +108,11 @@ NTAPI MiRemoveNode(IN PMMADDRESS_NODE Node, IN PMM_AVL_TABLE Table) { + if (Table->NodeHint == Node) + { + Table->NodeHint = MiGetPreviousNode(Table->NodeHint); + } + /* Call the AVL code */ RtlpDeleteAvlTreeNode(Table, Node); From fbf071095a9d6e9e5d7124b89f45a0c5ea74c89a Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Sun, 29 Aug 2010 07:18:47 +0000 Subject: [PATCH 69/76] [ntoskrnl] - Revert 48640, as it was incorrect. svn path=/trunk/; revision=48641 --- reactos/ntoskrnl/mm/ARM3/vadnode.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/reactos/ntoskrnl/mm/ARM3/vadnode.c b/reactos/ntoskrnl/mm/ARM3/vadnode.c index 79b962855b6..b75f2dc6589 100644 --- a/reactos/ntoskrnl/mm/ARM3/vadnode.c +++ b/reactos/ntoskrnl/mm/ARM3/vadnode.c @@ -108,11 +108,6 @@ NTAPI MiRemoveNode(IN PMMADDRESS_NODE Node, IN PMM_AVL_TABLE Table) { - if (Table->NodeHint == Node) - { - Table->NodeHint = MiGetPreviousNode(Table->NodeHint); - } - /* Call the AVL code */ RtlpDeleteAvlTreeNode(Table, Node); From 69814e0c5b2fc665b74bfe2122171f2e26ada171 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 29 Aug 2010 08:35:54 +0000 Subject: [PATCH 70/76] [NTOSKRNL] Modified version of r48640: - update the NodeHint to the root node when deleting a node - remove this code from MmCleanProcessAddressSpace svn path=/trunk/; revision=48642 --- reactos/ntoskrnl/mm/ARM3/procsup.c | 9 --------- reactos/ntoskrnl/mm/ARM3/vadnode.c | 10 ++++++++++ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/reactos/ntoskrnl/mm/ARM3/procsup.c b/reactos/ntoskrnl/mm/ARM3/procsup.c index dd79e2cddc2..a2280a00cf2 100644 --- a/reactos/ntoskrnl/mm/ARM3/procsup.c +++ b/reactos/ntoskrnl/mm/ARM3/procsup.c @@ -1164,18 +1164,9 @@ MmCleanProcessAddressSpace(IN PEPROCESS Process) /* Remove this VAD from the tree */ ASSERT(VadTree->NumberGenericTableElements >= 1); - DPRINT("Removing node for VAD: %lx %lx\n", Vad->StartingVpn, Vad->EndingVpn); MiRemoveNode((PMMADDRESS_NODE)Vad, VadTree); DPRINT("Moving on: %d\n", VadTree->NumberGenericTableElements); - /* Check if this VAD was the hint */ - if (VadTree->NodeHint == Vad) - { - /* Get a new hint, unless we're empty now, in which case nothing */ - VadTree->NodeHint = VadTree->BalancedRoot.RightChild; - if (!VadTree->NumberGenericTableElements) VadTree->NodeHint = NULL; - } - /* Only PEB/TEB VADs supported for now */ ASSERT(Vad->u.VadFlags.PrivateMemory == 1); ASSERT(Vad->u.VadFlags.VadType == VadNone); diff --git a/reactos/ntoskrnl/mm/ARM3/vadnode.c b/reactos/ntoskrnl/mm/ARM3/vadnode.c index b75f2dc6589..a9aa209dd84 100644 --- a/reactos/ntoskrnl/mm/ARM3/vadnode.c +++ b/reactos/ntoskrnl/mm/ARM3/vadnode.c @@ -108,11 +108,21 @@ NTAPI MiRemoveNode(IN PMMADDRESS_NODE Node, IN PMM_AVL_TABLE Table) { + DPRINT("Removing address node: %lx %lx\n", Node->StartingVpn, Node->EndingVpn); + /* Call the AVL code */ RtlpDeleteAvlTreeNode(Table, Node); /* Decrease element count */ Table->NumberGenericTableElements--; + + /* Check if this node was the hint */ + if (Table->NodeHint == Node) + { + /* Get a new hint, unless we're empty now, in which case nothing */ + if (!Table->NumberGenericTableElements) Table->NodeHint = NULL; + else Table->NodeHint = Table->BalancedRoot.RightChild; + } } PMMADDRESS_NODE From 52929981d96016fdaad815762b84b8f92237837e Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Sun, 29 Aug 2010 17:46:18 +0000 Subject: [PATCH 71/76] [cdfs] - Working with Pierre Schweitzer for yet another NonPaged Pool corruption fix. When copying VolumeLabel the VolumeLabelLength is in Unicode, so theres no need to mulitply it by size of WCHAR. svn path=/trunk/; revision=48646 --- reactos/drivers/filesystems/cdfs/fsctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/drivers/filesystems/cdfs/fsctl.c b/reactos/drivers/filesystems/cdfs/fsctl.c index dd0e065a055..c0433db4768 100644 --- a/reactos/drivers/filesystems/cdfs/fsctl.c +++ b/reactos/drivers/filesystems/cdfs/fsctl.c @@ -359,7 +359,7 @@ CdfsMountVolume(PDEVICE_OBJECT DeviceObject, Vpb->SerialNumber = CdInfo.SerialNumber; Vpb->VolumeLabelLength = CdInfo.VolumeLabelLength; - RtlCopyMemory(Vpb->VolumeLabel, CdInfo.VolumeLabel, CdInfo.VolumeLabelLength * sizeof(WCHAR)); + RtlCopyMemory(Vpb->VolumeLabel, CdInfo.VolumeLabel, CdInfo.VolumeLabelLength); RtlCopyMemory(&DeviceExt->CdInfo, &CdInfo, sizeof(CDINFO)); NewDeviceObject->Vpb = DeviceToMount->Vpb; From 1afef0ace6c6c1360e1bcf525d57f3b8f89b2c66 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 29 Aug 2010 18:40:33 +0000 Subject: [PATCH 72/76] [ACPI] - Read and report ACPI_RESOURCE_TYPE_FIXED_MEMORY32 svn path=/trunk/; revision=48648 --- reactos/drivers/bus/acpi/buspdo.c | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/reactos/drivers/bus/acpi/buspdo.c b/reactos/drivers/bus/acpi/buspdo.c index d5129ffa5f5..7d167b7742c 100644 --- a/reactos/drivers/bus/acpi/buspdo.c +++ b/reactos/drivers/bus/acpi/buspdo.c @@ -727,6 +727,7 @@ Bus_PDO_QueryResources( case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: case ACPI_RESOURCE_TYPE_MEMORY24: case ACPI_RESOURCE_TYPE_MEMORY32: + case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: case ACPI_RESOURCE_TYPE_IO: { NumberOfResources++; @@ -1044,6 +1045,22 @@ Bus_PDO_QueryResources( ResourceDescriptor->u.Memory.Start.QuadPart = mem32_data->Minimum; ResourceDescriptor->u.Memory.Length = mem32_data->AddressLength; + ResourceDescriptor++; + break; + } + case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: + { + ACPI_RESOURCE_FIXED_MEMORY32 *memfixed32_data = (ACPI_RESOURCE_FIXED_MEMORY32*) &resource->Data; + ResourceDescriptor->Type = CmResourceTypeMemory; + ResourceDescriptor->ShareDisposition = CmResourceShareDeviceExclusive; + ResourceDescriptor->Flags = 0; + if (memfixed32_data->WriteProtect == ACPI_READ_ONLY_MEMORY) + ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_ONLY; + else + ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_WRITE; + ResourceDescriptor->u.Memory.Start.QuadPart = memfixed32_data->Address; + ResourceDescriptor->u.Memory.Length = memfixed32_data->AddressLength; + ResourceDescriptor++; break; } @@ -1142,6 +1159,7 @@ Bus_PDO_QueryResourceRequirements( case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: case ACPI_RESOURCE_TYPE_MEMORY24: case ACPI_RESOURCE_TYPE_MEMORY32: + case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: case ACPI_RESOURCE_TYPE_IO: { NumberOfResources++; @@ -1479,6 +1497,24 @@ Bus_PDO_QueryResourceRequirements( RequirementDescriptor->u.Memory.MaximumAddress.QuadPart = mem32_data->Maximum; RequirementDescriptor->u.Memory.Length = mem32_data->AddressLength; + RequirementDescriptor++; + break; + } + case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: + { + ACPI_RESOURCE_FIXED_MEMORY32 *fixedmem32_data = (ACPI_RESOURCE_FIXED_MEMORY32*) &resource->Data; + RequirementDescriptor->Option = CurrentRes ? 0 : IO_RESOURCE_PREFERRED; + RequirementDescriptor->Type = CmResourceTypeMemory; + RequirementDescriptor->ShareDisposition = CmResourceShareDeviceExclusive; + RequirementDescriptor->Flags = 0; + if (fixedmem32_data->WriteProtect == ACPI_READ_ONLY_MEMORY) + RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_ONLY; + else + RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_WRITE; + RequirementDescriptor->u.Memory.MinimumAddress.QuadPart = fixedmem32_data->Address; + RequirementDescriptor->u.Memory.MaximumAddress.QuadPart = fixedmem32_data->Address; + RequirementDescriptor->u.Memory.Length = fixedmem32_data->AddressLength; + RequirementDescriptor++; break; } From cf28a01e5ecc2e321190aa59eec528eefda47071 Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Sun, 29 Aug 2010 19:13:08 +0000 Subject: [PATCH 73/76] [NTOS]: Add DRIVER_CAUGHT_MODIFYING_FREED_POOL bugcheck code. [NTOS]: Add support for protected freed nonpaged pool. This is controlled through MmProtectFreedNonPagedPool, which is initialized based on a registry value (see cmdata.c). This is not "Special Pool", but a useful debugging feature Windows implements that we now have too, since I noticed a lot of mj's work was with freed pool access. NB. It's 3AM and I have not tested this, it should be off in trunk by default, you'll need to try turning it on and testing it. Hope it helps. --This line, and those low, will be ignored-- M ntoskrnl/mm/ARM3/pagfault.c M ntoskrnl/mm/ARM3/pool.c M include/reactos/mc/bugcodes.mc svn path=/trunk/; revision=48649 --- reactos/include/reactos/mc/bugcodes.mc | 10 ++ reactos/ntoskrnl/mm/ARM3/pagfault.c | 26 ++- reactos/ntoskrnl/mm/ARM3/pool.c | 214 ++++++++++++++++++++++--- 3 files changed, 228 insertions(+), 22 deletions(-) diff --git a/reactos/include/reactos/mc/bugcodes.mc b/reactos/include/reactos/mc/bugcodes.mc index f59d7f0d7f3..bb0b556f564 100644 --- a/reactos/include/reactos/mc/bugcodes.mc +++ b/reactos/include/reactos/mc/bugcodes.mc @@ -1311,6 +1311,16 @@ restart your computer, press F8 to select Advanced Startup Options, and then select Safe Mode. . +MessageId=0xC6 +Severity=Success +Facility=System +SymbolicName=DRIVER_CAUGHT_MODIFYING_FREED_POOL +Language=English +A device driver attempting to corrupt the system has been caught. +The faulty driver currently on the kernel stack must be replaced +with a working version. +. + MessageId=0xC8 Severity=Success Facility=System diff --git a/reactos/ntoskrnl/mm/ARM3/pagfault.c b/reactos/ntoskrnl/mm/ARM3/pagfault.c index 2570d790e19..8627cdeebe3 100644 --- a/reactos/ntoskrnl/mm/ARM3/pagfault.c +++ b/reactos/ntoskrnl/mm/ARM3/pagfault.c @@ -620,10 +620,28 @@ MmArmAccessFault(IN BOOLEAN StoreInstruction, return STATUS_SUCCESS; } - // - // We don't implement prototype PTEs - // - ASSERT(TempPte.u.Soft.Prototype == 0); + /* Check one kind of prototype PTE */ + if (TempPte.u.Soft.Prototype) + { + /* The one used for protected pool... */ + ASSERT(MmProtectFreedNonPagedPool == TRUE); + + /* Make sure protected pool is on, and that this is a pool address */ + if ((MmProtectFreedNonPagedPool) && + (((Address >= MmNonPagedPoolStart) && + (Address < (PVOID)((ULONG_PTR)MmNonPagedPoolStart + + MmSizeOfNonPagedPoolInBytes))) || + ((Address >= MmNonPagedPoolExpansionStart) && + (Address < MmNonPagedPoolEnd)))) + { + /* Bad boy, bad boy, whatcha gonna do, whatcha gonna do when ARM3 comes for you! */ + KeBugCheckEx(DRIVER_CAUGHT_MODIFYING_FREED_POOL, + (ULONG_PTR)Address, + StoreInstruction, + Mode, + 4); + } + } // // We don't implement transition PTEs diff --git a/reactos/ntoskrnl/mm/ARM3/pool.c b/reactos/ntoskrnl/mm/ARM3/pool.c index 57409b02ad1..ca3a4b3589b 100644 --- a/reactos/ntoskrnl/mm/ARM3/pool.c +++ b/reactos/ntoskrnl/mm/ARM3/pool.c @@ -31,6 +31,150 @@ BOOLEAN MmProtectFreedNonPagedPool; /* PRIVATE FUNCTIONS **********************************************************/ +VOID +NTAPI +MiProtectFreeNonPagedPool(IN PVOID VirtualAddress, + IN ULONG PageCount) +{ + PMMPTE PointerPte, LastPte; + MMPTE TempPte; + + /* If pool is physical, can't protect PTEs */ + if (MI_IS_PHYSICAL_ADDRESS(VirtualAddress)) return; + + /* Get PTE pointers and loop */ + PointerPte = MiAddressToPte(VirtualAddress); + LastPte = PointerPte + PageCount; + do + { + /* Capture the PTE for safety */ + TempPte = *PointerPte; + + /* Mark it as an invalid PTE, set proto bit to recognize it as pool */ + TempPte.u.Hard.Valid = 0; + TempPte.u.Soft.Prototype = 1; + MI_WRITE_INVALID_PTE(PointerPte, TempPte); + } while (++PointerPte < LastPte); + + /* Flush the TLB */ + KeFlushEntireTb(TRUE, TRUE); +} + +BOOLEAN +NTAPI +MiUnProtectFreeNonPagedPool(IN PVOID VirtualAddress, + IN ULONG PageCount) +{ + PMMPTE PointerPte; + MMPTE TempPte; + PFN_NUMBER UnprotectedPages = 0; + + /* If pool is physical, can't protect PTEs */ + if (MI_IS_PHYSICAL_ADDRESS(VirtualAddress)) return FALSE; + + /* Get, and capture the PTE */ + PointerPte = MiAddressToPte(VirtualAddress); + TempPte = *PointerPte; + + /* Loop protected PTEs */ + while ((TempPte.u.Hard.Valid == 0) && (TempPte.u.Soft.Prototype == 1)) + { + /* Unprotect the PTE */ + TempPte.u.Hard.Valid = 1; + TempPte.u.Soft.Prototype = 0; + MI_WRITE_VALID_PTE(PointerPte, TempPte); + + /* One more page */ + if (++UnprotectedPages == PageCount) break; + + /* Capture next PTE */ + TempPte = *(++PointerPte); + } + + /* Return if any pages were unprotected */ + return UnprotectedPages ? TRUE : FALSE; +} + +VOID +FORCEINLINE +MiProtectedPoolUnProtectLinks(IN PLIST_ENTRY Links, + OUT PVOID* PoolFlink, + OUT PVOID* PoolBlink) +{ + BOOLEAN Safe; + PVOID PoolVa; + + /* Initialize variables */ + *PoolFlink = *PoolBlink = NULL; + + /* Check if the list has entries */ + if (IsListEmpty(Links) == FALSE) + { + /* We are going to need to forward link to do an insert */ + PoolVa = Links->Flink; + + /* So make it safe to access */ + Safe = MiUnProtectFreeNonPagedPool(PoolVa, 1); + if (Safe) PoolFlink = PoolVa; + } + + /* Are we going to need a backward link too? */ + if (Links != Links->Blink) + { + /* Get the head's backward link for the insert */ + PoolVa = Links->Blink; + + /* Make it safe to access */ + Safe = MiUnProtectFreeNonPagedPool(PoolVa, 1); + if (Safe) PoolBlink = PoolVa; + } +} + +VOID +FORCEINLINE +MiProtectedPoolProtectLinks(IN PVOID PoolFlink, + IN PVOID PoolBlink) +{ + /* Reprotect the pages, if they got unprotected earlier */ + if (PoolFlink) MiProtectFreeNonPagedPool(PoolFlink, 1); + if (PoolBlink) MiProtectFreeNonPagedPool(PoolBlink, 1); +} + +VOID +NTAPI +MiProtectedPoolInsertList(IN PLIST_ENTRY ListHead, + IN PLIST_ENTRY Entry, + IN BOOLEAN Critical) +{ + PVOID PoolFlink, PoolBlink; + + /* Make the list accessible */ + MiProtectedPoolUnProtectLinks(ListHead, &PoolFlink, &PoolBlink); + + /* Now insert in the right position */ + Critical ? InsertHeadList(ListHead, Entry) : InsertTailList(ListHead, Entry); + + /* And reprotect the pages containing the free links */ + MiProtectedPoolProtectLinks(PoolFlink, PoolBlink); +} + +VOID +NTAPI +MiProtectedPoolRemoveEntryList(IN PLIST_ENTRY Entry) +{ + PVOID PoolFlink, PoolBlink; + + /* Make the list accessible */ + MiProtectedPoolUnProtectLinks(Entry, &PoolFlink, &PoolBlink); + + /* Now remove */ + RemoveEntryList(Entry); + + /* And reprotect the pages containing the free links */ + if (PoolFlink) MiProtectFreeNonPagedPool(PoolFlink, 1); + if (PoolBlink) MiProtectFreeNonPagedPool(PoolBlink, 1); +} + VOID NTAPI MiInitializeNonPagedPoolThresholds(VOID) @@ -245,7 +389,7 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType, // // Handle paged pool // - if (PoolType == PagedPool) + if ((PoolType & BASE_POOL_TYPE_MASK) == PagedPool) { // // Lock the paged pool mutex @@ -755,12 +899,21 @@ MiFreePoolPages(IN PVOID StartingVa) } else { + /* Sanity check */ + ASSERT((ULONG_PTR)StartingVa + NumberOfPages <= (ULONG_PTR)MmNonPagedPoolEnd); + + /* Check if protected pool is enabled */ + if (MmProtectFreedNonPagedPool) + { + /* The freed block will be merged, it must be made accessible */ + MiUnProtectFreeNonPagedPool(MiPteToAddress(PointerPte), 0); + } + // // Otherwise, our entire allocation must've fit within the initial non // paged pool, or the expansion nonpaged pool, so get the PFN entry of // the next allocation // - ASSERT((ULONG_PTR)StartingVa + NumberOfPages <= (ULONG_PTR)MmNonPagedPoolEnd); if (PointerPte->u.Hard.Valid == 1) { // @@ -791,11 +944,13 @@ MiFreePoolPages(IN PVOID StartingVa) (NumberOfPages << PAGE_SHIFT)); ASSERT(FreeEntry->Owner == FreeEntry); - // - // Consume this entry's pages, and remove it from its free list - // + /* Consume this entry's pages */ FreePages += FreeEntry->Size; - RemoveEntryList (&FreeEntry->List); + + /* Remove the item from the list, depending if pool is protected */ + MmProtectFreedNonPagedPool ? + MiProtectedPoolRemoveEntryList(&FreeEntry->List) : + RemoveEntryList(&FreeEntry->List); } // @@ -819,6 +974,15 @@ MiFreePoolPages(IN PVOID StartingVa) // Otherwise, get the PTE for the page right before our allocation // PointerPte -= NumberOfPages + 1; + + /* Check if protected pool is enabled */ + if (MmProtectFreedNonPagedPool) + { + /* The freed block will be merged, it must be made accessible */ + MiUnProtectFreeNonPagedPool(MiPteToAddress(PointerPte), 0); + } + + /* Check if this is valid pool, or a guard page */ if (PointerPte->u.Hard.Valid == 1) { // @@ -848,6 +1012,13 @@ MiFreePoolPages(IN PVOID StartingVa) FreeEntry = (PMMFREE_POOL_ENTRY)((ULONG_PTR)StartingVa - PAGE_SIZE); FreeEntry = FreeEntry->Owner; + /* Check if protected pool is enabled */ + if (MmProtectFreedNonPagedPool) + { + /* The freed block will be merged, it must be made accessible */ + MiUnProtectFreeNonPagedPool(FreeEntry, 0); + } + // // Check if the entry is small enough to be indexed on a free list // If it is, we'll want to re-insert it, since we're about to @@ -855,10 +1026,10 @@ MiFreePoolPages(IN PVOID StartingVa) // if (FreeEntry->Size < (MI_MAX_FREE_PAGE_LISTS - 1)) { - // - // Remove the list from where it is now - // - RemoveEntryList(&FreeEntry->List); + /* Remove the item from the list, depending if pool is protected */ + MmProtectFreedNonPagedPool ? + MiProtectedPoolRemoveEntryList(&FreeEntry->List) : + RemoveEntryList(&FreeEntry->List); // // Update its size @@ -871,10 +1042,10 @@ MiFreePoolPages(IN PVOID StartingVa) i = (ULONG)(FreeEntry->Size - 1); if (i >= MI_MAX_FREE_PAGE_LISTS) i = MI_MAX_FREE_PAGE_LISTS - 1; - // - // Do it - // - InsertTailList(&MmNonPagedPoolFreeListHead[i], &FreeEntry->List); + /* Insert the entry into the free list head, check for prot. pool */ + MmProtectFreedNonPagedPool ? + MiProtectedPoolInsertList(&MmNonPagedPoolFreeListHead[i], &FreeEntry->List, TRUE) : + InsertTailList(&MmNonPagedPoolFreeListHead[i], &FreeEntry->List); } else { @@ -902,10 +1073,10 @@ MiFreePoolPages(IN PVOID StartingVa) i = FreeEntry->Size - 1; if (i >= MI_MAX_FREE_PAGE_LISTS) i = MI_MAX_FREE_PAGE_LISTS - 1; - // - // And insert us - // - InsertTailList (&MmNonPagedPoolFreeListHead[i], &FreeEntry->List); + /* Insert the entry into the free list head, check for prot. pool */ + MmProtectFreedNonPagedPool ? + MiProtectedPoolInsertList(&MmNonPagedPoolFreeListHead[i], &FreeEntry->List, TRUE) : + InsertTailList(&MmNonPagedPoolFreeListHead[i], &FreeEntry->List); } // @@ -928,6 +1099,13 @@ MiFreePoolPages(IN PVOID StartingVa) NextEntry = (PMMFREE_POOL_ENTRY)((ULONG_PTR)NextEntry + PAGE_SIZE); } while (NextEntry != LastEntry); + /* Is freed non paged pool protected? */ + if (MmProtectFreedNonPagedPool) + { + /* Protect the freed pool! */ + MiProtectFreeNonPagedPool(FreeEntry, FreeEntry->Size); + } + // // We're done, release the lock and let the caller know how much we freed // From b85ab20f13c49450c8d7f7e82db9d3a32a0daf7c Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Sun, 29 Aug 2010 19:27:58 +0000 Subject: [PATCH 74/76] [NTOS]: Missed a bunch of codepaths, protected pool "should" work now. svn path=/trunk/; revision=48650 --- reactos/ntoskrnl/include/internal/mm.h | 3 ++ reactos/ntoskrnl/mm/ARM3/pool.c | 42 ++++++++++++++++++++------ 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/reactos/ntoskrnl/include/internal/mm.h b/reactos/ntoskrnl/include/internal/mm.h index a7154de564d..346d9c08a54 100644 --- a/reactos/ntoskrnl/include/internal/mm.h +++ b/reactos/ntoskrnl/include/internal/mm.h @@ -435,6 +435,9 @@ typedef struct _MMFREE_POOL_ENTRY struct _MMFREE_POOL_ENTRY *Owner; } MMFREE_POOL_ENTRY, *PMMFREE_POOL_ENTRY; +/* Signature of a freed block */ +#define MM_FREE_POOL_SIGNATURE 'ARM3' + /* Paged pool information */ typedef struct _MM_PAGED_POOL_INFO { diff --git a/reactos/ntoskrnl/mm/ARM3/pool.c b/reactos/ntoskrnl/mm/ARM3/pool.c index ca3a4b3589b..2e089507234 100644 --- a/reactos/ntoskrnl/mm/ARM3/pool.c +++ b/reactos/ntoskrnl/mm/ARM3/pool.c @@ -615,6 +615,13 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType, NextEntry = NextHead->Flink; while (NextEntry != NextHead) { + /* Is freed non paged pool enabled */ + if (MmProtectFreedNonPagedPool) + { + /* We need to be able to touch this page, unprotect it */ + MiUnProtectFreeNonPagedPool(NextEntry, 0); + } + // // Grab the entry and see if it can handle our allocation // @@ -632,23 +639,31 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType, BaseVa = (PVOID)((ULONG_PTR)FreeEntry + (FreeEntry->Size << PAGE_SHIFT)); - // - // This is not a free page segment anymore - // - RemoveEntryList(&FreeEntry->List); + /* Remove the item from the list, depending if pool is protected */ + MmProtectFreedNonPagedPool ? + MiProtectedPoolRemoveEntryList(&FreeEntry->List) : + RemoveEntryList(&FreeEntry->List); // // However, check if its' still got space left // if (FreeEntry->Size != 0) { - // - // Insert it back into a different list, based on its pages - // + /* Check which list to insert this entry into */ i = FreeEntry->Size - 1; if (i >= MI_MAX_FREE_PAGE_LISTS) i = MI_MAX_FREE_PAGE_LISTS - 1; - InsertTailList (&MmNonPagedPoolFreeListHead[i], - &FreeEntry->List); + + /* Insert the entry into the free list head, check for prot. pool */ + MmProtectFreedNonPagedPool ? + MiProtectedPoolInsertList(&MmNonPagedPoolFreeListHead[i], &FreeEntry->List, TRUE) : + InsertTailList(&MmNonPagedPoolFreeListHead[i], &FreeEntry->List); + + /* Is freed non paged pool protected? */ + if (MmProtectFreedNonPagedPool) + { + /* Protect the freed pool! */ + MiProtectFreeNonPagedPool(FreeEntry, FreeEntry->Size); + } } // @@ -698,6 +713,13 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType, // Try the next free page entry // NextEntry = FreeEntry->List.Flink; + + /* Is freed non paged pool protected? */ + if (MmProtectFreedNonPagedPool) + { + /* Protect the freed pool! */ + MiProtectFreeNonPagedPool(FreeEntry, FreeEntry->Size); + } } } while (++NextHead < LastHead); @@ -1095,7 +1117,7 @@ MiFreePoolPages(IN PVOID StartingVa) // // Link back to the parent free entry, and keep going // - NextEntry->Owner = FreeEntry; + NextEntry->Owner = FreeEntry; NextEntry = (PMMFREE_POOL_ENTRY)((ULONG_PTR)NextEntry + PAGE_SIZE); } while (NextEntry != LastEntry); From c574f506637441497bfc3573027b7ded651f14ae Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Sun, 29 Aug 2010 19:32:25 +0000 Subject: [PATCH 75/76] [NTOS]: Add an extra layer of protection for freed nonpaged pool: write a 4-byte signature on freed blocks, and assert its valid on checked builds. Use a slightly less egocentric ASCII value than on Windows (name of the developer who wrote the first memory manager). svn path=/trunk/; revision=48651 --- reactos/ntoskrnl/mm/ARM3/pool.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/reactos/ntoskrnl/mm/ARM3/pool.c b/reactos/ntoskrnl/mm/ARM3/pool.c index 2e089507234..39736ffdb5b 100644 --- a/reactos/ntoskrnl/mm/ARM3/pool.c +++ b/reactos/ntoskrnl/mm/ARM3/pool.c @@ -298,6 +298,7 @@ MiInitializeNonPagedPool(VOID) FreeEntry = MmNonPagedPoolStart; FirstEntry = FreeEntry; FreeEntry->Size = PoolPages; + FreeEntry->Signature = MM_FREE_POOL_SIGNATURE; FreeEntry->Owner = FirstEntry; // @@ -316,6 +317,7 @@ MiInitializeNonPagedPool(VOID) // FreeEntry = (PMMFREE_POOL_ENTRY)((ULONG_PTR)FreeEntry + PAGE_SIZE); FreeEntry->Owner = FirstEntry; + FreeEntry->Signature = MM_FREE_POOL_SIGNATURE; } // @@ -626,6 +628,7 @@ MiAllocatePoolPages(IN POOL_TYPE PoolType, // Grab the entry and see if it can handle our allocation // FreeEntry = CONTAINING_RECORD(NextEntry, MMFREE_POOL_ENTRY, List); + ASSERT(FreeEntry->Signature == MM_FREE_POOL_SIGNATURE); if (FreeEntry->Size >= SizeInPages) { // @@ -964,6 +967,7 @@ MiFreePoolPages(IN PVOID StartingVa) // FreeEntry = (PMMFREE_POOL_ENTRY)((ULONG_PTR)StartingVa + (NumberOfPages << PAGE_SHIFT)); + ASSERT(FreeEntry->Signature == MM_FREE_POOL_SIGNATURE); ASSERT(FreeEntry->Owner == FreeEntry); /* Consume this entry's pages */ @@ -1032,6 +1036,7 @@ MiFreePoolPages(IN PVOID StartingVa) // Get the free entry descriptor for that given page range // FreeEntry = (PMMFREE_POOL_ENTRY)((ULONG_PTR)StartingVa - PAGE_SIZE); + ASSERT(FreeEntry->Signature == MM_FREE_POOL_SIGNATURE); FreeEntry = FreeEntry->Owner; /* Check if protected pool is enabled */ @@ -1118,6 +1123,7 @@ MiFreePoolPages(IN PVOID StartingVa) // Link back to the parent free entry, and keep going // NextEntry->Owner = FreeEntry; + NextEntry->Signature = MM_FREE_POOL_SIGNATURE; NextEntry = (PMMFREE_POOL_ENTRY)((ULONG_PTR)NextEntry + PAGE_SIZE); } while (NextEntry != LastEntry); From 9b7e628d96ec6d1f2c3c9e9653390f19815db9b7 Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Mon, 30 Aug 2010 11:51:17 +0000 Subject: [PATCH 76/76] Patch by Pierre Schweitzer. [CDFS] - Several fixes for directory information query. - Fixed a null access memory under certain circumstances. - Added support for media ejection. [FASTFAT] - Fixed calls to CcMapData(), CcPinRead(). - Fixed an endless loop in FCB management under certain circumstances. [NTOSKRNL] - Fixed wrong prototype for IopParseDevice(). svn path=/trunk/; revision=48654 --- reactos/drivers/filesystems/cdfs/cdfs.c | 2 + reactos/drivers/filesystems/cdfs/cdfs.h | 6 +- reactos/drivers/filesystems/cdfs/cdfs.rbuild | 1 + reactos/drivers/filesystems/cdfs/common.c | 7 +- reactos/drivers/filesystems/cdfs/devctrl.c | 64 +++++++++++++ reactos/drivers/filesystems/cdfs/dirctl.c | 93 ++++++++----------- reactos/drivers/filesystems/cdfs/fcb.c | 9 +- reactos/drivers/filesystems/fastfat/create.c | 4 +- .../drivers/filesystems/fastfat/direntry.c | 4 +- reactos/drivers/filesystems/fastfat/dirwr.c | 4 +- reactos/drivers/filesystems/fastfat/fcb.c | 4 +- reactos/drivers/filesystems/fastfat/volume.c | 16 ++-- reactos/ntoskrnl/include/internal/io.h | 2 +- reactos/ntoskrnl/io/iomgr/file.c | 2 +- 14 files changed, 139 insertions(+), 79 deletions(-) create mode 100644 reactos/drivers/filesystems/cdfs/devctrl.c diff --git a/reactos/drivers/filesystems/cdfs/cdfs.c b/reactos/drivers/filesystems/cdfs/cdfs.c index 28eb370766b..172282eff77 100644 --- a/reactos/drivers/filesystems/cdfs/cdfs.c +++ b/reactos/drivers/filesystems/cdfs/cdfs.c @@ -95,6 +95,8 @@ DriverEntry(PDRIVER_OBJECT DriverObject, CdfsQueryVolumeInformation; DriverObject->MajorFunction[IRP_MJ_SET_VOLUME_INFORMATION] = CdfsSetVolumeInformation; + DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = + CdfsDeviceControl; DriverObject->DriverUnload = NULL; diff --git a/reactos/drivers/filesystems/cdfs/cdfs.h b/reactos/drivers/filesystems/cdfs/cdfs.h index 3b114efdfee..905a34e0c75 100644 --- a/reactos/drivers/filesystems/cdfs/cdfs.h +++ b/reactos/drivers/filesystems/cdfs/cdfs.h @@ -277,13 +277,17 @@ CdfsDeviceIoControl (IN PDEVICE_OBJECT DeviceObject, IN OUT PULONG pOutputBufferSize, IN BOOLEAN Override); - /* create.c */ NTSTATUS NTAPI CdfsCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp); +/* devctrl.c */ + +NTSTATUS NTAPI +CdfsDeviceControl(PDEVICE_OBJECT DeviceObject, + PIRP Irp); /* dirctl.c */ diff --git a/reactos/drivers/filesystems/cdfs/cdfs.rbuild b/reactos/drivers/filesystems/cdfs/cdfs.rbuild index 2aed0e891db..ef0edec3bba 100644 --- a/reactos/drivers/filesystems/cdfs/cdfs.rbuild +++ b/reactos/drivers/filesystems/cdfs/cdfs.rbuild @@ -10,6 +10,7 @@ close.c common.c create.c + devctrl.c dirctl.c fcb.c finfo.c diff --git a/reactos/drivers/filesystems/cdfs/common.c b/reactos/drivers/filesystems/cdfs/common.c index 3a3722e5a74..dd47a78a964 100644 --- a/reactos/drivers/filesystems/cdfs/common.c +++ b/reactos/drivers/filesystems/cdfs/common.c @@ -197,8 +197,11 @@ CdfsDeviceIoControl (IN PDEVICE_OBJECT DeviceObject, DeviceToVerify = IoGetDeviceToVerify(PsGetCurrentThread()); IoSetDeviceToVerify(PsGetCurrentThread(), NULL); - NewStatus = IoVerifyVolume(DeviceToVerify, FALSE); - DPRINT1("IoVerifyVolume() returned (Status %lx)\n", NewStatus); + if (DeviceToVerify) + { + NewStatus = IoVerifyVolume(DeviceToVerify, FALSE); + DPRINT1("IoVerifyVolume() returned (Status %lx)\n", NewStatus); + } } DPRINT("Returning Status %x\n", Status); diff --git a/reactos/drivers/filesystems/cdfs/devctrl.c b/reactos/drivers/filesystems/cdfs/devctrl.c new file mode 100644 index 00000000000..cee4ba58aca --- /dev/null +++ b/reactos/drivers/filesystems/cdfs/devctrl.c @@ -0,0 +1,64 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: drivers/filesystems/cdfs/devctrl.c + * PURPOSE: CDROM (ISO 9660) filesystem driver + * PROGRAMMER: Pierre Schweitzer + * + */ + +/* INCLUDES *****************************************************************/ + +#include "cdfs.h" + +#define NDEBUG +#include + +/* FUNCTIONS ****************************************************************/ + +NTSTATUS NTAPI +CdfsDeviceControl(PDEVICE_OBJECT DeviceObject, + PIRP Irp) +{ + NTSTATUS Status; + PVCB Vcb = NULL; + PFILE_OBJECT FileObject; + PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp); + + FileObject = Stack->FileObject; + Irp->IoStatus.Information = 0; + + /* FIXME: HACK, it means that CD has changed */ + if (!FileObject) + { + DPRINT1("FIXME: CdfsDeviceControl called without FileObject!\n"); + Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return STATUS_INVALID_DEVICE_REQUEST; + } + + /* Only support such operations on volume */ + if (!(FileObject->RelatedFileObject == NULL || FileObject->RelatedFileObject->FsContext2 != NULL)) + { + Irp->IoStatus.Status = STATUS_INVALID_PARAMETER; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return STATUS_INVALID_PARAMETER; + } + + if (Stack->Parameters.DeviceIoControl.IoControlCode == IOCTL_CDROM_DISK_TYPE) + { + /* We should handle this one, but we don't! */ + Status = STATUS_NOT_IMPLEMENTED; + Irp->IoStatus.Status = Status; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + } + else + { + /* Pass it to storage driver */ + IoSkipCurrentIrpStackLocation(Irp); + Vcb = (PVCB)Stack->DeviceObject->DeviceExtension; + Status = IoCallDriver(Vcb->StorageDevice, Irp); + } + + return Status; +} diff --git a/reactos/drivers/filesystems/cdfs/dirctl.c b/reactos/drivers/filesystems/cdfs/dirctl.c index 12399883234..0160c922321 100644 --- a/reactos/drivers/filesystems/cdfs/dirctl.c +++ b/reactos/drivers/filesystems/cdfs/dirctl.c @@ -376,13 +376,15 @@ CdfsGetNameInformation(PFCB Fcb, DPRINT("CdfsGetNameInformation() called\n"); Length = wcslen(Fcb->ObjectName) * sizeof(WCHAR); - if ((sizeof (FILE_BOTH_DIR_INFORMATION) + Length) > BufferLength) + if ((sizeof(FILE_NAMES_INFORMATION) + Length) > BufferLength) return(STATUS_BUFFER_OVERFLOW); Info->FileNameLength = Length; Info->NextEntryOffset = - ROUND_UP(sizeof(FILE_BOTH_DIR_INFORMATION) + Length, 4); - memcpy(Info->FileName, Fcb->ObjectName, Length); + ROUND_UP(sizeof(FILE_NAMES_INFORMATION) + Length, sizeof(ULONG)); + RtlCopyMemory(Info->FileName, Fcb->ObjectName, Length); + + // Info->FileIndex=; return(STATUS_SUCCESS); } @@ -399,31 +401,27 @@ CdfsGetDirectoryInformation(PFCB Fcb, DPRINT("CdfsGetDirectoryInformation() called\n"); Length = wcslen(Fcb->ObjectName) * sizeof(WCHAR); - if ((sizeof (FILE_BOTH_DIR_INFORMATION) + Length) > BufferLength) + if ((sizeof (FILE_DIRECTORY_INFORMATION) + Length) > BufferLength) return(STATUS_BUFFER_OVERFLOW); Info->FileNameLength = Length; Info->NextEntryOffset = - ROUND_UP(sizeof(FILE_BOTH_DIR_INFORMATION) + Length, 4); - memcpy(Info->FileName, Fcb->ObjectName, Length); + ROUND_UP(sizeof(FILE_DIRECTORY_INFORMATION) + Length, sizeof(ULONG)); + RtlCopyMemory(Info->FileName, Fcb->ObjectName, Length); /* Convert file times */ CdfsDateTimeToSystemTime(Fcb, &Info->CreationTime); - CdfsDateTimeToSystemTime(Fcb, - &Info->LastAccessTime); - CdfsDateTimeToSystemTime(Fcb, - &Info->LastWriteTime); - CdfsDateTimeToSystemTime(Fcb, - &Info->ChangeTime); + Info->LastWriteTime = Info->CreationTime; + Info->ChangeTime = Info->CreationTime; /* Convert file flags */ CdfsFileFlagsToAttributes(Fcb, &Info->FileAttributes); if (CdfsFCBIsDirectory(Fcb)) { - Info->EndOfFile.QuadPart = 0LL; - Info->AllocationSize.QuadPart = 0LL; + Info->EndOfFile.QuadPart = 0; + Info->AllocationSize.QuadPart = 0; } else { @@ -450,23 +448,19 @@ CdfsGetFullDirectoryInformation(PFCB Fcb, DPRINT("CdfsGetFullDirectoryInformation() called\n"); Length = wcslen(Fcb->ObjectName) * sizeof(WCHAR); - if ((sizeof (FILE_BOTH_DIR_INFORMATION) + Length) > BufferLength) + if ((sizeof (FILE_FULL_DIR_INFORMATION) + Length) > BufferLength) return(STATUS_BUFFER_OVERFLOW); Info->FileNameLength = Length; Info->NextEntryOffset = - ROUND_UP(sizeof(FILE_BOTH_DIR_INFORMATION) + Length, 4); - memcpy(Info->FileName, Fcb->ObjectName, Length); + ROUND_UP(sizeof(FILE_FULL_DIR_INFORMATION) + Length, sizeof(ULONG)); + RtlCopyMemory(Info->FileName, Fcb->ObjectName, Length); /* Convert file times */ CdfsDateTimeToSystemTime(Fcb, &Info->CreationTime); - CdfsDateTimeToSystemTime(Fcb, - &Info->LastAccessTime); - CdfsDateTimeToSystemTime(Fcb, - &Info->LastWriteTime); - CdfsDateTimeToSystemTime(Fcb, - &Info->ChangeTime); + Info->LastWriteTime = Info->CreationTime; + Info->ChangeTime = Info->CreationTime; /* Convert file flags */ CdfsFileFlagsToAttributes(Fcb, @@ -474,8 +468,8 @@ CdfsGetFullDirectoryInformation(PFCB Fcb, if (CdfsFCBIsDirectory(Fcb)) { - Info->EndOfFile.QuadPart = 0LL; - Info->AllocationSize.QuadPart = 0LL; + Info->EndOfFile.QuadPart = 0; + Info->AllocationSize.QuadPart = 0; } else { @@ -508,18 +502,14 @@ CdfsGetBothDirectoryInformation(PFCB Fcb, Info->FileNameLength = Length; Info->NextEntryOffset = - ROUND_UP(sizeof(FILE_BOTH_DIR_INFORMATION) + Length, 4); - memcpy(Info->FileName, Fcb->ObjectName, Length); + ROUND_UP(sizeof(FILE_BOTH_DIR_INFORMATION) + Length, sizeof(ULONG)); + RtlCopyMemory(Info->FileName, Fcb->ObjectName, Length); /* Convert file times */ CdfsDateTimeToSystemTime(Fcb, &Info->CreationTime); - CdfsDateTimeToSystemTime(Fcb, - &Info->LastAccessTime); - CdfsDateTimeToSystemTime(Fcb, - &Info->LastWriteTime); - CdfsDateTimeToSystemTime(Fcb, - &Info->ChangeTime); + Info->LastWriteTime = Info->CreationTime; + Info->ChangeTime = Info->CreationTime; /* Convert file flags */ CdfsFileFlagsToAttributes(Fcb, @@ -527,8 +517,8 @@ CdfsGetBothDirectoryInformation(PFCB Fcb, if (CdfsFCBIsDirectory(Fcb)) { - Info->EndOfFile.QuadPart = 0LL; - Info->AllocationSize.QuadPart = 0LL; + Info->EndOfFile.QuadPart = 0; + Info->AllocationSize.QuadPart = 0; } else { @@ -542,8 +532,9 @@ CdfsGetBothDirectoryInformation(PFCB Fcb, Info->EaSize = 0; /* Copy short name */ + ASSERT(Fcb->ShortNameU.Length / sizeof(WCHAR) <= 12); Info->ShortNameLength = Fcb->ShortNameU.Length; - memcpy(Info->ShortName, Fcb->ShortNameU.Buffer, Fcb->ShortNameU.Length); + RtlCopyMemory(Info->ShortName, Fcb->ShortNameU.Buffer, Fcb->ShortNameU.Length); return(STATUS_SUCCESS); } @@ -584,6 +575,15 @@ CdfsQueryDirectory(PDEVICE_OBJECT DeviceObject, Stack->Parameters.QueryDirectory.FileInformationClass; FileIndex = Stack->Parameters.QueryDirectory.FileIndex; + /* Determine Buffer for result */ + if (Irp->MdlAddress) + { + Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress); + } + else + { + Buffer = Irp->UserBuffer; + } if (SearchPattern != NULL) { @@ -596,13 +596,8 @@ CdfsQueryDirectory(PDEVICE_OBJECT DeviceObject, { return STATUS_INSUFFICIENT_RESOURCES; } - - Ccb->DirectorySearchPattern.Length = SearchPattern->Length; Ccb->DirectorySearchPattern.MaximumLength = SearchPattern->Length + sizeof(WCHAR); - - memcpy(Ccb->DirectorySearchPattern.Buffer, - SearchPattern->Buffer, - SearchPattern->Length); + RtlCopyUnicodeString(&Ccb->DirectorySearchPattern, SearchPattern); Ccb->DirectorySearchPattern.Buffer[SearchPattern->Length / sizeof(WCHAR)] = 0; } } @@ -625,24 +620,14 @@ CdfsQueryDirectory(PDEVICE_OBJECT DeviceObject, /* Determine directory index */ if (Stack->Flags & SL_INDEX_SPECIFIED) { - Ccb->Entry = Ccb->CurrentByteOffset.u.LowPart; - Ccb->Offset = 0; + Ccb->Entry = Stack->Parameters.QueryDirectory.FileIndex; + Ccb->Offset = Ccb->CurrentByteOffset.u.LowPart; } else if (First || (Stack->Flags & SL_RESTART_SCAN)) { Ccb->Entry = 0; Ccb->Offset = 0; } - - /* Determine Buffer for result */ - if (Irp->MdlAddress) - { - Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress); - } - else - { - Buffer = Irp->UserBuffer; - } DPRINT("Buffer = %p tofind = %wZ\n", Buffer, &Ccb->DirectorySearchPattern); TempFcb.ObjectName = TempFcb.PathName; diff --git a/reactos/drivers/filesystems/cdfs/fcb.c b/reactos/drivers/filesystems/cdfs/fcb.c index a7dd385aa46..12bee1dd753 100644 --- a/reactos/drivers/filesystems/cdfs/fcb.c +++ b/reactos/drivers/filesystems/cdfs/fcb.c @@ -233,7 +233,6 @@ CdfsFCBInitializeCache(PVCB Vcb, PFCB Fcb) { PFILE_OBJECT FileObject; - NTSTATUS Status; PCCB newCCB; FileObject = IoCreateStreamFileObject(NULL, Vcb->StorageDevice); @@ -241,7 +240,7 @@ CdfsFCBInitializeCache(PVCB Vcb, newCCB = ExAllocatePoolWithTag(NonPagedPool, sizeof(CCB), TAG_CCB); if (newCCB == NULL) { - return(STATUS_INSUFFICIENT_RESOURCES); + return STATUS_INSUFFICIENT_RESOURCES; } RtlZeroMemory(newCCB, sizeof(CCB)); @@ -256,7 +255,6 @@ CdfsFCBInitializeCache(PVCB Vcb, Fcb->FileObject = FileObject; Fcb->DevExt = Vcb; - Status = STATUS_SUCCESS; CcInitializeCacheMap(FileObject, (PCC_FILE_SIZES)(&Fcb->RFCB.AllocationSize), FALSE, @@ -266,7 +264,7 @@ CdfsFCBInitializeCache(PVCB Vcb, ObDereferenceObject(FileObject); Fcb->Flags |= FCB_CACHE_INITIALIZED; - return(Status); + return STATUS_SUCCESS; } @@ -434,6 +432,9 @@ CdfsAttachFCBToFileObject(PDEVICE_EXTENSION Vcb, } memset(newCCB, 0, sizeof(CCB)); + FileObject->ReadAccess = TRUE; + FileObject->WriteAccess = FALSE; + FileObject->DeleteAccess = FALSE; FileObject->SectionObjectPointer = &Fcb->SectionObjectPointers; FileObject->FsContext = Fcb; FileObject->FsContext2 = newCCB; diff --git a/reactos/drivers/filesystems/fastfat/create.c b/reactos/drivers/filesystems/fastfat/create.c index f643104c947..514084ee3f1 100644 --- a/reactos/drivers/filesystems/fastfat/create.c +++ b/reactos/drivers/filesystems/fastfat/create.c @@ -125,7 +125,7 @@ ReadVolumeLabel (PDEVICE_EXTENSION DeviceExt, PVPB Vpb) ExReleaseResourceLite (&DeviceExt->DirResource); FileOffset.QuadPart = 0; - if (CcMapData(pFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, &Context, (PVOID*)&Entry)) + if (CcMapData(pFcb->FileObject, &FileOffset, SizeDirEntry, TRUE, &Context, (PVOID*)&Entry)) { while (TRUE) { @@ -155,7 +155,7 @@ ReadVolumeLabel (PDEVICE_EXTENSION DeviceExt, PVPB Vpb) { CcUnpinData(Context); FileOffset.u.LowPart += PAGE_SIZE; - if (!CcMapData(pFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, &Context, (PVOID*)&Entry)) + if (!CcMapData(pFcb->FileObject, &FileOffset, SizeDirEntry, TRUE, &Context, (PVOID*)&Entry)) { Context = NULL; break; diff --git a/reactos/drivers/filesystems/fastfat/direntry.c b/reactos/drivers/filesystems/fastfat/direntry.c index 1a1577c452d..060102973c6 100644 --- a/reactos/drivers/filesystems/fastfat/direntry.c +++ b/reactos/drivers/filesystems/fastfat/direntry.c @@ -66,7 +66,7 @@ FATIsDirectoryEmpty(PVFATFCB Fcb) CcUnpinData(Context); } - if (!CcMapData(Fcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, &Context, (PVOID*)&FatDirEntry)) + if (!CcMapData(Fcb->FileObject, &FileOffset, sizeof(FAT_DIR_ENTRY), TRUE, &Context, (PVOID*)&FatDirEntry)) { return TRUE; } @@ -120,7 +120,7 @@ FATXIsDirectoryEmpty(PVFATFCB Fcb) CcUnpinData(Context); } - if (!CcMapData(Fcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, &Context, (PVOID*)&FatXDirEntry)) + if (!CcMapData(Fcb->FileObject, &FileOffset, sizeof(FATX_DIR_ENTRY), TRUE, &Context, (PVOID*)&FatXDirEntry)) { return TRUE; } diff --git a/reactos/drivers/filesystems/fastfat/dirwr.c b/reactos/drivers/filesystems/fastfat/dirwr.c index a1da379004b..0e948addc67 100644 --- a/reactos/drivers/filesystems/fastfat/dirwr.c +++ b/reactos/drivers/filesystems/fastfat/dirwr.c @@ -638,7 +638,7 @@ FATDelEntry( CcUnpinData(Context); } Offset.u.LowPart = (i * sizeof(FAT_DIR_ENTRY) / PAGE_SIZE) * PAGE_SIZE; - CcPinRead(pFcb->parentFcb->FileObject, &Offset, PAGE_SIZE, TRUE, + CcPinRead(pFcb->parentFcb->FileObject, &Offset, sizeof(FAT_DIR_ENTRY), TRUE, &Context, (PVOID*)&pDirEntry); } pDirEntry[i % (PAGE_SIZE / sizeof(FAT_DIR_ENTRY))].Filename[0] = 0xe5; @@ -689,7 +689,7 @@ FATXDelEntry( DPRINT("delete entry: %d\n", StartIndex); Offset.u.HighPart = 0; Offset.u.LowPart = (StartIndex * sizeof(FATX_DIR_ENTRY) / PAGE_SIZE) * PAGE_SIZE; - if (!CcPinRead(pFcb->parentFcb->FileObject, &Offset, PAGE_SIZE, TRUE, + if (!CcPinRead(pFcb->parentFcb->FileObject, &Offset, sizeof(FATX_DIR_ENTRY), TRUE, &Context, (PVOID*)&pDirEntry)) { DPRINT1("CcPinRead(Offset %x:%x, Length %d) failed\n", Offset.u.HighPart, Offset.u.LowPart, PAGE_SIZE); diff --git a/reactos/drivers/filesystems/fastfat/fcb.c b/reactos/drivers/filesystems/fastfat/fcb.c index 1bfc51cec39..bfdeb18605b 100644 --- a/reactos/drivers/filesystems/fastfat/fcb.c +++ b/reactos/drivers/filesystems/fastfat/fcb.c @@ -474,7 +474,7 @@ vfatMakeFCBFromDirEntry( if (vfatFCBIsDirectory(rcFCB)) { ULONG FirstCluster, CurrentCluster; - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; Size = 0; FirstCluster = vfatDirEntryGetFirstCluster (vcb, &rcFCB->entry); if (FirstCluster == 1) @@ -484,7 +484,7 @@ vfatMakeFCBFromDirEntry( else if (FirstCluster != 0) { CurrentCluster = FirstCluster; - while (CurrentCluster != 0xffffffff) + while (CurrentCluster != 0xffffffff && NT_SUCCESS(Status)) { Size += vcb->FatInfo.BytesPerCluster; Status = NextCluster (vcb, FirstCluster, &CurrentCluster, FALSE); diff --git a/reactos/drivers/filesystems/fastfat/volume.c b/reactos/drivers/filesystems/fastfat/volume.c index d91e44fa99c..4a014b37882 100644 --- a/reactos/drivers/filesystems/fastfat/volume.c +++ b/reactos/drivers/filesystems/fastfat/volume.c @@ -229,7 +229,7 @@ FsdSetFsLabelInformation(PDEVICE_OBJECT DeviceObject, /* Search existing volume entry on disk */ FileOffset.QuadPart = 0; - if (CcPinRead(pRootFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, &Context, (PVOID*)&Entry)) + if (CcPinRead(pRootFcb->FileObject, &FileOffset, SizeDirEntry, TRUE, &Context, (PVOID*)&Entry)) { while (TRUE) { @@ -250,13 +250,13 @@ FsdSetFsLabelInformation(PDEVICE_OBJECT DeviceObject, Entry = (PDIR_ENTRY)((ULONG_PTR)Entry + SizeDirEntry); if ((DirIndex % EntriesPerPage) == 0) { - CcUnpinData(Context); - FileOffset.u.LowPart += PAGE_SIZE; - if (!CcPinRead(pRootFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, &Context, (PVOID*)&Entry)) - { - Context = NULL; - break; - } + CcUnpinData(Context); + FileOffset.u.LowPart += PAGE_SIZE; + if (!CcPinRead(pRootFcb->FileObject, &FileOffset, SizeDirEntry, TRUE, &Context, (PVOID*)&Entry)) + { + Context = NULL; + break; + } } } if (Context) diff --git a/reactos/ntoskrnl/include/internal/io.h b/reactos/ntoskrnl/include/internal/io.h index bec9be6d1b4..5f2998debdf 100644 --- a/reactos/ntoskrnl/include/internal/io.h +++ b/reactos/ntoskrnl/include/internal/io.h @@ -1073,7 +1073,7 @@ IopParseDevice( IN ULONG Attributes, IN OUT PUNICODE_STRING CompleteName, IN OUT PUNICODE_STRING RemainingName, - IN OUT PVOID Context OPTIONAL, + IN OUT PVOID Context, IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL, OUT PVOID *Object ); diff --git a/reactos/ntoskrnl/io/iomgr/file.c b/reactos/ntoskrnl/io/iomgr/file.c index b6a63d9af66..46060f470b2 100644 --- a/reactos/ntoskrnl/io/iomgr/file.c +++ b/reactos/ntoskrnl/io/iomgr/file.c @@ -171,7 +171,7 @@ IopParseDevice(IN PVOID ParseObject, IN ULONG Attributes, IN OUT PUNICODE_STRING CompleteName, IN OUT PUNICODE_STRING RemainingName, - IN OUT PVOID Context OPTIONAL, + IN OUT PVOID Context, IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL, OUT PVOID *Object) {