mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
[KERNEL32]: Whitespace fixes only, no functional code changes.
svn path=/trunk/; revision=71687
This commit is contained in:
parent
def1d69426
commit
5113536603
1 changed files with 181 additions and 196 deletions
|
@ -92,7 +92,7 @@ DefineDosDeviceW(
|
|||
DEV_BROADCAST_VOLUME dbcv;
|
||||
BOOL Result = TRUE;
|
||||
DWORD dwRecipients;
|
||||
typedef long (WINAPI *BSM_type)(DWORD,LPDWORD,UINT,WPARAM,LPARAM);
|
||||
typedef long (WINAPI *BSM_type)(DWORD, LPDWORD, UINT, WPARAM, LPARAM);
|
||||
BSM_type BSM_ptr;
|
||||
|
||||
if ( (dwFlags & 0xFFFFFFF0) ||
|
||||
|
@ -241,73 +241,62 @@ QueryDosDeviceA(
|
|||
DWORD ucchMax
|
||||
)
|
||||
{
|
||||
UNICODE_STRING DeviceNameU;
|
||||
UNICODE_STRING TargetPathU;
|
||||
ANSI_STRING TargetPathA;
|
||||
DWORD Length;
|
||||
DWORD CurrentLength;
|
||||
PWCHAR Buffer;
|
||||
UNICODE_STRING DeviceNameU;
|
||||
UNICODE_STRING TargetPathU;
|
||||
ANSI_STRING TargetPathA;
|
||||
DWORD Length;
|
||||
DWORD CurrentLength;
|
||||
PWCHAR Buffer;
|
||||
|
||||
if (lpDeviceName)
|
||||
{
|
||||
if (!RtlCreateUnicodeStringFromAsciiz (&DeviceNameU,
|
||||
(LPSTR)lpDeviceName))
|
||||
{
|
||||
SetLastError (ERROR_NOT_ENOUGH_MEMORY);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Buffer = RtlAllocateHeap (RtlGetProcessHeap (),
|
||||
0,
|
||||
ucchMax * sizeof(WCHAR));
|
||||
if (Buffer == NULL)
|
||||
{
|
||||
if (lpDeviceName)
|
||||
{
|
||||
RtlFreeHeap (RtlGetProcessHeap (),
|
||||
0,
|
||||
DeviceNameU.Buffer);
|
||||
if (!RtlCreateUnicodeStringFromAsciiz(&DeviceNameU,
|
||||
(LPSTR)lpDeviceName))
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
SetLastError (ERROR_NOT_ENOUGH_MEMORY);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Length = QueryDosDeviceW (lpDeviceName ? DeviceNameU.Buffer : NULL,
|
||||
Buffer,
|
||||
ucchMax);
|
||||
if (Length != 0)
|
||||
{
|
||||
TargetPathA.Buffer = lpTargetPath;
|
||||
TargetPathU.Buffer = Buffer;
|
||||
ucchMax = Length;
|
||||
|
||||
while (ucchMax)
|
||||
Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, ucchMax * sizeof(WCHAR));
|
||||
if (Buffer == NULL)
|
||||
{
|
||||
CurrentLength = min (ucchMax, MAXUSHORT / 2);
|
||||
TargetPathU.MaximumLength = TargetPathU.Length = (USHORT)CurrentLength * sizeof(WCHAR);
|
||||
|
||||
TargetPathA.Length = 0;
|
||||
TargetPathA.MaximumLength = (USHORT)CurrentLength;
|
||||
|
||||
RtlUnicodeStringToAnsiString (&TargetPathA,
|
||||
&TargetPathU,
|
||||
FALSE);
|
||||
ucchMax -= CurrentLength;
|
||||
TargetPathA.Buffer += TargetPathA.Length;
|
||||
TargetPathU.Buffer += TargetPathU.Length / sizeof(WCHAR);
|
||||
if (lpDeviceName)
|
||||
{
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, DeviceNameU.Buffer);
|
||||
}
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
RtlFreeHeap (RtlGetProcessHeap (),
|
||||
0,
|
||||
Buffer);
|
||||
if (lpDeviceName)
|
||||
{
|
||||
RtlFreeHeap (RtlGetProcessHeap (),
|
||||
0,
|
||||
DeviceNameU.Buffer);
|
||||
}
|
||||
return Length;
|
||||
Length = QueryDosDeviceW(lpDeviceName ? DeviceNameU.Buffer : NULL,
|
||||
Buffer, ucchMax);
|
||||
if (Length != 0)
|
||||
{
|
||||
TargetPathA.Buffer = lpTargetPath;
|
||||
TargetPathU.Buffer = Buffer;
|
||||
ucchMax = Length;
|
||||
|
||||
while (ucchMax)
|
||||
{
|
||||
CurrentLength = min(ucchMax, MAXUSHORT / 2);
|
||||
TargetPathU.MaximumLength = TargetPathU.Length = (USHORT)CurrentLength * sizeof(WCHAR);
|
||||
|
||||
TargetPathA.Length = 0;
|
||||
TargetPathA.MaximumLength = (USHORT)CurrentLength;
|
||||
|
||||
RtlUnicodeStringToAnsiString(&TargetPathA, &TargetPathU, FALSE);
|
||||
ucchMax -= CurrentLength;
|
||||
TargetPathA.Buffer += TargetPathA.Length;
|
||||
TargetPathU.Buffer += TargetPathU.Length / sizeof(WCHAR);
|
||||
}
|
||||
}
|
||||
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||
if (lpDeviceName)
|
||||
{
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, DeviceNameU.Buffer);
|
||||
}
|
||||
return Length;
|
||||
}
|
||||
|
||||
|
||||
|
@ -322,160 +311,156 @@ QueryDosDeviceW(
|
|||
DWORD ucchMax
|
||||
)
|
||||
{
|
||||
POBJECT_DIRECTORY_INFORMATION DirInfo;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
UNICODE_STRING UnicodeString;
|
||||
HANDLE DirectoryHandle;
|
||||
HANDLE DeviceHandle;
|
||||
ULONG ReturnLength;
|
||||
ULONG NameLength;
|
||||
ULONG Length;
|
||||
ULONG Context;
|
||||
BOOLEAN RestartScan;
|
||||
NTSTATUS Status;
|
||||
UCHAR Buffer[512];
|
||||
PWSTR Ptr;
|
||||
POBJECT_DIRECTORY_INFORMATION DirInfo;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
UNICODE_STRING UnicodeString;
|
||||
HANDLE DirectoryHandle;
|
||||
HANDLE DeviceHandle;
|
||||
ULONG ReturnLength;
|
||||
ULONG NameLength;
|
||||
ULONG Length;
|
||||
ULONG Context;
|
||||
BOOLEAN RestartScan;
|
||||
NTSTATUS Status;
|
||||
UCHAR Buffer[512];
|
||||
PWSTR Ptr;
|
||||
|
||||
/* Open the '\??' directory */
|
||||
RtlInitUnicodeString (&UnicodeString,
|
||||
L"\\??");
|
||||
InitializeObjectAttributes (&ObjectAttributes,
|
||||
&UnicodeString,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
Status = NtOpenDirectoryObject (&DirectoryHandle,
|
||||
DIRECTORY_QUERY,
|
||||
&ObjectAttributes);
|
||||
if (!NT_SUCCESS (Status))
|
||||
{
|
||||
WARN ("NtOpenDirectoryObject() failed (Status %lx)\n", Status);
|
||||
BaseSetLastNTError (Status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Length = 0;
|
||||
|
||||
if (lpDeviceName != NULL)
|
||||
{
|
||||
/* Open the lpDeviceName link object */
|
||||
RtlInitUnicodeString (&UnicodeString,
|
||||
(PWSTR)lpDeviceName);
|
||||
InitializeObjectAttributes (&ObjectAttributes,
|
||||
&UnicodeString,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
DirectoryHandle,
|
||||
NULL);
|
||||
Status = NtOpenSymbolicLinkObject (&DeviceHandle,
|
||||
SYMBOLIC_LINK_QUERY,
|
||||
&ObjectAttributes);
|
||||
if (!NT_SUCCESS (Status))
|
||||
/* Open the '\??' directory */
|
||||
RtlInitUnicodeString(&UnicodeString, L"\\??");
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&UnicodeString,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
Status = NtOpenDirectoryObject(&DirectoryHandle,
|
||||
DIRECTORY_QUERY,
|
||||
&ObjectAttributes);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
WARN ("NtOpenSymbolicLinkObject() failed (Status %lx)\n", Status);
|
||||
NtClose (DirectoryHandle);
|
||||
BaseSetLastNTError (Status);
|
||||
return 0;
|
||||
WARN("NtOpenDirectoryObject() failed (Status %lx)\n", Status);
|
||||
BaseSetLastNTError(Status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Query link target */
|
||||
UnicodeString.Length = 0;
|
||||
UnicodeString.MaximumLength = (USHORT)ucchMax * sizeof(WCHAR);
|
||||
UnicodeString.Buffer = lpTargetPath;
|
||||
Length = 0;
|
||||
|
||||
ReturnLength = 0;
|
||||
Status = NtQuerySymbolicLinkObject (DeviceHandle,
|
||||
&UnicodeString,
|
||||
&ReturnLength);
|
||||
NtClose (DeviceHandle);
|
||||
NtClose (DirectoryHandle);
|
||||
if (!NT_SUCCESS (Status))
|
||||
if (lpDeviceName != NULL)
|
||||
{
|
||||
WARN ("NtQuerySymbolicLinkObject() failed (Status %lx)\n", Status);
|
||||
BaseSetLastNTError (Status);
|
||||
return 0;
|
||||
}
|
||||
/* Open the lpDeviceName link object */
|
||||
RtlInitUnicodeString(&UnicodeString, (PWSTR)lpDeviceName);
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&UnicodeString,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
DirectoryHandle,
|
||||
NULL);
|
||||
Status = NtOpenSymbolicLinkObject(&DeviceHandle,
|
||||
SYMBOLIC_LINK_QUERY,
|
||||
&ObjectAttributes);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
WARN("NtOpenSymbolicLinkObject() failed (Status %lx)\n", Status);
|
||||
NtClose(DirectoryHandle);
|
||||
BaseSetLastNTError(Status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
TRACE ("ReturnLength: %lu\n", ReturnLength);
|
||||
TRACE ("TargetLength: %hu\n", UnicodeString.Length);
|
||||
TRACE ("Target: '%wZ'\n", &UnicodeString);
|
||||
/* Query link target */
|
||||
UnicodeString.Length = 0;
|
||||
UnicodeString.MaximumLength = (USHORT)ucchMax * sizeof(WCHAR);
|
||||
UnicodeString.Buffer = lpTargetPath;
|
||||
|
||||
Length = UnicodeString.Length / sizeof(WCHAR);
|
||||
if (Length < ucchMax)
|
||||
{
|
||||
/* Append null-charcter */
|
||||
lpTargetPath[Length] = UNICODE_NULL;
|
||||
Length++;
|
||||
ReturnLength = 0;
|
||||
Status = NtQuerySymbolicLinkObject(DeviceHandle,
|
||||
&UnicodeString,
|
||||
&ReturnLength);
|
||||
NtClose(DeviceHandle);
|
||||
NtClose(DirectoryHandle);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
WARN("NtQuerySymbolicLinkObject() failed (Status %lx)\n", Status);
|
||||
BaseSetLastNTError(Status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
TRACE("ReturnLength: %lu\n", ReturnLength);
|
||||
TRACE("TargetLength: %hu\n", UnicodeString.Length);
|
||||
TRACE("Target: '%wZ'\n", &UnicodeString);
|
||||
|
||||
Length = UnicodeString.Length / sizeof(WCHAR);
|
||||
if (Length < ucchMax)
|
||||
{
|
||||
/* Append null-charcter */
|
||||
lpTargetPath[Length] = UNICODE_NULL;
|
||||
Length++;
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE("Buffer is too small\n");
|
||||
BaseSetLastNTError(STATUS_BUFFER_TOO_SMALL);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE ("Buffer is too small\n");
|
||||
BaseSetLastNTError (STATUS_BUFFER_TOO_SMALL);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RestartScan = TRUE;
|
||||
Context = 0;
|
||||
Ptr = lpTargetPath;
|
||||
DirInfo = (POBJECT_DIRECTORY_INFORMATION)Buffer;
|
||||
RestartScan = TRUE;
|
||||
Context = 0;
|
||||
Ptr = lpTargetPath;
|
||||
DirInfo = (POBJECT_DIRECTORY_INFORMATION)Buffer;
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
Status = NtQueryDirectoryObject (DirectoryHandle,
|
||||
Buffer,
|
||||
sizeof (Buffer),
|
||||
TRUE,
|
||||
RestartScan,
|
||||
&Context,
|
||||
&ReturnLength);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
if (Status == STATUS_NO_MORE_ENTRIES)
|
||||
{
|
||||
/* Terminate the buffer */
|
||||
*Ptr = UNICODE_NULL;
|
||||
Length++;
|
||||
while (TRUE)
|
||||
{
|
||||
Status = NtQueryDirectoryObject(DirectoryHandle,
|
||||
Buffer,
|
||||
sizeof(Buffer),
|
||||
TRUE,
|
||||
RestartScan,
|
||||
&Context,
|
||||
&ReturnLength);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
if (Status == STATUS_NO_MORE_ENTRIES)
|
||||
{
|
||||
/* Terminate the buffer */
|
||||
*Ptr = UNICODE_NULL;
|
||||
Length++;
|
||||
|
||||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
Length = 0;
|
||||
}
|
||||
BaseSetLastNTError (Status);
|
||||
break;
|
||||
}
|
||||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
Length = 0;
|
||||
}
|
||||
BaseSetLastNTError(Status);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!wcscmp (DirInfo->TypeName.Buffer, L"SymbolicLink"))
|
||||
{
|
||||
TRACE ("Name: '%wZ'\n", &DirInfo->Name);
|
||||
if (!wcscmp(DirInfo->TypeName.Buffer, L"SymbolicLink"))
|
||||
{
|
||||
TRACE("Name: '%wZ'\n", &DirInfo->Name);
|
||||
|
||||
NameLength = DirInfo->Name.Length / sizeof(WCHAR);
|
||||
if (Length + NameLength + 1 >= ucchMax)
|
||||
{
|
||||
Length = 0;
|
||||
BaseSetLastNTError (STATUS_BUFFER_TOO_SMALL);
|
||||
break;
|
||||
}
|
||||
NameLength = DirInfo->Name.Length / sizeof(WCHAR);
|
||||
if (Length + NameLength + 1 >= ucchMax)
|
||||
{
|
||||
Length = 0;
|
||||
BaseSetLastNTError (STATUS_BUFFER_TOO_SMALL);
|
||||
break;
|
||||
}
|
||||
|
||||
memcpy (Ptr,
|
||||
DirInfo->Name.Buffer,
|
||||
DirInfo->Name.Length);
|
||||
Ptr += NameLength;
|
||||
Length += NameLength;
|
||||
*Ptr = UNICODE_NULL;
|
||||
Ptr++;
|
||||
Length++;
|
||||
}
|
||||
memcpy(Ptr, DirInfo->Name.Buffer, DirInfo->Name.Length);
|
||||
Ptr += NameLength;
|
||||
Length += NameLength;
|
||||
*Ptr = UNICODE_NULL;
|
||||
Ptr++;
|
||||
Length++;
|
||||
}
|
||||
|
||||
RestartScan = FALSE;
|
||||
RestartScan = FALSE;
|
||||
}
|
||||
|
||||
NtClose(DirectoryHandle);
|
||||
}
|
||||
|
||||
NtClose (DirectoryHandle);
|
||||
}
|
||||
|
||||
return Length;
|
||||
return Length;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
Loading…
Reference in a new issue