{
#if 0NTSTATUSstatus;
ULONGindex;
ULONG resultLength;
UCHAR lowerController[64];
BOOLEAN validControllerNumber;
UNICODE_STRING unicodeString[64];
OBJECT_ATTRIBUTES objectAttributes;
HANDLE controllerHandle;
HANDLE controllerNumberHandle;
ULONG controllerIndex;
ULONG controllerNumberIndex;
UCHAR keyBuffer[256]; // Allow for variable length name at endUCHAR numberKeyBuffer[64];
PKEY_BASIC_INFORMATION pControllerKeyInformation;
PKEY_BASIC_INFORMATION pControllerNumberKeyInformation;
// TODO: Any PAGED_CODE stuff...//// Walk enumerated subkeys, looking for valid controllers//for (controllerIndex = 0; TRUE; controllerIndex++) {
//// Ensure pControllerKeyInformation->Name is null terminated//RtlZeroMemory(keyBuffer, sizeof(keyBuffer));
pControllerKeyInformation = (PKEY_BASIC_INFORMATION) keyBuffer;
status = ZwEnumerateKey(
KeyHandle,
controllerIndex,
KeyBasicInformation,
pControllerKeyInformation,
sizeof(keyBuffer),
&resultLength
);
if (!NT_SUCCESS(status)) {
if (status != STATUS_NO_MORE_ENTRIES) {
DebugPrint ((2, "FindScsiAdapter: Error 0x%x enumerating key\n", status));
return(status);
}
break; // return NOT_FOUND
}
DebugPrint ((3, "FindScsiAdapter: Found Adapter=%S\n", pControllerKeyInformation->Name));
if (!_wcsicmp(pControllerKeyInformation->Name, L"ScsiAdapter")) {
//// Found scsi, now verify that it's the same one we're trying to initialize.//INIT_OPEN_KEY (ScsiUnicodeString, KeyHandle, &controllerHandle);
ZwClose(controllerHandle);
if (NT_SUCCESS(status)) {
//// Found correct scsi, now build ARC name of IntermediateController// (i.e. the intervening controllers, or everything above ScsiAdapter)// start with null, and build string one controller at a time as we// return up the recursively called routine.//
IntermediateController = "\0";
return (STATUS_SUCCESS);
}
//// Found ScsiAdapter, but wrong scsi id or Lun info doesn't match,// (ignore other ZwOpenKey errors &) keep looking...//
}
elseif (!_wcsicmp(pControllerKeyInformation->Name, L"MultifunctionAdapter") ||
!_wcsicmp(pControllerKeyInformation->Name, L"EisaAdapter")) {
//// This is a valid controller that may have ScsiAdapter beneath it.// Open controller & walk controller's subkeys: 0, 1, 2, etc....//RtlInitUnicodeString (unicodeString, pControllerKeyInformation->Name);
INIT_OPEN_KEY (unicodeString, KeyHandle, &controllerHandle);
if (!NT_SUCCESS(status)) {
DebugPrint ((2, "FindScsiAdapter: ZwOpenKey got status = %x \n", status));
ZwClose (controllerHandle);
return (status);
}
for (controllerNumberIndex = 0; TRUE; controllerNumberIndex++) {
RtlZeroMemory(numberKeyBuffer, sizeof(numberKeyBuffer));
pControllerNumberKeyInformation = (PKEY_BASIC_INFORMATION) numberKeyBuffer;
status = ZwEnumerateKey(
controllerHandle,
controllerNumberIndex,
KeyBasicInformation,
pControllerNumberKeyInformation,
sizeof(numberKeyBuffer),
&resultLength
);
if (!NT_SUCCESS(status)) {
if (status != STATUS_NO_MORE_ENTRIES) {
DebugPrint ((2, "FindScsiAdapter: Status %x enumerating key\n", status));
ZwClose(controllerHandle);
return (status);
}
ZwClose(controllerHandle);
break; // next controller
}
DebugPrint ((3, "FindScsiAdapter: Found Adapter #=%S\n", pControllerNumberKeyInformation->Name));
validControllerNumber = TRUE;
for (index = 0; index < pControllerNumberKeyInformation->NameLength / 2; index++) {
if (!isxdigit(pControllerNumberKeyInformation->Name[index])) {
validControllerNumber = FALSE;
break;
}
}
if (validControllerNumber) {
//// Found valid controller and controller number: check children for scsi.//RtlInitUnicodeString (unicodeString, pControllerNumberKeyInformation->Name);
INIT_OPEN_KEY (unicodeString, controllerHandle, &controllerNumberHandle);
if (!NT_SUCCESS(status)) {
DebugPrint ((2, "FindScsiAdapter: Status %x opening controller number key\n", status));
ZwClose(controllerNumberHandle);
ZwClose(controllerHandle);
return (status);
}
RtlZeroMemory(lowerController, sizeof(lowerController));
status = FindScsiAdapter(
controllerNumberHandle,
ScsiUnicodeString,
&lowerController[0]
);
ZwClose(controllerNumberHandle);
if (NT_SUCCESS(status)) {
//// SUCCESS!//// Scsi adapter DOES exist under this node,// prepend Arc Name for the current adapter to whatever was returned// by other calls to this routine.//if (!_wcsicmp(pControllerKeyInformation->Name, L"MultifunctionAdapter")) {
sprintf(IntermediateController, "multi(0)%s", lowerController);
} else {
sprintf(IntermediateController, "eisa(0)%s", lowerController);
}
ZwClose(controllerHandle);
return(STATUS_SUCCESS);
}
elseif (status != STATUS_OBJECT_PATH_NOT_FOUND) {
ZwClose(controllerHandle);
return(status);
}
//// Scsi not found under this controller number, check next one//
} // if validControllerNumber
} // for controllerNumberIndex//// ScsiAdapter not found under this controller//ZwClose(controllerHandle);
} // else if valid subkey (i.e., scsi, multi, eisa)
} // for controllerIndex//// ScsiAdapter not found under key we were called with//
IntermediateController = "\0";
#endifreturn (STATUS_OBJECT_PATH_NOT_FOUND);
}
Generated on Sat May 26 2012 05:24:13 for ReactOS by
1.7.6.1
ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.