From: William A. Rowe Jr Date: Mon, 1 Jul 2002 18:24:54 +0000 (+0000) Subject: Eliminate GetModuleFileName() X-Git-Tag: 2.0.40~343 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=da73839710e28fb26136de5c538a41205c8a2f91;p=apache Eliminate GetModuleFileName() git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95931 13f79535-47bb-0310-9956-ffa450edef68 --- 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