FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE);
if (!NT_SUCCESS(Status))
{
- DPRINT1("Failed to read image file from disk\n");
+ DPRINT1("Failed to read image file from disk, Status = 0x%08X\n", Status);
return Status;
}
hFile);
if (!NT_SUCCESS(Status))
{
- DPRINT1("Failed to create section for image file\n");
+ DPRINT1("Failed to create section for image file, Status = 0x%08X\n", Status);
}
ZwClose(hFile);
{
/* Give 1MB starting at 0x4 */
BaseAddress = (PVOID)4;
- EnviroSize = 1024 * 1024;
+ EnviroSize = (1024 * 1024) - 256;
Status = ZwAllocateVirtualMemory(ProcessHandle,
&BaseAddress,
0,
Status = RtlpMapFile(ImageFileName,
Attributes,
&hSection);
- if(!NT_SUCCESS(Status))
+ if (!NT_SUCCESS(Status))
{
DPRINT1("Could not map process image\n");
return Status;
}
/* Get some information about the process */
- ZwQueryInformationProcess(ProcessInfo->ProcessHandle,
- ProcessBasicInformation,
- &ProcessBasicInfo,
- sizeof(ProcessBasicInfo),
- NULL);
+ Status = ZwQueryInformationProcess(ProcessInfo->ProcessHandle,
+ ProcessBasicInformation,
+ &ProcessBasicInfo,
+ sizeof(ProcessBasicInfo),
+ NULL);
if (!NT_SUCCESS(Status))
{
DPRINT1("Could not query Process Info\n");
* http://www.geoffchappell.com/studies/windows/win32/ntdll/api/rtl/peb/setprocessiscritical.htm
*/
NTSTATUS
-NTAPI
+__cdecl
RtlSetProcessIsCritical(IN BOOLEAN NewValue,
OUT PBOOLEAN OldValue OPTIONAL,
IN BOOLEAN NeedBreaks)
{
- ULONG BreakOnTermination = FALSE;
+ ULONG BreakOnTermination;
- if (OldValue)
- *OldValue = FALSE;
+ /* Initialize to FALSE */
+ if (OldValue) *OldValue = FALSE;
/* Fail, if the critical breaks flag is required but is not set */
- if (NeedBreaks == TRUE &&
+ if ((NeedBreaks) &&
!(NtCurrentPeb()->NtGlobalFlag & FLG_ENABLE_SYSTEM_CRIT_BREAKS))
+ {
return STATUS_UNSUCCESSFUL;
+ }
+ /* Check if the caller wants the old value */
if (OldValue)
{
/* Query and return the old break on termination flag for the process */