本文整理汇总了C++中RtlAppendUnicodeToString函数的典型用法代码示例。如果您正苦于以下问题:C++ RtlAppendUnicodeToString函数的具体用法?C++ RtlAppendUnicodeToString怎么用?C++ RtlAppendUnicodeToString使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RtlAppendUnicodeToString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CdfsCreateFCB
PFCB
CdfsCreateFCB(PCWSTR FileName)
{
PFCB Fcb;
Fcb = ExAllocatePoolWithTag(NonPagedPool, sizeof(FCB), TAG_FCB);
if(!Fcb) return NULL;
RtlZeroMemory(Fcb, sizeof(FCB));
RtlInitEmptyUnicodeString(&Fcb->PathName, Fcb->PathNameBuffer, sizeof(Fcb->PathNameBuffer));
if (FileName)
{
RtlAppendUnicodeToString(&Fcb->PathName, FileName);
if (wcsrchr(Fcb->PathName.Buffer, '\\') != 0)
{
Fcb->ObjectName = wcsrchr(Fcb->PathName.Buffer, '\\');
}
else
{
Fcb->ObjectName = Fcb->PathName.Buffer;
}
}
ExInitializeResourceLite(&Fcb->PagingIoResource);
ExInitializeResourceLite(&Fcb->MainResource);
ExInitializeResourceLite(&Fcb->NameListResource);
Fcb->RFCB.PagingIoResource = &Fcb->PagingIoResource;
Fcb->RFCB.Resource = &Fcb->MainResource;
Fcb->RFCB.IsFastIoPossible = FastIoIsNotPossible;
InitializeListHead(&Fcb->ShortNameList);
return(Fcb);
}
示例2: SmpInvokeAutoChk
NTSTATUS
NTAPI
SmpInvokeAutoChk(IN PUNICODE_STRING FileName,
IN PUNICODE_STRING Directory,
IN PUNICODE_STRING Arguments,
IN ULONG Flags)
{
ANSI_STRING MessageString;
CHAR MessageBuffer[256];
UNICODE_STRING Destination;
WCHAR Buffer[1024];
BOOLEAN BootState, BootOkay, ShutdownOkay;
/* Check if autochk should show dots (if the user booted with /SOS) */
if (SmpQueryRegistrySosOption()) SmpEnableDots = FALSE;
/* Make sure autochk was actually found */
if (Flags & SMP_INVALID_PATH)
{
/* It wasn't, so create an error message to print on the screen */
sprintf_nt(MessageBuffer,
"%wZ program not found - skipping AUTOCHECK\r\n",
FileName);
RtlInitAnsiString(&MessageString, MessageBuffer);
if (NT_SUCCESS(RtlAnsiStringToUnicodeString(&Destination,
&MessageString,
TRUE)))
{
/* And show it */
NtDisplayString(&Destination);
RtlFreeUnicodeString(&Destination);
}
}
else
{
/* Autochk is there, so record the BSD state */
BootState = SmpSaveAndClearBootStatusData(&BootOkay, &ShutdownOkay);
/* Build the path to autochk and place its arguments */
RtlInitEmptyUnicodeString(&Destination, Buffer, sizeof(Buffer));
RtlAppendUnicodeStringToString(&Destination, FileName);
RtlAppendUnicodeToString(&Destination, L" ");
RtlAppendUnicodeStringToString(&Destination, Arguments);
/* Execute it */
SmpExecuteImage(FileName,
Directory,
&Destination,
0,
Flags & ~SMP_AUTOCHK_FLAG,
NULL);
/* Restore the BSD state */
if (BootState) SmpRestoreBootStatusData(BootOkay, ShutdownOkay);
}
/* We're all done! */
return STATUS_SUCCESS;
}
示例3: myAddDevice
//
// 实现我们自己的AddDevice函数
//
NTSTATUS myAddDevice(
IN PDRIVER_OBJECT DriverObject,
IN PDEVICE_OBJECT PhysicalDeviceObject
)
{
if(gDeviceObject != NULL)
{
// 在这里面创建我们自己的设备对象,或者申请所需要的资源。
// 为了区分不同实例,将设备对象名构造成:”MyNdisDevice”+HardwareID。
UNICODE_STRING nameString;
WCHAR wcsName[256];
UNICODE_STRING preName = RTL_CONSTANT_STRING(L"\\Device\\MyNdisDevice");
// 首先取得设备的HDID。
ULONG nameLength = 0;
WCHAR wcsHardwareID[256]; //足够大了
NTSTATUS status = IoGetDeviceProperty (PhysicalDeviceObject,
DevicePropertyHardwareID,
256,
wcsHardwareID,
&nameLength);
if(status != STATUS_SUCCESS){
KdPrint(("Failed to get hardware ID %x\n", status));
return status;
}
// 下面构造设备对象的名字,根据上面的规则:“MyNdisDevice”+ HardwareID。
RtlInitEmptyUnicodeString( &nameString, wcsName, 256*2);
RtlCopyUnicodeString( &nameString, &preName);
//RtlUnicodeStringPrintf(&nameString, L"%wZ_%d_", &preName, 0);
RtlAppendUnicodeToString( &nameString, wcsHardwareID);
status = IoCreateDevice(DriverObject,
0,
&nameString,
FILE_DEVICE_UNKNOWN,
FILE_DEVICE_SECURE_OPEN,
FALSE,
&gDeviceObject);
// 如果创建失败了,我们有权利让函数以失败返回
// 但这样我们的驱动加载也就失败了
if(status != STATUS_SUCCESS){
KdPrint(("Failed to create device %ws\n", nameString));
return status;
}
}
//ExAllocatePoolWithTag(); //申请资源及其他
//
// 还可以加入其他正确的操作
//
// 现在调用保存的Ndis库中的AddDevice实现
// 千万不要忘记,否则就会大错特错了
return systemAddDevice(DriverObject, PhysicalDeviceObject);
}
示例4: MyDLPKBF_CreateDevice
NTSTATUS
MyDLPKBF_CreateDevice (IN PDRIVER_OBJECT pDriverObject,
IN ULONG DeviceNumber)
{
PDEVICE_OBJECT pDevObj;
UNICODE_STRING uniNtDeviceName, uniDosDeviceName, uniNumber;
WCHAR ntDeviceNameBuffer[MYDLP_MAX_NAME_LENGTH];
WCHAR dosDeviceNameBuffer[MYDLP_MAX_NAME_LENGTH];
WCHAR numberBuffer[2];
PMYDLPKBF_DEVICE_EXTENSION pDevExt;
NTSTATUS status;
DbgPrint("MyDLPKBF_CreateDevice: Start\n");
status = STATUS_SUCCESS;
uniNtDeviceName.Buffer = ntDeviceNameBuffer;
uniNtDeviceName.MaximumLength = MYDLP_MAX_NAME_LENGTH * 2;
uniNtDeviceName.Length = 0;
uniDosDeviceName.Buffer = dosDeviceNameBuffer;
uniDosDeviceName.MaximumLength = MYDLP_MAX_NAME_LENGTH * 2;
uniDosDeviceName.Length = 0;
uniNumber.Buffer = numberBuffer;
uniNumber.MaximumLength = 4;
uniNumber.Length = 0;
RtlIntegerToUnicodeString( DeviceNumber, 10, &uniNumber);
RtlAppendUnicodeToString( &uniNtDeviceName, NT_DEVICE_NAME);
RtlAppendUnicodeStringToString( &uniNtDeviceName, &uniNumber);
RtlAppendUnicodeToString( &uniDosDeviceName, DOS_DEVICE_NAME);
RtlAppendUnicodeStringToString( &uniDosDeviceName, &uniNumber);
status = IoCreateDevice(pDriverObject, sizeof(MYDLPKBF_DEVICE_EXTENSION),
&uniNtDeviceName, FILE_DEVICE_UNKNOWN,
0,
TRUE,
&pDevObj);
if(!NT_SUCCESS(status))
{
DbgPrint("MyDLPKBF_CreateDevice: IoCreateDevice failed\
device no:%d\n", DeviceNumber);
return status;
}
示例5: NT_ConcatUnicodeStrings
/****************************************************************************\
*
* NT_ConcatUnicodeStrings()
*
* DESCRIPTION:
*
* This routine concatenates two NULL terminated strings and returns
* the result as an allocated UNICODE string.
*
* ARGUMENTS:
*
* s1, s2 - strings to concatenate
* MaxLength - max length of the UNICODE string. If 0, then max length of
* the allocated string equals the length of the concatenated
* string.
*
* RETURN VALUE:
*
* Pointer to the allocated string, NULL if the allocation failed
*
\****************************************************************************/
PUNICODE_STRING
NT_ConcatUnicodeStrings( IN PWSTR s1, IN PWSTR s2, IN USHORT MaxLength )
{
PUNICODE_STRING String;
size_t ActualMaxLength = (wcslen(s1) + wcslen(s2) + 1);
ASSERT( (MaxLength > ActualMaxLength) || MaxLength == 0 );
if ( MaxLength > ActualMaxLength ) ActualMaxLength = MaxLength;
String = NT_AllocUnicodeString( (USHORT)ActualMaxLength );
if ( String ) {
/* RtlAppendUnicodeToString must not fail here if we have correctly
* calculated the required size. */
NTSTATUS Status = RtlAppendUnicodeToString( String, s1 );
ASSERT( Status == STATUS_SUCCESS );
Status = RtlAppendUnicodeToString( String, s2 );
ASSERT( Status == STATUS_SUCCESS );
}
return (String);
}
示例6: XenM2BPdoQueryDeviceText
static NTSTATUS
XenM2BPdoQueryDeviceText(PXENM2B_PDO_EXTENSION pPdoExt,
PIRP pIrp)
{
PIO_STACK_LOCATION pIrpStack;
PVOID pBuffer;
UNICODE_STRING Text;
NTSTATUS Status;
pIrpStack = IoGetCurrentIrpStackLocation(pIrp);
switch (pIrpStack->Parameters.QueryDeviceText.DeviceTextType) {
case DeviceTextDescription:
TraceDebug(("%s: DeviceTextDescription\n", __FUNCTION__));
break;
case DeviceTextLocationInformation:
TraceDebug(("%s: DeviceTextLocationInformation\n", __FUNCTION__));
break;
default:
pIrp->IoStatus.Information = 0;
return STATUS_NOT_SUPPORTED;
}
pBuffer = ExAllocatePoolWithTag(PagedPool,
XENM2B_MAX_TEXT_LENGTH,
XENM2B_POOL_TAG);
if (pBuffer == NULL)
return STATUS_INSUFFICIENT_RESOURCES;
RtlZeroMemory(pBuffer, XENM2B_MAX_TEXT_LENGTH);
Text.Buffer = pBuffer;
Text.MaximumLength = XENM2B_MAX_TEXT_LENGTH;
Text.Length = 0;
switch (pIrpStack->Parameters.QueryDeviceText.DeviceTextType) {
case DeviceTextDescription:
RtlAppendUnicodeStringToString(&Text, &pPdoExt->DeviceName);
break;
case DeviceTextLocationInformation:
RtlAppendUnicodeToString(&Text, L"Xen PV HID Device on XenM2B Bus");
break;
default:
ASSERT(FALSE);
break;
}
TraceDebug(("%s: %wZ\n", __FUNCTION__, &Text));
pIrp->IoStatus.Information = (ULONG_PTR)pBuffer;
return STATUS_SUCCESS;
}
示例7: IoQueryDeviceDescription
NTSTATUS NTAPI
IoQueryDeviceDescription(PINTERFACE_TYPE BusType OPTIONAL,
PULONG BusNumber OPTIONAL,
PCONFIGURATION_TYPE ControllerType OPTIONAL,
PULONG ControllerNumber OPTIONAL,
PCONFIGURATION_TYPE PeripheralType OPTIONAL,
PULONG PeripheralNumber OPTIONAL,
PIO_QUERY_DEVICE_ROUTINE CalloutRoutine,
PVOID Context)
{
NTSTATUS Status;
ULONG BusLoopNumber = -1; /* Root Bus */
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING RootRegKey;
HANDLE RootRegHandle;
IO_QUERY Query;
/* Set up the String */
RootRegKey.Length = 0;
RootRegKey.MaximumLength = 2048;
RootRegKey.Buffer = ExAllocatePoolWithTag(PagedPool, RootRegKey.MaximumLength, TAG_IO_RESOURCE);
RtlAppendUnicodeToString(&RootRegKey, L"\\REGISTRY\\MACHINE\\HARDWARE\\DESCRIPTION\\SYSTEM");
/* Open a handle to the Root Registry Key */
InitializeObjectAttributes(
&ObjectAttributes,
&RootRegKey,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status = ZwOpenKey(&RootRegHandle, KEY_READ, &ObjectAttributes);
if (NT_SUCCESS(Status))
{
/* Use a helper function to loop though this key and get the info */
Query.BusType = BusType;
Query.BusNumber = BusNumber;
Query.ControllerType = ControllerType;
Query.ControllerNumber = ControllerNumber;
Query.PeripheralType = PeripheralType;
Query.PeripheralNumber = PeripheralNumber;
Query.CalloutRoutine = CalloutRoutine;
Query.Context = Context;
Status = IopQueryBusDescription(&Query, RootRegKey, RootRegHandle, &BusLoopNumber, TRUE);
/* Close registry */
ZwClose(RootRegHandle);
}
/* Free Memory */
ExFreePoolWithTag(RootRegKey.Buffer, TAG_IO_RESOURCE);
return Status;
}
示例8: DriverEntry
NTSTATUS DriverEntry (IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
{
NTSTATUS ntStatus;
ntStatus= STATUS_SUCCESS;
PPJoyBus_DebugLevel= PPJOY_DEFAULT_DEBUGLEVEL;
PPJOY_DBGPRINT (FILE_PPJOYBUS|PPJOY_WARN, ("Built " __DATE__ " at " __TIME__) );
PPJOY_DBGPRINT (FILE_PPJOYBUS|PPJOY_FENTRY, ("DriverEntry (DriverObject=0x%p,RegistryPath=0x%p)",DriverObject, RegistryPath) );
RtlZeroMemory (&Globals,sizeof(Globals));
/* Setup copy of DriverObject first so we can use it for event log function */
Globals.DriverObject= DriverObject;
/* Allocate buffer to store registry path to the parameters registry key */
Globals.ParamRegistryPath.MaximumLength= RegistryPath->Length+sizeof(UNICODE_NULL)+sizeof(PARAM_KEY_NAME);
Globals.ParamRegistryPath.Length= RegistryPath->Length;
Globals.ParamRegistryPath.Buffer= ExAllocatePoolWithTag (PagedPool,Globals.ParamRegistryPath.MaximumLength,PPJOYBUS_POOL_TAG);
if (!Globals.ParamRegistryPath.Buffer)
{
PPJoyBus_WriteEventLog (PPJ_MSG_ERRORALLOCMEM,&ntStatus,sizeof(ntStatus),L"");
ntStatus= STATUS_INSUFFICIENT_RESOURCES;
goto Exit;
}
/* Copy driver registry path and append the parameters subkey name */
RtlCopyUnicodeString (&Globals.ParamRegistryPath,RegistryPath);
RtlAppendUnicodeToString (&Globals.ParamRegistryPath,PARAM_KEY_NAME);
ExInitializeFastMutex (&Globals.Mutex);
PPJOY_DBGPRINT (FILE_PPJOYBUS|PPJOY_BABBLE2, ("ParamRegistryPath=%S",Globals.ParamRegistryPath.Buffer) );
/* Set up pointers to our other entry points in the DeviceObject */
DriverObject->MajorFunction[IRP_MJ_CREATE]= PPJoyBus_CreateClose;
DriverObject->MajorFunction[IRP_MJ_CLOSE]= PPJoyBus_CreateClose;
DriverObject->MajorFunction[IRP_MJ_POWER]= PPJoyBus_Power;
DriverObject->MajorFunction[IRP_MJ_PNP]= PPJoyBus_PnP;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL]= PPJoyBus_Ioctl;
DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL]= PPJoyBus_InternalIoctl;
DriverObject->DriverUnload= PPJoyBus_Unload;
DriverObject->DriverExtension->AddDevice= PPJoyBus_AddDevice;
PPJoyBus_WriteEventLog (PPJ_MSG_DRIVERSTARTEDVER,&ntStatus,sizeof(ntStatus),LVER_PRODUCTVERSION_STR);
Exit:
PPJOY_EXITPROC (FILE_PPJOYBUS|PPJOY_FEXIT_STATUSOK , "DriverEntry", ntStatus);
return ntStatus;
} /* DriverEntry */
示例9: AppendUserEnvironmentVariable
static
BOOL
AppendUserEnvironmentVariable(PWSTR* Environment,
LPWSTR lpName,
LPWSTR lpValue)
{
NTSTATUS Status;
UNICODE_STRING Name, Value;
RtlInitUnicodeString(&Name, lpName);
Value.Length = 0;
Value.MaximumLength = 1024 * sizeof(WCHAR);
Value.Buffer = LocalAlloc(LPTR, Value.MaximumLength);
if (Value.Buffer == NULL)
return FALSE;
Value.Buffer[0] = UNICODE_NULL;
Status = RtlQueryEnvironmentVariable_U(*Environment,
&Name,
&Value);
if (NT_SUCCESS(Status))
RtlAppendUnicodeToString(&Value, L";");
RtlAppendUnicodeToString(&Value, lpValue);
Status = RtlSetEnvironmentVariable(Environment,
&Name,
&Value);
LocalFree(Value.Buffer);
if (!NT_SUCCESS(Status))
{
DPRINT1("RtlSetEnvironmentVariable() failed (Status %lx)\n", Status);
return FALSE;
}
return TRUE;
}
示例10: ReadRegistery
//read EnableReplace key from reg to check if replace the key with our define key
void ReadRegistery(IN PUNICODE_STRING RegistryPath)
{
UNICODE_STRING parameter_path;
RTL_QUERY_REGISTRY_TABLE query_table[2];
NTSTATUS status;
parameter_path.Length = 0;
parameter_path.MaximumLength = RegistryPath->Length + sizeof(PARAMETER_KEY);
parameter_path.Buffer = (PWSTR) ExAllocatePool(PagedPool, parameter_path.MaximumLength);
if (parameter_path.Buffer == NULL)
{
return;
}
RtlZeroMemory(parameter_path.Buffer,parameter_path.MaximumLength);
RtlCopyUnicodeString(¶meter_path, RegistryPath);
RtlAppendUnicodeToString(¶meter_path, PARAMETER_KEY);
RtlZeroMemory(&query_table[0], sizeof(query_table));
query_table[0].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_REQUIRED;
query_table[0].Name = ENABLEWRITEPORT_VALUE;
query_table[0].EntryContext = &bEnableReplace;
status = RtlQueryRegistryValues(
RTL_REGISTRY_ABSOLUTE,
parameter_path.Buffer,
&query_table[0],
NULL,
NULL
);
ExFreePool(parameter_path.Buffer);
if (!NT_SUCCESS(status))
{
KdPrint(("Kb_sniff_Mp: Query registry failed.\n"));
}
}
示例11: InitializeProvider
VOID
InitializeProvider(
PWCH ProviderName,
ULONG Priority
)
/*++
Routine Description:
This routine reads provider information out of the registry and
creates an unregistered provider entry.
Arguments:
ProviderName - The registry name for the provider.
Priority - The priority to assign to this provider.
Return Value:
None.
--*/
{
UNICODE_STRING keyName;
PVOID buffer = NULL;
ULONG bufferLength;
NTSTATUS status;
OBJECT_ATTRIBUTES objectAttributes;
ULONG lengthRequired;
UNICODE_STRING valueName;
HANDLE handle;
PAGED_CODE();
//
// Allocate space for the registry string
//
bufferLength = sizeof( L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\" ) +
wcslen( ProviderName ) * sizeof( WCHAR ) +
sizeof( L"\\NetworkProvider" );
buffer = ExAllocatePoolWithTag( PagedPool, bufferLength, ' puM' );
if ( buffer == NULL ) {
return;
}
//
// Build the registry string
//
RtlMoveMemory(
buffer,
L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\",
sizeof( L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\" )
);
keyName.Buffer = buffer;
keyName.MaximumLength = (USHORT)bufferLength;
keyName.Length = sizeof( L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\" ) - 2;
status = RtlAppendUnicodeToString( &keyName, ProviderName );
ASSERT( NT_SUCCESS( status ) );
status = RtlAppendUnicodeToString( &keyName, L"\\NetworkProvider" );
ASSERT( NT_SUCCESS( status ) );
InitializeObjectAttributes(
&objectAttributes,
&keyName,
OBJ_CASE_INSENSITIVE,
0,
NULL
);
status = ZwOpenKey(
&handle,
KEY_QUERY_VALUE,
&objectAttributes
);
ExFreePool( buffer );
if ( !NT_SUCCESS( status )) {
return;
}
buffer = NULL;
RtlInitUnicodeString( &valueName, L"DeviceName" );
status = ZwQueryValueKey(
handle,
&valueName,
KeyValueFullInformation,
buffer,
0,
&lengthRequired
);
if ( status == STATUS_BUFFER_TOO_SMALL ) {
//.........这里部分代码省略.........
示例12: OpenRegistryHandlesFromSymbolicLink
static
NTSTATUS
OpenRegistryHandlesFromSymbolicLink(IN PUNICODE_STRING SymbolicLinkName,
IN ACCESS_MASK DesiredAccess,
IN OPTIONAL PHANDLE GuidKey,
IN OPTIONAL PHANDLE DeviceKey,
IN OPTIONAL PHANDLE InstanceKey)
{
OBJECT_ATTRIBUTES ObjectAttributes;
WCHAR PathBuffer[MAX_PATH];
UNICODE_STRING BaseKeyU;
UNICODE_STRING GuidString, SubKeyName, ReferenceString;
PWCHAR StartPosition, EndPosition;
HANDLE ClassesKey;
PHANDLE GuidKeyRealP, DeviceKeyRealP, InstanceKeyRealP;
HANDLE GuidKeyReal, DeviceKeyReal, InstanceKeyReal;
NTSTATUS Status;
SubKeyName.Buffer = NULL;
if (GuidKey != NULL)
GuidKeyRealP = GuidKey;
else
GuidKeyRealP = &GuidKeyReal;
if (DeviceKey != NULL)
DeviceKeyRealP = DeviceKey;
else
DeviceKeyRealP = &DeviceKeyReal;
if (InstanceKey != NULL)
InstanceKeyRealP = InstanceKey;
else
InstanceKeyRealP = &InstanceKeyReal;
*GuidKeyRealP = INVALID_HANDLE_VALUE;
*DeviceKeyRealP = INVALID_HANDLE_VALUE;
*InstanceKeyRealP = INVALID_HANDLE_VALUE;
BaseKeyU.Buffer = PathBuffer;
BaseKeyU.Length = 0;
BaseKeyU.MaximumLength = MAX_PATH * sizeof(WCHAR);
RtlAppendUnicodeToString(&BaseKeyU, BaseKeyString);
/* Open the DeviceClasses key */
InitializeObjectAttributes(&ObjectAttributes,
&BaseKeyU,
OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
NULL,
NULL);
Status = ZwOpenKey(&ClassesKey,
DesiredAccess | KEY_ENUMERATE_SUB_KEYS,
&ObjectAttributes);
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to open %wZ\n", &BaseKeyU);
goto cleanup;
}
StartPosition = wcschr(SymbolicLinkName->Buffer, L'{');
EndPosition = wcschr(SymbolicLinkName->Buffer, L'}');
if (!StartPosition || !EndPosition || StartPosition > EndPosition)
{
DPRINT1("Bad symbolic link: %wZ\n", SymbolicLinkName);
return STATUS_INVALID_PARAMETER_1;
}
GuidString.Buffer = StartPosition;
GuidString.MaximumLength = GuidString.Length = (USHORT)((ULONG_PTR)(EndPosition + 1) - (ULONG_PTR)StartPosition);
InitializeObjectAttributes(&ObjectAttributes,
&GuidString,
OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
ClassesKey,
NULL);
Status = ZwOpenKey(GuidKeyRealP,
DesiredAccess | KEY_ENUMERATE_SUB_KEYS,
&ObjectAttributes);
ZwClose(ClassesKey);
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to open %wZ%wZ (%x)\n", &BaseKeyU, &GuidString, Status);
goto cleanup;
}
SubKeyName.MaximumLength = SymbolicLinkName->Length + sizeof(WCHAR);
SubKeyName.Length = 0;
SubKeyName.Buffer = ExAllocatePool(PagedPool, SubKeyName.MaximumLength);
if (!SubKeyName.Buffer)
{
Status = STATUS_INSUFFICIENT_RESOURCES;
goto cleanup;
}
RtlAppendUnicodeStringToString(&SubKeyName,
SymbolicLinkName);
SubKeyName.Buffer[SubKeyName.Length / sizeof(WCHAR)] = UNICODE_NULL;
SubKeyName.Buffer[0] = L'#';
//.........这里部分代码省略.........
示例13: IopOpenInterfaceKey
/*++
* @name IopOpenInterfaceKey
*
* Returns the alias device interface of the specified device interface
*
* @param InterfaceClassGuid
* FILLME
*
* @param DesiredAccess
* FILLME
*
* @param pInterfaceKey
* FILLME
*
* @return Usual NTSTATUS
*
* @remarks None
*
*--*/
static NTSTATUS
IopOpenInterfaceKey(IN CONST GUID *InterfaceClassGuid,
IN ACCESS_MASK DesiredAccess,
OUT HANDLE *pInterfaceKey)
{
UNICODE_STRING LocalMachine = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\");
UNICODE_STRING GuidString;
UNICODE_STRING KeyName;
OBJECT_ATTRIBUTES ObjectAttributes;
HANDLE InterfaceKey = INVALID_HANDLE_VALUE;
NTSTATUS Status;
GuidString.Buffer = KeyName.Buffer = NULL;
Status = RtlStringFromGUID(InterfaceClassGuid, &GuidString);
if (!NT_SUCCESS(Status))
{
DPRINT("RtlStringFromGUID() failed with status 0x%08lx\n", Status);
goto cleanup;
}
KeyName.Length = 0;
KeyName.MaximumLength = LocalMachine.Length + ((USHORT)wcslen(REGSTR_PATH_DEVICE_CLASSES) + 1) * sizeof(WCHAR) + GuidString.Length;
KeyName.Buffer = ExAllocatePool(PagedPool, KeyName.MaximumLength);
if (!KeyName.Buffer)
{
DPRINT("ExAllocatePool() failed\n");
Status = STATUS_INSUFFICIENT_RESOURCES;
goto cleanup;
}
Status = RtlAppendUnicodeStringToString(&KeyName, &LocalMachine);
if (!NT_SUCCESS(Status))
{
DPRINT("RtlAppendUnicodeStringToString() failed with status 0x%08lx\n", Status);
goto cleanup;
}
Status = RtlAppendUnicodeToString(&KeyName, REGSTR_PATH_DEVICE_CLASSES);
if (!NT_SUCCESS(Status))
{
DPRINT("RtlAppendUnicodeToString() failed with status 0x%08lx\n", Status);
goto cleanup;
}
Status = RtlAppendUnicodeToString(&KeyName, L"\\");
if (!NT_SUCCESS(Status))
{
DPRINT("RtlAppendUnicodeToString() failed with status 0x%08lx\n", Status);
goto cleanup;
}
Status = RtlAppendUnicodeStringToString(&KeyName, &GuidString);
if (!NT_SUCCESS(Status))
{
DPRINT("RtlAppendUnicodeStringToString() failed with status 0x%08lx\n", Status);
goto cleanup;
}
InitializeObjectAttributes(
&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status = ZwOpenKey(
&InterfaceKey,
DesiredAccess,
&ObjectAttributes);
if (!NT_SUCCESS(Status))
{
DPRINT("ZwOpenKey() failed with status 0x%08lx\n", Status);
goto cleanup;
}
*pInterfaceKey = InterfaceKey;
Status = STATUS_SUCCESS;
cleanup:
if (!NT_SUCCESS(Status))
{
if (InterfaceKey != INVALID_HANDLE_VALUE)
ZwClose(InterfaceKey);
}
//.........这里部分代码省略.........
示例14: Ext2QueryGlobalParameters
BOOLEAN
Ext2QueryGlobalParameters( IN PUNICODE_STRING RegistryPath)
{
NTSTATUS Status;
UNICODE_STRING ParameterPath;
RTL_QUERY_REGISTRY_TABLE QueryTable[2];
ULONG WritingSupport = 0;
ULONG CheckingBitmap = 0;
ULONG Ext3ForceWriting = 0;
ULONG AutoMount = 0;
UNICODE_STRING UniName;
ANSI_STRING AnsiName;
WCHAR UniBuffer[CODEPAGE_MAXLEN];
USHORT Buffer[HIDINGPAT_LEN];
ParameterPath.Length = 0;
ParameterPath.MaximumLength =
RegistryPath->Length + sizeof(PARAMETERS_KEY) + sizeof(WCHAR);
ParameterPath.Buffer =
(PWSTR) Ext2AllocatePool(
PagedPool,
ParameterPath.MaximumLength,
'LG2E'
);
if (!ParameterPath.Buffer) {
DbgBreak();
DEBUG(DL_ERR, ( "Ex2QueryParameters: failed to allocate Parameters...\n"));
return FALSE;
}
RtlCopyUnicodeString(&ParameterPath, RegistryPath);
RtlAppendUnicodeToString(&ParameterPath, PARAMETERS_KEY);
/* querying value of WritingSupport */
RtlZeroMemory(&QueryTable[0], sizeof(RTL_QUERY_REGISTRY_TABLE) * 2);
QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_REQUIRED;
QueryTable[0].Name = WRITING_SUPPORT;
QueryTable[0].EntryContext = &WritingSupport;
Status = RtlQueryRegistryValues(
RTL_REGISTRY_ABSOLUTE,
ParameterPath.Buffer,
&QueryTable[0],
NULL,
NULL );
DEBUG(DL_ERR, ( "Ext2QueryParameters: WritingSupport=%xh\n", WritingSupport));
/* querying value of CheckingBitmap */
RtlZeroMemory(&QueryTable[0], sizeof(RTL_QUERY_REGISTRY_TABLE) * 2);
QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_REQUIRED;
QueryTable[0].Name = CHECKING_BITMAP;
QueryTable[0].EntryContext = &CheckingBitmap;
Status = RtlQueryRegistryValues(
RTL_REGISTRY_ABSOLUTE,
ParameterPath.Buffer,
&QueryTable[0],
NULL,
NULL );
DEBUG(DL_ERR, ( "Ext2QueryParameters: CheckingBitmap=%xh\n", CheckingBitmap));
/* querying value of Ext3ForceWriting */
RtlZeroMemory(&QueryTable[0], sizeof(RTL_QUERY_REGISTRY_TABLE) * 2);
QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_REQUIRED;
QueryTable[0].Name = EXT3_FORCEWRITING;
QueryTable[0].EntryContext = &Ext3ForceWriting;
Status = RtlQueryRegistryValues(
RTL_REGISTRY_ABSOLUTE,
ParameterPath.Buffer,
&QueryTable[0],
NULL,
NULL );
DEBUG(DL_ERR, ( "Ext2QueryParameters: Ext3ForceWriting=%xh\n", Ext3ForceWriting));
/* querying value of AutoMount */
RtlZeroMemory(&QueryTable[0], sizeof(RTL_QUERY_REGISTRY_TABLE) * 2);
QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_REQUIRED;
QueryTable[0].Name = AUTO_MOUNT;
QueryTable[0].EntryContext = &AutoMount;
Status = RtlQueryRegistryValues(
RTL_REGISTRY_ABSOLUTE,
ParameterPath.Buffer,
&QueryTable[0],
NULL,
NULL );
//.........这里部分代码省略.........
示例15: Ext2QueryRegistrySettings
BOOLEAN
Ext2QueryRegistrySettings(IN PUNICODE_STRING RegistryPath)
{
UNICODE_STRING ParameterPath;
UNICODE_STRING UniName;
ANSI_STRING AnsiName;
ULONG WritingSupport = 0;
ULONG CheckingBitmap = 0;
ULONG Ext3ForceWriting = 0;
ULONG AutoMount = 0;
WCHAR UniBuffer[CODEPAGE_MAXLEN];
USHORT Buffer[HIDINGPAT_LEN];
NTSTATUS Status;
ParameterPath.Length = 0;
ParameterPath.MaximumLength =
RegistryPath->Length + sizeof(PARAMETERS_KEY) + sizeof(WCHAR);
ParameterPath.Buffer =
(PWSTR) Ext2AllocatePool(
PagedPool,
ParameterPath.MaximumLength,
'LG2E'
);
if (!ParameterPath.Buffer) {
DbgBreak();
DEBUG(DL_ERR, ( "Ex2QueryParameters: failed to allocate Parameters...\n"));
return FALSE;
}
RtlCopyUnicodeString(&ParameterPath, RegistryPath);
RtlAppendUnicodeToString(&ParameterPath, PARAMETERS_KEY);
/* enable automount of ext2/3/4 volumes */
SetLongFlag(Ext2Global->Flags, EXT2_AUTO_MOUNT);
/* query parameter settings from registry */
Ext2QueryGlobalParameters(&ParameterPath);
/* set global codepage settings */
if (wcslen(&Ext2Global->Codepage.PageName[0])) {
UniName.Length = sizeof(WCHAR) * wcslen(&Ext2Global->Codepage.PageName[0]);
UniName.MaximumLength = CODEPAGE_MAXLEN * sizeof(WCHAR);
UniName.Buffer = &Ext2Global->Codepage.PageName[0];
AnsiName.MaximumLength = CODEPAGE_MAXLEN;
AnsiName.Length = 0;
AnsiName.Buffer = &Ext2Global->Codepage.AnsiName[0];
Status = RtlUnicodeStringToAnsiString(
&AnsiName,
&UniName,
FALSE);
if (!NT_SUCCESS(Status)) {
DEBUG(DL_ERR, ( "Ext2QueryParameters: Wrong CodePage %wZ ...\n", &UniName));
RtlCopyMemory(&(Ext2Global->Codepage.AnsiName[0]),"default\0", 8);
}
} else {
DEBUG(DL_ERR, ( "Ext2QueryParameters: CodePage not specified.\n"));
RtlCopyMemory(&(Ext2Global->Codepage.AnsiName[0]),"default\0", 8);
}
Ext2Global->Codepage.AnsiName[CODEPAGE_MAXLEN - 1] = 0;
/* set global hidden prefix pattern */
if (wcslen(&Ext2Global->wHidingPrefix[0])) {
UniName.Length = sizeof(WCHAR) * wcslen(&Ext2Global->wHidingPrefix[0]);
UniName.MaximumLength = HIDINGPAT_LEN * sizeof(WCHAR);
UniName.Buffer = &Ext2Global->wHidingPrefix[0];
AnsiName.MaximumLength = HIDINGPAT_LEN;
AnsiName.Length = 0;
AnsiName.Buffer = &(Ext2Global->sHidingPrefix[0]);
Status = RtlUnicodeStringToAnsiString(
&AnsiName,
&UniName,
FALSE);
if (NT_SUCCESS(Status)) {
Ext2Global->bHidingPrefix = TRUE;
} else {
DEBUG(DL_ERR, ( "Ext2QueryParameters: Wrong HidingPrefix ...\n"));
}
} else {
DEBUG(DL_ERR, ( "Ext2QueryParameters: HidingPrefix not specified.\n"));
}
Ext2Global->sHidingPrefix[HIDINGPAT_LEN - 1] = 0;
/* set global hidden suffix pattern */
if (wcslen(&Ext2Global->wHidingSuffix[0])) {
UniName.Length = sizeof(WCHAR) * wcslen(&Ext2Global->wHidingSuffix[0]);
UniName.MaximumLength = HIDINGPAT_LEN * sizeof(WCHAR);
UniName.Buffer = &Ext2Global->wHidingSuffix[0];
AnsiName.MaximumLength = HIDINGPAT_LEN;
AnsiName.Length = 0;
AnsiName.Buffer = &(Ext2Global->sHidingSuffix[0]);
Status = RtlUnicodeStringToAnsiString(
&AnsiName,
&UniName,
//.........这里部分代码省略.........