Hi,
I am very new to driver developement.
I am soppose to read a registry value through the driver.
the key:seed and value:0x2348b231.(REG_SZ)
I have written the code to read the registry value but it is printing only a single character.
can anyone help me in reading the entire value.
Here is the code.It wouldbe fine if you can add the code to read the entire value.
This code has some irrelevant declarions which are not used and can be ignored
Naveen
#include <ntddk.h>
#define CMI_DEVICE_PATH L"\Registry\Machine\Software\bmc\wDsc\configuration\PROM"
#define MAX_CMI_DEVICE_NAME_LENGTH 50
typedef struct DEV_EXT
{
UNICODE_STRING SymLink;
void *pBuff;
ULONG BuffSize;
}DEV_EXT;
TopOfNTMemory()
{
NTSTATUS status;
OBJECT_ATTRIBUTES obj;
HANDLE key;
ULONG size, i, j, temp;
UNICODE_STRING name, value;
WCHAR string[20] = L"Seed";
PCM_RESOURCE_LIST resList;
PKEY_VALUE_PARTIAL_INFORMATION keyData,vpip;
ULONG PhysMemTop = 0;
size=0;
RtlInitUnicodeString(&name,L"\Registry\Machine\Software\bmc\wDsc\configuration\PROM");
DbgPrint(“Hello inside function\n”);
InitializeObjectAttributes(&obj, &name, OBJ_CASE_INSENSITIVE, NULL, NULL);
RtlInitUnicodeString(&value, string);
status = ZwOpenKey(&key, KEY_QUERY_VALUE, &obj);
if (NT_SUCCESS(status))
{
DbgPrint(“Hello driver sucess\n”);
status = ZwQueryValueKey(key, &value, KeyValuePartialInformation, NULL, 0, &size);
if ( size == 0)
{
DbgPrint(“ZwQueryValueKey 1 failed\n”);
}
vpip = (PKEY_VALUE_PARTIAL_INFORMATION)ExAllocatePool(PagedPool, size);
if (!vpip)
{
DbgPrint(“vpip 1 failed\n”);
}
status = ZwQueryValueKey(key, &value, KeyValuePartialInformation,vpip, size, &size);
if (!NT_SUCCESS(status))
{
DbgPrint(“ZWquery failed 2 failed\n”);
}
resList = (PCM_RESOURCE_LIST)vpip->Data;
DbgPrint(“value %s\n”,vpip->Data);
ExFreePool(vpip);
(VOID)ZwClose(key);
}
if (!NT_SUCCESS(status))
{
DbgPrint(“Hello driver ntfs\n”);
}
}
void myUnload(PDRIVER_OBJECT pDrvObj)
{
DbgPrint(“Hello driver unload\n”);
}
NTSTATUS DriverEntry(PDRIVER_OBJECT pDrvObj, PUNICODE_STRING pStr)
{
ULONG ulStopDataTransmissionOnSuspend ;
BOOLEAN fOptionDetermined = FALSE;
ANSI_STRING Ansi;
NTSTATUS status;
UNICODE_STRING DevName;
UNICODE_STRING SymLink;
PDEVICE_OBJECT pDevObj;
DEV_EXT *pe;
PVOID handle;
PVOID buffer;
UNICODE_STRING gRegistryPath;
RTL_QUERY_REGISTRY_TABLE QueryTable[10];
RtlInitUnicodeString(&gRegistryPath,CMI_DEVICE_PATH);
RtlInitUnicodeString(&DevName, L"\device\myDev");
RtlInitUnicodeString(&SymLink, L"\??\mySymLink");
DbgPrint(“Hello new driver\n”);
TopOfNTMemory();
RtlUnicodeStringToAnsiString(&Ansi, pStr, TRUE);
DbgPrint(“Driver Path : %s”, Ansi.Buffer);
RtlFreeAnsiString(&Ansi);
pDrvObj->DriverUnload = myUnload;
return STATUS_SUCCESS;
}</ntddk.h>