ReactOS 0.4.15-dev-7924-g5949c20
memtest.c
Go to the documentation of this file.
1/*
2 * Memory Manager Information and Test driver
3 *
4 * Copyright 2006 Aleksey Bragin <alekset@reactos.org>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; see the file COPYING.LIB.
18 * If not, write to the Free Software Foundation,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22/* INCLUDES *******************************************************************/
23
24#include <ddk/ntddk.h>
25#include "memtest.h"
26
27//#define NDEBUG
28#include <debug.h>
29
31
32/* FUNCTIONS ***********************************************************/
33
34static VOID NTAPI
36{
37 SYSTEM_PERFORMANCE_INFORMATION PerformanceInfo;
39 LARGE_INTEGER Interval, SystemTime;
40
41 /* Main loop */
42 while (TRUE)
43 {
44 Interval.QuadPart = -300 * 10000; // 300 ms
45
46 /* Query information */
48 (PVOID) &PerformanceInfo,
51 {
52 break;
53 }
54
55 /* Query current system time */
56 KeQuerySystemTime(&SystemTime);
57
58
59 DbgPrint("%I64d;%d;%d\n", SystemTime.QuadPart,
60 PerformanceInfo.CommittedPages, PerformanceInfo.AvailablePages);
61
62 /* Wait for a bit. */
64 }
65
66 DPRINT("Finishing monitoring thread.\n");
67
69}
70
71
72VOID
74{
76
80 NULL,
81 NULL,
82 NULL,
84 NULL);
85
86 if (!NT_SUCCESS(Status))
87 {
88 DPRINT1("Failed to start a monitoring thread\n");
89 return;
90 }
91}
92
93/* PUBLIC FUNCTIONS ***********************************************************/
94
95/*
96 * DriverEntry
97 */
102{
103 DbgPrint("\n===============================================\n Memory Manager Information and Test driver\n");
104 DbgPrint("Time;Memory pages allocated;Memory pages free\n");
105
106
108
109 return STATUS_SUCCESS;
110}
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
DRIVER_INITIALIZE DriverEntry
Definition: condrv.c:21
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
#define KeDelayExecutionThread(mode, foo, t)
Definition: env_spec_w32.h:484
NTSYSAPI NTSTATUS NTAPI ZwQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
Status
Definition: gdiplustypes.h:25
#define DbgPrint
Definition: hal.h:12
static VOID NTAPI MonitorThread(PVOID Ignored)
Definition: memtest.c:35
VOID StartMemoryMonitor()
Definition: memtest.c:73
HANDLE MonitorThreadHandle
Definition: memtest.c:30
#define SystemPerformanceInformation
Definition: memtest.h:87
#define KernelMode
Definition: asm.h:34
DWORD Interval
Definition: netstat.c:30
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1339
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
NTSTATUS NTAPI PsTerminateSystemThread(IN NTSTATUS ExitStatus)
Definition: kill.c:1145
NTSTATUS NTAPI PsCreateSystemThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN HANDLE ProcessHandle, IN PCLIENT_ID ClientId, IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext)
Definition: thread.c:602
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
#define NTAPI
Definition: typedefs.h:36
uint32_t ULONG
Definition: typedefs.h:59
LONGLONG QuadPart
Definition: typedefs.h:114
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213