I have been using the RtlQueryRegistryValues function to read REG_DWORD
values from the registry. Now I need to read a REG_EXPAND_SZ value. I
reviewed the DDK documentation (the online version) and I believe I have set
the RTL_QUERY_REGISTRY_TABLE up correctly.
paramTable[3].Flags = RTL_QUERY_REGISTRY_DIRECT;
paramTable[3].Name = L"FPGAFileName";
paramTable[3].EntryContext = fpgaFileName; // Pointer to UNICODE_STRING
paramTable[3].DefaultType = REG_EXPAND_SZ;
paramTable[3].DefaultData = L"";
paramTable[3].DefaultLength = 0;
This is the last entry in the paramTable. The values at paramTable[4] are
all zero’ed.
If the REG_EXPAND_SZ value does not contain any environment variables
everything works fine. RtlQueryRegistryValues returns the string in my
supplied unicode buffer (fpgaFileName). However, if the registry value
contains an environment varialbe (%SystemRoot% for example) I get the blue
screen below.
The problem appears that RtlQueryEnvironmentVariable_U is either not loaded
in memory or has the wrong address. I verified that I am running at IRQL
Passive Level.
Does anyone have any ideas what I might be doing wrong?
- Steve -
0: kd> !analyze -v
****************************************************************************
***
*
*
* Bugcheck Analysis
*
*
*
****************************************************************************
***
PAGE_FAULT_IN_NONPAGED_AREA (50)
Invalid system memory was referenced. This cannot be protected by
try-except,
it must be protected by a Probe. Typically the address is just plain bad or
it
is pointing at freed memory.
Arguments:
Arg1: 80681cb4, memory referenced.
Arg2: 00000000, value 0 = read operation, 1 = write operation.
Arg3: 80681cb4, If non-zero, the instruction address which referenced the
bad memory
address.
Arg4: 00000000, (reserved)
Debugging Details:
READ_ADDRESS: 80681cb4
FAULTING_IP:
nt!RtlQueryEnvironmentVariable_U+0
80681cb4 ?? ???
MM_INTERNAL_CODE: 0
DEFAULT_BUCKET_ID: DRIVER_FAULT
BUGCHECK_STR: 0x50
LAST_CONTROL_TRANSFER: from 804f428c to 8051d4b0
STACK_TEXT:
fc9172fc 804f428c 00000003 804d4000 80681cb4
nt!RtlpBreakWithStatusInstruction
fc917348 804f4d11 00000003 806bb8cc c0201a04 nt!KiBugCheckDebugBreak+0x19
fc917714 804f52af 00000050 80681cb4 00000000 nt!KeBugCheck2+0x46d
fc917734 8051445e 00000050 80681cb4 00000000 nt!KeBugCheckEx+0x19
fc917784 80532fa8 00000000 80681cb4 00000000 nt!MmAccessFault+0x758
fc917784 80681cb4 00000000 80681cb4 00000000 nt!KiTrap0E+0xbc
fc91780c 805c5f92 00000000 fc917834 fc91782c
nt!RtlQueryEnvironmentVariable_U
fc91784c 805c66de 00000000 00000082 fc917878
nt!RtlExpandEnvironmentStrings_U+0xb6
fc917890 805c6ade fc917970 e1dc2604 fc9178f0
nt!RtlpCallQueryRegistryRoutine+0x2db
fc9178f4 f772965d 00000000 00000084 00000001 nt!RtlQueryRegistryValues+0x2a4
fc9179c4 f77255dd 00000064 f7730018 81255e40
fg8000!cfFg8000GetDeviceParamsFromRegistry+0x17b [c:/fg8000/entrycom.c @
494]
fc9179f4 804f2a40 ff9de2d0 81255e40 00000000 fg8000!cfFg8000AddDevice+0xdf
[c:/fg8000/pnp.c @ 166]
fc917a10 80574afe f77254fe 00000004 00000001 nt!PpvUtilCallAddDevice+0x2c
fc917ad8 80575d29 00000000 02000001 00000000 nt!PipCallDriverAddDevice+0x374
fc917d24 8057620e 81255738 00000001 00000000 nt!PipProcessDevNodeTree+0x147
fc917d54 804f2120 00000003 805482c0 8054d0dc nt!PiRestartDevice+0x7e
fc917d7c 80528267 00000000 00000000 81275b30 nt!PipDeviceActionWorker+0x15a
fc917dac 805b046c 00000000 00000000 00000000 nt!ExpWorkerThread+0xed
fc917ddc 80534ad6 8052817a 00000001 00000000 nt!PspSystemThreadStartup+0x34
00000000 00000000 00000000 00000000 00000000 nt!KiThreadStartup+0x16
FAILED_INSTRUCTION_ADDRESS:
nt!RtlQueryEnvironmentVariable_U+0
80681cb4 ?? ???
FOLLOWUP_IP:
fg8000!cfFg8000GetDeviceParamsFromRegistry+17b
f772965d ff75f4 push dword ptr [ebp-0xc]
FOLLOWUP_NAME: MachineOwner
SYMBOL_NAME: fg8000!cfFg8000GetDeviceParamsFromRegistry+17b
MODULE_NAME: fg8000
IMAGE_NAME: fg8000.sys
DEBUG_FLR_IMAGE_TIMESTAMP: 3ea5d39a
STACK_COMMAND: kb
BUCKET_ID:
0x50_CODE_AV_BAD_IP_fg8000!cfFg8000GetDeviceParamsFromRegistry+17b