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.

119 lines
4.2 KiB

  1. /****************************** Module Header ******************************\
  2. * Module Name: common.h
  3. *
  4. * Copyright (c) 1985 - 2002, Microsoft Corporation
  5. *
  6. * Cross Language Migration Tool, Token Generator header file
  7. *
  8. \***************************************************************************/
  9. #ifndef __COMMON_H__
  10. #define __COMMON_H__
  11. #include <windows.h>
  12. #include <winreg.h>
  13. #include <setupapi.h>
  14. #include <stdio.h>
  15. #include <strsafe.h>
  16. #define MAX_SRC_PATH 16
  17. #define MAX_KEYS 1024
  18. #define MAX_CHAR 512
  19. #define LSTR_EQUAL 0
  20. #define TEXT_STRING_SECTION TEXT("Strings")
  21. #define TEXT_INF TEXT("INF")
  22. #define TEXT_DLL TEXT("DLL")
  23. #define TEXT_MSG TEXT("MSG")
  24. #define TEXT_STR TEXT("STR")
  25. #define TEXT_DEFAULT_TEMPLATE_FILE TEXT("CLMTOK.TXT")
  26. #define TEXT_DEFAULT_OUTPUT_FILE TEXT("CLMTOK.OUT")
  27. #define TEXT_TOKGEN_TEMP_PATH_NAME TEXT("CLMTOK")
  28. #define ARRAYSIZE(s) (sizeof(s) / sizeof(s[0]))
  29. // Macros for heap memory management
  30. #define MEMALLOC(cb) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cb)
  31. #define MEMFREE(pv) HeapFree(GetProcessHeap(), 0, pv);
  32. #define MEMREALLOC(pv, cb) HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, pv, cb)
  33. // Structure to keep source paths
  34. typedef struct _SRC_PATH
  35. {
  36. WCHAR wszSrcName[32]; // Name of source path
  37. WCHAR wszPath[MAX_PATH]; // Path
  38. } SRC_PATH, *PSRC_PATH;
  39. typedef struct _STRING_TO_DATA {
  40. TCHAR String[50];
  41. HKEY Data;
  42. } STRING_TO_DATA, *PSTRING_TO_DATA;
  43. typedef struct _STRING_TO_HKEY
  44. {
  45. TCHAR String[50]; // HKEY name string
  46. HKEY hKey; // HKEY value associated to the name
  47. } STRING_TO_HKEY, *PSTRING_TO_HKEY;
  48. //
  49. // Global variables
  50. //
  51. WCHAR g_wszTemplateFile[MAX_PATH]; // Template file name
  52. WCHAR g_wszOutputFile[MAX_PATH]; // Output file name
  53. WCHAR g_wszTempFolder[MAX_PATH]; // Temp folder used in our program
  54. WCHAR g_wszTargetLCIDSection[32]; // String section name with lcid - Strings.XXXX
  55. LCID g_lcidTarget; // LCID of token file to be generated
  56. BOOL g_bUseDefaultTemplate; // Use default template file
  57. BOOL g_bUseDefaultOuputFile; // Use default output file
  58. SRC_PATH g_SrcPath[MAX_SRC_PATH];
  59. DWORD g_dwSrcCount;
  60. //
  61. // Function Prototypes
  62. //
  63. // Engine.c
  64. HRESULT GenerateTokenFile(VOID);
  65. HRESULT ReadSourcePathData(HINF);
  66. HRESULT ResolveStringsSection(HINF, LPCWSTR);
  67. HRESULT ResolveLine(PINFCONTEXT, LPWSTR*, LPDWORD, LPWSTR*, LPDWORD);
  68. HRESULT InitOutputFile(LPCWSTR, LPWSTR, DWORD);
  69. HRESULT WriteToOutputFile(LPCWSTR, LPCWSTR, LPCWSTR);
  70. HRESULT ResolveValue(PINFCONTEXT, LPWSTR*, LPDWORD);
  71. HRESULT ResolveSourceFile(LPCWSTR, LPCWSTR, LPWSTR, DWORD);
  72. HRESULT GetStringFromINF(LPCWSTR, LPCWSTR, LPCWSTR, LPWSTR*, LPDWORD);
  73. HRESULT GetStringFromDLL(LPCWSTR, UINT, LPWSTR*, LPDWORD);
  74. HRESULT GetStringFromMSG(LPCWSTR, DWORD, DWORD, LPWSTR*, LPDWORD);
  75. HRESULT GetStringFromSTR(LPCWSTR, LPWSTR*, LPDWORD);
  76. BOOL SetPrivateEnvironmentVar();
  77. HRESULT RemoveUnneededStrings(HINF);
  78. HRESULT GetExpString(LPWSTR, DWORD, LPCWSTR);
  79. HRESULT RemoveUnneededString(LPCWSTR, LPCWSTR);
  80. HRESULT ExtractStrings(HINF);
  81. HRESULT ExtractString(LPCWSTR, LPCWSTR, LPCWSTR, LPCWSTR, LPCWSTR);
  82. // From Utils.c
  83. LONG TokenizeMultiSzString(LPCWSTR, DWORD, LPCWSTR[], DWORD);
  84. LONG ExtractTokenString(LPWSTR, LPWSTR[], LPCWSTR, DWORD);
  85. HRESULT ConcatFilePath(LPCWSTR, LPCWSTR, LPWSTR, DWORD);
  86. HRESULT CopyCompressedFile(LPCWSTR, LPCWSTR, LPCWSTR, LPWSTR, DWORD);
  87. HRESULT LaunchProgram(LPWSTR, LPWSTR);
  88. HRESULT GetPathFromSourcePathName(LPCWSTR, LPWSTR, DWORD);
  89. HRESULT GetCabFileName(LPCWSTR, LPWSTR, DWORD, LPWSTR, DWORD);
  90. HRESULT GetCabTempDirectory(LPCWSTR);
  91. HRESULT CreateTempDirectory(LPWSTR, DWORD);
  92. void LTrim(LPWSTR);
  93. void RTrim(LPWSTR);
  94. BOOL Str2KeyPath(LPCWSTR, PHKEY, LPCWSTR*);
  95. HRESULT StringSubstitute(LPWSTR, DWORD, LPCWSTR, LPCWSTR, LPCWSTR);
  96. int CompareEngString(LPCTSTR, LPCTSTR);
  97. HRESULT ExtractSubString(LPWSTR, DWORD, LPCWSTR, LPCWSTR, LPCWSTR); // Right delimitor
  98. #endif