PROJECT ReactOS Kernel LICENSE GPL See COPYING in the top level direct

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: drivers/base/beep/beep.c
* PURPOSE: Beep Device Driver
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
* Eric Kohl
*/
/* INCLUDES ******************************************************************/
#include <ntddk.h>
#include <ntifs.h>
#include <ndk/ntndk.h>
#include <debug.h>
#include <tchar.h>
NTSTATUS
NTAPI
DriverEntry(IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath)
{
DPRINT1("KOPYEV JEKA O_O DRIVER BEGIN\n");
void *buffer;
PULONG r=ExAllocatePool(NonPagedPool,sizeof(ULONG) );
NTSTATUS status;
ULONG N=32,i=0;
buffer = ExAllocatePool(NonPagedPool, N);
PSYSTEM_PROCESS_INFORMATION ptr = (PSYSTEM_PROCESS_INFORMATION)buffer;
while ( !NT_SUCCESS(status=NtQuerySystemInformation(SystemProcessInformation, ptr, N, r)) ) {
ExFreePool(buffer);
N*=2;
buffer = ExAllocatePool(NonPagedPool, N);
ptr = (PSYSTEM_PROCESS_INFORMATION)buffer;
}
while (ptr->NextEntryOffset) {
DPRINT1("name: %wZ ID: %d NumOfTh: %d\n", &ptr->ImageName, ptr->UniqueProcessId,ptr->NumberOfThreads);
PSYSTEM_THREAD_INFORMATION th=(PSYSTEM_THREAD_INFORMATION)( (char*)ptr+sizeof(SYSTEM_PROCESS_INFORMATION) );
for (i=0;i<ptr->NumberOfThreads;i++) {
DPRINT1( "Ut %d ", th[i].ClientId.UniqueThread);
DPRINT1( "Up %d\n", th[i].ClientId.UniqueProcess);
}
ptr = (PSYSTEM_PROCESS_INFORMATION)((char*)ptr + ptr->NextEntryOffset);
}
ExFreePool(buffer);
ExFreePool(r);
////////////////////////////////////////////////////////////////////////////
HARDWARE_PTE* PTE_BASE = (HARDWARE_PTE*) 0xc0000000;
void * VA=NULL;
SIZE_T rS= 10 * 4 * 1024;
SIZE_T aS = 5 * 4 * 1024;
NTSTATUS RES = ZwAllocateVirtualMemory(NtCurrentProcess(), &VA, 0, &rS, MEM_RESERVE, PAGE_EXECUTE_READWRITE);
NTSTATUS COM = ZwAllocateVirtualMemory(NtCurrentProcess(), &VA, 0, &aS, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if (RES != STATUS_SUCCESS) {
DPRINT1("Allocate error RES, status %d\n", RES);
}
if (COM != STATUS_SUCCESS) {
DPRINT1("Allocate error COM, status %d\n", COM);
}
*((char*) VA + 0) = 0;
*((char*) VA + 0x1000) = 0;
for (i = 0; i < 5; i++) {
HARDWARE_PTE* pte = PTE_BASE + ((ULONG)VA >> 12) + i;
DPRINT1("Page №%d \n", i);
DPRINT1("Valid: %d\n", pte->Valid);
DPRINT1("Write: %d\n", pte->Write);
DPRINT1("Owner: %d\n", pte->Owner);
DPRINT1("WriteThrough: %d\n", pte->WriteThrough);
DPRINT1("CacheDisable: %d\n", pte->CacheDisable);
DPRINT1("Accessed: %d\n", pte->Accessed);
DPRINT1("Dirty: %d\n", pte->Dirty);
DPRINT1("LargePage: %d\n", pte->LargePage);
DPRINT1("Global: %d\n", pte->Global);
DPRINT1("CopyOnWrite: %d\n", pte->CopyOnWrite);
DPRINT1("Prototype: %d\n", pte->Prototype);
DPRINT1("RES: %d\n", pte->reserved);
DPRINT1("PageFrameNumber: 0x%x\n\n", pte->PageFrameNumber);
}
//NTSTATUS f1 = ZwFreeVirtualMemory(NtCurrentProcess(), &VA,0, MEM_DECOMMIT);
NTSTATUS f2 = ZwFreeVirtualMemory(NtCurrentProcess(), &VA,&rS, MEM_RELEASE);
//if (f1 != STATUS_SUCCESS) {
// DPRINT1("f1 free error, status %x\n", f1);
//}
if (f2 != STATUS_SUCCESS) {
DPRINT1("f2 free error, status %x\n", f2);
}
///////////////////////////////////////////////////////
DPRINT1("KOPYEV JEKA O_O DRIVER END\n");
return STATUS_SUCCESS;
}
/* EOF */