Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
d892239f
Commit
d892239f
authored
Jul 07, 2014
by
Sebastian Lackner
Committed by
Alexandre Julliard
Jul 09, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shell32: Return NULL-terminated list of arguments in CommandLineToArgvW.
parent
359767fd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
6 deletions
+13
-6
shell32_main.c
dlls/shell32/shell32_main.c
+9
-6
shlexec.c
dlls/shell32/tests/shlexec.c
+4
-0
No files found.
dlls/shell32/shell32_main.c
View file @
d892239f
...
...
@@ -101,11 +101,11 @@ LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* numargs)
/* Return the path to the executable */
DWORD
len
,
deslen
=
MAX_PATH
,
size
;
size
=
sizeof
(
LPWSTR
)
+
deslen
*
sizeof
(
WCHAR
)
+
sizeof
(
LPWST
R
);
size
=
sizeof
(
LPWSTR
)
*
2
+
deslen
*
sizeof
(
WCHA
R
);
for
(;;)
{
if
(
!
(
argv
=
LocalAlloc
(
LMEM_FIXED
,
size
)))
return
NULL
;
len
=
GetModuleFileNameW
(
0
,
(
LPWSTR
)(
argv
+
1
),
deslen
);
len
=
GetModuleFileNameW
(
0
,
(
LPWSTR
)(
argv
+
2
),
deslen
);
if
(
!
len
)
{
LocalFree
(
argv
);
...
...
@@ -113,10 +113,11 @@ LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* numargs)
}
if
(
len
<
deslen
)
break
;
deslen
*=
2
;
size
=
sizeof
(
LPWSTR
)
+
deslen
*
sizeof
(
WCHAR
)
+
sizeof
(
LPWST
R
);
size
=
sizeof
(
LPWSTR
)
*
2
+
deslen
*
sizeof
(
WCHA
R
);
LocalFree
(
argv
);
}
argv
[
0
]
=
(
LPWSTR
)(
argv
+
1
);
argv
[
0
]
=
(
LPWSTR
)(
argv
+
2
);
argv
[
1
]
=
NULL
;
*
numargs
=
1
;
return
argv
;
...
...
@@ -194,10 +195,10 @@ LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* numargs)
* with it. This way the caller can make a single LocalFree() call to free
* both, as per MSDN.
*/
argv
=
LocalAlloc
(
LMEM_FIXED
,
argc
*
sizeof
(
LPWSTR
)
+
(
strlenW
(
lpCmdline
)
+
1
)
*
sizeof
(
WCHAR
));
argv
=
LocalAlloc
(
LMEM_FIXED
,
(
argc
+
1
)
*
sizeof
(
LPWSTR
)
+
(
strlenW
(
lpCmdline
)
+
1
)
*
sizeof
(
WCHAR
));
if
(
!
argv
)
return
NULL
;
cmdline
=
(
LPWSTR
)(
argv
+
argc
);
cmdline
=
(
LPWSTR
)(
argv
+
argc
+
1
);
strcpyW
(
cmdline
,
lpCmdline
);
/* --- Then split and copy the arguments */
...
...
@@ -235,6 +236,7 @@ LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* numargs)
if
(
!*
s
)
{
/* There are no parameters so we are all done */
argv
[
argc
]
=
NULL
;
*
numargs
=
argc
;
return
argv
;
}
...
...
@@ -306,6 +308,7 @@ LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* numargs)
}
}
*
d
=
'\0'
;
argv
[
argc
]
=
NULL
;
*
numargs
=
argc
;
return
argv
;
...
...
dlls/shell32/tests/shlexec.c
View file @
d892239f
...
...
@@ -1159,6 +1159,8 @@ static BOOL test_one_cmdline(const cmdline_tests_t* test)
win_skip
(
"CommandLineToArgvW not implemented, skipping
\n
"
);
return
FALSE
;
}
ok
(
!
argsW
[
cl2a_count
]
||
broken
(
argsW
[
cl2a_count
]
!=
NULL
)
/* before Vista */
,
"expected NULL-terminated list of commandline arguments
\n
"
);
count
=
0
;
while
(
test
->
args
[
count
])
...
...
@@ -1218,6 +1220,8 @@ static void test_commandline2argv(void)
*
strW
=
0
;
args
=
CommandLineToArgvW
(
strW
,
&
numargs
);
ok
(
numargs
==
1
,
"expected 1 args, got %d
\n
"
,
numargs
);
ok
(
!
args
||
(
!
args
[
numargs
]
||
broken
(
args
[
numargs
]
!=
NULL
)
/* before Vista */
),
"expected NULL-terminated list of commandline arguments
\n
"
);
if
(
numargs
==
1
)
{
GetModuleFileNameW
(
NULL
,
strW
,
sizeof
(
strW
)
/
sizeof
(
*
strW
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment