HANDLE hOut;
HANDLE hConsole;
HANDLE CMD_ModuleHandle;
-HMODULE NtDllModule;
static NtQueryInformationProcessProc NtQueryInformationProcessPtr = NULL;
static NtReadVirtualMemoryProc NtReadVirtualMemoryPtr = NULL;
return NULL;
}
-BOOL bNoInteractive;
-BOOL bIsBatch;
-
BOOL
SubstituteVars(TCHAR *Src, TCHAR *Dest, TCHAR Delim)
{
}
Src++;
- if (bIsBatch && Delim == _T('%'))
+ if (bc && Delim == _T('%'))
{
UINT NameLen;
Var = GetBatchVar(Src, &NameLen);
if (Var == NULL)
{
/* In a batch file, %NONEXISTENT% "expands" to an empty string */
- if (bIsBatch)
+ if (bc)
continue;
goto bad_subst;
}
bad_subst:
Src = SubstStart;
- if (!bIsBatch)
+ if (!bc)
APPEND1(Delim)
}
*Dest = _T('\0');
/* if no batch input then... */
if (bc == NULL)
{
- if (bNoInteractive)
- {
- bExit = TRUE;
- return FALSE;
- }
-
if (bMore)
{
ConOutPrintf(_T("More? "));
return FALSE;
}
ip = readline;
- bIsBatch = FALSE;
}
else
{
ip = ReadBatchLine();
if (!ip)
return FALSE;
- bIsBatch = TRUE;
}
return SubstituteVars(ip, commandline, _T('%'));
}
static INT
-ProcessInput (BOOL bFlag)
+ProcessInput()
{
PARSED_COMMAND *Cmd;
- bNoInteractive = bFlag;
do
{
Cmd = ParseCommand(NULL);
static VOID
Initialize()
{
+ HMODULE NtDllModule;
TCHAR commandline[CMDLINE_LENGTH];
TCHAR ModuleName[_MAX_PATH + 1];
TCHAR lpBuffer[2];
/* Some people like to run ReactOS cmd.exe on Win98, it helps in the
* build process. So don't link implicitly against ntdll.dll, load it
* dynamically instead */
-
- if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)
- {
- /* ntdll is always present on NT */
- NtDllModule = GetModuleHandle(TEXT("ntdll.dll"));
- }
- else
- {
- /* not all 9x versions have a ntdll.dll, try to load it */
- NtDllModule = LoadLibrary(TEXT("ntdll.dll"));
- }
-
+ NtDllModule = GetModuleHandle(TEXT("ntdll.dll"));
if (NtDllModule != NULL)
{
NtQueryInformationProcessPtr = (NtQueryInformationProcessProc)GetProcAddress(NtDllModule, "NtQueryInformationProcess");
/* This just runs a program and exits */
GetCmdLineCommand(commandline, &ptr[2], AlwaysStrip);
ParseCommandLine(commandline);
- cmd_exit (ProcessInput (TRUE));
+ cmd_exit(nErrorLevel);
}
else if (_totlower(ptr[1]) == _T('k'))
{
RemoveBreakHandler ();
SetConsoleMode( GetStdHandle( STD_INPUT_HANDLE ),
ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_ECHO_INPUT );
-
- if (NtDllModule != NULL)
- {
- FreeLibrary(NtDllModule);
- }
}
/*
Initialize();
/* call prompt routine */
- nExitCode = ProcessInput(FALSE);
+ nExitCode = ProcessInput();
/* do the cleanup */
Cleanup();