Search code examples
registrynullreferenceexceptionkmdf

why Kernel Driver can not update registry value when it throw an exception?


This a test KMDF project. it's function is read and write registry.

Case1:

1.read a registry value and write a value to registry

2.Check registry in windows, value updated.

Case2:

1.read a registry value and write a value to registry, add exception at end. BSOD happens when boot windows

2.remove exception, boot windows, check registry, value is not updated.

These are the exception code i use.

    void GoException()
    {
    PDRIVER_OBJECT obj = NULL;
    obj->DeviceObject->CurrentIrp = NULL;
    }

I have try two registry path.

HKEY_LOCAL_MACHINE\SOFTWARE\DELL\test (normal path)

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TEST (service path)


Solution

  • the reason why registry key can not updated, it need to get to a certain point to save changes in boot. Exception in one driver, it may not saved.