diff --git a/dlls/wow64/struct32.h b/dlls/wow64/struct32.h index 776b1d4df35..03a57fc2c27 100644 --- a/dlls/wow64/struct32.h +++ b/dlls/wow64/struct32.h @@ -37,6 +37,34 @@ typedef struct UNICODE_STRING32 ObjectTypeName; } DIRECTORY_BASIC_INFORMATION32; +typedef struct +{ + ULONG BaseAddress; + ULONG Attributes; + LARGE_INTEGER Size; +} SECTION_BASIC_INFORMATION32; + +typedef struct +{ + ULONG TransferAddress; + ULONG ZeroBits; + ULONG MaximumStackSize; + ULONG CommittedStackSize; + ULONG SubSystemType; + USHORT MinorSubsystemVersion; + USHORT MajorSubsystemVersion; + USHORT MajorOperatingSystemVersion; + USHORT MinorOperatingSystemVersion; + USHORT ImageCharacteristics; + USHORT DllCharacteristics; + USHORT Machine; + BOOLEAN ImageContainsCode; + UCHAR ImageFlags; + ULONG LoaderFlags; + ULONG ImageFileSize; + ULONG CheckSum; +} SECTION_IMAGE_INFORMATION32; + typedef struct { DBG_STATE NewState; diff --git a/dlls/wow64/sync.c b/dlls/wow64/sync.c index c748668620a..0332f85e3ff 100644 --- a/dlls/wow64/sync.c +++ b/dlls/wow64/sync.c @@ -32,6 +32,37 @@ WINE_DEFAULT_DEBUG_CHANNEL(wow); +void put_section_image_info( SECTION_IMAGE_INFORMATION32 *info32, const SECTION_IMAGE_INFORMATION *info ) +{ + if (info->Machine == IMAGE_FILE_MACHINE_AMD64 || info->Machine == IMAGE_FILE_MACHINE_ARM64) + { + info32->TransferAddress = 0x81231234; /* sic */ + info32->MaximumStackSize = 0x100000; + info32->CommittedStackSize = 0x10000; + } + else + { + info32->TransferAddress = PtrToUlong( info->TransferAddress ); + info32->MaximumStackSize = info->MaximumStackSize; + info32->CommittedStackSize = info->CommittedStackSize; + } + info32->ZeroBits = info->ZeroBits; + info32->SubSystemType = info->SubSystemType; + info32->MinorSubsystemVersion = info->MinorSubsystemVersion; + info32->MajorSubsystemVersion = info->MajorSubsystemVersion; + info32->MajorOperatingSystemVersion = info->MajorOperatingSystemVersion; + info32->MinorOperatingSystemVersion = info->MinorOperatingSystemVersion; + info32->ImageCharacteristics = info->ImageCharacteristics; + info32->DllCharacteristics = info->DllCharacteristics; + info32->Machine = info->Machine; + info32->ImageContainsCode = info->ImageContainsCode; + info32->ImageFlags = info->ImageFlags; + info32->LoaderFlags = info->LoaderFlags; + info32->ImageFileSize = info->ImageFileSize; + info32->CheckSum = info->CheckSum; +} + + /********************************************************************** * wow64_NtCancelTimer */ @@ -201,6 +232,30 @@ NTSTATUS WINAPI wow64_NtCreateMutant( UINT *args ) } +/********************************************************************** + * wow64_NtCreateSection + */ +NTSTATUS WINAPI wow64_NtCreateSection( UINT *args ) +{ + ULONG *handle_ptr = get_ptr( &args ); + ACCESS_MASK access = get_ulong( &args ); + OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args ); + const LARGE_INTEGER *size = get_ptr( &args ); + ULONG protect = get_ulong( &args ); + ULONG flags = get_ulong( &args ); + HANDLE file = get_handle( &args ); + + struct object_attr64 attr; + HANDLE handle = 0; + NTSTATUS status; + + *handle_ptr = 0; + status = NtCreateSection( &handle, access, objattr_32to64( &attr, attr32 ), size, protect, flags, file ); + put_handle( handle_ptr, handle ); + return status; +} + + /********************************************************************** * wow64_NtCreateSemaphore */ @@ -414,6 +469,26 @@ NTSTATUS WINAPI wow64_NtOpenMutant( UINT *args ) } +/********************************************************************** + * wow64_NtOpenSection + */ +NTSTATUS WINAPI wow64_NtOpenSection( UINT *args ) +{ + ULONG *handle_ptr = get_ptr( &args ); + ACCESS_MASK access = get_ulong( &args ); + OBJECT_ATTRIBUTES32 *attr32 = get_ptr( &args ); + + struct object_attr64 attr; + HANDLE handle = 0; + NTSTATUS status; + + *handle_ptr = 0; + status = NtOpenSection( &handle, access, objattr_32to64( &attr, attr32 )); + put_handle( handle_ptr, handle ); + return status; +} + + /********************************************************************** * wow64_NtOpenSemaphore */ @@ -580,6 +655,59 @@ NTSTATUS WINAPI wow64_NtQueryPerformanceCounter( UINT *args ) } +/********************************************************************** + * wow64_NtQuerySection + */ +NTSTATUS WINAPI wow64_NtQuerySection( UINT *args ) +{ + HANDLE handle = get_handle( &args ); + SECTION_INFORMATION_CLASS class = get_ulong( &args ); + void *ptr = get_ptr( &args ); + SIZE_T size = get_ulong( &args ); + ULONG *ret_ptr = get_ptr( &args ); + + NTSTATUS status; + SIZE_T ret_size = 0; + + switch (class) + { + case SectionBasicInformation: + { + SECTION_BASIC_INFORMATION info; + SECTION_BASIC_INFORMATION32 *info32 = ptr; + + if (size < sizeof(*info32)) return STATUS_INFO_LENGTH_MISMATCH; + if (!(status = NtQuerySection( handle, class, &info, sizeof(info), &ret_size ))) + { + info32->BaseAddress = PtrToUlong( info.BaseAddress ); + info32->Attributes = info.Attributes; + info32->Size = info.Size; + ret_size = sizeof(*info32); + } + break; + } + case SectionImageInformation: + { + SECTION_IMAGE_INFORMATION info; + SECTION_IMAGE_INFORMATION32 *info32 = ptr; + + if (size < sizeof(*info32)) return STATUS_INFO_LENGTH_MISMATCH; + if (!(status = NtQuerySection( handle, class, &info, sizeof(info), &ret_size ))) + { + put_section_image_info( info32, &info ); + ret_size = sizeof(*info32); + } + break; + } + default: + FIXME( "class %u not implemented\n", class ); + return STATUS_NOT_IMPLEMENTED; + } + put_size( ret_ptr, ret_size ); + return status; +} + + /********************************************************************** * wow64_NtQuerySemaphore */ diff --git a/dlls/wow64/syscall.h b/dlls/wow64/syscall.h index 91552953088..3d57b6c3a15 100644 --- a/dlls/wow64/syscall.h +++ b/dlls/wow64/syscall.h @@ -35,6 +35,7 @@ SYSCALL_ENTRY( NtCreateJobObject ) \ SYSCALL_ENTRY( NtCreateKeyedEvent ) \ SYSCALL_ENTRY( NtCreateMutant ) \ + SYSCALL_ENTRY( NtCreateSection ) \ SYSCALL_ENTRY( NtCreateSemaphore ) \ SYSCALL_ENTRY( NtCreateSymbolicLinkObject ) \ SYSCALL_ENTRY( NtCreateTimer ) \ @@ -49,6 +50,7 @@ SYSCALL_ENTRY( NtOpenJobObject ) \ SYSCALL_ENTRY( NtOpenKeyedEvent ) \ SYSCALL_ENTRY( NtOpenMutant ) \ + SYSCALL_ENTRY( NtOpenSection ) \ SYSCALL_ENTRY( NtOpenSemaphore ) \ SYSCALL_ENTRY( NtOpenSymbolicLinkObject ) \ SYSCALL_ENTRY( NtOpenTimer ) \ @@ -62,6 +64,7 @@ SYSCALL_ENTRY( NtQueryIoCompletion ) \ SYSCALL_ENTRY( NtQueryMutant ) \ SYSCALL_ENTRY( NtQueryPerformanceCounter ) \ + SYSCALL_ENTRY( NtQuerySection ) \ SYSCALL_ENTRY( NtQuerySemaphore ) \ SYSCALL_ENTRY( NtQuerySymbolicLinkObject ) \ SYSCALL_ENTRY( NtQueryTimer ) \ diff --git a/dlls/wow64/wow64_private.h b/dlls/wow64/wow64_private.h index 9e3fd914045..c456c0d9352 100644 --- a/dlls/wow64/wow64_private.h +++ b/dlls/wow64/wow64_private.h @@ -137,4 +137,12 @@ static inline void put_handle( ULONG *handle32, HANDLE handle ) *handle32 = HandleToULong( handle ); } +static inline void put_size( ULONG *size32, SIZE_T size ) +{ + if (size32) *size32 = min( size, MAXDWORD ); +} + +extern void put_section_image_info( SECTION_IMAGE_INFORMATION32 *info32, + const SECTION_IMAGE_INFORMATION *info ) DECLSPEC_HIDDEN; + #endif /* __WOW64_PRIVATE_H */