winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
September 2021
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
1030 discussions
Start a n
N
ew thread
Alexandre Julliard : widl: Use a string array for the filenames list.
by Alexandre Julliard
29 Sep '21
29 Sep '21
Module: wine Branch: master Commit: dbe7e12b547a169ee435fd7d34ce7b770b67a63e URL:
https://source.winehq.org/git/wine.git/?a=commit;h=dbe7e12b547a169ee435fd7d…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Wed Sep 29 11:21:11 2021 +0200 widl: Use a string array for the filenames list. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- tools/widl/widl.c | 57 ++++++++++++++----------------------------------------- 1 file changed, 14 insertions(+), 43 deletions(-) diff --git a/tools/widl/widl.c b/tools/widl/widl.c index f2f94808462..72888c35ac7 100644 --- a/tools/widl/widl.c +++ b/tools/widl/widl.c @@ -368,33 +368,10 @@ void end_cplusplus_guard(FILE *fp) fprintf(fp, "#endif\n\n"); } -typedef struct -{ - char *filename; - struct list link; -} filename_node_t; - -static void add_filename_node(struct list *list, const char *name) -{ - filename_node_t *node = xmalloc(sizeof *node); - node->filename = replace_extension( get_basename( name ), ".idl", "" ); - list_add_tail(list, &node->link); -} - -static void free_filename_nodes(struct list *list) -{ - filename_node_t *node, *next; - LIST_FOR_EACH_ENTRY_SAFE(node, next, list, filename_node_t, link) { - list_remove(&node->link); - free(node->filename); - free(node); - } -} - -static void write_dlldata_list(struct list *filenames, int define_proxy_delegation) +static void write_dlldata_list( struct strarray filenames, int define_proxy_delegation) { FILE *dlldata; - filename_node_t *node; + unsigned int i; dlldata = fopen(dlldata_name, "w"); if (!dlldata) @@ -408,13 +385,13 @@ static void write_dlldata_list(struct list *filenames, int define_proxy_delegati fprintf(dlldata, "#include <rpcproxy.h>\n\n"); start_cplusplus_guard(dlldata); - LIST_FOR_EACH_ENTRY(node, filenames, filename_node_t, link) - fprintf(dlldata, "EXTERN_PROXY_FILE(%s)\n", node->filename); + for (i = 0; i < filenames.count; i++) + fprintf(dlldata, "EXTERN_PROXY_FILE(%s)\n", filenames.str[i]); fprintf(dlldata, "\nPROXYFILE_LIST_START\n"); fprintf(dlldata, "/* Start of list */\n"); - LIST_FOR_EACH_ENTRY(node, filenames, filename_node_t, link) - fprintf(dlldata, " REFERENCE_PROXY_FILE(%s),\n", node->filename); + for (i = 0; i < filenames.count; i++) + fprintf(dlldata, " REFERENCE_PROXY_FILE(%s),\n", filenames.str[i]); fprintf(dlldata, "/* End of list */\n"); fprintf(dlldata, "PROXYFILE_LIST_END\n\n"); @@ -432,9 +409,8 @@ static char *eat_space(char *s) void write_dlldata(const statement_list_t *stmts) { - struct list filenames = LIST_INIT(filenames); + struct strarray filenames = empty_strarray; int define_proxy_delegation = 0; - filename_node_t *node; FILE *dlldata; if (!do_dlldata || !need_proxy_file(stmts)) @@ -465,7 +441,7 @@ void write_dlldata(const statement_list_t *stmts) --end; *end = '\0'; if (start < end) - add_filename_node(&filenames, start); + strarray_add(&filenames, replace_extension( get_basename( start ), ".idl", "" )); }else if (!define_proxy_delegation && strncmp(start, delegation_define, sizeof(delegation_define)-1)) { define_proxy_delegation = 1; } @@ -478,16 +454,12 @@ void write_dlldata(const statement_list_t *stmts) fclose(dlldata); } - LIST_FOR_EACH_ENTRY(node, &filenames, filename_node_t, link) - if (strcmp(proxy_token, node->filename) == 0) { + if (strarray_exists( &filenames, proxy_token )) /* We're already in the list, no need to regenerate this file. */ - free_filename_nodes(&filenames); return; - } - add_filename_node(&filenames, proxy_token); - write_dlldata_list(&filenames, define_proxy_delegation); - free_filename_nodes(&filenames); + strarray_add(&filenames, proxy_token); + write_dlldata_list(filenames, define_proxy_delegation); } static void write_id_guid(FILE *f, const char *type, const char *guid_prefix, const char *name, const UUID *uuid) @@ -865,12 +837,11 @@ int main(int argc,char *argv[]) if(optind < argc) { if (do_dlldata && !do_everything) { - struct list filenames = LIST_INIT(filenames); + struct strarray filenames = empty_strarray; for ( ; optind < argc; ++optind) - add_filename_node(&filenames, argv[optind]); + strarray_add(&filenames, replace_extension( get_basename( argv[optind] ), ".idl", "" )); - write_dlldata_list(&filenames, 0 /* FIXME */ ); - free_filename_nodes(&filenames); + write_dlldata_list(filenames, 0 /* FIXME */ ); return 0; } else if (optind != argc - 1) {
1
0
0
0
Alexandre Julliard : winedump: Use the shared tools functions.
by Alexandre Julliard
29 Sep '21
29 Sep '21
Module: wine Branch: master Commit: 3cdc6d682ceff3568d0e77f58772a266528f2bfa URL:
https://source.winehq.org/git/wine.git/?a=commit;h=3cdc6d682ceff3568d0e77f5…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Wed Sep 29 11:14:01 2021 +0200 winedump: Use the shared tools functions. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- tools/winedump/debug.c | 5 +- tools/winedump/dump.c | 3 +- tools/winedump/main.c | 36 ++------- tools/winedump/misc.c | 74 +----------------- tools/winedump/msc.c | 11 +-- tools/winedump/msmangle.c | 190 +++++++++++++++++++++++----------------------- tools/winedump/nls.c | 7 +- tools/winedump/pdb.c | 5 +- tools/winedump/pe.c | 10 +-- tools/winedump/search.c | 23 +++--- tools/winedump/symbol.c | 3 +- tools/winedump/tlb.c | 5 +- tools/winedump/winedump.h | 4 - 13 files changed, 142 insertions(+), 234 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=3cdc6d682ceff3568d0e…
1
0
0
0
Alexandre Julliard : tools: Add a few helper functions for file names and extensions.
by Alexandre Julliard
29 Sep '21
29 Sep '21
Module: wine Branch: master Commit: 9e3959bd9b44c17f4d2cf0449ca78c35e7d9fd66 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=9e3959bd9b44c17f4d2cf044…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Wed Sep 29 11:13:36 2021 +0200 tools: Add a few helper functions for file names and extensions. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- tools/make_xftmpl.c | 11 +------- tools/makedep.c | 17 ------------ tools/sfnt2fon/sfnt2fon.c | 12 ++------ tools/tools.h | 30 ++++++++++++++++++++ tools/widl/header.c | 7 ++--- tools/widl/parser.y | 2 +- tools/widl/typelib.c | 13 ++------- tools/widl/utils.c | 29 ------------------- tools/widl/utils.h | 1 - tools/widl/widl.c | 71 +++++++++++++---------------------------------- tools/winebuild/import.c | 4 +-- tools/winebuild/main.c | 6 ++-- tools/winebuild/utils.c | 9 +----- tools/winegcc/utils.c | 14 ---------- tools/winegcc/utils.h | 1 - tools/winegcc/winegcc.c | 45 ++++++++---------------------- tools/wmc/utils.c | 26 ----------------- tools/wmc/utils.h | 2 -- tools/wmc/wmc.c | 15 ++++------ tools/wrc/po.c | 5 +--- tools/wrc/utils.c | 26 ----------------- tools/wrc/utils.h | 1 - tools/wrc/wpp.c | 8 +----- tools/wrc/wrc.c | 15 ++++------ 24 files changed, 88 insertions(+), 282 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=9e3959bd9b44c17f4d2c…
1
0
0
0
Alexandre Julliard : tools: Add a helper function to create temp files.
by Alexandre Julliard
29 Sep '21
29 Sep '21
Module: wine Branch: master Commit: 55701c66728f6f2589e8fb5c72506aa8ba9ace66 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=55701c66728f6f2589e8fb5c…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Wed Sep 29 09:32:01 2021 +0200 tools: Add a helper function to create temp files. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- tools/tools.h | 31 +++++++++++++++++++++++++++++++ tools/widl/parser.l | 10 ++-------- tools/widl/widl.c | 9 ++------- tools/winebuild/utils.c | 24 ++++++------------------ tools/winegcc/winegcc.c | 15 ++------------- tools/wrc/genres.c | 1 + tools/wrc/newstruc.c | 1 + tools/wrc/parser.l | 1 + tools/wrc/parser.y | 1 + tools/wrc/po.c | 1 + tools/wrc/ppl.l | 1 + tools/wrc/ppy.y | 1 + tools/wrc/translation.c | 1 + tools/wrc/utils.c | 1 + tools/wrc/wpp.c | 1 + tools/wrc/wpp_private.h | 1 - tools/wrc/wrc.c | 8 ++------ tools/wrc/wrc.h | 1 - 18 files changed, 55 insertions(+), 54 deletions(-) diff --git a/tools/tools.h b/tools/tools.h index 7c0f4c20a42..09b4fa14b28 100644 --- a/tools/tools.h +++ b/tools/tools.h @@ -26,6 +26,8 @@ #include <stdlib.h> #include <string.h> #include <sys/types.h> +#include <fcntl.h> +#include <time.h> #include <errno.h> #ifdef HAVE_UNISTD_H # include <unistd.h> @@ -249,4 +251,33 @@ static inline int strarray_spawn( struct strarray args ) #endif } +static inline int make_temp_file( const char *prefix, const char *suffix, char **name ) +{ + static unsigned int value; + int fd, count; + const char *tmpdir = NULL; + + if (!prefix) prefix = "tmp"; + if (!suffix) suffix = ""; + value += time(NULL) + getpid(); + + for (count = 0; count < 0x8000; count++) + { + if (tmpdir) + *name = strmake( "%s/%s-%08x%s", tmpdir, prefix, value, suffix ); + else + *name = strmake( "%s-%08x%s", prefix, value, suffix ); + fd = open( *name, O_RDWR | O_CREAT | O_EXCL, 0600 ); + if (fd >= 0) return fd; + value += 7777; + if (errno == EACCES && !tmpdir && !strchr( prefix, '/' )) + { + if (!(tmpdir = getenv("TMPDIR"))) tmpdir = "/tmp"; + } + free( *name ); + } + fprintf( stderr, "failed to create temp file for %s%s\n", prefix, suffix ); + exit(1); +} + #endif /* __WINE_TOOLS_H */ diff --git a/tools/widl/parser.l b/tools/widl/parser.l index 72a7a432bbc..d01a9ece3bb 100644 --- a/tools/widl/parser.l +++ b/tools/widl/parser.l @@ -564,10 +564,7 @@ int do_import(char *fname) input_name = path; line_number = 1; - name = xstrdup( "widl.XXXXXX" ); - if((fd = mkstemps( name, 0 )) == -1) - error("Could not generate a temp name from %s\n", name); - + fd = make_temp_file( "widl-pp", NULL, &name ); temp_name = name; if (!(f = fdopen(fd, "wt"))) error("Could not open fd %s for writing\n", name); @@ -605,10 +602,7 @@ static void switch_to_acf(void) acf_name = NULL; line_number = 1; - name = xstrdup( "widl.XXXXXX" ); - if((fd = mkstemps( name, 0 )) == -1) - error("Could not generate a temp name from %s\n", name); - + fd = make_temp_file( "widl-acf", NULL, &name ); temp_name = name; if (!(f = fdopen(fd, "wt"))) error("Could not open fd %s for writing\n", name); diff --git a/tools/widl/widl.c b/tools/widl/widl.c index 5b1ce6ca689..d168a01529a 100644 --- a/tools/widl/widl.c +++ b/tools/widl/widl.c @@ -967,14 +967,9 @@ int main(int argc,char *argv[]) { FILE *output; int fd; - char *name = xmalloc( strlen(header_name) + 8 ); - - strcpy( name, header_name ); - strcat( name, ".XXXXXX" ); - - if ((fd = mkstemps( name, 0 )) == -1) - error("Could not generate a temp name from %s\n", name); + char *name; + fd = make_temp_file( header_name, NULL, &name ); temp_name = name; if (!(output = fdopen(fd, "wt"))) error("Could not open fd %s for writing\n", name); diff --git a/tools/winebuild/utils.c b/tools/winebuild/utils.c index de0d26ddba6..e375b696e59 100644 --- a/tools/winebuild/utils.c +++ b/tools/winebuild/utils.c @@ -441,26 +441,14 @@ char *get_temp_file_name( const char *prefix, const char *suffix ) const char *ext, *basename; int fd; - if (!prefix || !prefix[0]) prefix = "winebuild"; - if (!suffix) suffix = ""; - if ((basename = strrchr( prefix, '/' ))) basename++; - else basename = prefix; - if (!(ext = strchr( basename, '.' ))) ext = prefix + strlen(prefix); - name = xmalloc( sizeof("/tmp/") + (ext - prefix) + sizeof(".XXXXXX") + strlen(suffix) ); - memcpy( name, prefix, ext - prefix ); - strcpy( name + (ext - prefix), ".XXXXXX" ); - strcat( name, suffix ); - - if ((fd = mkstemps( name, strlen(suffix) )) == -1) + if (prefix) { - strcpy( name, "/tmp/" ); - memcpy( name + 5, basename, ext - basename ); - strcpy( name + 5 + (ext - basename), ".XXXXXX" ); - strcat( name, suffix ); - if ((fd = mkstemps( name, strlen(suffix) )) == -1) - fatal_error( "could not generate a temp file\n" ); + if ((basename = strrchr( prefix, '/' ))) basename++; + else basename = prefix; + if ((ext = strchr( basename, '.' ))) prefix = strmake( "%.*s", ext - basename, basename ); + else prefix = basename; } - + fd = make_temp_file( prefix, suffix, &name ); close( fd ); strarray_add( &tmp_files, name ); return name; diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c index 2bf13570bba..0a6481ff0db 100644 --- a/tools/winegcc/winegcc.c +++ b/tools/winegcc/winegcc.c @@ -297,25 +297,14 @@ static void exit_on_signal( int sig ) static char* get_temp_file(const char* prefix, const char* suffix) { int fd; - char* tmp = strmake("%s-XXXXXX%s", prefix, suffix); + char *tmp; #ifdef HAVE_SIGPROCMASK sigset_t old_set; /* block signals while manipulating the temp files list */ sigprocmask( SIG_BLOCK, &signal_mask, &old_set ); #endif - fd = mkstemps( tmp, strlen(suffix) ); - if (fd == -1) - { - /* could not create it in current directory, try in TMPDIR */ - const char* tmpdir; - - free(tmp); - if (!(tmpdir = getenv("TMPDIR"))) tmpdir = "/tmp"; - tmp = strmake("%s/%s-XXXXXX%s", tmpdir, prefix, suffix); - fd = mkstemps( tmp, strlen(suffix) ); - if (fd == -1) error( "could not create temp file\n" ); - } + fd = make_temp_file( prefix, suffix, &tmp ); close( fd ); strarray_add(&tmp_files, tmp); #ifdef HAVE_SIGPROCMASK diff --git a/tools/wrc/genres.c b/tools/wrc/genres.c index bf2d3b5b9bc..002d1a46bfb 100644 --- a/tools/wrc/genres.c +++ b/tools/wrc/genres.c @@ -34,6 +34,7 @@ #include <assert.h> #include <ctype.h> +#include "../tools.h" #include "wrc.h" #include "genres.h" #include "utils.h" diff --git a/tools/wrc/newstruc.c b/tools/wrc/newstruc.c index e93545f04f6..1b6cd429609 100644 --- a/tools/wrc/newstruc.c +++ b/tools/wrc/newstruc.c @@ -27,6 +27,7 @@ #include <assert.h> #include <ctype.h> +#include "../tools.h" #include "wrc.h" #include "newstruc.h" #include "utils.h" diff --git a/tools/wrc/parser.l b/tools/wrc/parser.l index 0c71396de73..c5d9db1488f 100644 --- a/tools/wrc/parser.l +++ b/tools/wrc/parser.l @@ -111,6 +111,7 @@ ws [ \f\t\r] #define YY_NO_UNISTD_H #endif +#include "../tools.h" #include "wrc.h" #include "utils.h" #include "parser.h" diff --git a/tools/wrc/parser.y b/tools/wrc/parser.y index bde02b736f8..7daa4581f23 100644 --- a/tools/wrc/parser.y +++ b/tools/wrc/parser.y @@ -130,6 +130,7 @@ #include <ctype.h> #include <string.h> +#include "../tools.h" #include "wrc.h" #include "utils.h" #include "newstruc.h" diff --git a/tools/wrc/po.c b/tools/wrc/po.c index 622d2f7a3ad..423d7142145 100644 --- a/tools/wrc/po.c +++ b/tools/wrc/po.c @@ -31,6 +31,7 @@ #include <gettext-po.h> #endif +#include "../tools.h" #include "wrc.h" #include "genres.h" #include "newstruc.h" diff --git a/tools/wrc/ppl.l b/tools/wrc/ppl.l index bd29dd274a7..d4df76f7950 100644 --- a/tools/wrc/ppl.l +++ b/tools/wrc/ppl.l @@ -173,6 +173,7 @@ ul [uUlL]|[uUlL][lL]|[lL][uU]|[lL][lL][uU]|[uU][lL][lL]|[lL][uU][lL] #define YY_NO_UNISTD_H #endif +#include "../tools.h" #include "utils.h" #include "wpp_private.h" #include "ppy.tab.h" diff --git a/tools/wrc/ppy.y b/tools/wrc/ppy.y index 7dc75ac1965..50561cbe1aa 100644 --- a/tools/wrc/ppy.y +++ b/tools/wrc/ppy.y @@ -30,6 +30,7 @@ #include <ctype.h> #include <string.h> +#include "../tools.h" #include "utils.h" #include "wpp_private.h" diff --git a/tools/wrc/translation.c b/tools/wrc/translation.c index bdbcb4342bd..eb0047c10b5 100644 --- a/tools/wrc/translation.c +++ b/tools/wrc/translation.c @@ -21,6 +21,7 @@ #include <stdlib.h> #include <assert.h> +#include "../tools.h" #include "dumpres.h" #include "utils.h" #include "wrc.h" diff --git a/tools/wrc/utils.c b/tools/wrc/utils.c index b37463ee6bf..c335e9eaa10 100644 --- a/tools/wrc/utils.c +++ b/tools/wrc/utils.c @@ -28,6 +28,7 @@ #include <string.h> #include <ctype.h> +#include "../tools.h" #include "wrc.h" #include "utils.h" #include "parser.h" diff --git a/tools/wrc/wpp.c b/tools/wrc/wpp.c index 200b21f8a2a..392ef189754 100644 --- a/tools/wrc/wpp.c +++ b/tools/wrc/wpp.c @@ -34,6 +34,7 @@ # include <unistd.h> #endif +#include "../tools.h" #include "utils.h" #include "wpp_private.h" diff --git a/tools/wrc/wpp_private.h b/tools/wrc/wpp_private.h index be118b020bd..435dbcc005a 100644 --- a/tools/wrc/wpp_private.h +++ b/tools/wrc/wpp_private.h @@ -22,7 +22,6 @@ #include <stdio.h> #include <string.h> -#include "../tools.h" #include "wine/list.h" extern void wpp_del_define( const char *name ); diff --git a/tools/wrc/wrc.c b/tools/wrc/wrc.c index 56c4c2f656b..1ffde86f0b7 100644 --- a/tools/wrc/wrc.c +++ b/tools/wrc/wrc.c @@ -35,6 +35,7 @@ # include <getopt.h> #endif +#include "../tools.h" #include "wrc.h" #include "utils.h" #include "dumpres.h" @@ -280,12 +281,7 @@ static int load_file( const char *input_name, const char *output_name ) exit(0); } - if (output_name && output_name[0]) name = strmake( "%s.XXXXXX", output_name ); - else name = xstrdup( "wrc.XXXXXX" ); - - if ((fd = mkstemps( name, 0 )) == -1) - error("Could not generate a temp name from %s\n", name); - + fd = make_temp_file( output_name, "", &name ); temp_name = name; if (!(output = fdopen(fd, "wt"))) error("Could not open fd %s for writing\n", name); diff --git a/tools/wrc/wrc.h b/tools/wrc/wrc.h index 4c572074e5e..d086c5c60f9 100644 --- a/tools/wrc/wrc.h +++ b/tools/wrc/wrc.h @@ -21,7 +21,6 @@ #ifndef __WRC_WRC_H #define __WRC_WRC_H -#include "../tools.h" #include "wrctypes.h" /* From wrc.c */
1
0
0
0
Huw Davies : secur32: Restore the done label.
by Alexandre Julliard
29 Sep '21
29 Sep '21
Module: wine Branch: master Commit: 1f0bc618eda7bc3f6eef3271d0fce32d4f009bc5 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=1f0bc618eda7bc3f6eef3271…
Author: Huw Davies <huw(a)codeweavers.com> Date: Wed Sep 29 07:53:54 2021 +0100 secur32: Restore the done label. This was incorrectly removed by commit 5c0fe4db7d580784ab6adc361bfed981be25753c. Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/secur32/schannel_macosx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/dlls/secur32/schannel_macosx.c b/dlls/secur32/schannel_macosx.c index 523f8c63562..f7f7db955ef 100644 --- a/dlls/secur32/schannel_macosx.c +++ b/dlls/secur32/schannel_macosx.c @@ -1107,6 +1107,7 @@ static SECURITY_STATUS CDECL schan_get_session_peer_certificate(schan_session se CFRelease(data); } +done: CFRelease(cert_array); return ret; }
1
0
0
0
Zebediah Figura : krnl386: Call generated 16-bit entry points from the snoop thunks.
by Alexandre Julliard
29 Sep '21
29 Sep '21
Module: wine Branch: master Commit: b035fe601dc61395c782f462d5072c9df87db7a9 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=b035fe601dc61395c782f462…
Author: Zebediah Figura <zfigura(a)codeweavers.com> Date: Tue Sep 28 20:39:05 2021 -0500 krnl386: Call generated 16-bit entry points from the snoop thunks. Instead of manually building a STACK16FRAME. Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/krnl386.exe16/krnl386.exe16.spec | 4 +++ dlls/krnl386.exe16/snoop.c | 56 ++++++----------------------------- 2 files changed, 13 insertions(+), 47 deletions(-) diff --git a/dlls/krnl386.exe16/krnl386.exe16.spec b/dlls/krnl386.exe16/krnl386.exe16.spec index c6ffd9df701..6a55aad78f8 100644 --- a/dlls/krnl386.exe16/krnl386.exe16.spec +++ b/dlls/krnl386.exe16/krnl386.exe16.spec @@ -747,3 +747,7 @@ # VxDs @ cdecl -arch=win32 -private __wine_vxd_open(wstr long ptr) @ cdecl -arch=win32 -private __wine_vxd_get_proc(long) + +# Snoop support +2001 pascal -register __wine_snoop_entry() +2002 pascal -register __wine_snoop_return() diff --git a/dlls/krnl386.exe16/snoop.c b/dlls/krnl386.exe16/snoop.c index 170796da390..d5c528d3382 100644 --- a/dlls/krnl386.exe16/snoop.c +++ b/dlls/krnl386.exe16/snoop.c @@ -34,13 +34,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(snoop); #include "pshpack1.h" -static void WINAPI SNOOP16_Entry(FARPROC proc, LPBYTE args, CONTEXT *context); -static void WINAPI SNOOP16_Return(FARPROC proc, LPBYTE args, CONTEXT *context); - typedef struct tagSNOOP16_FUN { /* code part */ BYTE lcall; /* 0x9a call absolute with segment */ - DWORD snr; + FARPROC16 snoop_entry; /* unreached */ int nrofargs; FARPROC16 origfun; @@ -58,7 +55,7 @@ typedef struct tagSNOOP16_DLL { typedef struct tagSNOOP16_RETURNENTRY { /* code part */ BYTE lcall; /* 0x9a call absolute with segment */ - DWORD snr; + FARPROC16 snoop_return; /* unreached */ FARPROC16 origreturn; SNOOP16_DLL *dll; @@ -73,24 +70,10 @@ typedef struct tagSNOOP16_RETURNENTRIES { struct tagSNOOP16_RETURNENTRIES *next; } SNOOP16_RETURNENTRIES; -typedef struct tagSNOOP16_RELAY { - WORD pushbp; /* 0x5566 */ - BYTE pusheax; /* 0x50 */ - WORD pushax; /* 0x5066 */ - BYTE pushl; /* 0x68 */ - DWORD realfun; /* SNOOP16_Return */ - BYTE lcall; /* 0x9a call absolute with segment */ - DWORD callfromregs; - WORD seg; - WORD lret; /* 0xcb66 */ -} SNOOP16_RELAY; - #include "poppack.h" static SNOOP16_DLL *firstdll = NULL; static SNOOP16_RETURNENTRIES *firstrets = NULL; -static SNOOP16_RELAY *snr; -static HANDLE16 xsnr = 0; void SNOOP16_RegisterDLL(HMODULE16 hModule,LPCSTR name) { @@ -102,29 +85,6 @@ SNOOP16_RegisterDLL(HMODULE16 hModule,LPCSTR name) { TRACE("hmod=%x, name=%s\n", hModule, name); - if (!snr) { - xsnr=GLOBAL_Alloc(GMEM_ZEROINIT,2*sizeof(*snr),0,LDT_FLAGS_CODE | LDT_FLAGS_32BIT); - snr = GlobalLock16(xsnr); - snr[0].pushbp = 0x5566; - snr[0].pusheax = 0x50; - snr[0].pushax = 0x5066; - snr[0].pushl = 0x68; - snr[0].realfun = (DWORD)SNOOP16_Entry; - snr[0].lcall = 0x9a; - snr[0].callfromregs = (DWORD)__wine_call_from_16_regs; - snr[0].seg = get_cs(); - snr[0].lret = 0xcb66; - - snr[1].pushbp = 0x5566; - snr[1].pusheax = 0x50; - snr[1].pushax = 0x5066; - snr[1].pushl = 0x68; - snr[1].realfun = (DWORD)SNOOP16_Return; - snr[1].lcall = 0x9a; - snr[1].callfromregs = (DWORD)__wine_call_from_16_regs; - snr[1].seg = get_cs(); - snr[1].lret = 0xcb66; - } while (*dll) { if ((*dll)->hmod == hModule) { @@ -181,7 +141,7 @@ SNOOP16_GetProcAddress16(HMODULE16 hmod,DWORD ordinal,FARPROC16 origfun) { fun = dll->funs+ordinal; /* already done? */ fun->lcall = 0x9a; - fun->snr = MAKELONG(0,xsnr); + fun->snoop_entry = GetProcAddress16( GetModuleHandle16( "KERNEL" ), "__wine_snoop_entry" ); fun->origfun = origfun; if (fun->name) return (FARPROC16)(SEGPTR)MAKELONG(((char*)fun-(char*)dll->funs),dll->funhandle); @@ -227,14 +187,15 @@ SNOOP16_GetProcAddress16(HMODULE16 hmod,DWORD ordinal,FARPROC16 origfun) { } } fun->lcall = 0x9a; - fun->snr = MAKELONG(0,xsnr); + fun->snoop_entry = GetProcAddress16( GetModuleHandle16( "KERNEL" ), "__wine_snoop_entry" ); fun->origfun = origfun; fun->nrofargs = -1; return (FARPROC16)(SEGPTR)MAKELONG(((char*)fun-(char*)dll->funs),dll->funhandle); } #define CALLER1REF (*(DWORD*)(MapSL( MAKESEGPTR(context->SegSs,LOWORD(context->Esp)+4)))) -static void WINAPI SNOOP16_Entry(FARPROC proc, LPBYTE args, CONTEXT *context) { +void WINAPI __wine_snoop_entry( CONTEXT *context ) +{ DWORD ordinal=0; DWORD entry=(DWORD)MapSL( MAKESEGPTR(context->SegCs,LOWORD(context->Eip)) )-5; WORD xcs = context->SegCs; @@ -273,7 +234,7 @@ static void WINAPI SNOOP16_Entry(FARPROC proc, LPBYTE args, CONTEXT *context) { } ret = &((*rets)->entry[i]); ret->lcall = 0x9a; - ret->snr = MAKELONG(sizeof(SNOOP16_RELAY),xsnr); + ret->snoop_return = GetProcAddress16( GetModuleHandle16( "KERNEL" ), "__wine_snoop_return" ); ret->origreturn = (FARPROC16)CALLER1REF; CALLER1REF = MAKELONG((char*)&(ret->lcall)-(char*)((*rets)->entry),(*rets)->rethandle); ret->dll = dll; @@ -301,7 +262,8 @@ static void WINAPI SNOOP16_Entry(FARPROC proc, LPBYTE args, CONTEXT *context) { TRACE(") ret=%04x:%04x\n",HIWORD(ret->origreturn),LOWORD(ret->origreturn)); } -static void WINAPI SNOOP16_Return(FARPROC proc, LPBYTE args, CONTEXT *context) { +void WINAPI __wine_snoop_return( CONTEXT *context ) +{ SNOOP16_RETURNENTRY *ret = (SNOOP16_RETURNENTRY*)((char *) MapSL( MAKESEGPTR(context->SegCs,LOWORD(context->Eip)) )-5); /* We haven't found out the nrofargs yet. If we called a cdecl
1
0
0
0
Zebediah Figura : krnl386: Return to a generated 16-bit entry point when calling builtin interrupt handlers.
by Alexandre Julliard
29 Sep '21
29 Sep '21
Module: wine Branch: master Commit: 5b38636b959a4dad631c39d9e3756b3cd996e61d URL:
https://source.winehq.org/git/wine.git/?a=commit;h=5b38636b959a4dad631c39d9…
Author: Zebediah Figura <zfigura(a)codeweavers.com> Date: Tue Sep 28 20:39:04 2021 -0500 krnl386: Return to a generated 16-bit entry point when calling builtin interrupt handlers. Instead of manually building a STACK16FRAME. Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ifsmgr.vxd/ifsmgr.c | 6 ++--- dlls/krnl386.exe16/dosexe.h | 6 +---- dlls/krnl386.exe16/dosmem.c | 14 ----------- dlls/krnl386.exe16/instr.c | 4 ++-- dlls/krnl386.exe16/interrupts.c | 37 +++++++++++++++-------------- dlls/krnl386.exe16/krnl386.exe16.spec | 3 ++- dlls/krnl386.exe16/relay.c | 44 ----------------------------------- dlls/vwin32.vxd/vwin32.c | 6 ++--- 8 files changed, 30 insertions(+), 90 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=5b38636b959a4dad631c…
1
0
0
0
Zebediah Figura : krnl386: Call DOSVM_IntProcRelay() via the application stack.
by Alexandre Julliard
29 Sep '21
29 Sep '21
Module: wine Branch: master Commit: a6118baa563d056ce3eb917e24b63b2f197d3d6a URL:
https://source.winehq.org/git/wine.git/?a=commit;h=a6118baa563d056ce3eb917e…
Author: Zebediah Figura <zfigura(a)codeweavers.com> Date: Tue Sep 28 20:39:03 2021 -0500 krnl386: Call DOSVM_IntProcRelay() via the application stack. Instead of using a dedicated stack. The dedicated stack was introduced by 9d7ff6c85b0827b7f54989050b4c34f1f459e94d, in order to support potentially nested DPMI interrupts. DPMI support was removed by ed6bdb3c51cd4b8c94f9839806321703e7aa9765; hence there is no longer a reason to account for nested interrupts. Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/krnl386.exe16/dosexe.h | 2 - dlls/krnl386.exe16/dosmem.c | 8 --- dlls/krnl386.exe16/interrupts.c | 9 +-- dlls/krnl386.exe16/relay.c | 132 +--------------------------------------- 4 files changed, 3 insertions(+), 148 deletions(-) diff --git a/dlls/krnl386.exe16/dosexe.h b/dlls/krnl386.exe16/dosexe.h index c4c8def5dce..42b8e0f4437 100644 --- a/dlls/krnl386.exe16/dosexe.h +++ b/dlls/krnl386.exe16/dosexe.h @@ -41,7 +41,6 @@ typedef void (WINAPI *INTPROC)(CONTEXT*); extern WORD DOSVM_psp DECLSPEC_HIDDEN; /* psp of current DOS task */ extern WORD int16_sel DECLSPEC_HIDDEN; extern WORD relay_code_sel DECLSPEC_HIDDEN; -extern WORD relay_data_sel DECLSPEC_HIDDEN; #define ADD_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD((DWORD)(dw)+(val))) @@ -247,7 +246,6 @@ extern DWORD DOSVM_inport( int port, int size ) DECLSPEC_HIDDEN; extern void DOSVM_outport( int port, int size, DWORD value ) DECLSPEC_HIDDEN; /* relay.c */ -void DOSVM_RelayHandler( CONTEXT * ) DECLSPEC_HIDDEN; void DOSVM_BuildCallFrame( CONTEXT *, DOSRELAY, LPVOID ) DECLSPEC_HIDDEN; #endif /* __WINE_DOSEXE_H */ diff --git a/dlls/krnl386.exe16/dosmem.c b/dlls/krnl386.exe16/dosmem.c index 36b02aec484..2d55eb050de 100644 --- a/dlls/krnl386.exe16/dosmem.c +++ b/dlls/krnl386.exe16/dosmem.c @@ -45,7 +45,6 @@ WORD DOSMEM_BiosSysSeg; /* BIOS ROM segment at 0xf000:0 */ WORD DOSVM_psp = 0; WORD int16_sel = 0; WORD relay_code_sel = 0; -WORD relay_data_sel = 0; /* DOS memory highest address (including HMA) */ #define DOSMEM_SIZE 0x110000 @@ -306,7 +305,6 @@ static void DOSMEM_InitSegments(void) static const char relay[]= { 0xca, 0x04, 0x00, /* 16-bit far return and pop 4 bytes (relay void* arg) */ - 0xcd, 0x31, /* int 31 */ }; /* @@ -330,17 +328,11 @@ static void DOSMEM_InitSegments(void) /* * PM / offset 0: Stub where __wine_call_from_16_regs returns. - * PM / offset 3: Stub which swaps back to 32-bit application code/stack. */ relay_code_sel = GLOBAL_Alloc( GMEM_FIXED, sizeof(relay), 0, LDT_FLAGS_CODE ); ptr = GlobalLock16( relay_code_sel ); memcpy( ptr, relay, sizeof(relay) ); GlobalUnlock16( relay_code_sel ); - - /* - * Space for 16-bit stack used by relay code. - */ - relay_data_sel = GlobalAlloc16( GMEM_FIXED | GMEM_ZEROINIT, DOSVM_RELAY_DATA_SIZE ); } /****************************************************************** diff --git a/dlls/krnl386.exe16/interrupts.c b/dlls/krnl386.exe16/interrupts.c index e2a129e4a20..d397d20072d 100644 --- a/dlls/krnl386.exe16/interrupts.c +++ b/dlls/krnl386.exe16/interrupts.c @@ -250,14 +250,7 @@ BOOL DOSVM_EmulateInterruptPM( CONTEXT *context, BYTE intnum ) DOSMEM_InitDosMemory(); - if (context->SegCs == relay_code_sel) - { - /* - * This must not be called using DOSVM_BuildCallFrame. - */ - DOSVM_RelayHandler( context ); - } - else if (context->SegCs == int16_sel) + if (context->SegCs == int16_sel) { /* Restore original flags stored into the stack by the caller. */ WORD *stack = CTX_SEG_OFF_TO_LIN(context, diff --git a/dlls/krnl386.exe16/relay.c b/dlls/krnl386.exe16/relay.c index 3559bb460a7..116198e5ddb 100644 --- a/dlls/krnl386.exe16/relay.c +++ b/dlls/krnl386.exe16/relay.c @@ -34,26 +34,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(relay); -/* - * Magic DWORD used to check stack integrity. - */ -#define RELAY_MAGIC 0xabcdef00 - -/* - * Memory block for temporary 16-bit stacks used with relay calls. - */ -typedef struct { - DWORD inuse; /* non-zero if stack block is in use */ - DWORD eip; /* saved ip */ - DWORD seg_cs; /* saved cs */ - DWORD esp; /* saved sp */ - DWORD seg_ss; /* saved ss */ - DWORD stack_bottom; /* guard dword */ - BYTE stack[256-7*4]; /* 16-bit stack */ - DWORD stack_top; /* guard dword */ -} RELAY_Stack16; - - static const char **debug_relay_excludelist; static const char **debug_relay_includelist; static const char **debug_snoop_excludelist; @@ -572,58 +552,6 @@ int relay_call_from_16( void *entry_point, unsigned char *args16, CONTEXT *conte return ret_val; } -/********************************************************************** - * RELAY_GetPointer - * - * Get pointer to stack block when given esp pointing to 16-bit stack - * inside relay data segment. - */ -static RELAY_Stack16 *RELAY_GetPointer( DWORD offset ) -{ - offset = offset / sizeof(RELAY_Stack16) * sizeof(RELAY_Stack16); - return MapSL(MAKESEGPTR(relay_data_sel, offset)); -} - - -/********************************************************************** - * RELAY_MakeShortContext - * - * Allocate separate 16-bit stack, make stack pointer point to this - * stack and make code pointer point to stub that restores everything. - * So, after this routine, SS and CS are guaranteed to be 16-bit. - * - * Note: This might be called from signal handler, so the stack - * allocation algorithm must be signal safe. - */ -static void RELAY_MakeShortContext( CONTEXT *context ) -{ - DWORD offset = offsetof(RELAY_Stack16, stack_top); - RELAY_Stack16 *stack = RELAY_GetPointer( 0 ); - - while (stack->inuse && offset < DOSVM_RELAY_DATA_SIZE) { - stack++; - offset += sizeof(RELAY_Stack16); - } - - if (offset >= DOSVM_RELAY_DATA_SIZE) - ERR( "Too many nested interrupts!\n" ); - - stack->inuse = 1; - stack->eip = context->Eip; - stack->seg_cs = context->SegCs; - stack->esp = context->Esp; - stack->seg_ss = context->SegSs; - - stack->stack_bottom = RELAY_MAGIC; - stack->stack_top = RELAY_MAGIC; - - context->SegSs = relay_data_sel; - context->Esp = offset; - context->SegCs = relay_code_sel; - context->Eip = 3; -} - - /********************************************************************** * RELAY_RelayStub * @@ -632,58 +560,9 @@ static void RELAY_MakeShortContext( CONTEXT *context ) */ static void __stdcall RELAY_RelayStub( DOSRELAY proc, unsigned char *args, CONTEXT *context ) { - if (proc) - { - RELAY_Stack16 *stack = RELAY_GetPointer( context->Esp ); - - DWORD old_seg_cs = context->SegCs; - DWORD old_eip = context->Eip; - DWORD old_seg_ss = context->SegSs; - DWORD old_esp = context->Esp; - - context->SegCs = stack->seg_cs; - context->Eip = stack->eip; - context->SegSs = stack->seg_ss; - context->Esp = stack->esp; - - proc( context, *(LPVOID *)args ); - - stack->seg_cs = context->SegCs; - stack->eip = context->Eip; - stack->seg_ss = context->SegSs; - stack->esp = context->Esp; - - context->SegCs = old_seg_cs; - context->Eip = old_eip; - context->SegSs = old_seg_ss; - context->Esp = old_esp; - } + proc( context, *(LPVOID *)args ); } - -/********************************************************************** - * DOSVM_RelayHandler - * - * Restore saved code and stack pointers and release stack block. - */ -void DOSVM_RelayHandler( CONTEXT *context ) -{ - RELAY_Stack16 *stack = RELAY_GetPointer( context->Esp ); - - context->SegSs = stack->seg_ss; - context->Esp = stack->esp; - context->SegCs = stack->seg_cs; - context->Eip = stack->eip; - - if (!stack->inuse || - stack->stack_bottom != RELAY_MAGIC || - stack->stack_top != RELAY_MAGIC) - ERR( "Stack corrupted!\n" ); - - stack->inuse = 0; -} - - /********************************************************************** * DOSVM_BuildCallFrame * @@ -692,13 +571,6 @@ void DOSVM_RelayHandler( CONTEXT *context ) */ void DOSVM_BuildCallFrame( CONTEXT *context, DOSRELAY relay, LPVOID data ) { - WORD code_sel = relay_code_sel; - - /* - * Allocate separate stack for relay call. - */ - RELAY_MakeShortContext( context ); - /* * Build call frame. */ @@ -713,7 +585,7 @@ void DOSVM_BuildCallFrame( CONTEXT *context, DOSRELAY relay, LPVOID data ) PUSH_WORD16( context, HIWORD(RELAY_RelayStub) ); /* STACK16FRAME.relay.hiword */ PUSH_WORD16( context, LOWORD(RELAY_RelayStub) ); /* STACK16FRAME.relay.loword */ PUSH_WORD16( context, 0 ); /* STACK16FRAME.module_cs.hiword */ - PUSH_WORD16( context, code_sel ); /* STACK16FRAME.module_cs.loword */ + PUSH_WORD16( context, relay_code_sel ); /* STACK16FRAME.module_cs.loword */ PUSH_WORD16( context, 0 ); /* STACK16FRAME.callfrom_ip.hiword */ PUSH_WORD16( context, 0 ); /* STACK16FRAME.callfrom_ip.loword */
1
0
0
0
Paul Gofman : kernelbase: Use LdrGetDllFullName() in GetModuleFileNameW().
by Alexandre Julliard
29 Sep '21
29 Sep '21
Module: wine Branch: master Commit: 43d14fd808bb965762bb6c76027bbe26ba936f82 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=43d14fd808bb965762bb6c76…
Author: Paul Gofman <pgofman(a)codeweavers.com> Date: Wed Sep 29 04:20:26 2021 +0300 kernelbase: Use LdrGetDllFullName() in GetModuleFileNameW(). Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernelbase/loader.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/dlls/kernelbase/loader.c b/dlls/kernelbase/loader.c index 53c6750e668..145d721bc26 100644 --- a/dlls/kernelbase/loader.c +++ b/dlls/kernelbase/loader.c @@ -298,9 +298,9 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetModuleFileNameA( HMODULE module, LPSTR filenam DWORD WINAPI DECLSPEC_HOTPATCH GetModuleFileNameW( HMODULE module, LPWSTR filename, DWORD size ) { ULONG len = 0; - ULONG_PTR magic; - LDR_DATA_TABLE_ENTRY *pldr; WIN16_SUBSYSTEM_TIB *win16_tib; + UNICODE_STRING name; + NTSTATUS status; if (!module && ((win16_tib = NtCurrentTeb()->Tib.SubSystemTib)) && win16_tib->exe_name) { @@ -310,22 +310,11 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetModuleFileNameW( HMODULE module, LPWSTR filena goto done; } - LdrLockLoaderLock( 0, NULL, &magic ); - - if (!module) module = NtCurrentTeb()->Peb->ImageBaseAddress; - if (set_ntstatus( LdrFindEntryForAddress( module, &pldr ))) - { - len = min( size, pldr->FullDllName.Length / sizeof(WCHAR) ); - memcpy( filename, pldr->FullDllName.Buffer, len * sizeof(WCHAR) ); - if (len < size) - { - filename[len] = 0; - SetLastError( 0 ); - } - else SetLastError( ERROR_INSUFFICIENT_BUFFER ); - } - - LdrUnlockLoaderLock( 0, magic ); + name.Buffer = filename; + name.MaximumLength = size * sizeof(WCHAR); + status = LdrGetDllFullName( module, &name ); + if (!status || status == STATUS_BUFFER_TOO_SMALL) len = name.Length / sizeof(WCHAR); + SetLastError( RtlNtStatusToDosError( status )); done: TRACE( "%s\n", debugstr_wn(filename, len) ); return len;
1
0
0
0
Paul Gofman : ntdll: Implement LdrGetDllFullName() function.
by Alexandre Julliard
29 Sep '21
29 Sep '21
Module: wine Branch: master Commit: 39a3549093c670fc1dd7251ddb037b48d8086c71 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=39a3549093c670fc1dd7251d…
Author: Paul Gofman <pgofman(a)codeweavers.com> Date: Wed Sep 29 04:20:25 2021 +0300 ntdll: Implement LdrGetDllFullName() function. Based on a patch by Alex Henrie. Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernel32/tests/module.c | 2 +- dlls/ntdll/loader.c | 26 ++++++++++++++++++++++++++ dlls/ntdll/ntdll.spec | 1 + include/winternl.h | 1 + 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/dlls/kernel32/tests/module.c b/dlls/kernel32/tests/module.c index eac4f478293..2487b9d65ab 100644 --- a/dlls/kernel32/tests/module.c +++ b/dlls/kernel32/tests/module.c @@ -1278,7 +1278,7 @@ static void test_LdrGetDllFullName(void) if (!pLdrGetDllFullName) { - skip( "LdrGetDllFullName not available.\n" ); + win_skip( "LdrGetDllFullName not available.\n" ); return; } diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 3e3f991eba2..e00c1e0c31d 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -2995,6 +2995,32 @@ NTSTATUS WINAPI DECLSPEC_HOTPATCH LdrLoadDll(LPCWSTR path_name, DWORD flags, } +/****************************************************************** + * LdrGetDllFullName (NTDLL.@) + */ +NTSTATUS WINAPI LdrGetDllFullName( HMODULE module, UNICODE_STRING *name ) +{ + WINE_MODREF *wm; + NTSTATUS status; + + TRACE( "module %p, name %p.\n", module, name ); + + if (!module) module = NtCurrentTeb()->Peb->ImageBaseAddress; + + RtlEnterCriticalSection( &loader_section ); + wm = get_modref( module ); + if (wm) + { + RtlCopyUnicodeString( name, &wm->ldr.FullDllName ); + if (name->MaximumLength < wm->ldr.FullDllName.Length + sizeof(WCHAR)) status = STATUS_BUFFER_TOO_SMALL; + else status = STATUS_SUCCESS; + } else status = STATUS_DLL_NOT_FOUND; + RtlLeaveCriticalSection( &loader_section ); + + return status; +} + + /****************************************************************** * LdrGetDllHandleEx (NTDLL.@) */ diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index e7ac08e94ba..13e65f65139 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -87,6 +87,7 @@ @ stdcall LdrFindResource_U(long ptr long ptr) @ stub LdrFlushAlternateResourceModules @ stdcall LdrGetDllDirectory(ptr) +@ stdcall LdrGetDllFullName(long ptr) @ stdcall LdrGetDllHandle(wstr long ptr ptr) @ stdcall LdrGetDllHandleEx(long ptr ptr ptr ptr) # @ stub LdrGetDllHandleEx diff --git a/include/winternl.h b/include/winternl.h index 2b8acc624b5..200756569d5 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -3784,6 +3784,7 @@ NTSYSAPI NTSTATUS WINAPI LdrGetDllDirectory(UNICODE_STRING*); NTSYSAPI NTSTATUS WINAPI LdrGetDllHandle(LPCWSTR, ULONG, const UNICODE_STRING*, HMODULE*); NTSYSAPI NTSTATUS WINAPI LdrGetDllHandleEx(ULONG, LPCWSTR, ULONG *, const UNICODE_STRING*, HMODULE*); NTSYSAPI NTSTATUS WINAPI LdrGetDllPath(PCWSTR,ULONG,PWSTR*,PWSTR*); +NTSYSAPI NTSTATUS WINAPI LdrGetDllFullName(HMODULE, UNICODE_STRING*); NTSYSAPI NTSTATUS WINAPI LdrGetProcedureAddress(HMODULE, const ANSI_STRING*, ULONG, void**); NTSYSAPI NTSTATUS WINAPI LdrLoadDll(LPCWSTR, DWORD, const UNICODE_STRING*, HMODULE*); NTSYSAPI NTSTATUS WINAPI LdrLockLoaderLock(ULONG,ULONG*,ULONG_PTR*);
1
0
0
0
← Newer
1
...
5
6
7
8
9
10
11
...
103
Older →
Jump to page:
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
Results per page:
10
25
50
100
200