mirror of
https://github.com/reactos/reactos.git
synced 2024-09-06 02:37:06 +00:00
Fix my previous "fix", which is even worse then original.
svn path=/trunk/; revision=27033
This commit is contained in:
parent
8c5a2928ed
commit
32740d717d
|
@ -97,7 +97,7 @@ SetupCopyFile(PWCHAR SourceFileName,
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
HANDLE FileHandleSource;
|
HANDLE FileHandleSource;
|
||||||
HANDLE FileHandleDest;
|
HANDLE FileHandleDest;
|
||||||
PIO_STATUS_BLOCK IoStatusBlock;
|
static IO_STATUS_BLOCK IoStatusBlock;
|
||||||
FILE_STANDARD_INFORMATION FileStandard;
|
FILE_STANDARD_INFORMATION FileStandard;
|
||||||
FILE_BASIC_INFORMATION FileBasic;
|
FILE_BASIC_INFORMATION FileBasic;
|
||||||
PUCHAR Buffer;
|
PUCHAR Buffer;
|
||||||
|
@ -111,9 +111,6 @@ SetupCopyFile(PWCHAR SourceFileName,
|
||||||
|
|
||||||
Buffer = NULL;
|
Buffer = NULL;
|
||||||
|
|
||||||
IoStatusBlock = RtlAllocateHeap(ProcessHeap, 0, sizeof(IO_STATUS_BLOCK));
|
|
||||||
if (!IoStatusBlock) return STATUS_INSUFFICIENT_RESOURCES;
|
|
||||||
|
|
||||||
#ifdef __REACTOS__
|
#ifdef __REACTOS__
|
||||||
RtlInitUnicodeString(&FileName,
|
RtlInitUnicodeString(&FileName,
|
||||||
SourceFileName);
|
SourceFileName);
|
||||||
|
@ -127,25 +124,25 @@ SetupCopyFile(PWCHAR SourceFileName,
|
||||||
Status = NtOpenFile(&FileHandleSource,
|
Status = NtOpenFile(&FileHandleSource,
|
||||||
GENERIC_READ,
|
GENERIC_READ,
|
||||||
&ObjectAttributes,
|
&ObjectAttributes,
|
||||||
IoStatusBlock,
|
&IoStatusBlock,
|
||||||
FILE_SHARE_READ,
|
FILE_SHARE_READ,
|
||||||
FILE_SEQUENTIAL_ONLY);
|
FILE_SEQUENTIAL_ONLY);
|
||||||
if(!NT_SUCCESS(Status))
|
if(!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("NtOpenFile failed: %x\n", Status);
|
DPRINT1("NtOpenFile failed: %x\n", Status);
|
||||||
goto freemem;
|
goto done;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
FileHandleSource = CreateFileW(SourceFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
|
FileHandleSource = CreateFileW(SourceFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
|
||||||
if (FileHandleSource == INVALID_HANDLE_VALUE)
|
if (FileHandleSource == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
Status = STATUS_UNSUCCESSFUL;
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
goto freemem;
|
goto done;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Status = NtQueryInformationFile(FileHandleSource,
|
Status = NtQueryInformationFile(FileHandleSource,
|
||||||
IoStatusBlock,
|
&IoStatusBlock,
|
||||||
&FileStandard,
|
&FileStandard,
|
||||||
sizeof(FILE_STANDARD_INFORMATION),
|
sizeof(FILE_STANDARD_INFORMATION),
|
||||||
FileStandardInformation);
|
FileStandardInformation);
|
||||||
|
@ -155,7 +152,7 @@ SetupCopyFile(PWCHAR SourceFileName,
|
||||||
goto closesrc;
|
goto closesrc;
|
||||||
}
|
}
|
||||||
Status = NtQueryInformationFile(FileHandleSource,
|
Status = NtQueryInformationFile(FileHandleSource,
|
||||||
IoStatusBlock, &FileBasic,
|
&IoStatusBlock,&FileBasic,
|
||||||
sizeof(FILE_BASIC_INFORMATION),
|
sizeof(FILE_BASIC_INFORMATION),
|
||||||
FileBasicInformation);
|
FileBasicInformation);
|
||||||
if(!NT_SUCCESS(Status))
|
if(!NT_SUCCESS(Status))
|
||||||
|
@ -205,7 +202,7 @@ SetupCopyFile(PWCHAR SourceFileName,
|
||||||
Status = NtCreateFile(&FileHandleDest,
|
Status = NtCreateFile(&FileHandleDest,
|
||||||
GENERIC_WRITE,
|
GENERIC_WRITE,
|
||||||
&ObjectAttributes,
|
&ObjectAttributes,
|
||||||
IoStatusBlock,
|
&IoStatusBlock,
|
||||||
NULL,
|
NULL,
|
||||||
FILE_ATTRIBUTE_NORMAL,
|
FILE_ATTRIBUTE_NORMAL,
|
||||||
0,
|
0,
|
||||||
|
@ -220,25 +217,25 @@ SetupCopyFile(PWCHAR SourceFileName,
|
||||||
}
|
}
|
||||||
|
|
||||||
RegionSize = (ULONG)PAGE_ROUND_UP(FileStandard.EndOfFile.u.LowPart);
|
RegionSize = (ULONG)PAGE_ROUND_UP(FileStandard.EndOfFile.u.LowPart);
|
||||||
IoStatusBlock->Status = 0;
|
IoStatusBlock.Status = 0;
|
||||||
ByteOffset.QuadPart = 0;
|
ByteOffset.QuadPart = 0;
|
||||||
Status = NtWriteFile(FileHandleDest,
|
Status = NtWriteFile(FileHandleDest,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
IoStatusBlock,
|
&IoStatusBlock,
|
||||||
SourceFileMap,
|
SourceFileMap,
|
||||||
RegionSize,
|
RegionSize,
|
||||||
&ByteOffset,
|
&ByteOffset,
|
||||||
NULL);
|
NULL);
|
||||||
if(!NT_SUCCESS(Status))
|
if(!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("NtWriteFile failed: %x:%x, iosb: %p src: %p, size: %x\n", Status, IoStatusBlock->Status, IoStatusBlock, SourceFileMap, RegionSize);
|
DPRINT1("NtWriteFile failed: %x:%x, iosb: %p src: %p, size: %x\n", Status, IoStatusBlock.Status, &IoStatusBlock, SourceFileMap, RegionSize);
|
||||||
goto closedest;
|
goto closedest;
|
||||||
}
|
}
|
||||||
/* Copy file date/time from source file */
|
/* Copy file date/time from source file */
|
||||||
Status = NtSetInformationFile(FileHandleDest,
|
Status = NtSetInformationFile(FileHandleDest,
|
||||||
IoStatusBlock,
|
&IoStatusBlock,
|
||||||
&FileBasic,
|
&FileBasic,
|
||||||
sizeof(FILE_BASIC_INFORMATION),
|
sizeof(FILE_BASIC_INFORMATION),
|
||||||
FileBasicInformation);
|
FileBasicInformation);
|
||||||
|
@ -250,7 +247,7 @@ SetupCopyFile(PWCHAR SourceFileName,
|
||||||
|
|
||||||
/* shorten the file back to it's real size after completing the write */
|
/* shorten the file back to it's real size after completing the write */
|
||||||
NtSetInformationFile(FileHandleDest,
|
NtSetInformationFile(FileHandleDest,
|
||||||
IoStatusBlock,
|
&IoStatusBlock,
|
||||||
&FileStandard.EndOfFile,
|
&FileStandard.EndOfFile,
|
||||||
sizeof(FILE_END_OF_FILE_INFORMATION),
|
sizeof(FILE_END_OF_FILE_INFORMATION),
|
||||||
FileEndOfFileInformation);
|
FileEndOfFileInformation);
|
||||||
|
@ -262,8 +259,7 @@ SetupCopyFile(PWCHAR SourceFileName,
|
||||||
NtClose(SourceFileSection);
|
NtClose(SourceFileSection);
|
||||||
closesrc:
|
closesrc:
|
||||||
NtClose(FileHandleSource);
|
NtClose(FileHandleSource);
|
||||||
freemem:
|
done:
|
||||||
RtlFreeHeap(ProcessHeap, 0, IoStatusBlock);
|
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue