Skip to content

Commit 18f9a03

Browse files
[PCIX] Fix a few easy bugs (reactos#8443)
* [PCIX] Fix the weird text corruption in PciGetDescriptionMessage * [PCIX] Return the buffer to the caller PciQueryBusInformation Co-authored-by: Stanislav Motylkov <[email protected]>
1 parent 3fe5b8b commit 18f9a03

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

drivers/bus/pcix/pci.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ NTSTATUS
11641164
NTAPI
11651165
PciQueryBusInformation(
11661166
IN PPCI_PDO_EXTENSION PdoExtension,
1167-
IN PPNP_BUS_INFORMATION* Buffer
1167+
OUT PPNP_BUS_INFORMATION* Buffer
11681168
);
11691169

11701170
NTSTATUS

drivers/bus/pcix/pci/id.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,20 @@ PciGetDescriptionMessage(IN ULONG Identifier,
4848
/* Grab the text */
4949
Description = (PWCHAR)Entry->Text;
5050

51-
/* Validate valid message length, ending with a newline character */
52-
ASSERT(TextLength > 1);
53-
ASSERT(Description[TextLength / sizeof(WCHAR)] == L'\n');
51+
/* Validate the message length, ending with a newline character */
52+
ASSERT(TextLength > sizeof(WCHAR));
53+
ASSERT(Description[(TextLength / sizeof(WCHAR)) - 1] == L'\n');
5454

5555
/* Allocate the buffer to hold the message string */
5656
Buffer = ExAllocatePoolWithTag(PagedPool, TextLength, 'BicP');
5757
if (!Buffer) return NULL;
5858

5959
/* Copy the message, minus the newline character, and terminate it */
60-
RtlCopyMemory(Buffer, Entry->Text, TextLength - 1);
61-
Buffer[TextLength / sizeof(WCHAR)] = UNICODE_NULL;
60+
RtlCopyMemory(Buffer, Description, TextLength - sizeof(WCHAR));
61+
Buffer[(TextLength / sizeof(WCHAR)) - 1] = UNICODE_NULL;
6262

6363
/* Return the length to the caller, minus the terminating NULL */
64-
if (Length) *Length = TextLength - 1;
64+
if (Length) *Length = TextLength - sizeof(WCHAR);
6565
}
6666
else
6767
{

drivers/bus/pcix/utils.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,12 +1314,10 @@ PciDecodeEnable(IN PPCI_PDO_EXTENSION PdoExtension,
13141314
NTSTATUS
13151315
NTAPI
13161316
PciQueryBusInformation(IN PPCI_PDO_EXTENSION PdoExtension,
1317-
IN PPNP_BUS_INFORMATION* Buffer)
1317+
OUT PPNP_BUS_INFORMATION* Buffer)
13181318
{
13191319
PPNP_BUS_INFORMATION BusInfo;
13201320

1321-
UNREFERENCED_PARAMETER(Buffer);
1322-
13231321
/* Allocate a structure for the bus information */
13241322
BusInfo = ExAllocatePoolWithTag(PagedPool,
13251323
sizeof(PNP_BUS_INFORMATION),
@@ -1330,6 +1328,9 @@ PciQueryBusInformation(IN PPCI_PDO_EXTENSION PdoExtension,
13301328
BusInfo->BusTypeGuid = GUID_BUS_TYPE_PCI;
13311329
BusInfo->LegacyBusType = PCIBus;
13321330
BusInfo->BusNumber = PdoExtension->ParentFdoExtension->BaseBus;
1331+
1332+
*Buffer = BusInfo;
1333+
13331334
return STATUS_SUCCESS;
13341335
}
13351336

0 commit comments

Comments
 (0)