Blame psxscl.local.patch

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