fixed incorrect alignment specifications when probing

git-svn-id: svn://svn.code.sf.net/p/processhacker/code@3946 21ef857c-d57f-4fe0-8362-d861dc6d29cd
This commit is contained in:
wj32
2010-12-26 20:51:05 +00:00
parent 04d613cb7c
commit 558b25ad2b
6 changed files with 57 additions and 13 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
@echo off
build -cZ
build -cZ dirty
if not %errorlevel%==0 goto end
copy bin\i386\kprocesshacker.sys ..\bin\Release32\
copy bin\i386\kprocesshacker.pdb ..\bin\Release32\
Binary file not shown.
+5
View File
@@ -42,6 +42,11 @@ VOID KphDynamicImport(
PsIsProtectedProcess_I = KphGetSystemRoutineAddress(L"PsIsProtectedProcess");
PsResumeProcess_I = KphGetSystemRoutineAddress(L"PsResumeProcess");
PsSuspendProcess_I = KphGetSystemRoutineAddress(L"PsSuspendProcess");
dprintf("ObGetObjectType: 0x%Ix\n", ObGetObjectType_I);
dprintf("PsIsProtectedProcess: 0x%Ix\n", PsIsProtectedProcess_I);
dprintf("PsResumeProcess: 0x%Ix\n", PsResumeProcess_I);
dprintf("PsSuspendProcess: 0x%Ix\n", PsSuspendProcess_I);
}
/**
+13 -1
View File
@@ -1021,9 +1021,21 @@ NTSTATUS KpiSetInformationObject(
if (AccessMode != KernelMode)
{
ULONG alignment;
switch (ObjectInformationClass)
{
case KphObjectHandleFlagInformation:
alignment = sizeof(BOOLEAN);
break;
default:
alignment = sizeof(ULONG);
break;
}
__try
{
ProbeForRead(ObjectInformation, ObjectInformationLength, sizeof(ULONG));
ProbeForRead(ObjectInformation, ObjectInformationLength, alignment);
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
+38 -11
View File
@@ -515,9 +515,21 @@ NTSTATUS KpiQueryInformationProcess(
if (AccessMode != KernelMode)
{
ULONG alignment;
switch (ProcessInformationClass)
{
case KphProcessProtectionInformation:
alignment = sizeof(KPH_PROCESS_PROTECTION_INFORMATION);
break;
default:
alignment = sizeof(ULONG);
break;
}
__try
{
ProbeForWrite(ProcessInformation, ProcessInformationLength, sizeof(ULONG));
ProbeForWrite(ProcessInformation, ProcessInformationLength, alignment);
if (ReturnLength)
ProbeForWrite(ReturnLength, sizeof(ULONG), sizeof(ULONG));
@@ -561,21 +573,24 @@ NTSTATUS KpiQueryInformationProcess(
status = STATUS_NOT_SUPPORTED;
}
if (ProcessInformationLength == sizeof(KPH_PROCESS_PROTECTION_INFORMATION))
if (NT_SUCCESS(status))
{
__try
if (ProcessInformationLength == sizeof(KPH_PROCESS_PROTECTION_INFORMATION))
{
((PKPH_PROCESS_PROTECTION_INFORMATION)ProcessInformation)->IsProtectedProcess = protectedProcess;
__try
{
((PKPH_PROCESS_PROTECTION_INFORMATION)ProcessInformation)->IsProtectedProcess = protectedProcess;
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
status = GetExceptionCode();
}
}
__except (EXCEPTION_EXECUTE_HANDLER)
else
{
status = GetExceptionCode();
status = STATUS_INFO_LENGTH_MISMATCH;
}
}
else
{
status = STATUS_INFO_LENGTH_MISMATCH;
}
returnLength = sizeof(KPH_PROCESS_PROTECTION_INFORMATION);
}
@@ -679,9 +694,21 @@ NTSTATUS KpiSetInformationProcess(
if (AccessMode != KernelMode)
{
ULONG alignment;
switch (ProcessInformationClass)
{
case KphProcessProtectionInformation:
alignment = sizeof(KPH_PROCESS_PROTECTION_INFORMATION);
break;
default:
alignment = sizeof(ULONG);
break;
}
__try
{
ProbeForRead(ProcessInformation, ProcessInformationLength, sizeof(ULONG));
ProbeForRead(ProcessInformation, ProcessInformationLength, alignment);
}
__except (EXCEPTION_EXECUTE_HANDLER)
{