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.

212 lines
7.5 KiB

  1. /*++ BUILD Version: 0001
  2. *
  3. * WOW v1.0
  4. *
  5. * Copyright (c) 2002, Microsoft Corporation
  6. *
  7. * DpmTbls.h
  8. * Builds the Dynamic Patch Module global dispatch tables
  9. *
  10. * History:
  11. * Created 01-10-2002 by cmjones
  12. *
  13. * NOTE:
  14. * 1. This instantiates the memory for DpmFamTbls[] & DpmFamModuleSets[] in
  15. * v86\monitor\i386\thread.c
  16. * by that file.
  17. * 2. If you add to or change this, you must rebuild ntvdm.exe & wow32.dll!!
  18. * 3. To add new families, follow the instructions for each "!!!EDIT THIS !!!"
  19. * section below.
  20. *
  21. --*/
  22. #include "vdm.h"
  23. #define DPMFAMTBLS() (((PVDM_TIB)(NtCurrentTeb()->Vdm))->pDpmFamTbls)
  24. // 1. !!! EDIT THIS !!!
  25. // - for both VDM and/or WOW!!!
  26. //
  27. // Add the include file for each family here.
  28. #include "dpmf_fio.h"
  29. #include "dpmf_prf.h"
  30. #include "dpmf_reg.h"
  31. #include "dpmf_ntd.h"
  32. #ifndef _DPMTBLS_H_COMMON_
  33. #define _DPMTBLS_H_COMMON_
  34. typedef struct _tagDpmModuleSets {
  35. const char *DpmFamilyType; // Type of DPM patch module.dll (see below)
  36. const char *ApiModuleName; // Name of system.dll patched api's belong to
  37. const char **ApiNames; // Array of ptrs to API names we are hooking
  38. } DPMMODULESETS, *PDPMMODULESETS;
  39. // Type prototypes for calling the family table init & destroy functions
  40. // in the various dpmfxxx.dll's.
  41. typedef PFAMILY_TABLE (*LPDPMINIT)(PFAMILY_TABLE, HMODULE, PVOID, PVOID, LPWSTR, PDPMMODULESETS);
  42. typedef PFAMILY_TABLE (*LPDPMDESTROY)(PFAMILY_TABLE, PFAMILY_TABLE);
  43. // 2. !!! EDIT THIS !!!
  44. // Add a description for any new associations you add.
  45. //
  46. // DpmFamilyType's:
  47. // This tells the DPM loader which DPM family to associate your dpm .dll with.
  48. // Current associations:
  49. // DPMFIO - built from dpmf_fio.h
  50. // DPMNTD - built from dpmf_ntd.h
  51. // DPMPRF - built from dpmf_prf.h
  52. // DPMREG - built from dpmf_reg.h
  53. // These are strings used in the dbu.xml with the WOWCF2_DPM_PATCHES app compat
  54. // flag. For example:
  55. // <FLAG NAME="WOWCF2_DPM_PATCHES" COMMAND_LINE="DPMFIO=dpmffio.dll;DPMPRF=dpmprf.dll;DPMREG=dpmfreg.dll"/>
  56. // where the .dll specified is the .dll you build with the associated
  57. // dpmf_xxx.h file shown above.
  58. typedef struct _tagCMDLNPARMS {
  59. int argc; // number of ';' delimited parameters in the command_line
  60. char **argv; // array of vectors pointing to each item in command_line
  61. DWORD dwFlag; // App compat flag associated with these parameters
  62. } CMDLNPARMS, *PCMDLNPARMS;
  63. void BuildGlobalDpmStuffForWow(PFAMILY_TABLE *, PDPMMODULESETS *);
  64. void InitTaskDpmSupport(int,
  65. PFAMILY_TABLE *,
  66. PCMDLNPARMS,
  67. PVOID,
  68. PVOID,
  69. LPWSTR,
  70. LPWSTR,
  71. LPWSTR);
  72. VOID FreeTaskDpmSupport(PFAMILY_TABLE *, int, PFAMILY_TABLE *);
  73. void InitGlobalDpmTables(PFAMILY_TABLE *, int);
  74. PVOID GetDpmAddress(PVOID lpAddress);
  75. PCMDLNPARMS InitVdmSdbInfo(LPCSTR, DWORD *, int *);
  76. VOID FreeCmdLnParmStructs(PCMDLNPARMS, int);
  77. BOOL IsDpmEnabledForThisTask(void);
  78. #define MAX_APP_NAME 31+1
  79. // 3.Vdm. !!! EDIT THIS !!!
  80. // -- add any new VDM familes to this list
  81. //
  82. // NOTE: If you update this list you must update all of the following:
  83. // gDpmVdmFamTbls[]
  84. // gDpmWowFamTbls[]
  85. // gDpmVdmModuleSets[]
  86. // gDpmWowModuleSets[]
  87. enum VdmFamilies {FIO_FAM=0,
  88. NTD_FAM,
  89. enum_last_VDM_fam}; // this should always be last
  90. #define NUM_VDM_FAMILIES_HOOKED enum_last_VDM_fam
  91. // 4.Wow. !!! EDIT THIS !!!
  92. /// -- add any new WOW Families to this list
  93. //
  94. // NOTE: If you update this list you must update gDpmWowFamTbls[] &
  95. // gDpmWowModuleSets[] below.
  96. enum WowFamilies {REG_FAM=enum_last_VDM_fam,
  97. PRF_FAM,
  98. enum_last_WOW_fam}; // this should always be last
  99. #define NUM_WOW_FAMILIES_HOOKED (enum_last_WOW_fam)
  100. // Note: The WOW families & module sets get appended on the end of the VDM
  101. // families & module sets for WOW.
  102. #endif // _DPMTBLS_H_COMMON_
  103. // 5.Common. !!! EDIT THIS !!!
  104. //
  105. // Add a DPMMODULESETS struct for each family created.
  106. // If you add something to this list, be sure to add the new moduleset to the
  107. // appropriate modulesets below.
  108. #ifdef _DPM_COMMON_ // For both VDM & WOW
  109. const DPMMODULESETS FioModSet = {"DPMFIO", "kernel32.dll", DpmFioStrs};
  110. const DPMMODULESETS NtdModSet = {"DPMNTD", "ntdll.dll", DpmNtdStrs};
  111. #ifdef _WDPM_C_ // For WOW only
  112. const DPMMODULESETS RegModSet = {"DPMREG", "advapi32.dll", DpmRegStrs};
  113. const DPMMODULESETS PrfModSet = {"DPMPRF", "kernel32.dll", DpmPrfStrs};
  114. #endif // _WDPM_C_
  115. #endif // _DPM_COMMON_
  116. #ifdef _VDPM_C_
  117. //
  118. // THIS SECTION IS FOR VDM FAMILIES ONLY!!!!
  119. //
  120. // VDM Patches (Possibly callable by WOW!)
  121. // The following two arrays become part of v86\monitor\i386\thread.c through
  122. // this inclusion.
  123. // 6.Vdm. !!! EDIT THIS !!!
  124. // -- For VDM Families only!!!
  125. //
  126. // Add the family defined at the end of each VDM dpmf_xxx.h file included above.
  127. // Families added to this list must be in the same order as enum VdmFamilies{}
  128. // above. If you add something to this list you must also add it to the
  129. // gDpmWowFamTbls[] list below.
  130. const PFAMILY_TABLE gDpmVdmFamTbls[] = {&DpmFioFam,
  131. &DpmNtdFam };
  132. // 7.Vdm. !!! EDIT THIS !!!
  133. // -- For VDM Families only!!!
  134. //
  135. // Add each DPMMODULESETS struct created above.
  136. // list.
  137. // Names added to this list must be in the same order as enum VdmFamilies{}
  138. // above. If you add something to this list you must also add it to the
  139. // gDpmWowModuleSets[] list below.
  140. const PDPMMODULESETS gDpmVdmModuleSets[] = {(const PDPMMODULESETS)&FioModSet,
  141. (const PDPMMODULESETS)&NtdModSet};
  142. // END VDM ONLY SECTION!!!!
  143. #endif // _VDPM_C_
  144. #ifdef _WDPM_C_
  145. //
  146. // THIS SECTION IS FOR WOW FAMILIES!!!!
  147. //
  148. // WOW exclusive Patches
  149. // The following two arrays become part of mvdm\wow32\wdpm.c through
  150. // this inclusion.
  151. // 6.Wow. !!! EDIT THIS !!!
  152. // -- For WOW Families only!!!
  153. //
  154. // Add the family defined at the end of each WOW dpmf_xxx.h file included above.
  155. // Families added to this list must be in the same order as enum WowFamilies{}
  156. // above. All VDM familes added to this list must be at the head of the list
  157. // and be in the same order as gDpmVdmFamTbls[].
  158. const PFAMILY_TABLE gDpmWowFamTbls[] = {&DpmFioFam,
  159. &DpmNtdFam,
  160. &DpmRegFam,
  161. &DpmPrfFam };
  162. // 7.Wow. !!! EDIT THIS !!!
  163. // -- For WOW Families only!!!
  164. //
  165. // Add each DPMMODULESETS struct created above.
  166. // list.
  167. // Families added to this list must be in the same order as enum WowFamilies{}
  168. // above. All VDM familes added to this list must be at the head of the list
  169. // and be in the same order as gDpmVdmModuleSets[].
  170. const PDPMMODULESETS gDpmWowModuleSets[] = {(const PDPMMODULESETS)&FioModSet,
  171. (const PDPMMODULESETS)&NtdModSet,
  172. (const PDPMMODULESETS)&RegModSet,
  173. (const PDPMMODULESETS)&PrfModSet};
  174. // END WOW ONLY SECTION!!!!
  175. #endif // _WDPM_C_