Be sure to specify FORMAT_MESSAGE_IGNORE_INSERTS in the dwFlags arg to all FormatMessage() calls where FORMAT_MESSAGE_FROM_SYSTEM is also specified. (Ref: http://blogs.msdn.com/b/oldnewthing/archive/2007/11/28/6564257.aspx)

svn path=/trunk/; revision=43172
This commit is contained in:
Chris Maynard 2012-06-09 03:41:23 +00:00
parent c3dadc73f3
commit e40c7ab1dc
3 changed files with 6 additions and 6 deletions

View File

@ -225,8 +225,8 @@ win32strerror(DWORD error)
size_t errlen;
char *p;
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, 0, errbuf,
ERRBUF_SIZE, NULL);
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, error, 0, errbuf, ERRBUF_SIZE, NULL);
/*
* "FormatMessage()" "helpfully" sticks CR/LF at the end of the
@ -1637,7 +1637,7 @@ sync_pipe_input_cb(gint source, gpointer user_data)
"standard output", as the capture file. */
sync_pipe_stop(capture_opts);
capture_input_closed(capture_opts, NULL);
return FALSE;
//return FALSE;
}
break;
case SP_PACKET_COUNT:

View File

@ -305,7 +305,7 @@ init_progfile_dir(const char *arg0
* Oh, well. Return an indication of the error.
*/
error = GetLastError();
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, error, 0, (LPTSTR) &msg_w, 0, NULL) == 0) {
/*
* Gak. We can't format the message.

View File

@ -321,7 +321,7 @@ raw_pipe_open(const char *pipe_name)
err = GetLastError();
if (err != ERROR_PIPE_BUSY) {
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER,
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, err, 0, (LPTSTR) &err_str, 0, NULL);
fprintf(stderr, "rawshark: \"%s\" could not be opened: %s (error %d)\n",
pipe_name, utf_16to8(err_str), err);
@ -331,7 +331,7 @@ raw_pipe_open(const char *pipe_name)
if (!WaitNamedPipe(utf_8to16(pipe_name), 30 * 1000)) {
err = GetLastError();
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER,
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, err, 0, (LPTSTR) &err_str, 0, NULL);
fprintf(stderr, "rawshark: \"%s\" could not be waited for: %s (error %d)\n",
pipe_name, utf_16to8(err_str), err);