Discussion:
[PATCH] Ensure DifRemove coinst routine runs on uninstall.
Troy Crosley
2021-04-02 20:34:35 UTC
Permalink
The console monitor service will persist if DifRemove does not run.

In Windows 10 version 2004, The coinstallers' DIF_INSTALLDEVICE routines
do not get called on driver uninstall. In previous versions of Windows,
this occurs as part of the uninstall during the null device install and
is the only time DifRemove gets called to perform cleanup. Work around
this change by calling DifRemove from DIF_SELECTBESTCOMPATDRV, which is
the only coinstaller request that seems to happen on uninstall in
Windows 10 version 2004. In addition, improve the null driver test to
also check if DriverInfoData.DriverType is equal to SPDIT_CLASSDRIVER or
SPDIT_COMPATDRIVER, which is necessary as of some Windows version (at
least Windows 10 version 1803).

Signed-off-by: Joel Upham <***@ainfosec.com>
Signed-off-by: Troy Crosley <***@gmail.com>
---
src/coinst/coinst.c | 49 +++++++++++++++++++++++++++++++--------------
1 file changed, 34 insertions(+), 15 deletions(-)

diff --git a/src/coinst/coinst.c b/src/coinst/coinst.c
index 4d2953d..ac3847c 100644
--- a/src/coinst/coinst.c
+++ b/src/coinst/coinst.c
@@ -440,6 +440,9 @@ Entry(
)
{
HRESULT Error;
+ SP_DRVINFO_DATA DriverInfoData;
+ BOOLEAN DriverInfoAvailable;
+ BOOLEAN IsNullDriver;

Log("%s (%s) ===>",
MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
@@ -454,23 +457,39 @@ Entry(
Context->InstallResult);
}

+ DriverInfoData.cbSize = sizeof(DriverInfoData);
+ DriverInfoAvailable = SetupDiGetSelectedDriver(DeviceInfoSet,
+ DeviceInfoData,
+ &DriverInfoData) ?
+ TRUE :
+ FALSE;
+ IsNullDriver = !(DriverInfoAvailable &&
+ (DriverInfoData.DriverType == SPDIT_CLASSDRIVER ||
+ DriverInfoData.DriverType == SPDIT_COMPATDRIVER));
+
switch (Function) {
+ case DIF_SELECTBESTCOMPATDRV: {
+ //
+ // If the NULL driver will be installed, treat this as we would a
+ // DIF_REMOVE to work around the fact that Windows 10 2004 doesn't
+ // call DIF_INSTALLDEVICE on uninstall.
+ // An InstallResult value of ERROR_NO_COMPAT_DRIVERS simply means
+ // that the NULL driver was selected, and so should not be treated
+ // as an error.
+ //
+ if (Context->PostProcessing &&
+ Context->InstallResult == ERROR_NO_COMPAT_DRIVERS)
+ Context->InstallResult = NO_ERROR;
+
+ Error = (IsNullDriver) ?
+ DifRemove(DeviceInfoSet, DeviceInfoData, Context) :
+ NO_ERROR;
+ break;
+ }
case DIF_INSTALLDEVICE: {
- SP_DRVINFO_DATA DriverInfoData;
- BOOLEAN DriverInfoAvailable;
-
- DriverInfoData.cbSize = sizeof (DriverInfoData);
- DriverInfoAvailable = SetupDiGetSelectedDriver(DeviceInfoSet,
- DeviceInfoData,
- &DriverInfoData) ?
- TRUE :
- FALSE;
-
- // If there is no driver information then the NULL driver is being
- // installed. Treat this as we would a DIF_REMOVE.
- Error = (DriverInfoAvailable) ?
- DifInstall(DeviceInfoSet, DeviceInfoData, Context) :
- DifRemove(DeviceInfoSet, DeviceInfoData, Context);
+ Error = (IsNullDriver) ?
+ NO_ERROR :
+ DifInstall(DeviceInfoSet, DeviceInfoData, Context);
break;
}
case DIF_REMOVE:
--
2.25.1
Troy Crosley
2021-04-02 20:37:43 UTC
Permalink
In Windows 10 version 2004, The coinstallers' DIF_INSTALLDEVICE routines
do not get called on driver uninstall. In previous versions of Windows,
this occurs as part of the uninstall during the null device install and
is the only time DifRemove gets called to perform cleanup. Work around
this change by calling DifRemove from DIF_SELECTBESTCOMPATDRV, which is
the only coinstaller request that seems to happen on uninstall in
Windows 10 version 2004. In addition, improve the null driver test to
also check if DriverInfoData.DriverType is equal to SPDIT_CLASSDRIVER or
SPDIT_COMPATDRIVER, which is necessary as of some Windows version (at
least Windows 10 version 1803).

Signed-off-by: Joel Upham <***@ainfosec.com>
Signed-off-by: Troy Crosley <***@gmail.com>
---
src/coinst/coinst.c | 57 +++++++++++++++++++++++++++------------------
1 file changed, 34 insertions(+), 23 deletions(-)

diff --git a/src/coinst/coinst.c b/src/coinst/coinst.c
index aec1ae9..866ae40 100644
--- a/src/coinst/coinst.c
+++ b/src/coinst/coinst.c
@@ -469,6 +469,9 @@ Entry(
)
{
HRESULT Error;
+ SP_DRVINFO_DATA DriverInfoData;
+ BOOLEAN DriverInfoAvailable;
+ BOOLEAN IsNullDriver;

Log("%s (%s) ===>",
MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
@@ -483,31 +486,39 @@ Entry(
Context->InstallResult);
}

+ DriverInfoData.cbSize = sizeof(DriverInfoData);
+ DriverInfoAvailable = SetupDiGetSelectedDriver(DeviceInfoSet,
+ DeviceInfoData,
+ &DriverInfoData) ?
+ TRUE :
+ FALSE;
+ IsNullDriver = !(DriverInfoAvailable &&
+ (DriverInfoData.DriverType == SPDIT_CLASSDRIVER ||
+ DriverInfoData.DriverType == SPDIT_COMPATDRIVER));
+
switch (Function) {
+ case DIF_SELECTBESTCOMPATDRV: {
+ //
+ // If the NULL driver will be installed, treat this as we would a
+ // DIF_REMOVE to work around the fact that Windows 10 2004 doesn't
+ // call DIF_INSTALLDEVICE on uninstall.
+ // An InstallResult value of ERROR_NO_COMPAT_DRIVERS simply means
+ // that the NULL driver was selected, and so should not be treated
+ // as an error.
+ //
+ if (Context->PostProcessing &&
+ Context->InstallResult == ERROR_NO_COMPAT_DRIVERS)
+ Context->InstallResult = NO_ERROR;
+
+ Error = (IsNullDriver) ?
+ DifRemove(DeviceInfoSet, DeviceInfoData, Context) :
+ NO_ERROR;
+ break;
+ }
case DIF_INSTALLDEVICE: {
- SP_DRVINFO_DATA DriverInfoData;
- BOOLEAN DriverInfoAvailable;
-
- DriverInfoData.cbSize = sizeof (DriverInfoData);
- DriverInfoAvailable = SetupDiGetSelectedDriver(DeviceInfoSet,
- DeviceInfoData,
- &DriverInfoData) ?
- TRUE :
- FALSE;
-
- // The NET class installer will call DIF_REMOVE even in the event of
- // a NULL driver add. However, the default installer (for the NULL
- // driver) then fails for some reason so we squash the error in
- // post-processing.
- if (DriverInfoAvailable) {
- Error = DifInstall(DeviceInfoSet, DeviceInfoData, Context);
- } else {
- if (!Context->PostProcessing) {
- Error = ERROR_DI_POSTPROCESSING_REQUIRED;
- } else {
- Error = NO_ERROR;
- }
- }
+ Error = (IsNullDriver) ?
+ NO_ERROR :
+ DifInstall(DeviceInfoSet, DeviceInfoData, Context);
break;
}
case DIF_REMOVE:
--
2.25.1
Troy Crosley
2021-04-02 20:45:02 UTC
Permalink
The xenagent service will persist if DifRemove does not run.

In Windows 10 version 2004, The coinstallers' DIF_INSTALLDEVICE routines
do not get called on driver uninstall. In previous versions of Windows,
this occurs as part of the uninstall during the null device install and
is the only time DifRemove gets called to perform cleanup. Work around
this change by calling DifRemove from DIF_SELECTBESTCOMPATDRV, which is
the only coinstaller request that seems to happen on uninstall in
Windows 10 version 2004. In addition, improve the null driver test to
also check if DriverInfoData.DriverType is equal to SPDIT_CLASSDRIVER or
SPDIT_COMPATDRIVER, which is necessary as of some Windows version (at
least Windows 10 version 1803).

Signed-off-by: Joel Upham <***@ainfosec.com>
Signed-off-by: Troy Crosley <***@gmail.com>
---
src/coinst/coinst.c | 49 +++++++++++++++++++++++++++++++--------------
1 file changed, 34 insertions(+), 15 deletions(-)

diff --git a/src/coinst/coinst.c b/src/coinst/coinst.c
index a4c883a..6ed39da 100644
--- a/src/coinst/coinst.c
+++ b/src/coinst/coinst.c
@@ -606,6 +606,9 @@ Entry(
)
{
HRESULT Error;
+ SP_DRVINFO_DATA DriverInfoData;
+ BOOLEAN DriverInfoAvailable;
+ BOOLEAN IsNullDriver;

Log("%s (%s) ===>",
MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
@@ -620,23 +623,39 @@ Entry(
Context->InstallResult);
}

+ DriverInfoData.cbSize = sizeof(DriverInfoData);
+ DriverInfoAvailable = SetupDiGetSelectedDriver(DeviceInfoSet,
+ DeviceInfoData,
+ &DriverInfoData) ?
+ TRUE :
+ FALSE;
+ IsNullDriver = !(DriverInfoAvailable &&
+ (DriverInfoData.DriverType == SPDIT_CLASSDRIVER ||
+ DriverInfoData.DriverType == SPDIT_COMPATDRIVER));
+
switch (Function) {
+ case DIF_SELECTBESTCOMPATDRV: {
+ //
+ // If the NULL driver will be installed, treat this as we would a
+ // DIF_REMOVE to work around the fact that Windows 10 2004 doesn't
+ // call DIF_INSTALLDEVICE on uninstall.
+ // An InstallResult value of ERROR_NO_COMPAT_DRIVERS simply means
+ // that the NULL driver was selected, and so should not be treated
+ // as an error.
+ //
+ if (Context->PostProcessing &&
+ Context->InstallResult == ERROR_NO_COMPAT_DRIVERS)
+ Context->InstallResult = NO_ERROR;
+
+ Error = (IsNullDriver) ?
+ DifRemove(DeviceInfoSet, DeviceInfoData, Context) :
+ NO_ERROR;
+ break;
+ }
case DIF_INSTALLDEVICE: {
- SP_DRVINFO_DATA DriverInfoData;
- BOOLEAN DriverInfoAvailable;
-
- DriverInfoData.cbSize = sizeof (DriverInfoData);
- DriverInfoAvailable = SetupDiGetSelectedDriver(DeviceInfoSet,
- DeviceInfoData,
- &DriverInfoData) ?
- TRUE :
- FALSE;
-
- // If there is no driver information then the NULL driver is being
- // installed. Treat this as we would a DIF_REMOVE.
- Error = (DriverInfoAvailable) ?
- DifInstall(DeviceInfoSet, DeviceInfoData, Context) :
- DifRemove(DeviceInfoSet, DeviceInfoData, Context);
+ Error = (IsNullDriver) ?
+ NO_ERROR :
+ DifInstall(DeviceInfoSet, DeviceInfoData, Context);
break;
}
case DIF_REMOVE:
--
2.25.1
Troy Crosley
2021-04-02 20:46:29 UTC
Permalink
In Windows 10 version 2004, The coinstallers' DIF_INSTALLDEVICE routines
do not get called on driver uninstall. In previous versions of Windows,
this occurs as part of the uninstall during the null device install and
is the only time DifRemove gets called to perform cleanup. Work around
this change by calling DifRemove from DIF_SELECTBESTCOMPATDRV, which is
the only coinstaller request that seems to happen on uninstall in
Windows 10 version 2004. In addition, improve the null driver test to
also check if DriverInfoData.DriverType is equal to SPDIT_CLASSDRIVER or
SPDIT_COMPATDRIVER, which is necessary as of some Windows version (at
least Windows 10 version 1803).

Signed-off-by: Joel Upham <***@ainfosec.com>
Signed-off-by: Troy Crosley <***@gmail.com>
---
src/coinst/coinst.c | 57 +++++++++++++++++++++++++++------------------
1 file changed, 34 insertions(+), 23 deletions(-)

diff --git a/src/coinst/coinst.c b/src/coinst/coinst.c
index 89547cc..950743f 100644
--- a/src/coinst/coinst.c
+++ b/src/coinst/coinst.c
@@ -479,6 +479,9 @@ Entry(
)
{
HRESULT Error;
+ SP_DRVINFO_DATA DriverInfoData;
+ BOOLEAN DriverInfoAvailable;
+ BOOLEAN IsNullDriver;

Log("%s (%s) ===>",
MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
@@ -493,31 +496,39 @@ Entry(
Context->InstallResult);
}

+ DriverInfoData.cbSize = sizeof(DriverInfoData);
+ DriverInfoAvailable = SetupDiGetSelectedDriver(DeviceInfoSet,
+ DeviceInfoData,
+ &DriverInfoData) ?
+ TRUE :
+ FALSE;
+ IsNullDriver = !(DriverInfoAvailable &&
+ (DriverInfoData.DriverType == SPDIT_CLASSDRIVER ||
+ DriverInfoData.DriverType == SPDIT_COMPATDRIVER));
+
switch (Function) {
+ case DIF_SELECTBESTCOMPATDRV: {
+ //
+ // If the NULL driver will be installed, treat this as we would a
+ // DIF_REMOVE to work around the fact that Windows 10 2004 doesn't
+ // call DIF_INSTALLDEVICE on uninstall.
+ // An InstallResult value of ERROR_NO_COMPAT_DRIVERS simply means
+ // that the NULL driver was selected, and so should not be treated
+ // as an error.
+ //
+ if (Context->PostProcessing &&
+ Context->InstallResult == ERROR_NO_COMPAT_DRIVERS)
+ Context->InstallResult = NO_ERROR;
+
+ Error = (IsNullDriver) ?
+ DifRemove(DeviceInfoSet, DeviceInfoData, Context) :
+ NO_ERROR;
+ break;
+ }
case DIF_INSTALLDEVICE: {
- SP_DRVINFO_DATA DriverInfoData;
- BOOLEAN DriverInfoAvailable;
-
- DriverInfoData.cbSize = sizeof (DriverInfoData);
- DriverInfoAvailable = SetupDiGetSelectedDriver(DeviceInfoSet,
- DeviceInfoData,
- &DriverInfoData) ?
- TRUE :
- FALSE;
-
- // The NET class installer will call DIF_REMOVE even in the event of
- // a NULL driver add. However, the default installer (for the NULL
- // driver) then fails for some reason so we squash the error in
- // post-processing.
- if (DriverInfoAvailable) {
- Error = DifInstall(DeviceInfoSet, DeviceInfoData, Context);
- } else {
- if (!Context->PostProcessing) {
- Error = ERROR_DI_POSTPROCESSING_REQUIRED;
- } else {
- Error = NO_ERROR;
- }
- }
+ Error = (IsNullDriver) ?
+ NO_ERROR :
+ DifInstall(DeviceInfoSet, DeviceInfoData, Context);
break;
}
case DIF_REMOVE:
--
2.25.1
Troy Crosley
2021-04-02 20:48:04 UTC
Permalink
The unplug registry entry will persist if DifRemove does not run.

In Windows 10 version 2004, The coinstallers' DIF_INSTALLDEVICE routines
do not get called on driver uninstall. In previous versions of Windows,
this occurs as part of the uninstall during the null device install and
is the only time DifRemove gets called to perform cleanup. Work around
this change by calling DifRemove from DIF_SELECTBESTCOMPATDRV, which is
the only coinstaller request that seems to happen on uninstall in
Windows 10 version 2004. In addition, improve the null driver test to
also check if DriverInfoData.DriverType is equal to SPDIT_CLASSDRIVER or
SPDIT_COMPATDRIVER, which is necessary as of some Windows version (at
least Windows 10 version 1803).

Signed-off-by: Joel Upham <***@ainfosec.com>
Signed-off-by: Troy Crosley <***@gmail.com>
---
src/coinst/coinst.c | 49 +++++++++++++++++++++++++++++++--------------
1 file changed, 34 insertions(+), 15 deletions(-)

diff --git a/src/coinst/coinst.c b/src/coinst/coinst.c
index bc8f605..376a6cc 100644
--- a/src/coinst/coinst.c
+++ b/src/coinst/coinst.c
@@ -801,6 +801,9 @@ Entry(
)
{
HRESULT Error;
+ SP_DRVINFO_DATA DriverInfoData;
+ BOOLEAN DriverInfoAvailable;
+ BOOLEAN IsNullDriver;

Log("%s (%s) ===>",
MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
@@ -815,23 +818,39 @@ Entry(
Context->InstallResult);
}

+ DriverInfoData.cbSize = sizeof(DriverInfoData);
+ DriverInfoAvailable = SetupDiGetSelectedDriver(DeviceInfoSet,
+ DeviceInfoData,
+ &DriverInfoData) ?
+ TRUE :
+ FALSE;
+ IsNullDriver = !(DriverInfoAvailable &&
+ (DriverInfoData.DriverType == SPDIT_CLASSDRIVER ||
+ DriverInfoData.DriverType == SPDIT_COMPATDRIVER));
+
switch (Function) {
+ case DIF_SELECTBESTCOMPATDRV: {
+ //
+ // If the NULL driver will be installed, treat this as we would a
+ // DIF_REMOVE to work around the fact that Windows 10 2004 doesn't
+ // call DIF_INSTALLDEVICE on uninstall.
+ // An InstallResult value of ERROR_NO_COMPAT_DRIVERS simply means
+ // that the NULL driver was selected, and so should not be treated
+ // as an error.
+ //
+ if (Context->PostProcessing &&
+ Context->InstallResult == ERROR_NO_COMPAT_DRIVERS)
+ Context->InstallResult = NO_ERROR;
+
+ Error = (IsNullDriver) ?
+ DifRemove(DeviceInfoSet, DeviceInfoData, Context) :
+ NO_ERROR;
+ break;
+ }
case DIF_INSTALLDEVICE: {
- SP_DRVINFO_DATA DriverInfoData;
- BOOLEAN DriverInfoAvailable;
-
- DriverInfoData.cbSize = sizeof (DriverInfoData);
- DriverInfoAvailable = SetupDiGetSelectedDriver(DeviceInfoSet,
- DeviceInfoData,
- &DriverInfoData) ?
- TRUE :
- FALSE;
-
- // If there is no driver information then the NULL driver is being
- // installed. Treat this as we would a DIF_REMOVE.
- Error = (DriverInfoAvailable) ?
- DifInstall(DeviceInfoSet, DeviceInfoData, Context) :
- DifRemove(DeviceInfoSet, DeviceInfoData, Context);
+ Error = (IsNullDriver) ?
+ NO_ERROR :
+ DifInstall(DeviceInfoSet, DeviceInfoData, Context);
break;
}
case DIF_REMOVE:
--
2.25.1
Troy Crosley
2021-04-02 20:49:10 UTC
Permalink
In Windows 10 version 2004, The coinstallers' DIF_INSTALLDEVICE routines
do not get called on driver uninstall. In previous versions of Windows,
this occurs as part of the uninstall during the null device install and
is the only time DifRemove gets called to perform cleanup. Work around
this change by calling DifRemove from DIF_SELECTBESTCOMPATDRV, which is
the only coinstaller request that seems to happen on uninstall in
Windows 10 version 2004. In addition, improve the null driver test to
also check if DriverInfoData.DriverType is equal to SPDIT_CLASSDRIVER or
SPDIT_COMPATDRIVER, which is necessary as of some Windows version (at
least Windows 10 version 1803).

Signed-off-by: Joel Upham <***@ainfosec.com>
Signed-off-by: Troy Crosley <***@gmail.com>
---
src/coinst/coinst.c | 49 +++++++++++++++++++++++++++++++--------------
1 file changed, 34 insertions(+), 15 deletions(-)

diff --git a/src/coinst/coinst.c b/src/coinst/coinst.c
index e749506..7d72a67 100644
--- a/src/coinst/coinst.c
+++ b/src/coinst/coinst.c
@@ -1248,6 +1248,9 @@ Entry(
)
{
HRESULT Error;
+ SP_DRVINFO_DATA DriverInfoData;
+ BOOLEAN DriverInfoAvailable;
+ BOOLEAN IsNullDriver;

Log("%s (%s) ===>",
MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
@@ -1262,23 +1265,39 @@ Entry(
Context->InstallResult);
}

+ DriverInfoData.cbSize = sizeof(DriverInfoData);
+ DriverInfoAvailable = SetupDiGetSelectedDriver(DeviceInfoSet,
+ DeviceInfoData,
+ &DriverInfoData) ?
+ TRUE :
+ FALSE;
+ IsNullDriver = !(DriverInfoAvailable &&
+ (DriverInfoData.DriverType == SPDIT_CLASSDRIVER ||
+ DriverInfoData.DriverType == SPDIT_COMPATDRIVER));
+
switch (Function) {
+ case DIF_SELECTBESTCOMPATDRV: {
+ //
+ // If the NULL driver will be installed, treat this as we would a
+ // DIF_REMOVE to work around the fact that Windows 10 2004 doesn't
+ // call DIF_INSTALLDEVICE on uninstall.
+ // An InstallResult value of ERROR_NO_COMPAT_DRIVERS simply means
+ // that the NULL driver was selected, and so should not be treated
+ // as an error.
+ //
+ if (Context->PostProcessing &&
+ Context->InstallResult == ERROR_NO_COMPAT_DRIVERS)
+ Context->InstallResult = NO_ERROR;
+
+ Error = (IsNullDriver) ?
+ DifRemove(DeviceInfoSet, DeviceInfoData, Context) :
+ NO_ERROR;
+ break;
+ }
case DIF_INSTALLDEVICE: {
- SP_DRVINFO_DATA DriverInfoData;
- BOOLEAN DriverInfoAvailable;
-
- DriverInfoData.cbSize = sizeof (DriverInfoData);
- DriverInfoAvailable = SetupDiGetSelectedDriver(DeviceInfoSet,
- DeviceInfoData,
- &DriverInfoData) ?
- TRUE :
- FALSE;
-
- // If there is no driver information then the NULL driver is being
- // installed. Treat this as we would a DIF_REMOVE.
- Error = (DriverInfoAvailable) ?
- DifInstall(DeviceInfoSet, DeviceInfoData, Context) :
- DifRemove(DeviceInfoSet, DeviceInfoData, Context);
+ Error = (IsNullDriver) ?
+ NO_ERROR :
+ DifInstall(DeviceInfoSet, DeviceInfoData, Context);
break;
}
case DIF_REMOVE:
--
2.25.1
Troy Crosley
2021-04-02 20:49:34 UTC
Permalink
In Windows 10 version 2004, The coinstallers' DIF_INSTALLDEVICE routines
do not get called on driver uninstall. In previous versions of Windows,
this occurs as part of the uninstall during the null device install and
is the only time DifRemove gets called to perform cleanup. Work around
this change by calling DifRemove from DIF_SELECTBESTCOMPATDRV, which is
the only coinstaller request that seems to happen on uninstall in
Windows 10 version 2004. In addition, improve the null driver test to
also check if DriverInfoData.DriverType is equal to SPDIT_CLASSDRIVER or
SPDIT_COMPATDRIVER, which is necessary as of some Windows version (at
least Windows 10 version 1803).

Signed-off-by: Joel Upham <***@ainfosec.com>
Signed-off-by: Troy Crosley <***@gmail.com>
---
src/coinst/coinst.c | 49 +++++++++++++++++++++++++++++++--------------
1 file changed, 34 insertions(+), 15 deletions(-)

diff --git a/src/coinst/coinst.c b/src/coinst/coinst.c
index da2c59e..5ff86d4 100644
--- a/src/coinst/coinst.c
+++ b/src/coinst/coinst.c
@@ -1248,6 +1248,9 @@ Entry(
)
{
HRESULT Error;
+ SP_DRVINFO_DATA DriverInfoData;
+ BOOLEAN DriverInfoAvailable;
+ BOOLEAN IsNullDriver;

Log("%s (%s) ===>",
MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
@@ -1262,23 +1265,39 @@ Entry(
Context->InstallResult);
}

+ DriverInfoData.cbSize = sizeof(DriverInfoData);
+ DriverInfoAvailable = SetupDiGetSelectedDriver(DeviceInfoSet,
+ DeviceInfoData,
+ &DriverInfoData) ?
+ TRUE :
+ FALSE;
+ IsNullDriver = !(DriverInfoAvailable &&
+ (DriverInfoData.DriverType == SPDIT_CLASSDRIVER ||
+ DriverInfoData.DriverType == SPDIT_COMPATDRIVER));
+
switch (Function) {
+ case DIF_SELECTBESTCOMPATDRV: {
+ //
+ // If the NULL driver will be installed, treat this as we would a
+ // DIF_REMOVE to work around the fact that Windows 10 2004 doesn't
+ // call DIF_INSTALLDEVICE on uninstall.
+ // An InstallResult value of ERROR_NO_COMPAT_DRIVERS simply means
+ // that the NULL driver was selected, and so should not be treated
+ // as an error.
+ //
+ if (Context->PostProcessing &&
+ Context->InstallResult == ERROR_NO_COMPAT_DRIVERS)
+ Context->InstallResult = NO_ERROR;
+
+ Error = (IsNullDriver) ?
+ DifRemove(DeviceInfoSet, DeviceInfoData, Context) :
+ NO_ERROR;
+ break;
+ }
case DIF_INSTALLDEVICE: {
- SP_DRVINFO_DATA DriverInfoData;
- BOOLEAN DriverInfoAvailable;
-
- DriverInfoData.cbSize = sizeof (DriverInfoData);
- DriverInfoAvailable = SetupDiGetSelectedDriver(DeviceInfoSet,
- DeviceInfoData,
- &DriverInfoData) ?
- TRUE :
- FALSE;
-
- // If there is no driver information then the NULL driver is being
- // installed. Treat this as we would a DIF_REMOVE.
- Error = (DriverInfoAvailable) ?
- DifInstall(DeviceInfoSet, DeviceInfoData, Context) :
- DifRemove(DeviceInfoSet, DeviceInfoData, Context);
+ Error = (IsNullDriver) ?
+ NO_ERROR :
+ DifInstall(DeviceInfoSet, DeviceInfoData, Context);
break;
}
case DIF_REMOVE:
--
2.25.1
Loading...