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.

195 lines
5.7 KiB

  1. #include "TransportParser.hpp"
  2. #include "SPParser.hpp"
  3. #include "VoiceParser.hpp"
  4. #include "SessionParser.hpp"
  5. // DESCRIPTION: Identifies the parser, or parsers that are located in the DLL.
  6. //
  7. // NOTE: ParserAutoInstallInfo should be implemented in all parser DLLs.
  8. //
  9. // ARGUMENTS: NONE
  10. //
  11. // RETURNS: Success: PF_PARSERDLLINFO structure that describes the parsers in the DLL.
  12. // Failiure: NULL
  13. //
  14. DPLAYPARSER_API PPF_PARSERDLLINFO WINAPI ParserAutoInstallInfo( void ) // TODO: RIGHT NOW THIS SEEMS TO DO NOTHING!!!
  15. {
  16. enum
  17. {
  18. nNUM_OF_PROTOCOLS = 4
  19. };
  20. // Allocate memory for the parser info
  21. // NetMon will free this with HeapFree
  22. PPF_PARSERDLLINFO pParserDllInfo =
  23. reinterpret_cast<PPF_PARSERDLLINFO>( HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
  24. sizeof(PF_PARSERDLLINFO) + nNUM_OF_PROTOCOLS * sizeof(PF_PARSERINFO)) );
  25. if( pParserDllInfo == NULL)
  26. {
  27. return NULL;
  28. }
  29. // Number of parsers in the parser DLL.
  30. pParserDllInfo->nParsers = nNUM_OF_PROTOCOLS;
  31. //=============================================//
  32. // DPlay Service Provider parser specific info //===============================================================
  33. //=============================================//
  34. // Defining a synonym reference for simpler access
  35. PF_PARSERINFO& rSPInfo = pParserDllInfo->ParserInfo[0];
  36. // Name of the protocol that the parser detects
  37. strcpy(rSPInfo.szProtocolName, "DPLAYSP");
  38. // Brief description of the protocol
  39. strcpy(rSPInfo.szComment, "DPlay v.8.0 - Service Provider protocol");
  40. // Optional name of the protocol Help file
  41. strcpy(rSPInfo.szHelpFile, "\0");
  42. // Specify the preceding protocols
  43. enum
  44. {
  45. nNUM_OF_PARSERS_SP_FOLLOWS = 2
  46. };
  47. // NetMon will free this with HeapFree
  48. PPF_FOLLOWSET pSPPrecedeSet =
  49. reinterpret_cast<PPF_FOLLOWSET>( HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
  50. sizeof(PF_FOLLOWSET) + nNUM_OF_PARSERS_SP_FOLLOWS * sizeof(PF_FOLLOWENTRY)) );
  51. if( pSPPrecedeSet == NULL )
  52. {
  53. return pParserDllInfo;
  54. }
  55. // Fill in the follow set for preceding parsers
  56. pSPPrecedeSet->nEntries = nNUM_OF_PARSERS_SP_FOLLOWS;
  57. strcpy(pSPPrecedeSet->Entry[0].szProtocol, "UDP");
  58. strcpy(pSPPrecedeSet->Entry[1].szProtocol, "IPX");
  59. rSPInfo.pWhoCanPrecedeMe = pSPPrecedeSet;
  60. //==================================//
  61. // DPlay8 Transport parser specific info //==========================================================================
  62. //==================================//
  63. // Defining a synonym reference for simpler access
  64. PF_PARSERINFO& rTransportInfo = pParserDllInfo->ParserInfo[1];
  65. // Name of the protocol that the parser detects
  66. strcpy(rTransportInfo.szProtocolName, "DPLAYTRANSPORT");
  67. // Brief description of the protocol
  68. strcpy(rTransportInfo.szComment, "DPlay v.8.0 - Transport protocol");
  69. // Optional name of the protocol Help file
  70. strcpy(rTransportInfo.szHelpFile, "\0");
  71. //==================================//
  72. // DPlay Voice parser specific info //==========================================================================
  73. //==================================//
  74. // Defining a synonym reference for simpler access
  75. PF_PARSERINFO& rVoiceInfo = pParserDllInfo->ParserInfo[2];
  76. // Name of the protocol that the parser detects
  77. strcpy(rVoiceInfo.szProtocolName, "DPLAYVOICE");
  78. // Brief description of the protocol
  79. strcpy(rVoiceInfo.szComment, "DPlay v.8.0 - Voice protocol");
  80. // Optional name of the protocol Help file
  81. strcpy(rVoiceInfo.szHelpFile, "\0");
  82. //=================================//
  83. // DPlay Core parser specific info //===========================================================================
  84. //=================================//
  85. // Defining a synonym reference for simpler access
  86. PF_PARSERINFO& rCoreInfo = pParserDllInfo->ParserInfo[3];
  87. // Name of the protocol that the parser detects
  88. strcpy(rCoreInfo.szProtocolName, "DPLAYSESSION");
  89. // Brief description of the protocol
  90. strcpy(rCoreInfo.szComment, "DPlay v.8.0 - Session protocol");
  91. // Optional name of the protocol Help file
  92. strcpy(rCoreInfo.szHelpFile, "\0");
  93. return pParserDllInfo;
  94. } // ParserAutoInstallInfo
  95. // DESCRIPTION: (Called by the OS) Tell the kernel about our entry points.
  96. //
  97. // ARGUMENTS: i_hInstance - Handle to an instance of the parser.
  98. // i_dwCommand - Indicator to determine why the function is called.
  99. // i_pReserved - Not used now.
  100. //
  101. // RETURNS: Success = TRUE; Failure = FALSE
  102. //
  103. BOOL WINAPI DllMain( HANDLE i_hInstance, ULONG i_dwCommand, LPVOID i_pReserved )
  104. {
  105. static DWORD dwAttached = 0;
  106. // Process according to the calling context
  107. switch( i_dwCommand )
  108. {
  109. case DLL_PROCESS_ATTACH:
  110. // Are we loading for the first time?
  111. if( dwAttached == 0 )
  112. {
  113. // TODO: TEMPORARY: THIS SEEMS TO ADD THE PROTOCOLS TO PARSER.INI
  114. CreateTransportProtocol();
  115. CreateSPProtocol();
  116. CreateVoiceProtocol();
  117. CreateSessionProtocol();
  118. /*
  119. if ( !CreateTransportProtocol() || !CreateSPProtocol() || !CreateVoiceProtocol() || !CreateSessionProtocol() )
  120. {
  121. // TODO: ADD DEBUGING MESSAGE HERE
  122. MessageBox(NULL, "Failed to create protocols", "FAILED", MB_OK);
  123. // return FALSE; // (?BUG?) NetMon won't update the INI file if DllMain returns FALSE.
  124. }
  125. */
  126. }
  127. ++dwAttached;
  128. break;
  129. case DLL_PROCESS_DETACH:
  130. // Are we detaching our last instance?
  131. if( --dwAttached == 0 )
  132. {
  133. // Last active instance of this parser needs to clean up
  134. DestroyTransportProtocol();
  135. DestroySPProtocol();
  136. DestroyVoiceProtocol();
  137. DestroySessionProtocol();
  138. }
  139. break;
  140. }
  141. return TRUE;
  142. } // DllMain