From 9d2131a4dd7e9ba6e5e11becbfd8081a6fdcd15a Mon Sep 17 00:00:00 2001 From: midipix Date: Jan 18 2017 07:15:45 +0000 Subject: ldso: control inheritance and share access when opening image or parent dir. --- diff --git a/include/pemagine/pemagine.h b/include/pemagine/pemagine.h index d5d0e66..d8d3159 100644 --- a/include/pemagine/pemagine.h +++ b/include/pemagine/pemagine.h @@ -202,7 +202,9 @@ pe_api int32_t pe_open_image_from_addr( void * addr, uintptr_t * buffer, uint32_t buffer_size, + uint32_t oattr, uint32_t desired_access, + uint32_t share_access, uint32_t open_options); @@ -211,7 +213,9 @@ pe_api int32_t pe_open_physical_parent_directory( void * href, uintptr_t * buffer, uint32_t buffer_size, + uint32_t oattr, uint32_t desired_access, + uint32_t share_access, uint32_t open_options); diff --git a/src/ldso/pe_open_image_from_addr.c b/src/ldso/pe_open_image_from_addr.c index 2729a18..810503c 100644 --- a/src/ldso/pe_open_image_from_addr.c +++ b/src/ldso/pe_open_image_from_addr.c @@ -19,7 +19,9 @@ pe_api int32_t pe_open_image_from_addr( __in void * addr, __out uintptr_t * buffer, __in uint32_t buffer_size, + __in uint32_t oattr, __in uint32_t desired_access, + __in uint32_t share_access, __in uint32_t open_options) { int32_t status; @@ -63,7 +65,7 @@ pe_api int32_t pe_open_image_from_addr( oa.len = sizeof(struct os_oa); oa.root_dir = 0; oa.obj_name = &path->section_name; - oa.obj_attr = 0; + oa.obj_attr = oattr; oa.sec_desc = 0; oa.sec_qos = 0; @@ -76,8 +78,7 @@ pe_api int32_t pe_open_image_from_addr( return zw_open_file( himage, desired_access, - &oa, - &iosb, - OS_FILE_SHARE_READ | OS_FILE_SHARE_WRITE, + &oa,&iosb, + share_access, open_options | OS_FILE_NON_DIRECTORY_FILE); } diff --git a/src/ldso/pe_open_physical_parent_directory.c b/src/ldso/pe_open_physical_parent_directory.c index 7166df5..5f535a3 100644 --- a/src/ldso/pe_open_physical_parent_directory.c +++ b/src/ldso/pe_open_physical_parent_directory.c @@ -14,7 +14,9 @@ int32_t pe_open_physical_parent_directory( __in void * href, __out uintptr_t * buffer, __in uint32_t buffer_size, + __in uint32_t oattr, __in uint32_t desired_access, + __in uint32_t share_access, __in uint32_t open_options) { int32_t status; @@ -85,7 +87,7 @@ int32_t pe_open_physical_parent_directory( oa.len = sizeof(struct os_oa); oa.root_dir = 0; oa.obj_name = path; - oa.obj_attr = 0; + oa.obj_attr = oattr; oa.sec_desc = 0; oa.sec_qos = 0; @@ -98,8 +100,7 @@ int32_t pe_open_physical_parent_directory( return zw_open_file( hparent, desired_access, - &oa, - &iosb, - OS_FILE_SHARE_READ | OS_FILE_SHARE_WRITE, + &oa,&iosb, + share_access, open_options | OS_FILE_DIRECTORY_FILE); }