#include "mpm_winnt.h"
#include "apr_strings.h"
#include "apr_lib.h"
+#include "ap_regkey.h"
static char *display_name = NULL;
static HANDLE stderr_thread = NULL;
char *errmsg = errbuf;
const char *errarg[9];
DWORD errres;
- HKEY hk;
+ ap_regkey_t *regkey;
+ apr_status_t rv;
+ apr_pool_t *p;
+ apr_pool_sub_make(&p, NULL, NULL);
+
errarg[0] = "The Apache service named";
errarg[1] = display_name;
errarg[2] = "reported the following error:\r\n>>>";
errarg[8] = NULL;
/* What are we going to do in here, bail on the user? not. */
- if (!RegCreateKey(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services"
- "\\EventLog\\Application\\Apache Service", &hk))
+ if ((rv = ap_regkey_open(®key, AP_REGKEY_LOCAL_MACHINE,
+ "SYSTEM\\CurrentControlSet\\Services\\"
+ "EventLog\\Application\\Apache Service",
+ APR_READ | APR_WRITE | APR_CREATE, p))
+ == APR_SUCCESS)
{
- /* The stock message file */
- char *netmsgkey = "%SystemRoot%\\System32\\netmsg.dll";
DWORD dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE |
EVENTLOG_INFORMATION_TYPE;
- RegSetValueEx(hk, "EventMessageFile", 0, REG_EXPAND_SZ,
- (LPBYTE) netmsgkey, strlen(netmsgkey) + 1);
+ /* The stock message file */
+ ap_regkey_value_set(regkey, "EventMessageFile",
+ "%SystemRoot%\\System32\\netmsg.dll",
+ AP_REGKEY_EXPAND, p);
- RegSetValueEx(hk, "TypesSupported", 0, REG_DWORD,
- (LPBYTE) &dwData, sizeof(dwData));
- RegCloseKey(hk);
+ ap_regkey_value_raw_set(regkey, "TypesSupported", &dwData,
+ sizeof(dwData), REG_DWORD, p);
+ ap_regkey_close(regkey);
}
- hEventSource = RegisterEventSource(NULL, "Apache Service");
+ hEventSource = RegisterEventSourceW(NULL, L"Apache Service");
SetEvent(stderr_ready);
DeregisterEventSource(hEventSource);
CloseHandle(stderr_thread);
stderr_thread = NULL;
+ apr_pool_destroy(p);
return 0;
}
"SYSTEM\\CurrentControlSet\\Services\\%s",
mpm_service_name);
rv = ap_regkey_open(&svckey, AP_REGKEY_LOCAL_MACHINE, szPath,
- APR_WRITE, pconf);
+ APR_READ | APR_WRITE, pconf);
if (rv != APR_SUCCESS) {
return;
}
/* Attempt to set the Description value for our service */
- ap_regkey_value_set(svckey, "Description", full_description, pconf);
+ ap_regkey_value_set(svckey, "Description", full_description, 0, pconf);
ap_regkey_close(svckey);
}
}
launch_cmd = apr_psprintf(ptemp, "\"%s\" -n %s -k runservice",
exe_path, mpm_service_name);
rv = ap_regkey_open(&key, AP_REGKEY_LOCAL_MACHINE, SERVICECONFIG9X,
- APR_READ, pconf);
+ APR_READ | APR_WRITE | APR_CREATE, pconf);
if (rv == APR_SUCCESS) {
- rv = ap_regkey_value_set(key, mpm_service_name, launch_cmd, pconf);
+ rv = ap_regkey_value_set(key, mpm_service_name,
+ launch_cmd, 0, pconf);
ap_regkey_close(key);
}
if (rv != APR_SUCCESS) {
apr_snprintf(key_name, sizeof(key_name), SERVICECONFIG, mpm_service_name);
rv = ap_regkey_open(&key, AP_REGKEY_LOCAL_MACHINE, key_name,
- APR_READ, pconf);
+ APR_READ | APR_WRITE | APR_CREATE, pconf);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
"%s: Failed to create the registry service key.",
mpm_display_name);
return (rv);
}
- rv = ap_regkey_value_set(key, "ImagePath", launch_cmd, pconf);
+ rv = ap_regkey_value_set(key, "ImagePath", launch_cmd, 0, pconf);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
"%s: Failed to store ImagePath in the registry.",
ap_regkey_close(key);
return (rv);
}
- rv = ap_regkey_value_set(key, "DisplayName", mpm_display_name, pconf);
+ rv = ap_regkey_value_set(key, "DisplayName",
+ mpm_display_name, 0, pconf);
ap_regkey_close(key);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL,
*/
apr_snprintf(key_name, sizeof(key_name), SERVICEPARAMS, mpm_service_name);
rv = ap_regkey_open(&key, AP_REGKEY_LOCAL_MACHINE, key_name,
- APR_READ, pconf);
+ APR_READ | APR_WRITE | APR_CREATE, pconf);
if (rv == APR_SUCCESS) {
rv = ap_regkey_value_array_set(key, "ConfigArgs", argc, argv, pconf);
ap_regkey_close(key);
/* TODO: assure the service is stopped before continuing */
rv = ap_regkey_open(&key, AP_REGKEY_LOCAL_MACHINE, SERVICECONFIG9X,
- APR_WRITE, pconf);
+ APR_READ | APR_WRITE | APR_CREATE, pconf);
if (rv == APR_SUCCESS) {
rv = ap_regkey_value_remove(key, mpm_service_name, pconf);
ap_regkey_close(key);