Source code of Windows XP (NT5)
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.

168 lines
4.5 KiB

  1. /*****************************************************************************\
  2. * MODULE: genutil.h
  3. *
  4. * This is the header module for genutil.c. This contains useful utility
  5. * routines shared across the gen* file.s
  6. *
  7. *
  8. * Copyright (C) 1996-1997 Microsoft Corporation
  9. * Copyright (C) 1996-1997 Hewlett Packard
  10. *
  11. * history:
  12. * 22-Nov-1996 <chriswil> created.
  13. *
  14. \*****************************************************************************/
  15. #define PRT_LEV_2 2
  16. LPTSTR genGetCurDir(VOID);
  17. LPTSTR genGetWinDir(VOID);
  18. LPTSTR genBuildFileName(LPCTSTR, LPCTSTR, LPCTSTR);
  19. LPTSTR genFindCharDiff(LPTSTR, LPTSTR);
  20. LPTSTR genFindChar(LPTSTR, TCHAR);
  21. LPTSTR genFindRChar(LPTSTR, TCHAR);
  22. LPWSTR genWCFromMB(LPCSTR);
  23. LPTSTR genTCFromMB(LPCSTR);
  24. LPTSTR genTCFromWC(LPCWSTR);
  25. LPSTR genMBFromWC(LPCWSTR);
  26. LPSTR genMBFromTC(LPCTSTR);
  27. LPTSTR genItoA(int);
  28. BOOL genUpdIPAddr(VOID);
  29. LPTSTR genFrnName(LPCTSTR);
  30. WORD genChkSum(LPCTSTR);
  31. #define IDX_X86 ((DWORD) 0)
  32. #define IDX_MIP ((DWORD) 1)
  33. #define IDX_AXP ((DWORD) 2)
  34. #define IDX_PPC ((DWORD) 3)
  35. #define IDX_W9X ((DWORD) 4)
  36. #define IDX_I64 ((DWORD) 5)
  37. #define IDX_AMD64 ((DWORD) 6)
  38. #define IDX_UNKNOWN ((DWORD)-1)
  39. #define IDX_SPLVER_0 ((DWORD)0)
  40. #define IDX_SPLVER_1 ((DWORD)1)
  41. #define IDX_SPLVER_2 ((DWORD)2)
  42. #define IDX_SPLVER_3 ((DWORD)3)
  43. typedef struct _PLTINFO {
  44. LPCTSTR lpszCab; // Name of cab platform.
  45. LPCTSTR lpszEnv; // Environment string.
  46. LPCTSTR lpszPlt; // Platform override string.
  47. WORD wArch; // Integer representation of platform-type.
  48. } PLTINFO;
  49. typedef PLTINFO *PPLTINFO;
  50. typedef PLTINFO NEAR *NPPLTINFO;
  51. typedef PLTINFO FAR *LPPLTINFO;
  52. BOOL genIsWin9X(DWORD);
  53. DWORD genIdxCliPlatform(DWORD);
  54. LPCTSTR genStrCliCab(DWORD);
  55. LPCTSTR genStrCliEnvironment(DWORD);
  56. LPCTSTR genStrCliOverride(DWORD);
  57. WORD genValCliArchitecture(DWORD);
  58. DWORD genIdxCliVersion(DWORD);
  59. LPCTSTR genStrCliVersion(DWORD);
  60. DWORD genIdxFromStrVersion(LPCTSTR);
  61. WORD genValSvrArchitecture(VOID);
  62. /***************************************\
  63. * genIsWin9X
  64. \***************************************/
  65. __inline BOOL genIsWin9X(
  66. DWORD idxPlt)
  67. {
  68. return (idxPlt == IDX_W9X);
  69. }
  70. /***************************************\
  71. * genWCtoMB
  72. \***************************************/
  73. __inline DWORD genWCtoMB(
  74. LPSTR lpszMB,
  75. LPCWSTR lpszWC,
  76. DWORD cbSize)
  77. {
  78. cbSize = (DWORD)WideCharToMultiByte(CP_ACP,
  79. 0,
  80. lpszWC,
  81. -1,
  82. lpszMB,
  83. (int)cbSize,
  84. NULL,
  85. NULL);
  86. return cbSize;
  87. }
  88. /***************************************\
  89. * genMBtoWC
  90. \***************************************/
  91. __inline DWORD genMBtoWC(
  92. LPWSTR lpszWC,
  93. LPCSTR lpszMB,
  94. DWORD cbSize)
  95. {
  96. cbSize = (DWORD)MultiByteToWideChar(CP_ACP,
  97. MB_PRECOMPOSED,
  98. lpszMB,
  99. -1,
  100. lpszWC,
  101. (int)(cbSize / sizeof(WCHAR)));
  102. return (cbSize * sizeof(WCHAR));
  103. }
  104. /***************************************\
  105. * gen_OpenFileRead
  106. \***************************************/
  107. __inline HANDLE gen_OpenFileRead(
  108. LPCTSTR lpszName)
  109. {
  110. return CreateFile(lpszName,
  111. GENERIC_READ,
  112. FILE_SHARE_READ,
  113. NULL,
  114. OPEN_EXISTING,
  115. FILE_ATTRIBUTE_NORMAL,
  116. NULL);
  117. }
  118. /***************************************\
  119. * gen_OpenFileWrite
  120. \***************************************/
  121. __inline HANDLE gen_OpenFileWrite(
  122. LPCTSTR lpszName)
  123. {
  124. return CreateFile(lpszName,
  125. GENERIC_WRITE,
  126. 0,
  127. NULL,
  128. CREATE_ALWAYS,
  129. FILE_ATTRIBUTE_NORMAL,
  130. NULL);
  131. }
  132. /***************************************\
  133. * gen_OpenDirectory
  134. \***************************************/
  135. __inline HANDLE gen_OpenDirectory(
  136. LPCTSTR lpszDir)
  137. {
  138. return CreateFile(lpszDir,
  139. 0,
  140. FILE_SHARE_READ | FILE_SHARE_WRITE,
  141. NULL,
  142. OPEN_EXISTING,
  143. FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS,
  144. NULL);
  145. }