BOOL DumpDeviceDescr(_In_ HDEVINFO Devs, _In_ PSP_DEVINFO_DATA DevInfo) /*++ Routine Description: Write device description to stdout Arguments: Devs )_ uniquely identify device DevInfo ) Return Value: TRUE if success --*/ { LPTSTR desc; desc = GetDeviceDescription(Devs,DevInfo); if(!desc) { return FALSE; } Padding(1); FormatToStream(stdout,MSG_DUMP_DESCRIPTION,desc); delete [] desc; return TRUE; }
BOOL DumpDeviceClass(_In_ HDEVINFO Devs, _In_ PSP_DEVINFO_DATA DevInfo) /*++ Routine Description: Write device class information to stdout Arguments: Devs )_ uniquely identify device DevInfo ) Return Value: TRUE if success --*/ { LPTSTR cls; LPTSTR guid; Padding(1); cls = GetDeviceStringProperty(Devs,DevInfo,SPDRP_CLASS); guid = GetDeviceStringProperty(Devs,DevInfo,SPDRP_CLASSGUID); if(!cls && !guid) { FormatToStream(stdout, MSG_DUMP_NOSETUPCLASS ); } else { FormatToStream(stdout, MSG_DUMP_SETUPCLASS, guid ? guid : TEXT("{}"), cls ? cls : TEXT("(?)") ); } if(cls) { delete [] cls; } if(guid) { delete [] guid; } return TRUE; }
void Failure(_In_ LPCTSTR BaseName, _In_ LPCTSTR Cmd) /*++ Routine Description: Display simple error text for general failure Arguments: BaseName - name of executable Return Value: none --*/ { FormatToStream(stderr,MSG_FAILURE,BaseName,Cmd); }
void Usage(_In_ LPCTSTR BaseName) /*++ Routine Description: Display simple usage text Arguments: BaseName - name of executable Return Value: none --*/ { FormatToStream(stderr,MSG_USAGE,BaseName); }
void CommandUsage(_In_ LPCTSTR BaseName, _In_ LPCTSTR Cmd) /*++ Routine Description: Invalid command usage Display how to get help on command Arguments: BaseName - name of executable Return Value: none --*/ { FormatToStream(stderr,MSG_COMMAND_USAGE,BaseName,Cmd); }
BOOL DumpDeviceResources(_In_ HDEVINFO Devs, _In_ PSP_DEVINFO_DATA DevInfo) /*++ Routine Description: Dump Resources to stdout Arguments: Devs )_ uniquely identify device DevInfo ) Return Value: none --*/ { SP_DEVINFO_LIST_DETAIL_DATA devInfoListDetail; ULONG status = 0; ULONG problem = 0; LOG_CONF config = 0; BOOL haveConfig = FALSE; // // see what state the device is in // devInfoListDetail.cbSize = sizeof(devInfoListDetail); if((!SetupDiGetDeviceInfoListDetail(Devs,&devInfoListDetail)) || (CM_Get_DevNode_Status_Ex(&status,&problem,DevInfo->DevInst,0,devInfoListDetail.RemoteMachineHandle)!=CR_SUCCESS)) { return FALSE; } // // see if the device is running and what resources it might be using // if(!(status & DN_HAS_PROBLEM)) { // // If this device is running, does this devinst have a ALLOC log config? // if (CM_Get_First_Log_Conf_Ex(&config, DevInfo->DevInst, ALLOC_LOG_CONF, devInfoListDetail.RemoteMachineHandle) == CR_SUCCESS) { haveConfig = TRUE; } } if(!haveConfig) { // // If no config so far, does it have a FORCED log config? // (note that technically these resources might be used by another device // but is useful info to show) // if (CM_Get_First_Log_Conf_Ex(&config, DevInfo->DevInst, FORCED_LOG_CONF, devInfoListDetail.RemoteMachineHandle) == CR_SUCCESS) { haveConfig = TRUE; } } if(!haveConfig) { // // if there's a hardware-disabled problem, boot-config isn't valid // otherwise use this if we don't have anything else // if(!(status & DN_HAS_PROBLEM) || (problem != CM_PROB_HARDWARE_DISABLED)) { // // Does it have a BOOT log config? // if (CM_Get_First_Log_Conf_Ex(&config, DevInfo->DevInst, BOOT_LOG_CONF, devInfoListDetail.RemoteMachineHandle) == CR_SUCCESS) { haveConfig = TRUE; } } } if(!haveConfig) { // // if we don't have any configuration, display an apropriate message // Padding(1); FormatToStream(stdout,(status & DN_STARTED) ? MSG_DUMP_NO_RESOURCES : MSG_DUMP_NO_RESERVED_RESOURCES ); return TRUE; } Padding(1); FormatToStream(stdout,(status & DN_STARTED) ? MSG_DUMP_RESOURCES : MSG_DUMP_RESERVED_RESOURCES ); // // dump resources // DumpDeviceResourcesOfType(DevInfo->DevInst,devInfoListDetail.RemoteMachineHandle,config,ResType_All); // // release handle // CM_Free_Log_Conf_Handle(config); return TRUE; }
BOOL DumpDeviceStatus(_In_ HDEVINFO Devs, _In_ PSP_DEVINFO_DATA DevInfo) /*++ Routine Description: Write device status to stdout Arguments: Devs )_ uniquely identify device DevInfo ) Return Value: none --*/ { SP_DEVINFO_LIST_DETAIL_DATA devInfoListDetail; ULONG status = 0; ULONG problem = 0; BOOL hasInfo = FALSE; BOOL isPhantom = FALSE; CONFIGRET cr = CR_SUCCESS; devInfoListDetail.cbSize = sizeof(devInfoListDetail); if((!SetupDiGetDeviceInfoListDetail(Devs,&devInfoListDetail)) || ((cr = CM_Get_DevNode_Status_Ex(&status,&problem,DevInfo->DevInst,0,devInfoListDetail.RemoteMachineHandle))!=CR_SUCCESS)) { if ((cr == CR_NO_SUCH_DEVINST) || (cr == CR_NO_SUCH_VALUE)) { isPhantom = TRUE; } else { Padding(1); FormatToStream(stdout,MSG_DUMP_STATUS_ERROR); return FALSE; } } // // handle off the status/problem codes // if (isPhantom) { Padding(1); FormatToStream(stdout,MSG_DUMP_PHANTOM); return TRUE; } if((status & DN_HAS_PROBLEM) && problem == CM_PROB_DISABLED) { hasInfo = TRUE; Padding(1); FormatToStream(stdout,MSG_DUMP_DISABLED); return TRUE; } if(status & DN_HAS_PROBLEM) { hasInfo = TRUE; Padding(1); FormatToStream(stdout,MSG_DUMP_PROBLEM,problem); } if(status & DN_PRIVATE_PROBLEM) { hasInfo = TRUE; Padding(1); FormatToStream(stdout,MSG_DUMP_PRIVATE_PROBLEM); } if(status & DN_STARTED) { Padding(1); FormatToStream(stdout,MSG_DUMP_STARTED); } else if (!hasInfo) { Padding(1); FormatToStream(stdout,MSG_DUMP_NOTSTARTED); } return TRUE; }
/*---------------------------------------------------------------------------------------------- Write an integer-valued text property in XML format. @param pstrm Pointer to an IStream for output. @param tpt @param nVar @param nVal ----------------------------------------------------------------------------------------------*/ void FwXml::WriteIntTextProp(IStream * pstrm, ILgWritingSystemFactory * pwsf, int tpt, int nVar, int nVal) { AssertPtr(pstrm); AssertPtr(pwsf); switch (tpt) { case ktptBackColor: FormatToStream(pstrm, " backcolor=\"%s\"", ColorName(nVal)); break; case ktptBold: FormatToStream(pstrm, " bold=\"%s\"", ToggleValueName((byte)nVal)); break; case ktptWs: if (nVal == 0) { Assert(nVar == 0); } else { SmartBstr sbstrWs; CheckHr(pwsf->GetStrFromWs(nVal, &sbstrWs)); if (!sbstrWs.Length()) ThrowInternalError(E_INVALIDARG, "Writing system invalid for <Run ws>"); FormatToStream(pstrm, " ws=\"", nVal); WriteXmlUnicode(pstrm, sbstrWs.Chars(), sbstrWs.Length()); FormatToStream(pstrm, "\"", nVal); } break; case ktptBaseWs: if (nVal == 0) { Assert(nVar == 0); } else { SmartBstr sbstrWs; CheckHr(pwsf->GetStrFromWs(nVal, &sbstrWs)); if (!sbstrWs.Length()) ThrowInternalError(E_INVALIDARG, "Writing system invalid for <Run wsBase>"); FormatToStream(pstrm, " wsBase=\"", nVal); WriteXmlUnicode(pstrm, sbstrWs.Chars(), sbstrWs.Length()); FormatToStream(pstrm, "\"", nVal); } break; case ktptFontSize: FormatToStream(pstrm, " fontsize=\"%d\"", nVal); if (nVar != ktpvDefault) FormatToStream(pstrm, " fontsizeUnit=\"%s\"", PropVarName(nVar)); break; case ktptForeColor: FormatToStream(pstrm, " forecolor=\"%s\"", ColorName(nVal)); break; case ktptItalic: FormatToStream(pstrm, " italic=\"%s\"", ToggleValueName((byte)nVal)); break; case ktptOffset: FormatToStream(pstrm, " offset=\"%d\"", nVal); FormatToStream(pstrm, " offsetUnit=\"%s\"", PropVarName(nVar)); break; case ktptSuperscript: FormatToStream(pstrm, " superscript=\"%s\"", SuperscriptValName((byte)nVal)); break; case ktptUnderColor: FormatToStream(pstrm, " undercolor=\"%s\"", ColorName(nVal)); break; case ktptUnderline: FormatToStream(pstrm, " underline=\"%s\"", UnderlineTypeName((byte)nVal)); break; case ktptSpellCheck: FormatToStream(pstrm, " spellcheck=\"%s\"", SpellingModeName((byte)nVal)); break; // Paragraph-level properties: case ktptAlign: FormatToStream(pstrm, " align=\"%s\"", AlignmentTypeName((byte)nVal)); break; case ktptFirstIndent: FormatToStream(pstrm, " firstIndent=\"%d\"", nVal); break; case ktptLeadingIndent: FormatToStream(pstrm, " leadingIndent=\"%d\"", nVal); break; case ktptTrailingIndent: FormatToStream(pstrm, " trailingIndent=\"%d\"", nVal); break; case ktptSpaceBefore: FormatToStream(pstrm, " spaceBefore=\"%d\"", nVal); break; case ktptSpaceAfter: FormatToStream(pstrm, " spaceAfter=\"%d\"", nVal); break; case ktptTabDef: FormatToStream(pstrm, " tabDef=\"%d\"", nVal); break; case ktptLineHeight: FormatToStream(pstrm, " lineHeight=\"%d\"", abs(nVal)); FormatToStream(pstrm, " lineHeightUnit=\"%s\"", PropVarName(nVar)); Assert(nVal >= 0 || nVar == ktpvMilliPoint); if (nVar == ktpvMilliPoint) { // negative means "exact" internally. See FWC-20. FormatToStream(pstrm, " lineHeightType=\"%s\"", nVal < 0 ? "exact" : "atLeast"); } break; case ktptParaColor: FormatToStream(pstrm, " paracolor=\"%s\"", ColorName(nVal)); break; // Properties from the views subsystem: case ktptRightToLeft: FormatToStream(pstrm, " rightToLeft=\"%d\"", nVal); break; case ktptPadLeading: FormatToStream(pstrm, " padLeading=\"%d\"", nVal); break; case ktptPadTrailing: FormatToStream(pstrm, " padTrailing=\"%d\"", nVal); break; // Not the other margins: they are duplicated by FirstIndent etc. case ktptMarginTop: FormatToStream(pstrm, " MarginTop=\"%d\"", nVal); break; case ktptPadTop: FormatToStream(pstrm, " padTop=\"%d\"", nVal); break; case ktptPadBottom: FormatToStream(pstrm, " padBottom=\"%d\"", nVal); break; case ktptBorderTop: FormatToStream(pstrm, " borderTop=\"%d\"", nVal); break; case ktptBorderBottom: FormatToStream(pstrm, " borderBottom=\"%d\"", nVal); break; case ktptBorderLeading: FormatToStream(pstrm, " borderLeading=\"%d\"", nVal); break; case ktptBorderTrailing: FormatToStream(pstrm, " borderTrailing=\"%d\"", nVal); break; case ktptBorderColor: FormatToStream(pstrm, " borderColor=\"%s\"", ColorName(nVal)); break; case ktptBulNumScheme: FormatToStream(pstrm, " bulNumScheme=\"%d\"", nVal); break; case ktptBulNumStartAt: FormatToStream(pstrm, " bulNumStartAt=\"%d\"", nVal == INT_MIN ? 0 : nVal); break; case ktptDirectionDepth: FormatToStream(pstrm, " directionDepth=\"%d\"", nVal); break; case ktptKeepWithNext: FormatToStream(pstrm, " keepWithNext=\"%d\"", nVal); break; case ktptKeepTogether: FormatToStream(pstrm, " keepTogether=\"%d\"", nVal); break; case ktptHyphenate: FormatToStream(pstrm, " hyphenate=\"%d\"", nVal); break; case ktptWidowOrphanControl: FormatToStream(pstrm, " widowOrphan=\"%d\"", nVal); break; case ktptMaxLines: FormatToStream(pstrm, " maxLines=\"%d\"", nVal); break; case ktptCellBorderWidth: FormatToStream(pstrm, " cellBorderWidth=\"%d\"", nVal); break; case ktptCellSpacing: FormatToStream(pstrm, " cellSpacing=\"%d\"", nVal); break; case ktptCellPadding: FormatToStream(pstrm, " cellPadding=\"%d\"", nVal); break; case ktptEditable: FormatToStream(pstrm, " editable=\"%s\"", EditableName(nVal)); break; case ktptSetRowDefaults: FormatToStream(pstrm, " setRowDefaults=\"%d\"", nVal); break; case ktptRelLineHeight: FormatToStream(pstrm, " relLineHeight=\"%d\"", nVal); break; case ktptTableRule: // Ignore this view-only property. break; default: break; } }
MemoryOutStream& MemoryOutStream::operator << (unsigned long const n) { FormatToStream(*this, "%lu", n); return *this; }
MemoryOutStream& MemoryOutStream::operator << (int const n) { FormatToStream(*this, "%i", n); return *this; }
MemoryOutStream& MemoryOutStream::operator <<(double const d) { FormatToStream(*this, "%f", d); return *this; }
MemoryOutStream& MemoryOutStream::operator << (unsigned int const s) { FormatToStream(*this, "%u", s); return *this; }
MemoryOutStream& MemoryOutStream::operator << (void const* p) { FormatToStream(*this, "%p", p); return *this; }
/*---------------------------------------------------------------------------------------------- Write the given FontInfo string text property value in readable XML format. @param pstrm Pointer to an IStream for output. @param bstrVal ----------------------------------------------------------------------------------------------*/ void FwXml::WriteBulNumFontInfo(IStream * pstrm, BSTR bstrVal, int cchIndent) { AssertPtr(pstrm); Assert(cchIndent >= 0); int cchProps = ::SysStringLen(bstrVal); if (!cchProps) return; Vector<char> vchIndent; vchIndent.Resize(cchIndent + 1); memset(vchIndent.Begin(), ' ', cchIndent); const OLECHAR * pchProps = bstrVal; const OLECHAR * pchPropsLim = pchProps + cchProps; FormatToStream(pstrm, "%s<BulNumFontInfo", vchIndent.Begin()); StrAnsi staItalic; StrAnsi staBold; StrAnsi staSuperscript; StrAnsi staUnderline; StrAnsi staFontsize; StrAnsi staOffset; StrAnsi staForecolor; StrAnsi staBackcolor; StrAnsi staUndercolor; StrAnsi staXXX; int tpt; while (pchProps < pchPropsLim) { tpt = *pchProps++; if (tpt == ktptFontFamily) break; int nVal = *pchProps + ((*(pchProps + 1)) << 16); pchProps += 2; switch (tpt) { case ktptItalic: staItalic.Format(" italic=\"%s\"", ToggleValueName((byte)nVal)); break; case ktptBold: staBold.Format(" bold=\"%s\"", ToggleValueName((byte)nVal)); break; case ktptSuperscript: staSuperscript.Format(" superscript=\"%s\"", SuperscriptValName((byte)nVal)); break; case ktptUnderline: staUnderline.Format(" underline=\"%s\"", UnderlineTypeName((byte)nVal)); break; case ktptFontSize: staFontsize.Format(" fontsize=\"%dmpt\"", nVal); break; case ktptOffset: staOffset.Format(" offset=\"%dmpt\"", nVal); break; case ktptForeColor: staForecolor.Format(" forecolor=\"%s\"", ColorName(nVal)); break; case ktptBackColor: staBackcolor.Format(" backcolor=\"%s\"", ColorName(nVal)); break; case ktptUnderColor: staUndercolor.Format(" undercolor=\"%s\"", ColorName(nVal)); break; default: staXXX.FormatAppend(" prop_%u=\"%d\"", tpt, nVal); break; } } ULONG cb; // Write the integer valued properties in alphabetical order. if (staBackcolor.Length()) pstrm->Write(staBackcolor.Chars(), staBackcolor.Length(), &cb); if (staBold.Length()) pstrm->Write(staBold.Chars(), staBold.Length(), &cb); if (staFontsize.Length()) pstrm->Write(staFontsize.Chars(), staFontsize.Length(), &cb); if (staForecolor.Length()) pstrm->Write(staForecolor.Chars(), staForecolor.Length(), &cb); if (staItalic.Length()) pstrm->Write(staItalic.Chars(), staItalic.Length(), &cb); if (staOffset.Length()) pstrm->Write(staOffset.Chars(), staOffset.Length(), &cb); if (staSuperscript.Length()) pstrm->Write(staSuperscript.Chars(), staSuperscript.Length(), &cb); if (staUndercolor.Length()) pstrm->Write(staUndercolor.Chars(), staUndercolor.Length(), &cb); if (staUnderline.Length()) pstrm->Write(staUnderline.Chars(), staUnderline.Length(), &cb); if (staXXX.Length()) pstrm->Write(staXXX.Chars(), staXXX.Length(), &cb); // Write the string valued property (if it exists). if (tpt == ktptFontFamily && pchProps < pchPropsLim) { FormatToStream(pstrm, " fontFamily=\""); WriteXmlUnicode(pstrm, pchProps, pchPropsLim - pchProps); FormatToStream(pstrm, "\""); } FormatToStream(pstrm, "/>%n"); }
/*---------------------------------------------------------------------------------------------- Write a string-valued text property in XML format. @param pstrm Pointer to an IStream for output. @param tpt @param bstrVal ----------------------------------------------------------------------------------------------*/ void FwXml::WriteStrTextProp(IStream * pstrm, int tpt, BSTR bstrVal) { AssertPtr(pstrm); int cch = ::SysStringLen(bstrVal); switch (tpt) { case ktptCharStyle: FormatToStream(pstrm, " charStyle=\""); WriteXmlUnicode(pstrm, bstrVal, cch); FormatToStream(pstrm, "\""); break; case ktptFontFamily: FormatToStream(pstrm, " fontFamily=\""); WriteXmlUnicode(pstrm, bstrVal, cch); FormatToStream(pstrm, "\""); break; case ktptObjData: if (cch >= 1) { switch (bstrVal[0]) { case kodtPictEven: case kodtPictOdd: // type="chars" is the default value for this attribute. // The caller is responsible for writing out the picture data. (This is an // antique kludge that isn't really used in practice, but some of our test data // still exercises it.) FormatToStream(pstrm, " type=\"picture\""); break; case kodtNameGuidHot: Assert((cch - 1) * isizeof(OLECHAR) == isizeof(GUID)); { const GUID * pguid = reinterpret_cast<const GUID *>(bstrVal + 1); FormatToStream(pstrm, " link=\"%g\"", pguid); } break; case kodtExternalPathName: FormatToStream(pstrm, " externalLink=\""); WriteXmlUnicode(pstrm, bstrVal + 1, cch - 1); FormatToStream(pstrm, "\""); break; case kodtOwnNameGuidHot: Assert((cch - 1) * isizeof(OLECHAR) == isizeof(GUID)); { const GUID * pguid = reinterpret_cast<const GUID *>(bstrVal + 1); FormatToStream(pstrm, " ownlink=\"%g\"", pguid); } break; case kodtEmbeddedObjectData: // used ONLY in the clipboard...code won't know what to do with it elsewhere! Assert(bstrVal[0] != kodtEmbeddedObjectData); break; case kodtContextString: // This is a generated context-sensitive string. The next 8 characters give a // GUID, which is from to a known set of GUIDs that have special meaning to a // view contructor. Assert((cch - 1) * isizeof(OLECHAR) == isizeof(GUID)); { const GUID * pguid = reinterpret_cast<const GUID *>(bstrVal + 1); FormatToStream(pstrm, " contextString=\"%g\"", pguid); } break; case kodtGuidMoveableObjDisp: // This results in a call-back to the VC, with a new VwEnv, to create any // display it wants of the object specified by the Guid (see // IVwViewConstructor.DisplayEmbeddedObject). The display will typically // occur immediately following the paragraph line that contains the ORC, // which functions as an anchor, but may be moved down past following text // to improve page breaking. Assert((cch - 1) * isizeof(OLECHAR) == isizeof(GUID)); { const GUID * pguid = reinterpret_cast<const GUID *>(bstrVal + 1); FormatToStream(pstrm, " moveableObj=\"%g\"", pguid); } break; default: // This forces an assert when a new enum value is added and used. Assert(bstrVal[0] == kodtExternalPathName); break; } } break; // Properties from the views subsystem: case ktptNamedStyle: FormatToStream(pstrm, " namedStyle=\""); WriteXmlUnicode(pstrm, bstrVal, cch); FormatToStream(pstrm, "\""); break; case ktptBulNumTxtBef: FormatToStream(pstrm, " bulNumTxtBef=\""); WriteXmlUnicode(pstrm, bstrVal, cch); FormatToStream(pstrm, "\""); break; case ktptBulNumTxtAft: FormatToStream(pstrm, " bulNumTxtAft=\""); WriteXmlUnicode(pstrm, bstrVal, cch); FormatToStream(pstrm, "\""); break; case ktptBulNumFontInfo: // BulNumFontInfo is written separately. break; case ktptWsStyle: // WsStyles are written separately break; case ktptFontVariations: // string, giving variation names specific to font. FormatToStream(pstrm, " fontVariations=\""); WriteXmlUnicode(pstrm, bstrVal, cch); FormatToStream(pstrm, "\""); break; case ktptParaStyle: FormatToStream(pstrm, " paraStyle=\""); WriteXmlUnicode(pstrm, bstrVal, cch); FormatToStream(pstrm, "\""); break; case ktptTabList: FormatToStream(pstrm, " tabList=\""); WriteXmlUnicode(pstrm, bstrVal, cch); FormatToStream(pstrm, "\""); break; case ktptTags: // prop holds sequence of 8-char items, each the memcpy-equivalent of a GUID { const GUID * prgguid = reinterpret_cast<const GUID *>(bstrVal); int cguid = (cch * isizeof(OLECHAR)) / isizeof(GUID); FormatToStream(pstrm, " tags=\""); for (int iguid = 0; iguid < cguid; ++iguid) { if (iguid) FormatToStream(pstrm, " "); FormatToStream(pstrm, "I%g", prgguid + iguid); } FormatToStream(pstrm, "\""); } break; /* ktptFieldName: // Fake string valued text property used for exporting. */ default: break; } }
BOOL DumpDeviceDriverFiles(_In_ HDEVINFO Devs, _In_ PSP_DEVINFO_DATA DevInfo) /*++ Routine Description: Dump information about what files were installed for driver package <tab>Installed using OEM123.INF section [abc.NT] <tab><tab>file... Arguments: Devs )_ uniquely identify device DevInfo ) Return Value: none --*/ { // // do this by 'searching' for the current driver // mimmicing a copy-only install to our own file queue // and then parsing that file queue // SP_DEVINSTALL_PARAMS deviceInstallParams; SP_DRVINFO_DATA driverInfoData; SP_DRVINFO_DETAIL_DATA driverInfoDetail; HSPFILEQ queueHandle = INVALID_HANDLE_VALUE; DWORD count; DWORD scanResult; BOOL success = FALSE; ZeroMemory(&driverInfoData,sizeof(driverInfoData)); driverInfoData.cbSize = sizeof(driverInfoData); if(!FindCurrentDriver(Devs,DevInfo,&driverInfoData)) { Padding(1); FormatToStream(stdout, MSG_DUMP_NO_DRIVER); return FALSE; } // // get useful driver information // driverInfoDetail.cbSize = sizeof(SP_DRVINFO_DETAIL_DATA); if(!SetupDiGetDriverInfoDetail(Devs,DevInfo,&driverInfoData,&driverInfoDetail,sizeof(SP_DRVINFO_DETAIL_DATA),NULL) && GetLastError() != ERROR_INSUFFICIENT_BUFFER) { // // no information about driver or section // goto final; } if(!driverInfoDetail.InfFileName[0] || !driverInfoDetail.SectionName[0]) { goto final; } // // pretend to do the file-copy part of a driver install // to determine what files are used // the specified driver must be selected as the active driver // if(!SetupDiSetSelectedDriver(Devs, DevInfo, &driverInfoData)) { goto final; } // // create a file queue so we can look at this queue later // queueHandle = SetupOpenFileQueue(); if ( queueHandle == (HSPFILEQ)INVALID_HANDLE_VALUE ) { goto final; } // // modify flags to indicate we're providing our own queue // ZeroMemory(&deviceInstallParams, sizeof(deviceInstallParams)); deviceInstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS); if ( !SetupDiGetDeviceInstallParams(Devs, DevInfo, &deviceInstallParams) ) { goto final; } // // we want to add the files to the file queue, not install them! // deviceInstallParams.FileQueue = queueHandle; deviceInstallParams.Flags |= DI_NOVCP; if ( !SetupDiSetDeviceInstallParams(Devs, DevInfo, &deviceInstallParams) ) { goto final; } // // now fill queue with files that are to be installed // this involves all class/co-installers // if ( !SetupDiCallClassInstaller(DIF_INSTALLDEVICEFILES, Devs, DevInfo) ) { goto final; } // // we now have a list of delete/rename/copy files // iterate the copy queue twice - 1st time to get # of files // 2nd time to get files // (WinXP has API to get # of files, but we want this to work // on Win2k too) // count = 0; scanResult = 0; // // call once to count // SetupScanFileQueue(queueHandle,SPQ_SCAN_USE_CALLBACK,NULL,DumpDeviceDriversCallback,&count,&scanResult); Padding(1); FormatToStream(stdout, count ? MSG_DUMP_DRIVER_FILES : MSG_DUMP_NO_DRIVER_FILES, count, driverInfoDetail.InfFileName, driverInfoDetail.SectionName); // // call again to dump the files // SetupScanFileQueue(queueHandle,SPQ_SCAN_USE_CALLBACK,NULL,DumpDeviceDriversCallback,NULL,&scanResult); success = TRUE; final:
MemoryOutStream& MemoryOutStream::operator << (float const f) { FormatToStream(*this, "%ff", f); return *this; }
DEFINE_THIS_FILE /*---------------------------------------------------------------------------------------------- Write the given string, which encodes a group of writing-system styles, to WorldPad XML format. @param pstrm Pointer to an IStream for output. @param bstrWsStyles @param cchIndent Number of spaces to indent the XML output. This code must be kept in sync with FwStyledText::DecodeFontPropsString()! ----------------------------------------------------------------------------------------------*/ void FwXml::WriteWsStyles(IStream * pstrm, ILgWritingSystemFactory * pwsf, BSTR bstrWsStyles, int cchIndent) { AssertPtr(pstrm); AssertPtr(pwsf); Assert(cchIndent >= 0); Vector<char> vchIndent; vchIndent.Resize(cchIndent + 1); // new elements are zero initialized. memset(vchIndent.Begin(), ' ', cchIndent); Vector<WsStyleInfo> vesi; Vector<int> vws; FwStyledText::DecodeFontPropsString(bstrWsStyles, vesi, vws); if (vesi.Size()) { FormatToStream(pstrm, "%s<WsStyles9999>%n", vchIndent.Begin()); for (int iv = 0; iv < vesi.Size(); ++iv) { SmartBstr sbstrWs; CheckHr(pwsf->GetStrFromWs(vesi[iv].m_ws, &sbstrWs)); if (!sbstrWs.Length()) { // We don't want WorldPad writing invalid XML! // ThrowInternalError(E_INVALIDARG, "Writing system invalid for <WsProp ws>"); #if 99 ::MessageBoxA(NULL, "Writing system invalid for <WsProp ws>", "DEBUG!", MB_OK); #endif ::OutputDebugStringA("Writing system invalid for <WsProp ws>"); continue; } FormatToStream(pstrm, "%s%s<WsProp ws=\"", vchIndent.Begin(), cchIndent ? " " : ""); WriteXmlUnicode(pstrm, sbstrWs.Chars(), sbstrWs.Length()); FormatToStream(pstrm, "\""); if (vesi[iv].m_stuFontFamily.Length()) FwXml::WriteStrTextProp(pstrm, ktptFontFamily, vesi[iv].m_stuFontFamily.Bstr()); if (vesi[iv].m_stuFontVar.Length()) FwXml::WriteStrTextProp(pstrm, ktptFontVariations, vesi[iv].m_stuFontVar.Bstr()); if (vesi[iv].m_mpSize != knNinch) FwXml::WriteIntTextProp(pstrm, pwsf, ktptFontSize, ktpvMilliPoint, vesi[iv].m_mpSize); if (vesi[iv].m_fBold != knNinch) FwXml::WriteIntTextProp(pstrm, pwsf, ktptBold, ktpvEnum, vesi[iv].m_fBold); if (vesi[iv].m_fItalic != knNinch) FwXml::WriteIntTextProp(pstrm, pwsf, ktptItalic, ktpvEnum, vesi[iv].m_fItalic); if (vesi[iv].m_ssv != knNinch) FwXml::WriteIntTextProp(pstrm, pwsf, ktptSuperscript, ktpvEnum, vesi[iv].m_ssv); if (vesi[iv].m_clrFore != (COLORREF)knNinch) FwXml::WriteIntTextProp(pstrm, pwsf, ktptForeColor, ktpvDefault, vesi[iv].m_clrFore); if (vesi[iv].m_clrBack != (COLORREF)knNinch) FwXml::WriteIntTextProp(pstrm, pwsf, ktptBackColor, ktpvDefault, vesi[iv].m_clrBack); if (vesi[iv].m_clrUnder != (COLORREF)knNinch) FwXml::WriteIntTextProp(pstrm, pwsf, ktptUnderColor, ktpvDefault, vesi[iv].m_clrUnder); if (vesi[iv].m_unt != knNinch) FwXml::WriteIntTextProp(pstrm, pwsf, ktptUnderline, ktpvEnum, vesi[iv].m_unt); if (vesi[iv].m_mpOffset != knNinch) FwXml::WriteIntTextProp(pstrm, pwsf, ktptOffset, ktpvMilliPoint, vesi[iv].m_mpOffset); FormatToStream(pstrm, " />%n"); } FormatToStream(pstrm, "%s</WsStyles9999>%n", vchIndent.Begin()); } }