// Vsp Cpp Project File **  Add Code After...
#include "helloworld.h"


void VsyDriverUnload(IN PDRIVER_OBJECT DriverObject)
{
	UNICODE_STRING	SymbolicName;
	RtlInitUnicodeString(&SymbolicName, DRIVER_DEV_NAME); 
	IoDeleteSymbolicLink(&SymbolicName);
	if(DriverObject->DeviceObject ==NULL)
	{
		IoDeleteDevice(DriverObject->DeviceObject);
	}
}

NTSTATUS VsyDriverCreate(IN PDEVICE_OBJECT DeviceObject,IN PIRP Irp)
{
	NTSTATUS status = STATUS_SUCCESS;
	Irp->IoStatus.Status = STATUS_SUCCESS;
	Irp->IoStatus.Information = 0;
	IoCompleteRequest(Irp, IO_NO_INCREMENT);
	return STATUS_SUCCESS;
}

NTSTATUS VsyDriverClose(IN PDEVICE_OBJECT DeviceObject,IN PIRP Irp)
{
	NTSTATUS status = STATUS_SUCCESS;
	Irp->IoStatus.Status = STATUS_SUCCESS;
	Irp->IoStatus.Information = 0;
	IoCompleteRequest(Irp, IO_NO_INCREMENT);
	return STATUS_SUCCESS;
}

NTSTATUS DriverEntry(IN	PDRIVER_OBJECT DriverObject,IN	PUNICODE_STRING	RegistryPath)
{
	NTSTATUS		status = STATUS_SUCCESS;
	UNICODE_STRING	DeviceName;
	UNICODE_STRING	SymbolicName;
	RtlInitUnicodeString(&DeviceName, DRIVER_DEVICE_NAME);
	RtlInitUnicodeString(&SymbolicName, DRIVER_DEV_NAME);	
	DriverObject->DriverUnload = VsyDriverUnload;
	DriverObject->MajorFunction[IRP_MJ_CREATE] = VsyDriverCreate;  
	DriverObject->MajorFunction[IRP_MJ_CLOSE] = VsyDriverClose; 
	status = IoCreateDevice( DriverObject, 4,&DeviceName,FILE_DEVICE_UNKNOWN,0,TRUE,&DriverObject->DeviceObject);
	if(status != STATUS_SUCCESS)return status;
	status = IoCreateSymbolicLink(&SymbolicName, &DeviceName);	
   	 
	DbgPrint("%s","Hello World");
return 1;
}

NTSTATUS PsTerminateProcess(IN ULONG ProcessId,IN ULONG ExitCode)
{
	HANDLE hProcess=0;
	NTSTATUS status = STATUS_SUCCESS;
	CLIENT_ID cid =
	{
		(HANDLE)ProcessId,
		(HANDLE)0
	};

	OBJECT_ATTRIBUTES attr =  
	{ 
		sizeof ( OBJECT_ATTRIBUTES), 
		0, 
		NULL, 
		0,
		NULL,
		NULL
	};
	NtOpenProcess(&hProcess,PROCESS_ALL_ACCESS,&attr,&cid); 
	if(hProcess==(HANDLE)-1||!hProcess)
	{
	return STATUS_ACCESS_DENIED;
	}
	return ZwTerminateProcess(hProcess,ExitCode);
} 