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.

211 lines
4.0 KiB

  1. /*++
  2. Copyright (c) 2000, Microsoft Corporation
  3. Module Name:
  4. AlgModule.cpp
  5. Abstract:
  6. Iplementation of the CAlgModule class
  7. Author:
  8. JP Duplessis (jpdup) 2000.01.19
  9. Revision History:
  10. --*/
  11. #include "PreComp.h"
  12. #include "AlgModule.h"
  13. #include "AlgController.h"
  14. //
  15. // Validate and Load an ALG
  16. //
  17. HRESULT
  18. CAlgModule::Start()
  19. {
  20. MYTRACE_ENTER("CAlgModule::Start");
  21. MYTRACE("---------------------------------------------------");
  22. MYTRACE("ALG Module:\"%S\"", m_szFriendlyName);
  23. MYTRACE("CLSID is :\"%S\"", m_szID);
  24. MYTRACE("---------------------------------------------------");
  25. //
  26. // Extract Full Path and File Name of DLL of the ISV ALG
  27. //
  28. CLSID guidAlgToLoad;
  29. HRESULT hr = CLSIDFromString(
  30. CComBSTR(m_szID), // ProgID
  31. &guidAlgToLoad // Pointer to the CLSID
  32. );
  33. if ( FAILED(hr) )
  34. {
  35. MYTRACE_ERROR("Could not convert to CLSID", hr);
  36. return hr;
  37. }
  38. hr = CoCreateInstance(
  39. guidAlgToLoad,
  40. NULL,
  41. CLSCTX_INPROC_SERVER,
  42. IID_IApplicationGateway,
  43. (void**)&m_pInterface
  44. );
  45. if ( FAILED(hr) )
  46. {
  47. MYTRACE_ERROR("Error CoCreating", hr);
  48. return hr;
  49. }
  50. //
  51. // Start the ALG plug-in
  52. //
  53. try
  54. {
  55. hr = m_pInterface->Initialize(g_pAlgController->m_pIAlgServices);
  56. }
  57. catch(...)
  58. {
  59. MYTRACE_ERROR("Exception done by this ISV ALG Module", hr);
  60. return hr;
  61. }
  62. return S_OK;
  63. }
  64. //
  65. //
  66. //
  67. HRESULT
  68. CAlgModule::Stop()
  69. {
  70. MYTRACE_ENTER("CAlgModule::Stop");
  71. HRESULT hr=E_FAIL;
  72. try
  73. {
  74. if ( m_pInterface )
  75. {
  76. hr = m_pInterface->Stop();
  77. LONG nRef = m_pInterface->Release();
  78. MYTRACE("************ REF is NOW %d", nRef);
  79. m_pInterface = NULL;
  80. }
  81. }
  82. catch(...)
  83. {
  84. MYTRACE_ERROR("TRY/CATCH on Stop", GetLastError());
  85. }
  86. return hr;
  87. };
  88. //
  89. // Verify that the DLL has a valid signature
  90. //
  91. HRESULT
  92. CAlgModule::ValidateDLL(
  93. LPCTSTR pszPathAndFileNameOfDLL
  94. )
  95. {
  96. /*
  97. MYTRACE_ENTER("CAlgModule::ValidateDLL");
  98. USES_CONVERSION;
  99. HRESULT hr=0;
  100. try
  101. {
  102. //
  103. // Used by WINTRUST_DATA
  104. //
  105. WINTRUST_FILE_INFO FileInfo;
  106. FileInfo.cbStruct = sizeof(WINTRUST_FILE_INFO);
  107. FileInfo.pcwszFilePath = T2W((LPTSTR)pszPathAndFileNameOfDLL); //szFilePath;
  108. FileInfo.hFile = INVALID_HANDLE_VALUE;
  109. FileInfo.pgKnownSubject = NULL;
  110. WINTRUST_DATA TrustData;
  111. memset(&TrustData,0,sizeof(TrustData));
  112. TrustData.cbStruct = sizeof(WINTRUST_DATA);
  113. TrustData.pPolicyCallbackData = NULL;
  114. TrustData.pSIPClientData = NULL;
  115. TrustData.dwUIChoice = WTD_UI_NONE; //WTD_UI_ALL; //;
  116. TrustData.fdwRevocationChecks = WTD_REVOKE_NONE;
  117. TrustData.dwUnionChoice = WTD_CHOICE_FILE;
  118. TrustData.pFile = &FileInfo;
  119. TrustData.dwStateAction = WTD_STATEACTION_IGNORE;
  120. TrustData.hWVTStateData = NULL;
  121. TrustData.pwszURLReference = NULL;
  122. TrustData.dwProvFlags = WTD_USE_IE4_TRUST_FLAG;
  123. //
  124. // Win32 Verification
  125. //
  126. GUID ActionGUID = WINTRUST_ACTION_GENERIC_VERIFY_V2;
  127. hr = WinVerifyTrust(
  128. GetDesktopWindow(),
  129. &ActionGUID,
  130. &TrustData
  131. );
  132. if ( SUCCEEDED(hr) )
  133. {
  134. // MessageBox(NULL, TEXT("Valid ALG"), TEXT("ALG.EXE"), MB_OK|MB_SERVICE_NOTIFICATION);
  135. }
  136. else
  137. {
  138. MYTRACE("******************************");
  139. MYTRACE(" NOT SIGNED - %ws", pszPathAndFileNameOfDLL);
  140. MYTRACE("******************************");
  141. }
  142. }
  143. catch(...)
  144. {
  145. MYTRACE_ERROR("WinTrust exception", hr);
  146. }
  147. hr = S_OK; // For the purpose of DEV for now we will always report OK
  148. return hr;
  149. */
  150. return S_OK;
  151. }