From f5f4262a9f4e41f4b16721b91405e788781f77d1 Mon Sep 17 00:00:00 2001 From: "William A. Rowe Jr" Date: Mon, 1 Jul 2002 18:24:54 +0000 Subject: [PATCH] Eliminate GetModuleFileName() git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95931 13f79535-47bb-0310-9956-ffa450edef68 --- server/mpm/winnt/mpm_winnt.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/server/mpm/winnt/mpm_winnt.c b/server/mpm/winnt/mpm_winnt.c index c695d43758..868c73a9bb 100644 --- a/server/mpm/winnt/mpm_winnt.c +++ b/server/mpm/winnt/mpm_winnt.c @@ -2002,7 +2002,7 @@ void winnt_rewrite_args(process_rec *process) */ apr_status_t rv; char *def_server_root; - char fnbuf[MAX_PATH]; + char *binpath; char optbuf[3]; const char *optarg; int fixed_args; @@ -2054,23 +2054,23 @@ void winnt_rewrite_args(process_rec *process) * The requested service's (-n) registry ConfigArgs * The WinNT SCM's StartService() args */ - if (!GetModuleFileName(NULL, fnbuf, sizeof(fnbuf))) { - rv = apr_get_os_error(); + if ((rv = ap_os_proc_filepath(&binpath, process->pconf)) + != APR_SUCCESS) { ap_log_error(APLOG_MARK,APLOG_CRIT, rv, NULL, - "Failed to get the path of Apache.exe"); + "Failed to get the full path of %s", process->argv[0]); exit(APEXIT_INIT); } /* WARNING: There is an implict assumption here that the * executable resides in ServerRoot or ServerRoot\bin */ - def_server_root = (char *) apr_filename_of_pathname(fnbuf); - if (def_server_root > fnbuf) { + def_server_root = (char *) apr_filename_of_pathname(binpath); + if (def_server_root > binpath) { *(def_server_root - 1) = '\0'; - def_server_root = (char *) apr_filename_of_pathname(fnbuf); + def_server_root = (char *) apr_filename_of_pathname(binpath); if (!strcasecmp(def_server_root, "bin")) *(def_server_root - 1) = '\0'; } - apr_filepath_merge(&def_server_root, NULL, fnbuf, + apr_filepath_merge(&def_server_root, NULL, binpath, APR_FILEPATH_TRUENAME, process->pool); /* Use process->pool so that the rewritten argv -- 2.50.1