Skip to content
This repository has been archived by the owner on Jul 26, 2023. It is now read-only.

Add SetupDiGetDriverInfoDetail #481

Merged
merged 2 commits into from
Jul 3, 2020
Merged

Add SetupDiGetDriverInfoDetail #481

merged 2 commits into from
Jul 3, 2020

Conversation

qmfrederik
Copy link
Contributor

No description provided.

@qmfrederik
Copy link
Contributor Author

@AArnott The SP_DRVINFO_DETAIL_DATA struct is a bit of a mystery to me. The code in this PR makes the tests pass on 32-bit and 64-bit Windows; but I'm not quite sure why the magic which is being done works/is required.

As a sidenote, I think the unit tests in this repo only run in a 32-bit process, correct?

@AArnott
Copy link
Collaborator

AArnott commented Jul 3, 2020

I think the unit tests in this repo only run in a 32-bit process, correct?

Yes, but I should fix this: #486

src/SetupApi.Tests/SetupApiFacts.cs Outdated Show resolved Hide resolved
src/SetupApi/SetupApi+SP_DRVINFO_DETAIL_DATA.cs Outdated Show resolved Hide resolved
src/SetupApi/SetupApi+SP_DRVINFO_DETAIL_DATA.cs Outdated Show resolved Hide resolved
src/SetupApi/SetupApi+SP_DRVINFO_DETAIL_DATA.cs Outdated Show resolved Hide resolved
src/SetupApi/SetupApi+SP_DRVINFO_DETAIL_DATA.cs Outdated Show resolved Hide resolved
src/SetupApi/SetupApi.csproj Outdated Show resolved Hide resolved
@qmfrederik
Copy link
Contributor Author

For the sake of completeness, here's the source code for that test program, and the output when ran as a 32-bit or 64-bit program:

#include <iostream>
#include <Windows.h>
#include "setupapi.h"

int main()
{
    printf("Bitness:                                 0x%p\n", sizeof(void*));
    printf("\n");
    printf("SP_DRVINFO_DETAIL_DATA size:             0x%p\n", sizeof(SP_DRVINFO_DETAIL_DATA));
    printf("\n");
    printf("SP_DRVINFO_DETAIL_DATA.cbSize          @ 0x%p\n", offsetof(SP_DRVINFO_DETAIL_DATA, cbSize));
    printf("SP_DRVINFO_DETAIL_DATA.InfDate         @ 0x%p\n", offsetof(SP_DRVINFO_DETAIL_DATA, InfDate));
    printf("SP_DRVINFO_DETAIL_DATA.CompatIDsOffset @ 0x%p\n", offsetof(SP_DRVINFO_DETAIL_DATA, CompatIDsOffset));
    printf("SP_DRVINFO_DETAIL_DATA.CompatIDsLength @ 0x%p\n", offsetof(SP_DRVINFO_DETAIL_DATA, CompatIDsLength));
    printf("SP_DRVINFO_DETAIL_DATA.Reserved        @ 0x%p\n", offsetof(SP_DRVINFO_DETAIL_DATA, Reserved));
    printf("SP_DRVINFO_DETAIL_DATA.SectionName     @ 0x%p\n", offsetof(SP_DRVINFO_DETAIL_DATA, SectionName));
    printf("SP_DRVINFO_DETAIL_DATA.InfFileName     @ 0x%p\n", offsetof(SP_DRVINFO_DETAIL_DATA, InfFileName));
    printf("SP_DRVINFO_DETAIL_DATA.DrvDescription  @ 0x%p\n", offsetof(SP_DRVINFO_DETAIL_DATA, DrvDescription));
    printf("SP_DRVINFO_DETAIL_DATA.HardwareID      @ 0x%p\n", offsetof(SP_DRVINFO_DETAIL_DATA, HardwareID));
}
Bitness:                                 0x00000004

SP_DRVINFO_DETAIL_DATA size:             0x00000622

SP_DRVINFO_DETAIL_DATA.cbSize          @ 0x00000000
SP_DRVINFO_DETAIL_DATA.InfDate         @ 0x00000004
SP_DRVINFO_DETAIL_DATA.CompatIDsOffset @ 0x0000000C
SP_DRVINFO_DETAIL_DATA.CompatIDsLength @ 0x00000010
SP_DRVINFO_DETAIL_DATA.Reserved        @ 0x00000014
SP_DRVINFO_DETAIL_DATA.SectionName     @ 0x00000018
SP_DRVINFO_DETAIL_DATA.InfFileName     @ 0x00000218
SP_DRVINFO_DETAIL_DATA.DrvDescription  @ 0x00000420
SP_DRVINFO_DETAIL_DATA.HardwareID      @ 0x00000620
Bitness:                                 0x0000000000000008

SP_DRVINFO_DETAIL_DATA size:             0x0000000000000630

SP_DRVINFO_DETAIL_DATA.cbSize          @ 0x0000000000000000
SP_DRVINFO_DETAIL_DATA.InfDate         @ 0x0000000000000004
SP_DRVINFO_DETAIL_DATA.CompatIDsOffset @ 0x000000000000000C
SP_DRVINFO_DETAIL_DATA.CompatIDsLength @ 0x0000000000000010
SP_DRVINFO_DETAIL_DATA.Reserved        @ 0x0000000000000018
SP_DRVINFO_DETAIL_DATA.SectionName     @ 0x0000000000000020
SP_DRVINFO_DETAIL_DATA.InfFileName     @ 0x0000000000000220
SP_DRVINFO_DETAIL_DATA.DrvDescription  @ 0x0000000000000428
SP_DRVINFO_DETAIL_DATA.HardwareID      @ 0x0000000000000628

It doesn't answer the why but serves as a confirmation that the values in that unit test are correct.

@AArnott AArnott merged commit 050b351 into dotnet:master Jul 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants