__p___argc, MSVCRT,__wine_get_main_args and ParseOptions
Hallo, running with builtin msvcrt like
wine --dll msvcrt=b a.exe
for the following source: #include <stdio.h> #include <stdlib.h> #define _stat stat int main( void ) { printf("%d\n",__p___argc()); printf("%d\n",*(__p___argc())); return 0; } still counts _two_ arguments, as it sees "wine a.exe". OPTIONS_ParseOptions,__wine_get_main_args and __wine_get_wmain_args are very delicate stocked on each other, so I don't know which one to change. For a short test I did hertz:/spare/bon/wine-clean> cvs -d $CVSROOT diff -u wine/misc/options.c Index: wine/misc/options.c =================================================================== RCS file: /home/wine/wine/misc/options.c,v retrieving revision 1.29 diff -u -r1.29 options.c --- wine/misc/options.c 2001/11/06 00:49:48 1.29 +++ wine/misc/options.c 2001/11/20 20:18:44 @@ -356,8 +356,8 @@ */ int __wine_get_main_args( char ***argv ) { - *argv = app_argv; - return app_argc; + *argv = &app_argv[1]; + return app_argc-1; } (leaving aside __wine_get_wmain_args for the moment) and was able to run some programm that didn't run before. Can anybody help with the right fix? Bye -- Uwe Bonnes bon(a)elektron.ikp.physik.tu-darmstadt.de Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt --------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
On Tue, 20 Nov 2001, Uwe Bonnes wrote:
Hallo,
running with builtin msvcrt like
wine --dll msvcrt=b a.exe [...] still counts _two_ arguments, as it sees "wine a.exe".
Yes, there is a problem. How did I miss it when I looked into the parameter passing?
For a short test I did
hertz:/spare/bon/wine-clean> cvs -d $CVSROOT diff -u wine/misc/options.c Index: wine/misc/options.c =================================================================== RCS file: /home/wine/wine/misc/options.c,v retrieving revision 1.29 diff -u -r1.29 options.c --- wine/misc/options.c 2001/11/06 00:49:48 1.29 +++ wine/misc/options.c 2001/11/20 20:18:44 @@ -356,8 +356,8 @@ */ int __wine_get_main_args( char ***argv ) { - *argv = app_argv; - return app_argc; + *argv = &app_argv[1]; + return app_argc-1; }
The problem with this patch is that it removes the application name for Winelib applications. More investigation is needed... -- Francois Gouget fgouget(a)free.fr http://fgouget.free.fr/ I haven't lost my mind, it's backed up on tape around here somewhere...
"Francois" == Francois Gouget <fgouget(a)free.fr> writes:
Francois> On Tue, 20 Nov 2001, Uwe Bonnes wrote: >> Hallo, >> >> running with builtin msvcrt like >> >> > wine --dll msvcrt=b a.exe Francois> [...] >> still counts _two_ arguments, as it sees "wine a.exe". Francois> Yes, there is a problem. How did I miss it when I looked Francois> into the parameter passing? ... Francois> The problem with this patch is that it removes the Francois> application name for Winelib applications. More investigation Francois> is needed... How about removing the parameters in msvcrt/data.c like: Index: wine/dlls/msvcrt/data.c =================================================================== RCS file: /home/wine/wine/dlls/msvcrt/data.c,v retrieving revision 1.11 diff -u -w -r1.11 data.c --- wine/dlls/msvcrt/data.c 2001/09/07 19:47:30 1.11 +++ wine/dlls/msvcrt/data.c 2001/12/04 07:10:43 @@ -50,7 +50,10 @@ /*********************************************************************** * __p___argc (MSVCRT.@) */ -int* __p___argc(void) { return &MSVCRT___argc; } +int* __p___argc(void) { +TRACE("BON: %p %d\n",&MSVCRT___argc,MSVCRT___argc); +return &MSVCRT___argc; +} /*********************************************************************** * __p__commode (MSVCRT.@) @@ -156,7 +159,10 @@ MSVCRT__acmdln = _strdup( GetCommandLineA() ); MSVCRT__wcmdln = wstrdupa(MSVCRT__acmdln); MSVCRT___argc = __wine_get_main_args(&MSVCRT___argv); + MSVCRT___argv = &(MSVCRT___argv[1]); + MSVCRT___argc--; __wine_get_wmain_args(&MSVCRT___wargv); + MSVCRT___wargv = &(MSVCRT___wargv[1]); TRACE("got '%s', wide = %s argc=%d\n", MSVCRT__acmdln, debugstr_w(MSVCRT__wcmdln),MSVCRT___argc); -- Uwe Bonnes bon(a)elektron.ikp.physik.tu-darmstadt.de Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt --------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
Francois Gouget <fgouget(a)free.fr> writes:
The problem with this patch is that it removes the application name for Winelib applications. More investigation is needed...
Try the latest CVS. I believe I may have fixed that in the big server reorganization. -- Alexandre Julliard julliard(a)winehq.com
On 4 Dec 2001, Alexandre Julliard wrote:
Francois Gouget <fgouget(a)free.fr> writes:
The problem with this patch is that it removes the application name for Winelib applications. More investigation is needed...
Try the latest CVS. I believe I may have fixed that in the big server reorganization.
Yep. Works in the latest Wine. The fix is in scheduler/process.c in process_init() and PROCESS_InitWine() as I suspected :-) -- Francois Gouget fgouget(a)free.fr http://fgouget.free.fr/ The greatest programming project of all took six days; on the seventh day the programmer rested. We've been trying to debug the *&^%$#@ thing ever since. Moral: design before you implement.
participants (3)
-
Alexandre Julliard -
Francois Gouget -
Uwe Bonnes