Something went wrong. Try again.
Reactos
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178/* * PROJECT: ReactOS kernel-mode tests * LICENSE: GPLv2+ - See COPYING in the top level directory * PURPOSE: Kernel-Mode Test Suite Process Notification Routines test * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org> */
#include <kmt_test.h>
//#define NDEBUG#include <debug.h>
staticVOIDNTAPICreateProcessNotifyRoutine( IN HANDLE ParentId, IN HANDLE ProcessId, IN BOOLEAN Create){ ok_irql(PASSIVE_LEVEL); if (!Create) ok_eq_pointer(ProcessId, PsGetCurrentProcessId()); else ok(ProcessId != PsGetCurrentProcessId(), "ProcessId %p equals current\n", ProcessId); DPRINT("%s(%p, %p, %d)\n", __FUNCTION__, ParentId, ProcessId, Create);}
staticVOIDTestCreateProcessNotify(VOID){ NTSTATUS Status;
Status = PsSetCreateProcessNotifyRoutine(NULL, TRUE); ok_eq_hex(Status, STATUS_PROCEDURE_NOT_FOUND);
Status = PsSetCreateProcessNotifyRoutine(NULL, FALSE); ok_eq_hex(Status, STATUS_SUCCESS);
Status = PsSetCreateProcessNotifyRoutine(NULL, TRUE); ok_eq_hex(Status, STATUS_SUCCESS);
Status = PsSetCreateProcessNotifyRoutine(NULL, TRUE); ok_eq_hex(Status, STATUS_PROCEDURE_NOT_FOUND);
Status = PsSetCreateProcessNotifyRoutine(CreateProcessNotifyRoutine, TRUE); ok_eq_hex(Status, STATUS_PROCEDURE_NOT_FOUND);
Status = PsSetCreateProcessNotifyRoutine(CreateProcessNotifyRoutine, FALSE); ok_eq_hex(Status, STATUS_SUCCESS);
/* TODO: test whether the callback is notified on process creation */
Status = PsSetCreateProcessNotifyRoutine(CreateProcessNotifyRoutine, TRUE); ok_eq_hex(Status, STATUS_SUCCESS);
Status = PsSetCreateProcessNotifyRoutine(CreateProcessNotifyRoutine, TRUE); ok_eq_hex(Status, STATUS_PROCEDURE_NOT_FOUND);
/* TODO: register the same routine twice */ /* TODO: register more than the maximum number of notifications */}
staticVOIDNTAPICreateThreadNotifyRoutine( IN HANDLE ProcessId, IN HANDLE ThreadId, IN BOOLEAN Create){ ok_irql(PASSIVE_LEVEL); if (!Create) { ok_eq_pointer(ProcessId, PsGetCurrentProcessId()); ok_eq_pointer(ThreadId, PsGetCurrentThreadId()); } else { ok(ThreadId != PsGetCurrentThreadId(), "ThreadId %p equals current\n", ThreadId); } DPRINT("%s(%p, %p, %d)\n", __FUNCTION__, ProcessId, ThreadId, Create);}
staticVOIDTestCreateThreadNotify(VOID){ NTSTATUS Status;
Status = PsRemoveCreateThreadNotifyRoutine(NULL); ok_eq_hex(Status, STATUS_PROCEDURE_NOT_FOUND);
Status = PsSetCreateThreadNotifyRoutine(NULL); ok_eq_hex(Status, STATUS_SUCCESS);
Status = PsRemoveCreateThreadNotifyRoutine(NULL); ok_eq_hex(Status, STATUS_SUCCESS);
Status = PsRemoveCreateThreadNotifyRoutine(NULL); ok_eq_hex(Status, STATUS_PROCEDURE_NOT_FOUND);
Status = PsRemoveCreateThreadNotifyRoutine(CreateThreadNotifyRoutine); ok_eq_hex(Status, STATUS_PROCEDURE_NOT_FOUND);
Status = PsSetCreateThreadNotifyRoutine(CreateThreadNotifyRoutine); ok_eq_hex(Status, STATUS_SUCCESS);
/* TODO: test whether the callback is notified on thread creation */
Status = PsRemoveCreateThreadNotifyRoutine(CreateThreadNotifyRoutine); ok_eq_hex(Status, STATUS_SUCCESS);
Status = PsRemoveCreateThreadNotifyRoutine(CreateThreadNotifyRoutine); ok_eq_hex(Status, STATUS_PROCEDURE_NOT_FOUND);
/* TODO: register the same routine twice */ /* TODO: register more than the maximum number of notifications */}
staticVOIDNTAPILoadImageNotifyRoutine( IN PUNICODE_STRING FullImageName OPTIONAL, IN HANDLE ProcessId, IN PIMAGE_INFO ImageInfo){ ok_irql(PASSIVE_LEVEL); DPRINT("%s('%wZ', %p, %p)\n", __FUNCTION__, FullImageName, ProcessId, ImageInfo);}
staticVOIDTestLoadImageNotify(VOID){ NTSTATUS Status;
Status = PsRemoveLoadImageNotifyRoutine(NULL); ok_eq_hex(Status, STATUS_PROCEDURE_NOT_FOUND);
Status = PsSetLoadImageNotifyRoutine(NULL); ok_eq_hex(Status, STATUS_SUCCESS);
Status = PsRemoveLoadImageNotifyRoutine(NULL); ok_eq_hex(Status, STATUS_SUCCESS);
Status = PsRemoveLoadImageNotifyRoutine(NULL); ok_eq_hex(Status, STATUS_PROCEDURE_NOT_FOUND);
Status = PsRemoveLoadImageNotifyRoutine(LoadImageNotifyRoutine); ok_eq_hex(Status, STATUS_PROCEDURE_NOT_FOUND);
Status = PsSetLoadImageNotifyRoutine(LoadImageNotifyRoutine); ok_eq_hex(Status, STATUS_SUCCESS);
/* TODO: test whether the callback is notified on image load */
Status = PsRemoveLoadImageNotifyRoutine(LoadImageNotifyRoutine); ok_eq_hex(Status, STATUS_SUCCESS);
Status = PsRemoveLoadImageNotifyRoutine(LoadImageNotifyRoutine); ok_eq_hex(Status, STATUS_PROCEDURE_NOT_FOUND);
/* TODO: register the same routine twice */ /* TODO: register more than the maximum number of notifications */}
START_TEST(PsNotify){ TestCreateProcessNotify(); TestCreateThreadNotify(); TestLoadImageNotify();}