Leaked source code of windows server 2003
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.

150 lines
3.0 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. cathelper.c
  5. Abstract:
  6. Helper routines for categorizing APIs for logging.
  7. Author:
  8. 03-May-2001 KenCoope
  9. Revision History:
  10. --*/
  11. #include "w64logp.h"
  12. #include <cathelper.h>
  13. #include <apimap.c>
  14. ULONG
  15. GetApiCategoryTableSize(
  16. void )
  17. /*++
  18. Routine Description:
  19. This routine retreives the number of APICATEGORY entries
  20. in the passed table.
  21. Arguments:
  22. ApiCatTable - Pointer to API Category table
  23. Return Value:
  24. Number of entries
  25. --*/
  26. {
  27. ULONG Count = 0;
  28. PAPI_CATEGORY ApiCatTable = Wow64ApiCategories;
  29. while (ApiCatTable && ApiCatTable->CategoryName)
  30. {
  31. Count++;
  32. ApiCatTable++;
  33. }
  34. return Count;
  35. }
  36. PAPI_CATEGORY_MAPPING
  37. FindApiInMappingTable(
  38. IN PTHUNK_DEBUG_INFO DebugInfoEntry,
  39. IN ULONG TableNumber)
  40. /*++
  41. Routine Description:
  42. This routine searches the API mapping table to determing the API
  43. category of the input DebugInfoEntry.
  44. Arguments:
  45. DebugInfoEntry - A pointer to the THUNK_DEBUG_INFO entry
  46. TableNumber - The table number for the DebugInfoEntry
  47. Return Value:
  48. The api category
  49. --*/
  50. {
  51. ULONG MapCount = 0;
  52. PAPI_CATEGORY_MAPPING ApiCatMapTable = Wow64ApiCategoryMappings;
  53. if( !DebugInfoEntry )
  54. return NULL;
  55. // search mapping array for a matching entry
  56. while( ApiCatMapTable && ApiCatMapTable->ApiName )
  57. {
  58. if( 0 == strcmp(DebugInfoEntry->ApiName, ApiCatMapTable->ApiName) )
  59. {
  60. ApiCatMapTable->ApiFlags = 0;
  61. return ApiCatMapTable;
  62. }
  63. ApiCatMapTable++;
  64. MapCount++;
  65. }
  66. // initialize pointer to next free mapping entry if needed
  67. if( ApiCategoryMappingNextFree == (ULONG)(-1) )
  68. {
  69. ApiCategoryMappingNextFree = MapCount;
  70. }
  71. // add new entry to the mapping table
  72. if( (ApiCategoryMappingNextFree+1) < MAX_API_MAPPINGS )
  73. {
  74. PAPI_CATEGORY_MAPPING NextMapping = ApiCatMapTable + 1;
  75. switch(TableNumber)
  76. {
  77. case WHNT32_INDEX:
  78. ApiCatMapTable->ApiCategoryIndex = APICAT_UNCLASS_WHNT32;
  79. break;
  80. case WHCON_INDEX:
  81. ApiCatMapTable->ApiCategoryIndex = APICAT_UNCLASS_WHCON;
  82. break;
  83. case WHWIN32_INDEX:
  84. ApiCatMapTable->ApiCategoryIndex = APICAT_UNCLASS_WHWIN32;
  85. break;
  86. case WHBASE_INDEX:
  87. ApiCatMapTable->ApiCategoryIndex = APICAT_UNCLASS_WHBASE;
  88. break;
  89. default:
  90. return NULL;
  91. break;
  92. }
  93. NextMapping->ApiName = NULL;
  94. NextMapping->ApiFlags = 0;
  95. NextMapping->ApiCategoryIndex = 0;
  96. ApiCatMapTable->ApiName = DebugInfoEntry->ApiName;
  97. ApiCatMapTable->ApiFlags = 0;
  98. ApiCategoryMappingNextFree++;
  99. return ApiCatMapTable;
  100. }
  101. return NULL;
  102. }