mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 19:52:56 +00:00
Copy all the startup info to the new process.
svn path=/trunk/; revision=3394
This commit is contained in:
parent
84a242512b
commit
87579ff3f0
3 changed files with 213 additions and 228 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: create.c,v 1.47 2002/08/08 17:54:12 dwelch Exp $
|
/* $Id: create.c,v 1.48 2002/08/26 11:24:28 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -892,6 +892,31 @@ CreateProcessW(LPCWSTR lpApplicationName,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialize some other fields in the PPB
|
||||||
|
*/
|
||||||
|
if (lpStartupInfo)
|
||||||
|
{
|
||||||
|
Ppb->Flags = lpStartupInfo->Flags;
|
||||||
|
if (Ppb->Flags & STARTF_USESHOWWINDOW)
|
||||||
|
{
|
||||||
|
Ppb->ShowWindowFlags = lpStartupInfo->wShowWindow;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Ppb->ShowWindowFlags = SW_SHOWDEFAULT;
|
||||||
|
}
|
||||||
|
Ppb->StartingX = Ppb->dwX;
|
||||||
|
Ppb->StartingY = Ppb->dwY;
|
||||||
|
Ppb->CountX = Ppb->dwXSize;
|
||||||
|
Ppb->CountY = Ppb->dwYSize;
|
||||||
|
Ppb->FillAttribute = Ppb->dwFillAttribute;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Ppb->Flags = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create Process Environment Block
|
* Create Process Environment Block
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: proc.c,v 1.43 2002/05/07 22:26:29 hbirr Exp $
|
/* $Id: proc.c,v 1.44 2002/08/26 11:24:28 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -477,263 +477,219 @@ GetStartupInfoA(LPSTARTUPINFOA lpStartupInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOL
|
BOOL STDCALL
|
||||||
STDCALL
|
FlushInstructionCache (HANDLE hProcess,
|
||||||
FlushInstructionCache (
|
LPCVOID lpBaseAddress,
|
||||||
HANDLE hProcess,
|
DWORD dwSize)
|
||||||
LPCVOID lpBaseAddress,
|
|
||||||
DWORD dwSize
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
NTSTATUS errCode;
|
NTSTATUS errCode;
|
||||||
|
|
||||||
errCode = NtFlushInstructionCache (
|
errCode = NtFlushInstructionCache (hProcess,
|
||||||
hProcess,
|
(PVOID) lpBaseAddress,
|
||||||
(PVOID) lpBaseAddress,
|
dwSize);
|
||||||
dwSize);
|
if (!NT_SUCCESS(errCode))
|
||||||
if (!NT_SUCCESS(errCode))
|
|
||||||
{
|
|
||||||
SetLastErrorByStatus (errCode);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VOID
|
|
||||||
STDCALL
|
|
||||||
ExitProcess (
|
|
||||||
UINT uExitCode
|
|
||||||
)
|
|
||||||
{
|
|
||||||
CSRSS_API_REQUEST CsrRequest;
|
|
||||||
CSRSS_API_REPLY CsrReply;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
/* unload all dll's */
|
|
||||||
LdrShutdownProcess ();
|
|
||||||
|
|
||||||
/* notify csrss of process termination */
|
|
||||||
CsrRequest.Type = CSRSS_TERMINATE_PROCESS;
|
|
||||||
Status = CsrClientCallServer(&CsrRequest,
|
|
||||||
&CsrReply,
|
|
||||||
sizeof(CSRSS_API_REQUEST),
|
|
||||||
sizeof(CSRSS_API_REPLY));
|
|
||||||
if (!NT_SUCCESS(Status) || !NT_SUCCESS(CsrReply.Status))
|
|
||||||
{
|
|
||||||
DbgPrint("Failed to tell csrss about terminating process. Expect trouble.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
NtTerminateProcess (NtCurrentProcess (),
|
|
||||||
uExitCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WINBOOL
|
|
||||||
STDCALL
|
|
||||||
TerminateProcess (
|
|
||||||
HANDLE hProcess,
|
|
||||||
UINT uExitCode
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (0 == hProcess)
|
|
||||||
{
|
{
|
||||||
SetLastError (ERROR_INVALID_HANDLE);
|
SetLastErrorByStatus (errCode);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
else
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID STDCALL
|
||||||
|
ExitProcess (UINT uExitCode)
|
||||||
|
{
|
||||||
|
CSRSS_API_REQUEST CsrRequest;
|
||||||
|
CSRSS_API_REPLY CsrReply;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
/* unload all dll's */
|
||||||
|
LdrShutdownProcess ();
|
||||||
|
|
||||||
|
/* notify csrss of process termination */
|
||||||
|
CsrRequest.Type = CSRSS_TERMINATE_PROCESS;
|
||||||
|
Status = CsrClientCallServer(&CsrRequest,
|
||||||
|
&CsrReply,
|
||||||
|
sizeof(CSRSS_API_REQUEST),
|
||||||
|
sizeof(CSRSS_API_REPLY));
|
||||||
|
if (!NT_SUCCESS(Status) || !NT_SUCCESS(CsrReply.Status))
|
||||||
{
|
{
|
||||||
NTSTATUS Status = NtTerminateProcess (hProcess, uExitCode);
|
DbgPrint("Failed to tell csrss about terminating process. "
|
||||||
|
"Expect trouble.\n");
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
SetLastErrorByStatus (Status);
|
|
||||||
}
|
}
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
|
NtTerminateProcess (NtCurrentProcess (),
|
||||||
|
uExitCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID
|
WINBOOL STDCALL
|
||||||
STDCALL
|
TerminateProcess (HANDLE hProcess,
|
||||||
FatalAppExitA (
|
UINT uExitCode)
|
||||||
UINT uAction,
|
|
||||||
LPCSTR lpMessageText
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
UNICODE_STRING MessageTextU;
|
NTSTATUS Status = NtTerminateProcess (hProcess, uExitCode);
|
||||||
ANSI_STRING MessageText;
|
|
||||||
|
|
||||||
RtlInitAnsiString (& MessageText,
|
if (NT_SUCCESS(Status))
|
||||||
(LPSTR) lpMessageText);
|
{
|
||||||
|
return TRUE;
|
||||||
RtlAnsiStringToUnicodeString (& MessageTextU,
|
}
|
||||||
& MessageText,
|
SetLastErrorByStatus (Status);
|
||||||
TRUE);
|
return FALSE;
|
||||||
|
|
||||||
FatalAppExitW (uAction,
|
|
||||||
MessageTextU.Buffer);
|
|
||||||
|
|
||||||
RtlFreeUnicodeString (&MessageTextU);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID
|
VOID STDCALL
|
||||||
STDCALL
|
FatalAppExitA (UINT uAction,
|
||||||
FatalAppExitW (
|
LPCSTR lpMessageText)
|
||||||
UINT uAction,
|
|
||||||
LPCWSTR lpMessageText
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return;
|
UNICODE_STRING MessageTextU;
|
||||||
|
ANSI_STRING MessageText;
|
||||||
|
|
||||||
|
RtlInitAnsiString (&MessageText, (LPSTR) lpMessageText);
|
||||||
|
|
||||||
|
RtlAnsiStringToUnicodeString (&MessageTextU,
|
||||||
|
&MessageText,
|
||||||
|
TRUE);
|
||||||
|
|
||||||
|
FatalAppExitW (uAction, MessageTextU.Buffer);
|
||||||
|
|
||||||
|
RtlFreeUnicodeString (&MessageTextU);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID
|
VOID STDCALL
|
||||||
STDCALL
|
FatalAppExitW (UINT uAction,
|
||||||
FatalExit (
|
LPCWSTR lpMessageText)
|
||||||
int ExitCode
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
ExitProcess(ExitCode);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DWORD
|
VOID STDCALL
|
||||||
STDCALL
|
FatalExit (int ExitCode)
|
||||||
GetPriorityClass (
|
|
||||||
HANDLE hProcess
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
HANDLE hProcessTmp;
|
ExitProcess(ExitCode);
|
||||||
DWORD CsrPriorityClass = 0; // This tells CSRSS we want to GET it!
|
}
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
Status = NtDuplicateObject (
|
|
||||||
GetCurrentProcess(),
|
DWORD STDCALL
|
||||||
hProcess,
|
GetPriorityClass (HANDLE hProcess)
|
||||||
GetCurrentProcess(),
|
{
|
||||||
& hProcessTmp,
|
HANDLE hProcessTmp;
|
||||||
(PROCESS_SET_INFORMATION | PROCESS_QUERY_INFORMATION),
|
DWORD CsrPriorityClass = 0; // This tells CSRSS we want to GET it!
|
||||||
FALSE,
|
NTSTATUS Status;
|
||||||
0
|
|
||||||
);
|
Status =
|
||||||
if (!NT_SUCCESS(Status))
|
NtDuplicateObject (GetCurrentProcess(),
|
||||||
{
|
hProcess,
|
||||||
SetLastErrorByStatus (Status);
|
GetCurrentProcess(),
|
||||||
return (0); /* ERROR */
|
&hProcessTmp,
|
||||||
}
|
(PROCESS_SET_INFORMATION | PROCESS_QUERY_INFORMATION),
|
||||||
/* Ask CSRSS to set it */
|
FALSE,
|
||||||
CsrSetPriorityClass (
|
0);
|
||||||
hProcessTmp,
|
if (!NT_SUCCESS(Status))
|
||||||
& CsrPriorityClass
|
{
|
||||||
);
|
SetLastErrorByStatus (Status);
|
||||||
NtClose (hProcessTmp);
|
return (0); /* ERROR */
|
||||||
/* Translate CSR->W32 priorities */
|
}
|
||||||
switch (CsrPriorityClass)
|
/* Ask CSRSS to set it */
|
||||||
{
|
CsrSetPriorityClass (hProcessTmp, &CsrPriorityClass);
|
||||||
case CSR_PRIORITY_CLASS_NORMAL:
|
NtClose (hProcessTmp);
|
||||||
return (NORMAL_PRIORITY_CLASS); /* 32 */
|
/* Translate CSR->W32 priorities */
|
||||||
case CSR_PRIORITY_CLASS_IDLE:
|
switch (CsrPriorityClass)
|
||||||
return (IDLE_PRIORITY_CLASS); /* 64 */
|
{
|
||||||
case CSR_PRIORITY_CLASS_HIGH:
|
case CSR_PRIORITY_CLASS_NORMAL:
|
||||||
return (HIGH_PRIORITY_CLASS); /* 128 */
|
return (NORMAL_PRIORITY_CLASS); /* 32 */
|
||||||
case CSR_PRIORITY_CLASS_REALTIME:
|
case CSR_PRIORITY_CLASS_IDLE:
|
||||||
return (REALTIME_PRIORITY_CLASS); /* 256 */
|
return (IDLE_PRIORITY_CLASS); /* 64 */
|
||||||
}
|
case CSR_PRIORITY_CLASS_HIGH:
|
||||||
SetLastError (ERROR_ACCESS_DENIED);
|
return (HIGH_PRIORITY_CLASS); /* 128 */
|
||||||
return (0); /* ERROR */
|
case CSR_PRIORITY_CLASS_REALTIME:
|
||||||
|
return (REALTIME_PRIORITY_CLASS); /* 256 */
|
||||||
|
}
|
||||||
|
SetLastError (ERROR_ACCESS_DENIED);
|
||||||
|
return (0); /* ERROR */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
WINBOOL
|
WINBOOL STDCALL
|
||||||
STDCALL
|
SetPriorityClass (HANDLE hProcess,
|
||||||
SetPriorityClass (
|
DWORD dwPriorityClass)
|
||||||
HANDLE hProcess,
|
|
||||||
DWORD dwPriorityClass
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
HANDLE hProcessTmp;
|
HANDLE hProcessTmp;
|
||||||
DWORD CsrPriorityClass;
|
DWORD CsrPriorityClass;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
switch (dwPriorityClass)
|
switch (dwPriorityClass)
|
||||||
{
|
{
|
||||||
case NORMAL_PRIORITY_CLASS: /* 32 */
|
case NORMAL_PRIORITY_CLASS: /* 32 */
|
||||||
CsrPriorityClass = CSR_PRIORITY_CLASS_NORMAL;
|
CsrPriorityClass = CSR_PRIORITY_CLASS_NORMAL;
|
||||||
break;
|
break;
|
||||||
case IDLE_PRIORITY_CLASS: /* 64 */
|
case IDLE_PRIORITY_CLASS: /* 64 */
|
||||||
CsrPriorityClass = CSR_PRIORITY_CLASS_IDLE;
|
CsrPriorityClass = CSR_PRIORITY_CLASS_IDLE;
|
||||||
break;
|
break;
|
||||||
case HIGH_PRIORITY_CLASS: /* 128 */
|
case HIGH_PRIORITY_CLASS: /* 128 */
|
||||||
CsrPriorityClass = CSR_PRIORITY_CLASS_HIGH;
|
CsrPriorityClass = CSR_PRIORITY_CLASS_HIGH;
|
||||||
break;
|
break;
|
||||||
case REALTIME_PRIORITY_CLASS: /* 256 */
|
case REALTIME_PRIORITY_CLASS: /* 256 */
|
||||||
CsrPriorityClass = CSR_PRIORITY_CLASS_REALTIME;
|
CsrPriorityClass = CSR_PRIORITY_CLASS_REALTIME;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SetLastError (ERROR_INVALID_PARAMETER);
|
SetLastError (ERROR_INVALID_PARAMETER);
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
Status = NtDuplicateObject (
|
Status =
|
||||||
GetCurrentProcess(),
|
NtDuplicateObject (GetCurrentProcess(),
|
||||||
hProcess,
|
hProcess,
|
||||||
GetCurrentProcess(),
|
GetCurrentProcess(),
|
||||||
& hProcessTmp,
|
&hProcessTmp,
|
||||||
(PROCESS_SET_INFORMATION | PROCESS_QUERY_INFORMATION),
|
(PROCESS_SET_INFORMATION | PROCESS_QUERY_INFORMATION),
|
||||||
FALSE,
|
FALSE,
|
||||||
0
|
0);
|
||||||
);
|
if (!NT_SUCCESS(Status))
|
||||||
if (!NT_SUCCESS(Status))
|
{
|
||||||
{
|
SetLastErrorByStatus (Status);
|
||||||
SetLastErrorByStatus (Status);
|
return (FALSE); /* ERROR */
|
||||||
return (FALSE); /* ERROR */
|
}
|
||||||
}
|
/* Ask CSRSS to set it */
|
||||||
/* Ask CSRSS to set it */
|
Status = CsrSetPriorityClass (hProcessTmp, &CsrPriorityClass);
|
||||||
Status = CsrSetPriorityClass (
|
NtClose (hProcessTmp);
|
||||||
hProcessTmp,
|
if (!NT_SUCCESS(Status))
|
||||||
& CsrPriorityClass
|
{
|
||||||
);
|
SetLastErrorByStatus (Status);
|
||||||
NtClose (hProcessTmp);
|
return (FALSE);
|
||||||
if (!NT_SUCCESS(Status))
|
}
|
||||||
{
|
return (TRUE);
|
||||||
SetLastErrorByStatus (Status);
|
|
||||||
return (FALSE);
|
|
||||||
}
|
|
||||||
return (TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DWORD
|
DWORD STDCALL
|
||||||
STDCALL
|
GetProcessVersion (DWORD ProcessId)
|
||||||
GetProcessVersion (
|
|
||||||
DWORD ProcessId
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
DWORD Version = 0;
|
DWORD Version = 0;
|
||||||
PIMAGE_NT_HEADERS NtHeader = NULL;
|
PIMAGE_NT_HEADERS NtHeader = NULL;
|
||||||
PVOID BaseAddress = NULL;
|
PVOID BaseAddress = NULL;
|
||||||
|
|
||||||
/* Caller's */
|
/* Caller's */
|
||||||
if (0 == ProcessId)
|
if (0 == ProcessId)
|
||||||
|
{
|
||||||
|
BaseAddress = (PVOID) NtCurrentPeb()->ImageBaseAddress;
|
||||||
|
NtHeader = RtlImageNtHeader (BaseAddress);
|
||||||
|
if (NULL != NtHeader)
|
||||||
{
|
{
|
||||||
BaseAddress = (PVOID) NtCurrentPeb()->ImageBaseAddress;
|
Version =
|
||||||
NtHeader = RtlImageNtHeader (BaseAddress);
|
(NtHeader->OptionalHeader.MajorOperatingSystemVersion << 16) |
|
||||||
if (NULL != NtHeader)
|
(NtHeader->OptionalHeader.MinorOperatingSystemVersion);
|
||||||
{
|
|
||||||
Version =
|
|
||||||
(NtHeader->OptionalHeader.MajorOperatingSystemVersion << 16)
|
|
||||||
| (NtHeader->OptionalHeader.MinorOperatingSystemVersion);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else /* other process */
|
}
|
||||||
{
|
else /* other process */
|
||||||
/* FIXME: open the other process */
|
{
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
/* FIXME: open the other process */
|
||||||
}
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return (Version);
|
}
|
||||||
|
return (Version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,10 +29,10 @@ static inline struct debug_info *get_info(void)
|
||||||
tmp.str_pos = tmp.strings;
|
tmp.str_pos = tmp.strings;
|
||||||
tmp.out_pos = tmp.output;
|
tmp.out_pos = tmp.output;
|
||||||
}
|
}
|
||||||
if (!GetProcessHeap()) return &tmp;
|
if (!RtlGetProcessHeap()) return &tmp;
|
||||||
/* setup the temp structure in case HeapAlloc wants to print something */
|
/* setup the temp structure in case HeapAlloc wants to print something */
|
||||||
NtCurrentTeb()->WineDebugInfo = &tmp;
|
NtCurrentTeb()->WineDebugInfo = &tmp;
|
||||||
info = HeapAlloc( GetProcessHeap(), 0, sizeof(*info) );
|
info = RtlAllocateHeap( RtlGetProcessHeap(), 0, sizeof(*info) );
|
||||||
info->str_pos = info->strings;
|
info->str_pos = info->strings;
|
||||||
info->out_pos = info->output;
|
info->out_pos = info->output;
|
||||||
NtCurrentTeb()->WineDebugInfo = info;
|
NtCurrentTeb()->WineDebugInfo = info;
|
||||||
|
@ -202,8 +202,12 @@ int wine_dbg_vprintf( const char *format, va_list args )
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *pos = info->output;
|
char *pos = info->output;
|
||||||
|
char saved_ch;
|
||||||
p++;
|
p++;
|
||||||
write( 2, pos, p - pos );
|
saved_ch = *p;
|
||||||
|
*p = 0;
|
||||||
|
DbgPrint(pos);
|
||||||
|
*p = saved_ch;
|
||||||
/* move beginning of next line to start of buffer */
|
/* move beginning of next line to start of buffer */
|
||||||
while ((*pos = *p++)) pos++;
|
while ((*pos = *p++)) pos++;
|
||||||
info->out_pos = pos;
|
info->out_pos = pos;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue