36 #define DBG_PROGNAME "OPENCBM-XA1541.DLL"
47 DWORD error = GetLastError();
61 IN DEVINST dnDevInst, OUT PTCHAR Buffer, IN ULONG BufferLen,
62 IN ULONG ulFlags, IN HMACHINE hMachine);
69 IN HDEVINFO DeviceInfoSet, OUT PSP_DEVINFO_LIST_DETAIL_DATA DeviceInfoSetDetailData);
89 FreeDynamicalAddresses(PSETUPAPI SetupApi)
97 DBGDO(memset(SetupApi, 0,
sizeof(*SetupApi));)
103 #define GET_PROC_ADDRESS(_xxx) \
104 if (SetupApi && SetupApi->HandleSetupApiDll) \
106 SetupApi->_xxx##_p = (P_##_xxx) GetProcAddress(SetupApi->HandleSetupApiDll, #_xxx); \
108 DBG_SUCCESS((DBG_PREFIX "p_CM_Get_Device_ID_Ex = %p", SetupApi->_xxx##_p)); \
110 if (SetupApi->_xxx##_p == NULL) \
112 DBG_WARN((DBG_PREFIX "GetProcAddress(\"" #_xxx "\") FAILED!")); \
113 FreeDynamicalAddresses(SetupApi); \
118 GetDynamicalAddresses(PSETUPAPI SetupApi)
150 DBGDO(memset(&setupApi, 0,
sizeof(setupApi));)
152 if (GetDynamicalAddresses(&setupApi))
160 hdevInfo = SetupDiGetClassDevs(&GUID_PARALLEL_DEVICE, NULL, NULL,
161 DIGCF_DEVICEINTERFACE | DIGCF_PRESENT | DIGCF_PROFILE);
163 if (hdevInfo != INVALID_HANDLE_VALUE)
171 char deviceId[MAX_DEVICE_ID_LEN];
173 SP_DEVINFO_LIST_DETAIL_DATA sdld;
175 sdld.cbSize =
sizeof(sdld);
180 printf(
"SetupDiGetDeviceInfoListDetail FAILED!\n");
184 sdd.cbSize =
sizeof(sdd);
186 if (SetupDiEnumDeviceInfo(hdevInfo, i, &sdd))
188 SP_DEVINSTALL_PARAMS devParams;
189 SP_PROPCHANGE_PARAMS spp;
190 HMACHINE machineHandle = { 0 };
193 0, machineHandle) != CR_SUCCESS)
199 spp.ClassInstallHeader.cbSize =
sizeof(spp.ClassInstallHeader);
200 spp.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE;
201 spp.StateChange = DICS_PROPCHANGE;
202 spp.Scope = DICS_FLAG_GLOBAL;
205 if (SetupDiSetClassInstallParams(hdevInfo, &sdd,
206 (PSP_CLASSINSTALL_HEADER) &spp,
sizeof(spp)))
213 printf(
"SET CLASS INSTALL PARAMS NOT SUCCESSFULL!\n");
217 if (SetupDiCallClassInstaller(DIF_PROPERTYCHANGE, hdevInfo, &sdd))
224 printf(
"CALL CLASS INSTALLER NOT SUCCESSFULL!\n");
228 if (SetupDiGetDeviceInstallParams(hdevInfo, &sdd, &devParams))
230 if (devParams.Flags & (DI_NEEDRESTART | DI_NEEDREBOOT))
233 printf(
"NEED REBOOT TO TAKE EFFECT!\n");
239 if (GetLastError() == ERROR_NO_MORE_ITEMS)
249 printf(
"SetupDiGetClassDevs FAILED!");
253 SetupDiDestroyDeviceInfoList(hdevInfo);
255 FreeDynamicalAddresses(&setupApi);
Define makros for debugging purposes.
HMODULE HandleSetupApiDll
VOID CbmParportRestart(VOID)
Restart the parallel port.
P_CM_Get_Device_ID_ExA CM_Get_Device_ID_ExA_p
#define FUNC_LEAVE_BOOLEAN(_xxx)
CMAPI CONFIGRET(* P_CM_Get_Device_ID_ExA)(IN DEVINST dnDevInst, OUT PTCHAR Buffer, IN ULONG BufferLen, IN ULONG ulFlags, IN HMACHINE hMachine)
struct SETUPAPI * PSETUPAPI
#define DBG_SUCCESS(_xxx)
P_SetupDiGetDeviceInfoListDetailA SetupDiGetDeviceInfoListDetailA_p
#define GET_PROC_ADDRESS(_xxx)
Internal API for opencbm installation.
Some functions for string handling.
WINSETUPAPI BOOL(* P_SetupDiGetDeviceInfoListDetailA)(IN HDEVINFO DeviceInfoSet, OUT PSP_DEVINFO_LIST_DETAIL_DATA DeviceInfoSetDetailData)