com0com-cvs Mailing List for Null-modem emulator (Page 32)
The virtual serial port driver for Windows.
Brought to you by:
vfrolov
You can subscribe to this list here.
2005 |
Jan
|
Feb
(7) |
Mar
|
Apr
|
May
(13) |
Jun
(18) |
Jul
(9) |
Aug
(10) |
Sep
(15) |
Oct
(6) |
Nov
(9) |
Dec
(6) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(6) |
Feb
(4) |
Mar
(4) |
Apr
(2) |
May
(7) |
Jun
(11) |
Jul
(6) |
Aug
(9) |
Sep
(1) |
Oct
(27) |
Nov
(22) |
Dec
(3) |
2007 |
Jan
(13) |
Feb
(16) |
Mar
(2) |
Apr
(3) |
May
(7) |
Jun
(17) |
Jul
(9) |
Aug
(1) |
Sep
(13) |
Oct
(20) |
Nov
(18) |
Dec
(1) |
2008 |
Jan
|
Feb
(3) |
Mar
(46) |
Apr
(40) |
May
(4) |
Jun
(9) |
Jul
(7) |
Aug
(62) |
Sep
(25) |
Oct
(51) |
Nov
(67) |
Dec
(81) |
2009 |
Jan
(13) |
Feb
(31) |
Mar
(12) |
Apr
|
May
(10) |
Jun
|
Jul
(5) |
Aug
(2) |
Sep
(10) |
Oct
|
Nov
(3) |
Dec
(1) |
2010 |
Jan
|
Feb
(1) |
Mar
(4) |
Apr
|
May
(12) |
Jun
(9) |
Jul
(12) |
Aug
(7) |
Sep
(6) |
Oct
|
Nov
|
Dec
(1) |
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(11) |
Jun
|
Jul
(26) |
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
(23) |
2012 |
Jan
(7) |
Feb
(3) |
Mar
|
Apr
|
May
(2) |
Jun
(9) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Vyacheslav F. <vf...@us...> - 2006-10-23 12:01:52
|
Update of /cvsroot/com0com/com0com/setup In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv15158 Modified Files: sources Log Message: Changed TARGETPATH to .. Index: sources =================================================================== RCS file: /cvsroot/com0com/com0com/setup/sources,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** sources 28 Jul 2006 12:16:42 -0000 1.1 --- sources 23 Oct 2006 12:01:49 -0000 1.2 *************** *** 1,4 **** TARGETNAME=setup ! TARGETPATH=obj TARGETTYPE=DYNLINK --- 1,4 ---- TARGETNAME=setup ! TARGETPATH=.. TARGETTYPE=DYNLINK |
From: Vyacheslav F. <vf...@us...> - 2006-10-23 12:00:02
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv14290 Modified Files: sources Log Message: Changed TARGETPATH to .. Index: sources =================================================================== RCS file: /cvsroot/com0com/com0com/sys/sources,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** sources 23 Aug 2006 13:12:16 -0000 1.6 --- sources 23 Oct 2006 11:59:55 -0000 1.7 *************** *** 1,4 **** TARGETNAME=com0com ! TARGETPATH=obj TARGETTYPE=DRIVER --- 1,4 ---- TARGETNAME=com0com ! TARGETPATH=.. TARGETTYPE=DRIVER |
From: Vyacheslav F. <vf...@us...> - 2006-10-19 13:28:55
|
Update of /cvsroot/com0com/com0com/setup In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv25354 Modified Files: inffile.cpp inffile.h setup.cpp Log Message: Added InfFile::UninstallAllInfFiles() Index: inffile.h =================================================================== RCS file: /cvsroot/com0com/com0com/setup/inffile.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** inffile.h 28 Jul 2006 12:16:42 -0000 1.1 --- inffile.h 19 Oct 2006 13:28:50 -0000 1.2 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.2 2006/10/19 13:28:50 vfrolov + * Added InfFile::UninstallAllInfFiles() + * * Revision 1.1 2006/07/28 12:16:42 vfrolov * Initial revision *************** *** 35,46 **** const char *Path() const { return pPath; } ! const char *ClassGUID() const; ! const char *Class() const; ! const char *Provider() const; BOOL Compare( const char *_pClassGUID, const char *_pClass, ! const char *_pProvider) const; BOOL UninstallFiles(const char *pFilesSection) const; --- 38,50 ---- const char *Path() const { return pPath; } ! const char *ClassGUID(BOOL showErrors = TRUE) const; ! const char *Class(BOOL showErrors = TRUE) const; ! const char *Provider(BOOL showErrors = TRUE) const; BOOL Compare( const char *_pClassGUID, const char *_pClass, ! const char *_pProvider, ! BOOL showErrors = TRUE) const; BOOL UninstallFiles(const char *pFilesSection) const; *************** *** 48,51 **** --- 52,60 ---- BOOL InstallOEMInf() const; BOOL UninstallOEMInf() const; + + static BOOL UninstallAllInfFiles( + const char *_pClassGUID, + const char *_pClass, + const char *_pProvider); protected: char *pPath; Index: inffile.cpp =================================================================== RCS file: /cvsroot/com0com/com0com/setup/inffile.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** inffile.cpp 28 Jul 2006 12:16:43 -0000 1.1 --- inffile.cpp 19 Oct 2006 13:28:48 -0000 1.2 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.2 2006/10/19 13:28:48 vfrolov + * Added InfFile::UninstallAllInfFiles() + * * Revision 1.1 2006/07/28 12:16:43 vfrolov * Initial revision *************** *** 29,35 **** #include "inffile.h" #include "msg.h" /////////////////////////////////////////////////////////////// ! static BOOL GetVersionInfo(const char *pInfPath, const char *pKey, char **ppValue) { if (!pInfPath) --- 32,39 ---- #include "inffile.h" #include "msg.h" + #include "utils.h" /////////////////////////////////////////////////////////////// ! static BOOL GetVersionInfo(const char *pInfPath, const char *pKey, char **ppValue, BOOL showErrors) { if (!pInfPath) *************** *** 42,46 **** if (!SetupGetInfInformation(pInfPath, INFINFO_INF_NAME_IS_ABSOLUTE, (PSP_INF_INFORMATION)buf, sizeof(buf), NULL)) { ! ShowLastError(MB_OK|MB_ICONSTOP, "SetupGetInfInformation()"); return FALSE; } --- 46,51 ---- if (!SetupGetInfInformation(pInfPath, INFINFO_INF_NAME_IS_ABSOLUTE, (PSP_INF_INFORMATION)buf, sizeof(buf), NULL)) { ! if (showErrors) ! ShowLastError(MB_OK|MB_ICONSTOP, "SetupGetInfInformation(%s)", pInfPath); return FALSE; } *************** *** 49,53 **** if (!SetupQueryInfVersionInformation((PSP_INF_INFORMATION)buf, 0, pKey, NULL, 0, &size)) { ! ShowLastError(MB_OK|MB_ICONSTOP, "SetupQueryInfVersionInformation(%s)", pKey); return FALSE; } --- 54,59 ---- if (!SetupQueryInfVersionInformation((PSP_INF_INFORMATION)buf, 0, pKey, NULL, 0, &size)) { ! if (showErrors) ! ShowLastError(MB_OK|MB_ICONSTOP, "SetupQueryInfVersionInformation(%s) for %s", pKey, pInfPath); return FALSE; } *************** *** 57,61 **** if (*ppValue) { if (!SetupQueryInfVersionInformation((PSP_INF_INFORMATION)buf, 0, pKey, *ppValue, size, NULL)) { ! ShowLastError(MB_OK|MB_ICONSTOP, "SetupQueryInfVersionInformation(%s)", pKey); LocalFree(*ppValue); *ppValue = NULL; --- 63,68 ---- if (*ppValue) { if (!SetupQueryInfVersionInformation((PSP_INF_INFORMATION)buf, 0, pKey, *ppValue, size, NULL)) { ! if (showErrors) ! ShowLastError(MB_OK|MB_ICONSTOP, "SetupQueryInfVersionInformation(%s) for %s", pKey, pInfPath); LocalFree(*ppValue); *ppValue = NULL; *************** *** 79,82 **** --- 86,101 ---- DWORD res; + if (!pNearPath) { + if (DWORD(lstrlen(pFileName)) >= lenFilePath) { + ShowError(MB_OK|MB_ICONSTOP, ERROR_BUFFER_OVERFLOW, "lstrlen(%s) >= %lu", + pFileName, (long)lenFilePath); + return FALSE; + } + + lstrcpy(pFilePath, pFileName); + + return TRUE; + } + res = GetFullPathName(pNearPath, lenFilePath, pFilePath, &pBuf); *************** *** 111,115 **** char path[MAX_PATH]; ! if (GetFilePath(pInfName, pNearPath, path, sizeof(path))) { int len = lstrlen(path); --- 130,134 ---- char path[MAX_PATH]; ! if (GetFilePath(pInfName, pNearPath, path, sizeof(path)/sizeof(path[0]))) { int len = lstrlen(path); *************** *** 135,155 **** } /////////////////////////////////////////////////////////////// ! const char *InfFile::ClassGUID() const { ! GetVersionInfo(pPath, "ClassGUID", &(char *)pClassGUID); return pClassGUID; } /////////////////////////////////////////////////////////////// ! const char *InfFile::Class() const { ! GetVersionInfo(pPath, "Class", &(char *)pClass); return pClass; } /////////////////////////////////////////////////////////////// ! const char *InfFile::Provider() const { ! GetVersionInfo(pPath, "Provider", &(char *)pProvider); return pProvider; --- 154,174 ---- } /////////////////////////////////////////////////////////////// ! const char *InfFile::ClassGUID(BOOL showErrors) const { ! GetVersionInfo(pPath, "ClassGUID", &(char *)pClassGUID, showErrors); return pClassGUID; } /////////////////////////////////////////////////////////////// ! const char *InfFile::Class(BOOL showErrors) const { ! GetVersionInfo(pPath, "Class", &(char *)pClass, showErrors); return pClass; } /////////////////////////////////////////////////////////////// ! const char *InfFile::Provider(BOOL showErrors) const { ! GetVersionInfo(pPath, "Provider", &(char *)pProvider, showErrors); return pProvider; *************** *** 159,167 **** const char *_pClassGUID, const char *_pClass, ! const char *_pProvider) const { ! return ClassGUID() && !lstrcmpi(pClassGUID, _pClassGUID) && ! Class() && !lstrcmpi(pClass, _pClass) && ! Provider() && !lstrcmpi(pProvider, _pProvider); } /////////////////////////////////////////////////////////////// --- 178,187 ---- const char *_pClassGUID, const char *_pClass, ! const char *_pProvider, ! BOOL showErrors) const { ! return (!_pClassGUID || (ClassGUID(showErrors) && !lstrcmpi(pClassGUID, _pClassGUID))) && ! (!_pClass || (Class(showErrors) && !lstrcmpi(pClass, _pClass))) && ! (!_pProvider || (Provider(showErrors) && !lstrcmpi(pProvider, _pProvider))); } /////////////////////////////////////////////////////////////// *************** *** 254,258 **** char infPathDest[MAX_PATH]; ! if (!SetupCopyOEMInf(pPath, NULL, SPOST_PATH, 0, infPathDest, sizeof(infPathDest), NULL, NULL)) { ShowLastError(MB_OK|MB_ICONSTOP, "SetupCopyOEMInf(%s)", pPath); return FALSE; --- 274,280 ---- char infPathDest[MAX_PATH]; ! if (!SetupCopyOEMInf(pPath, NULL, SPOST_PATH, 0, infPathDest, ! sizeof(infPathDest)/sizeof(infPathDest[0]), NULL, NULL)) ! { ShowLastError(MB_OK|MB_ICONSTOP, "SetupCopyOEMInf(%s)", pPath); return FALSE; *************** *** 292,300 **** #endif /* HAVE_SetupUninstallOEMInf */ ! BOOL InfFile::UninstallOEMInf() const { - if (!pPath) - return FALSE; - int res; --- 314,319 ---- #endif /* HAVE_SetupUninstallOEMInf */ ! static BOOL UninstallInf(const char *pPath) { int res; *************** *** 303,310 **** char infPathDest[MAX_PATH]; - char *pInfNameDest; ! if (SetupCopyOEMInf(pPath, NULL, SPOST_NONE, SP_COPY_REPLACEONLY, infPathDest, sizeof(infPathDest), NULL, &pInfNameDest)) { #ifdef HAVE_SetupUninstallOEMInf if (SetupUninstallOEMInf(pInfNameDest, 0, NULL)) { Trace("Deleted %s\n", pInfNameDest); --- 322,334 ---- char infPathDest[MAX_PATH]; ! if (SNPRINTF(infPathDest, sizeof(infPathDest)/sizeof(infPathDest[0]), "%s", pPath) > 0) { #ifdef HAVE_SetupUninstallOEMInf + char *pInfNameDest, *p; + + for (pInfNameDest = p = infPathDest ; *p ; p++) + if (*p == '\\') + pInfNameDest = p + 1; + if (SetupUninstallOEMInf(pInfNameDest, 0, NULL)) { Trace("Deleted %s\n", pInfNameDest); *************** *** 331,334 **** --- 355,386 ---- #endif /* HAVE_SetupUninstallOEMInf */ } else { + Trace("Can't uninstall %s\n", pPath); + res = IDCANCEL; + } + } while (res == IDTRYAGAIN); + + if (res != IDCONTINUE) + return FALSE; + + return res; + } + /////////////////////////////////////////////////////////////// + BOOL InfFile::UninstallOEMInf() const + { + if (!pPath) + return FALSE; + + int res; + + do { + res = IDCONTINUE; + + char infPathDest[MAX_PATH]; + + if (SetupCopyOEMInf(pPath, NULL, SPOST_NONE, SP_COPY_REPLACEONLY, infPathDest, + sizeof(infPathDest)/sizeof(infPathDest[0]), NULL, NULL)) + { + UninstallInf(infPathDest); + } else { if (GetLastError() == ERROR_FILE_NOT_FOUND) { Trace("File %s not installed\n", pPath); *************** *** 345,346 **** --- 397,473 ---- } /////////////////////////////////////////////////////////////// + BOOL InfFile::UninstallAllInfFiles( + const char *_pClassGUID, + const char *_pClass, + const char *_pProvider) + { + DWORD size; + + if (!SetupGetInfFileList(NULL, INF_STYLE_WIN4, NULL, 0, &size)) { + ShowLastError(MB_OK|MB_ICONSTOP, "SetupGetInfFileList()"); + return FALSE; + } + + char *pList = (char *)LocalAlloc(LPTR, size*sizeof(pList[0])); + + if (pList) { + if (!SetupGetInfFileList(NULL, INF_STYLE_WIN4, pList, size, NULL)) { + ShowLastError(MB_OK|MB_ICONSTOP, "SetupGetInfFileList()"); + LocalFree(pList); + return FALSE; + } + } else { + ShowLastError(MB_OK|MB_ICONSTOP, "LocalAlloc()"); + return FALSE; + } + + char windir[MAX_PATH]; + + size = GetEnvironmentVariable("windir", windir, sizeof(windir)/sizeof(windir[0])); + + if (!size || size >= sizeof(windir)/sizeof(windir[0])) { + DWORD err = !size ? GetLastError() : ERROR_BUFFER_OVERFLOW; + + ShowError(MB_OK|MB_ICONSTOP, err, "GetEnvironmentVariable(windir)"); + + LocalFree(pList); + return FALSE; + } + + char *p = pList; + + do { + char infPath[MAX_PATH]; + + if (SNPRINTF(infPath, sizeof(infPath)/sizeof(infPath[0]), "%s\\inf\\%s", windir, p) > 0) { + InfFile infFile(infPath, NULL); + + if (infFile.Compare(_pClassGUID, _pClass, _pProvider, FALSE)) { + if (ShowMsg(MB_YESNO, + "The file %s possible should be deleted too.\n" + "\n" + "%s:\n" + " ClassGUID = %s\n" + " Class = %s\n" + " Provider = %s\n" + "\n" + "Would you like to delete it?\n", + infFile.Path(), + infFile.Path(), + infFile.ClassGUID(FALSE), + infFile.Class(FALSE), + infFile.Provider(FALSE)) == IDYES) + { + UninstallInf(infFile.Path()); + } + } + } + + p += lstrlen(p) + 1; + } while (*p); + + LocalFree(pList); + + return TRUE; + } + /////////////////////////////////////////////////////////////// Index: setup.cpp =================================================================== RCS file: /cvsroot/com0com/com0com/setup/setup.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** setup.cpp 13 Oct 2006 10:26:35 -0000 1.3 --- setup.cpp 19 Oct 2006 13:28:50 -0000 1.4 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.4 2006/10/19 13:28:50 vfrolov + * Added InfFile::UninstallAllInfFiles() + * * Revision 1.3 2006/10/13 10:26:35 vfrolov * Some defines moved to ../include/com0com.h *************** *** 374,377 **** --- 377,383 ---- return 1; + if (!InfFile::UninstallAllInfFiles(C0C_CLASS_GUID, NULL, NULL)) + return 1; + return 0; } *************** *** 388,393 **** " list - for each port show parameters\n" " change <port> <params> - set parameters for port\n" ! " install <params> <params> - install a pair of ports\n" ! " preinstall - install driver\n" " update - update driver\n" " uninstall - uninstall all pairs and driver\n" --- 394,399 ---- " list - for each port show parameters\n" " change <port> <params> - set parameters for port\n" ! " install <paramsA> <paramsB> - install a pair of ports\n" ! " preinstall - preinstall driver\n" " update - update driver\n" " uninstall - uninstall all pairs and driver\n" |
From: Vyacheslav F. <vf...@us...> - 2006-10-17 11:24:25
|
Update of /cvsroot/com0com/homepage In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv25084 Modified Files: index.html Log Message: Added donate button Index: index.html =================================================================== RCS file: /cvsroot/com0com/homepage/index.html,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** index.html 13 Jun 2006 16:05:58 -0000 1.4 --- index.html 17 Oct 2006 11:24:18 -0000 1.5 *************** *** 7,10 **** --- 7,13 ---- </head> <body> + <a href="http://sourceforge.net/donate/index.php?group_id=129551"> + <img src="http://images.sourceforge.net/images/project-support.jpg" + width="88" height="32" border="0" alt="Support This Project" /> </a> <center> <h1> Null-modem emulator <br> *************** *** 51,55 **** <a href="http://sourceforge.net"><img src="http://sourceforge.net/sflogo.php?group_id=129551&type=5" ! alt="SourceForge.net Logo" border="0" height="62" width="210"></a></center> </body> </html> --- 54,59 ---- <a href="http://sourceforge.net"><img src="http://sourceforge.net/sflogo.php?group_id=129551&type=5" ! alt="SourceForge.net Logo" border="0" height="62" width="210"></a> ! </center> </body> </html> |
From: Vyacheslav F. <vf...@us...> - 2006-10-17 10:04:09
|
Update of /cvsroot/com0com/com0com/setup In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv26485 Modified Files: msg.cpp Log Message: Added MB_SETFOREGROUND flag to MessageBox() Index: msg.cpp =================================================================== RCS file: /cvsroot/com0com/com0com/setup/msg.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** msg.cpp 28 Jul 2006 12:16:42 -0000 1.1 --- msg.cpp 17 Oct 2006 10:03:59 -0000 1.2 *************** *** 20,27 **** * * $Log$ * Revision 1.1 2006/07/28 12:16:42 vfrolov * Initial revision * - * */ --- 20,29 ---- * * $Log$ + * Revision 1.2 2006/10/17 10:03:59 vfrolov + * Added MB_SETFOREGROUND flag to MessageBox() + * * Revision 1.1 2006/07/28 12:16:42 vfrolov * Initial revision * */ *************** *** 33,37 **** static int ShowMsgDefault(LPCSTR pText, LPCSTR pCaption, UINT type) { ! return MessageBox(NULL, pText, pCaption, type); } --- 35,39 ---- static int ShowMsgDefault(LPCSTR pText, LPCSTR pCaption, UINT type) { ! return MessageBox(NULL, pText, pCaption, type|MB_SETFOREGROUND); } |
From: Vyacheslav F. <vf...@us...> - 2006-10-17 06:54:40
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv22687 Modified Files: wmi.c Log Message: Disabled SERIAL_PORT_WMI_HW_GUID for binary compatibility with both W2K and WXP Index: wmi.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/wmi.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** wmi.c 23 Aug 2006 13:09:55 -0000 1.1 --- wmi.c 17 Oct 2006 06:54:37 -0000 1.2 *************** *** 20,27 **** * * $Log$ * Revision 1.1 2006/08/23 13:09:55 vfrolov * Initial revision * - * */ --- 20,30 ---- * * $Log$ + * Revision 1.2 2006/10/17 06:54:37 vfrolov + * Disabled SERIAL_PORT_WMI_HW_GUID for binary compatibility with + * both W2K and WXP + * * Revision 1.1 2006/08/23 13:09:55 vfrolov * Initial revision * */ *************** *** 35,39 **** #include "commprop.h" ! /* * FILE_ID used by HALT_UNLESS to put it on BSOD */ --- 38,42 ---- #include "commprop.h" ! /* * FILE_ID used by HALT_UNLESS to put it on BSOD */ *************** *** 42,61 **** GUID guidWmiPortName = SERIAL_PORT_WMI_NAME_GUID; GUID guidWmiPortComm = SERIAL_PORT_WMI_COMM_GUID; GUID guidWmiPortHW = SERIAL_PORT_WMI_HW_GUID; GUID guidWmiPortPerf = SERIAL_PORT_WMI_PERF_GUID; GUID guidWmiPortProperties = SERIAL_PORT_WMI_PROPERTIES_GUID; ! #define COC_WMI_PORT_NAME 0 ! #define COC_WMI_PORT_COMM 1 ! #define COC_WMI_PORT_HW 2 ! #define COC_WMI_PORT_PERF 3 ! #define COC_WMI_PORT_PROPERTIES 4 ! #define COC_WMI_LIST_SIZE 5 WMIGUIDREGINFO guidWmiList[COC_WMI_LIST_SIZE] = { {&guidWmiPortName, 1, 0}, {&guidWmiPortComm, 1, 0}, {&guidWmiPortHW, 1, 0}, {&guidWmiPortPerf, 1, 0}, {&guidWmiPortProperties, 1, 0}, --- 45,72 ---- GUID guidWmiPortName = SERIAL_PORT_WMI_NAME_GUID; GUID guidWmiPortComm = SERIAL_PORT_WMI_COMM_GUID; + #ifdef ALLOW_WMI_HW_GUID GUID guidWmiPortHW = SERIAL_PORT_WMI_HW_GUID; + #endif /* ALLOW_WMI_HW_GUID */ GUID guidWmiPortPerf = SERIAL_PORT_WMI_PERF_GUID; GUID guidWmiPortProperties = SERIAL_PORT_WMI_PROPERTIES_GUID; ! enum COC_GUID_INDEX { ! COC_WMI_PORT_NAME, ! COC_WMI_PORT_COMM, ! #ifdef ALLOW_WMI_HW_GUID ! COC_WMI_PORT_HW, ! #endif /* ALLOW_WMI_HW_GUID */ ! COC_WMI_PORT_PERF, ! COC_WMI_PORT_PROPERTIES, ! COC_WMI_LIST_SIZE ! }; WMIGUIDREGINFO guidWmiList[COC_WMI_LIST_SIZE] = { {&guidWmiPortName, 1, 0}, {&guidWmiPortComm, 1, 0}, + #ifdef ALLOW_WMI_HW_GUID {&guidWmiPortHW, 1, 0}, + #endif /* ALLOW_WMI_HW_GUID */ {&guidWmiPortPerf, 1, 0}, {&guidWmiPortProperties, 1, 0}, *************** *** 202,205 **** --- 213,222 ---- status = STATUS_SUCCESS; break; + #ifdef ALLOW_WMI_HW_GUID + /* + * W2K and WXP have different SERIAL_WMI_HW_DATA structures + * so we don't allow SERIAL_PORT_WMI_HW_GUID by default. + * Define ALLOW_WMI_HW_GUID if you need it. + */ case COC_WMI_PORT_HW: Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"QueryWmiDataBlock PORT_HW"); *************** *** 216,219 **** --- 233,237 ---- status = STATUS_SUCCESS; break; + #endif /* ALLOW_WMI_HW_GUID */ case COC_WMI_PORT_PERF: Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"QueryWmiDataBlock PORT_PERF"); *************** *** 337,341 **** case IrpNotCompleted: TraceCode((PC0C_COMMON_EXTENSION)pDevExt, "IrpNotCompleted ", NULL, ! (ULONG)IoGetCurrentIrpStackLocation(pIrp)->Parameters.WMI.DataPath, &status); IoCompleteRequest(pIrp, IO_NO_INCREMENT); break; --- 355,359 ---- case IrpNotCompleted: TraceCode((PC0C_COMMON_EXTENSION)pDevExt, "IrpNotCompleted ", NULL, ! (ULONG)(ULONG_PTR)IoGetCurrentIrpStackLocation(pIrp)->Parameters.WMI.DataPath, &status); IoCompleteRequest(pIrp, IO_NO_INCREMENT); break; |
From: Vyacheslav F. <vf...@us...> - 2006-10-16 08:30:55
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv16680 Modified Files: adddev.c com0com.h Log Message: Added the device interface registration Index: adddev.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/adddev.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** adddev.c 13 Oct 2006 10:22:22 -0000 1.19 --- adddev.c 16 Oct 2006 08:30:45 -0000 1.20 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.20 2006/10/16 08:30:45 vfrolov + * Added the device interface registration + * * Revision 1.19 2006/10/13 10:22:22 vfrolov * Changed name of device object (for WMI) *************** *** 83,86 **** --- 86,91 ---- #include "precomp.h" + #include <initguid.h> + #include <ntddser.h> #include "timeout.h" #include "delay.h" *************** *** 113,129 **** IoWMIRegistrationControl(pDevExt->pDevObj, WMIREG_ACTION_DEREGISTER); ! if (pDevExt->mappedSerialDevice) RtlDeleteRegistryValue(RTL_REGISTRY_DEVICEMAP, C0C_SERIAL_DEVICEMAP, pDevExt->ntDeviceName.Buffer); ! if (pDevExt->createdSymbolicLink) IoDeleteSymbolicLink(&pDevExt->win32DeviceName); if (pDevExt->pLowDevObj) IoDetachDevice(pDevExt->pLowDevObj); - StrFree(&pDevExt->win32DeviceName); - StrFree(&pDevExt->ntDeviceName); - Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"RemoveFdoPort"); --- 118,140 ---- IoWMIRegistrationControl(pDevExt->pDevObj, WMIREG_ACTION_DEREGISTER); ! if (pDevExt->symbolicLinkName.Buffer) { ! IoSetDeviceInterfaceState(&pDevExt->symbolicLinkName, FALSE); ! RtlFreeUnicodeString(&pDevExt->symbolicLinkName); ! } ! ! if (pDevExt->ntDeviceName.Buffer) { RtlDeleteRegistryValue(RTL_REGISTRY_DEVICEMAP, C0C_SERIAL_DEVICEMAP, pDevExt->ntDeviceName.Buffer); + StrFree(&pDevExt->ntDeviceName); + } ! if (pDevExt->win32DeviceName.Buffer) { IoDeleteSymbolicLink(&pDevExt->win32DeviceName); + StrFree(&pDevExt->win32DeviceName); + } if (pDevExt->pLowDevObj) IoDetachDevice(pDevExt->pLowDevObj); Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"RemoveFdoPort"); *************** *** 139,143 **** PC0C_PDOPORT_EXTENSION pPhDevExt; ULONG emuBR, emuOverrun; ! UNICODE_STRING property; PWCHAR pPortName; --- 150,154 ---- PC0C_PDOPORT_EXTENSION pPhDevExt; ULONG emuBR, emuOverrun; ! UNICODE_STRING ntDeviceName; PWCHAR pPortName; *************** *** 145,151 **** pDevExt = NULL; RtlInitUnicodeString(&portName, NULL); ! RtlInitUnicodeString(&property, NULL); ! StrAppendDeviceProperty(&status, &property, pPhDevObj, DevicePropertyPhysicalDeviceObjectName); if (!NT_SUCCESS(status)) { --- 156,162 ---- pDevExt = NULL; RtlInitUnicodeString(&portName, NULL); ! RtlInitUnicodeString(&ntDeviceName, NULL); ! StrAppendDeviceProperty(&status, &ntDeviceName, pPhDevObj, DevicePropertyPhysicalDeviceObjectName); if (!NT_SUCCESS(status)) { *************** *** 162,166 **** } ! Trace00((PC0C_COMMON_EXTENSION)pPhDevExt, L"AddFdoPort for ", property.Buffer); pPortName = pPhDevExt->portName; --- 173,177 ---- } ! Trace00((PC0C_COMMON_EXTENSION)pPhDevExt, L"AddFdoPort for ", ntDeviceName.Buffer); pPortName = pPhDevExt->portName; *************** *** 277,281 **** NULL, FILE_DEVICE_SERIAL_PORT, ! 0, TRUE, &pNewDevObj); --- 288,292 ---- NULL, FILE_DEVICE_SERIAL_PORT, ! FILE_DEVICE_SECURE_OPEN, TRUE, &pNewDevObj); *************** *** 291,301 **** status = InitCommonExt((PC0C_COMMON_EXTENSION)pDevExt, pNewDevObj, C0C_DOTYPE_FP, portName.Buffer); - RtlInitUnicodeString(&pDevExt->ntDeviceName, NULL); - StrAppendStr0(&status, &pDevExt->ntDeviceName, property.Buffer); - - RtlInitUnicodeString(&pDevExt->win32DeviceName, NULL); - StrAppendStr0(&status, &pDevExt->win32DeviceName, C0C_PREF_WIN32_DEVICE_NAME); - StrAppendStr0(&status, &pDevExt->win32DeviceName, portName.Buffer); - if (!NT_SUCCESS(status)) { SysLog(pPhDevObj, status, L"AddFdoPort FAIL"); --- 302,305 ---- *************** *** 342,379 **** SetWriteDelay(pDevExt->pIoPortLocal); ! status = IoCreateSymbolicLink(&pDevExt->win32DeviceName, &pDevExt->ntDeviceName); ! if (!NT_SUCCESS(status)) { ! SysLog(pPhDevObj, status, L"AddFdoPort IoCreateSymbolicLink FAIL"); goto clean; } ! pDevExt->createdSymbolicLink = TRUE; ! status = RtlWriteRegistryValue(RTL_REGISTRY_DEVICEMAP, C0C_SERIAL_DEVICEMAP, ! pDevExt->ntDeviceName.Buffer, REG_SZ, ! portName.Buffer, ! portName.Length + sizeof(WCHAR)); ! if (!NT_SUCCESS(status)) { ! SysLog(pPhDevObj, status, L"AddFdoPort RtlWriteRegistryValue FAIL"); ! goto clean; } ! pDevExt->mappedSerialDevice = TRUE; ! pDevExt->pPhDevObj = pPhDevObj; ! pDevExt->pLowDevObj = IoAttachDeviceToDeviceStack(pNewDevObj, pPhDevObj); ! if (!pDevExt->pLowDevObj) { ! status = STATUS_NO_SUCH_DEVICE; ! SysLog(pPhDevObj, status, L"AddFdoPort IoAttachDeviceToDeviceStack FAIL"); ! goto clean; } ! pNewDevObj->Flags &= ~DO_DEVICE_INITIALIZING; ! pNewDevObj->Flags |= DO_BUFFERED_IO; ! IoWMIRegistrationControl(pNewDevObj, WMIREG_ACTION_REGISTER); Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"AddFdoPort OK"); --- 346,418 ---- SetWriteDelay(pDevExt->pIoPortLocal); ! pDevExt->pPhDevObj = pPhDevObj; ! pDevExt->pLowDevObj = IoAttachDeviceToDeviceStack(pNewDevObj, pPhDevObj); ! if (!pDevExt->pLowDevObj) { ! status = STATUS_NO_SUCH_DEVICE; ! SysLog(pPhDevObj, status, L"AddFdoPort IoAttachDeviceToDeviceStack FAIL"); goto clean; } ! pNewDevObj->Flags &= ~DO_DEVICE_INITIALIZING; ! pNewDevObj->Flags |= DO_BUFFERED_IO; ! /* Create symbolic links to device */ ! RtlInitUnicodeString(&pDevExt->ntDeviceName, NULL); ! StrAppendStr0(&status, &pDevExt->ntDeviceName, ntDeviceName.Buffer); ! ! RtlInitUnicodeString(&pDevExt->win32DeviceName, NULL); ! StrAppendStr0(&status, &pDevExt->win32DeviceName, C0C_PREF_WIN32_DEVICE_NAME); ! StrAppendStr0(&status, &pDevExt->win32DeviceName, portName.Buffer); ! ! if (NT_SUCCESS(status)) { ! status = IoCreateSymbolicLink(&pDevExt->win32DeviceName, &pDevExt->ntDeviceName); ! ! if (NT_SUCCESS(status)) { ! status = RtlWriteRegistryValue(RTL_REGISTRY_DEVICEMAP, C0C_SERIAL_DEVICEMAP, ! pDevExt->ntDeviceName.Buffer, REG_SZ, ! portName.Buffer, ! portName.Length + sizeof(WCHAR)); ! ! if (!NT_SUCCESS(status)) { ! StrFree(&pDevExt->ntDeviceName); ! ! SysLog(pPhDevObj, status, L"AddFdoPort RtlWriteRegistryValue" C0C_SERIAL_DEVICEMAP L" FAIL"); ! } ! } else { ! StrFree(&pDevExt->win32DeviceName); ! StrFree(&pDevExt->ntDeviceName); ! ! SysLog(pPhDevObj, status, L"AddFdoPort IoCreateSymbolicLink FAIL"); ! } ! } else { ! StrFree(&pDevExt->win32DeviceName); ! StrFree(&pDevExt->ntDeviceName); ! ! SysLog(pPhDevObj, status, L"AddFdoPort StrAppendStr0 FAIL"); } ! status = IoRegisterDeviceInterface(pPhDevObj, ! (LPGUID)&GUID_CLASS_COMPORT, ! NULL, ! &pDevExt->symbolicLinkName); ! if (NT_SUCCESS(status)) { ! status = IoSetDeviceInterfaceState(&pDevExt->symbolicLinkName, TRUE); ! if (!NT_SUCCESS(status)) ! SysLog(pPhDevObj, status, L"AddFdoPort IoSetDeviceInterfaceState FAIL"); ! } else { ! SysLog(pPhDevObj, status, L"AddFdoPort IoRegisterDeviceInterface FAIL"); ! pDevExt->symbolicLinkName.Buffer = NULL; } ! status = IoWMIRegistrationControl(pNewDevObj, WMIREG_ACTION_REGISTER); ! if (!NT_SUCCESS(status)) ! SysLog(pPhDevObj, status, L"AddFdoPort IoWMIRegistrationControl FAIL"); ! ! status = STATUS_SUCCESS; Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"AddFdoPort OK"); *************** *** 384,388 **** RemoveFdoPort(pDevExt); ! StrFree(&property); StrFree(&portName); --- 423,427 ---- RemoveFdoPort(pDevExt); ! StrFree(&ntDeviceName); StrFree(&portName); Index: com0com.h =================================================================== RCS file: /cvsroot/com0com/com0com/sys/com0com.h,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** com0com.h 13 Oct 2006 10:15:02 -0000 1.29 --- com0com.h 16 Oct 2006 08:30:45 -0000 1.30 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.30 2006/10/16 08:30:45 vfrolov + * Added the device interface registration + * * Revision 1.29 2006/10/13 10:15:02 vfrolov * Some defines moved to ../include/com0com.h *************** *** 259,264 **** UNICODE_STRING ntDeviceName; UNICODE_STRING win32DeviceName; ! BOOLEAN createdSymbolicLink; ! BOOLEAN mappedSerialDevice; LONG openCount; --- 262,266 ---- UNICODE_STRING ntDeviceName; UNICODE_STRING win32DeviceName; ! UNICODE_STRING symbolicLinkName; LONG openCount; |
From: Vyacheslav F. <vf...@us...> - 2006-10-13 11:20:36
|
Update of /cvsroot/com0com/com0com/setup In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv4392 Added Files: .cvsignore Log Message: Initial revision --- NEW FILE: .cvsignore --- obj objchk objfre |
From: Vyacheslav F. <vf...@us...> - 2006-10-13 10:26:44
|
Update of /cvsroot/com0com/com0com/setup In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv16274 Modified Files: devutils.cpp setup.cpp Log Message: Some defines moved to ../include/com0com.h Changed name of device object (for WMI) Index: setup.cpp =================================================================== RCS file: /cvsroot/com0com/com0com/setup/setup.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** setup.cpp 25 Aug 2006 10:36:48 -0000 1.2 --- setup.cpp 13 Oct 2006 10:26:35 -0000 1.3 *************** *** 20,23 **** --- 20,27 ---- * * $Log$ + * Revision 1.3 2006/10/13 10:26:35 vfrolov + * Some defines moved to ../include/com0com.h + * Changed name of device object (for WMI) + * * Revision 1.2 2006/08/25 10:36:48 vfrolov * Added C0C_PREF_PORT_NAME_A and C0C_PREF_PORT_NAME_B defines *************** *** 37,44 **** #include "utils.h" ! #define C0C_BUS_DEVICE_ID "root\\com0com" ! #define C0C_PORT_DEVICE_ID "com0com\\port" ! #define C0C_PREF_PORT_NAME_A "CNCA" ! #define C0C_PREF_PORT_NAME_B "CNCB" #define C0C_INF_NAME "com0com.inf" --- 41,46 ---- #include "utils.h" ! #define TEXT_PREF ! #include "../include/com0com.h" #define C0C_INF_NAME "com0com.inf" *************** *** 46,50 **** #define C0C_CLASS "CNCPorts" #define C0C_PROVIDER "Vyacheslav Frolov" - #define C0C_SERVICE "com0com" #define C0C_REGKEY_EVENTLOG REGSTR_PATH_SERVICES "\\Eventlog\\System\\" C0C_SERVICE #define C0C_COPY_DRIVERS_SECTION "com0com_CopyDrivers" --- 48,51 ---- *************** *** 62,66 **** char phPortName[20]; ! SNPRINTF(phPortName, sizeof(phPortName), "%s%d", j ? C0C_PREF_PORT_NAME_B : C0C_PREF_PORT_NAME_A, i); PortParameters portParameters(C0C_SERVICE, phPortName); --- 63,68 ---- char phPortName[20]; ! SNPRINTF(phPortName, sizeof(phPortName)/sizeof(phPortName[0]), "%s%d", ! j ? C0C_PREF_PORT_NAME_B : C0C_PREF_PORT_NAME_A, i); PortParameters portParameters(C0C_SERVICE, phPortName); *************** *** 70,74 **** char buf[100]; ! portParameters.FillParametersStr(buf, sizeof(buf)); Trace(" %s %s\n", phPortName, buf); --- 72,76 ---- char buf[100]; ! portParameters.FillParametersStr(buf, sizeof(buf)/sizeof(buf[0])); Trace(" %s %s\n", phPortName, buf); *************** *** 81,88 **** if (err == ERROR_SUCCESS) { ! portParameters.FillParametersStr(buf, sizeof(buf)); Trace("change %s %s\n", phPortName, buf); ! RestartDevices(infFile, C0C_PORT_DEVICE_ID, phPortName, &rebootRequired); } else { ShowError(MB_OK|MB_ICONWARNING, err, "portParameters.Save(%s)", phPortName); --- 83,95 ---- if (err == ERROR_SUCCESS) { ! portParameters.FillParametersStr(buf, sizeof(buf)/sizeof(buf[0])); Trace("change %s %s\n", phPortName, buf); ! char phDevDevName[40]; ! ! SNPRINTF(phDevDevName, sizeof(phDevDevName)/sizeof(phDevDevName[0]), "%s%d", ! j ? C0C_PREF_DEVICE_NAME_A : C0C_PREF_DEVICE_NAME_B, i); ! ! RestartDevices(infFile, C0C_PORT_DEVICE_ID, phDevDevName, &rebootRequired); } else { ShowError(MB_OK|MB_ICONWARNING, err, "portParameters.Save(%s)", phPortName); *************** *** 142,146 **** pParameters = j ? pParametersB : pParametersA; ! SNPRINTF(phPortName, sizeof(phPortName), "%s%d", j ? C0C_PREF_PORT_NAME_B : C0C_PREF_PORT_NAME_A, i); PortParameters portParameters(C0C_SERVICE, phPortName); --- 149,154 ---- pParameters = j ? pParametersB : pParametersA; ! SNPRINTF(phPortName, sizeof(phPortName)/sizeof(phPortName[0]), "%s%d", ! j ? C0C_PREF_PORT_NAME_B : C0C_PREF_PORT_NAME_A, i); PortParameters portParameters(C0C_SERVICE, phPortName); *************** *** 163,167 **** char buf[100]; ! portParameters.FillParametersStr(buf, sizeof(buf)); Trace(" %s %s\n", phPortName, buf); --- 171,175 ---- char buf[100]; ! portParameters.FillParametersStr(buf, sizeof(buf)/sizeof(buf[0])); Trace(" %s %s\n", phPortName, buf); Index: devutils.cpp =================================================================== RCS file: /cvsroot/com0com/com0com/setup/devutils.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** devutils.cpp 28 Jul 2006 12:16:42 -0000 1.1 --- devutils.cpp 13 Oct 2006 10:26:35 -0000 1.2 *************** *** 20,23 **** --- 20,27 ---- * * $Log$ + * Revision 1.2 2006/10/13 10:26:35 vfrolov + * Some defines moved to ../include/com0com.h + * Changed name of device object (for WMI) + * * Revision 1.1 2006/07/28 12:16:42 vfrolov * Initial revision *************** *** 313,323 **** BOOL *pRebootRequired) { - char phDevObjName[30]; - - if (SNPRINTF(phDevObjName, sizeof(phDevObjName), "\\Device\\%s", pPhDevName) < 0) - return FALSE; - - phDevObjName[sizeof(phDevObjName) - 1] = 0; - EnumParams enumParams; --- 317,320 ---- *************** *** 326,330 **** enumParams.pRebootRequired = pRebootRequired; enumParams.pDevId = pDevId; ! enumParams.pPhObjName = phDevObjName; do { --- 323,327 ---- enumParams.pRebootRequired = pRebootRequired; enumParams.pDevId = pDevId; ! enumParams.pPhObjName = pPhDevName; do { |
From: Vyacheslav F. <vf...@us...> - 2006-10-13 10:22:29
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv14734 Modified Files: adddev.c Log Message: Changed name of device object (for WMI) Index: adddev.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/adddev.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** adddev.c 10 Oct 2006 15:18:15 -0000 1.18 --- adddev.c 13 Oct 2006 10:22:22 -0000 1.19 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.19 2006/10/13 10:22:22 vfrolov + * Changed name of device object (for WMI) + * * Revision 1.18 2006/10/10 15:18:15 vfrolov * Added PortName value setting for WMI *************** *** 133,143 **** UNICODE_STRING portName; PDEVICE_OBJECT pNewDevObj; ! PC0C_FDOPORT_EXTENSION pDevExt = NULL; ULONG emuBR, emuOverrun; UNICODE_STRING property; PWCHAR pPortName; - int i; status = STATUS_SUCCESS; RtlInitUnicodeString(&portName, NULL); RtlInitUnicodeString(&property, NULL); --- 136,147 ---- UNICODE_STRING portName; PDEVICE_OBJECT pNewDevObj; ! PC0C_FDOPORT_EXTENSION pDevExt; ! PC0C_PDOPORT_EXTENSION pPhDevExt; ULONG emuBR, emuOverrun; UNICODE_STRING property; PWCHAR pPortName; status = STATUS_SUCCESS; + pDevExt = NULL; RtlInitUnicodeString(&portName, NULL); RtlInitUnicodeString(&property, NULL); *************** *** 150,162 **** } ! Trace00((PC0C_COMMON_EXTENSION)pPhDevObj->DeviceExtension, L"AddFdoPort for ", property.Buffer); ! for (pPortName = NULL, i = 0 ; property.Buffer[i] ; i++) ! if (property.Buffer[i] == L'\\') ! pPortName = &property.Buffer[i + 1]; ! if (!pPortName || !*pPortName) { status = STATUS_UNSUCCESSFUL; ! SysLog(pPhDevObj, status, L"AddFdoPort no port name in the property"); goto clean; } --- 154,172 ---- } ! pPhDevExt = (PC0C_PDOPORT_EXTENSION)pPhDevObj->DeviceExtension; ! if (pPhDevExt->doType != C0C_DOTYPE_PP) { ! status = STATUS_UNSUCCESSFUL; ! SysLog(pPhDevObj, status, L"AddFdoPort FAIL. Type of PDO is not PP"); ! goto clean; ! } ! Trace00((PC0C_COMMON_EXTENSION)pPhDevExt, L"AddFdoPort for ", property.Buffer); ! ! pPortName = pPhDevExt->portName; ! ! if (!*pPortName) { status = STATUS_UNSUCCESSFUL; ! SysLog(pPhDevObj, status, L"AddFdoPort FAIL. The PDO has invalid port name"); goto clean; } *************** *** 197,201 **** } else { StrAppendStr(&status, &portName, portNameTmp.Buffer, portNameTmp.Length); ! Trace00((PC0C_COMMON_EXTENSION)pPhDevObj->DeviceExtension, L"PortName set to ", portName.Buffer); } } --- 207,211 ---- } else { StrAppendStr(&status, &portName, portNameTmp.Buffer, portNameTmp.Length); ! Trace00((PC0C_COMMON_EXTENSION)pPhDevExt, L"PortName set to ", portName.Buffer); } } *************** *** 293,297 **** } ! pDevExt->pIoPortLocal = ((PC0C_PDOPORT_EXTENSION)pPhDevObj->DeviceExtension)->pIoPortLocal; pDevExt->pIoPortLocal->pDevExt = pDevExt; --- 303,307 ---- } ! pDevExt->pIoPortLocal = pPhDevExt->pIoPortLocal; pDevExt->pIoPortLocal->pDevExt = pDevExt; *************** *** 408,413 **** RtlInitUnicodeString(&ntDeviceName, NULL); ! StrAppendStr0(&status, &ntDeviceName, C0C_PREF_NT_DEVICE_NAME); ! StrAppendStr(&status, &ntDeviceName, portName.Buffer, portName.Length); if (!NT_SUCCESS(status)) { --- 418,423 ---- RtlInitUnicodeString(&ntDeviceName, NULL); ! StrAppendStr0(&status, &ntDeviceName, isA ? C0C_PREF_DEVICE_NAME_A : C0C_PREF_DEVICE_NAME_B); ! StrAppendNum(&status, &ntDeviceName, num, 10); if (!NT_SUCCESS(status)) { *************** *** 442,446 **** pDevExt->pIoPortLocal = pIoPortLocal; ! Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"AddPdoPort OK"); clean: --- 452,456 ---- pDevExt->pIoPortLocal = pIoPortLocal; ! Trace00((PC0C_COMMON_EXTENSION)pDevExt, L"AddPdoPort OK - ", ntDeviceName.Buffer); clean: |
From: Vyacheslav F. <vf...@us...> - 2006-10-13 10:15:08
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv11782 Modified Files: com0com.h Log Message: Some defines moved to ../include/com0com.h Changed defines of C0C_DOTYPE_* to more unique values Index: com0com.h =================================================================== RCS file: /cvsroot/com0com/com0com/sys/com0com.h,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** com0com.h 23 Aug 2006 13:48:12 -0000 1.28 --- com0com.h 13 Oct 2006 10:15:02 -0000 1.29 *************** *** 20,23 **** --- 20,27 ---- * * $Log$ + * Revision 1.29 2006/10/13 10:15:02 vfrolov + * Some defines moved to ../include/com0com.h + * Changed defines of C0C_DOTYPE_* to more unique values + * * Revision 1.28 2006/08/23 13:48:12 vfrolov * Implemented WMI functionality *************** *** 112,136 **** #define _C0C_COM0COM_H_ #define C0C_SERIAL_DEVICEMAP L"SERIALCOMM" #define C0C_PREF_WIN32_DEVICE_NAME L"\\DosDevices\\" - #define C0C_PREF_NT_DEVICE_NAME L"\\Device\\" ! #define C0C_BUS_DEVICE_ID L"root\\com0com" ! #define C0C_PORT_DEVICE_ID L"com0com\\port" ! #define C0C_PORT_HARDWARE_IDS L"com0com\\port\0" #define C0C_PORT_COMPATIBLE_IDS L"\0" ! #define C0C_PREF_BUS_NAME L"CNCBUS" ! #define C0C_PREF_PORT_NAME_A L"CNCA" ! #define C0C_PREF_PORT_NAME_B L"CNCB" ! ! #define C0C_DOTYPE_FB 1 ! #define C0C_DOTYPE_PP 2 ! #define C0C_DOTYPE_FP 3 #define C0C_PORT_NAME_LEN 12 #define COMMON_EXTENSION \ ! short doType; \ PDEVICE_OBJECT pDevObj; \ WCHAR portName[C0C_PORT_NAME_LEN]; \ --- 116,136 ---- #define _C0C_COM0COM_H_ + #define TEXT_PREF L + #include "../include/com0com.h" + #define C0C_SERIAL_DEVICEMAP L"SERIALCOMM" #define C0C_PREF_WIN32_DEVICE_NAME L"\\DosDevices\\" ! #define C0C_PORT_HARDWARE_IDS C0C_PORT_DEVICE_ID L"\0" #define C0C_PORT_COMPATIBLE_IDS L"\0" ! #define C0C_DOTYPE_FB ((unsigned)0xC0C1) ! #define C0C_DOTYPE_PP ((unsigned)0xC0C2) ! #define C0C_DOTYPE_FP ((unsigned)0xC0C3) #define C0C_PORT_NAME_LEN 12 #define COMMON_EXTENSION \ ! unsigned short doType; \ PDEVICE_OBJECT pDevObj; \ WCHAR portName[C0C_PORT_NAME_LEN]; \ |
From: Vyacheslav F. <vf...@us...> - 2006-10-13 10:06:16
|
Update of /cvsroot/com0com/com0com/include In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv8852 Added Files: com0com.h Log Message: Initial revision --- NEW FILE: com0com.h --- /* * $Id: com0com.h,v 1.1 2006/10/13 10:06:13 vfrolov Exp $ * * Copyright (c) 2006 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * $Log: com0com.h,v $ * Revision 1.1 2006/10/13 10:06:13 vfrolov * Initial revision * * */ #ifndef _INCLUDE_C0C_COM0COM_H_ #define _INCLUDE_C0C_COM0COM_H_ #define C0C_BUS_DEVICE_ID TEXT_PREF"root\\com0com" #define C0C_PORT_DEVICE_ID TEXT_PREF"com0com\\port" #define C0C_SERVICE TEXT_PREF"com0com" #define C0C_PREF_NT_DEVICE_NAME TEXT_PREF"\\Device\\" #define C0C_PREF_BUS_NAME TEXT_PREF"CNCBUS" #define C0C_PREF_PORT_NAME_A TEXT_PREF"CNCA" #define C0C_PREF_PORT_NAME_B TEXT_PREF"CNCB" #define C0C_PREF_DEVICE_NAME_A C0C_PREF_NT_DEVICE_NAME C0C_SERVICE TEXT_PREF"1" #define C0C_PREF_DEVICE_NAME_B C0C_PREF_NT_DEVICE_NAME C0C_SERVICE TEXT_PREF"2" #endif /* _INCLUDE_C0C_COM0COM_H_ */ |
From: Vyacheslav F. <vf...@us...> - 2006-10-13 09:47:30
|
Update of /cvsroot/com0com/com0com/include In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv1766/include Log Message: Directory /cvsroot/com0com/com0com/include added to the repository |
From: Vyacheslav F. <vf...@us...> - 2006-10-10 15:18:18
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv3310 Modified Files: adddev.c Log Message: Added PortName value setting for WMI Index: adddev.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/adddev.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** adddev.c 23 Aug 2006 13:48:12 -0000 1.17 --- adddev.c 10 Oct 2006 15:18:15 -0000 1.18 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.18 2006/10/10 15:18:15 vfrolov + * Added PortName value setting for WMI + * * Revision 1.17 2006/08/23 13:48:12 vfrolov * Implemented WMI functionality *************** *** 236,239 **** --- 239,266 ---- } + { + HANDLE hKey; + + status = IoOpenDeviceRegistryKey(pPhDevObj, + PLUGPLAY_REGKEY_DEVICE, + STANDARD_RIGHTS_READ, + &hKey); + + if (status == STATUS_SUCCESS) { + UNICODE_STRING keyName; + + RtlInitUnicodeString(&keyName, L"PortName"); + + status = ZwSetValueKey(hKey, &keyName, 0, REG_SZ, portName.Buffer, portName.Length + sizeof(WCHAR)); + + if (!NT_SUCCESS(status)) + SysLog(pPhDevObj, status, L"ZwSetValueKey(PortName) FAIL"); + + ZwClose(hKey); + } else { + SysLog(pPhDevObj, status, L"IoOpenDeviceRegistryKey(PLUGPLAY_REGKEY_DEVICE) FAIL"); + } + } + status = IoCreateDevice(pDrvObj, sizeof(*pDevExt), |
From: Vyacheslav F. <vf...@us...> - 2006-09-27 07:25:01
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv1192 Modified Files: tracetbl.c Log Message: Added IRP_MN_REGINFO_EX Index: tracetbl.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/tracetbl.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tracetbl.c 23 Aug 2006 12:56:20 -0000 1.9 --- tracetbl.c 27 Sep 2006 07:24:51 -0000 1.10 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.10 2006/09/27 07:24:51 vfrolov + * Added IRP_MN_REGINFO_EX + * * Revision 1.9 2006/08/23 12:56:20 vfrolov * Added codeNameTableWmi *************** *** 185,188 **** --- 188,195 ---- TOCODE2NAME(IRP_MN_, REGINFO), TOCODE2NAME(IRP_MN_, EXECUTE_METHOD), + #ifndef IRP_MN_REGINFO_EX + #define IRP_MN_REGINFO_EX 0x0b + #endif + TOCODE2NAME(IRP_MN_, REGINFO_EX), {0, NULL} }; |
From: Vyacheslav F. <vf...@us...> - 2006-08-25 10:37:00
|
Update of /cvsroot/com0com/com0com/setup In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv26810 Modified Files: setup.cpp Log Message: Added C0C_PREF_PORT_NAME_A and C0C_PREF_PORT_NAME_B defines Added deleting Class subkeys Index: setup.cpp =================================================================== RCS file: /cvsroot/com0com/com0com/setup/setup.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** setup.cpp 28 Jul 2006 12:16:42 -0000 1.1 --- setup.cpp 25 Aug 2006 10:36:48 -0000 1.2 *************** *** 20,23 **** --- 20,27 ---- * * $Log$ + * Revision 1.2 2006/08/25 10:36:48 vfrolov + * Added C0C_PREF_PORT_NAME_A and C0C_PREF_PORT_NAME_B defines + * Added deleting Class subkeys + * * Revision 1.1 2006/07/28 12:16:42 vfrolov * Initial revision *************** *** 33,39 **** #include "utils.h" - #define C0C_INF_NAME "com0com.inf" #define C0C_BUS_DEVICE_ID "root\\com0com" #define C0C_PORT_DEVICE_ID "com0com\\port" #define C0C_CLASS_GUID "{df799e12-3c56-421b-b298-b6d3642bc878}" #define C0C_CLASS "CNCPorts" --- 37,46 ---- #include "utils.h" #define C0C_BUS_DEVICE_ID "root\\com0com" #define C0C_PORT_DEVICE_ID "com0com\\port" + #define C0C_PREF_PORT_NAME_A "CNCA" + #define C0C_PREF_PORT_NAME_B "CNCB" + + #define C0C_INF_NAME "com0com.inf" #define C0C_CLASS_GUID "{df799e12-3c56-421b-b298-b6d3642bc878}" #define C0C_CLASS "CNCPorts" *************** *** 55,59 **** char phPortName[20]; ! SNPRINTF(phPortName, sizeof(phPortName), "CNC%c%d", j ? 'B' : 'A', i); PortParameters portParameters(C0C_SERVICE, phPortName); --- 62,66 ---- char phPortName[20]; ! SNPRINTF(phPortName, sizeof(phPortName), "%s%d", j ? C0C_PREF_PORT_NAME_B : C0C_PREF_PORT_NAME_A, i); PortParameters portParameters(C0C_SERVICE, phPortName); *************** *** 135,139 **** pParameters = j ? pParametersB : pParametersA; ! SNPRINTF(phPortName, sizeof(phPortName), "CNC%c%d", j ? 'B' : 'A', i); PortParameters portParameters(C0C_SERVICE, phPortName); --- 142,146 ---- pParameters = j ? pParametersB : pParametersA; ! SNPRINTF(phPortName, sizeof(phPortName), "%s%d", j ? C0C_PREF_PORT_NAME_B : C0C_PREF_PORT_NAME_A, i); PortParameters portParameters(C0C_SERVICE, phPortName); *************** *** 290,293 **** --- 297,334 ---- err = RegDeleteKey(hKey, infFile.ClassGUID()); + if (err != ERROR_SUCCESS) { + HKEY hClassGuidKey; + err = RegOpenKeyEx(hKey, infFile.ClassGUID(), 0, KEY_READ, &hClassGuidKey); + + if (err == ERROR_SUCCESS) { + for (;;) { + char subKey[MAX_PATH+1]; + DWORD subKeySize = sizeof(subKey)/sizeof(subKey[0]); + + err = RegEnumKeyEx(hClassGuidKey, 0, subKey, &subKeySize, NULL, NULL, NULL, NULL); + + if (err != ERROR_SUCCESS) + break; + + err = RegDeleteKey(hClassGuidKey, subKey); + + if (err == ERROR_SUCCESS) + Trace("Deleted Class subkey %s\\%s\n", infFile.ClassGUID(), subKey); + else + if (err != ERROR_FILE_NOT_FOUND) { + ShowError(MB_OK|MB_ICONWARNING, err, "RegDeleteKey(%s\\%s)", infFile.ClassGUID(), subKey); + break; + } + } + + err = RegCloseKey(hClassGuidKey); + + if (err != ERROR_SUCCESS) + ShowError(MB_OK|MB_ICONWARNING, err, "RegCloseKey()"); + } + + err = RegDeleteKey(hKey, infFile.ClassGUID()); + } + if (err == ERROR_SUCCESS) { Trace("Deleted Class %s\n", infFile.ClassGUID()); *************** *** 360,364 **** , pProgName); Trace( ! " %s change CNCA0 EmuBR=yes,EmuOverrun=yes\n" , pProgName); --- 401,405 ---- , pProgName); Trace( ! " %s change " C0C_PREF_PORT_NAME_A "0 EmuBR=yes,EmuOverrun=yes\n" , pProgName); |
From: Vyacheslav F. <vf...@us...> - 2006-08-23 13:48:23
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv8473 Modified Files: adddev.c com0com.h Log Message: Implemented WMI functionality Index: adddev.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/adddev.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** adddev.c 23 Jun 2006 11:44:52 -0000 1.16 --- adddev.c 23 Aug 2006 13:48:12 -0000 1.17 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.17 2006/08/23 13:48:12 vfrolov + * Implemented WMI functionality + * * Revision 1.16 2006/06/23 11:44:52 vfrolov * Mass replacement pDevExt by pIoPort *************** *** 102,105 **** --- 105,110 ---- } + IoWMIRegistrationControl(pDevExt->pDevObj, WMIREG_ACTION_DEREGISTER); + if (pDevExt->mappedSerialDevice) RtlDeleteRegistryValue(RTL_REGISTRY_DEVICEMAP, C0C_SERIAL_DEVICEMAP, *************** *** 321,324 **** --- 326,330 ---- pDevExt->mappedSerialDevice = TRUE; + pDevExt->pPhDevObj = pPhDevObj; pDevExt->pLowDevObj = IoAttachDeviceToDeviceStack(pNewDevObj, pPhDevObj); *************** *** 332,335 **** --- 338,343 ---- pNewDevObj->Flags |= DO_BUFFERED_IO; + IoWMIRegistrationControl(pNewDevObj, WMIREG_ACTION_REGISTER); + Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"AddFdoPort OK"); *************** *** 532,535 **** --- 540,544 ---- pDevExt->portNum = num; + pDevExt->pPhDevObj = pPhDevObj; pDevExt->pLowDevObj = IoAttachDeviceToDeviceStack(pNewDevObj, pPhDevObj); Index: com0com.h =================================================================== RCS file: /cvsroot/com0com/com0com/sys/com0com.h,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** com0com.h 23 Jun 2006 11:44:52 -0000 1.27 --- com0com.h 23 Aug 2006 13:48:12 -0000 1.28 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.28 2006/08/23 13:48:12 vfrolov + * Implemented WMI functionality + * * Revision 1.27 2006/06/23 11:44:52 vfrolov * Mass replacement pDevExt by pIoPort *************** *** 135,138 **** --- 138,142 ---- #define FDO_EXTENSION \ COMMON_EXTENSION \ + PDEVICE_OBJECT pPhDevObj; \ PDEVICE_OBJECT pLowDevObj; \ |
From: Vyacheslav F. <vf...@us...> - 2006-08-23 13:16:54
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv28899 Modified Files: ioctl.c Log Message: Moved code for IOCTL_SERIAL_GET_PROPERTIES to commprop.c Index: ioctl.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/ioctl.c,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** ioctl.c 17 Jul 2006 09:58:21 -0000 1.25 --- ioctl.c 23 Aug 2006 13:16:50 -0000 1.26 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.26 2006/08/23 13:16:50 vfrolov + * Moved code for IOCTL_SERIAL_GET_PROPERTIES to commprop.c + * * Revision 1.25 2006/07/17 09:58:21 vfrolov * Added #if DBG *************** *** 106,109 **** --- 109,113 ---- #include "bufutils.h" #include "handflow.h" + #include "commprop.h" NTSTATUS FdoPortIoCtl( *************** *** 568,652 **** break; case IOCTL_SERIAL_GET_PROPERTIES: { ! PSERIAL_COMMPROP pSysBuf; ! ! if (pIrpStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(SERIAL_COMMPROP)) { ! status = STATUS_BUFFER_TOO_SMALL; ! break; ! } ! ! pSysBuf = (PSERIAL_COMMPROP)pIrp->AssociatedIrp.SystemBuffer; ! ! RtlZeroMemory(pSysBuf, sizeof(SERIAL_COMMPROP)); ! ! pSysBuf->PacketLength = sizeof(SERIAL_COMMPROP); ! pSysBuf->PacketVersion = 2; ! pSysBuf->ServiceMask = SERIAL_SP_SERIALCOMM; ! pSysBuf->MaxTxQueue = 0; ! pSysBuf->MaxRxQueue = 0; ! ! pSysBuf->MaxBaud = SERIAL_BAUD_USER; ! ! pSysBuf->SettableBaud = ! SERIAL_BAUD_075 | ! SERIAL_BAUD_110 | ! SERIAL_BAUD_134_5 | ! SERIAL_BAUD_150 | ! SERIAL_BAUD_300 | ! SERIAL_BAUD_600 | ! SERIAL_BAUD_1200 | ! SERIAL_BAUD_1800 | ! SERIAL_BAUD_2400 | ! SERIAL_BAUD_4800 | ! SERIAL_BAUD_7200 | ! SERIAL_BAUD_9600 | ! SERIAL_BAUD_14400 | ! SERIAL_BAUD_19200 | ! SERIAL_BAUD_38400 | ! SERIAL_BAUD_56K | ! SERIAL_BAUD_128K | ! SERIAL_BAUD_115200 | ! SERIAL_BAUD_57600; ! ! pSysBuf->ProvSubType = SERIAL_SP_RS232; ! ! pSysBuf->ProvCapabilities = ! SERIAL_PCF_DTRDSR | ! SERIAL_PCF_RTSCTS | ! SERIAL_PCF_CD | ! SERIAL_PCF_PARITY_CHECK | ! SERIAL_PCF_XONXOFF | ! SERIAL_PCF_SETXCHAR | ! SERIAL_PCF_TOTALTIMEOUTS | ! SERIAL_PCF_INTTIMEOUTS; ! ! pSysBuf->SettableParams = ! SERIAL_SP_PARITY | ! SERIAL_SP_BAUD | ! SERIAL_SP_DATABITS | ! SERIAL_SP_STOPBITS | ! SERIAL_SP_HANDSHAKING | ! SERIAL_SP_PARITY_CHECK | ! SERIAL_SP_CARRIER_DETECT; ! ! pSysBuf->SettableData = ! SERIAL_DATABITS_5 | ! SERIAL_DATABITS_6 | ! SERIAL_DATABITS_7 | ! SERIAL_DATABITS_8; ! pSysBuf->SettableStopParity = ! SERIAL_STOPBITS_10 | ! SERIAL_STOPBITS_15 | ! SERIAL_STOPBITS_20 | ! SERIAL_PARITY_NONE | ! SERIAL_PARITY_ODD | ! SERIAL_PARITY_EVEN | ! SERIAL_PARITY_MARK | ! SERIAL_PARITY_SPACE; ! pSysBuf->CurrentTxQueue = 0; ! pSysBuf->CurrentRxQueue = (ULONG)C0C_BUFFER_SIZE(&pIoPortLocal->readBuf); - pIrp->IoStatus.Information = sizeof(SERIAL_COMMPROP); break; } --- 572,585 ---- break; case IOCTL_SERIAL_GET_PROPERTIES: { ! ULONG size; ! status = GetCommProp(pDevExt, ! pIrp->AssociatedIrp.SystemBuffer, ! pIrpStack->Parameters.DeviceIoControl.OutputBufferLength, ! &size); ! if (status == STATUS_SUCCESS) ! pIrp->IoStatus.Information = size; break; } |
From: Vyacheslav F. <vf...@us...> - 2006-08-23 13:13:57
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv27757 Modified Files: initunlo.c Log Message: Moved c0cSystemControlDispatch() to wmi.c Index: initunlo.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/initunlo.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** initunlo.c 28 Sep 2005 10:06:42 -0000 1.5 --- initunlo.c 23 Aug 2006 13:13:53 -0000 1.6 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.6 2006/08/23 13:13:53 vfrolov + * Moved c0cSystemControlDispatch() to wmi.c + * * Revision 1.5 2005/09/28 10:06:42 vfrolov * Implemented IRP_MJ_QUERY_INFORMATION and IRP_MJ_SET_INFORMATION *************** *** 106,132 **** return status; } - - NTSTATUS c0cSystemControlDispatch(IN PDEVICE_OBJECT pDevObj, IN PIRP pIrp) - { - NTSTATUS status; - PC0C_COMMON_EXTENSION pDevExt = pDevObj->DeviceExtension; - - status = STATUS_NO_SUCH_DEVICE; - - switch (pDevExt->doType) { - case C0C_DOTYPE_FB: - case C0C_DOTYPE_FP: - TraceIrp("c0cSystemControlDispatch", pIrp, NULL, TRACE_FLAG_PARAMS); - IoSkipCurrentIrpStackLocation(pIrp); - status = IoCallDriver(((PC0C_COMMON_FDO_EXTENSION)pDevExt)->pLowDevObj, pIrp); - break; - case C0C_DOTYPE_PP: - status = STATUS_NOT_SUPPORTED; - default: - TraceIrp("c0cSystemControlDispatch", pIrp, &status, TRACE_FLAG_PARAMS); - pIrp->IoStatus.Status = status; - IoCompleteRequest(pIrp, IO_NO_INCREMENT); - } - - return status; - } --- 109,110 ---- |
From: Vyacheslav F. <vf...@us...> - 2006-08-23 13:12:20
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv27337 Modified Files: sources Log Message: Added wmi.c and commprop.c Index: sources =================================================================== RCS file: /cvsroot/com0com/com0com/sys/sources,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** sources 10 Jan 2006 10:17:23 -0000 1.5 --- sources 23 Aug 2006 13:12:16 -0000 1.6 *************** *** 13,16 **** --- 13,18 ---- power.c \ ioctl.c \ + wmi.c \ + commprop.c \ read.c \ write.c \ |
From: Vyacheslav F. <vf...@us...> - 2006-08-23 13:10:03
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv26152 Added Files: wmi.c Log Message: Initial revision --- NEW FILE: wmi.c --- /* * $Id: wmi.c,v 1.1 2006/08/23 13:09:55 vfrolov Exp $ * * Copyright (c) 2006 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * $Log: wmi.c,v $ * Revision 1.1 2006/08/23 13:09:55 vfrolov * Initial revision * * */ #include "precomp.h" #include <wmidata.h> #include <wmilib.h> #pragma warning(push, 3) #include <wmistr.h> #pragma warning(pop) #include "strutils.h" #include "commprop.h" /* * FILE_ID used by HALT_UNLESS to put it on BSOD */ #define FILE_ID 0xB GUID guidWmiPortName = SERIAL_PORT_WMI_NAME_GUID; GUID guidWmiPortComm = SERIAL_PORT_WMI_COMM_GUID; GUID guidWmiPortHW = SERIAL_PORT_WMI_HW_GUID; GUID guidWmiPortPerf = SERIAL_PORT_WMI_PERF_GUID; GUID guidWmiPortProperties = SERIAL_PORT_WMI_PROPERTIES_GUID; #define COC_WMI_PORT_NAME 0 #define COC_WMI_PORT_COMM 1 #define COC_WMI_PORT_HW 2 #define COC_WMI_PORT_PERF 3 #define COC_WMI_PORT_PROPERTIES 4 #define COC_WMI_LIST_SIZE 5 WMIGUIDREGINFO guidWmiList[COC_WMI_LIST_SIZE] = { {&guidWmiPortName, 1, 0}, {&guidWmiPortComm, 1, 0}, {&guidWmiPortHW, 1, 0}, {&guidWmiPortPerf, 1, 0}, {&guidWmiPortProperties, 1, 0}, }; NTSTATUS QueryWmiRegInfo( IN PDEVICE_OBJECT pDevObj, OUT PULONG pRegFlags, OUT PUNICODE_STRING pInstanceName, OUT PUNICODE_STRING *ppRegistryPath, OUT PUNICODE_STRING pMofResourceName, OUT PDEVICE_OBJECT *ppPhDevObj) { PC0C_FDOPORT_EXTENSION pDevExt = (PC0C_FDOPORT_EXTENSION)pDevObj->DeviceExtension; UNREFERENCED_PARAMETER(pInstanceName); UNREFERENCED_PARAMETER(pMofResourceName); Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"QueryWmiRegInfo"); *ppRegistryPath = &c0cGlobal.registryPath; *pRegFlags = WMIREG_FLAG_INSTANCE_PDO; *ppPhDevObj = pDevExt->pPhDevObj; return STATUS_SUCCESS; } NTSTATUS QueryWmiDataBlock( IN PDEVICE_OBJECT pDevObj, IN PIRP pIrp, IN ULONG guidIndex, IN ULONG instanceIndex, IN ULONG instanceCount, IN OUT PULONG pInstanceLengthArray, IN ULONG bufSize, OUT PUCHAR pBuf) { NTSTATUS status; ULONG size; KIRQL oldIrql; PC0C_FDOPORT_EXTENSION pDevExt = (PC0C_FDOPORT_EXTENSION)pDevObj->DeviceExtension; UNREFERENCED_PARAMETER(instanceIndex); UNREFERENCED_PARAMETER(instanceCount); switch(guidIndex) { case COC_WMI_PORT_NAME: Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"QueryWmiDataBlock PORT_NAME"); size = wcslen(pDevExt->portName) * sizeof(pDevExt->portName[0]); if (bufSize < (size + sizeof(USHORT))) { size += sizeof(USHORT); status = STATUS_BUFFER_TOO_SMALL; break; } *(USHORT *)pBuf = (USHORT)size; RtlCopyMemory(pBuf + sizeof(USHORT), pDevExt->portName, size); size += sizeof(USHORT); status = STATUS_SUCCESS; break; case COC_WMI_PORT_COMM: Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"QueryWmiDataBlock PORT_COMM"); size = sizeof(SERIAL_WMI_COMM_DATA); if (bufSize < size) { status = STATUS_BUFFER_TOO_SMALL; break; } KeAcquireSpinLock(&pDevExt->controlLock, &oldIrql); ((PSERIAL_WMI_COMM_DATA)pBuf)->BaudRate = pDevExt->baudRate.BaudRate; ((PSERIAL_WMI_COMM_DATA)pBuf)->BitsPerByte = pDevExt->lineControl.WordLength; ((PSERIAL_WMI_COMM_DATA)pBuf)->ParityCheckEnable = TRUE; switch (pDevExt->lineControl.Parity) { default: case NO_PARITY: ((PSERIAL_WMI_COMM_DATA)pBuf)->Parity = SERIAL_WMI_PARITY_NONE; ((PSERIAL_WMI_COMM_DATA)pBuf)->ParityCheckEnable = FALSE; break; case ODD_PARITY: ((PSERIAL_WMI_COMM_DATA)pBuf)->Parity = SERIAL_WMI_PARITY_ODD; break; case EVEN_PARITY: ((PSERIAL_WMI_COMM_DATA)pBuf)->Parity = SERIAL_WMI_PARITY_EVEN; break; case MARK_PARITY: ((PSERIAL_WMI_COMM_DATA)pBuf)->Parity = SERIAL_WMI_PARITY_MARK; break; case SPACE_PARITY: ((PSERIAL_WMI_COMM_DATA)pBuf)->Parity = SERIAL_WMI_PARITY_SPACE; break; } switch (pDevExt->lineControl.StopBits) { default: case STOP_BIT_1: ((PSERIAL_WMI_COMM_DATA)pBuf)->StopBits = SERIAL_WMI_STOP_1; break; case STOP_BITS_1_5: ((PSERIAL_WMI_COMM_DATA)pBuf)->StopBits = SERIAL_WMI_STOP_1_5; break; case STOP_BITS_2: ((PSERIAL_WMI_COMM_DATA)pBuf)->StopBits = SERIAL_WMI_STOP_2; break; } KeReleaseSpinLock(&pDevExt->controlLock, oldIrql); KeAcquireSpinLock(pDevExt->pIoPortLocal->pIoLock, &oldIrql); ((PSERIAL_WMI_COMM_DATA)pBuf)->XoffCharacter = pDevExt->pIoPortLocal->specialChars.XoffChar; ((PSERIAL_WMI_COMM_DATA)pBuf)->XoffXmitThreshold = pDevExt->pIoPortLocal->handFlow.XoffLimit; ((PSERIAL_WMI_COMM_DATA)pBuf)->XonCharacter = pDevExt->pIoPortLocal->specialChars.XonChar; ((PSERIAL_WMI_COMM_DATA)pBuf)->XonXmitThreshold = pDevExt->pIoPortLocal->handFlow.XonLimit; KeReleaseSpinLock(pDevExt->pIoPortLocal->pIoLock, oldIrql); ((PSERIAL_WMI_COMM_DATA)pBuf)->MaximumBaudRate = 128L * 1024L; ((PSERIAL_WMI_COMM_DATA)pBuf)->MaximumOutputBufferSize = (ULONG)-1L; ((PSERIAL_WMI_COMM_DATA)pBuf)->MaximumInputBufferSize = (ULONG)-1L; ((PSERIAL_WMI_COMM_DATA)pBuf)->Support16BitMode = FALSE; ((PSERIAL_WMI_COMM_DATA)pBuf)->SupportDTRDSR = TRUE; ((PSERIAL_WMI_COMM_DATA)pBuf)->SupportIntervalTimeouts = TRUE; ((PSERIAL_WMI_COMM_DATA)pBuf)->SupportParityCheck = TRUE; ((PSERIAL_WMI_COMM_DATA)pBuf)->SupportRTSCTS = TRUE; ((PSERIAL_WMI_COMM_DATA)pBuf)->SupportXonXoff = TRUE; ((PSERIAL_WMI_COMM_DATA)pBuf)->SettableBaudRate = TRUE; ((PSERIAL_WMI_COMM_DATA)pBuf)->SettableDataBits = TRUE; ((PSERIAL_WMI_COMM_DATA)pBuf)->SettableFlowControl = TRUE; ((PSERIAL_WMI_COMM_DATA)pBuf)->SettableParity = TRUE; ((PSERIAL_WMI_COMM_DATA)pBuf)->SettableParityCheck = TRUE; ((PSERIAL_WMI_COMM_DATA)pBuf)->SettableStopBits = TRUE; ((PSERIAL_WMI_COMM_DATA)pBuf)->IsBusy = (BOOLEAN)pDevExt->openCount; status = STATUS_SUCCESS; break; case COC_WMI_PORT_HW: Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"QueryWmiDataBlock PORT_HW"); size = sizeof(SERIAL_WMI_HW_DATA); if (bufSize < size) { status = STATUS_BUFFER_TOO_SMALL; break; } RtlZeroMemory((PSERIAL_WMI_HW_DATA)pBuf, size); status = STATUS_SUCCESS; break; case COC_WMI_PORT_PERF: Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"QueryWmiDataBlock PORT_PERF"); size = sizeof(SERIAL_WMI_PERF_DATA); if (bufSize < size) { status = STATUS_BUFFER_TOO_SMALL; break; } KeAcquireSpinLock(pDevExt->pIoPortLocal->pIoLock, &oldIrql); ((PSERIAL_WMI_PERF_DATA)pBuf)->ReceivedCount = pDevExt->pIoPortLocal->perfStats.ReceivedCount; ((PSERIAL_WMI_PERF_DATA)pBuf)->TransmittedCount = pDevExt->pIoPortLocal->perfStats.TransmittedCount; ((PSERIAL_WMI_PERF_DATA)pBuf)->FrameErrorCount = pDevExt->pIoPortLocal->perfStats.FrameErrorCount; ((PSERIAL_WMI_PERF_DATA)pBuf)->SerialOverrunErrorCount = pDevExt->pIoPortLocal->perfStats.SerialOverrunErrorCount; ((PSERIAL_WMI_PERF_DATA)pBuf)->BufferOverrunErrorCount = pDevExt->pIoPortLocal->perfStats.BufferOverrunErrorCount; ((PSERIAL_WMI_PERF_DATA)pBuf)->ParityErrorCount = pDevExt->pIoPortLocal->perfStats.ParityErrorCount; KeReleaseSpinLock(pDevExt->pIoPortLocal->pIoLock, oldIrql); status = STATUS_SUCCESS; break; case COC_WMI_PORT_PROPERTIES: Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"QueryWmiDataBlock PORT_PROPERTIES"); status = GetCommProp(pDevExt, pBuf, bufSize, &size); break; default: Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"QueryWmiDataBlock ???"); size = 0; status = STATUS_WMI_GUID_NOT_FOUND; } if (status == STATUS_SUCCESS) *pInstanceLengthArray = size; status = WmiCompleteRequest(pDevObj, pIrp, status, size, IO_NO_INCREMENT); return status; } NTSTATUS SetWmiDataBlock( IN PDEVICE_OBJECT pDevObj, IN PIRP pIrp, IN ULONG guidIndex, IN ULONG instanceIndex, IN ULONG bufSize, IN PUCHAR pBuf) { NTSTATUS status; ULONG size = 0; UNREFERENCED_PARAMETER(guidIndex); UNREFERENCED_PARAMETER(instanceIndex); UNREFERENCED_PARAMETER(bufSize); UNREFERENCED_PARAMETER(pBuf); Trace0((PC0C_COMMON_EXTENSION)pDevObj->DeviceExtension, L"SetWmiDataBlock"); status = STATUS_WMI_GUID_NOT_FOUND; status = WmiCompleteRequest(pDevObj, pIrp, status, size, IO_NO_INCREMENT); return status; } NTSTATUS SetWmiDataItem( IN PDEVICE_OBJECT pDevObj, IN PIRP pIrp, IN ULONG guidIndex, IN ULONG instanceIndex, IN ULONG dataItemId, IN ULONG bufSize, IN PUCHAR pBuf) { NTSTATUS status; ULONG size = 0; UNREFERENCED_PARAMETER(guidIndex); UNREFERENCED_PARAMETER(instanceIndex); UNREFERENCED_PARAMETER(dataItemId); UNREFERENCED_PARAMETER(bufSize); UNREFERENCED_PARAMETER(pBuf); Trace0((PC0C_COMMON_EXTENSION)pDevObj->DeviceExtension, L"SetWmiDataItem"); status = STATUS_WMI_GUID_NOT_FOUND; status = WmiCompleteRequest(pDevObj, pIrp, status, size, IO_NO_INCREMENT); return status; } WMILIB_CONTEXT wmiLibContext = { COC_WMI_LIST_SIZE, guidWmiList, QueryWmiRegInfo, QueryWmiDataBlock, SetWmiDataBlock, SetWmiDataItem, NULL /*ExecuteWmiMethod*/, NULL /*WmiFunctionControl*/ }; NTSTATUS FdoPortWmi( IN PC0C_FDOPORT_EXTENSION pDevExt, IN PIRP pIrp) { NTSTATUS status; SYSCTL_IRP_DISPOSITION disposition; status = WmiSystemControl(&wmiLibContext, pDevExt->pDevObj, pIrp, &disposition); switch(disposition) { case IrpProcessed: Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"IrpProcessed"); break; case IrpNotCompleted: TraceCode((PC0C_COMMON_EXTENSION)pDevExt, "IrpNotCompleted ", NULL, (ULONG)IoGetCurrentIrpStackLocation(pIrp)->Parameters.WMI.DataPath, &status); IoCompleteRequest(pIrp, IO_NO_INCREMENT); break; case IrpForward: Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"IrpForward"); goto forward; case IrpNotWmi: Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"IrpNotWmi"); goto forward; default: Trace0((PC0C_COMMON_EXTENSION)pDevExt, L"Irp???"); goto forward; forward: IoSkipCurrentIrpStackLocation(pIrp); status = IoCallDriver(pDevExt->pLowDevObj, pIrp); } return status; } NTSTATUS c0cSystemControlDispatch(IN PDEVICE_OBJECT pDevObj, IN PIRP pIrp) { NTSTATUS status; PC0C_COMMON_EXTENSION pDevExt = pDevObj->DeviceExtension; #if DBG ULONG code = IoGetCurrentIrpStackLocation(pIrp)->MinorFunction; #endif /* DBG */ HALT_UNLESS2(IoGetCurrentIrpStackLocation(pIrp)->MajorFunction == IRP_MJ_SYSTEM_CONTROL, IoGetCurrentIrpStackLocation(pIrp)->MajorFunction, IoGetCurrentIrpStackLocation(pIrp)->MinorFunction); TraceIrp("c0cSystemControlDispatch", pIrp, NULL, TRACE_FLAG_PARAMS); status = STATUS_NO_SUCH_DEVICE; switch (pDevExt->doType) { case C0C_DOTYPE_FP: status = FdoPortWmi((PC0C_FDOPORT_EXTENSION)pDevExt, pIrp); break; case C0C_DOTYPE_FB: IoSkipCurrentIrpStackLocation(pIrp); status = IoCallDriver(((PC0C_COMMON_FDO_EXTENSION)pDevExt)->pLowDevObj, pIrp); break; case C0C_DOTYPE_PP: status = STATUS_NOT_SUPPORTED; default: pIrp->IoStatus.Status = status; IoCompleteRequest(pIrp, IO_NO_INCREMENT); } #if DBG if (status != STATUS_SUCCESS) TraceCode(pDevExt, "WMI_", codeNameTableWmi, code, &status); #endif /* DBG */ return status; } |
From: Vyacheslav F. <vf...@us...> - 2006-08-23 13:09:20
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv26115 Added Files: commprop.c commprop.h Log Message: Initial revision --- NEW FILE: commprop.c --- /* * $Id: commprop.c,v 1.1 2006/08/23 13:09:15 vfrolov Exp $ * * Copyright (c) 2006 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * $Log: commprop.c,v $ * Revision 1.1 2006/08/23 13:09:15 vfrolov * Initial revision * * */ #include "precomp.h" #include "commprop.h" NTSTATUS GetCommProp( PC0C_FDOPORT_EXTENSION pDevExt, PVOID pBuf, ULONG bufSize, PULONG pSize) { *pSize = sizeof(SERIAL_COMMPROP); if (bufSize < sizeof(SERIAL_COMMPROP)) return STATUS_BUFFER_TOO_SMALL; RtlZeroMemory(pBuf, sizeof(SERIAL_COMMPROP)); ((PSERIAL_COMMPROP)pBuf)->PacketLength = sizeof(SERIAL_COMMPROP); ((PSERIAL_COMMPROP)pBuf)->PacketVersion = 2; ((PSERIAL_COMMPROP)pBuf)->ServiceMask = SERIAL_SP_SERIALCOMM; ((PSERIAL_COMMPROP)pBuf)->MaxTxQueue = 0; ((PSERIAL_COMMPROP)pBuf)->MaxRxQueue = 0; ((PSERIAL_COMMPROP)pBuf)->MaxBaud = SERIAL_BAUD_USER; ((PSERIAL_COMMPROP)pBuf)->SettableBaud = SERIAL_BAUD_075 | SERIAL_BAUD_110 | SERIAL_BAUD_134_5 | SERIAL_BAUD_150 | SERIAL_BAUD_300 | SERIAL_BAUD_600 | SERIAL_BAUD_1200 | SERIAL_BAUD_1800 | SERIAL_BAUD_2400 | SERIAL_BAUD_4800 | SERIAL_BAUD_7200 | SERIAL_BAUD_9600 | SERIAL_BAUD_14400 | SERIAL_BAUD_19200 | SERIAL_BAUD_38400 | SERIAL_BAUD_56K | SERIAL_BAUD_128K | SERIAL_BAUD_115200 | SERIAL_BAUD_57600 | SERIAL_BAUD_USER; ((PSERIAL_COMMPROP)pBuf)->ProvSubType = SERIAL_SP_RS232; ((PSERIAL_COMMPROP)pBuf)->ProvCapabilities = SERIAL_PCF_DTRDSR | SERIAL_PCF_RTSCTS | SERIAL_PCF_CD | SERIAL_PCF_PARITY_CHECK | SERIAL_PCF_XONXOFF | SERIAL_PCF_SETXCHAR | SERIAL_PCF_TOTALTIMEOUTS | SERIAL_PCF_INTTIMEOUTS; ((PSERIAL_COMMPROP)pBuf)->SettableParams = SERIAL_SP_PARITY | SERIAL_SP_BAUD | SERIAL_SP_DATABITS | SERIAL_SP_STOPBITS | SERIAL_SP_HANDSHAKING | SERIAL_SP_PARITY_CHECK | SERIAL_SP_CARRIER_DETECT; ((PSERIAL_COMMPROP)pBuf)->SettableData = SERIAL_DATABITS_5 | SERIAL_DATABITS_6 | SERIAL_DATABITS_7 | SERIAL_DATABITS_8; ((PSERIAL_COMMPROP)pBuf)->SettableStopParity = SERIAL_STOPBITS_10 | SERIAL_STOPBITS_15 | SERIAL_STOPBITS_20 | SERIAL_PARITY_NONE | SERIAL_PARITY_ODD | SERIAL_PARITY_EVEN | SERIAL_PARITY_MARK | SERIAL_PARITY_SPACE; ((PSERIAL_COMMPROP)pBuf)->CurrentTxQueue = 0; ((PSERIAL_COMMPROP)pBuf)->CurrentRxQueue = (ULONG)C0C_BUFFER_SIZE(&pDevExt->pIoPortLocal->readBuf); return STATUS_SUCCESS; } --- NEW FILE: commprop.h --- /* * $Id: commprop.h,v 1.1 2006/08/23 13:09:15 vfrolov Exp $ * * Copyright (c) 2006 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * $Log: commprop.h,v $ * Revision 1.1 2006/08/23 13:09:15 vfrolov * Initial revision * * */ #ifndef _C0C_COMMPROP_H_ #define _C0C_COMMPROP_H_ NTSTATUS GetCommProp( PC0C_FDOPORT_EXTENSION pDevExt, PVOID pBuf, ULONG bufSize, PULONG pSize); #endif /* _C0C_COMMPROP_H_ */ |
From: Vyacheslav F. <vf...@us...> - 2006-08-23 13:05:46
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv24627 Modified Files: trace.c Log Message: Added ability to trace w/o table Added tracing IRP_MN_QUERY_ID result Added tracing GUID for IRP_MN_QUERY_INTERFACE Added tracing WMI Index: trace.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/trace.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** trace.c 8 Jun 2006 11:30:52 -0000 1.20 --- trace.c 23 Aug 2006 13:05:43 -0000 1.21 *************** *** 20,23 **** --- 20,29 ---- * * $Log$ + * Revision 1.21 2006/08/23 13:05:43 vfrolov + * Added ability to trace w/o table + * Added tracing IRP_MN_QUERY_ID result + * Added tracing GUID for IRP_MN_QUERY_INTERFACE + * Added tracing WMI + * * Revision 1.20 2006/06/08 11:30:52 vfrolov * Added params check to Trace0() and Trace00() *************** *** 525,528 **** --- 531,537 ---- IN PCODE2NAME pTable) { + if (!pTable) + return NULL; + while (pTable->name) { if (pTable->code == code) *************** *** 607,621 **** pDestStr = AnsiStrCopyStr(pDestStr, pSize, "["); ! while (pTable->name) { ! ULONG m = (mask & pTable->mask); ! if (m == pTable->code) { ! mask &= ~pTable->mask; ! if (count) ! pDestStr = AnsiStrCopyStr(pDestStr, pSize, "|"); ! pDestStr = AnsiStrCopyStr(pDestStr, pSize, pTable->name); ! count++; } - pTable++; } --- 616,632 ---- pDestStr = AnsiStrCopyStr(pDestStr, pSize, "["); ! if (pTable) { ! while (pTable->name) { ! ULONG m = (mask & pTable->mask); ! if (m == pTable->code) { ! mask &= ~pTable->mask; ! if (count) ! pDestStr = AnsiStrCopyStr(pDestStr, pSize, "|"); ! pDestStr = AnsiStrCopyStr(pDestStr, pSize, pTable->name); ! count++; ! } ! pTable++; } } *************** *** 1256,1259 **** --- 1267,1271 ---- case IRP_MJ_PNP: case IRP_MJ_POWER: + case IRP_MJ_SYSTEM_CONTROL: break; default: *************** *** 1419,1422 **** --- 1431,1439 ---- pIrpStack->Parameters.QueryId.IdType, codeNameTableBusQuery, "BusQuery", 10); + if (flags & TRACE_FLAG_RESULTS && pIrp->IoStatus.Information) { + pDestStr = AnsiStrFormat(pDestStr, &size, + " Information: \"%S\"", + (PWCHAR)pIrp->IoStatus.Information); + } break; case IRP_MN_QUERY_DEVICE_TEXT: *************** *** 1441,1444 **** --- 1458,1478 ---- (unsigned)((PDEVICE_RELATIONS)pIrp->IoStatus.Information)->Count); } + break; + case IRP_MN_QUERY_INTERFACE: + pDestStr = AnsiStrCopyStr(pDestStr, &size, " "); + pDestStr = AnsiStrFormat(pDestStr, &size, + " GUID: %8lX-%4X-%4X-%2X%2X-%2X%2X%2X%2X%2X%2X", + (long)pIrpStack->Parameters.QueryInterface.InterfaceType->Data1, + (int)pIrpStack->Parameters.QueryInterface.InterfaceType->Data2, + (int)pIrpStack->Parameters.QueryInterface.InterfaceType->Data3, + (int)pIrpStack->Parameters.QueryInterface.InterfaceType->Data4[0], + (int)pIrpStack->Parameters.QueryInterface.InterfaceType->Data4[1], + (int)pIrpStack->Parameters.QueryInterface.InterfaceType->Data4[2], + (int)pIrpStack->Parameters.QueryInterface.InterfaceType->Data4[3], + (int)pIrpStack->Parameters.QueryInterface.InterfaceType->Data4[4], + (int)pIrpStack->Parameters.QueryInterface.InterfaceType->Data4[5], + (int)pIrpStack->Parameters.QueryInterface.InterfaceType->Data4[6], + (int)pIrpStack->Parameters.QueryInterface.InterfaceType->Data4[7]); + break; } break; *************** *** 1451,1454 **** --- 1485,1495 ---- break; } + case IRP_MJ_SYSTEM_CONTROL: { + ULONG code = pIrpStack->MinorFunction; + + pDestStr = AnsiStrCopyStr(pDestStr, &size, " "); + pDestStr = AnsiStrCopyCode(pDestStr, &size, code, codeNameTableWmi, "WMI_", 10); + break; + } case IRP_MJ_QUERY_INFORMATION: { ULONG code = pIrpStack->Parameters.QueryFile.FileInformationClass; |
From: Vyacheslav F. <vf...@us...> - 2006-08-23 12:56:32
|
Update of /cvsroot/com0com/com0com/sys In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv21224 Modified Files: trace.h tracetbl.c Log Message: Added codeNameTableWmi Index: trace.h =================================================================== RCS file: /cvsroot/com0com/com0com/sys/trace.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** trace.h 19 May 2006 15:02:03 -0000 1.9 --- trace.h 23 Aug 2006 12:56:20 -0000 1.10 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.10 2006/08/23 12:56:20 vfrolov + * Added codeNameTableWmi + * * Revision 1.9 2006/05/19 15:02:03 vfrolov * Implemented IOCTL_SERIAL_GET_MODEM_CONTROL *************** *** 119,122 **** --- 122,126 ---- CODE2NAME codeNameTablePnp[]; CODE2NAME codeNameTablePower[]; + CODE2NAME codeNameTableWmi[]; CODE2NAME codeNameTableDoType[]; CODE2NAME codeNameTableModemStatus[]; Index: tracetbl.c =================================================================== RCS file: /cvsroot/com0com/com0com/sys/tracetbl.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tracetbl.c 23 Jun 2006 07:38:39 -0000 1.8 --- tracetbl.c 23 Aug 2006 12:56:20 -0000 1.9 *************** *** 20,23 **** --- 20,26 ---- * * $Log$ + * Revision 1.9 2006/08/23 12:56:20 vfrolov + * Added codeNameTableWmi + * * Revision 1.8 2006/06/23 07:38:39 vfrolov * Added STATUS_DEVICE_BUSY *************** *** 171,174 **** --- 174,191 ---- }; + CODE2NAME codeNameTableWmi[] = { + TOCODE2NAME(IRP_MN_, QUERY_ALL_DATA), + TOCODE2NAME(IRP_MN_, QUERY_SINGLE_INSTANCE), + TOCODE2NAME(IRP_MN_, CHANGE_SINGLE_INSTANCE), + TOCODE2NAME(IRP_MN_, CHANGE_SINGLE_ITEM), + TOCODE2NAME(IRP_MN_, ENABLE_EVENTS), + TOCODE2NAME(IRP_MN_, DISABLE_EVENTS), + TOCODE2NAME(IRP_MN_, ENABLE_COLLECTION), + TOCODE2NAME(IRP_MN_, DISABLE_COLLECTION), + TOCODE2NAME(IRP_MN_, REGINFO), + TOCODE2NAME(IRP_MN_, EXECUTE_METHOD), + {0, NULL} + }; + CODE2NAME codeNameTableDoType[] = { TOCODE2NAME(C0C_DOTYPE_, FB), *************** *** 235,238 **** --- 252,256 ---- TOCODE2NAME(STATUS_, OBJECT_NAME_NOT_FOUND), TOCODE2NAME(STATUS_, DEVICE_BUSY), + TOCODE2NAME(STATUS_, WMI_GUID_NOT_FOUND), {0, NULL} }; |
From: Vyacheslav F. <vf...@us...> - 2006-07-28 20:58:28
|
Update of /cvsroot/com0com/com0com/setup In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv19123 Added Files: devutils.cpp msg.h setup.cpp makefile msg.cpp inffile.h sources setup.rc precomp.h setup.def params.h devutils.h utils.cpp inffile.cpp params.cpp utils.h Log Message: Initial revision --- NEW FILE: inffile.h --- /* * $Id: inffile.h,v 1.1 2006/07/28 12:16:42 vfrolov Exp $ * * Copyright (c) 2006 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * $Log: inffile.h,v $ * Revision 1.1 2006/07/28 12:16:42 vfrolov * Initial revision * * */ #ifndef _C0C_INFFILE_H_ #define _C0C_INFFILE_H_ class InfFile { public: InfFile(const char *pInfName, const char *pNearPath); ~InfFile(); const char *Path() const { return pPath; } const char *ClassGUID() const; const char *Class() const; const char *Provider() const; BOOL Compare( const char *_pClassGUID, const char *_pClass, const char *_pProvider) const; BOOL UninstallFiles(const char *pFilesSection) const; BOOL InstallOEMInf() const; BOOL UninstallOEMInf() const; protected: char *pPath; char *pClassGUID; char *pClass; char *pProvider; }; #endif /* _C0C_PARAMS_H_ */ --- NEW FILE: msg.cpp --- /* * $Id: msg.cpp,v 1.1 2006/07/28 12:16:42 vfrolov Exp $ * * Copyright (c) 2006 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * $Log: msg.cpp,v $ * Revision 1.1 2006/07/28 12:16:42 vfrolov * Initial revision * * */ #include "precomp.h" #include "msg.h" #include "utils.h" /////////////////////////////////////////////////////////////// static int ShowMsgDefault(LPCSTR pText, LPCSTR pCaption, UINT type) { return MessageBox(NULL, pText, pCaption, type); } static int (* pShowMsg)(LPCSTR pText, LPCSTR pCaption, UINT type) = ShowMsgDefault; /////////////////////////////////////////////////////////////// static void ConsoleWriteReadDefault(LPSTR pReadBuf, DWORD lenReadBuf, LPCSTR pText) { static HANDLE handle = INVALID_HANDLE_VALUE; if (handle == INVALID_HANDLE_VALUE) { AllocConsole(); handle = GetStdHandle(STD_OUTPUT_HANDLE); } if (pText) WriteConsole(handle, pText, lstrlen(pText), NULL, NULL); if (pReadBuf && lenReadBuf > 0) { if (lenReadBuf > 1 && ReadConsole(GetStdHandle(STD_INPUT_HANDLE), pReadBuf, lenReadBuf - 1, &lenReadBuf, 0)) { pReadBuf[lenReadBuf] = 0; } else { pReadBuf[0] = 0; } } } static void (* pConsole)(LPSTR pReadBuf, DWORD lenReadBuf, LPCSTR pText) = ConsoleWriteReadDefault; /////////////////////////////////////////////////////////////// static void TraceDefault(LPCSTR pText) { pConsole(NULL, 0, pText); } static void (* pTrace)(LPCSTR pText) = TraceDefault; /////////////////////////////////////////////////////////////// static int ShowMsgVA(UINT type, const char *pFmt, va_list va) { char buf[1024]; VSNPRINTF(buf, sizeof(buf)/sizeof(buf[0]), pFmt, va); return pShowMsg(buf, NULL, type); } /////////////////////////////////////////////////////////////// static int ShowErrorVA(UINT type, DWORD err, const char *pFmt, va_list va) { char buf[1024]; VSNPRINTF(buf, sizeof(buf)/sizeof(buf[0]), pFmt, va); LPVOID pMsgBuf; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), (LPTSTR) &pMsgBuf, 0, NULL); int len = lstrlen(buf); SNPRINTF(buf + len, sizeof(buf)/sizeof(buf[0]) - len, "\nERROR: 0x%08lX - %s\n", (unsigned long)err, pMsgBuf); LocalFree(pMsgBuf); return pShowMsg(buf, NULL, type); } /////////////////////////////////////////////////////////////// int ShowMsg(UINT type, const char *pFmt, ...) { int res; va_list va; va_start(va, pFmt); res = ShowMsgVA(type, pFmt, va); va_end(va); return res; } /////////////////////////////////////////////////////////////// int ShowError(UINT type, DWORD err, const char *pFmt, ...) { int res; va_list va; va_start(va, pFmt); res = ShowErrorVA(type, err, pFmt, va); va_end(va); return res; } /////////////////////////////////////////////////////////////// int ShowLastError(UINT type, const char *pFmt, ...) { int res; DWORD err = GetLastError(); va_list va; va_start(va, pFmt); res = ShowErrorVA(type, err, pFmt, va); va_end(va); SetLastError(err); return res; } /////////////////////////////////////////////////////////////// void Trace(const char *pFmt, ...) { char buf[1024]; va_list va; va_start(va, pFmt); VSNPRINTF(buf, sizeof(buf)/sizeof(buf[0]), pFmt, va); va_end(va); pTrace(buf); } /////////////////////////////////////////////////////////////// void ConsoleWriteRead(char *pReadBuf, int lenReadBuf, const char *pFmt, ...) { char buf[1024]; va_list va; va_start(va, pFmt); VSNPRINTF(buf, sizeof(buf)/sizeof(buf[0]), pFmt, va); va_end(va); pConsole(pReadBuf, lenReadBuf, buf); } /////////////////////////////////////////////////////////////// --- NEW FILE: utils.h --- /* * $Id: utils.h,v 1.1 2006/07/28 12:16:43 vfrolov Exp $ * * Copyright (c) 2006 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * $Log: utils.h,v $ * Revision 1.1 2006/07/28 12:16:43 vfrolov * Initial revision * * */ #ifndef _C0C_UTILS_H_ #define _C0C_UTILS_H_ int VSNPRINTF(char *pBuf, int size, const char *pFmt, va_list va); int SNPRINTF(char *pBuf, int size, const char *pFmt, ...); #endif /* _C0C_UTILS_H_ */ --- NEW FILE: sources --- TARGETNAME=setup TARGETPATH=obj TARGETTYPE=DYNLINK MSC_WARNING_LEVEL=/W4 SOURCES= \ setup.cpp \ inffile.cpp \ params.cpp \ devutils.cpp \ msg.cpp \ utils.cpp \ setup.rc \ TARGETLIBS= \ $(DDK_LIB_PATH)\kernel32.lib \ $(DDK_LIB_PATH)\advapi32.lib \ $(DDK_LIB_PATH)\setupapi.lib \ $(DDK_LIB_PATH)\newdev.lib \ $(DDK_LIB_PATH)\user32.lib \ PRECOMPILED_INCLUDE=precomp.h PRECOMPILED_PCH=precomp.pch PRECOMPILED_OBJ=precomp.obj --- NEW FILE: params.h --- /* * $Id: params.h,v 1.1 2006/07/28 12:16:43 vfrolov Exp $ * * Copyright (c) 2006 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * $Log: params.h,v $ * Revision 1.1 2006/07/28 12:16:43 vfrolov * Initial revision * * */ #ifndef _C0C_PARAMS_H_ #define _C0C_PARAMS_H_ class PortParameters { public: PortParameters(const char *pService, const char *pPhPortName); void Init(); LONG Load(); LONG Save(); BOOL ParseParametersStr(const char *pParameters); BOOL FillParametersStr(char *pParameters, int size); BOOL Changed() const { return maskChanged != 0; } static const char *PortParameters::GetHelp(); protected: BOOL FillParametersKey(char *pRegKey, int size); BOOL SetPortName(const char *pNewPortName); BOOL SetEmuBR(const char *pNewEmuBR); BOOL SetEmuOverrun(const char *pNewEmuOverrun); DWORD maskChanged; DWORD maskExplicit; char portName[20]; DWORD emuBR; DWORD emuOverrun; char service[20]; char phPortName[20]; }; #endif /* _C0C_PARAMS_H_ */ --- NEW FILE: params.cpp --- /* * $Id: params.cpp,v 1.1 2006/07/28 12:16:43 vfrolov Exp $ * * Copyright (c) 2006 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * $Log: params.cpp,v $ * Revision 1.1 2006/07/28 12:16:43 vfrolov * Initial revision * * */ #include "precomp.h" #include "params.h" #include "utils.h" /////////////////////////////////////////////////////////////// enum { m_portName = 0x0001, m_emuBR = 0x0002, m_emuOverrun = 0x0004, }; /////////////////////////////////////////////////////////////// PortParameters::PortParameters(const char *pService, const char *pPhPortName) { SNPRINTF(service, sizeof(service), "%s", pService); SNPRINTF(phPortName, sizeof(phPortName), "%s", pPhPortName); Init(); } /////////////////////////////////////////////////////////////// void PortParameters::Init() { SNPRINTF(portName, sizeof(portName), "%s", phPortName); emuBR = 0; emuOverrun = 0; maskChanged = 0; maskExplicit = 0; } /////////////////////////////////////////////////////////////// BOOL PortParameters::SetPortName(const char *pNewPortName) { if (!lstrcmpi(pNewPortName, "*")) return TRUE; if (lstrcmpi(pNewPortName, "-")) { if ((maskExplicit & m_portName) == 0) { maskExplicit |= m_portName; maskChanged |= m_portName; } } else { pNewPortName = phPortName; if (maskExplicit & m_portName) { maskExplicit &= ~m_portName; maskChanged |= m_portName; } } if (lstrcmpi(portName, pNewPortName)) { lstrcpyn(portName, pNewPortName, sizeof(portName)); portName[sizeof(portName) - 1] = 0; maskChanged |= m_portName; } return TRUE; } /////////////////////////////////////////////////////////////// BOOL PortParameters::SetEmuBR(const char *pNewEmuBR) { if (!lstrcmpi(pNewEmuBR, "*")) return TRUE; DWORD newEmuBR; if (!lstrcmpi(pNewEmuBR, "yes")) { newEmuBR = 0xFFFFFFFF; } else if (!lstrcmpi(pNewEmuBR, "no")) { newEmuBR = 0; } else if (!lstrcmpi(pNewEmuBR, "-")) { newEmuBR = 0; } else { return FALSE; } if (lstrcmpi("-", pNewEmuBR)) { if ((maskExplicit & m_emuBR) == 0) { maskExplicit |= m_emuBR; maskChanged |= m_emuBR; } } else { if (maskExplicit & m_emuBR) { maskExplicit &= ~m_emuBR; maskChanged |= m_emuBR; } } if (emuBR != newEmuBR) { emuBR = newEmuBR; maskChanged |= m_emuBR; } return TRUE; } /////////////////////////////////////////////////////////////// BOOL PortParameters::SetEmuOverrun(const char *pNewEmuOverrun) { if (!lstrcmpi(pNewEmuOverrun, "*")) return TRUE; DWORD newEmuOverrun; if (!lstrcmpi(pNewEmuOverrun, "yes")) { newEmuOverrun = 0xFFFFFFFF; } else if (!lstrcmpi(pNewEmuOverrun, "no")) { newEmuOverrun = 0; } else if (!lstrcmpi(pNewEmuOverrun, "-")) { newEmuOverrun = 0; } else { return FALSE; } if (lstrcmpi("-", pNewEmuOverrun)) { if ((maskExplicit & m_emuOverrun) == 0) { maskExplicit |= m_emuOverrun; maskChanged |= m_emuOverrun; } } else { if (maskExplicit & m_emuOverrun) { maskExplicit &= ~m_emuOverrun; maskChanged |= m_emuOverrun; } } if (emuOverrun != newEmuOverrun) { emuOverrun = newEmuOverrun; maskChanged |= m_emuOverrun; } return TRUE; } /////////////////////////////////////////////////////////////// BOOL PortParameters::FillParametersKey(char *pRegKey, int size) { int len; len = SNPRINTF(pRegKey, size, REGSTR_PATH_SERVICES "\\%s\\Parameters\\%s", service, phPortName); //Trace("%s\n", pRegKey); return len >= 0; } /////////////////////////////////////////////////////////////// LONG PortParameters::Load() { Init(); char reqKey[100]; FillParametersKey(reqKey, sizeof(reqKey)); LONG err; HKEY hKey; err = RegOpenKeyEx(HKEY_LOCAL_MACHINE, reqKey, 0, KEY_READ, &hKey); if (err == ERROR_FILE_NOT_FOUND) return ERROR_SUCCESS; if (err != ERROR_SUCCESS) return err; char buf[20]; DWORD len; len = sizeof(buf); err = RegQueryValueEx(hKey, "PortName", NULL, NULL, (PBYTE)buf, &len); if (err == ERROR_SUCCESS) { SNPRINTF(portName, sizeof(portName), "%s", buf); maskExplicit |= m_portName; //Trace(" PortName=%s\n", portName); } len = sizeof(buf); err = RegQueryValueEx(hKey, "EmuBR", NULL, NULL, (PBYTE)buf, &len); if (err == ERROR_SUCCESS) { emuBR = *(PDWORD)buf; maskExplicit |= m_emuBR; //Trace(" EmuBR=0x%lX\n", (unsigned long)emuBR); } len = sizeof(buf); err = RegQueryValueEx(hKey, "EmuOverrun", NULL, NULL, (PBYTE)buf, &len); if (err == ERROR_SUCCESS) { emuOverrun = *(PDWORD)buf; maskExplicit |= m_emuOverrun; //Trace(" EmuOverrun=0x%lX\n", (unsigned long)emuOverrun); } RegCloseKey(hKey); return ERROR_SUCCESS; } /////////////////////////////////////////////////////////////// LONG PortParameters::Save() { if (!Changed()) { return ERROR_SUCCESS; } char reqKey[100]; FillParametersKey(reqKey, sizeof(reqKey)); LONG err; HKEY hKey; err = RegCreateKeyEx(HKEY_LOCAL_MACHINE, reqKey, 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL); if (err != ERROR_SUCCESS) return err; if (maskChanged & m_portName) { if (maskExplicit & m_portName) { err = RegSetValueEx(hKey, "PortName", NULL, REG_SZ, (PBYTE)portName, (lstrlen(portName) + 1) * sizeof(portName[0])); } else { err = RegDeleteValue(hKey, "PortName"); if (err == ERROR_FILE_NOT_FOUND) err = ERROR_SUCCESS; } if (err != ERROR_SUCCESS) goto err; maskChanged &= ~m_portName; //Trace(" New PortName=%s\n", portName); } if (maskChanged & m_emuBR) { if (maskExplicit & m_emuBR) { err = RegSetValueEx(hKey, "EmuBR", NULL, REG_DWORD, (PBYTE)&emuBR, sizeof(emuBR)); } else { err = RegDeleteValue(hKey, "EmuBR"); if (err == ERROR_FILE_NOT_FOUND) err = ERROR_SUCCESS; } if (err != ERROR_SUCCESS) goto err; maskChanged &= ~m_emuBR; //Trace(" New EmuBR=0x%lX\n", (unsigned long)emuBR); } if (maskChanged & m_emuOverrun) { if (maskExplicit & m_emuOverrun) { err = RegSetValueEx(hKey, "EmuOverrun", NULL, REG_DWORD, (PBYTE)&emuOverrun, sizeof(emuOverrun)); } else { err = RegDeleteValue(hKey, "EmuOverrun"); if (err == ERROR_FILE_NOT_FOUND) err = ERROR_SUCCESS; } if (err != ERROR_SUCCESS) goto err; maskChanged &= ~m_emuOverrun; //Trace(" New EmuOverrun=0x%lX\n", (unsigned long)emuOverrun); } err: RegCloseKey(hKey); return err; } /////////////////////////////////////////////////////////////// BOOL PortParameters::ParseParametersStr(const char *pParameters) { PortParameters tmp = *this; if (!lstrcmpi(pParameters, "-") || !lstrcmpi(pParameters, "*")) { if (!tmp.SetPortName(pParameters)) return FALSE; if (!tmp.SetEmuBR(pParameters)) return FALSE; if (!tmp.SetEmuOverrun(pParameters)) return FALSE; } else { char pars[100]; lstrcpyn(pars, pParameters, sizeof(pars)); pars[sizeof(pars) - 1] = 0; for (const char *pPar = strtok(pars, "=") ; pPar ; pPar = strtok(NULL, "=")) { const char *pVal = strtok(NULL, ","); //Trace("'%s'='%s'\n", pPar, pVal); if (!pVal) return FALSE; if (!lstrcmpi(pPar, "PortName")) { if (!tmp.SetPortName(pVal)) return FALSE; } else if (!lstrcmpi(pPar, "EmuBR")) { if (!tmp.SetEmuBR(pVal)) return FALSE; } else if (!lstrcmpi(pPar, "EmuOverrun")) { if (!tmp.SetEmuOverrun(pVal)) return FALSE; } else { return FALSE; } } } *this = tmp; return TRUE; } /////////////////////////////////////////////////////////////// BOOL PortParameters::FillParametersStr(char *pParameters, int size) { int len; len = SNPRINTF(pParameters, size, "PortName=%s,EmuBR=%s,EmuOverrun=%s", (maskExplicit & m_portName) ? (portName) : "-", (maskExplicit & m_emuBR) ? (emuBR ? "yes" : "no") : "-", (maskExplicit & m_emuOverrun) ? (emuOverrun ? "yes" : "no") : "-"); return len >= 0; } /////////////////////////////////////////////////////////////// const char *PortParameters::GetHelp() { return "Syntax of port parameters string:\n" " - - use driver's defaults for all parameters\n" " * - use current settings for all parameters\n" " <par>=<val>[,...] - set value <val> for each parameter <par>\n" "\n" "Parameters:\n" " PortName=<name> - set port name to <name>\n" " EmuBR={yes|no} - enable/disable baud rate emulation\n" " EmuOverrun={yes|no} - enable/disable buffer overrun\n" "\n" "Special values:\n" " - - use driver's default value\n" " * - use current setting\n" ; } /////////////////////////////////////////////////////////////// --- NEW FILE: setup.cpp --- /* * $Id: setup.cpp,v 1.1 2006/07/28 12:16:42 vfrolov Exp $ * * Copyright (c) 2006 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * $Log: setup.cpp,v $ * Revision 1.1 2006/07/28 12:16:42 vfrolov * Initial revision * * */ #include "precomp.h" #include "inffile.h" #include "params.h" #include "devutils.h" #include "msg.h" #include "utils.h" #define C0C_INF_NAME "com0com.inf" #define C0C_BUS_DEVICE_ID "root\\com0com" #define C0C_PORT_DEVICE_ID "com0com\\port" #define C0C_CLASS_GUID "{df799e12-3c56-421b-b298-b6d3642bc878}" #define C0C_CLASS "CNCPorts" #define C0C_PROVIDER "Vyacheslav Frolov" #define C0C_SERVICE "com0com" #define C0C_REGKEY_EVENTLOG REGSTR_PATH_SERVICES "\\Eventlog\\System\\" C0C_SERVICE #define C0C_COPY_DRIVERS_SECTION "com0com_CopyDrivers" /////////////////////////////////////////////////////////////// int Change(InfFile &infFile, const char *pPhPortName, const char *pParameters) { BOOL rebootRequired = FALSE; int numPairs = CountDevices(infFile, C0C_BUS_DEVICE_ID); //Trace("Found %d pairs\n", numPairs); for (int i = 0 ; i < numPairs ; i++) { for (int j = 0 ; j < 2 ; j++) { char phPortName[20]; SNPRINTF(phPortName, sizeof(phPortName), "CNC%c%d", j ? 'B' : 'A', i); PortParameters portParameters(C0C_SERVICE, phPortName); LONG err = portParameters.Load(); char buf[100]; portParameters.FillParametersStr(buf, sizeof(buf)); Trace(" %s %s\n", phPortName, buf); if (err == ERROR_SUCCESS) { if (pPhPortName && !lstrcmpi(pPhPortName, phPortName)) portParameters.ParseParametersStr(pParameters); if (portParameters.Changed()) { err = portParameters.Save(); if (err == ERROR_SUCCESS) { portParameters.FillParametersStr(buf, sizeof(buf)); Trace("change %s %s\n", phPortName, buf); RestartDevices(infFile, C0C_PORT_DEVICE_ID, phPortName, &rebootRequired); } else { ShowError(MB_OK|MB_ICONWARNING, err, "portParameters.Save(%s)", phPortName); } } } else { ShowError(MB_OK|MB_ICONWARNING, err, "portParameters.Load(%s)", phPortName); } } } if (rebootRequired) SetupPromptReboot(NULL, NULL, FALSE); return 0; } /////////////////////////////////////////////////////////////// int Preinstall(InfFile &infFile) { if (!infFile.InstallOEMInf()) return 1; int res; do { res = IDCONTINUE; if (SetupDiInstallClass(NULL, infFile.Path(), 0, NULL)) { Trace("Installed Class %s\n", infFile.ClassGUID()); } else { res = ShowLastError(MB_CANCELTRYCONTINUE, "SetupDiInstallClass()"); } } while (res == IDTRYAGAIN); if (res != IDCONTINUE) return 1; return 0; } /////////////////////////////////////////////////////////////// int Update(InfFile &infFile) { if (!UpdateDriverForPlugAndPlayDevices(0, C0C_BUS_DEVICE_ID, infFile.Path(), INSTALLFLAG_FORCE, NULL)) return 1; return 0; } /////////////////////////////////////////////////////////////// int Install(InfFile &infFile, const char *pParametersA, const char *pParametersB) { int i = CountDevices(infFile, C0C_BUS_DEVICE_ID); for (int j = 0 ; j < 2 ; j++) { char phPortName[20]; const char *pParameters; pParameters = j ? pParametersB : pParametersA; SNPRINTF(phPortName, sizeof(phPortName), "CNC%c%d", j ? 'B' : 'A', i); PortParameters portParameters(C0C_SERVICE, phPortName); LONG err = portParameters.Load(); if (err == ERROR_SUCCESS) { portParameters.ParseParametersStr(pParameters); if (portParameters.Changed()) { err = portParameters.Save(); if (err != ERROR_SUCCESS) ShowError(MB_OK|MB_ICONWARNING, err, "portParameters.Save(%s)", phPortName); } } else { ShowError(MB_OK|MB_ICONWARNING, err, "portParameters.Load(%s)", phPortName); } char buf[100]; portParameters.FillParametersStr(buf, sizeof(buf)); Trace(" %s %s\n", phPortName, buf); } if (!InstallDevice(infFile, C0C_BUS_DEVICE_ID)) return 1; return 0; } /////////////////////////////////////////////////////////////// int Uninstall(InfFile &infFile) { BOOL rebootRequired = FALSE; if (!DisableDevices(infFile, C0C_PORT_DEVICE_ID, &rebootRequired)) return 1; if (!RemoveDevices(infFile, C0C_BUS_DEVICE_ID, &rebootRequired)) return 1; if (!RemoveDevices(infFile, NULL, NULL)) return 1; if (rebootRequired) { SetupPromptReboot(NULL, NULL, FALSE); return 0; } int res; BOOL notDeleted; LONG err; do { notDeleted = TRUE; res = IDCONTINUE; SC_HANDLE hSCM = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); if (hSCM) { do { res = IDCONTINUE; SC_HANDLE hSrv = OpenService(hSCM, C0C_SERVICE, DELETE|SERVICE_QUERY_STATUS); if (hSrv) { SERVICE_STATUS srvStatus; if (QueryServiceStatus(hSrv, &srvStatus)) { if (srvStatus.dwCurrentState == SERVICE_STOPPED) { if (ShowMsg(MB_YESNO, "The deleting %s service will remove your manual settings.\n" "Would you like to delete service?\n", C0C_SERVICE) == IDYES) { if (DeleteService(hSrv)) { Trace("Deleted Service %s\n", C0C_SERVICE); notDeleted = FALSE; } else { res = ShowLastError(MB_CANCELTRYCONTINUE, "DeleteService(%s)", C0C_SERVICE); } } } else { res = ShowMsg(MB_CANCELTRYCONTINUE, "Service %s is not stopped (state %ld).", C0C_SERVICE, (long)srvStatus.dwCurrentState); } } else { res = ShowLastError(MB_CANCELTRYCONTINUE, "QueryServiceStatus(%s)", C0C_SERVICE); } if (!CloseServiceHandle(hSrv)) ShowLastError(MB_OK|MB_ICONWARNING, "CloseServiceHandle(hSrv)"); } else { if (GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST) { Trace("Service %s not installed\n", C0C_SERVICE); notDeleted = FALSE; } else { res = ShowLastError(MB_CANCELTRYCONTINUE, "OpenService(%s)", C0C_SERVICE); } } } while (res == IDTRYAGAIN); if (!CloseServiceHandle(hSCM)) ShowLastError(MB_OK|MB_ICONWARNING, "CloseServiceHandle(hSCM)"); } else { res = ShowLastError(MB_CANCELTRYCONTINUE, "OpenSCManager()"); } } while (res == IDTRYAGAIN); if (notDeleted) Trace("WARNING: Service %s not deleted\n", C0C_SERVICE); if (res != IDCONTINUE) return 1; do { notDeleted = TRUE; res = IDCONTINUE; err = RegDeleteKey(HKEY_LOCAL_MACHINE, C0C_REGKEY_EVENTLOG); if (err == ERROR_SUCCESS) { Trace("Deleted EventLog %s\n", C0C_SERVICE); notDeleted = FALSE; } else if (err == ERROR_FILE_NOT_FOUND) { Trace("EventLog %s not installed\n", C0C_SERVICE); notDeleted = FALSE; } else { res = ShowError(MB_CANCELTRYCONTINUE, err, "RegDeleteKey(%s)", C0C_REGKEY_EVENTLOG); } } while (res == IDTRYAGAIN); if (notDeleted) Trace("WARNING: Key %s not deleted\n", C0C_REGKEY_EVENTLOG); if (res != IDCONTINUE) return 1; do { notDeleted = TRUE; res = IDCONTINUE; HKEY hKey = SetupDiOpenClassRegKey(NULL, DELETE); if (hKey != INVALID_HANDLE_VALUE) { do { res = IDCONTINUE; err = RegDeleteKey(hKey, infFile.ClassGUID()); if (err == ERROR_SUCCESS) { Trace("Deleted Class %s\n", infFile.ClassGUID()); notDeleted = FALSE; } else if (err == ERROR_FILE_NOT_FOUND) { Trace("Class %s not installed\n", infFile.ClassGUID()); notDeleted = FALSE; } else { res = ShowError(MB_CANCELTRYCONTINUE, err, "RegDeleteKey(%s)", infFile.ClassGUID()); } } while (res == IDTRYAGAIN); err = RegCloseKey(hKey); if (err != ERROR_SUCCESS) ShowError(MB_OK|MB_ICONWARNING, err, "RegCloseKey()"); } else { res = ShowLastError(MB_CANCELTRYCONTINUE, "SetupDiOpenClassRegKey(NULL)"); } } while (res == IDTRYAGAIN); if (notDeleted) Trace("WARNING: Class %s not deleted\n", infFile.ClassGUID()); if (res != IDCONTINUE) return 1; if (!infFile.UninstallOEMInf()) return 1; if (!infFile.UninstallFiles(C0C_COPY_DRIVERS_SECTION)) return 1; return 0; } /////////////////////////////////////////////////////////////// int Help(const char *pProgName) { Trace( "Usage:\n" " %s <command>\n" , pProgName); Trace( "\n" "Commands:\n" " list - for each port show parameters\n" " change <port> <params> - set parameters for port\n" " install <params> <params> - install a pair of ports\n" " preinstall - install driver\n" " update - update driver\n" " uninstall - uninstall all pairs and driver\n" "\n" ); Trace( "\n" "%s", PortParameters::GetHelp()); Trace( "\n" "Examples:\n" ); Trace( " %s install - -\n" , pProgName); Trace( " %s install PortName=COM2 PortName=COM4\n" , pProgName); Trace( " %s change CNCA0 EmuBR=yes,EmuOverrun=yes\n" , pProgName); return 1; } /////////////////////////////////////////////////////////////// int Main(int argc, const char* argv[]) { InfFile infFile(C0C_INF_NAME, C0C_INF_NAME); if (!infFile.Compare(C0C_CLASS_GUID, C0C_CLASS, C0C_PROVIDER)) return 1; if (argc == 2 && !lstrcmpi(argv[1], "list")) { return Change(infFile, NULL, NULL); } else if (argc == 4 && !lstrcmpi(argv[1], "change")) { return Change(infFile, argv[2], argv[3]); } else if (argc == 4 && !lstrcmpi(argv[1], "install")) { return Install(infFile, argv[2], argv[3]); } else if (argc == 2 && !lstrcmpi(argv[1], "preinstall")) { return Preinstall(infFile); } else if (argc == 2 && !lstrcmpi(argv[1], "update")) { return Update(infFile); } else if (argc == 2 && !lstrcmpi(argv[1], "uninstall")) { return Uninstall(infFile); } return Help(argv[0]); } /////////////////////////////////////////////////////////////// int CALLBACK RunDllA(HWND /*hWnd*/, HINSTANCE /*hInst*/, LPSTR pCmdLine, int /*nCmdShow*/) { int argc; const char* argv[5]; argc = 0; argv[argc++] = "rundll32 setup,RunDll"; argv[argc] = NULL; char cmd[200]; lstrcpyn(cmd, pCmdLine, sizeof(cmd)/sizeof(cmd[0])); for (const char *pArg = strtok(cmd, " \t") ; pArg ; pArg = strtok(NULL, " \t")) { if ((argc + 2) > sizeof(argv)/sizeof(argv[0])) break; argv[argc++] = pArg; argv[argc] = NULL; } int res = Main(argc, argv); char buf[2]; ConsoleWriteRead(buf, sizeof(buf)/sizeof(buf[0]), "\nresult = %d\n\nPress <RETURN> to continue\n", res); return res; } /////////////////////////////////////////////////////////////// --- NEW FILE: makefile --- !INCLUDE $(NTMAKEENV)\makefile.def --- NEW FILE: devutils.cpp --- /* * $Id: devutils.cpp,v 1.1 2006/07/28 12:16:42 vfrolov Exp $ * * Copyright (c) 2006 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * $Log: devutils.cpp,v $ * Revision 1.1 2006/07/28 12:16:42 vfrolov * Initial revision * * */ #include "precomp.h" #include "inffile.h" #include "msg.h" #include "devutils.h" #include "utils.h" /////////////////////////////////////////////////////////////// struct EnumParams { EnumParams() { pDevId = NULL; pPhObjName = NULL; count = 0; pRebootRequired = NULL; } const char *pDevId; const char *pPhObjName; int count; BOOL *pRebootRequired; }; typedef EnumParams *PEnumParams; struct DevParams { DevParams(PEnumParams _pEnumParams) { pEnumParams = _pEnumParams; pDevId = NULL; pPhObjName = NULL; } PEnumParams pEnumParams; const char *pDevId; const char *pPhObjName; }; typedef DevParams *PDevParams; /////////////////////////////////////////////////////////////// static int EnumDevices( InfFile &infFile, DWORD flags, BOOL (* pFunk)(HDEVINFO, PSP_DEVINFO_DATA, PDevParams), PEnumParams pEnumParams) { HDEVINFO hDevInfo; hDevInfo = SetupDiGetClassDevs(NULL, NULL, NULL, DIGCF_ALLCLASSES|flags); if (hDevInfo == INVALID_HANDLE_VALUE) { ShowLastError(MB_OK|MB_ICONSTOP, "SetupDiGetClassDevs()"); return IDCANCEL; } SP_DEVINFO_DATA devInfoData; devInfoData.cbSize = sizeof(devInfoData); int res = IDCONTINUE; for (int i = 0 ; SetupDiEnumDeviceInfo(hDevInfo, i, &devInfoData) ; i++) { char classGUID[100]; if (!SetupDiGetDeviceRegistryProperty(hDevInfo, &devInfoData, SPDRP_CLASSGUID, NULL, (PBYTE)classGUID, sizeof(classGUID), NULL)) continue; if (lstrcmpi(classGUID, infFile.ClassGUID())) continue; char provider[100]; if (SetupDiGetDeviceRegistryProperty(hDevInfo, &devInfoData, SPDRP_MFG, NULL, (PBYTE)provider, sizeof(provider), NULL)) { // check provider if exists if (lstrcmpi(provider, infFile.Provider())) continue; } DevParams devParams(pEnumParams); char hwid[150]; if (SetupDiGetDeviceRegistryProperty(hDevInfo, &devInfoData, SPDRP_HARDWAREID, NULL, (PBYTE)hwid, sizeof(hwid), NULL)) devParams.pDevId = hwid; if (pEnumParams->pDevId && (!devParams.pDevId || lstrcmpi(devParams.pDevId, pEnumParams->pDevId))) continue; char name[150]; if (SetupDiGetDeviceRegistryProperty(hDevInfo, &devInfoData, SPDRP_PHYSICAL_DEVICE_OBJECT_NAME, NULL, (PBYTE)name, sizeof(name), NULL)) devParams.pPhObjName = name; if (pEnumParams->pPhObjName && (!devParams.pPhObjName || lstrcmpi(devParams.pPhObjName, pEnumParams->pPhObjName))) continue; res = pFunk(hDevInfo, &devInfoData, &devParams); if (res != IDCONTINUE) break; } DWORD err = GetLastError(); SetupDiDestroyDeviceInfoList(hDevInfo); SetLastError(err); return res; } /////////////////////////////////////////////////////////////// static BOOL UpdateRebootRequired(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pDevInfoData, BOOL *pRebootRequired) { if (!pRebootRequired) return TRUE; if (*pRebootRequired) return TRUE; SP_DEVINSTALL_PARAMS installParams; memset(&installParams, 0, sizeof(installParams)); installParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS); if (!SetupDiGetDeviceInstallParams(hDevInfo, pDevInfoData, &installParams)) { ShowLastError(MB_OK|MB_ICONSTOP, "SetupDiGetDeviceInstallParams()"); return FALSE; } *pRebootRequired = (installParams.Flags & DI_NEEDREBOOT) ? TRUE : FALSE; return TRUE; } /////////////////////////////////////////////////////////////// static BOOL ChangeState(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pDevInfoData, DWORD stateChange) { SP_PROPCHANGE_PARAMS propChangeParams; memset(&propChangeParams, 0, sizeof(propChangeParams)); propChangeParams.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER); propChangeParams.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE; propChangeParams.StateChange = stateChange; propChangeParams.Scope = DICS_FLAG_CONFIGSPECIFIC; propChangeParams.HwProfile = 0; if (!SetupDiSetClassInstallParams(hDevInfo, pDevInfoData, (SP_CLASSINSTALL_HEADER *)&propChangeParams, sizeof(propChangeParams))) { ShowLastError(MB_OK|MB_ICONSTOP, "SetupDiSetClassInstallParams()"); return FALSE; } if (!SetupDiCallClassInstaller(DIF_PROPERTYCHANGE, hDevInfo, pDevInfoData)) { ShowLastError(MB_OK|MB_ICONSTOP, "SetupDiCallClassInstaller(DIF_PROPERTYCHANGE)"); return FALSE; } return TRUE; } /////////////////////////////////////////////////////////////// static int CountDevice(HDEVINFO /*hDevInfo*/, PSP_DEVINFO_DATA /*pDevInfoData*/, PDevParams pDevParams) { //Trace("Counted %s %s\n", pDevParams->pDevId, pDevParams->pPhObjName); pDevParams->pEnumParams->count++; return IDCONTINUE; } int CountDevices( InfFile &infFile, const char *pDevId) { EnumParams enumParams; enumParams.pDevId = pDevId; if (EnumDevices(infFile, DIGCF_PRESENT, CountDevice, &enumParams) != IDCONTINUE) return -1; return enumParams.count; } /////////////////////////////////////////////////////////////// static int DisableDevice(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pDevInfoData, PDevParams pDevParams) { if (!ChangeState(hDevInfo, pDevInfoData, DICS_DISABLE)) return IDCANCEL; Trace("Disabled %s %s\n", pDevParams->pDevId, pDevParams->pPhObjName); pDevParams->pEnumParams->count++; if (pDevParams->pEnumParams->pRebootRequired && !*pDevParams->pEnumParams->pRebootRequired) { BOOL rebootRequired = FALSE; if (!UpdateRebootRequired(hDevInfo, pDevInfoData, &rebootRequired)) return IDCANCEL; if (rebootRequired) { int res = ShowMsg(MB_CANCELTRYCONTINUE, "Can't disable device %s %s.\n" "Close application that use this device and Try Again.\n" "Or Continue and then reboot system.\n", pDevParams->pDevId, pDevParams->pPhObjName); if (res != IDCONTINUE) { if (!ChangeState(hDevInfo, pDevInfoData, DICS_ENABLE)) return IDCANCEL; Trace("Enabled %s %s\n", pDevParams->pDevId, pDevParams->pPhObjName); pDevParams->pEnumParams->count--; return res; } *pDevParams->pEnumParams->pRebootRequired = TRUE; } } return IDCONTINUE; } BOOL DisableDevices( InfFile &infFile, const char *pDevId, BOOL *pRebootRequired) { EnumParams enumParams; int res; enumParams.pRebootRequired = pRebootRequired; enumParams.pDevId = pDevId; do { res = EnumDevices(infFile, DIGCF_PRESENT, DisableDevice, &enumParams); } while (res == IDTRYAGAIN); if (res != IDCONTINUE) return FALSE; Sleep(1000); return TRUE; } /////////////////////////////////////////////////////////////// static int RestartDevice(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pDevInfoData, PDevParams pDevParams) { if (!ChangeState(hDevInfo, pDevInfoData, DICS_PROPCHANGE)) return IDCANCEL; if (pDevParams->pEnumParams->pRebootRequired && !*pDevParams->pEnumParams->pRebootRequired) { BOOL rebootRequired = FALSE; if (!UpdateRebootRequired(hDevInfo, pDevInfoData, &rebootRequired)) return IDCANCEL; if (rebootRequired) { int res = ShowMsg(MB_CANCELTRYCONTINUE, "Can't reastart device %s %s.\n" "Close application that use this device and Try Again.\n" "Or Continue and then reboot system.\n", pDevParams->pDevId, pDevParams->pPhObjName); if (res != IDCONTINUE) { if (!ChangeState(hDevInfo, pDevInfoData, DICS_ENABLE)) return IDCANCEL; return res; } *pDevParams->pEnumParams->pRebootRequired = TRUE; } } if (!pDevParams->pEnumParams->pRebootRequired || !*pDevParams->pEnumParams->pRebootRequired) { Trace("Restarted %s %s\n", pDevParams->pDevId, pDevParams->pPhObjName); pDevParams->pEnumParams->count++; } return IDCONTINUE; } BOOL RestartDevices( InfFile &infFile, const char *pDevId, const char *pPhDevName, BOOL *pRebootRequired) { char phDevObjName[30]; if (SNPRINTF(phDevObjName, sizeof(phDevObjName), "\\Device\\%s", pPhDevName) < 0) return FALSE; phDevObjName[sizeof(phDevObjName) - 1] = 0; EnumParams enumParams; int res; enumParams.pRebootRequired = pRebootRequired; enumParams.pDevId = pDevId; enumParams.pPhObjName = phDevObjName; do { res = EnumDevices(infFile, DIGCF_PRESENT, RestartDevice, &enumParams); } while (res == IDTRYAGAIN); if (res != IDCONTINUE) return FALSE; return TRUE; } /////////////////////////////////////////////////////////////// static int RemoveDevice(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pDevInfoData, PDevParams pDevParams) { if (!SetupDiCallClassInstaller(DIF_REMOVE, hDevInfo, pDevInfoData)) { ShowLastError(MB_OK|MB_ICONSTOP, "SetupDiCallClassInstaller(DIF_REMOVE, %s, %s)", pDevParams->pDevId, pDevParams->pPhObjName); return IDCANCEL; } Trace("Removed %s %s\n", pDevParams->pDevId, pDevParams->pPhObjName); pDevParams->pEnumParams->count++; if (!UpdateRebootRequired(hDevInfo, pDevInfoData, pDevParams->pEnumParams->pRebootRequired)) return IDCANCEL; return IDCONTINUE; } BOOL RemoveDevices( InfFile &infFile, const char *pDevId, BOOL *pRebootRequired) { EnumParams enumParams; int res; enumParams.pRebootRequired = pRebootRequired; enumParams.pDevId = pDevId; do { res = EnumDevices(infFile, 0, RemoveDevice, &enumParams); } while (res == IDTRYAGAIN); if (res != IDCONTINUE) return FALSE; if (!enumParams.count) Trace("No devices found\n"); return TRUE; } /////////////////////////////////////////////////////////////// BOOL InstallDevice(InfFile &infFile, const char *pDevId) { GUID classGUID; char className[32]; if (!SetupDiGetINFClass(infFile.Path(), &classGUID, className, sizeof(className), 0)) { ShowLastError(MB_OK|MB_ICONSTOP, "SetupDiGetINFClass(%s)", infFile.Path()); return FALSE; } //Trace("className=%s\n", className); HDEVINFO hDevInfo; hDevInfo = SetupDiCreateDeviceInfoList(&classGUID, 0); if (hDevInfo == INVALID_HANDLE_VALUE) { ShowLastError(MB_OK|MB_ICONSTOP, "SetupDiCreateDeviceInfoList()"); return FALSE; } BOOL res; SP_DEVINFO_DATA devInfoData; devInfoData.cbSize = sizeof(devInfoData); res = SetupDiCreateDeviceInfo(hDevInfo, className, &classGUID, NULL, 0, DICD_GENERATE_ID, &devInfoData); if (!res) { ShowLastError(MB_OK|MB_ICONSTOP, "SetupDiCreateDeviceInfo()"); goto err; } char hardwareId[MAX_DEVICE_ID_LEN + 1 + 1]; memset(hardwareId, 0, sizeof(hardwareId)); lstrcpyn(hardwareId, pDevId, sizeof(hardwareId) - 1 - 1); int hardwareIdSize; hardwareIdSize = (lstrlen(hardwareId) + 1 + 1) * sizeof(hardwareId[0]); res = SetupDiSetDeviceRegistryProperty(hDevInfo, &devInfoData, SPDRP_HARDWAREID, (LPBYTE)hardwareId, hardwareIdSize); if (!res) { ShowLastError(MB_OK|MB_ICONSTOP, "SetupDiSetDeviceRegistryProperty()"); goto err; } res = SetupDiCallClassInstaller(DIF_REGISTERDEVICE, hDevInfo, &devInfoData); if (!res) { ShowLastError(MB_OK|MB_ICONSTOP, "SetupDiCallClassInstaller()"); goto err; } BOOL rebootRequired; res = UpdateDriverForPlugAndPlayDevices(0, pDevId, infFile.Path(), INSTALLFLAG_FORCE, &rebootRequired); if (!res) { ShowLastError(MB_OK|MB_ICONSTOP, "UpdateDriverForPlugAndPlayDevices()"); if (!SetupDiCallClassInstaller(DIF_REMOVE, hDevInfo, &devInfoData)) ShowLastError(MB_OK|MB_ICONWARNING, "SetupDiCallClassInstaller()"); goto err; } res = TRUE; err: SetupDiDestroyDeviceInfoList(hDevInfo); return res; } /////////////////////////////////////////////////////////////// --- NEW FILE: msg.h --- /* * $Id: msg.h,v 1.1 2006/07/28 12:16:42 vfrolov Exp $ * * Copyright (c) 2006 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * $Log: msg.h,v $ * Revision 1.1 2006/07/28 12:16:42 vfrolov * Initial revision * * */ #ifndef _C0C_MSG_H_ #define _C0C_MSG_H_ int ShowMsg(UINT type, const char *pFmt, ...); int ShowError(UINT type, DWORD err, const char *pFmt, ...); int ShowLastError(UINT type, const char *pFmt, ...); void Trace(const char *pFmt, ...); void ConsoleWriteRead(char *pReadBuf, int lenReadBuf, const char *pFmt, ...); #endif /* _C0C_MSG_H_ */ --- NEW FILE: precomp.h --- /* * $Id: precomp.h,v 1.1 2006/07/28 12:16:43 vfrolov Exp $ * * Copyright (c) 2006 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * $Log: precomp.h,v $ * Revision 1.1 2006/07/28 12:16:43 vfrolov * Initial revision * * */ #ifndef _PRECOMP_H_ #define _PRECOMP_H_ #include <windows.h> #include <newdev.h> #include <cfgmgr32.h> #include <regstr.h> #pragma warning(push, 3) #include <setupapi.h> #pragma warning(pop) #endif /* _PRECOMP_H_ */ --- NEW FILE: utils.cpp --- /* * $Id: utils.cpp,v 1.1 2006/07/28 12:16:43 vfrolov Exp $ * * Copyright (c) 2006 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * $Log: utils.cpp,v $ * Revision 1.1 2006/07/28 12:16:43 vfrolov * Initial revision * * */ #include "precomp.h" #include "utils.h" /////////////////////////////////////////////////////////////// int VSNPRINTF(char *pBuf, int size, const char *pFmt, va_list va) { char buf[1024]; int res1 = wvsprintf(buf, pFmt, va); buf[sizeof(buf)/sizeof(buf[0]) - 1] = 0; lstrcpyn(pBuf, buf, size); int res2 = lstrlen(pBuf); return res2 == res1 ? res1 : -1; } /////////////////////////////////////////////////////////////// int SNPRINTF(char *pBuf, int size, const char *pFmt, ...) { va_list va; va_start(va, pFmt); int res1 = VSNPRINTF(pBuf, size, pFmt, va); va_end(va); return res1; } /////////////////////////////////////////////////////////////// --- NEW FILE: setup.def --- LIBRARY C0CSETUP EXPORTS RunDllA --- NEW FILE: devutils.h --- /* * $Id: devutils.h,v 1.1 2006/07/28 12:16:43 vfrolov Exp $ * * Copyright (c) 2006 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * $Log: devutils.h,v $ * Revision 1.1 2006/07/28 12:16:43 vfrolov * Initial revision * * */ #ifndef _C0C_DEVUTILS_H_ #define _C0C_DEVUTILS_H_ class InfFile; int CountDevices( InfFile &infFile, const char *pDevId); BOOL DisableDevices( InfFile &infFile, const char *pDevId, BOOL *pRebootRequired); BOOL RestartDevices( InfFile &infFile, const char *pDevId, const char *pPhDevName, BOOL *pRebootRequired); BOOL RemoveDevices( InfFile &infFile, const char *pDevId, BOOL *pRebootRequired); BOOL InstallDevice( InfFile &infFile, const char *pDevId); #endif /* _C0C_DEVUTILS_H_ */ --- NEW FILE: inffile.cpp --- /* * $Id: inffile.cpp,v 1.1 2006/07/28 12:16:43 vfrolov Exp $ * * Copyright (c) 2006 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * $Log: inffile.cpp,v $ * Revision 1.1 2006/07/28 12:16:43 vfrolov * Initial revision * * */ #include "precomp.h" #include "inffile.h" #include "msg.h" /////////////////////////////////////////////////////////////// static BOOL GetVersionInfo(const char *pInfPath, const char *pKey, char **ppValue) { if (!pInfPath) return FALSE; if (*ppValue) return TRUE; char buf[4000]; if (!SetupGetInfInformation(pInfPath, INFINFO_INF_NAME_IS_ABSOLUTE, (PSP_INF_INFORMATION)buf, sizeof(buf), NULL)) { ShowLastError(MB_OK|MB_ICONSTOP, "SetupGetInfInformation()"); return FALSE; } DWORD size; if (!SetupQueryInfVersionInformation((PSP_INF_INFORMATION)buf, 0, pKey, NULL, 0, &size)) { ShowLastError(MB_OK|MB_ICONSTOP, "SetupQueryInfVersionInformation(%s)", pKey); return FALSE; } *ppValue = (char *)LocalAlloc(LPTR, size*sizeof(*ppValue[0])); if (*ppValue) { if (!SetupQueryInfVersionInformation((PSP_INF_INFORMATION)buf, 0, pKey, *ppValue, size, NULL)) { ShowLastError(MB_OK|MB_ICONSTOP, "SetupQueryInfVersionInformation(%s)", pKey); LocalFree(*ppValue); *ppValue = NULL; return FALSE; } } else { ShowLastError(MB_OK|MB_ICONSTOP, "LocalAlloc()"); return FALSE; } return TRUE; } /////////////////////////////////////////////////////////////// static BOOL GetFilePath( const char *pFileName, const char *pNearPath, char *pFilePath, DWORD lenFilePath) { char *pBuf; DWORD res; res = GetFullPathName(pNearPath, lenFilePath, pFilePath, &pBuf); if (!res) { ShowLastError(MB_OK|MB_ICONSTOP, "GetFullPathName(%s)", pNearPath); return FALSE; } if (res >= lenFilePath) { ShowError(MB_OK|MB_ICONSTOP, ERROR_BUFFER_OVERFLOW, "GetFullPathName(%s)", pNearPath); return FALSE; } if (DWORD(pBuf - pFilePath + lstrlen(pFileName)) >= lenFilePath) { ShowError(MB_OK|MB_ICONSTOP, ERROR_BUFFER_OVERFLOW, "GetFullPathName(%s)", pNearPath); return FALSE; } lstrcpy(pBuf, pFileName); //ShowMsg(MB_OK, "pFilePath=%s\n", pFilePath); return TRUE; } InfFile::InfFile(const char *pInfName, const char *pNearPath) : pPath(NULL), pClassGUID(NULL), pClass(NULL), pProvider(NULL) { char path[MAX_PATH]; if (GetFilePath(pInfName, pNearPath, path, sizeof(path))) { int len = lstrlen(path); pPath = (char *)LocalAlloc(LPTR, (len + 1)*sizeof(path[0])); if (pPath) lstrcpy(pPath, path); else ShowLastError(MB_OK|MB_ICONSTOP, "LocalAlloc()"); } } /////////////////////////////////////////////////////////////// InfFile::~InfFile() { if (pPath) LocalFree((HLOCAL)pPath); if (pClassGUID) LocalFree((HLOCAL)pClassGUID); if (pClass) LocalFree((HLOCAL)pClass); if (pProvider) LocalFree((HLOCAL)pProvider); } /////////////////////////////////////////////////////////////// const char *InfFile::ClassGUID() const { GetVersionInfo(pPath, "ClassGUID", &(char *)pClassGUID); return pClassGUID; } /////////////////////////////////////////////////////////////// const char *InfFile::Class() const { GetVersionInfo(pPath, "Class", &(char *)pClass); return pClass; } /////////////////////////////////////////////////////////////// const char *InfFile::Provider() const { GetVersionInfo(pPath, "Provider", &(char *)pProvider); return pProvider; } /////////////////////////////////////////////////////////////// BOOL InfFile::Compare( const char *_pClassGUID, const char *_pClass, const char *_pProvider) const { return ClassGUID() && !lstrcmpi(pClassGUID, _pClassGUID) && Class() && !lstrcmpi(pClass, _pClass) && Provider() && !lstrcmpi(pProvider, _pProvider); } /////////////////////////////////////////////////////////////// static UINT FileCallback( PVOID Context, UINT Notification, UINT_PTR Param1, UINT_PTR Param2) { if (Notification == SPFILENOTIFY_ENDDELETE) { PFILEPATHS pFilePaths = (PFILEPATHS)Param1; if (pFilePaths->Win32Error == ERROR_SUCCESS) { Trace("Deleted File %s\n", pFilePaths->Target); } else if (pFilePaths->Win32Error == ERROR_FILE_NOT_FOUND) { Trace("File %s not installed\n", pFilePaths->Target); } else { ShowError(MB_OK|MB_ICONWARNING, pFilePaths->Win32Error, "Delete(%s)", pFilePaths->Target); } } return SetupDefaultQueueCallback(Context, Notification, Param1, Param2); } BOOL InfFile::UninstallFiles(const char *pFilesSection) const { if (!pPath) return FALSE; int res; HINF hInf; do { res = IDCONTINUE; UINT errLine; hInf = SetupOpenInfFile(pPath, NULL, INF_STYLE_WIN4, &errLine); if (hInf == INVALID_HANDLE_VALUE) res = ShowLastError(MB_CANCELTRYCONTINUE, "SetupOpenInfFile(%s) on line %u", pPath, errLine); } while (res == IDTRYAGAIN); if (res != IDCONTINUE) return FALSE; do { res = IDCONTINUE; HSPFILEQ hFileQueue = SetupOpenFileQueue(); if (hFileQueue != INVALID_HANDLE_VALUE) { if (SetupQueueDeleteSection(hFileQueue, hInf, NULL, pFilesSection)) { PVOID pContext = SetupInitDefaultQueueCallback(NULL); if (pContext) { if(!SetupCommitFileQueue(NULL, hFileQueue, FileCallback, pContext)) res = ShowLastError(MB_CANCELTRYCONTINUE, "SetupCommitFileQueue()"); SetupTermDefaultQueueCallback(pContext); } else { res = ShowLastError(MB_CANCELTRYCONTINUE, "SetupInitDefaultQueueCallback()"); } } else { res = ShowLastError(MB_CANCELTRYCONTINUE, "SetupQueueDeleteSection(%s)", pFilesSection); } SetupCloseFileQueue(hFileQueue); } else { res = ShowLastError(MB_CANCELTRYCONTINUE, "SetupOpenFileQueue()"); } } while (res == IDTRYAGAIN); SetupCloseInfFile(hInf); if (res != IDCONTINUE) return FALSE; return TRUE; } /////////////////////////////////////////////////////////////// BOOL InfFile::InstallOEMInf() const { if (!pPath) return FALSE; if (!SetupCopyOEMInf(pPath, NULL, SPOST_PATH, SP_COPY_REPLACEONLY, NULL, 0, NULL, NULL)) { char infPathDest[MAX_PATH]; if (!SetupCopyOEMInf(pPath, NULL, SPOST_PATH, 0, infPathDest, sizeof(infPathDest), NULL, NULL)) { ShowLastError(MB_OK|MB_ICONSTOP, "SetupCopyOEMInf(%s)", pPath); return FALSE; } Trace("Installed %s to %s\n", pPath, infPathDest); } return TRUE; } /////////////////////////////////////////////////////////////// #ifndef HAVE_SetupUninstallOEMInf static BOOL UninstallFile(const char *pPath) { int res; do { res = IDCONTINUE; if (DeleteFile(pPath)) { Trace("Deleted File %s\n", pPath); } else if (GetLastError() == ERROR_FILE_NOT_FOUND) { Trace("File %s not installed\n", pPath); } else { res = ShowLastError(MB_CANCELTRYCONTINUE, "DeleteFile(%s)", pPath); } } while (res == IDTRYAGAIN); if (res != IDCONTINUE) return FALSE; return TRUE; } #endif /* HAVE_SetupUninstallOEMInf */ BOOL InfFile::UninstallOEMInf() const { if (!pPath) return FALSE; int res; do { res = IDCONTINUE; char infPathDest[MAX_PATH]; char *pInfNameDest; if (SetupCopyOEMInf(pPath, NULL, SPOST_NONE, SP_COPY_REPLACEONLY, infPathDest, sizeof(infPathDest), NULL, &pInfNameDest)) { #ifdef HAVE_SetupUninstallOEMInf if (SetupUninstallOEMInf(pInfNameDest, 0, NULL)) { Trace("Deleted %s\n", pInfNameDest); } else { res = ShowLastError(MB_CANCELTRYCONTINUE, "SetupUninstallOEMInf(%s)", pInfNameDest); } #else /* HAVE_SetupUninstallOEMInf */ if (UninstallFile(infPathDest)) { int infPathDestLen = lstrlen(infPathDest); if (infPathDestLen > 4) { char *pInfPathDestExt = infPathDest + infPathDestLen - 4; if (!lstrcmpi(pInfPathDestExt, ".inf")) { pInfPathDestExt[1] = 'p'; // pInfPathDestExt = ".pnf" if (!UninstallFile(infPathDest)) res = IDCANCEL; } } } else { res = IDCANCEL; } #endif /* HAVE_SetupUninstallOEMInf */ } else { if (GetLastError() == ERROR_FILE_NOT_FOUND) { Trace("File %s not installed\n", pPath); } else { res = ShowLastError(MB_CANCELTRYCONTINUE, "SetupCopyOEMInf(%s)", pPath); } } } while (res == IDTRYAGAIN); if (res != IDCONTINUE) return FALSE; return TRUE; } /////////////////////////////////////////////////////////////// --- NEW FILE: setup.rc --- /* * $Id: setup.rc,v 1.1 2006/07/28 12:16:43 vfrolov Exp $ * * Copyright (c) 2006 Vyacheslav Frolov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any... [truncated message content] |