ntdll: Implement ProcessImageInformation class in NtQueryInformationProcess().

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-05-26 13:23:21 +02:00
parent e076fff578
commit 54a7e592e4
8 changed files with 78 additions and 1 deletions

View File

@ -621,6 +621,29 @@ NTSTATUS WINAPI NtQueryInformationProcess(
else else
ret = STATUS_INVALID_PARAMETER; ret = STATUS_INVALID_PARAMETER;
break; break;
case ProcessImageInformation:
len = sizeof(SECTION_IMAGE_INFORMATION);
if (ProcessInformationLength == len)
{
if (ProcessInformation)
{
pe_image_info_t pe_info;
SERVER_START_REQ( get_process_info )
{
req->handle = wine_server_obj_handle( ProcessHandle );
wine_server_set_reply( req, &pe_info, sizeof(pe_info) );
if ((ret = wine_server_call( req )) == STATUS_SUCCESS)
virtual_fill_image_information( &pe_info, ProcessInformation );
}
SERVER_END_REQ;
}
else ret = STATUS_ACCESS_VIOLATION;
}
else ret = STATUS_INFO_LENGTH_MISMATCH;
break;
default: default:
FIXME("(%p,info_class=%d,%p,0x%08x,%p) Unknown information class\n", FIXME("(%p,info_class=%d,%p,0x%08x,%p) Unknown information class\n",
ProcessHandle,ProcessInformationClass, ProcessHandle,ProcessInformationClass,

View File

@ -1821,6 +1821,34 @@ todo_wine
heap_free(buffer); heap_free(buffer);
} }
static void test_query_process_image_info(void)
{
IMAGE_NT_HEADERS *nt = RtlImageNtHeader( NtCurrentTeb()->Peb->ImageBaseAddress );
NTSTATUS status;
SECTION_IMAGE_INFORMATION info;
ULONG len;
status = pNtQueryInformationProcess( NULL, ProcessImageInformation, &info, sizeof(info), &len );
ok( status == STATUS_INVALID_HANDLE || broken(status == STATUS_INVALID_PARAMETER), /* winxp */
"got %08x\n", status);
status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessImageInformation, &info, sizeof(info)-1, &len );
ok( status == STATUS_INFO_LENGTH_MISMATCH, "got %08x\n", status);
status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessImageInformation, &info, sizeof(info)+1, &len );
ok( status == STATUS_INFO_LENGTH_MISMATCH, "got %08x\n", status);
memset( &info, 0xcc, sizeof(info) );
status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessImageInformation, &info, sizeof(info), &len );
ok( status == STATUS_SUCCESS, "got %08x\n", status);
ok( len == sizeof(info), "wrong len %u\n", len );
ok( info.SubsystemVersionHigh == nt->OptionalHeader.MajorSubsystemVersion, "wrong major version %x/%x\n",
info.SubsystemVersionHigh, nt->OptionalHeader.MajorSubsystemVersion );
ok( info.SubsystemVersionLow == nt->OptionalHeader.MinorSubsystemVersion, "wrong minor version %x/%x\n",
info.SubsystemVersionLow, nt->OptionalHeader.MinorSubsystemVersion );
}
static void test_query_process_debug_object_handle(int argc, char **argv) static void test_query_process_debug_object_handle(int argc, char **argv)
{ {
char cmdline[MAX_PATH]; char cmdline[MAX_PATH];
@ -2741,6 +2769,10 @@ START_TEST(info)
trace("Starting test_process_debug_flags()\n"); trace("Starting test_process_debug_flags()\n");
test_query_process_debug_flags(argc, argv); test_query_process_debug_flags(argc, argv);
/* 0x25 ProcessImageInformation */
trace("Starting test_process_image_info()\n");
test_query_process_image_info();
/* 0x4C SystemFirmwareTableInformation */ /* 0x4C SystemFirmwareTableInformation */
trace("Starting test_query_firmware()\n"); trace("Starting test_query_firmware()\n");
test_query_firmware(); test_query_firmware();

View File

@ -962,6 +962,7 @@ struct get_process_info_reply
client_cpu_t cpu; client_cpu_t cpu;
short int debugger_present; short int debugger_present;
short int debug_children; short int debug_children;
/* VARARG(image,pe_image_info); */
}; };
@ -6684,7 +6685,7 @@ union generic_reply
/* ### protocol_version begin ### */ /* ### protocol_version begin ### */
#define SERVER_PROTOCOL_VERSION 603 #define SERVER_PROTOCOL_VERSION 604
/* ### protocol_version end ### */ /* ### protocol_version end ### */

View File

@ -171,6 +171,7 @@ extern struct mapping *get_mapping_obj( struct process *process, obj_handle_t ha
unsigned int access ); unsigned int access );
extern struct file *get_mapping_file( struct process *process, client_ptr_t base, extern struct file *get_mapping_file( struct process *process, client_ptr_t base,
unsigned int access, unsigned int sharing ); unsigned int access, unsigned int sharing );
extern const pe_image_info_t *get_mapping_image_info( struct process *process, client_ptr_t base );
extern void free_mapped_views( struct process *process ); extern void free_mapped_views( struct process *process );
extern int get_page_size(void); extern int get_page_size(void);

View File

@ -127,6 +127,7 @@ struct memory_view
struct fd *fd; /* fd for mapped file */ struct fd *fd; /* fd for mapped file */
struct ranges *committed; /* list of committed ranges in this mapping */ struct ranges *committed; /* list of committed ranges in this mapping */
struct shared_map *shared; /* temp file for shared PE mapping */ struct shared_map *shared; /* temp file for shared PE mapping */
pe_image_info_t image; /* image info (for PE image mapping) */
unsigned int flags; /* SEC_* flags */ unsigned int flags; /* SEC_* flags */
client_ptr_t base; /* view base address (in process addr space) */ client_ptr_t base; /* view base address (in process addr space) */
mem_size_t size; /* view size */ mem_size_t size; /* view size */
@ -894,6 +895,15 @@ struct file *get_mapping_file( struct process *process, client_ptr_t base,
return create_file_for_fd_obj( view->fd, access, sharing ); return create_file_for_fd_obj( view->fd, access, sharing );
} }
/* get the image info for a SEC_IMAGE mapping */
const pe_image_info_t *get_mapping_image_info( struct process *process, client_ptr_t base )
{
struct memory_view *view = find_mapped_view( process, base );
if (!view || !(view->flags & SEC_IMAGE)) return NULL;
return &view->image;
}
static void mapping_dump( struct object *obj, int verbose ) static void mapping_dump( struct object *obj, int verbose )
{ {
struct mapping *mapping = (struct mapping *)obj; struct mapping *mapping = (struct mapping *)obj;
@ -1062,6 +1072,7 @@ DECL_HANDLER(map_view)
view->fd = !is_fd_removable( mapping->fd ) ? (struct fd *)grab_object( mapping->fd ) : NULL; view->fd = !is_fd_removable( mapping->fd ) ? (struct fd *)grab_object( mapping->fd ) : NULL;
view->committed = mapping->committed ? (struct ranges *)grab_object( mapping->committed ) : NULL; view->committed = mapping->committed ? (struct ranges *)grab_object( mapping->committed ) : NULL;
view->shared = mapping->shared ? (struct shared_map *)grab_object( mapping->shared ) : NULL; view->shared = mapping->shared ? (struct shared_map *)grab_object( mapping->shared ) : NULL;
if (mapping->flags & SEC_IMAGE) view->image = mapping->image;
list_add_tail( &current->process->views, &view->entry ); list_add_tail( &current->process->views, &view->entry );
} }

View File

@ -1447,6 +1447,13 @@ DECL_HANDLER(get_process_info)
reply->cpu = process->cpu; reply->cpu = process->cpu;
reply->debugger_present = !!process->debugger; reply->debugger_present = !!process->debugger;
reply->debug_children = process->debug_children; reply->debug_children = process->debug_children;
if (get_reply_max_size())
{
const pe_image_info_t *info;
struct process_dll *exe = get_process_exe_module( process );
if (exe && (info = get_mapping_image_info( process, exe->base )))
set_reply_data( info, min( sizeof(*info), get_reply_max_size() ));
}
release_object( process ); release_object( process );
} }
} }

View File

@ -915,6 +915,7 @@ struct rawinput_device
client_cpu_t cpu; /* CPU that this process is running on */ client_cpu_t cpu; /* CPU that this process is running on */
short int debugger_present; /* process is being debugged */ short int debugger_present; /* process is being debugged */
short int debug_children; /* inherit debugger to child processes */ short int debug_children; /* inherit debugger to child processes */
VARARG(image,pe_image_info); /* image info for main exe */
@END @END

View File

@ -1389,6 +1389,7 @@ static void dump_get_process_info_reply( const struct get_process_info_reply *re
dump_client_cpu( ", cpu=", &req->cpu ); dump_client_cpu( ", cpu=", &req->cpu );
fprintf( stderr, ", debugger_present=%d", req->debugger_present ); fprintf( stderr, ", debugger_present=%d", req->debugger_present );
fprintf( stderr, ", debug_children=%d", req->debug_children ); fprintf( stderr, ", debug_children=%d", req->debug_children );
dump_varargs_pe_image_info( ", image=", cur_size );
} }
static void dump_get_process_vm_counters_request( const struct get_process_vm_counters_request *req ) static void dump_get_process_vm_counters_request( const struct get_process_vm_counters_request *req )