mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 01:15:09 +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
1 changed files with 13 additions and 17 deletions
|
@ -97,7 +97,7 @@ SetupCopyFile(PWCHAR SourceFileName,
|
|||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
HANDLE FileHandleSource;
|
||||
HANDLE FileHandleDest;
|
||||
PIO_STATUS_BLOCK IoStatusBlock;
|
||||
static IO_STATUS_BLOCK IoStatusBlock;
|
||||
FILE_STANDARD_INFORMATION FileStandard;
|
||||
FILE_BASIC_INFORMATION FileBasic;
|
||||
PUCHAR Buffer;
|
||||
|
@ -111,9 +111,6 @@ SetupCopyFile(PWCHAR SourceFileName,
|
|||
|
||||
Buffer = NULL;
|
||||
|
||||
IoStatusBlock = RtlAllocateHeap(ProcessHeap, 0, sizeof(IO_STATUS_BLOCK));
|
||||
if (!IoStatusBlock) return STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
||||
#ifdef __REACTOS__
|
||||
RtlInitUnicodeString(&FileName,
|
||||
SourceFileName);
|
||||
|
@ -127,25 +124,25 @@ SetupCopyFile(PWCHAR SourceFileName,
|
|||
Status = NtOpenFile(&FileHandleSource,
|
||||
GENERIC_READ,
|
||||
&ObjectAttributes,
|
||||
IoStatusBlock,
|
||||
&IoStatusBlock,
|
||||
FILE_SHARE_READ,
|
||||
FILE_SEQUENTIAL_ONLY);
|
||||
if(!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("NtOpenFile failed: %x\n", Status);
|
||||
goto freemem;
|
||||
goto done;
|
||||
}
|
||||
#else
|
||||
FileHandleSource = CreateFileW(SourceFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
|
||||
if (FileHandleSource == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
goto freemem;
|
||||
goto done;
|
||||
}
|
||||
#endif
|
||||
|
||||
Status = NtQueryInformationFile(FileHandleSource,
|
||||
IoStatusBlock,
|
||||
&IoStatusBlock,
|
||||
&FileStandard,
|
||||
sizeof(FILE_STANDARD_INFORMATION),
|
||||
FileStandardInformation);
|
||||
|
@ -155,7 +152,7 @@ SetupCopyFile(PWCHAR SourceFileName,
|
|||
goto closesrc;
|
||||
}
|
||||
Status = NtQueryInformationFile(FileHandleSource,
|
||||
IoStatusBlock, &FileBasic,
|
||||
&IoStatusBlock,&FileBasic,
|
||||
sizeof(FILE_BASIC_INFORMATION),
|
||||
FileBasicInformation);
|
||||
if(!NT_SUCCESS(Status))
|
||||
|
@ -205,7 +202,7 @@ SetupCopyFile(PWCHAR SourceFileName,
|
|||
Status = NtCreateFile(&FileHandleDest,
|
||||
GENERIC_WRITE,
|
||||
&ObjectAttributes,
|
||||
IoStatusBlock,
|
||||
&IoStatusBlock,
|
||||
NULL,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
0,
|
||||
|
@ -220,25 +217,25 @@ SetupCopyFile(PWCHAR SourceFileName,
|
|||
}
|
||||
|
||||
RegionSize = (ULONG)PAGE_ROUND_UP(FileStandard.EndOfFile.u.LowPart);
|
||||
IoStatusBlock->Status = 0;
|
||||
IoStatusBlock.Status = 0;
|
||||
ByteOffset.QuadPart = 0;
|
||||
Status = NtWriteFile(FileHandleDest,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
IoStatusBlock,
|
||||
&IoStatusBlock,
|
||||
SourceFileMap,
|
||||
RegionSize,
|
||||
&ByteOffset,
|
||||
NULL);
|
||||
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;
|
||||
}
|
||||
/* Copy file date/time from source file */
|
||||
Status = NtSetInformationFile(FileHandleDest,
|
||||
IoStatusBlock,
|
||||
&IoStatusBlock,
|
||||
&FileBasic,
|
||||
sizeof(FILE_BASIC_INFORMATION),
|
||||
FileBasicInformation);
|
||||
|
@ -250,7 +247,7 @@ SetupCopyFile(PWCHAR SourceFileName,
|
|||
|
||||
/* shorten the file back to it's real size after completing the write */
|
||||
NtSetInformationFile(FileHandleDest,
|
||||
IoStatusBlock,
|
||||
&IoStatusBlock,
|
||||
&FileStandard.EndOfFile,
|
||||
sizeof(FILE_END_OF_FILE_INFORMATION),
|
||||
FileEndOfFileInformation);
|
||||
|
@ -262,8 +259,7 @@ SetupCopyFile(PWCHAR SourceFileName,
|
|||
NtClose(SourceFileSection);
|
||||
closesrc:
|
||||
NtClose(FileHandleSource);
|
||||
freemem:
|
||||
RtlFreeHeap(ProcessHeap, 0, IoStatusBlock);
|
||||
done:
|
||||
return(Status);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue