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.

164 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_W9X ((DWORD) 1)
  33. #define IDX_I64 ((DWORD) 2)
  34. #define IDX_AMD64 ((DWORD) 3)
  35. #define IDX_UNKNOWN ((DWORD)-1)
  36. #define IDX_SPLVER_0 ((DWORD)0)
  37. #define IDX_SPLVER_2 ((DWORD)1)
  38. #define IDX_SPLVER_3 ((DWORD)2)
  39. typedef struct _PLTINFO {
  40. LPCTSTR lpszCab; // Name of cab platform.
  41. LPCTSTR lpszEnv; // Environment string.
  42. LPCTSTR lpszPlt; // Platform override string.
  43. WORD wArch; // Integer representation of platform-type.
  44. } PLTINFO;
  45. typedef PLTINFO *PPLTINFO;
  46. typedef PLTINFO NEAR *NPPLTINFO;
  47. typedef PLTINFO FAR *LPPLTINFO;
  48. BOOL genIsWin9X(DWORD);
  49. DWORD genIdxCliPlatform(DWORD);
  50. LPCTSTR genStrCliCab(DWORD);
  51. LPCTSTR genStrCliEnvironment(DWORD);
  52. LPCTSTR genStrCliOverride(DWORD);
  53. WORD genValCliArchitecture(DWORD);
  54. DWORD genIdxCliVersion(DWORD);
  55. LPCTSTR genStrCliVersion(DWORD);
  56. DWORD genIdxFromStrVersion(LPCTSTR);
  57. WORD genValSvrArchitecture(VOID);
  58. /***************************************\
  59. * genIsWin9X
  60. \***************************************/
  61. __inline BOOL genIsWin9X(
  62. DWORD idxPlt)
  63. {
  64. return (idxPlt == IDX_W9X);
  65. }
  66. /***************************************\
  67. * genWCtoMB
  68. \***************************************/
  69. __inline DWORD genWCtoMB(
  70. LPSTR lpszMB,
  71. LPCWSTR lpszWC,
  72. DWORD cbSize)
  73. {
  74. cbSize = (DWORD)WideCharToMultiByte(CP_ACP,
  75. 0,
  76. lpszWC,
  77. -1,
  78. lpszMB,
  79. (int)cbSize,
  80. NULL,
  81. NULL);
  82. return cbSize;
  83. }
  84. /***************************************\
  85. * genMBtoWC
  86. \***************************************/
  87. __inline DWORD genMBtoWC(
  88. LPWSTR lpszWC,
  89. LPCSTR lpszMB,
  90. DWORD cbSize)
  91. {
  92. cbSize = (DWORD)MultiByteToWideChar(CP_ACP,
  93. MB_PRECOMPOSED,
  94. lpszMB,
  95. -1,
  96. lpszWC,
  97. (int)(cbSize / sizeof(WCHAR)));
  98. return (cbSize * sizeof(WCHAR));
  99. }
  100. /***************************************\
  101. * gen_OpenFileRead
  102. \***************************************/
  103. __inline HANDLE gen_OpenFileRead(
  104. LPCTSTR lpszName)
  105. {
  106. return CreateFile(lpszName,
  107. GENERIC_READ,
  108. FILE_SHARE_READ,
  109. NULL,
  110. OPEN_EXISTING,
  111. FILE_ATTRIBUTE_NORMAL,
  112. NULL);
  113. }
  114. /***************************************\
  115. * gen_OpenFileWrite
  116. \***************************************/
  117. __inline HANDLE gen_OpenFileWrite(
  118. LPCTSTR lpszName)
  119. {
  120. return CreateFile(lpszName,
  121. GENERIC_WRITE,
  122. 0,
  123. NULL,
  124. CREATE_ALWAYS,
  125. FILE_ATTRIBUTE_NORMAL,
  126. NULL);
  127. }
  128. /***************************************\
  129. * gen_OpenDirectory
  130. \***************************************/
  131. __inline HANDLE gen_OpenDirectory(
  132. LPCTSTR lpszDir)
  133. {
  134. return CreateFile(lpszDir,
  135. 0,
  136. FILE_SHARE_READ | FILE_SHARE_WRITE,
  137. NULL,
  138. OPEN_EXISTING,
  139. FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS,
  140. NULL);
  141. }