2 * PROJECT: ReactOS Win32 Base API
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/win32/kernel32/client/vdm.c
5 * PURPOSE: Virtual DOS Machines (VDM) Support
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
9 /* INCLUDES *******************************************************************/
16 /* TYPES **********************************************************************/
18 typedef struct _ENV_INFO
23 } ENV_INFO
, *PENV_INFO
;
25 /* GLOBALS ********************************************************************/
27 ENV_INFO BasepEnvNameType
[] =
29 {3, sizeof(L
"PATH") , L
"PATH" },
30 {2, sizeof(L
"WINDIR") , L
"WINDIR" },
31 {2, sizeof(L
"SYSTEMROOT"), L
"SYSTEMROOT"},
32 {3, sizeof(L
"TEMP") , L
"TEMP" },
33 {3, sizeof(L
"TMP") , L
"TMP" },
36 UNICODE_STRING BaseDotComSuffixName
= RTL_CONSTANT_STRING(L
".com");
37 UNICODE_STRING BaseDotPifSuffixName
= RTL_CONSTANT_STRING(L
".pif");
38 UNICODE_STRING BaseDotExeSuffixName
= RTL_CONSTANT_STRING(L
".exe");
40 /* FUNCTIONS ******************************************************************/
44 BaseIsDosApplication(IN PUNICODE_STRING PathName
,
47 UNICODE_STRING String
;
50 String
.Length
= BaseDotComSuffixName
.Length
;
51 String
.Buffer
= &PathName
->Buffer
[(PathName
->Length
- String
.Length
) / sizeof(WCHAR
)];
52 if (RtlEqualUnicodeString(&String
, &BaseDotComSuffixName
, TRUE
)) return BINARY_TYPE_COM
;
55 String
.Length
= BaseDotPifSuffixName
.Length
;
56 String
.Buffer
= &PathName
->Buffer
[(PathName
->Length
- String
.Length
) / sizeof(WCHAR
)];
57 if (RtlEqualUnicodeString(&String
, &BaseDotPifSuffixName
, TRUE
)) return BINARY_TYPE_PIF
;
60 String
.Length
= BaseDotExeSuffixName
.Length
;
61 String
.Buffer
= &PathName
->Buffer
[(PathName
->Length
- String
.Length
) / sizeof(WCHAR
)];
62 if (RtlEqualUnicodeString(&String
, &BaseDotExeSuffixName
, TRUE
)) return BINARY_TYPE_EXE
;
69 BaseCheckVDM(IN ULONG BinaryType
,
70 IN PCWCH ApplicationName
,
72 IN PCWCH CurrentDirectory
,
73 IN PANSI_STRING AnsiEnvironment
,
74 IN PBASE_API_MESSAGE ApiMessage
,
76 IN DWORD CreationFlags
,
77 IN LPSTARTUPINFOW StartupInfo
,
78 IN HANDLE hUserToken OPTIONAL
)
81 PBASE_CHECK_VDM CheckVdm
= &ApiMessage
->Data
.CheckVDMRequest
;
82 PCSR_CAPTURE_BUFFER CaptureBuffer
;
83 PWCHAR CurrentDir
= NULL
;
84 PWCHAR ShortAppName
= NULL
;
85 PWCHAR ShortCurrentDir
= NULL
;
87 PCHAR AnsiCmdLine
= NULL
;
88 PCHAR AnsiAppName
= NULL
;
89 PCHAR AnsiCurDirectory
= NULL
;
90 PCHAR AnsiDesktop
= NULL
;
91 PCHAR AnsiTitle
= NULL
;
92 PCHAR AnsiReserved
= NULL
;
93 STARTUPINFOA AnsiStartupInfo
;
96 if (CurrentDirectory
== NULL
)
98 /* Allocate memory for the current directory path */
99 Length
= GetCurrentDirectoryW(0, NULL
);
100 CurrentDir
= (PWCHAR
)RtlAllocateHeap(RtlGetProcessHeap(),
102 Length
* sizeof(WCHAR
));
103 if (CurrentDir
== NULL
)
105 Status
= STATUS_NO_MEMORY
;
109 /* Get the current directory */
110 GetCurrentDirectoryW(Length
, CurrentDir
);
111 CurrentDirectory
= CurrentDir
;
114 /* Calculate the size of the short application name */
115 Length
= GetShortPathNameW(ApplicationName
, NULL
, 0);
117 /* Allocate memory for the short application name */
118 ShortAppName
= (PWCHAR
)RtlAllocateHeap(RtlGetProcessHeap(),
120 Length
* sizeof(WCHAR
));
123 Status
= STATUS_NO_MEMORY
;
127 /* Get the short application name */
128 if (!GetShortPathNameW(ApplicationName
, ShortAppName
, Length
))
130 /* Try to determine which error occurred */
131 switch (GetLastError())
133 case ERROR_NOT_ENOUGH_MEMORY
:
135 Status
= STATUS_NO_MEMORY
;
139 case ERROR_INVALID_PARAMETER
:
141 Status
= STATUS_INVALID_PARAMETER
;
147 Status
= STATUS_OBJECT_PATH_INVALID
;
154 /* Calculate the size of the short current directory path */
155 Length
= GetShortPathNameW(CurrentDirectory
, NULL
, 0);
157 /* Allocate memory for the short current directory path */
158 ShortCurrentDir
= (PWCHAR
)RtlAllocateHeap(RtlGetProcessHeap(),
160 Length
* sizeof(WCHAR
));
161 if (!ShortCurrentDir
)
163 Status
= STATUS_NO_MEMORY
;
167 /* Get the short current directory path */
168 if (!GetShortPathNameW(CurrentDirectory
, ShortCurrentDir
, Length
))
170 /* Try to determine which error occurred */
171 switch (GetLastError())
173 case ERROR_NOT_ENOUGH_MEMORY
:
175 Status
= STATUS_NO_MEMORY
;
179 case ERROR_INVALID_PARAMETER
:
181 Status
= STATUS_INVALID_PARAMETER
;
187 Status
= STATUS_OBJECT_PATH_INVALID
;
193 /* Setup the input parameters */
194 CheckVdm
->ConsoleHandle
= NtCurrentPeb()->ProcessParameters
->ConsoleHandle
;
195 CheckVdm
->BinaryType
= BinaryType
;
196 CheckVdm
->CodePage
= CP_ACP
;
197 CheckVdm
->dwCreationFlags
= CreationFlags
;
198 CheckVdm
->CurDrive
= CurrentDirectory
[0] - L
'A';
199 CheckVdm
->CmdLen
= wcslen(CommandLine
) + 1;
200 CheckVdm
->AppLen
= wcslen(ShortAppName
) + 1;
201 CheckVdm
->PifLen
= 0; // TODO: PIF file support!
202 CheckVdm
->CurDirectoryLen
= wcslen(ShortCurrentDir
) + 1;
203 CheckVdm
->EnvLen
= AnsiEnvironment
->Length
;
204 CheckVdm
->DesktopLen
= (StartupInfo
->lpDesktop
!= NULL
) ? (wcslen(StartupInfo
->lpDesktop
) + 1) : 0;
205 CheckVdm
->TitleLen
= (StartupInfo
->lpTitle
!= NULL
) ? (wcslen(StartupInfo
->lpTitle
) + 1) : 0;
206 CheckVdm
->ReservedLen
= (StartupInfo
->lpReserved
!= NULL
) ? (wcslen(StartupInfo
->lpReserved
) + 1) : 0;
208 if (StartupInfo
->dwFlags
& STARTF_USESTDHANDLES
)
210 /* Set the standard handles */
211 CheckVdm
->StdIn
= StartupInfo
->hStdInput
;
212 CheckVdm
->StdOut
= StartupInfo
->hStdOutput
;
213 CheckVdm
->StdErr
= StartupInfo
->hStdError
;
216 /* Allocate memory for the ANSI strings */
217 AnsiCmdLine
= (PCHAR
)RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY
, CheckVdm
->CmdLen
);
218 AnsiAppName
= (PCHAR
)RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY
, CheckVdm
->AppLen
);
219 AnsiCurDirectory
= (PCHAR
)RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY
, CheckVdm
->CurDirectoryLen
);
220 if (StartupInfo
->lpDesktop
) AnsiDesktop
= (PCHAR
)RtlAllocateHeap(RtlGetProcessHeap(),
222 CheckVdm
->DesktopLen
);
223 if (StartupInfo
->lpTitle
) AnsiTitle
= (PCHAR
)RtlAllocateHeap(RtlGetProcessHeap(),
226 if (StartupInfo
->lpReserved
) AnsiReserved
= (PCHAR
)RtlAllocateHeap(RtlGetProcessHeap(),
228 CheckVdm
->ReservedLen
);
233 || (StartupInfo
->lpDesktop
&& !AnsiDesktop
)
234 || (StartupInfo
->lpTitle
&& !AnsiTitle
)
235 || (StartupInfo
->lpReserved
&& !AnsiReserved
))
237 Status
= STATUS_NO_MEMORY
;
241 /* Convert the command line into an ANSI string */
242 WideCharToMultiByte(CP_ACP
,
251 /* Convert the short application name into an ANSI string */
252 WideCharToMultiByte(CP_ACP
,
261 /* Convert the short current directory path into an ANSI string */
262 WideCharToMultiByte(CP_ACP
,
265 CheckVdm
->CurDirectoryLen
,
267 CheckVdm
->CurDirectoryLen
,
271 if (StartupInfo
->lpDesktop
)
273 /* Convert the desktop name into an ANSI string */
274 WideCharToMultiByte(CP_ACP
,
276 StartupInfo
->lpDesktop
,
277 CheckVdm
->DesktopLen
,
279 CheckVdm
->DesktopLen
,
285 if (StartupInfo
->lpTitle
)
287 /* Convert the title into an ANSI string */
288 WideCharToMultiByte(CP_ACP
,
290 StartupInfo
->lpTitle
,
299 if (StartupInfo
->lpReserved
)
301 /* Convert the reserved value into an ANSI string */
302 WideCharToMultiByte(CP_ACP
,
304 StartupInfo
->lpReserved
,
305 CheckVdm
->ReservedLen
,
307 CheckVdm
->ReservedLen
,
313 /* Fill the ANSI startup info structure */
314 RtlCopyMemory(&AnsiStartupInfo
, StartupInfo
, sizeof(STARTUPINFO
));
315 AnsiStartupInfo
.lpReserved
= AnsiReserved
;
316 AnsiStartupInfo
.lpDesktop
= AnsiDesktop
;
317 AnsiStartupInfo
.lpTitle
= AnsiTitle
;
319 /* Allocate the capture buffer */
320 CaptureBuffer
= CsrAllocateCaptureBuffer(NumStrings
,
324 + CheckVdm
->CurDirectoryLen
325 + CheckVdm
->DesktopLen
327 + CheckVdm
->ReservedLen
329 + sizeof(STARTUPINFOA
));
330 if (CaptureBuffer
== NULL
)
332 Status
= STATUS_NO_MEMORY
;
336 /* Capture the command line */
337 CsrCaptureMessageBuffer(CaptureBuffer
,
340 (PVOID
*)&CheckVdm
->CmdLine
);
342 /* Capture the application name */
343 CsrCaptureMessageBuffer(CaptureBuffer
,
346 (PVOID
*)&CheckVdm
->AppName
);
348 CheckVdm
->PifFile
= NULL
; // TODO: PIF file support!
350 /* Capture the current directory */
351 CsrCaptureMessageBuffer(CaptureBuffer
,
353 CheckVdm
->CurDirectoryLen
,
354 (PVOID
*)&CheckVdm
->CurDirectory
);
356 /* Capture the environment */
357 CsrCaptureMessageBuffer(CaptureBuffer
,
358 AnsiEnvironment
->Buffer
,
360 (PVOID
*)&CheckVdm
->Env
);
362 /* Capture the startup info structure */
363 CsrCaptureMessageBuffer(CaptureBuffer
,
365 sizeof(STARTUPINFOA
),
366 (PVOID
*)&CheckVdm
->StartupInfo
);
368 if (StartupInfo
->lpDesktop
)
370 /* Capture the desktop name */
371 CsrCaptureMessageBuffer(CaptureBuffer
,
373 CheckVdm
->DesktopLen
,
374 (PVOID
*)&CheckVdm
->Desktop
);
376 else CheckVdm
->Desktop
= NULL
;
378 if (StartupInfo
->lpTitle
)
380 /* Capture the title */
381 CsrCaptureMessageBuffer(CaptureBuffer
,
384 (PVOID
*)&CheckVdm
->Title
);
386 else CheckVdm
->Title
= NULL
;
388 if (StartupInfo
->lpReserved
)
390 /* Capture the reserved parameter */
391 CsrCaptureMessageBuffer(CaptureBuffer
,
393 CheckVdm
->ReservedLen
,
394 (PVOID
*)&CheckVdm
->Reserved
);
396 else CheckVdm
->Reserved
= NULL
;
398 /* Send the message to CSRSS */
399 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)ApiMessage
,
401 CSR_CREATE_API_NUMBER(BASESRV_SERVERDLL_INDEX
, BasepCheckVDM
),
402 sizeof(BASE_CHECK_VDM
));
404 /* Write back the task ID */
405 *iTask
= CheckVdm
->iTask
;
409 /* Free the ANSI strings */
410 if (AnsiCmdLine
) RtlFreeHeap(RtlGetProcessHeap(), 0, AnsiCmdLine
);
411 if (AnsiAppName
) RtlFreeHeap(RtlGetProcessHeap(), 0, AnsiAppName
);
412 if (AnsiCurDirectory
) RtlFreeHeap(RtlGetProcessHeap(), 0, AnsiCurDirectory
);
413 if (AnsiDesktop
) RtlFreeHeap(RtlGetProcessHeap(), 0, AnsiDesktop
);
414 if (AnsiTitle
) RtlFreeHeap(RtlGetProcessHeap(), 0, AnsiTitle
);
415 if (AnsiReserved
) RtlFreeHeap(RtlGetProcessHeap(), 0, AnsiReserved
);
417 /* Free the capture buffer */
418 CsrFreeCaptureBuffer(CaptureBuffer
);
420 /* Free the short paths */
421 if (ShortAppName
) RtlFreeHeap(RtlGetProcessHeap(), 0, ShortAppName
);
422 if (ShortCurrentDir
) RtlFreeHeap(RtlGetProcessHeap(), 0, ShortCurrentDir
);
424 /* Free the current directory, if it was allocated here */
425 if (CurrentDir
) RtlFreeHeap(RtlGetProcessHeap(), 0, CurrentDir
);
432 BaseUpdateVDMEntry(IN ULONG UpdateIndex
,
433 IN OUT PHANDLE WaitHandle
,
438 BASE_API_MESSAGE ApiMessage
;
439 PBASE_UPDATE_VDM_ENTRY UpdateVdmEntry
= &ApiMessage
.Data
.UpdateVDMEntryRequest
;
441 /* Check what update is being sent */
444 /* VDM is being undone */
447 /* Tell the server how far we had gotten along */
448 UpdateVdmEntry
->iTask
= HandleToUlong(*WaitHandle
);
449 UpdateVdmEntry
->VDMCreationState
= IndexInfo
;
453 /* VDM is ready with a new process handle */
454 case VdmEntryUpdateProcess
:
456 /* Send it the process handle */
457 UpdateVdmEntry
->VDMProcessHandle
= *WaitHandle
;
458 UpdateVdmEntry
->iTask
= IndexInfo
;
463 /* Also check what kind of binary this is for the console handle */
464 if (BinaryType
== BINARY_TYPE_WOW
)
466 /* Magic value for 16-bit apps */
467 UpdateVdmEntry
->ConsoleHandle
= (HANDLE
)-1;
469 else if (UpdateVdmEntry
->iTask
)
471 /* No handle for true VDM */
472 UpdateVdmEntry
->ConsoleHandle
= NULL
;
476 /* Otherwise, use the regular console handle */
477 UpdateVdmEntry
->ConsoleHandle
= NtCurrentPeb()->ProcessParameters
->ConsoleHandle
;
480 /* Finally write the index and binary type */
481 UpdateVdmEntry
->EntryIndex
= UpdateIndex
;
482 UpdateVdmEntry
->BinaryType
= BinaryType
;
484 /* Send the message to CSRSS */
485 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
487 CSR_CREATE_API_NUMBER(BASESRV_SERVERDLL_INDEX
, BasepUpdateVDMEntry
),
488 sizeof(BASE_UPDATE_VDM_ENTRY
));
489 if (!NT_SUCCESS(Status
))
492 BaseSetLastNTError(Status
);
496 /* If this was an update, CSRSS returns a new wait handle */
497 if (UpdateIndex
== VdmEntryUpdateProcess
)
499 /* Return it to the caller */
500 *WaitHandle
= UpdateVdmEntry
->WaitObjectForParent
;
509 BaseCheckForVDM(IN HANDLE ProcessHandle
,
510 OUT LPDWORD ExitCode
)
513 EVENT_BASIC_INFORMATION EventBasicInfo
;
514 BASE_API_MESSAGE ApiMessage
;
515 PBASE_GET_VDM_EXIT_CODE GetVdmExitCode
= &ApiMessage
.Data
.GetVDMExitCodeRequest
;
517 /* It's VDM if the process is actually a wait handle (an event) */
518 Status
= NtQueryEvent(ProcessHandle
,
519 EventBasicInformation
,
521 sizeof(EventBasicInfo
),
523 if (!NT_SUCCESS(Status
)) return FALSE
;
525 /* Setup the input parameters */
526 GetVdmExitCode
->ConsoleHandle
= NtCurrentPeb()->ProcessParameters
->ConsoleHandle
;
527 GetVdmExitCode
->hParent
= ProcessHandle
;
530 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
532 CSR_CREATE_API_NUMBER(BASESRV_SERVERDLL_INDEX
, BasepGetVDMExitCode
),
533 sizeof(BASE_GET_VDM_EXIT_CODE
));
534 if (!NT_SUCCESS(Status
)) return FALSE
;
536 /* Get the exit code from the reply */
537 *ExitCode
= GetVdmExitCode
->ExitCode
;
543 BaseGetVdmConfigInfo(IN LPCWSTR CommandLineReserved
,
546 IN PUNICODE_STRING CmdLineString
,
549 WCHAR Buffer
[MAX_PATH
];
550 WCHAR CommandLine
[MAX_PATH
* 2];
553 /* Clear the buffer in case we fail */
554 CmdLineString
->Buffer
= 0;
556 /* Always return the same size: 16 Mb */
557 *VdmSize
= 0x1000000;
559 /* Get the system directory */
560 Length
= GetSystemDirectoryW(Buffer
, MAX_PATH
);
561 if (!(Length
) || (Length
>= MAX_PATH
))
563 /* Eliminate no path or path too big */
564 SetLastError(ERROR_INVALID_NAME
);
568 /* Check if this is VDM with a DOS Sequence ID */
572 * Build the VDM string for it:
573 * -i%lx : Gives the DOS Sequence ID;
574 * %s%c : Nothing if DOS VDM, -w if WoW VDM, -ws if separate WoW VDM.
576 _snwprintf(CommandLine
,
577 sizeof(CommandLine
) / sizeof(CommandLine
[0]),
578 L
"\"%s\\ntvdm.exe\" -i%lx %s%c",
581 (BinaryType
== BINARY_TYPE_DOS
) ? L
" " : L
"-w",
582 (BinaryType
== BINARY_TYPE_SEPARATE_WOW
) ? L
's' : L
' ');
587 * Build the string for it without the DOS Sequence ID:
588 * %s%c : Nothing if DOS VDM, -w if WoW VDM, -ws if separate WoW VDM.
590 _snwprintf(CommandLine
,
591 sizeof(CommandLine
) / sizeof(CommandLine
[0]),
592 L
"\"%s\\ntvdm.exe\" %s%c",
594 (BinaryType
== BINARY_TYPE_DOS
) ? L
" " : L
"-w",
595 (BinaryType
== BINARY_TYPE_SEPARATE_WOW
) ? L
's' : L
' ');
598 /* Create the actual string */
599 return RtlCreateUnicodeString(CmdLineString
, CommandLine
);
604 BaseGetEnvNameType_U(IN PWCHAR Name
,
610 /* Start by assuming unknown type */
613 /* Loop all the environment names */
614 for (i
= 0; i
< (sizeof(BasepEnvNameType
) / sizeof(ENV_INFO
)); i
++)
617 EnvInfo
= &BasepEnvNameType
[i
];
619 /* Check if it matches the name */
620 if ((EnvInfo
->NameLength
== NameLength
) &&
621 !(_wcsnicmp(EnvInfo
->Name
, Name
, NameLength
)))
623 /* It does, return the type */
624 NameType
= EnvInfo
->NameType
;
629 /* Return what we found, or unknown if nothing */
635 BaseDestroyVDMEnvironment(IN PANSI_STRING AnsiEnv
,
636 IN PUNICODE_STRING UnicodeEnv
)
640 /* Clear the ASCII buffer since Rtl creates this for us */
641 if (AnsiEnv
->Buffer
) RtlFreeAnsiString(AnsiEnv
);
643 /* The Unicode buffer is build by hand, though */
644 if (UnicodeEnv
->Buffer
)
646 /* So clear it through the API */
647 NtFreeVirtualMemory(NtCurrentProcess(),
648 (PVOID
*)&UnicodeEnv
->Buffer
,
659 BaseCreateVDMEnvironment(IN PWCHAR lpEnvironment
,
660 IN PANSI_STRING AnsiEnv
,
661 IN PUNICODE_STRING UnicodeEnv
)
664 ULONG RegionSize
, EnvironmentSize
= 0;
665 PWCHAR p
, Environment
, NewEnvironment
= NULL
;
668 /* Make sure we have both strings */
669 if (!(AnsiEnv
) || !(UnicodeEnv
))
672 SetLastError(ERROR_INVALID_PARAMETER
);
676 /* Check if an environment was passed in */
679 /* Nope, create one */
680 Status
= RtlCreateEnvironment(TRUE
, (PWCHAR
*)&Environment
);
681 if (!NT_SUCCESS(Status
)) goto Quickie
;
685 /* Use the one we got */
686 Environment
= lpEnvironment
;
689 /* Do we have something now ? */
692 /* Still not, fail out */
693 SetLastError(ERROR_BAD_ENVIRONMENT
);
697 /* Count how much space the whole environment takes */
699 while ((*p
++ != UNICODE_NULL
) && (*p
!= UNICODE_NULL
)) EnvironmentSize
++;
700 EnvironmentSize
+= sizeof(UNICODE_NULL
);
702 /* Allocate a new copy */
703 RegionSize
= (EnvironmentSize
+ MAX_PATH
) * sizeof(WCHAR
);
704 if (!NT_SUCCESS(NtAllocateVirtualMemory(NtCurrentProcess(),
705 (PVOID
*)&NewEnvironment
,
711 /* We failed, bail out */
712 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
713 NewEnvironment
= NULL
;
717 /* Begin parsing the new environment */
720 /* FIXME: Code here */
725 /* Initialize the unicode string to hold it */
726 EnvironmentSize
= (p
- NewEnvironment
) * sizeof(WCHAR
);
727 RtlInitEmptyUnicodeString(UnicodeEnv
, NewEnvironment
, (USHORT
)EnvironmentSize
);
728 UnicodeEnv
->Length
= (USHORT
)EnvironmentSize
;
730 /* Create the ASCII version of it */
731 Status
= RtlUnicodeStringToAnsiString(AnsiEnv
, UnicodeEnv
, TRUE
);
732 if (!NT_SUCCESS(Status
))
734 /* Set last error if conversion failure */
735 BaseSetLastNTError(Status
);
739 /* Everything went okay, so return success */
741 NewEnvironment
= NULL
;
745 /* Cleanup path starts here, start by destroying the envrionment copy */
746 if (!(lpEnvironment
) && (Environment
)) RtlDestroyEnvironment(Environment
);
748 /* See if we are here due to failure */
751 /* Initialize the paths to be empty */
752 RtlInitEmptyUnicodeString(UnicodeEnv
, NULL
, 0);
753 RtlInitEmptyAnsiString(AnsiEnv
, NULL
, 0);
755 /* Free the environment copy */
757 Status
= NtFreeVirtualMemory(NtCurrentProcess(),
758 (PVOID
*)&NewEnvironment
,
761 ASSERT(NT_SUCCESS(Status
));
764 /* Return the result */
769 /* Check whether a file is an OS/2 or a very old Windows executable
770 * by testing on import of KERNEL.
772 * FIXME: is reading the module imports the only way of discerning
773 * old Windows binaries from OS/2 ones ? At least it seems so...
776 InternalIsOS2OrOldWin(HANDLE hFile
, IMAGE_DOS_HEADER
*mz
, IMAGE_OS2_HEADER
*ne
)
779 LPWORD modtab
= NULL
;
780 LPSTR nametab
= NULL
;
785 CurPos
= SetFilePointer(hFile
, 0, NULL
, FILE_CURRENT
);
787 /* read modref table */
788 if((SetFilePointer(hFile
, mz
->e_lfanew
+ ne
->ne_modtab
, NULL
, FILE_BEGIN
) == INVALID_SET_FILE_POINTER
) ||
789 (!(modtab
= HeapAlloc(GetProcessHeap(), 0, ne
->ne_cmod
* sizeof(WORD
)))) ||
790 (!(ReadFile(hFile
, modtab
, ne
->ne_cmod
* sizeof(WORD
), &Read
, NULL
))) ||
791 (Read
!= (DWORD
)ne
->ne_cmod
* sizeof(WORD
)))
796 /* read imported names table */
797 if((SetFilePointer(hFile
, mz
->e_lfanew
+ ne
->ne_imptab
, NULL
, FILE_BEGIN
) == INVALID_SET_FILE_POINTER
) ||
798 (!(nametab
= HeapAlloc(GetProcessHeap(), 0, ne
->ne_enttab
- ne
->ne_imptab
))) ||
799 (!(ReadFile(hFile
, nametab
, ne
->ne_enttab
- ne
->ne_imptab
, &Read
, NULL
))) ||
800 (Read
!= (DWORD
)ne
->ne_enttab
- ne
->ne_imptab
))
805 for(i
= 0; i
< ne
->ne_cmod
; i
++)
808 module
= &nametab
[modtab
[i
]];
809 if(!strncmp(&module
[1], "KERNEL", module
[0]))
811 /* very old windows file */
818 DPRINT1("InternalIsOS2OrOldWin(): Binary file seems to be broken\n");
821 HeapFree(GetProcessHeap(), 0, modtab
);
822 HeapFree(GetProcessHeap(), 0, nametab
);
823 SetFilePointer(hFile
, CurPos
, NULL
, FILE_BEGIN
);
828 InternalGetBinaryType(HANDLE hFile
)
834 unsigned char magic
[4];
835 unsigned char ignored
[12];
841 unsigned long cputype
;
842 unsigned long cpusubtype
;
843 unsigned long filetype
;
850 if((SetFilePointer(hFile
, 0, NULL
, FILE_BEGIN
) == INVALID_SET_FILE_POINTER
) ||
851 (!ReadFile(hFile
, &Header
, sizeof(Header
), &Read
, NULL
) ||
852 (Read
!= sizeof(Header
))))
854 return BINARY_UNKNOWN
;
857 if(!memcmp(Header
.elf
.magic
, "\177ELF", sizeof(Header
.elf
.magic
)))
859 /* FIXME: we don't bother to check byte order, architecture, etc. */
860 switch(Header
.elf
.type
)
863 return BINARY_UNIX_EXE
;
865 return BINARY_UNIX_LIB
;
867 return BINARY_UNKNOWN
;
870 /* Mach-o File with Endian set to Big Endian or Little Endian*/
871 if(Header
.macho
.magic
== 0xFEEDFACE ||
872 Header
.macho
.magic
== 0xCEFAEDFE)
874 switch(Header
.macho
.filetype
)
878 return BINARY_UNIX_LIB
;
880 return BINARY_UNKNOWN
;
883 /* Not ELF, try DOS */
884 if(Header
.mz
.e_magic
== IMAGE_DOS_SIGNATURE
)
886 /* We do have a DOS image so we will now try to seek into
887 * the file by the amount indicated by the field
888 * "Offset to extended header" and read in the
889 * "magic" field information at that location.
890 * This will tell us if there is more header information
893 if((SetFilePointer(hFile
, Header
.mz
.e_lfanew
, NULL
, FILE_BEGIN
) == INVALID_SET_FILE_POINTER
) ||
894 (!ReadFile(hFile
, magic
, sizeof(magic
), &Read
, NULL
) ||
895 (Read
!= sizeof(magic
))))
900 /* Reading the magic field succeeded so
901 * we will try to determine what type it is.
903 if(!memcmp(magic
, "PE\0\0", sizeof(magic
)))
905 IMAGE_FILE_HEADER FileHeader
;
906 if(!ReadFile(hFile
, &FileHeader
, sizeof(IMAGE_FILE_HEADER
), &Read
, NULL
) ||
907 (Read
!= sizeof(IMAGE_FILE_HEADER
)))
912 /* FIXME - detect 32/64 bit */
914 if(FileHeader
.Characteristics
& IMAGE_FILE_DLL
)
915 return BINARY_PE_DLL32
;
916 return BINARY_PE_EXE32
;
919 if(!memcmp(magic
, "NE", 1))
921 /* This is a Windows executable (NE) header. This can
922 * mean either a 16-bit OS/2 or a 16-bit Windows or even a
923 * DOS program (running under a DOS extender). To decide
924 * which, we'll have to read the NE header.
927 if((SetFilePointer(hFile
, Header
.mz
.e_lfanew
, NULL
, FILE_BEGIN
) == 1) ||
928 !ReadFile(hFile
, &ne
, sizeof(IMAGE_OS2_HEADER
), &Read
, NULL
) ||
929 (Read
!= sizeof(IMAGE_OS2_HEADER
)))
931 /* Couldn't read header, so abort. */
942 return InternalIsOS2OrOldWin(hFile
, &Header
.mz
, &ne
);
947 return BINARY_UNKNOWN
;
956 LPCWSTR lpApplicationName
,
963 if(!lpApplicationName
|| !lpBinaryType
)
965 SetLastError(ERROR_INVALID_PARAMETER
);
969 hFile
= CreateFileW(lpApplicationName
, GENERIC_READ
, FILE_SHARE_READ
, NULL
,
970 OPEN_EXISTING
, 0, 0);
971 if(hFile
== INVALID_HANDLE_VALUE
)
976 BinType
= InternalGetBinaryType(hFile
);
986 * guess from filename
988 if(!(dot
= wcsrchr(lpApplicationName
, L
'.')))
992 if(!lstrcmpiW(dot
, L
".COM"))
994 *lpBinaryType
= SCS_DOS_BINARY
;
997 if(!lstrcmpiW(dot
, L
".PIF"))
999 *lpBinaryType
= SCS_PIF_BINARY
;
1004 case BINARY_PE_EXE32
:
1005 case BINARY_PE_DLL32
:
1007 *lpBinaryType
= SCS_32BIT_BINARY
;
1010 case BINARY_PE_EXE64
:
1011 case BINARY_PE_DLL64
:
1013 *lpBinaryType
= SCS_64BIT_BINARY
;
1018 *lpBinaryType
= SCS_WOW_BINARY
;
1023 *lpBinaryType
= SCS_OS216_BINARY
;
1028 *lpBinaryType
= SCS_DOS_BINARY
;
1031 case BINARY_UNIX_EXE
:
1032 case BINARY_UNIX_LIB
:
1038 DPRINT1("Invalid binary type %lu returned!\n", BinType
);
1047 GetBinaryTypeA(IN LPCSTR lpApplicationName
,
1048 OUT LPDWORD lpBinaryType
)
1050 ANSI_STRING ApplicationNameString
;
1051 UNICODE_STRING ApplicationNameW
;
1052 BOOL StringAllocated
= FALSE
, Result
;
1055 RtlInitAnsiString(&ApplicationNameString
, lpApplicationName
);
1057 if (ApplicationNameString
.Length
* sizeof(WCHAR
) >= NtCurrentTeb()->StaticUnicodeString
.MaximumLength
)
1059 StringAllocated
= TRUE
;
1060 Status
= RtlAnsiStringToUnicodeString(&ApplicationNameW
, &ApplicationNameString
, TRUE
);
1064 Status
= RtlAnsiStringToUnicodeString(&(NtCurrentTeb()->StaticUnicodeString
), &ApplicationNameString
, FALSE
);
1067 if (!NT_SUCCESS(Status
))
1069 BaseSetLastNTError(Status
);
1073 if (StringAllocated
)
1075 Result
= GetBinaryTypeW(ApplicationNameW
.Buffer
, lpBinaryType
);
1076 RtlFreeUnicodeString(&ApplicationNameW
);
1080 Result
= GetBinaryTypeW(NtCurrentTeb()->StaticUnicodeString
.Buffer
, lpBinaryType
);
1091 CmdBatNotification (
1104 ExitVDM(BOOL IsWow
, ULONG iWowTask
)
1106 BASE_API_MESSAGE ApiMessage
;
1107 PBASE_EXIT_VDM ExitVdm
= &ApiMessage
.Data
.ExitVDMRequest
;
1109 /* Setup the input parameters */
1110 ExitVdm
->ConsoleHandle
= NtCurrentPeb()->ProcessParameters
->ConsoleHandle
;
1111 ExitVdm
->iWowTask
= IsWow
? iWowTask
: 0; /* Always zero for DOS tasks */
1112 ExitVdm
->WaitObjectForVDM
= NULL
;
1115 CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1117 CSR_CREATE_API_NUMBER(BASESRV_SERVERDLL_INDEX
, BasepExitVDM
),
1118 sizeof(BASE_EXIT_VDM
));
1120 /* Close the returned wait object handle, if any */
1121 if (NT_SUCCESS(ApiMessage
.Status
) && (ExitVdm
->WaitObjectForVDM
!= NULL
))
1123 CloseHandle(ExitVdm
->WaitObjectForVDM
);
1132 GetNextVDMCommand(PVDM_COMMAND_INFO CommandData
)
1135 BOOL Result
= FALSE
;
1136 BASE_API_MESSAGE ApiMessage
;
1137 PBASE_GET_NEXT_VDM_COMMAND GetNextVdmCommand
= &ApiMessage
.Data
.GetNextVDMCommandRequest
;
1138 PBASE_IS_FIRST_VDM IsFirstVdm
= &ApiMessage
.Data
.IsFirstVDMRequest
;
1139 PBASE_SET_REENTER_COUNT SetReenterCount
= &ApiMessage
.Data
.SetReenterCountRequest
;
1140 PCSR_CAPTURE_BUFFER CaptureBuffer
= NULL
;
1141 ULONG NumStrings
= 0;
1143 if (CommandData
!= NULL
)
1145 if (CommandData
->VDMState
& (VDM_NOT_LOADED
| VDM_NOT_READY
| VDM_READY
))
1147 /* Clear the structure */
1148 ZeroMemory(GetNextVdmCommand
, sizeof(*GetNextVdmCommand
));
1150 /* Setup the input parameters */
1151 GetNextVdmCommand
->ConsoleHandle
= NtCurrentPeb()->ProcessParameters
->ConsoleHandle
;
1152 GetNextVdmCommand
->CmdLen
= CommandData
->CmdLen
;
1153 GetNextVdmCommand
->AppLen
= CommandData
->AppLen
;
1154 GetNextVdmCommand
->PifLen
= CommandData
->PifLen
;
1155 GetNextVdmCommand
->CurDirectoryLen
= CommandData
->CurDirectoryLen
;
1156 GetNextVdmCommand
->EnvLen
= CommandData
->EnvLen
;
1157 GetNextVdmCommand
->DesktopLen
= CommandData
->DesktopLen
;
1158 GetNextVdmCommand
->TitleLen
= CommandData
->TitleLen
;
1159 GetNextVdmCommand
->ReservedLen
= CommandData
->ReservedLen
;
1160 GetNextVdmCommand
->VDMState
= CommandData
->VDMState
;
1162 /* Count the number of strings */
1163 if (CommandData
->CmdLen
) NumStrings
++;
1164 if (CommandData
->AppLen
) NumStrings
++;
1165 if (CommandData
->PifLen
) NumStrings
++;
1166 if (CommandData
->CurDirectoryLen
) NumStrings
++;
1167 if (CommandData
->EnvLen
) NumStrings
++;
1168 if (CommandData
->DesktopLen
) NumStrings
++;
1169 if (CommandData
->TitleLen
) NumStrings
++;
1170 if (CommandData
->ReservedLen
) NumStrings
++;
1172 /* Allocate the capture buffer */
1173 CaptureBuffer
= CsrAllocateCaptureBuffer(NumStrings
+ 1,
1174 GetNextVdmCommand
->CmdLen
1175 + GetNextVdmCommand
->AppLen
1176 + GetNextVdmCommand
->PifLen
1177 + GetNextVdmCommand
->CurDirectoryLen
1178 + GetNextVdmCommand
->EnvLen
1179 + GetNextVdmCommand
->DesktopLen
1180 + GetNextVdmCommand
->TitleLen
1181 + GetNextVdmCommand
->ReservedLen
1182 + sizeof(STARTUPINFOA
));
1183 if (CaptureBuffer
== NULL
)
1185 BaseSetLastNTError(STATUS_NO_MEMORY
);
1189 /* Allocate memory for the startup info */
1190 CsrAllocateMessagePointer(CaptureBuffer
,
1191 sizeof(STARTUPINFOA
),
1192 (PVOID
*)&GetNextVdmCommand
->StartupInfo
);
1194 if (CommandData
->CmdLen
)
1196 /* Allocate memory for the command line */
1197 CsrAllocateMessagePointer(CaptureBuffer
,
1198 CommandData
->CmdLen
,
1199 (PVOID
*)&GetNextVdmCommand
->CmdLine
);
1202 if (CommandData
->AppLen
)
1204 /* Allocate memory for the application name */
1205 CsrAllocateMessagePointer(CaptureBuffer
,
1206 CommandData
->AppLen
,
1207 (PVOID
*)&GetNextVdmCommand
->AppName
);
1210 if (CommandData
->PifLen
)
1212 /* Allocate memory for the PIF file name */
1213 CsrAllocateMessagePointer(CaptureBuffer
,
1214 CommandData
->PifLen
,
1215 (PVOID
*)&GetNextVdmCommand
->PifFile
);
1218 if (CommandData
->CurDirectoryLen
)
1220 /* Allocate memory for the current directory */
1221 CsrAllocateMessagePointer(CaptureBuffer
,
1222 CommandData
->CurDirectoryLen
,
1223 (PVOID
*)&GetNextVdmCommand
->CurDirectory
);
1226 if (CommandData
->EnvLen
)
1228 /* Allocate memory for the environment */
1229 CsrAllocateMessagePointer(CaptureBuffer
,
1230 CommandData
->EnvLen
,
1231 (PVOID
*)&GetNextVdmCommand
->Env
);
1234 if (CommandData
->DesktopLen
)
1236 /* Allocate memory for the desktop name */
1237 CsrAllocateMessagePointer(CaptureBuffer
,
1238 CommandData
->DesktopLen
,
1239 (PVOID
*)&GetNextVdmCommand
->Desktop
);
1242 if (CommandData
->TitleLen
)
1244 /* Allocate memory for the title */
1245 CsrAllocateMessagePointer(CaptureBuffer
,
1246 CommandData
->TitleLen
,
1247 (PVOID
*)&GetNextVdmCommand
->Title
);
1250 if (CommandData
->ReservedLen
)
1252 /* Allocate memory for the reserved parameter */
1253 CsrAllocateMessagePointer(CaptureBuffer
,
1254 CommandData
->ReservedLen
,
1255 (PVOID
*)&GetNextVdmCommand
->Reserved
);
1261 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1263 CSR_CREATE_API_NUMBER(BASESRV_SERVERDLL_INDEX
, BasepGetNextVDMCommand
),
1264 sizeof(BASE_GET_NEXT_VDM_COMMAND
));
1266 if (!NT_SUCCESS(Status
))
1268 BaseSetLastNTError(Status
);
1272 /* Did we receive an event handle? */
1273 if (GetNextVdmCommand
->WaitObjectForVDM
!= NULL
)
1275 /* Wait for the event to become signaled and try again */
1276 Status
= NtWaitForSingleObject(GetNextVdmCommand
->WaitObjectForVDM
,
1279 if (!NT_SUCCESS(Status
))
1281 BaseSetLastNTError(Status
);
1285 /* Set the retry flag and clear the exit code */
1286 GetNextVdmCommand
->VDMState
|= VDM_FLAG_RETRY
;
1287 GetNextVdmCommand
->ExitCode
= 0;
1290 while (GetNextVdmCommand
->WaitObjectForVDM
!= NULL
);
1292 /* Write back the standard handles */
1293 CommandData
->StdIn
= GetNextVdmCommand
->StdIn
;
1294 CommandData
->StdOut
= GetNextVdmCommand
->StdOut
;
1295 CommandData
->StdErr
= GetNextVdmCommand
->StdErr
;
1297 /* Write back the startup info */
1298 RtlMoveMemory(&CommandData
->StartupInfo
,
1299 GetNextVdmCommand
->StartupInfo
,
1300 sizeof(STARTUPINFOA
));
1302 if (CommandData
->CmdLen
)
1304 /* Write back the command line */
1305 RtlMoveMemory(CommandData
->CmdLine
,
1306 GetNextVdmCommand
->CmdLine
,
1307 GetNextVdmCommand
->CmdLen
);
1309 /* Set the actual length */
1310 CommandData
->CmdLen
= GetNextVdmCommand
->CmdLen
;
1313 if (CommandData
->AppLen
)
1315 /* Write back the application name */
1316 RtlMoveMemory(CommandData
->AppName
,
1317 GetNextVdmCommand
->AppName
,
1318 GetNextVdmCommand
->AppLen
);
1320 /* Set the actual length */
1321 CommandData
->AppLen
= GetNextVdmCommand
->AppLen
;
1324 if (CommandData
->PifLen
)
1326 /* Write back the PIF file name */
1327 RtlMoveMemory(CommandData
->PifFile
,
1328 GetNextVdmCommand
->PifFile
,
1329 GetNextVdmCommand
->PifLen
);
1331 /* Set the actual length */
1332 CommandData
->PifLen
= GetNextVdmCommand
->PifLen
;
1335 if (CommandData
->CurDirectoryLen
)
1337 /* Write back the current directory */
1338 RtlMoveMemory(CommandData
->CurDirectory
,
1339 GetNextVdmCommand
->CurDirectory
,
1340 GetNextVdmCommand
->CurDirectoryLen
);
1342 /* Set the actual length */
1343 CommandData
->CurDirectoryLen
= GetNextVdmCommand
->CurDirectoryLen
;
1346 if (CommandData
->EnvLen
)
1348 /* Write back the environment */
1349 RtlMoveMemory(CommandData
->Env
,
1350 GetNextVdmCommand
->Env
,
1351 GetNextVdmCommand
->EnvLen
);
1353 /* Set the actual length */
1354 CommandData
->EnvLen
= GetNextVdmCommand
->EnvLen
;
1357 if (CommandData
->DesktopLen
)
1359 /* Write back the desktop name */
1360 RtlMoveMemory(CommandData
->Desktop
,
1361 GetNextVdmCommand
->Desktop
,
1362 GetNextVdmCommand
->DesktopLen
);
1364 /* Set the actual length */
1365 CommandData
->DesktopLen
= GetNextVdmCommand
->DesktopLen
;
1368 if (CommandData
->TitleLen
)
1370 /* Write back the title */
1371 RtlMoveMemory(CommandData
->Title
,
1372 GetNextVdmCommand
->Title
,
1373 GetNextVdmCommand
->TitleLen
);
1375 /* Set the actual length */
1376 CommandData
->TitleLen
= GetNextVdmCommand
->TitleLen
;
1379 if (CommandData
->ReservedLen
)
1381 /* Write back the reserved parameter */
1382 RtlMoveMemory(CommandData
->Reserved
,
1383 GetNextVdmCommand
->Reserved
,
1384 GetNextVdmCommand
->ReservedLen
);
1386 /* Set the actual length */
1387 CommandData
->ReservedLen
= GetNextVdmCommand
->ReservedLen
;
1390 /* Write the remaining output parameters */
1391 CommandData
->TaskId
= GetNextVdmCommand
->iTask
;
1392 CommandData
->CreationFlags
= GetNextVdmCommand
->dwCreationFlags
;
1393 CommandData
->CodePage
= GetNextVdmCommand
->CodePage
;
1394 CommandData
->ExitCode
= GetNextVdmCommand
->ExitCode
;
1395 CommandData
->CurrentDrive
= GetNextVdmCommand
->CurrentDrive
;
1396 CommandData
->VDMState
= GetNextVdmCommand
->VDMState
;
1397 CommandData
->ComingFromBat
= GetNextVdmCommand
->fComingFromBat
;
1399 /* It was successful */
1402 else if ((CommandData
->VDMState
== VDM_INC_REENTER_COUNT
)
1403 || (CommandData
->VDMState
== VDM_DEC_REENTER_COUNT
))
1405 /* Setup the input parameters */
1406 SetReenterCount
->ConsoleHandle
= NtCurrentPeb()->ProcessParameters
->ConsoleHandle
;
1407 SetReenterCount
->fIncDec
= CommandData
->VDMState
;
1410 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1412 CSR_CREATE_API_NUMBER(BASESRV_SERVERDLL_INDEX
, BasepSetReenterCount
),
1413 sizeof(BASE_SET_REENTER_COUNT
));
1414 BaseSetLastNTError(Status
);
1415 Result
= NT_SUCCESS(Status
);
1419 BaseSetLastNTError(STATUS_INVALID_PARAMETER
);
1426 Status
= CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1428 CSR_CREATE_API_NUMBER(BASESRV_SERVERDLL_INDEX
, BasepIsFirstVDM
),
1429 sizeof(BASE_IS_FIRST_VDM
));
1430 if (!NT_SUCCESS(Status
))
1432 BaseSetLastNTError(Status
);
1436 /* Return TRUE if this is the first VDM */
1437 Result
= IsFirstVdm
->FirstVDM
;
1441 if (CaptureBuffer
!= NULL
) CsrFreeCaptureBuffer(CaptureBuffer
);
1451 GetVDMCurrentDirectories(DWORD cchCurDirs
, PCHAR lpszzCurDirs
)
1453 BASE_API_MESSAGE ApiMessage
;
1454 PBASE_GETSET_VDM_CURDIRS VDMCurrentDirsRequest
= &ApiMessage
.Data
.VDMCurrentDirsRequest
;
1455 PCSR_CAPTURE_BUFFER CaptureBuffer
;
1457 /* Allocate the capture buffer */
1458 CaptureBuffer
= CsrAllocateCaptureBuffer(1, cchCurDirs
);
1459 if (CaptureBuffer
== NULL
)
1461 BaseSetLastNTError(STATUS_NO_MEMORY
);
1465 /* Setup the input parameters */
1466 VDMCurrentDirsRequest
->cchCurDirs
= cchCurDirs
;
1467 CsrAllocateMessagePointer(CaptureBuffer
,
1469 (PVOID
*)&VDMCurrentDirsRequest
->lpszzCurDirs
);
1472 CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1474 CSR_CREATE_API_NUMBER(BASESRV_SERVERDLL_INDEX
, BasepGetVDMCurDirs
),
1475 sizeof(BASE_GETSET_VDM_CURDIRS
));
1477 /* Set the last error */
1478 BaseSetLastNTError(ApiMessage
.Status
);
1480 if (NT_SUCCESS(ApiMessage
.Status
))
1482 /* Copy the result */
1483 RtlMoveMemory(lpszzCurDirs
, VDMCurrentDirsRequest
->lpszzCurDirs
, cchCurDirs
);
1486 /* Free the capture buffer */
1487 CsrFreeCaptureBuffer(CaptureBuffer
);
1489 /* Return the size if it was successful, or if the buffer was too small */
1490 return (NT_SUCCESS(ApiMessage
.Status
) || (ApiMessage
.Status
== STATUS_BUFFER_TOO_SMALL
))
1491 ? VDMCurrentDirsRequest
->cchCurDirs
: 0;
1500 RegisterConsoleVDM (
1524 RegisterWowBaseHandlers (
1552 SetVDMCurrentDirectories(DWORD cchCurDirs
, PCHAR lpszzCurDirs
)
1554 BASE_API_MESSAGE ApiMessage
;
1555 PBASE_GETSET_VDM_CURDIRS VDMCurrentDirsRequest
= &ApiMessage
.Data
.VDMCurrentDirsRequest
;
1556 PCSR_CAPTURE_BUFFER CaptureBuffer
;
1558 /* Allocate the capture buffer */
1559 CaptureBuffer
= CsrAllocateCaptureBuffer(1, cchCurDirs
);
1560 if (CaptureBuffer
== NULL
)
1562 BaseSetLastNTError(STATUS_NO_MEMORY
);
1566 /* Setup the input parameters */
1567 VDMCurrentDirsRequest
->cchCurDirs
= cchCurDirs
;
1568 CsrCaptureMessageBuffer(CaptureBuffer
,
1571 (PVOID
*)&VDMCurrentDirsRequest
->lpszzCurDirs
);
1574 CsrClientCallServer((PCSR_API_MESSAGE
)&ApiMessage
,
1576 CSR_CREATE_API_NUMBER(BASESRV_SERVERDLL_INDEX
, BasepSetVDMCurDirs
),
1577 sizeof(BASE_GETSET_VDM_CURDIRS
));
1579 /* Free the capture buffer */
1580 CsrFreeCaptureBuffer(CaptureBuffer
);
1582 /* Set the last error */
1583 BaseSetLastNTError(ApiMessage
.Status
);
1585 return NT_SUCCESS(ApiMessage
.Status
) ? TRUE
: FALSE
;
1593 VDMConsoleOperation (
1608 VDMOperationStarted (