CoInstaller is not detect when insert the USB device.

I am new in device driver programming. I have written a co-installer to when USB device plugged in machine, the co-installer DLL should be called but it is not called. Below is the co-installer DLL code, which I have written:

#include <windows.h>
#include <setupapi.h>
#include <stdio.h>
//#include “resource.h”
//#include <dontuse.h>
//±--------------------------------------------------------------------------
//
// WARNING!
//
// Installer must not generate any popup to the user.
// It should provide appropriate defaults.
//
// OutputDebugString should be fine…
//
#if DBG
#define DbgOut(Text) OutputDebugString(TEXT(“ClassInstaller: " Text “\n”))
#else
#define DbgOut(Text)
#endif

DWORD CALLBACK
ClassInstaller(
in DI_FUNCTION InstallFunction,
in HDEVINFO DeviceInfoSet,
_in PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
)
/++

Routine Description:

Responds to Class-installer messages
.
Arguments:

InstallFunction [in]
DeviceInfoSet [in]
DeviceInfoData [in]

Return Value:

Returns: NO_ERROR, ERROR_DI_POSTPROCESSING_REQUIRED, or an error code.

/
{
DWORD dwRegType, UINumber;
TCHAR szTest[80];

switch (InstallFunction)
{

case DIF_INSTALLDEVICE:
//
// Sent twice: once before installing the device and once
// after installing device, if you have returned
// ERROR_DI_POSTPROCESSING_REQUIRED during the first pass.
//
MessageBox(NULL,L"DIF_INSTALLDEVICE",Title,MB_OK);
DbgOut(“DIF_INSTALLDEVICE”);
break;

case DIF_ADDPROPERTYPAGE_ADVANCED:
//
// Sent when you check the properties of the device in the
// device manager.
//
MessageBox(NULL,L"DIF_ADDPROPERTYPAGE_ADVANCED",Title,MB_OK);
DbgOut(“DIF_ADDPROPERTYPAGE_ADVANCED”);
break;
//return PropPageProvider(DeviceInfoSet, DeviceInfoData);

case DIF_POWERMESSAGEWAKE:
//
// Sent when you check the power management tab
//
MessageBox(NULL,L"DIF_POWERMESSAGEWAKE",Title,MB_OK);
DbgOut(“DIF_POWERMESSAGEWAKE”);
break;

case DIF_PROPERTYCHANGE:
//
// Sent when you change the property of the device using
// SetupDiSetDeviceInstallParams. (Enable/Disable/Restart)
//
MessageBox(NULL,L"DIF_PROPERTYCHANGE",Title,MB_OK);
DbgOut(“DIF_PROPERTYCHANGE”);
break;
case DIF_REMOVE:
//
// Sent when you uninstall the device.
//
MessageBox(NULL,L"DIF_REMOVE",Title,MB_OK);
DbgOut(“DIF_REMOVE”);
break;

case DIF_NEWDEVICEWIZARD_FINISHINSTALL:
//
// Sent near the end of installation to allow
// an installer to supply wizard page(s) to the user.
// These wizard pages are different from the device manager
// property sheet.There are popped only once during install.
//
MessageBox(NULL,L"DIF_NEWDEVICEWIZARD_FINISHINSTALL",Title,MB_OK);
DbgOut(“DIF_NEWDEVICEWIZARD_FINISHINSTALL”);
break;

case DIF_SELECTDEVICE:

MessageBox(NULL,L"DIF_SELECTDEVICE",Title,MB_OK);
DbgOut(“DIF_SELECTDEVICE”);
break;
case DIF_DESTROYPRIVATEDATA:
//
// Sent when Setup destroys a device information set
// or an SP_DEVINFO_DATA element, or when Setup discards
// its list of co-installers and class installer for a device
//
MessageBox(NULL,L"DIF_DESTROYPRIVATEDATA",Title,MB_OK);
DbgOut(“DIF_DESTROYPRIVATEDATA”);
break;
case DIF_INSTALLDEVICEFILES:
MessageBox(NULL,L"DIF_INSTALLDEVICEFILES",Title,MB_OK);
DbgOut(“DIF_INSTALLDEVICEFILES”);
break;
case DIF_ALLOW_INSTALL:
//
// Sent to confirm whether the installer wants to allow
// the installation of device.
//
MessageBox(NULL,L"DIF_ALLOW_INSTALL",Title,MB_OK);
DbgOut(“DIF_ALLOW_INSTALL”);
break;
case DIF_SELECTBESTCOMPATDRV:
MessageBox(NULL,L"DIF_SELECTBESTCOMPATDRV",Title,MB_OK);
DbgOut(“DIF_SELECTBESTCOMPATDRV”);
break;

case DIF_INSTALLINTERFACES:
MessageBox(NULL,L"DIF_INSTALLINTERFACES",Title,MB_OK);
DbgOut(“DIF_INSTALLINTERFACES”);
break;
case DIF_REGISTER_COINSTALLERS:
MessageBox(NULL,L"DIF_REGISTER_COINSTALLERS",Title,MB_OK);
DbgOut(“DIF_REGISTER_COINSTALLERS”);
break;
default:
MessageBox(NULL,L"default",Title,MB_OK);
DbgOut("DIF
???”);
break;
}
return NO_ERROR;;
}
Note:
1. This dll I have copied in system32 folder and Installed the driver.

Case1: When I plugged the USB device the co-installer DLL is not called after install the our device driver.
Case2: When Uninstalled the driver, then Inserting the USB device, the co-installer DLL is called.
Case3: when updating the driver from the device manager that time also called the co-installer DLL.

Only failure occur in case 1.

Thanks in advance.</dontuse.h></stdio.h></setupapi.h></windows.h>

xxxxx@yahoo.co.in wrote:

I am new in device driver programming. I have written a co-installer to when USB device plugged in machine, the co-installer DLL should be called but it is not called. Below is the co-installer DLL code, which I have written:

How are you installing your driver? A co-installer is called when your
device is INSTALLED, not when your device is PLUGGED IN. So, if you
pre-install your driver on a machine that has never seen the device
before, the co-installer should be called the very first time you plug
in. After the driver has been installed, the co-installer won’t be
called on future plugins unless you uninstall or disable and enable.

Note:

  1. This dll I have copied in system32 folder and Installed the driver.

I don’t understand this line. You never copy your co-installer
directly. Your co-installer should be listed in your INF file, part of
your driver package, and will be copied as part of the driver
installation. Can you show us your INF file?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Thanks for reply,

Yes, I have included in the DLL in INF file. I can not show you the full INF file because of security reason. sorry for that. But I have modified the INF file for the CoInstallder.dll and below is the entry in INF file which I have included:

[DestinationDirs]
DefaultDestDir=12
CodeClassInstallerCopyFiles=11

; ================= Class section =====================

[ClassInstall32]
Addreg=CodeClassReg
CopyFiles=CodeClassInstallerCopyFiles

[CodeClassReg]
HKR,Installer32,“ClassCoInstaller.dll,CodeClassInstaller”
HKR,DeviceCharacteristics,0x10001,0x100 ;Use same security checks on relative opens
HKR,Security,“D:P(A;;GA;;;SY)(A;;GA;;;BA)” ;Allow generic all access to system and built-in Admin.
;This one overrides the security set by the driver

[CodeClassInstallerCopyFiles]
ClassCoInstaller.dll

;------------------------------------------------------------------------------

[SourceDisksFiles]
ClassCoInstaller.dll=1,

xxxxx@yahoo.co.in wrote:

Yes, I have included in the DLL in INF file. I can not show you the full INF file because of security reason. sorry for that.

Well, you’re the one that will suffer, because there isn’t that much we
can do for you. Co-installers work. If yours isn’t working, then
you’re doing something wrong, but we can’t identify any common issues
without seeing the setup.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.