summaryrefslogtreecommitdiffhomepage
path: root/psxscl.local.patch
blob: 1b3b9c02414b2b0ed177252fe9de587a4716d0bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
diff --git a/src/iofn/psx_iofn_fsdir.c b/src/iofn/psx_iofn_fsdir.c
index 53b3380..8bdd7d8 100644
--- a/src/iofn/psx_iofn_fsdir.c
+++ b/src/iofn/psx_iofn_fsdir.c
@@ -52,10 +52,34 @@ static int32_t __fastcall __psx_iofn_fsdir_open_next(
 		path.buffer++;
 	}
 
+	/* XXX */
+	uint32_t		status;
+	static char		name_buffer[1024];
+	nt_unicode_string *	dev_name,full_path;
+	
+	iosb.info = 0;
+	if ((status = __ntapi->zw_query_object(
+			path_info->hat,NT_OBJECT_NAME_INFORMATION,
+			name_buffer,sizeof(name_buffer),(uint32_t *)&iosb.info)))
+		return status;
+	else {
+		dev_name = (nt_unicode_string *)name_buffer;
+		if ((dev_name->strlen > 2) && 
+			(dev_name->buffer[(dev_name->strlen - 1) / 2] != '\\')) {
+			dev_name->buffer[dev_name->strlen / 2] = '\\';
+			dev_name->strlen += 2;
+		}
+		__ntapi->tt_generic_memcpy(&dev_name->buffer[dev_name->strlen / 2],
+			path.buffer,path.strlen);
+		dev_name->strlen += path.strlen;
+		full_path.maxlen = (full_path.strlen = dev_name->strlen) + 2;
+		full_path.buffer = dev_name->buffer;
+	}
+
 	/* oa */
 	oa.len = sizeof(nt_oa);
-	oa.root_dir = path_info->hat;
-	oa.obj_name = &path;
+	oa.root_dir = 0;
+	oa.obj_name = &full_path;
 	oa.obj_attr = path_info->ntobjattr;
 	oa.sec_desc = 0;
 	oa.sec_qos  = 0;
@@ -73,6 +97,45 @@ static int32_t __fastcall __psx_iofn_fsdir_open_next(
 		0,0);
 }
 
+static int32_t __stdcall __psx_iofn_fsdir_open_parent_directory(
+	void **		hparent,
+	void *		hdir,
+	uintptr_t *	buffer,
+	uint32_t	buffer_size,
+	uint32_t	desired_access,
+	uint32_t	open_options,
+	int32_t *	type)
+{
+	uint32_t			status;
+	nt_io_status_block		iosb;
+	nt_file_internal_information	fii_hdir,fii_hroot;
+	struct __psx_tlca *		tlca;
+
+	tlca = __tlca_self();
+	status = __ntapi->zw_query_information_file(
+			hdir,&iosb,&fii_hdir,sizeof(fii_hdir),
+			NT_FILE_INTERNAL_INFORMATION);
+	if (status)
+		return status;
+	status = __ntapi->zw_query_information_file(
+			tlca->ctx->root.hfile,&iosb,&fii_hroot,sizeof(fii_hroot),
+			NT_FILE_INTERNAL_INFORMATION);
+	if (status)
+		return status;
+	if (fii_hdir.index_number.quad == fii_hroot.index_number.quad) {
+		*hparent = hdir;
+		*type = PSX_FD_OS_FS_ROOT;
+		status = NT_STATUS_SUCCESS;
+	} else
+		status = __ntapi->tt_open_physical_parent_directory(
+			hparent,hdir,
+			buffer,
+			buffer_size,
+			desired_access,
+			open_options,type);
+	return status;
+}
+
 int32_t	__stdcall __psx_iofn_fsdir_getvents(
 	void *			hfile,
 	void *			hevent,
@@ -133,6 +196,6 @@ void __fastcall __psx_iofn_fsdir_init(struct __iovtbl * iovtbl)
 	iovtbl->getdents		= __ntapi->zw_query_directory_file;
 	iovtbl->getvents		= __psx_iofn_fsdir_getvents;
 
-	iovtbl->open_logical_parent  = __ntapi->tt_open_logical_parent_directory;
-	iovtbl->open_physical_parent = __ntapi->tt_open_physical_parent_directory;
+	iovtbl->open_logical_parent  = __psx_iofn_fsdir_open_parent_directory;
+	iovtbl->open_physical_parent = __psx_iofn_fsdir_open_parent_directory;
 }
diff --git a/src/path/psx_path_parse.c b/src/path/psx_path_parse.c
index ff4d933..08431b6 100644
--- a/src/path/psx_path_parse.c
+++ b/src/path/psx_path_parse.c
@@ -48,8 +48,8 @@ int32_t __fastcall __psx_parse_normalized_path_utf8(
 			ch,
 			++(path_info->depth));
 
-		if (*(++ch)=='/') {
-			ch++;
+		if (ch[1]=='/') {
+			ch+=2;
 		}
 	}
 
diff --git a/src/path/psx_path_resolve.c b/src/path/psx_path_resolve.c
index 2bd615c..705e646 100644
--- a/src/path/psx_path_resolve.c
+++ b/src/path/psx_path_resolve.c
@@ -260,7 +260,7 @@ static int __fastcall __path_swap_at(
 	int32_t			status;
 
 	/* swap */
-	if (path_info->pathflags & PSX_PATH_CLOSE_AT)
+	if ((path_info->pathflags & PSX_PATH_CLOSE_AT) && (path_info->hat != path_info->hfile))
 		if ((status = __iovtbl[path_info->fdtypeat].close(path_info->hat)))
 			return status;

diff --git a/src/process/_execve.c b/src/process/_execve.c
index a623d2a..80dd4a9 100644
--- a/src/process/_execve.c
+++ b/src/process/_execve.c
@@ -232,7 +232,7 @@ intptr_t __sys_execve(const unsigned char * path, const char ** argv, const char
 			NT_SECTION_QUERY|NT_SECTION_MAP_EXECUTE,
 			&oa,&ssize,
 			NT_PAGE_EXECUTE,
-			NT_SEC_IMAGE,
+			NT_SEC_RESERVE,
 			image->info.hfile)))
 		return __execve_return(tlca,0,target,-ENOEXEC);