Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
036f4dca
Commit
036f4dca
authored
Apr 08, 2020
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winecrt0: Rebuild the argv array instead of getting it from libwine.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
e5895164
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
125 additions
and
21 deletions
+125
-21
exe_entry.c
dlls/winecrt0/exe_entry.c
+59
-19
exe_wentry.c
dlls/winecrt0/exe_wentry.c
+66
-2
No files found.
dlls/winecrt0/exe_entry.c
View file @
036f4dca
...
...
@@ -25,43 +25,83 @@
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winternl.h"
#include "wine/library.h"
#include "crt0_private.h"
extern
int
__cdecl
main
(
int
argc
,
char
*
argv
[]
);
static
char
**
build_argv
(
WCHAR
**
wargv
)
static
char
**
build_argv
(
const
char
*
src
,
int
*
ret_argc
)
{
int
argc
;
char
*
p
,
**
argv
;
DWORD
total
=
0
;
for
(
argc
=
0
;
wargv
[
argc
];
argc
++
)
total
+=
WideCharToMultiByte
(
CP_ACP
,
0
,
wargv
[
argc
],
-
1
,
NULL
,
0
,
NULL
,
NULL
);
char
**
argv
,
*
arg
,
*
dst
;
int
argc
,
in_quotes
=
0
,
bcount
=
0
,
len
=
strlen
(
src
)
+
1
;
argv
=
HeapAlloc
(
GetProcessHeap
(),
0
,
total
+
(
argc
+
1
)
*
sizeof
(
*
argv
)
);
p
=
(
char
*
)(
argv
+
argc
+
1
);
for
(
argc
=
0
;
wargv
[
argc
];
argc
++
)
argc
=
2
+
len
/
2
;
argv
=
HeapAlloc
(
GetProcessHeap
(),
0
,
argc
*
sizeof
(
*
argv
)
+
len
);
arg
=
dst
=
(
char
*
)(
argv
+
argc
);
argc
=
0
;
while
(
*
src
)
{
DWORD
reslen
=
WideCharToMultiByte
(
CP_ACP
,
0
,
wargv
[
argc
],
-
1
,
p
,
total
,
NULL
,
NULL
);
argv
[
argc
]
=
p
;
p
+=
reslen
;
total
-=
reslen
;
if
((
*
src
==
' '
||
*
src
==
'\t'
)
&&
!
in_quotes
)
{
/* skip the remaining spaces */
while
(
*
src
==
' '
||
*
src
==
'\t'
)
src
++
;
if
(
!*
src
)
break
;
/* close the argument and copy it */
*
dst
++
=
0
;
argv
[
argc
++
]
=
arg
;
/* start with a new argument */
arg
=
dst
;
bcount
=
0
;
}
else
if
(
*
src
==
'\\'
)
{
*
dst
++
=
*
src
++
;
bcount
++
;
}
else
if
(
*
src
==
'"'
)
{
if
((
bcount
&
1
)
==
0
)
{
/* Preceded by an even number of '\', this is half that
* number of '\', plus a '"' which we discard.
*/
dst
-=
bcount
/
2
;
src
++
;
if
(
in_quotes
&&
*
src
==
'"'
)
*
dst
++
=
*
src
++
;
else
in_quotes
=
!
in_quotes
;
}
else
{
/* Preceded by an odd number of '\', this is half that
* number of '\' followed by a '"'
*/
dst
-=
bcount
/
2
+
1
;
*
dst
++
=
*
src
++
;
}
bcount
=
0
;
}
else
/* a regular character */
{
*
dst
++
=
*
src
++
;
bcount
=
0
;
}
}
*
dst
=
0
;
argv
[
argc
++
]
=
arg
;
argv
[
argc
]
=
NULL
;
*
ret_argc
=
argc
;
return
argv
;
}
DWORD
WINAPI
DECLSPEC_HIDDEN
__wine_spec_exe_entry
(
PEB
*
peb
)
{
int
argc
;
BOOL
needs_init
=
(
__wine_spec_init_state
!=
CONSTRUCTORS_DONE
);
char
**
argv
=
build_argv
(
__wine_main_wargv
);
char
**
argv
=
build_argv
(
GetCommandLineA
(),
&
argc
);
DWORD
ret
;
if
(
needs_init
)
_init
(
__wine_main_
argc
,
argv
,
NULL
);
ret
=
main
(
__wine_main_
argc
,
argv
);
if
(
needs_init
)
_init
(
argc
,
argv
,
NULL
);
ret
=
main
(
argc
,
argv
);
if
(
needs_init
)
_fini
();
ExitProcess
(
ret
);
}
dlls/winecrt0/exe_wentry.c
View file @
036f4dca
...
...
@@ -26,18 +26,82 @@
#include "windef.h"
#include "winbase.h"
#include "winternl.h"
#include "wine/library.h"
#include "crt0_private.h"
extern
int
__cdecl
wmain
(
int
argc
,
WCHAR
*
argv
[]
);
static
WCHAR
**
build_argv
(
const
WCHAR
*
src
,
int
*
ret_argc
)
{
WCHAR
**
argv
,
*
arg
,
*
dst
;
int
argc
,
in_quotes
=
0
,
bcount
=
0
,
len
=
lstrlenW
(
src
)
+
1
;
argc
=
2
+
len
/
2
;
argv
=
HeapAlloc
(
GetProcessHeap
(),
0
,
argc
*
sizeof
(
*
argv
)
+
len
*
sizeof
(
WCHAR
)
);
arg
=
dst
=
(
WCHAR
*
)(
argv
+
argc
);
argc
=
0
;
while
(
*
src
)
{
if
((
*
src
==
' '
||
*
src
==
'\t'
)
&&
!
in_quotes
)
{
/* skip the remaining spaces */
while
(
*
src
==
' '
||
*
src
==
'\t'
)
src
++
;
if
(
!*
src
)
break
;
/* close the argument and copy it */
*
dst
++
=
0
;
argv
[
argc
++
]
=
arg
;
/* start with a new argument */
arg
=
dst
;
bcount
=
0
;
}
else
if
(
*
src
==
'\\'
)
{
*
dst
++
=
*
src
++
;
bcount
++
;
}
else
if
(
*
src
==
'"'
)
{
if
((
bcount
&
1
)
==
0
)
{
/* Preceded by an even number of '\', this is half that
* number of '\', plus a '"' which we discard.
*/
dst
-=
bcount
/
2
;
src
++
;
if
(
in_quotes
&&
*
src
==
'"'
)
*
dst
++
=
*
src
++
;
else
in_quotes
=
!
in_quotes
;
}
else
{
/* Preceded by an odd number of '\', this is half that
* number of '\' followed by a '"'
*/
dst
-=
bcount
/
2
+
1
;
*
dst
++
=
*
src
++
;
}
bcount
=
0
;
}
else
/* a regular character */
{
*
dst
++
=
*
src
++
;
bcount
=
0
;
}
}
*
dst
=
0
;
argv
[
argc
++
]
=
arg
;
argv
[
argc
]
=
NULL
;
*
ret_argc
=
argc
;
return
argv
;
}
DWORD
WINAPI
DECLSPEC_HIDDEN
__wine_spec_exe_wentry
(
PEB
*
peb
)
{
int
argc
;
BOOL
needs_init
=
(
__wine_spec_init_state
!=
CONSTRUCTORS_DONE
);
WCHAR
**
argv
=
build_argv
(
GetCommandLineW
(),
&
argc
);
DWORD
ret
;
if
(
needs_init
)
_init
(
0
,
NULL
,
NULL
);
ret
=
wmain
(
__wine_main_argc
,
__wine_main_w
argv
);
ret
=
wmain
(
argc
,
argv
);
if
(
needs_init
)
_fini
();
ExitProcess
(
ret
);
}
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