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.

397 lines
7.8 KiB

  1. /*++
  2. Copyright (c) 1985 - 1999, Microsoft Corporation
  3. Module Name:
  4. condll.h
  5. Abstract:
  6. This module contains the include files and definitions for the
  7. console client DLL.
  8. Author:
  9. Therese Stowell (thereses) 16-Nov-1990
  10. Revision History:
  11. --*/
  12. #include <nt.h>
  13. #include <ntrtl.h>
  14. #include <nturtl.h>
  15. //Don't include this when building wow64 type/function database.
  16. #if !defined(SORTPP_PASS)
  17. #include <windows.h>
  18. #endif
  19. #include <winuserk.h> // temporary
  20. #include <conroute.h>
  21. #include "conapi.h"
  22. #include "ntcsrdll.h"
  23. #include "conmsg.h"
  24. #include <string.h>
  25. #if defined(BUILD_WOW64)
  26. #define SET_CONSOLE_HANDLE(HANDLE) (Wow64SetConsoleHandle(HANDLE))
  27. #define GET_CONSOLE_HANDLE (Wow64GetConsoleHandle())
  28. #define SET_LAST_ERROR(ERROR) (Wow64SetLastError(ERROR) )
  29. #define SET_LAST_NT_ERROR(ERROR) (Wow64SetLastError(RtlNtStatusToDosError( ERROR )) )
  30. #include "ntwow64c.h"
  31. #else
  32. #define SET_CONSOLE_HANDLE(HANDLE) ((NtCurrentPeb())->ProcessParameters->ConsoleHandle = HANDLE)
  33. #define GET_CONSOLE_HANDLE ((NtCurrentPeb())->ProcessParameters->ConsoleHandle)
  34. #define SET_LAST_ERROR(ERROR) (SetLastError( ERROR ) )
  35. #define SET_LAST_NT_ERROR(ERROR) (SetLastError( RtlNtStatusToDosError( ERROR ) ) )
  36. #endif
  37. #define VALID_ACCESSES (GENERIC_READ | GENERIC_WRITE)
  38. #define VALID_SHARE_ACCESSES (FILE_SHARE_READ | FILE_SHARE_WRITE)
  39. #define VALID_DUP_OPTIONS (DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)
  40. #define CONSOLE_RECT_SIZE_X(RECT) ((RECT)->Right - (RECT)->Left + 1)
  41. #define CONSOLE_RECT_SIZE_Y(RECT) ((RECT)->Bottom - (RECT)->Top + 1)
  42. //
  43. // this critical section is used to serialize access to the code that
  44. // accesses the ctrl handler data structures and the code that allocs
  45. // and frees consoles.
  46. //
  47. CRITICAL_SECTION DllLock;
  48. #define LockDll() RtlEnterCriticalSection(&DllLock)
  49. #define UnlockDll() RtlLeaveCriticalSection(&DllLock)
  50. NTSTATUS
  51. InitializeCtrlHandling( VOID );
  52. VOID
  53. InitExeName(
  54. VOID
  55. );
  56. USHORT
  57. GetCurrentExeName(
  58. LPWSTR Buffer,
  59. ULONG BufferLength
  60. );
  61. HANDLE
  62. APIENTRY
  63. OpenConsoleWInternal(
  64. IN ULONG HandleType,
  65. IN ULONG DesiredAccess,
  66. IN BOOL InheritHandle,
  67. IN ULONG ShareMode
  68. );
  69. BOOL
  70. APIENTRY
  71. ReadConsoleInternal(
  72. IN HANDLE hConsoleInput,
  73. OUT LPVOID lpBuffer,
  74. IN DWORD nNumberOfCharsToRead,
  75. OUT LPDWORD lpNumberOfCharsRead,
  76. IN OUT LPVOID lpReserved,
  77. IN BOOLEAN Unicode,
  78. IN USHORT ExeNameLength,
  79. IN LPWSTR ExeName
  80. );
  81. BOOL
  82. APIENTRY
  83. WriteConsoleInternal(
  84. IN HANDLE hConsoleOutput,
  85. IN CONST VOID *lpBuffer,
  86. IN DWORD nNumberOfCharsToWrite,
  87. OUT LPDWORD lpNumberOfCharsWritten,
  88. IN BOOLEAN Unicode
  89. );
  90. BOOL
  91. APIENTRY
  92. RegisterConsoleIMEInternal(
  93. IN HWND hWndConsoleIME,
  94. IN DWORD dwConsoleIMEThreadId,
  95. IN DWORD DesktopLength,
  96. IN LPWSTR Desktop,
  97. OUT DWORD *dwConsoleThreadId
  98. );
  99. BOOL
  100. APIENTRY
  101. UnregisterConsoleIMEInternal(
  102. IN DWORD dwConsoleIMEThtreadId
  103. );
  104. BOOL
  105. APIENTRY
  106. GetConsoleInput(
  107. IN HANDLE hConsoleInput,
  108. OUT PINPUT_RECORD lpBuffer,
  109. IN DWORD nLength,
  110. OUT LPDWORD lpNumberOfEventsRead,
  111. IN USHORT wFlags,
  112. IN BOOLEAN Unicode
  113. );
  114. BOOL
  115. APIENTRY
  116. WriteConsoleInputInternal(
  117. IN HANDLE hConsoleInput,
  118. IN CONST INPUT_RECORD *lpBuffer,
  119. IN DWORD nLength,
  120. OUT LPDWORD lpNumberOfEventsWritten,
  121. IN BOOLEAN Unicode,
  122. IN BOOLEAN Append
  123. );
  124. BOOL
  125. APIENTRY
  126. ReadConsoleOutputInternal(
  127. IN HANDLE hConsoleOutput,
  128. OUT PCHAR_INFO lpBuffer,
  129. IN COORD dwBufferSize,
  130. IN COORD dwBufferCoord,
  131. IN OUT PSMALL_RECT lpReadRegion,
  132. IN BOOLEAN Unicode
  133. );
  134. BOOL
  135. APIENTRY
  136. WriteConsoleOutputInternal(
  137. IN HANDLE hConsoleOutput,
  138. IN CONST CHAR_INFO *lpBuffer,
  139. IN COORD dwBufferSize,
  140. IN COORD dwBufferCoord,
  141. IN PSMALL_RECT lpWriteRegion,
  142. IN BOOLEAN Unicode
  143. );
  144. BOOL
  145. APIENTRY
  146. ReadConsoleOutputString(
  147. IN HANDLE hConsoleOutput,
  148. OUT LPVOID lpString,
  149. IN DWORD nLength,
  150. IN DWORD nSize,
  151. IN DWORD fFlags,
  152. IN COORD dwReadCoord,
  153. OUT LPDWORD lpNumberOfElementsRead
  154. );
  155. BOOL
  156. APIENTRY
  157. WriteConsoleOutputString(
  158. IN HANDLE hConsoleOutput,
  159. IN CONST VOID *lpString,
  160. IN DWORD nLength,
  161. IN DWORD nSize,
  162. IN DWORD fFlags,
  163. IN COORD dwWriteCoord,
  164. OUT LPDWORD lpNumberOfElementsWritten
  165. );
  166. BOOL
  167. APIENTRY
  168. FillConsoleOutput(
  169. IN HANDLE hConsoleOutput,
  170. IN WORD Element,
  171. IN DWORD nLength,
  172. IN DWORD fFlags,
  173. IN COORD dwWriteCoord,
  174. OUT LPDWORD lpNumberOfElementsWritten
  175. );
  176. BOOL
  177. APIENTRY
  178. GetConsoleKeyboardLayoutNameWorker(
  179. OUT LPSTR pszLayout,
  180. IN BOOL bAnsi);
  181. BOOL
  182. APIENTRY
  183. SetConsolePaletteInternal(
  184. IN HANDLE hConsoleOutput,
  185. IN HPALETTE hPalette,
  186. IN UINT dwUsage
  187. );
  188. BOOL
  189. APIENTRY
  190. ScrollConsoleScreenBufferInternal(
  191. IN HANDLE hConsoleOutput,
  192. IN CONST SMALL_RECT *lpScrollRectangle,
  193. IN CONST SMALL_RECT *lpClipRectangle,
  194. IN COORD dwDestinationOrigin,
  195. IN CONST CHAR_INFO *lpFill,
  196. IN BOOLEAN Unicode
  197. );
  198. NTSTATUS
  199. APIENTRY
  200. SetConsoleOutputCPInternal(
  201. IN UINT wCodePageID
  202. );
  203. VOID
  204. APIENTRY
  205. SetLastConsoleEventActiveInternal(
  206. VOID
  207. );
  208. BOOL
  209. APIENTRY
  210. ConnectConsoleInternal(
  211. IN PWSTR pObjectDirectory,
  212. IN OUT PCONSOLE_API_CONNECTINFO pConnectInfo,
  213. OUT PBOOLEAN pServerProcess
  214. );
  215. BOOL
  216. APIENTRY
  217. AllocConsoleInternal(
  218. IN LPWSTR lpTitle,
  219. IN DWORD dwTitleLength,
  220. IN LPWSTR lpDesktop,
  221. IN DWORD dwDesktopLength,
  222. IN LPWSTR lpCurDir,
  223. IN DWORD dwCurDirLength,
  224. IN LPWSTR AppName,
  225. IN DWORD dwAppNameLength,
  226. IN LPTHREAD_START_ROUTINE CtrlRoutine,
  227. IN LPTHREAD_START_ROUTINE PropRoutine,
  228. IN OUT PCONSOLE_INFO pConsoleInfo
  229. );
  230. BOOL
  231. APIENTRY
  232. FreeConsoleInternal(
  233. VOID
  234. );
  235. BOOL
  236. APIENTRY
  237. AttachConsoleInternal(
  238. IN DWORD dwProcessId,
  239. IN LPTHREAD_START_ROUTINE CtrlRoutine,
  240. IN LPTHREAD_START_ROUTINE PropRoutine,
  241. IN OUT PCONSOLE_INFO pConsoleInfo
  242. );
  243. BOOL
  244. WINAPI
  245. GetConsoleLangId(
  246. OUT LANGID *lpLangId
  247. );
  248. BOOL
  249. APIENTRY
  250. AddConsoleAliasInternal(
  251. IN LPVOID Source,
  252. IN UINT SourceLength,
  253. IN LPVOID Target,
  254. IN UINT TargetLength,
  255. IN LPVOID ExeName,
  256. IN BOOLEAN Unicode
  257. );
  258. DWORD
  259. APIENTRY
  260. GetConsoleAliasInternal(
  261. IN LPVOID Source,
  262. IN UINT SourceLength,
  263. OUT LPVOID TargetBuffer,
  264. IN UINT TargetBufferLength,
  265. IN LPVOID ExeName,
  266. IN BOOLEAN Unicode
  267. );
  268. DWORD
  269. APIENTRY
  270. GetConsoleAliasesLengthInternal(
  271. IN LPVOID ExeName,
  272. IN BOOLEAN Unicode
  273. );
  274. DWORD
  275. APIENTRY
  276. GetConsoleAliasExesLengthInternal(
  277. IN BOOLEAN Unicode
  278. );
  279. DWORD
  280. APIENTRY
  281. GetConsoleAliasesInternal(
  282. OUT LPVOID AliasBuffer,
  283. IN DWORD AliasBufferLength,
  284. IN LPVOID ExeName,
  285. IN BOOLEAN Unicode
  286. );
  287. DWORD
  288. APIENTRY
  289. GetConsoleAliasExesInternal(
  290. OUT LPVOID ExeNameBuffer,
  291. IN DWORD ExeNameBufferLength,
  292. IN BOOLEAN Unicode
  293. );
  294. VOID
  295. APIENTRY
  296. ExpungeConsoleCommandHistoryInternal(
  297. IN LPVOID ExeName,
  298. IN BOOLEAN Unicode
  299. );
  300. BOOL
  301. APIENTRY
  302. SetConsoleNumberOfCommandsInternal(
  303. IN DWORD Number,
  304. IN LPVOID ExeName,
  305. IN BOOLEAN Unicode
  306. );
  307. DWORD
  308. APIENTRY
  309. GetConsoleCommandHistoryLengthInternal(
  310. IN LPVOID ExeName,
  311. IN BOOLEAN Unicode
  312. );
  313. DWORD
  314. APIENTRY
  315. GetConsoleCommandHistoryInternal(
  316. OUT LPVOID Commands,
  317. IN DWORD CommandBufferLength,
  318. IN LPVOID ExeName,
  319. IN BOOLEAN Unicode
  320. );
  321. DWORD
  322. APIENTRY
  323. GetConsoleTitleInternal(
  324. OUT PVOID lpConsoleTitle,
  325. IN DWORD nSize,
  326. IN BOOLEAN Unicode
  327. );
  328. BOOL
  329. APIENTRY
  330. SetConsoleTitleInternal(
  331. IN CONST VOID *lpConsoleTitle,
  332. IN DWORD TitleLength, // in bytes
  333. IN BOOLEAN Unicode
  334. );
  335. VOID
  336. SetTEBLangID(
  337. VOID
  338. );