diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2008-02-28 15:50:51 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2008-02-28 15:50:51 +0000 |
commit | 6965e469611070aa84620c55220f02b017e15fd1 (patch) | |
tree | b29d521511ffc01ce92716554612bb06ebf64cdc /winsup/cygwin/exceptions.cc | |
parent | 11cd2378b08a69fcca6f16827fd6a27f98ccc479 (diff) | |
download | cygnal-6965e469611070aa84620c55220f02b017e15fd1.tar.gz cygnal-6965e469611070aa84620c55220f02b017e15fd1.tar.bz2 cygnal-6965e469611070aa84620c55220f02b017e15fd1.zip |
* exceptions.cc (open_stackdumpfile): Use NtCreateFile to create
stackdump file.
Diffstat (limited to 'winsup/cygwin/exceptions.cc')
-rw-r--r-- | winsup/cygwin/exceptions.cc | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 4c569b4d9..a903852ee 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -32,6 +32,7 @@ details. */ #include "dtable.h" #include "cygheap.h" #include "child_info.h" +#include "ntdll.h" #define CALL_HANDLER_RETRY 20 @@ -140,11 +141,28 @@ open_stackdumpfile () p++; else p = myself->progname; - char corefile[strlen (p) + sizeof (".stackdump")]; - __small_sprintf (corefile, "%s.stackdump", p); - HANDLE h = CreateFile (corefile, GENERIC_WRITE, 0, &sec_none_nih, - CREATE_ALWAYS, 0, 0); - if (h != INVALID_HANDLE_VALUE) + + WCHAR corefile[strlen (p) + sizeof (".stackdump")]; + UNICODE_STRING ucore; + OBJECT_ATTRIBUTES attr; + RtlInitEmptyUnicodeString (&ucore, corefile, + sizeof corefile - sizeof (WCHAR)); + ucore.Length = sys_mbstowcs (ucore.Buffer, + ucore.MaximumLength / sizeof (WCHAR), + p, strlen (p)) * sizeof (WCHAR); + RtlAppendUnicodeToString (&ucore, L".stackdump"); + InitializeObjectAttributes (&attr, &ucore, OBJ_CASE_INSENSITIVE, + cygheap->cwd.get_handle (), NULL); + HANDLE h; + IO_STATUS_BLOCK io; + NTSTATUS status; + + status = NtCreateFile (&h, GENERIC_WRITE | SYNCHRONIZE, &attr, &io, + NULL, FILE_ATTRIBUTE_NORMAL, 0, FILE_OVERWRITE_IF, + FILE_SYNCHRONOUS_IO_NONALERT + | FILE_OPEN_FOR_BACKUP_INTENT + | FILE_OPEN_FOR_RECOVERY, NULL, 0); + if (NT_SUCCESS (status)) { if (!myself->cygstarted) system_printf ("Dumping stack trace to %s", corefile); |