Blame psxscl.local@lucio-vm.local.patch

Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
diff --git a/src/iofn/psx_iofn_fsdir.c b/src/iofn/psx_iofn_fsdir.c
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
index 53b3380..8bdd7d8 100644
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
--- a/src/iofn/psx_iofn_fsdir.c
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+++ b/src/iofn/psx_iofn_fsdir.c
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
@@ -52,10 +52,34 @@ static int32_t __fastcall __psx_iofn_fsdir_open_next(
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
 		path.buffer++;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
 	}
Lucio Andrés Illanes Albornoz (arab, vxp) 3aebd9
 
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	/* XXX */
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	uint32_t		status;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	static char		name_buffer[1024];
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	nt_unicode_string *	dev_name,full_path;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	iosb.info = 0;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	if ((status = __ntapi->zw_query_object(
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+			path_info->hat,NT_OBJECT_NAME_INFORMATION,
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+			name_buffer,sizeof(name_buffer),(uint32_t *)&iosb.info)))
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+		return status;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	else {
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+		dev_name = (nt_unicode_string *)name_buffer;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+		if ((dev_name->strlen > 2) && 
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+			(dev_name->buffer[(dev_name->strlen - 1) / 2] != '\\')) {
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+			dev_name->buffer[dev_name->strlen / 2] = '\\';
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+			dev_name->strlen += 2;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+		}
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+		__ntapi->tt_generic_memcpy(&dev_name->buffer[dev_name->strlen / 2],
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+			path.buffer,path.strlen);
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+		dev_name->strlen += path.strlen;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+		full_path.maxlen = (full_path.strlen = dev_name->strlen) + 2;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+		full_path.buffer = dev_name->buffer;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	}
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
 	/* oa */
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
 	oa.len = sizeof(nt_oa);
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
-	oa.root_dir = path_info->hat;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
-	oa.obj_name = &pat;;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	oa.root_dir = 0;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	oa.obj_name = &full_path;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
 	oa.obj_attr = path_info->ntobjattr;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
 	oa.sec_desc = 0;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
 	oa.sec_qos  = 0;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
@@ -73,6 +97,45 @@ static int32_t __fastcall __psx_iofn_fsdir_open_next(
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
 		0,0);
Lucio Andrés Illanes Albornoz (arab, vxp) 3aebd9
 }
Lucio Andrés Illanes Albornoz (arab, vxp) 3aebd9
 
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+static int32_t __stdcall __psx_iofn_fsdir_open_parent_directory(
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	void **		hparent,
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	void *		hdir,
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	uintptr_t *	buffer,
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	uint32_t	buffer_size,
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	uint32_t	desired_access,
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	uint32_t	open_options,
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	int32_t *	type)
Lucio Andrés Illanes Albornoz (arab, vxp) 3aebd9
+{
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	uint32_t			status;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	nt_io_status_block		iosb;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	nt_file_internal_information	fii_hdir,fii_hroot;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	struct __psx_tlca *		tlca;
Lucio Andrés Illanes Albornoz (arab, vxp) 3aebd9
+
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	tlca = __tlca_self();
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	status = __ntapi->zw_query_information_file(
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+			hdir,&iosb,&fii_hdir,sizeof(fii_hdir),
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+			NT_FILE_INTERNAL_INFORMATION);
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	if (status)
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+		return status;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	status = __ntapi->zw_query_information_file(
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+			tlca->ctx->root.hfile,&iosb,&fii_hroot,sizeof(fii_hroot),
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+			NT_FILE_INTERNAL_INFORMATION);
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	if (status)
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+		return status;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	if (fii_hdir.index_number.quad == fii_hroot.index_number.quad) {
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+		*hparent = hdir;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+		*type = PSX_FD_OS_FS_ROOT;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+		status = NT_STATUS_SUCCESS;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	} else
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+		status = __ntapi->tt_open_physical_parent_directory(
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+			hparent,hdir,
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+			buffer,
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+			buffer_size,
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+			desired_access,
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+			open_options,type);
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	return status;
Lucio Andrés Illanes Albornoz (arab, vxp) 3aebd9
+}
Lucio Andrés Illanes Albornoz (arab, vxp) 3aebd9
+
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
 int32_t	__stdcall __psx_iofn_fsdir_getvents(
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
 	void *			hfile,
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
 	void *			hevent,
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
@@ -133,6 +196,6 @@ void __fastcall __psx_iofn_fsdir_init(struct __iovtbl * iovtbl)
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
 	iovtbl->getdents		= __ntapi->zw_query_directory_file;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
 	iovtbl->getvents		= __psx_iofn_fsdir_getvents;
Lucio Andrés Illanes Albornoz (arab, vxp) 3aebd9
 
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
-	iovtbl->open_logical_parent  = __ntapi->tt_open_logical_parent_directory;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
-	iovtbl->open_physical_parent = __ntapi->tt_open_physical_parent_directory;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	iovtbl->open_logical_parent  = __psx_iofn_fsdir_open_parent_directory;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	iovtbl->open_physical_parent = __psx_iofn_fsdir_open_parent_directory;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
 }
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
diff --git a/src/path/psx_path_parse.c b/src/path/psx_path_parse.c
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
index ff4d933..08431b6 100644
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
--- a/src/path/psx_path_parse.c
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+++ b/src/path/psx_path_parse.c
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
@@ -48,8 +48,8 @@ int32_t __fastcall __psx_parse_normalized_path_utf8(
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
 			ch,
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
 			++(path_info->depth));
Lucio Andrés Illanes Albornoz (arab, vxp) 3aebd9
 
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
-		if (*(++ch)=='/') {
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
-			ch++;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+		if (ch[1]=='/') {
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+			ch+=2;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
 		}
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
 	}
Lucio Andrés Illanes Albornoz (arab, vxp) 3aebd9
 
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
diff --git a/src/path/psx_path_resolve.c b/src/path/psx_path_resolve.c
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
index 2bd615c..705e646 100644
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
--- a/src/path/psx_path_resolve.c
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+++ b/src/path/psx_path_resolve.c
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
@@ -260,7 +260,7 @@ static int __fastcall __path_swap_at(
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
 	int32_t			status;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
 
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
 	/* swap */
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
-	if (path_info->pathflags & PSX_PATH_CLOSE_AT)
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
+	if ((path_info->pathflags & PSX_PATH_CLOSE_AT) && (path_info->hat != path_info->hfile))
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
 		if ((status = __iovtbl[path_info->fdtypeat].close(path_info->hat)))
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
 			return status;
Lucio Andrés Illanes Albornoz (arab, vxp) 2696b7
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
diff --git a/src/process/_execve.c b/src/process/_execve.c
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
index a623d2a..80dd4a9 100644
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
--- a/src/process/_execve.c
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
+++ b/src/process/_execve.c
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
@@ -232,7 +232,7 @@ intptr_t __sys_execve(const unsigned char * path, const char ** argv, const char
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
 			NT_SECTION_QUERY|NT_SECTION_MAP_EXECUTE,
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
 			&oa,&ssize,
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
 			NT_PAGE_EXECUTE,
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
-			NT_SEC_IMAGE,
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
+			NT_SEC_RESERVE,
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
 			image->info.hfile)))
Lucio Andrés Illanes Albornoz (arab, vxp) 792796
 		return __execve_return(tlca,0,target,-ENOEXEC);
Lucio Andrés Illanes Albornoz (arab, vxp) 792796