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.

125 lines
2.6 KiB

  1. /*
  2. * pch.h for srcsrv project
  3. */
  4. #include <windows.h>
  5. #include <assert.h>
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <ctype.h>
  9. #include <memory.h>
  10. #include <malloc.h>
  11. #include <dbgeng.h>
  12. #include <assert.h>
  13. #include <string.h>
  14. #include <time.h>
  15. #include <ntverp.h>
  16. #include <copystr.h>
  17. #include <srcsrv.h>
  18. // this defines all text replacement variables
  19. typedef struct _VARIABLE {
  20. char *key;
  21. char *val;
  22. } VARIABLE, *PVARIABLE;
  23. // this defines the location of a source file in source depot
  24. typedef struct _SDFILE {
  25. char *path;
  26. char *depot;
  27. char *loc;
  28. } SDFILE, *PSDFILE;
  29. // Define some list prototypes
  30. #define InitializeListHead(ListHead) (\
  31. (ListHead)->Flink = (ListHead)->Blink = (ListHead))
  32. #define IsListEmpty(ListHead) \
  33. ((ListHead)->Flink == (ListHead))
  34. #define InsertTailList(ListHead,Entry) {\
  35. PLIST_ENTRY _EX_Blink;\
  36. PLIST_ENTRY _EX_ListHead;\
  37. _EX_ListHead = (ListHead);\
  38. _EX_Blink = _EX_ListHead->Blink;\
  39. (Entry)->Flink = _EX_ListHead;\
  40. (Entry)->Blink = _EX_Blink;\
  41. _EX_Blink->Flink = (Entry);\
  42. _EX_ListHead->Blink = (Entry);\
  43. }
  44. #define RemoveEntryList(Entry) {\
  45. PLIST_ENTRY _EX_Blink;\
  46. PLIST_ENTRY _EX_Flink;\
  47. _EX_Flink = (Entry)->Flink;\
  48. _EX_Blink = (Entry)->Blink;\
  49. _EX_Blink->Flink = _EX_Flink;\
  50. _EX_Flink->Blink = _EX_Blink;\
  51. }
  52. // for every process being handled
  53. typedef struct _PROCESS_ENTRY {
  54. LIST_ENTRY ListEntry;
  55. LIST_ENTRY ModuleList;
  56. ULONG cRefs;
  57. HANDLE hProcess;
  58. PSRCSRVCALLBACKPROC callback;
  59. DWORD64 context;
  60. char path[MAX_PATH + 1];
  61. } PROCESS_ENTRY, *PPROCESS_ENTRY;
  62. // for every module within a process
  63. typedef struct _MODULE_ENTRY {
  64. LIST_ENTRY ListEntry;
  65. ULONG64 base;
  66. char name[MAX_PATH + 1];
  67. char *stream;
  68. DWORD cbStream;
  69. PVARIABLE vars;
  70. int cvars;
  71. PSDFILE sdfiles;
  72. int cfiles;
  73. } MODULE_ENTRY, *PMODULE_ENTRY;
  74. // defines blocks of the stream
  75. typedef enum {
  76. blNone,
  77. blVars,
  78. blSource,
  79. blMax
  80. };
  81. // from util.cpp
  82. void
  83. EnsureTrailingBackslash(
  84. char *sz
  85. );
  86. BOOL
  87. EnsurePathExists(
  88. const char *path,
  89. char *existing,
  90. DWORD existingsize,
  91. BOOL fNoFileName
  92. );
  93. __inline
  94. BOOL
  95. CreateDir(
  96. const char *path,
  97. char *existing,
  98. DWORD existingsize
  99. )
  100. {
  101. return EnsurePathExists(path, existing, 0, TRUE);
  102. }