31 #define STRSAFE_NO_DEPRECATE
35 #define _WIN32_WINNT 0x0501
39 #include "dbus-internals.h"
41 #include "dbus-sysdeps.h"
42 #include "dbus-threads.h"
43 #include "dbus-protocol.h"
44 #include "dbus-string.h"
45 #include "dbus-sysdeps.h"
46 #include "dbus-sysdeps-win.h"
47 #include "dbus-protocol.h"
48 #include "dbus-hash.h"
49 #include "dbus-sockets-win.h"
50 #include "dbus-list.h"
51 #include "dbus-nonce.h"
52 #include "dbus-credentials.h"
59 extern BOOL WINAPI ConvertStringSidToSidA (LPCSTR StringSid, PSID *Sid);
60 extern BOOL WINAPI ConvertSidToStringSidA (PSID Sid, LPSTR *StringSid);
71 #include <sys/types.h>
74 #ifdef HAVE_WS2TCPIP_H
87 #endif // HAVE_WSPIAPI_H
93 typedef int socklen_t;
97 _dbus_win_set_errno (
int err)
109 _dbus_win_error_from_last_error (
void)
111 switch (GetLastError())
116 case ERROR_NO_MORE_FILES:
117 case ERROR_TOO_MANY_OPEN_FILES:
120 case ERROR_ACCESS_DENIED:
121 case ERROR_CANNOT_MAKE:
124 case ERROR_NOT_ENOUGH_MEMORY:
127 case ERROR_FILE_EXISTS:
130 case ERROR_FILE_NOT_FOUND:
131 case ERROR_PATH_NOT_FOUND:
140 _dbus_win_error_string (
int error_number)
144 FormatMessageA (FORMAT_MESSAGE_ALLOCATE_BUFFER |
145 FORMAT_MESSAGE_IGNORE_INSERTS |
146 FORMAT_MESSAGE_FROM_SYSTEM,
147 NULL, error_number, 0,
148 (LPSTR) &msg, 0,
NULL);
150 if (msg[strlen (msg) - 1] ==
'\n')
151 msg[strlen (msg) - 1] =
'\0';
152 if (msg[strlen (msg) - 1] ==
'\r')
153 msg[strlen (msg) - 1] =
'\0';
159 _dbus_win_free_error_string (
char *
string)
199 _dbus_win_set_errno (ENOMEM);
207 _dbus_verbose (
"recv: count=%d fd=%d\n", count, fd);
208 bytes_read = recv (fd, data, count, 0);
210 if (bytes_read == SOCKET_ERROR)
212 DBUS_SOCKET_SET_ERRNO();
213 _dbus_verbose (
"recv: failed: %s (%d)\n", _dbus_strerror (errno), errno);
217 _dbus_verbose (
"recv: = %d\n", bytes_read);
267 _dbus_verbose (
"send: len=%d fd=%d\n", len, fd);
268 bytes_written = send (fd, data, len, 0);
270 if (bytes_written == SOCKET_ERROR)
272 DBUS_SOCKET_SET_ERRNO();
277 _dbus_verbose (
"send: = %d\n", bytes_written);
279 if (bytes_written < 0 && errno == EINTR)
283 if (bytes_written > 0)
287 return bytes_written;
302 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
305 if (closesocket (fd) == SOCKET_ERROR)
307 DBUS_SOCKET_SET_ERRNO ();
313 "Could not close socket: socket=%d, , %s",
317 _dbus_verbose (
"_dbus_close_socket: socket=%d, \n", fd);
332 if ( !SetHandleInformation( (HANDLE) handle,
333 HANDLE_FLAG_INHERIT | HANDLE_FLAG_PROTECT_FROM_CLOSE,
336 _dbus_win_warn_win_error (
"Disabling socket handle inheritance failed:", GetLastError());
348 _dbus_set_fd_nonblocking (
int handle,
353 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
355 if (ioctlsocket (handle, FIONBIO, &one) == SOCKET_ERROR)
357 DBUS_SOCKET_SET_ERRNO ();
359 "Failed to set socket %d:%d to nonblocking: %s", handle,
421 vectors[0].buf = (
char*) data1;
422 vectors[0].len = len1;
423 vectors[1].buf = (
char*) data2;
424 vectors[1].len = len2;
428 _dbus_verbose (
"WSASend: len1+2=%d+%d fd=%d\n", len1, len2, fd);
437 if (rc == SOCKET_ERROR)
439 DBUS_SOCKET_SET_ERRNO ();
444 _dbus_verbose (
"WSASend: = %ld\n", bytes_written);
446 if (bytes_written < 0 && errno == EINTR)
449 return bytes_written;
453 _dbus_socket_is_invalid (
int fd)
455 return fd == INVALID_SOCKET ?
TRUE :
FALSE;
469 _dbus_connect_named_pipe (
const char *path,
480 _dbus_win_startup_winsock (
void)
486 WORD wVersionRequested;
493 wVersionRequested = MAKEWORD (2, 0);
495 err = WSAStartup (wVersionRequested, &wsaData);
507 if (LOBYTE (wsaData.wVersion) != 2 ||
508 HIBYTE (wsaData.wVersion) != 0)
542 bufsize =
sizeof (buf);
543 len = _vsnprintf (buf, bufsize - 1, format, args);
551 p = malloc (bufsize);
552 len = _vsnprintf (p, bufsize - 1, format, args);
568 _dbus_win_utf8_to_utf16 (
const char *str,
583 n = MultiByteToWideChar (CP_UTF8, 0, str, -1,
NULL, 0);
587 _dbus_win_set_error_from_win_error (error, GetLastError ());
595 _DBUS_SET_OOM (error);
599 if (MultiByteToWideChar (CP_UTF8, 0, str, -1, retval, n) != n)
617 _dbus_win_utf16_to_utf8 (
const wchar_t *str,
623 n = WideCharToMultiByte (CP_UTF8, 0, str, -1,
NULL, 0,
NULL,
NULL);
627 _dbus_win_set_error_from_win_error (error, GetLastError ());
635 _DBUS_SET_OOM (error);
639 if (WideCharToMultiByte (CP_UTF8, 0, str, -1, retval, n,
NULL,
NULL) != n)
660 _dbus_win_account_to_sid (
const wchar_t *waccount,
665 DWORD sid_length, wdomain_length;
673 if (!LookupAccountNameW (
NULL, waccount,
NULL, &sid_length,
674 NULL, &wdomain_length, &use) &&
675 GetLastError () != ERROR_INSUFFICIENT_BUFFER)
677 _dbus_win_set_error_from_win_error (error, GetLastError ());
684 _DBUS_SET_OOM (error);
688 wdomain =
dbus_new (
wchar_t, wdomain_length);
691 _DBUS_SET_OOM (error);
695 if (!LookupAccountNameW (
NULL, waccount, (PSID) *ppsid, &sid_length,
696 wdomain, &wdomain_length, &use))
698 _dbus_win_set_error_from_win_error (error, GetLastError ());
702 if (!IsValidSid ((PSID) *ppsid))
744 _dbus_getsid(
char **sid)
746 HANDLE process_token = INVALID_HANDLE_VALUE;
747 TOKEN_USER *token_user =
NULL;
752 if (!OpenProcessToken (GetCurrentProcess (), TOKEN_QUERY, &process_token))
754 _dbus_win_warn_win_error (
"OpenProcessToken failed", GetLastError ());
757 if ((!GetTokenInformation (process_token, TokenUser,
NULL, 0, &n)
758 && GetLastError () != ERROR_INSUFFICIENT_BUFFER)
759 || (token_user = alloca (n)) ==
NULL
760 || !GetTokenInformation (process_token, TokenUser, token_user, n, &n))
762 _dbus_win_warn_win_error (
"GetTokenInformation failed", GetLastError ());
765 psid = token_user->User.Sid;
766 if (!IsValidSid (psid))
768 _dbus_verbose(
"%s invalid sid\n",__FUNCTION__);
771 if (!ConvertSidToStringSidA (psid, sid))
773 _dbus_verbose(
"%s invalid sid\n",__FUNCTION__);
780 if (process_token != INVALID_HANDLE_VALUE)
781 CloseHandle (process_token);
783 _dbus_verbose(
"_dbus_getsid() returns %d\n",retval);
815 SOCKET temp, socket1 = -1, socket2 = -1;
816 struct sockaddr_in saddr;
819 fd_set read_set, write_set;
823 _dbus_win_startup_winsock ();
825 temp = socket (AF_INET, SOCK_STREAM, 0);
826 if (temp == INVALID_SOCKET)
828 DBUS_SOCKET_SET_ERRNO ();
833 saddr.sin_family = AF_INET;
835 saddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
837 if (bind (temp, (
struct sockaddr *)&saddr,
sizeof (saddr)) == SOCKET_ERROR)
839 DBUS_SOCKET_SET_ERRNO ();
843 if (listen (temp, 1) == SOCKET_ERROR)
845 DBUS_SOCKET_SET_ERRNO ();
849 len =
sizeof (saddr);
850 if (getsockname (temp, (
struct sockaddr *)&saddr, &len) == SOCKET_ERROR)
852 DBUS_SOCKET_SET_ERRNO ();
856 socket1 = socket (AF_INET, SOCK_STREAM, 0);
857 if (socket1 == INVALID_SOCKET)
859 DBUS_SOCKET_SET_ERRNO ();
863 if (connect (socket1, (
struct sockaddr *)&saddr, len) == SOCKET_ERROR)
865 DBUS_SOCKET_SET_ERRNO ();
869 socket2 = accept (temp, (
struct sockaddr *) &saddr, &len);
870 if (socket2 == INVALID_SOCKET)
872 DBUS_SOCKET_SET_ERRNO ();
879 if (ioctlsocket (socket1, FIONBIO, &arg) == SOCKET_ERROR)
881 DBUS_SOCKET_SET_ERRNO ();
886 if (ioctlsocket (socket2, FIONBIO, &arg) == SOCKET_ERROR)
888 DBUS_SOCKET_SET_ERRNO ();
896 _dbus_verbose (
"full-duplex pipe %d:%d <-> %d:%d\n",
897 *fd1, socket1, *fd2, socket2);
904 closesocket (socket2);
906 closesocket (socket1);
911 "Could not setup socket pair: %s",
928 int timeout_milliseconds)
930 #define USE_CHRIS_IMPL 0
934 #define DBUS_POLL_CHAR_BUFFER_SIZE 2000
935 char msg[DBUS_POLL_CHAR_BUFFER_SIZE];
943 #define DBUS_STACK_WSAEVENTS 256
944 WSAEVENT eventsOnStack[DBUS_STACK_WSAEVENTS];
945 WSAEVENT *pEvents =
NULL;
946 if (n_fds > DBUS_STACK_WSAEVENTS)
947 pEvents = calloc(
sizeof(WSAEVENT), n_fds);
949 pEvents = eventsOnStack;
952 #ifdef DBUS_ENABLE_VERBOSE_MODE
954 msgp += sprintf (msgp,
"WSAEventSelect: to=%d\n\t", timeout_milliseconds);
955 for (i = 0; i < n_fds; i++)
962 msgp += sprintf (msgp,
"R:%d ", fdp->
fd);
965 msgp += sprintf (msgp,
"W:%d ", fdp->
fd);
967 msgp += sprintf (msgp,
"E:%d\n\t", fdp->
fd);
971 if (msgp >= msg + DBUS_POLL_CHAR_BUFFER_SIZE)
977 msgp += sprintf (msgp,
"\n");
978 _dbus_verbose (
"%s",msg);
980 for (i = 0; i < n_fds; i++)
984 long lNetworkEvents = FD_OOB;
986 ev = WSACreateEvent();
989 lNetworkEvents |= FD_READ | FD_ACCEPT | FD_CLOSE;
992 lNetworkEvents |= FD_WRITE | FD_CONNECT;
994 WSAEventSelect(fdp->
fd, ev, lNetworkEvents);
1000 ready = WSAWaitForMultipleEvents (n_fds, pEvents,
FALSE, timeout_milliseconds,
FALSE);
1002 if (DBUS_SOCKET_API_RETURNS_ERROR (ready))
1004 DBUS_SOCKET_SET_ERRNO ();
1005 if (errno != WSAEWOULDBLOCK)
1009 else if (ready == WSA_WAIT_TIMEOUT)
1011 _dbus_verbose (
"WSAWaitForMultipleEvents: WSA_WAIT_TIMEOUT\n");
1014 else if (ready >= WSA_WAIT_EVENT_0 && ready < (
int)(WSA_WAIT_EVENT_0 + n_fds))
1017 msgp += sprintf (msgp,
"WSAWaitForMultipleEvents: =%d\n\t", ready);
1019 for (i = 0; i < n_fds; i++)
1022 WSANETWORKEVENTS ne;
1026 WSAEnumNetworkEvents(fdp->
fd, pEvents[i], &ne);
1028 if (ne.lNetworkEvents & (FD_READ | FD_ACCEPT | FD_CLOSE))
1031 if (ne.lNetworkEvents & (FD_WRITE | FD_CONNECT))
1034 if (ne.lNetworkEvents & (FD_OOB))
1037 if (ne.lNetworkEvents & (FD_READ | FD_ACCEPT | FD_CLOSE))
1038 msgp += sprintf (msgp,
"R:%d ", fdp->
fd);
1040 if (ne.lNetworkEvents & (FD_WRITE | FD_CONNECT))
1041 msgp += sprintf (msgp,
"W:%d ", fdp->
fd);
1043 if (ne.lNetworkEvents & (FD_OOB))
1044 msgp += sprintf (msgp,
"E:%d ", fdp->
fd);
1046 msgp += sprintf (msgp,
"lNetworkEvents:%d ", ne.lNetworkEvents);
1048 if(ne.lNetworkEvents)
1051 WSAEventSelect(fdp->
fd, pEvents[i], 0);
1054 msgp += sprintf (msgp,
"\n");
1055 _dbus_verbose (
"%s",msg);
1059 _dbus_verbose (
"WSAWaitForMultipleEvents: failed for unknown reason!");
1063 for(i = 0; i < n_fds; i++)
1065 WSACloseEvent(pEvents[i]);
1068 if (n_fds > DBUS_STACK_WSAEVENTS)
1075 #define DBUS_POLL_CHAR_BUFFER_SIZE 2000
1076 char msg[DBUS_POLL_CHAR_BUFFER_SIZE];
1079 fd_set read_set, write_set, err_set;
1085 FD_ZERO (&read_set);
1086 FD_ZERO (&write_set);
1090 #ifdef DBUS_ENABLE_VERBOSE_MODE
1092 msgp += sprintf (msgp,
"select: to=%d\n\t", timeout_milliseconds);
1093 for (i = 0; i < n_fds; i++)
1100 msgp += sprintf (msgp,
"R:%d ", fdp->
fd);
1103 msgp += sprintf (msgp,
"W:%d ", fdp->
fd);
1105 msgp += sprintf (msgp,
"E:%d\n\t", fdp->
fd);
1109 if (msgp >= msg + DBUS_POLL_CHAR_BUFFER_SIZE)
1115 msgp += sprintf (msgp,
"\n");
1116 _dbus_verbose (
"%s",msg);
1118 for (i = 0; i < n_fds; i++)
1123 FD_SET (fdp->
fd, &read_set);
1126 FD_SET (fdp->
fd, &write_set);
1128 FD_SET (fdp->
fd, &err_set);
1130 max_fd = MAX (max_fd, fdp->
fd);
1134 tv.tv_sec = timeout_milliseconds < 0 ? 1 : timeout_milliseconds / 1000;
1135 tv.tv_usec = timeout_milliseconds < 0 ? 0 : (timeout_milliseconds % 1000) * 1000;
1137 ready = select (max_fd + 1, &read_set, &write_set, &err_set, &tv);
1139 if (DBUS_SOCKET_API_RETURNS_ERROR (ready))
1141 DBUS_SOCKET_SET_ERRNO ();
1142 if (errno != WSAEWOULDBLOCK)
1145 else if (ready == 0)
1146 _dbus_verbose (
"select: = 0\n");
1150 #ifdef DBUS_ENABLE_VERBOSE_MODE
1152 msgp += sprintf (msgp,
"select: = %d:\n\t", ready);
1154 for (i = 0; i < n_fds; i++)
1158 if (FD_ISSET (fdp->
fd, &read_set))
1159 msgp += sprintf (msgp,
"R:%d ", fdp->
fd);
1161 if (FD_ISSET (fdp->
fd, &write_set))
1162 msgp += sprintf (msgp,
"W:%d ", fdp->
fd);
1164 if (FD_ISSET (fdp->
fd, &err_set))
1165 msgp += sprintf (msgp,
"E:%d\n\t", fdp->
fd);
1167 msgp += sprintf (msgp,
"\n");
1168 _dbus_verbose (
"%s",msg);
1171 for (i = 0; i < n_fds; i++)
1177 if (FD_ISSET (fdp->
fd, &read_set))
1180 if (FD_ISSET (fdp->
fd, &write_set))
1183 if (FD_ISSET (fdp->
fd, &err_set))
1253 return _dbus_connect_tcp_socket_with_nonce (host, port, family, (
const char*)
NULL, error);
1257 _dbus_connect_tcp_socket_with_nonce (
const char *host,
1260 const char *noncefile,
1264 struct addrinfo hints;
1265 struct addrinfo *ai, *tmp;
1267 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
1269 _dbus_win_startup_winsock ();
1274 hints.ai_family = AF_UNSPEC;
1275 else if (!strcmp(family,
"ipv4"))
1276 hints.ai_family = AF_INET;
1277 else if (!strcmp(family,
"ipv6"))
1278 hints.ai_family = AF_INET6;
1283 "Unknown address family %s", family);
1286 hints.ai_protocol = IPPROTO_TCP;
1287 hints.ai_socktype = SOCK_STREAM;
1288 #ifdef AI_ADDRCONFIG
1289 hints.ai_flags = AI_ADDRCONFIG;
1294 if ((res = getaddrinfo(host, port, &hints, &ai)) != 0 || !ai)
1298 "Failed to lookup host/port: \"%s:%s\": %s (%d)",
1299 host, port, _dbus_strerror(res), res);
1306 if ((fd = socket (tmp->ai_family, SOCK_STREAM, 0)) == INVALID_SOCKET)
1308 DBUS_SOCKET_SET_ERRNO ();
1311 "Failed to open socket: %s",
1316 _DBUS_ASSERT_ERROR_IS_CLEAR(error);
1318 if (connect (fd, (
struct sockaddr*) tmp->ai_addr, tmp->ai_addrlen) == SOCKET_ERROR)
1320 DBUS_SOCKET_SET_ERRNO ();
1335 "Failed to connect to socket \"%s:%s\" %s",
1340 if (noncefile !=
NULL)
1352 ret = _dbus_send_nonce (fd, &noncefileStr, error);
1365 if (!_dbus_set_fd_nonblocking (fd, error))
1397 int nlisten_fd = 0, *listen_fd =
NULL, res, i, port_num = -1;
1398 struct addrinfo hints;
1399 struct addrinfo *ai, *tmp;
1406 struct sockaddr Address;
1407 struct sockaddr_in AddressIn;
1408 struct sockaddr_in6 AddressIn6;
1412 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
1414 _dbus_win_startup_winsock ();
1419 hints.ai_family = AF_UNSPEC;
1420 else if (!strcmp(family,
"ipv4"))
1421 hints.ai_family = AF_INET;
1422 else if (!strcmp(family,
"ipv6"))
1423 hints.ai_family = AF_INET6;
1428 "Unknown address family %s", family);
1432 hints.ai_protocol = IPPROTO_TCP;
1433 hints.ai_socktype = SOCK_STREAM;
1434 #ifdef AI_ADDRCONFIG
1435 hints.ai_flags = AI_ADDRCONFIG | AI_PASSIVE;
1437 hints.ai_flags = AI_PASSIVE;
1440 redo_lookup_with_port:
1441 if ((res = getaddrinfo(host, port, &hints, &ai)) != 0 || !ai)
1445 "Failed to lookup host/port: \"%s:%s\": %s (%d)",
1446 host ? host :
"*", port, _dbus_strerror(res), res);
1453 int fd = -1, *newlisten_fd;
1454 if ((fd = socket (tmp->ai_family, SOCK_STREAM, 0)) == INVALID_SOCKET)
1456 DBUS_SOCKET_SET_ERRNO ();
1459 "Failed to open socket: %s",
1463 _DBUS_ASSERT_ERROR_IS_CLEAR(error);
1465 if (bind (fd, (
struct sockaddr*) tmp->ai_addr, tmp->ai_addrlen) == SOCKET_ERROR)
1467 DBUS_SOCKET_SET_ERRNO ();
1469 "Failed to bind socket \"%s:%s\": %s",
1475 if (listen (fd, 30 ) == SOCKET_ERROR)
1477 DBUS_SOCKET_SET_ERRNO ();
1479 "Failed to listen on socket \"%s:%s\": %s",
1485 newlisten_fd =
dbus_realloc(listen_fd,
sizeof(
int)*(nlisten_fd+1));
1490 "Failed to allocate file handle array");
1493 listen_fd = newlisten_fd;
1494 listen_fd[nlisten_fd] = fd;
1503 if (!port || !strcmp(port,
"0"))
1505 mysockaddr_gen addr;
1506 socklen_t addrlen =
sizeof(addr);
1509 if (getsockname(fd, &addr.Address, &addrlen) == SOCKET_ERROR)
1511 DBUS_SOCKET_SET_ERRNO ();
1513 "Failed to resolve port \"%s:%s\": %s",
1517 snprintf( portbuf,
sizeof( portbuf ) - 1,
"%d", addr.AddressIn.sin_port );
1527 goto redo_lookup_with_port;
1546 _dbus_win_set_errno (WSAEADDRINUSE);
1548 "Failed to bind socket \"%s:%s\": %s",
1555 for (i = 0 ; i < nlisten_fd ; i++)
1558 if (!_dbus_set_fd_nonblocking (listen_fd[i], error))
1571 for (i = 0 ; i < nlisten_fd ; i++)
1572 closesocket (listen_fd[i]);
1591 client_fd = accept (listen_fd,
NULL,
NULL);
1593 if (DBUS_SOCKET_IS_INVALID (client_fd))
1595 DBUS_SOCKET_SET_ERRNO ();
1600 _dbus_verbose (
"client fd %d accepted\n", client_fd);
1642 if (bytes_written < 0 && errno == EINTR)
1645 if (bytes_written < 0)
1648 "Failed to write credentials byte: %s",
1652 else if (bytes_written == 0)
1655 "wrote zero bytes writing credentials byte");
1661 _dbus_verbose (
"wrote 1 zero byte, credential sending isn't implemented yet\n");
1699 _dbus_verbose(
"got one zero byte from server");
1705 _dbus_verbose(
"FIXME: get faked credentials from current process");
1722 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
1752 file_starts_with_slash =
1756 if (dir_ends_in_slash && file_starts_with_slash)
1760 else if (!(dir_ends_in_slash || file_starts_with_slash))
1801 if (!_dbus_getsid(&sid))
1839 if (!_dbus_getsid(&sid))
1855 return GetCurrentProcessId ();
1859 #define NANOSECONDS_PER_SECOND 1000000000
1861 #define MICROSECONDS_PER_SECOND 1000000
1863 #define MILLISECONDS_PER_SECOND 1000
1865 #define NANOSECONDS_PER_MILLISECOND 1000000
1867 #define MICROSECONDS_PER_MILLISECOND 1000
1876 Sleep (milliseconds);
1893 GetSystemTimeAsFileTime (&ft);
1895 memcpy (&time64, &ft,
sizeof (time64));
1904 *tv_sec = time64 / 1000000;
1907 *tv_usec = time64 % 1000000;
1931 const char *filename_c;
1933 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
1937 if (!CreateDirectoryA (filename_c,
NULL))
1939 if (GetLastError () == ERROR_ALREADY_EXISTS)
1943 "Failed to create directory %s: %s\n",
1975 if (!CryptAcquireContext (&hprov,
NULL,
NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
1978 if (!CryptGenRandom (hprov, n_bytes, p))
1980 CryptReleaseContext (hprov, 0);
1984 CryptReleaseContext (hprov, 0);
1998 static const char* tmpdir =
NULL;
1999 static char buf[1000];
2005 if (!GetTempPathA (
sizeof (buf), buf))
2012 last_slash = _mbsrchr (buf,
'\\');
2013 if (last_slash > buf && last_slash[1] ==
'\0')
2014 last_slash[0] =
'\0';
2015 last_slash = _mbsrchr (buf,
'/');
2016 if (last_slash > buf && last_slash[1] ==
'\0')
2017 last_slash[0] =
'\0';
2040 const char *filename_c;
2042 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
2046 if (DeleteFileA (filename_c) == 0)
2049 "Failed to delete file %s: %s\n",
2065 _dbus_replace_install_prefix (
const char *configure_time_path)
2068 return configure_time_path;
2070 static char retval[1000];
2071 static char runtime_prefix[1000];
2075 if (!configure_time_path)
2078 if ((!_dbus_get_install_root(runtime_prefix, len) ||
2079 strncmp (configure_time_path, DBUS_PREFIX
"/",
2080 strlen (DBUS_PREFIX) + 1))) {
2081 strcat (retval, configure_time_path);
2085 strcpy (retval, runtime_prefix);
2086 strcat (retval, configure_time_path + strlen (DBUS_PREFIX) + 1);
2093 for(i = 0; retval[i] !=
'\0'; i++) {
2094 if(retval[i] ==
'\\')
2101 #if !defined (DBUS_DISABLE_ASSERTS) || defined(DBUS_BUILD_TESTS)
2103 #if defined(_MSC_VER) || defined(DBUS_WINCE)
2134 #include <imagehlp.h>
2137 #define DPRINTF _dbus_warn
2153 static BOOL (WINAPI *pStackWalk)(
2157 LPSTACKFRAME StackFrame,
2158 PVOID ContextRecord,
2159 PREAD_PROCESS_MEMORY_ROUTINE ReadMemoryRoutine,
2160 PFUNCTION_TABLE_ACCESS_ROUTINE FunctionTableAccessRoutine,
2161 PGET_MODULE_BASE_ROUTINE GetModuleBaseRoutine,
2162 PTRANSLATE_ADDRESS_ROUTINE TranslateAddress
2165 static DWORD64 (WINAPI *pSymGetModuleBase)(
2169 static PVOID (WINAPI *pSymFunctionTableAccess)(
2174 static DWORD (WINAPI *pSymGetModuleBase)(
2178 static PVOID (WINAPI *pSymFunctionTableAccess)(
2183 static BOOL (WINAPI *pSymInitialize)(
2185 PSTR UserSearchPath,
2188 static BOOL (WINAPI *pSymGetSymFromAddr)(
2191 PDWORD Displacement,
2192 PIMAGEHLP_SYMBOL Symbol
2194 static BOOL (WINAPI *pSymGetModuleInfo)(
2197 PIMAGEHLP_MODULE ModuleInfo
2199 static DWORD (WINAPI *pSymSetOptions)(
2204 static BOOL init_backtrace()
2206 HMODULE hmodDbgHelp = LoadLibraryA(
"dbghelp");
2226 pStackWalk = (BOOL (WINAPI *)(
2230 LPSTACKFRAME StackFrame,
2231 PVOID ContextRecord,
2232 PREAD_PROCESS_MEMORY_ROUTINE ReadMemoryRoutine,
2233 PFUNCTION_TABLE_ACCESS_ROUTINE FunctionTableAccessRoutine,
2234 PGET_MODULE_BASE_ROUTINE GetModuleBaseRoutine,
2235 PTRANSLATE_ADDRESS_ROUTINE TranslateAddress
2236 ))GetProcAddress (hmodDbgHelp, FUNC(StackWalk));
2238 pSymGetModuleBase=(DWORD64 (WINAPI *)(
2241 ))GetProcAddress (hmodDbgHelp, FUNC(SymGetModuleBase));
2242 pSymFunctionTableAccess=(PVOID (WINAPI *)(
2245 ))GetProcAddress (hmodDbgHelp, FUNC(SymFunctionTableAccess));
2247 pSymGetModuleBase=(DWORD (WINAPI *)(
2250 ))GetProcAddress (hmodDbgHelp, FUNC(SymGetModuleBase));
2251 pSymFunctionTableAccess=(PVOID (WINAPI *)(
2254 ))GetProcAddress (hmodDbgHelp, FUNC(SymFunctionTableAccess));
2256 pSymInitialize = (BOOL (WINAPI *)(
2258 PSTR UserSearchPath,
2260 ))GetProcAddress (hmodDbgHelp, FUNC(SymInitialize));
2261 pSymGetSymFromAddr = (BOOL (WINAPI *)(
2264 PDWORD Displacement,
2265 PIMAGEHLP_SYMBOL Symbol
2266 ))GetProcAddress (hmodDbgHelp, FUNC(SymGetSymFromAddr));
2267 pSymGetModuleInfo = (BOOL (WINAPI *)(
2270 PIMAGEHLP_MODULE ModuleInfo
2271 ))GetProcAddress (hmodDbgHelp, FUNC(SymGetModuleInfo));
2272 pSymSetOptions = (DWORD (WINAPI *)(
2274 ))GetProcAddress (hmodDbgHelp, FUNC(SymSetOptions));
2277 pSymSetOptions(SYMOPT_UNDNAME);
2279 pSymInitialize(GetCurrentProcess(),
NULL,
TRUE);
2284 static void dump_backtrace_for_thread(HANDLE hThread)
2291 if (!init_backtrace())
2296 if (hThread == GetCurrentThread())
2299 DPRINTF(
"Backtrace:\n");
2302 context.ContextFlags = CONTEXT_FULL;
2304 SuspendThread(hThread);
2306 if (!GetThreadContext(hThread, &context))
2308 DPRINTF(
"Couldn't get thread context (error %ld)\n", GetLastError());
2309 ResumeThread(hThread);
2316 sf.AddrFrame.Offset = context.Ebp;
2317 sf.AddrFrame.Mode = AddrModeFlat;
2318 sf.AddrPC.Offset = context.Eip;
2319 sf.AddrPC.Mode = AddrModeFlat;
2320 dwImageType = IMAGE_FILE_MACHINE_I386;
2322 dwImageType = IMAGE_FILE_MACHINE_AMD64;
2323 sf.AddrPC.Offset = context.Rip;
2324 sf.AddrPC.Mode = AddrModeFlat;
2325 sf.AddrFrame.Offset = context.Rsp;
2326 sf.AddrFrame.Mode = AddrModeFlat;
2327 sf.AddrStack.Offset = context.Rsp;
2328 sf.AddrStack.Mode = AddrModeFlat;
2330 dwImageType = IMAGE_FILE_MACHINE_IA64;
2331 sf.AddrPC.Offset = context.StIIP;
2332 sf.AddrPC.Mode = AddrModeFlat;
2333 sf.AddrFrame.Offset = context.IntSp;
2334 sf.AddrFrame.Mode = AddrModeFlat;
2335 sf.AddrBStore.Offset= context.RsBSP;
2336 sf.AddrBStore.Mode = AddrModeFlat;
2337 sf.AddrStack.Offset = context.IntSp;
2338 sf.AddrStack.Mode = AddrModeFlat;
2340 # error You need to fill in the STACKFRAME structure for your architecture
2343 while (pStackWalk(dwImageType, GetCurrentProcess(),
2344 hThread, &sf, &context,
NULL, pSymFunctionTableAccess,
2345 pSymGetModuleBase,
NULL))
2348 IMAGEHLP_SYMBOL * pSymbol = (IMAGEHLP_SYMBOL *)buffer;
2349 DWORD dwDisplacement;
2351 pSymbol->SizeOfStruct =
sizeof(IMAGEHLP_SYMBOL);
2352 pSymbol->MaxNameLength =
sizeof(buffer) -
sizeof(IMAGEHLP_SYMBOL) + 1;
2354 if (!pSymGetSymFromAddr(GetCurrentProcess(), sf.AddrPC.Offset,
2355 &dwDisplacement, pSymbol))
2357 IMAGEHLP_MODULE ModuleInfo;
2358 ModuleInfo.SizeOfStruct =
sizeof(ModuleInfo);
2360 if (!pSymGetModuleInfo(GetCurrentProcess(), sf.AddrPC.Offset,
2362 DPRINTF(
"1\t%p\n", (
void*)sf.AddrPC.Offset);
2364 DPRINTF(
"2\t%s+0x%lx\n", ModuleInfo.ImageName,
2365 sf.AddrPC.Offset - ModuleInfo.BaseOfImage);
2367 else if (dwDisplacement)
2368 DPRINTF(
"3\t%s+0x%lx\n", pSymbol->Name, dwDisplacement);
2370 DPRINTF(
"4\t%s\n", pSymbol->Name);
2373 ResumeThread(hThread);
2376 static DWORD WINAPI dump_thread_proc(LPVOID lpParameter)
2378 dump_backtrace_for_thread((HANDLE)lpParameter);
2384 static void dump_backtrace()
2386 HANDLE hCurrentThread;
2389 DuplicateHandle(GetCurrentProcess(), GetCurrentThread(),
2390 GetCurrentProcess(), &hCurrentThread, 0,
FALSE, DUPLICATE_SAME_ACCESS);
2391 hThread = CreateThread(
NULL, 0, dump_thread_proc, (LPVOID)hCurrentThread,
2393 WaitForSingleObject(hThread, INFINITE);
2394 CloseHandle(hThread);
2395 CloseHandle(hCurrentThread);
2409 _dbus_verbose (
" D-Bus not compiled with backtrace support\n");
2415 if(ascii >=
'0' && ascii <=
'9')
2417 if(ascii >=
'A' && ascii <=
'F')
2418 return ascii -
'A' + 10;
2419 if(ascii >=
'a' && ascii <=
'f')
2420 return ascii -
'a' + 10;
2432 HW_PROFILE_INFOA info;
2433 char *lpc = &info.szHwProfileGuid[0];
2437 if(!GetCurrentHwProfileA(&info))
2446 u = ((fromAscii(lpc[0]) << 0) |
2447 (fromAscii(lpc[1]) << 4) |
2448 (fromAscii(lpc[2]) << 8) |
2449 (fromAscii(lpc[3]) << 12) |
2450 (fromAscii(lpc[4]) << 16) |
2451 (fromAscii(lpc[5]) << 20) |
2452 (fromAscii(lpc[6]) << 24) |
2453 (fromAscii(lpc[7]) << 28));
2458 u = ((fromAscii(lpc[0]) << 0) |
2459 (fromAscii(lpc[1]) << 4) |
2460 (fromAscii(lpc[2]) << 8) |
2461 (fromAscii(lpc[3]) << 12) |
2462 (fromAscii(lpc[5]) << 16) |
2463 (fromAscii(lpc[6]) << 20) |
2464 (fromAscii(lpc[7]) << 24) |
2465 (fromAscii(lpc[8]) << 28));
2470 u = ((fromAscii(lpc[0]) << 0) |
2471 (fromAscii(lpc[1]) << 4) |
2472 (fromAscii(lpc[2]) << 8) |
2473 (fromAscii(lpc[3]) << 12) |
2474 (fromAscii(lpc[5]) << 16) |
2475 (fromAscii(lpc[6]) << 20) |
2476 (fromAscii(lpc[7]) << 24) |
2477 (fromAscii(lpc[8]) << 28));
2482 u = ((fromAscii(lpc[0]) << 0) |
2483 (fromAscii(lpc[1]) << 4) |
2484 (fromAscii(lpc[2]) << 8) |
2485 (fromAscii(lpc[3]) << 12) |
2486 (fromAscii(lpc[4]) << 16) |
2487 (fromAscii(lpc[5]) << 20) |
2488 (fromAscii(lpc[6]) << 24) |
2489 (fromAscii(lpc[7]) << 28));
2496 HANDLE _dbus_global_lock (
const char *mutexname)
2501 mutex = CreateMutexA(
NULL,
FALSE, mutexname );
2507 gotMutex = WaitForSingleObject( mutex, INFINITE );
2510 case WAIT_ABANDONED:
2511 ReleaseMutex (mutex);
2512 CloseHandle (mutex);
2523 void _dbus_global_unlock (HANDLE mutex)
2525 ReleaseMutex (mutex);
2526 CloseHandle (mutex);
2530 static HANDLE hDBusDaemonMutex =
NULL;
2531 static HANDLE hDBusSharedMem =
NULL;
2533 static const char *cUniqueDBusInitMutex =
"UniqueDBusInitMutex";
2535 static const char *cDBusAutolaunchMutex =
"DBusAutolaunchMutex";
2537 static const char *cDBusDaemonMutex =
"DBusDaemonMutex";
2539 static const char *cDBusDaemonAddressInfo =
"DBusDaemonAddressInfo";
2542 _dbus_get_install_root_as_hash(
DBusString *out)
2546 char path[MAX_PATH*2];
2547 int path_size =
sizeof(path);
2549 if (!_dbus_get_install_root(path,path_size))
2565 _dbus_get_address_string (
DBusString *out,
const char *basestring,
const char *scope)
2574 else if (strcmp(scope,
"*install-path") == 0
2576 || strcmp(scope,
"install-path") == 0)
2579 if (!_dbus_get_install_root_as_hash(&temp))
2588 else if (strcmp(scope,
"*user") == 0)
2597 else if (strlen(scope) > 0)
2607 _dbus_get_shm_name (
DBusString *out,
const char *scope)
2609 return _dbus_get_address_string (out,cDBusDaemonAddressInfo,scope);
2613 _dbus_get_mutex_name (
DBusString *out,
const char *scope)
2615 return _dbus_get_address_string (out,cDBusDaemonMutex,scope);
2619 _dbus_daemon_is_session_bus_address_published (
const char *scope)
2626 if (!_dbus_get_mutex_name(&mutex_name,scope))
2632 if (hDBusDaemonMutex)
2636 lock = _dbus_global_lock( cUniqueDBusInitMutex );
2642 _dbus_global_unlock( lock );
2646 if (hDBusDaemonMutex ==
NULL)
2648 if (GetLastError() == ERROR_ALREADY_EXISTS)
2650 CloseHandle(hDBusDaemonMutex);
2651 hDBusDaemonMutex =
NULL;
2661 _dbus_daemon_publish_session_bus_address (
const char* address,
const char *scope)
2664 char *shared_addr =
NULL;
2666 char addressInfo[1024];
2672 if (!_dbus_get_mutex_name(&mutex_name,scope))
2679 lock = _dbus_global_lock( cUniqueDBusInitMutex );
2681 if (!hDBusDaemonMutex)
2687 if (!_dbus_get_shm_name(&shm_name,scope))
2690 _dbus_global_unlock( lock );
2695 hDBusSharedMem = CreateFileMappingA( INVALID_HANDLE_VALUE,
NULL, PAGE_READWRITE,
2699 shared_addr = MapViewOfFile( hDBusSharedMem, FILE_MAP_WRITE, 0, 0, 0 );
2703 strcpy( shared_addr, address);
2706 UnmapViewOfFile( shared_addr );
2708 _dbus_global_unlock( lock );
2716 _dbus_daemon_unpublish_session_bus_address (
void)
2721 lock = _dbus_global_lock( cUniqueDBusInitMutex );
2723 CloseHandle( hDBusSharedMem );
2725 hDBusSharedMem =
NULL;
2727 ReleaseMutex( hDBusDaemonMutex );
2729 CloseHandle( hDBusDaemonMutex );
2731 hDBusDaemonMutex =
NULL;
2733 _dbus_global_unlock( lock );
2747 if( sharedMem == 0 )
2749 if ( sharedMem != 0)
2753 if( sharedMem == 0 )
2756 shared_addr = MapViewOfFile( sharedMem, FILE_MAP_READ, 0, 0, 0 );
2766 UnmapViewOfFile( shared_addr );
2768 CloseHandle( sharedMem );
2781 if (!_dbus_get_mutex_name(&mutex_name,scope))
2788 lock = _dbus_global_lock( cUniqueDBusInitMutex );
2792 if(WaitForSingleObject( daemon, 10 ) != WAIT_TIMEOUT)
2794 ReleaseMutex (daemon);
2795 CloseHandle (daemon);
2797 _dbus_global_unlock( lock );
2803 bRet = _dbus_get_autolaunch_shm( address, shm_name );
2806 CloseHandle ( daemon );
2808 _dbus_global_unlock( lock );
2820 PROCESS_INFORMATION pi;
2823 char dbus_exe_path[MAX_PATH];
2824 char dbus_args[MAX_PATH * 2];
2825 const char * daemon_name = DBUS_DAEMON_NAME
".exe";
2828 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
2830 if (!_dbus_get_shm_name(&shm_name,scope))
2836 mutex = _dbus_global_lock ( cDBusAutolaunchMutex );
2838 if (_dbus_daemon_already_runs(address,&shm_name,scope))
2840 _dbus_verbose(
"found running dbus daemon at %s\n",
2846 if (!SearchPathA(
NULL, daemon_name,
NULL,
sizeof(dbus_exe_path), dbus_exe_path, &lpFile))
2848 printf (
"please add the path to %s to your PATH environment variable\n", daemon_name);
2849 printf (
"or start the daemon manually\n\n");
2854 ZeroMemory( &si,
sizeof(si) );
2856 ZeroMemory( &pi,
sizeof(pi) );
2858 _snprintf(dbus_args,
sizeof(dbus_args) - 1,
"\"%s\" %s", dbus_exe_path,
" --session");
2862 if(CreateProcessA(dbus_exe_path, dbus_args,
NULL,
NULL,
FALSE, CREATE_NO_WINDOW,
NULL,
NULL, &si, &pi))
2864 CloseHandle (pi.hThread);
2865 CloseHandle (pi.hProcess);
2866 retval = _dbus_get_autolaunch_shm( address, &shm_name );
2867 if (retval ==
FALSE)
2878 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
2880 _DBUS_ASSERT_ERROR_IS_SET (error);
2882 _dbus_global_unlock (mutex);
2909 _dbus_windows_get_datadir (
void)
2911 return _dbus_replace_install_prefix(DBUS_DATADIR);
2915 #define DBUS_DATADIR _dbus_windows_get_datadir ()
2918 #define DBUS_STANDARD_SESSION_SERVICEDIR "/dbus-1/services"
2919 #define DBUS_STANDARD_SYSTEM_SERVICEDIR "/dbus-1/system-services"
2940 const char *common_progs;
2951 if (data_dir !=
NULL)
2973 char install_root[1000];
2974 if (_dbus_get_install_root (install_root,
sizeof(install_root)))
2989 if (common_progs !=
NULL)
2999 DBUS_STANDARD_SESSION_SERVICEDIR,
3050 return InterlockedIncrement (&atomic->
value) - 1;
3065 return InterlockedDecrement (&atomic->
value) + 1;
3089 return errno == WSAEWOULDBLOCK;
3100 _dbus_get_install_root(
char *prefix,
int len)
3108 pathLength = GetModuleFileNameA(_dbus_win_get_dll_hmodule(), prefix, len);
3109 if ( pathLength == 0 || GetLastError() != 0 ) {
3113 lastSlash = _mbsrchr(prefix,
'\\');
3114 if (lastSlash ==
NULL) {
3127 if (lastSlash - prefix >= 4 && strnicmp(lastSlash - 4,
"\\bin", 4) == 0)
3129 else if (lastSlash - prefix >= 10 && strnicmp(lastSlash - 10,
"\\bin\\debug", 10) == 0)
3131 else if (lastSlash - prefix >= 12 && strnicmp(lastSlash - 12,
"\\bin\\release", 12) == 0)
3151 _dbus_get_config_file_name(
DBusString *config_file,
char *s)
3153 char path[MAX_PATH*2];
3154 int path_size =
sizeof(path);
3156 if (!_dbus_get_install_root(path,path_size))
3159 if(strlen(s) + 4 + strlen(path) >
sizeof(path)-2)
3161 strcat(path,
"etc\\");
3171 if (!_dbus_get_install_root(path,path_size))
3173 if(strlen(s) + 11 + strlen(path) >
sizeof(path)-2)
3175 strcat(path,
"etc\\dbus-1\\");
3185 if (!_dbus_get_install_root(path,path_size))
3187 if(strlen(s) + 4 + strlen(path) >
sizeof(path)-2)
3189 strcat(path,
"bus\\");
3213 return _dbus_get_config_file_name(str,
"system.conf");
3225 return _dbus_get_config_file_name(str,
"session.conf");
3259 const char *homepath;
3260 const char *homedrive;
3269 if (homedrive !=
NULL && *homedrive !=
'\0')
3275 if (homepath !=
NULL && *homepath !=
'\0')
3280 #ifdef DBUS_BUILD_TESTS
3282 const char *
override;
3285 if (
override !=
NULL && *
override !=
'\0')
3291 _dbus_verbose (
"Using fake homedir for testing: %s\n",
3297 if (!already_warned)
3299 _dbus_warn (
"Using your real home directory for testing, set DBUS_TEST_HOMEDIR to avoid\n");
3300 already_warned =
TRUE;
3309 #define KEYRING_DIR "dbus-keyrings"
3311 #define KEYRING_DIR ".dbus-keyrings"
3340 DWORD attributes = GetFileAttributesA (file);
3342 if (attributes != INVALID_FILE_ATTRIBUTES && GetLastError() != ERROR_PATH_NOT_FOUND)
3356 _dbus_strerror (
int error_number)
3364 switch (error_number)
3367 return "Interrupted function call";
3369 return "Permission denied";
3371 return "Bad address";
3373 return "Invalid argument";
3375 return "Too many open files";
3376 case WSAEWOULDBLOCK:
3377 return "Resource temporarily unavailable";
3378 case WSAEINPROGRESS:
3379 return "Operation now in progress";
3381 return "Operation already in progress";
3383 return "Socket operation on nonsocket";
3384 case WSAEDESTADDRREQ:
3385 return "Destination address required";
3387 return "Message too long";
3389 return "Protocol wrong type for socket";
3390 case WSAENOPROTOOPT:
3391 return "Bad protocol option";
3392 case WSAEPROTONOSUPPORT:
3393 return "Protocol not supported";
3394 case WSAESOCKTNOSUPPORT:
3395 return "Socket type not supported";
3397 return "Operation not supported";
3398 case WSAEPFNOSUPPORT:
3399 return "Protocol family not supported";
3400 case WSAEAFNOSUPPORT:
3401 return "Address family not supported by protocol family";
3403 return "Address already in use";
3404 case WSAEADDRNOTAVAIL:
3405 return "Cannot assign requested address";
3407 return "Network is down";
3408 case WSAENETUNREACH:
3409 return "Network is unreachable";
3411 return "Network dropped connection on reset";
3412 case WSAECONNABORTED:
3413 return "Software caused connection abort";
3415 return "Connection reset by peer";
3417 return "No buffer space available";
3419 return "Socket is already connected";
3421 return "Socket is not connected";
3423 return "Cannot send after socket shutdown";
3425 return "Connection timed out";
3426 case WSAECONNREFUSED:
3427 return "Connection refused";
3429 return "Host is down";
3430 case WSAEHOSTUNREACH:
3431 return "No route to host";
3433 return "Too many processes";
3435 return "Graceful shutdown in progress";
3436 case WSATYPE_NOT_FOUND:
3437 return "Class type not found";
3438 case WSAHOST_NOT_FOUND:
3439 return "Host not found";
3441 return "Nonauthoritative host not found";
3442 case WSANO_RECOVERY:
3443 return "This is a nonrecoverable error";
3445 return "Valid name, no data record of requested type";
3446 case WSA_INVALID_HANDLE:
3447 return "Specified event object handle is invalid";
3448 case WSA_INVALID_PARAMETER:
3449 return "One or more parameters are invalid";
3450 case WSA_IO_INCOMPLETE:
3451 return "Overlapped I/O event object not in signaled state";
3452 case WSA_IO_PENDING:
3453 return "Overlapped operations will complete later";
3454 case WSA_NOT_ENOUGH_MEMORY:
3455 return "Insufficient memory available";
3456 case WSA_OPERATION_ABORTED:
3457 return "Overlapped operation aborted";
3458 #ifdef WSAINVALIDPROCTABLE
3460 case WSAINVALIDPROCTABLE:
3461 return "Invalid procedure table from service provider";
3463 #ifdef WSAINVALIDPROVIDER
3465 case WSAINVALIDPROVIDER:
3466 return "Invalid service provider version number";
3468 #ifdef WSAPROVIDERFAILEDINIT
3470 case WSAPROVIDERFAILEDINIT:
3471 return "Unable to initialize a service provider";
3474 case WSASYSCALLFAILURE:
3475 return "System call failure";
3477 msg = strerror (error_number);
3493 _dbus_win_set_error_from_win_error (
DBusError *error,
3499 FormatMessageA (FORMAT_MESSAGE_ALLOCATE_BUFFER |
3500 FORMAT_MESSAGE_IGNORE_INSERTS |
3501 FORMAT_MESSAGE_FROM_SYSTEM,
3502 NULL, code, MAKELANGID (LANG_ENGLISH, SUBLANG_ENGLISH_US),
3503 (LPSTR) &msg, 0,
NULL);
3509 strcpy (msg_copy, msg);
3515 dbus_set_error (error,
"win32.error",
"Unknown error code %d or FormatMessage failed", code);
3519 _dbus_win_warn_win_error (
const char *message,
3525 _dbus_win_set_error_from_win_error (&error, code);
3541 const char *filename_c;
3543 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
3547 if (RemoveDirectoryA (filename_c) == 0)
3549 char *emsg = _dbus_win_error_string (GetLastError ());
3551 "Failed to remove directory %s: %s",
3553 _dbus_win_free_error_string (emsg);