1c2c66affSColin Finck /*
2c2c66affSColin Finck  * COPYRIGHT:       See COPYING in the top level directory
3c2c66affSColin Finck  * PROJECT:         ReactOS system libraries
4c2c66affSColin Finck  * FILE:            dll/win32/kernel32/client/console/history.c
5c2c66affSColin Finck  * PURPOSE:         Win32 Console Client history functions
6c2c66affSColin Finck  * PROGRAMMERS:     Jeffrey Morlan
7c2c66affSColin Finck  */
8c2c66affSColin Finck 
9c2c66affSColin Finck /* INCLUDES *******************************************************************/
10c2c66affSColin Finck 
11c2c66affSColin Finck #include <k32.h>
12c2c66affSColin Finck 
13c2c66affSColin Finck #define NDEBUG
14c2c66affSColin Finck #include <debug.h>
15c2c66affSColin Finck 
16c2c66affSColin Finck 
17c2c66affSColin Finck /* PRIVATE FUNCTIONS **********************************************************/
18c2c66affSColin Finck 
19c2c66affSColin Finck #if 0
20c2c66affSColin Finck /* Get the size needed to copy a string to a capture buffer, including alignment */
21c2c66affSColin Finck static ULONG
22c2c66affSColin Finck IntStringSize(LPCVOID String,
23c2c66affSColin Finck               BOOL Unicode)
24c2c66affSColin Finck {
25c2c66affSColin Finck     ULONG Size = (Unicode ? wcslen(String) : strlen(String)) * sizeof(WCHAR);
26c2c66affSColin Finck     return (Size + 3) & ~3;
27c2c66affSColin Finck }
28c2c66affSColin Finck #endif
29c2c66affSColin Finck 
30c2c66affSColin Finck static VOID
IntExpungeConsoleCommandHistory(LPCVOID lpExeName,BOOLEAN bUnicode)31c2c66affSColin Finck IntExpungeConsoleCommandHistory(LPCVOID lpExeName, BOOLEAN bUnicode)
32c2c66affSColin Finck {
33c2c66affSColin Finck     CONSOLE_API_MESSAGE ApiMessage;
34c2c66affSColin Finck     PCONSOLE_EXPUNGECOMMANDHISTORY ExpungeCommandHistoryRequest = &ApiMessage.Data.ExpungeCommandHistoryRequest;
35c2c66affSColin Finck     PCSR_CAPTURE_BUFFER CaptureBuffer;
36c2c66affSColin Finck 
37c2c66affSColin Finck     USHORT NumChars = (USHORT)(lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0);
38c2c66affSColin Finck 
39c2c66affSColin Finck     if (lpExeName == NULL || NumChars == 0)
40c2c66affSColin Finck     {
41c2c66affSColin Finck         SetLastError(ERROR_INVALID_PARAMETER);
42c2c66affSColin Finck         return;
43c2c66affSColin Finck     }
44c2c66affSColin Finck 
45c2c66affSColin Finck     ExpungeCommandHistoryRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
46c2c66affSColin Finck     ExpungeCommandHistoryRequest->ExeLength     = NumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
47c2c66affSColin Finck     ExpungeCommandHistoryRequest->Unicode  =
48c2c66affSColin Finck     ExpungeCommandHistoryRequest->Unicode2 = bUnicode;
49c2c66affSColin Finck 
50c2c66affSColin Finck     // CaptureBuffer = CsrAllocateCaptureBuffer(1, IntStringSize(lpExeName, bUnicode));
51c2c66affSColin Finck     CaptureBuffer = CsrAllocateCaptureBuffer(1, ExpungeCommandHistoryRequest->ExeLength);
52c2c66affSColin Finck     if (!CaptureBuffer)
53c2c66affSColin Finck     {
54c2c66affSColin Finck         DPRINT1("CsrAllocateCaptureBuffer failed!\n");
55c2c66affSColin Finck         SetLastError(ERROR_NOT_ENOUGH_MEMORY);
56c2c66affSColin Finck         return;
57c2c66affSColin Finck     }
58c2c66affSColin Finck 
59c2c66affSColin Finck     CsrCaptureMessageBuffer(CaptureBuffer,
60c2c66affSColin Finck                             (PVOID)lpExeName,
61c2c66affSColin Finck                             ExpungeCommandHistoryRequest->ExeLength,
62c2c66affSColin Finck                             (PVOID)&ExpungeCommandHistoryRequest->ExeName);
63c2c66affSColin Finck 
64c2c66affSColin Finck     CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
65c2c66affSColin Finck                         CaptureBuffer,
66c2c66affSColin Finck                         CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepExpungeCommandHistory),
67c2c66affSColin Finck                         sizeof(*ExpungeCommandHistoryRequest));
68c2c66affSColin Finck 
69c2c66affSColin Finck     CsrFreeCaptureBuffer(CaptureBuffer);
70c2c66affSColin Finck 
71c2c66affSColin Finck     if (!NT_SUCCESS(ApiMessage.Status))
72c2c66affSColin Finck         BaseSetLastNTError(ApiMessage.Status);
73c2c66affSColin Finck }
74c2c66affSColin Finck 
75c2c66affSColin Finck 
76c2c66affSColin Finck static DWORD
IntGetConsoleCommandHistory(LPVOID lpHistory,DWORD cbHistory,LPCVOID lpExeName,BOOLEAN bUnicode)77c2c66affSColin Finck IntGetConsoleCommandHistory(LPVOID lpHistory, DWORD cbHistory, LPCVOID lpExeName, BOOLEAN bUnicode)
78c2c66affSColin Finck {
79c2c66affSColin Finck     CONSOLE_API_MESSAGE ApiMessage;
80c2c66affSColin Finck     PCONSOLE_GETCOMMANDHISTORY GetCommandHistoryRequest = &ApiMessage.Data.GetCommandHistoryRequest;
81c2c66affSColin Finck     PCSR_CAPTURE_BUFFER CaptureBuffer;
82c2c66affSColin Finck 
83c2c66affSColin Finck     USHORT NumChars = (USHORT)(lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0);
84c2c66affSColin Finck 
85c2c66affSColin Finck     if (lpExeName == NULL || NumChars == 0)
86c2c66affSColin Finck     {
87c2c66affSColin Finck         SetLastError(ERROR_INVALID_PARAMETER);
88c2c66affSColin Finck         return 0;
89c2c66affSColin Finck     }
90c2c66affSColin Finck 
91c2c66affSColin Finck     GetCommandHistoryRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
92c2c66affSColin Finck     GetCommandHistoryRequest->HistoryLength = cbHistory;
93c2c66affSColin Finck     GetCommandHistoryRequest->ExeLength     = NumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
94c2c66affSColin Finck     GetCommandHistoryRequest->Unicode  =
95c2c66affSColin Finck     GetCommandHistoryRequest->Unicode2 = bUnicode;
96c2c66affSColin Finck 
97c2c66affSColin Finck     // CaptureBuffer = CsrAllocateCaptureBuffer(2, IntStringSize(lpExeName, bUnicode) +
98c2c66affSColin Finck     //                                             HistoryLength);
99c2c66affSColin Finck     CaptureBuffer = CsrAllocateCaptureBuffer(2, GetCommandHistoryRequest->ExeLength +
100c2c66affSColin Finck                                                 GetCommandHistoryRequest->HistoryLength);
101c2c66affSColin Finck     if (!CaptureBuffer)
102c2c66affSColin Finck     {
103c2c66affSColin Finck         DPRINT1("CsrAllocateCaptureBuffer failed!\n");
104c2c66affSColin Finck         SetLastError(ERROR_NOT_ENOUGH_MEMORY);
105c2c66affSColin Finck         return 0;
106c2c66affSColin Finck     }
107c2c66affSColin Finck 
108c2c66affSColin Finck     CsrCaptureMessageBuffer(CaptureBuffer,
109c2c66affSColin Finck                             (PVOID)lpExeName,
110c2c66affSColin Finck                             GetCommandHistoryRequest->ExeLength,
111c2c66affSColin Finck                             (PVOID)&GetCommandHistoryRequest->ExeName);
112c2c66affSColin Finck 
113c2c66affSColin Finck     CsrAllocateMessagePointer(CaptureBuffer, GetCommandHistoryRequest->HistoryLength,
114c2c66affSColin Finck                               (PVOID*)&GetCommandHistoryRequest->History);
115c2c66affSColin Finck 
116c2c66affSColin Finck     CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
117c2c66affSColin Finck                         CaptureBuffer,
118c2c66affSColin Finck                         CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetCommandHistory),
119c2c66affSColin Finck                         sizeof(*GetCommandHistoryRequest));
120c2c66affSColin Finck     if (!NT_SUCCESS(ApiMessage.Status))
121c2c66affSColin Finck     {
122c2c66affSColin Finck         CsrFreeCaptureBuffer(CaptureBuffer);
123c2c66affSColin Finck         BaseSetLastNTError(ApiMessage.Status);
124c2c66affSColin Finck         return 0;
125c2c66affSColin Finck     }
126c2c66affSColin Finck 
127c2c66affSColin Finck     RtlCopyMemory(lpHistory,
128c2c66affSColin Finck                   GetCommandHistoryRequest->History,
129c2c66affSColin Finck                   GetCommandHistoryRequest->HistoryLength);
130c2c66affSColin Finck 
131c2c66affSColin Finck     CsrFreeCaptureBuffer(CaptureBuffer);
132c2c66affSColin Finck 
133c2c66affSColin Finck     return GetCommandHistoryRequest->HistoryLength;
134c2c66affSColin Finck }
135c2c66affSColin Finck 
136c2c66affSColin Finck 
137c2c66affSColin Finck static DWORD
IntGetConsoleCommandHistoryLength(LPCVOID lpExeName,BOOL bUnicode)138c2c66affSColin Finck IntGetConsoleCommandHistoryLength(LPCVOID lpExeName, BOOL bUnicode)
139c2c66affSColin Finck {
140c2c66affSColin Finck     CONSOLE_API_MESSAGE ApiMessage;
141c2c66affSColin Finck     PCONSOLE_GETCOMMANDHISTORYLENGTH GetCommandHistoryLengthRequest = &ApiMessage.Data.GetCommandHistoryLengthRequest;
142c2c66affSColin Finck     PCSR_CAPTURE_BUFFER CaptureBuffer;
143c2c66affSColin Finck 
144c2c66affSColin Finck     USHORT NumChars = (USHORT)(lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0);
145c2c66affSColin Finck 
146c2c66affSColin Finck     if (lpExeName == NULL || NumChars == 0)
147c2c66affSColin Finck     {
148c2c66affSColin Finck         SetLastError(ERROR_INVALID_PARAMETER);
149c2c66affSColin Finck         return 0;
150c2c66affSColin Finck     }
151c2c66affSColin Finck 
152c2c66affSColin Finck     GetCommandHistoryLengthRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
153c2c66affSColin Finck     GetCommandHistoryLengthRequest->ExeLength     = NumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
154c2c66affSColin Finck     GetCommandHistoryLengthRequest->Unicode  =
155c2c66affSColin Finck     GetCommandHistoryLengthRequest->Unicode2 = bUnicode;
156c2c66affSColin Finck 
157c2c66affSColin Finck     // CaptureBuffer = CsrAllocateCaptureBuffer(1, IntStringSize(lpExeName, bUnicode));
158c2c66affSColin Finck     CaptureBuffer = CsrAllocateCaptureBuffer(1, GetCommandHistoryLengthRequest->ExeLength);
159c2c66affSColin Finck     if (!CaptureBuffer)
160c2c66affSColin Finck     {
161c2c66affSColin Finck         DPRINT1("CsrAllocateCaptureBuffer failed!\n");
162c2c66affSColin Finck         SetLastError(ERROR_NOT_ENOUGH_MEMORY);
163c2c66affSColin Finck         return 0;
164c2c66affSColin Finck     }
165c2c66affSColin Finck 
166c2c66affSColin Finck     CsrCaptureMessageBuffer(CaptureBuffer,
167c2c66affSColin Finck                             (PVOID)lpExeName,
168c2c66affSColin Finck                             GetCommandHistoryLengthRequest->ExeLength,
169c2c66affSColin Finck                             (PVOID)&GetCommandHistoryLengthRequest->ExeName);
170c2c66affSColin Finck 
171c2c66affSColin Finck     CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
172c2c66affSColin Finck                         CaptureBuffer,
173c2c66affSColin Finck                         CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetCommandHistoryLength),
174c2c66affSColin Finck                         sizeof(*GetCommandHistoryLengthRequest));
175c2c66affSColin Finck 
176c2c66affSColin Finck     CsrFreeCaptureBuffer(CaptureBuffer);
177c2c66affSColin Finck 
178c2c66affSColin Finck     if (!NT_SUCCESS(ApiMessage.Status))
179c2c66affSColin Finck     {
180c2c66affSColin Finck         BaseSetLastNTError(ApiMessage.Status);
181c2c66affSColin Finck         return 0;
182c2c66affSColin Finck     }
183c2c66affSColin Finck 
184c2c66affSColin Finck     return GetCommandHistoryLengthRequest->HistoryLength;
185c2c66affSColin Finck }
186c2c66affSColin Finck 
187c2c66affSColin Finck 
188c2c66affSColin Finck static BOOL
IntSetConsoleNumberOfCommands(DWORD dwNumCommands,LPCVOID lpExeName,BOOLEAN bUnicode)189c2c66affSColin Finck IntSetConsoleNumberOfCommands(DWORD dwNumCommands,
190c2c66affSColin Finck                               LPCVOID lpExeName,
191c2c66affSColin Finck                               BOOLEAN bUnicode)
192c2c66affSColin Finck {
193c2c66affSColin Finck     CONSOLE_API_MESSAGE ApiMessage;
194c2c66affSColin Finck     PCONSOLE_SETHISTORYNUMBERCOMMANDS SetHistoryNumberCommandsRequest = &ApiMessage.Data.SetHistoryNumberCommandsRequest;
195c2c66affSColin Finck     PCSR_CAPTURE_BUFFER CaptureBuffer;
196c2c66affSColin Finck 
197c2c66affSColin Finck     USHORT NumChars = (USHORT)(lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0);
198c2c66affSColin Finck 
199c2c66affSColin Finck     if (lpExeName == NULL || NumChars == 0)
200c2c66affSColin Finck     {
201c2c66affSColin Finck         SetLastError(ERROR_INVALID_PARAMETER);
202c2c66affSColin Finck         return FALSE;
203c2c66affSColin Finck     }
204c2c66affSColin Finck 
205c2c66affSColin Finck     SetHistoryNumberCommandsRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
206c2c66affSColin Finck     SetHistoryNumberCommandsRequest->NumCommands   = dwNumCommands;
207c2c66affSColin Finck     SetHistoryNumberCommandsRequest->ExeLength     = NumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
208c2c66affSColin Finck     SetHistoryNumberCommandsRequest->Unicode  =
209c2c66affSColin Finck     SetHistoryNumberCommandsRequest->Unicode2 = bUnicode;
210c2c66affSColin Finck 
211c2c66affSColin Finck     // CaptureBuffer = CsrAllocateCaptureBuffer(1, IntStringSize(lpExeName, bUnicode));
212c2c66affSColin Finck     CaptureBuffer = CsrAllocateCaptureBuffer(1, SetHistoryNumberCommandsRequest->ExeLength);
213c2c66affSColin Finck     if (!CaptureBuffer)
214c2c66affSColin Finck     {
215c2c66affSColin Finck         DPRINT1("CsrAllocateCaptureBuffer failed!\n");
216c2c66affSColin Finck         SetLastError(ERROR_NOT_ENOUGH_MEMORY);
217c2c66affSColin Finck         return FALSE;
218c2c66affSColin Finck     }
219c2c66affSColin Finck 
220c2c66affSColin Finck     CsrCaptureMessageBuffer(CaptureBuffer,
221c2c66affSColin Finck                             (PVOID)lpExeName,
222c2c66affSColin Finck                             SetHistoryNumberCommandsRequest->ExeLength,
223c2c66affSColin Finck                             (PVOID)&SetHistoryNumberCommandsRequest->ExeName);
224c2c66affSColin Finck 
225c2c66affSColin Finck     CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
226c2c66affSColin Finck                         CaptureBuffer,
227c2c66affSColin Finck                         CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetNumberOfCommands),
228c2c66affSColin Finck                         sizeof(*SetHistoryNumberCommandsRequest));
229c2c66affSColin Finck 
230c2c66affSColin Finck     CsrFreeCaptureBuffer(CaptureBuffer);
231c2c66affSColin Finck 
232c2c66affSColin Finck     if (!NT_SUCCESS(ApiMessage.Status))
233c2c66affSColin Finck     {
234c2c66affSColin Finck         BaseSetLastNTError(ApiMessage.Status);
235c2c66affSColin Finck         return FALSE;
236c2c66affSColin Finck     }
237c2c66affSColin Finck 
238c2c66affSColin Finck     return TRUE;
239c2c66affSColin Finck }
240c2c66affSColin Finck 
241c2c66affSColin Finck 
242c2c66affSColin Finck /* FUNCTIONS ******************************************************************/
243c2c66affSColin Finck 
244c2c66affSColin Finck /*
245c2c66affSColin Finck  * @implemented (Undocumented)
246c2c66affSColin Finck  */
247c2c66affSColin Finck VOID
248c2c66affSColin Finck WINAPI
249c2c66affSColin Finck DECLSPEC_HOTPATCH
ExpungeConsoleCommandHistoryW(IN LPCWSTR lpExeName)250*197ec4c5SHermès Bélusca-Maïto ExpungeConsoleCommandHistoryW(IN LPCWSTR lpExeName)
251c2c66affSColin Finck {
252c2c66affSColin Finck     IntExpungeConsoleCommandHistory(lpExeName, TRUE);
253c2c66affSColin Finck }
254c2c66affSColin Finck 
255c2c66affSColin Finck 
256c2c66affSColin Finck /*
257c2c66affSColin Finck  * @implemented (Undocumented)
258c2c66affSColin Finck  */
259c2c66affSColin Finck VOID
260c2c66affSColin Finck WINAPI
261c2c66affSColin Finck DECLSPEC_HOTPATCH
ExpungeConsoleCommandHistoryA(IN LPCSTR lpExeName)262*197ec4c5SHermès Bélusca-Maïto ExpungeConsoleCommandHistoryA(IN LPCSTR lpExeName)
263c2c66affSColin Finck {
264c2c66affSColin Finck     IntExpungeConsoleCommandHistory(lpExeName, FALSE);
265c2c66affSColin Finck }
266c2c66affSColin Finck 
267c2c66affSColin Finck 
268c2c66affSColin Finck /*
269c2c66affSColin Finck  * @implemented (Undocumented)
270c2c66affSColin Finck  */
271c2c66affSColin Finck DWORD
272c2c66affSColin Finck WINAPI
273c2c66affSColin Finck DECLSPEC_HOTPATCH
GetConsoleCommandHistoryW(OUT LPWSTR lpHistory,IN DWORD cbHistory,IN LPCWSTR lpExeName)274*197ec4c5SHermès Bélusca-Maïto GetConsoleCommandHistoryW(OUT LPWSTR lpHistory,
275*197ec4c5SHermès Bélusca-Maïto                           IN DWORD cbHistory,
276*197ec4c5SHermès Bélusca-Maïto                           IN LPCWSTR lpExeName)
277c2c66affSColin Finck {
278c2c66affSColin Finck     return IntGetConsoleCommandHistory(lpHistory, cbHistory, lpExeName, TRUE);
279c2c66affSColin Finck }
280c2c66affSColin Finck 
281c2c66affSColin Finck 
282c2c66affSColin Finck /*
283c2c66affSColin Finck  * @implemented (Undocumented)
284c2c66affSColin Finck  */
285c2c66affSColin Finck DWORD
286c2c66affSColin Finck WINAPI
287c2c66affSColin Finck DECLSPEC_HOTPATCH
GetConsoleCommandHistoryA(OUT LPSTR lpHistory,IN DWORD cbHistory,IN LPCSTR lpExeName)288*197ec4c5SHermès Bélusca-Maïto GetConsoleCommandHistoryA(OUT LPSTR lpHistory,
289*197ec4c5SHermès Bélusca-Maïto                           IN DWORD cbHistory,
290*197ec4c5SHermès Bélusca-Maïto                           IN LPCSTR lpExeName)
291c2c66affSColin Finck {
292c2c66affSColin Finck     return IntGetConsoleCommandHistory(lpHistory, cbHistory, lpExeName, FALSE);
293c2c66affSColin Finck }
294c2c66affSColin Finck 
295c2c66affSColin Finck 
296c2c66affSColin Finck /*
297c2c66affSColin Finck  * @implemented (Undocumented)
298c2c66affSColin Finck  */
299c2c66affSColin Finck DWORD
300c2c66affSColin Finck WINAPI
301c2c66affSColin Finck DECLSPEC_HOTPATCH
GetConsoleCommandHistoryLengthW(IN LPCWSTR lpExeName)302*197ec4c5SHermès Bélusca-Maïto GetConsoleCommandHistoryLengthW(IN LPCWSTR lpExeName)
303c2c66affSColin Finck {
304c2c66affSColin Finck     return IntGetConsoleCommandHistoryLength(lpExeName, TRUE);
305c2c66affSColin Finck }
306c2c66affSColin Finck 
307c2c66affSColin Finck 
308c2c66affSColin Finck /*
309c2c66affSColin Finck  * @implemented (Undocumented)
310c2c66affSColin Finck  */
311c2c66affSColin Finck DWORD
312c2c66affSColin Finck WINAPI
313c2c66affSColin Finck DECLSPEC_HOTPATCH
GetConsoleCommandHistoryLengthA(IN LPCSTR lpExeName)314*197ec4c5SHermès Bélusca-Maïto GetConsoleCommandHistoryLengthA(IN LPCSTR lpExeName)
315c2c66affSColin Finck {
316c2c66affSColin Finck     return IntGetConsoleCommandHistoryLength(lpExeName, FALSE);
317c2c66affSColin Finck }
318c2c66affSColin Finck 
319c2c66affSColin Finck 
320c2c66affSColin Finck /*
321c2c66affSColin Finck  * @implemented (Undocumented)
322c2c66affSColin Finck  */
323c2c66affSColin Finck BOOL
324c2c66affSColin Finck WINAPI
325c2c66affSColin Finck DECLSPEC_HOTPATCH
SetConsoleNumberOfCommandsW(IN DWORD dwNumCommands,IN LPCWSTR lpExeName)326*197ec4c5SHermès Bélusca-Maïto SetConsoleNumberOfCommandsW(IN DWORD dwNumCommands,
327*197ec4c5SHermès Bélusca-Maïto                             IN LPCWSTR lpExeName)
328c2c66affSColin Finck {
329c2c66affSColin Finck     return IntSetConsoleNumberOfCommands(dwNumCommands, lpExeName, TRUE);
330c2c66affSColin Finck }
331c2c66affSColin Finck 
332c2c66affSColin Finck 
333c2c66affSColin Finck /*
334c2c66affSColin Finck  * @implemented (Undocumented)
335c2c66affSColin Finck  */
336c2c66affSColin Finck BOOL
337c2c66affSColin Finck WINAPI
338c2c66affSColin Finck DECLSPEC_HOTPATCH
SetConsoleNumberOfCommandsA(IN DWORD dwNumCommands,IN LPCSTR lpExeName)339*197ec4c5SHermès Bélusca-Maïto SetConsoleNumberOfCommandsA(IN DWORD dwNumCommands,
340*197ec4c5SHermès Bélusca-Maïto                             IN LPCSTR lpExeName)
341c2c66affSColin Finck {
342c2c66affSColin Finck     return IntSetConsoleNumberOfCommands(dwNumCommands, lpExeName, FALSE);
343c2c66affSColin Finck }
344c2c66affSColin Finck 
345c2c66affSColin Finck 
346c2c66affSColin Finck /*
347c2c66affSColin Finck  * @implemented
348c2c66affSColin Finck  */
349c2c66affSColin Finck BOOL
350c2c66affSColin Finck WINAPI
351c2c66affSColin Finck DECLSPEC_HOTPATCH
SetConsoleCommandHistoryMode(IN DWORD dwMode)352c2c66affSColin Finck SetConsoleCommandHistoryMode(IN DWORD dwMode)
353c2c66affSColin Finck {
354c2c66affSColin Finck     CONSOLE_API_MESSAGE ApiMessage;
355c2c66affSColin Finck     PCONSOLE_SETHISTORYMODE SetHistoryModeRequest = &ApiMessage.Data.SetHistoryModeRequest;
356c2c66affSColin Finck 
357c2c66affSColin Finck     SetHistoryModeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
358c2c66affSColin Finck     SetHistoryModeRequest->Mode          = dwMode;
359c2c66affSColin Finck 
360c2c66affSColin Finck     CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
361c2c66affSColin Finck                         NULL,
362c2c66affSColin Finck                         CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetCommandHistoryMode),
363c2c66affSColin Finck                         sizeof(*SetHistoryModeRequest));
364c2c66affSColin Finck     if (!NT_SUCCESS(ApiMessage.Status))
365c2c66affSColin Finck     {
366c2c66affSColin Finck         BaseSetLastNTError(ApiMessage.Status);
367c2c66affSColin Finck         return FALSE;
368c2c66affSColin Finck     }
369c2c66affSColin Finck 
370c2c66affSColin Finck     return TRUE;
371c2c66affSColin Finck }
372c2c66affSColin Finck 
373c2c66affSColin Finck /* EOF */
374