Alexandre Julliard : ntdll: Avoid calling NtReadFile() from the Unix side.
Alexandre Julliard
julliard at winehq.org
Thu Jul 8 16:43:50 CDT 2021
Module: wine
Branch: master
Commit: 3f9d49809d4560c6739597d85d72316e207a0d10
URL: https://source.winehq.org/git/wine.git/?a=commit;h=3f9d49809d4560c6739597d85d72316e207a0d10
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Jul 8 16:49:53 2021 +0200
ntdll: Avoid calling NtReadFile() from the Unix side.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/unix/process.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/dlls/ntdll/unix/process.c b/dlls/ntdll/unix/process.c
index b85132af131..77fb81fe404 100644
--- a/dlls/ntdll/unix/process.c
+++ b/dlls/ntdll/unix/process.c
@@ -144,7 +144,7 @@ static char **build_argv( const UNICODE_STRING *cmdline, int reserved )
/***********************************************************************
* get_so_file_info
*/
-static BOOL get_so_file_info( HANDLE handle, pe_image_info_t *info )
+static BOOL get_so_file_info( int fd, pe_image_info_t *info )
{
union
{
@@ -185,12 +185,9 @@ static BOOL get_so_file_info( HANDLE handle, pe_image_info_t *info )
IMAGE_DOS_HEADER mz;
} header;
- IO_STATUS_BLOCK io;
- LARGE_INTEGER offset;
+ off_t pos;
- offset.QuadPart = 0;
- if (NtReadFile( handle, 0, NULL, NULL, &io, &header, sizeof(header), &offset, 0 )) return FALSE;
- if (io.Information != sizeof(header)) return FALSE;
+ if (pread( fd, &header, sizeof(header), 0 ) != sizeof(header)) return FALSE;
if (!memcmp( header.elf.magic, "\177ELF", 4 ))
{
@@ -213,20 +210,19 @@ static BOOL get_so_file_info( HANDLE handle, pe_image_info_t *info )
if (header.elf.type != 3 /* ET_DYN */) return FALSE;
if (header.elf.class == 2 /* ELFCLASS64 */)
{
- offset.QuadPart = header.elf64.phoff;
+ pos = header.elf64.phoff;
phnum = header.elf64.phnum;
}
else
{
- offset.QuadPart = header.elf.phoff;
+ pos = header.elf.phoff;
phnum = header.elf.phnum;
}
while (phnum--)
{
- if (NtReadFile( handle, 0, NULL, NULL, &io, &type, sizeof(type), &offset, 0 )) return FALSE;
- if (io.Information < sizeof(type)) return FALSE;
+ if (pread( fd, &type, sizeof(type), pos ) != sizeof(type)) return FALSE;
if (type == 3 /* PT_INTERP */) return FALSE;
- offset.QuadPart += (header.elf.class == 2) ? 56 : 32;
+ pos += (header.elf.class == 2) ? 56 : 32;
}
return TRUE;
}
@@ -290,7 +286,13 @@ static NTSTATUS get_pe_file_info( OBJECT_ATTRIBUTES *attr, HANDLE *handle, pe_im
}
else if (status == STATUS_INVALID_IMAGE_NOT_MZ)
{
- if (get_so_file_info( *handle, info )) return STATUS_SUCCESS;
+ int unix_fd, needs_close;
+
+ if (!server_get_unix_fd( *handle, FILE_READ_DATA, &unix_fd, &needs_close, NULL, NULL ))
+ {
+ if (get_so_file_info( unix_fd, info )) status = STATUS_SUCCESS;
+ if (needs_close) close( unix_fd );
+ }
}
return status;
}
More information about the wine-cvs
mailing list