mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 22:33:00 +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;
|
DEV_BROADCAST_VOLUME dbcv;
|
||||||
BOOL Result = TRUE;
|
BOOL Result = TRUE;
|
||||||
DWORD dwRecipients;
|
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;
|
BSM_type BSM_ptr;
|
||||||
|
|
||||||
if ( (dwFlags & 0xFFFFFFF0) ||
|
if ( (dwFlags & 0xFFFFFFF0) ||
|
||||||
|
@ -241,73 +241,62 @@ QueryDosDeviceA(
|
||||||
DWORD ucchMax
|
DWORD ucchMax
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UNICODE_STRING DeviceNameU;
|
UNICODE_STRING DeviceNameU;
|
||||||
UNICODE_STRING TargetPathU;
|
UNICODE_STRING TargetPathU;
|
||||||
ANSI_STRING TargetPathA;
|
ANSI_STRING TargetPathA;
|
||||||
DWORD Length;
|
DWORD Length;
|
||||||
DWORD CurrentLength;
|
DWORD CurrentLength;
|
||||||
PWCHAR Buffer;
|
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)
|
if (lpDeviceName)
|
||||||
{
|
{
|
||||||
RtlFreeHeap (RtlGetProcessHeap (),
|
if (!RtlCreateUnicodeStringFromAsciiz(&DeviceNameU,
|
||||||
0,
|
(LPSTR)lpDeviceName))
|
||||||
DeviceNameU.Buffer);
|
{
|
||||||
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SetLastError (ERROR_NOT_ENOUGH_MEMORY);
|
Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, ucchMax * sizeof(WCHAR));
|
||||||
return 0;
|
if (Buffer == NULL)
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
if (lpDeviceName)
|
||||||
TargetPathU.MaximumLength = TargetPathU.Length = (USHORT)CurrentLength * sizeof(WCHAR);
|
{
|
||||||
|
RtlFreeHeap(RtlGetProcessHeap(), 0, DeviceNameU.Buffer);
|
||||||
TargetPathA.Length = 0;
|
}
|
||||||
TargetPathA.MaximumLength = (USHORT)CurrentLength;
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
|
return 0;
|
||||||
RtlUnicodeStringToAnsiString (&TargetPathA,
|
|
||||||
&TargetPathU,
|
|
||||||
FALSE);
|
|
||||||
ucchMax -= CurrentLength;
|
|
||||||
TargetPathA.Buffer += TargetPathA.Length;
|
|
||||||
TargetPathU.Buffer += TargetPathU.Length / sizeof(WCHAR);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
RtlFreeHeap (RtlGetProcessHeap (),
|
Length = QueryDosDeviceW(lpDeviceName ? DeviceNameU.Buffer : NULL,
|
||||||
0,
|
Buffer, ucchMax);
|
||||||
Buffer);
|
if (Length != 0)
|
||||||
if (lpDeviceName)
|
{
|
||||||
{
|
TargetPathA.Buffer = lpTargetPath;
|
||||||
RtlFreeHeap (RtlGetProcessHeap (),
|
TargetPathU.Buffer = Buffer;
|
||||||
0,
|
ucchMax = Length;
|
||||||
DeviceNameU.Buffer);
|
|
||||||
}
|
while (ucchMax)
|
||||||
return Length;
|
{
|
||||||
|
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
|
DWORD ucchMax
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
POBJECT_DIRECTORY_INFORMATION DirInfo;
|
POBJECT_DIRECTORY_INFORMATION DirInfo;
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
UNICODE_STRING UnicodeString;
|
UNICODE_STRING UnicodeString;
|
||||||
HANDLE DirectoryHandle;
|
HANDLE DirectoryHandle;
|
||||||
HANDLE DeviceHandle;
|
HANDLE DeviceHandle;
|
||||||
ULONG ReturnLength;
|
ULONG ReturnLength;
|
||||||
ULONG NameLength;
|
ULONG NameLength;
|
||||||
ULONG Length;
|
ULONG Length;
|
||||||
ULONG Context;
|
ULONG Context;
|
||||||
BOOLEAN RestartScan;
|
BOOLEAN RestartScan;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
UCHAR Buffer[512];
|
UCHAR Buffer[512];
|
||||||
PWSTR Ptr;
|
PWSTR Ptr;
|
||||||
|
|
||||||
/* Open the '\??' directory */
|
/* Open the '\??' directory */
|
||||||
RtlInitUnicodeString (&UnicodeString,
|
RtlInitUnicodeString(&UnicodeString, L"\\??");
|
||||||
L"\\??");
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
InitializeObjectAttributes (&ObjectAttributes,
|
&UnicodeString,
|
||||||
&UnicodeString,
|
OBJ_CASE_INSENSITIVE,
|
||||||
OBJ_CASE_INSENSITIVE,
|
NULL,
|
||||||
NULL,
|
NULL);
|
||||||
NULL);
|
Status = NtOpenDirectoryObject(&DirectoryHandle,
|
||||||
Status = NtOpenDirectoryObject (&DirectoryHandle,
|
DIRECTORY_QUERY,
|
||||||
DIRECTORY_QUERY,
|
&ObjectAttributes);
|
||||||
&ObjectAttributes);
|
if (!NT_SUCCESS(Status))
|
||||||
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))
|
|
||||||
{
|
{
|
||||||
WARN ("NtOpenSymbolicLinkObject() failed (Status %lx)\n", Status);
|
WARN("NtOpenDirectoryObject() failed (Status %lx)\n", Status);
|
||||||
NtClose (DirectoryHandle);
|
BaseSetLastNTError(Status);
|
||||||
BaseSetLastNTError (Status);
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Query link target */
|
Length = 0;
|
||||||
UnicodeString.Length = 0;
|
|
||||||
UnicodeString.MaximumLength = (USHORT)ucchMax * sizeof(WCHAR);
|
|
||||||
UnicodeString.Buffer = lpTargetPath;
|
|
||||||
|
|
||||||
ReturnLength = 0;
|
if (lpDeviceName != NULL)
|
||||||
Status = NtQuerySymbolicLinkObject (DeviceHandle,
|
|
||||||
&UnicodeString,
|
|
||||||
&ReturnLength);
|
|
||||||
NtClose (DeviceHandle);
|
|
||||||
NtClose (DirectoryHandle);
|
|
||||||
if (!NT_SUCCESS (Status))
|
|
||||||
{
|
{
|
||||||
WARN ("NtQuerySymbolicLinkObject() failed (Status %lx)\n", Status);
|
/* Open the lpDeviceName link object */
|
||||||
BaseSetLastNTError (Status);
|
RtlInitUnicodeString(&UnicodeString, (PWSTR)lpDeviceName);
|
||||||
return 0;
|
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);
|
/* Query link target */
|
||||||
TRACE ("TargetLength: %hu\n", UnicodeString.Length);
|
UnicodeString.Length = 0;
|
||||||
TRACE ("Target: '%wZ'\n", &UnicodeString);
|
UnicodeString.MaximumLength = (USHORT)ucchMax * sizeof(WCHAR);
|
||||||
|
UnicodeString.Buffer = lpTargetPath;
|
||||||
|
|
||||||
Length = UnicodeString.Length / sizeof(WCHAR);
|
ReturnLength = 0;
|
||||||
if (Length < ucchMax)
|
Status = NtQuerySymbolicLinkObject(DeviceHandle,
|
||||||
{
|
&UnicodeString,
|
||||||
/* Append null-charcter */
|
&ReturnLength);
|
||||||
lpTargetPath[Length] = UNICODE_NULL;
|
NtClose(DeviceHandle);
|
||||||
Length++;
|
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
|
else
|
||||||
{
|
{
|
||||||
TRACE ("Buffer is too small\n");
|
RestartScan = TRUE;
|
||||||
BaseSetLastNTError (STATUS_BUFFER_TOO_SMALL);
|
Context = 0;
|
||||||
return 0;
|
Ptr = lpTargetPath;
|
||||||
}
|
DirInfo = (POBJECT_DIRECTORY_INFORMATION)Buffer;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RestartScan = TRUE;
|
|
||||||
Context = 0;
|
|
||||||
Ptr = lpTargetPath;
|
|
||||||
DirInfo = (POBJECT_DIRECTORY_INFORMATION)Buffer;
|
|
||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
Status = NtQueryDirectoryObject (DirectoryHandle,
|
Status = NtQueryDirectoryObject(DirectoryHandle,
|
||||||
Buffer,
|
Buffer,
|
||||||
sizeof (Buffer),
|
sizeof(Buffer),
|
||||||
TRUE,
|
TRUE,
|
||||||
RestartScan,
|
RestartScan,
|
||||||
&Context,
|
&Context,
|
||||||
&ReturnLength);
|
&ReturnLength);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
if (Status == STATUS_NO_MORE_ENTRIES)
|
if (Status == STATUS_NO_MORE_ENTRIES)
|
||||||
{
|
{
|
||||||
/* Terminate the buffer */
|
/* Terminate the buffer */
|
||||||
*Ptr = UNICODE_NULL;
|
*Ptr = UNICODE_NULL;
|
||||||
Length++;
|
Length++;
|
||||||
|
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Length = 0;
|
Length = 0;
|
||||||
}
|
}
|
||||||
BaseSetLastNTError (Status);
|
BaseSetLastNTError(Status);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wcscmp (DirInfo->TypeName.Buffer, L"SymbolicLink"))
|
if (!wcscmp(DirInfo->TypeName.Buffer, L"SymbolicLink"))
|
||||||
{
|
{
|
||||||
TRACE ("Name: '%wZ'\n", &DirInfo->Name);
|
TRACE("Name: '%wZ'\n", &DirInfo->Name);
|
||||||
|
|
||||||
NameLength = DirInfo->Name.Length / sizeof(WCHAR);
|
NameLength = DirInfo->Name.Length / sizeof(WCHAR);
|
||||||
if (Length + NameLength + 1 >= ucchMax)
|
if (Length + NameLength + 1 >= ucchMax)
|
||||||
{
|
{
|
||||||
Length = 0;
|
Length = 0;
|
||||||
BaseSetLastNTError (STATUS_BUFFER_TOO_SMALL);
|
BaseSetLastNTError (STATUS_BUFFER_TOO_SMALL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy (Ptr,
|
memcpy(Ptr, DirInfo->Name.Buffer, DirInfo->Name.Length);
|
||||||
DirInfo->Name.Buffer,
|
Ptr += NameLength;
|
||||||
DirInfo->Name.Length);
|
Length += NameLength;
|
||||||
Ptr += NameLength;
|
*Ptr = UNICODE_NULL;
|
||||||
Length += NameLength;
|
Ptr++;
|
||||||
*Ptr = UNICODE_NULL;
|
Length++;
|
||||||
Ptr++;
|
}
|
||||||
Length++;
|
|
||||||
}
|
|
||||||
|
|
||||||
RestartScan = FALSE;
|
RestartScan = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
NtClose(DirectoryHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
NtClose (DirectoryHandle);
|
return Length;
|
||||||
}
|
|
||||||
|
|
||||||
return Length;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue