Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
3.4 KiB

  1. #include <tchar.h>
  2. #include <olectl.h>
  3. #include <setupapi.h>
  4. #include "interface.h"
  5. #include "simpledb.h"
  6. #define BUFFER_SIZE 64*1024
  7. struct _SectionList;
  8. typedef _SectionList SECTION, *PSECTION;
  9. struct _SectionEntry;
  10. typedef _SectionEntry SECTIONENTRY, *PSECTIONENTRY;
  11. #define HASH_BUCKETS 128
  12. struct _SectionAssociationList;
  13. typedef _SectionAssociationList SECTIONASSOCIATIONLIST, *PSECTIONASSOCIATIONLIST;
  14. class CUpdateInf : public IUpdateInf
  15. {
  16. public:
  17. // IUnknown
  18. ULONG __stdcall AddRef( void );
  19. ULONG __stdcall Release( void );
  20. HRESULT __stdcall QueryInterface( REFIID, void ** );
  21. // IDispatch
  22. HRESULT _stdcall GetTypeInfoCount( UINT * );
  23. HRESULT __stdcall GetTypeInfo( UINT, LCID, ITypeInfo ** );
  24. HRESULT __stdcall GetIDsOfNames( REFIID, LPOLESTR *, UINT, LCID, DISPID * );
  25. HRESULT __stdcall Invoke( DISPID, REFIID, LCID, WORD, DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT * );
  26. // IUpdateInf
  27. HRESULT __stdcall InsertFile( BSTR bstrFileName );
  28. HRESULT __stdcall WriteSectionData( BSTR bstrSection, BSTR bstrValue );
  29. HRESULT __stdcall SetConfigurationField( BSTR bstrFieldName, BSTR bstrValue );
  30. HRESULT __stdcall AddSourceDisksFilesEntry( BSTR bstrFile, BSTR bstrTag );
  31. HRESULT __stdcall AddEquality( BSTR bstrSection, BSTR bstrLVal, BSTR bstrRVal );
  32. HRESULT __stdcall SetVersionField( BSTR bstrFieldName, BSTR bstrValue );
  33. HRESULT __stdcall SetDB( BSTR bstrServer, BSTR bstrDB, BSTR bstrUser, BSTR bstrPassword );
  34. HRESULT __stdcall InitGen( BSTR bstrInxFile, BSTR bstrInfFile );
  35. HRESULT __stdcall CloseGen( BOOL bTrimInf );
  36. HRESULT __stdcall get_InfGenError( BSTR *bstrError );
  37. CUpdateInf();
  38. ~CUpdateInf();
  39. BOOL Init();
  40. private:
  41. void Cleanup();
  42. BOOL TrimInf(LPTSTR szINFIn, LPTSTR szINFOut);
  43. BOOL ReverseSectionList( void );
  44. BOOL WriteSmallINF(LPTSTR szINFIn, LPTSTR szINFOut);
  45. BOOL IdentifyUninstallSections();
  46. BOOL DeleteUnusedEntries();
  47. BOOL DeleteUnusedDirIdSections();
  48. BOOL MarkAssociatedEntriesForDelete(PSECTION ps);
  49. BOOL RemoveSectionFromMultiEntry(PSECTIONENTRY pse, LPCTSTR szSectionName);
  50. BOOL AddEntryToSection(PSECTION ps, LPCTSTR szEntry);
  51. BOOL AssociateEntryWithSection(PSECTIONENTRY pse, LPCTSTR szSectionName, BOOL fMultiEntry);
  52. DWORD CalcHashFromSectionName(LPCTSTR szSectionName);
  53. BOOL ReadSectionEntries(LPCTSTR szINF);
  54. BOOL GetSectionListFromInF( LPTSTR szINF );
  55. DWORD GetFileSizeByName(IN LPCTSTR pszFileName, OUT PDWORD pdwFileSizeHigh );
  56. DWORD m_bGenInitCalled;
  57. DWORD m_dwInfGenError;
  58. TCHAR m_textBuffer[ BUFFER_SIZE ];
  59. TCHAR m_textBuffer2[ BUFFER_SIZE ];
  60. TCHAR m_textBuffer3[ BUFFER_SIZE ];
  61. TCHAR m_szInxFile[ MAX_PATH]; // The inf template. This acts as a database
  62. TCHAR m_szOutFile[ MAX_PATH]; // The output file. This is generated.
  63. TCHAR m_szFilledInxFile[ MAX_PATH]; // The intermediate work file where the files are injected.
  64. TCHAR m_szDataServer[ MAX_PATH ]; // Name of the server hosting the DB
  65. TCHAR m_szDatabase[ MAX_PATH ]; // Name of the database
  66. TCHAR m_szUserName[ MAX_PATH ]; // Username to connect to database with
  67. TCHAR m_szPassword[ MAX_PATH ]; // password to supply to database
  68. HINF m_hInf;
  69. BOOL m_bActiveDB;
  70. PSECTION m_sectionList;
  71. _SectionAssociationList *m_rgNameHash[HASH_BUCKETS];
  72. CSimpleDatabase *m_pdb;
  73. ULONG m_cRef;
  74. ITypeInfo *m_pTypeInfo;
  75. };