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.

105 lines
3.1 KiB

  1. #pragma once
  2. #pragma warning(disable:4201) /* anonymous unions */
  3. #pragma warning(disable:4115) /* named type definition in parentheses */
  4. #pragma warning(disable:4100) /* unreferenced formal parameter */
  5. #pragma warning(disable:4100) /* unreferenced formal parameter */
  6. #pragma warning(disable:4706) /* assignment within conditional expression */
  7. #if defined (__cplusplus)
  8. extern "C"
  9. {
  10. #endif
  11. #include "nt.h"
  12. #include "ntrtl.h"
  13. #include "nturtl.h"
  14. #include "windows.h"
  15. #include "winerror.h"
  16. #include "imagehlp.h"
  17. //#include "dbghelp.h"
  18. #include <stdio.h>
  19. #undef MAX
  20. #undef MIN
  21. #define MIN(x,y) ((x)<(y)?(x):(y))
  22. #define MAX(x,y) ((x)>(y)?(x):(y))
  23. void RemoveTrailingWhitespace(CHAR * s);
  24. void RemoveTrailingSlashes(CHAR * s);
  25. void RemoveTrailingCharacters(CHAR * s, PCSTR CharsToRemove);
  26. #define StringLength(s) ((int)strlen(s))
  27. #define StringLengthW(s) ((int)wcslen(s))
  28. int FindCharInString(PCSTR StringToSearch, int CharToFind);
  29. int FindCharInStringW(PCWSTR StringToSearch, int CharToFind);
  30. #define IS_UPPER(x) ( (x) >= 'A' && (x) <= 'Z' )
  31. #define IS_LOWER(x) ( (x) >= 'a' && (x) <= 'z' )
  32. #define TO_UPPER(x) (IS_LOWER(x) ? ((x) & ~0x20) : (x))
  33. #define TO_LOWER(x) (IS_UPPER(x) ? ((x) | 0x20) : (x))
  34. extern const CHAR WhiteSpace[];
  35. #define NUMBER_OF(x) (sizeof(x)/sizeof((x)[0]))
  36. PCSTR GetErrorStringA(int Error);
  37. PCSTR GetLastPathElement(PCSTR s);
  38. void CloseMemoryMappedFile(struct _MEMORY_MAPPED_FILE * MemoryMappedFile);
  39. BOOL MyIsHandleValid(HANDLE Handle);
  40. void MyCloseHandle(HANDLE * Handle);
  41. void MyUnmapViewOfFile(PVOID * Handle);
  42. HRESULT OpenFileForRead(PCSTR Path, HANDLE * FileHandle);
  43. HRESULT GetFileSize64(HANDLE FileHandle, __int64 * Out);
  44. HRESULT MapEntireFileForRead(HANDLE FileHandle, HANDLE * FileMapping OPTIONAL, PBYTE * ViewOfFile);
  45. typedef struct _MEMORY_MAPPED_FILE {
  46. PCSTR FilePathA;
  47. PCWSTR FilePathW;
  48. HANDLE FileHandle;
  49. HANDLE FileMappingHandle;
  50. __int64 FileSize;
  51. PBYTE MappedViewBase;
  52. } MEMORY_MAPPED_FILE, *PMEMORY_MAPPED_FILE;
  53. HRESULT
  54. OpenAndMapEntireFileForRead(
  55. PMEMORY_MAPPED_FILE MemoryMappedFile,
  56. PCSTR FilePath
  57. );
  58. void CloseMemoryMappedFile(PMEMORY_MAPPED_FILE MemoryMappedFile);
  59. typedef struct _PDB_INFO {
  60. BYTE TypeSignature[4]; /* "NBxx" for VC<7, usually NB10, "RSDS" for VC7 */
  61. union
  62. {
  63. struct
  64. {
  65. unsigned long Offset; /* always zero */
  66. unsigned long Signature;
  67. unsigned long Age;
  68. CHAR PdbFilePath[1];
  69. } NB10;
  70. struct
  71. {
  72. GUID Guid;
  73. unsigned long Age;
  74. CHAR PdbFilePath[1];
  75. } RSDS;
  76. } u;
  77. } PDB_INFO, *PPDB_INFO;
  78. typedef struct _PDB_INFO_EX {
  79. PCSTR ImageFilePathA;
  80. PCWSTR ImageFilePathW;
  81. PCSTR PdbFilePathA;
  82. PCWSTR PdbFilePathW;
  83. PPDB_INFO PdbInfo;
  84. MEMORY_MAPPED_FILE MemoryMappedFile;
  85. } PDB_INFO_EX, *PPDB_INFO_EX;
  86. HRESULT GetPdbInfoEx(struct _PDB_INFO_EX * PdbInfo, PCSTR ImageFilePath);
  87. void ClosePdbInfoEx(struct _PDB_INFO_EX * PdbInfo);
  88. #if defined (__cplusplus)
  89. }
  90. #endif