ULONG State;
/* Typecast the Object */
- Profile = (PEPROFILE)ObjectBody;
+ Profile = ObjectBody;
/* Check if there if the Profile was started */
if (Profile->LockedBufferAddress)
MmUnmapLockedPages(Profile->LockedBufferAddress, Profile->Mdl);
MmUnlockPages(Profile->Mdl);
IoFreeMdl(Profile->Mdl);
+ ExFreePoolWithTag(Profile->ProfileObject, TAG_PROFILE);
}
/* Check if a Process is associated and reference it */
NtCreateProfile(OUT PHANDLE ProfileHandle,
IN HANDLE Process OPTIONAL,
IN PVOID RangeBase,
- IN ULONG RangeSize,
+ IN SIZE_T RangeSize,
IN ULONG BucketSize,
IN PVOID Buffer,
IN ULONG BufferSize,
0,
NULL,
&hProfile);
- ObDereferenceObject(Profile);
/* Check for Success */
if (!NT_SUCCESS(Status))
/* Allocate a Kernel Profile Object. */
ProfileObject = ExAllocatePoolWithTag(NonPagedPool,
- sizeof(EPROFILE),
+ sizeof(*ProfileObject),
TAG_PROFILE);
if (!ProfileObject)
{
/* Initialize the Kernel Profile Object */
Profile->ProfileObject = ProfileObject;
KeInitializeProfile(ProfileObject,
- (PKPROCESS)Profile->Process,
+ &Profile->Process->Pcb,
Profile->RangeBase,
Profile->RangeSize,
Profile->BucketSize,
/* Unlock the Buffer */
MmUnmapLockedPages(Profile->LockedBufferAddress, Profile->Mdl);
MmUnlockPages(Profile->Mdl);
+ IoFreeMdl(Profile->Mdl);
ExFreePoolWithTag(Profile->ProfileObject, TAG_PROFILE);
/* Clear the Locked Buffer pointer, meaning the Object is Stopped */