{"componentChunkName":"component---src-templates-post-template-js","path":"/windows-windbg-008-time-travel-debugging-en","result":{"data":{"markdownRemark":{"id":"ee6c8117-37a0-5022-b908-06440cc749cb","html":"<blockquote>\n<p>This page has been machine-translated from the <a href=\"/windows-windbg-008-time-travel-debugging\">original page</a>.</p>\n</blockquote>\n<p>My goal is to become proficient with WinDbg for Windows debugging and dump-based troubleshooting.</p>\n<p>This time, I’ll walk through the official Time Travel Debugging tutorial available in the UWP version of WinDbg Preview.</p>\n<p>Reference: <a href=\"https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/time-travel-debugging-walkthrough\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Time Travel Debugging - Sample App Walkthrough - Windows drivers | Microsoft Docs</a></p>\n<p>For a full list of articles on Windows debugging and dump analysis with WinDbg, see the index page:</p>\n<p>Reference: <a href=\"/windows-windbg-001-index-en\">Debugging and Troubleshooting Techniques with WinDbg</a></p>\n<p>This article covers the following topics.</p>\n<!-- omit in toc -->\n<h2 id=\"table-of-contents\" style=\"position:relative;\"><a href=\"#table-of-contents\" aria-label=\"table of contents permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Table of Contents</h2>\n<ul>\n<li>\n<p><a href=\"#what-is-time-travel-debugging\">What Is Time Travel Debugging?</a></p>\n<ul>\n<li><a href=\"#files-created-by-ttd\">Files Created by TTD</a></li>\n<li><a href=\"#what-ttd-cannot-do\">What TTD Cannot Do</a></li>\n</ul>\n</li>\n<li><a href=\"#tutorial-preparing-the-sample-program\">Tutorial: Preparing the Sample Program</a></li>\n<li><a href=\"#tracing-ttd_sampleexe-with-ttd\">Tracing ttd_sample.exe with TTD</a></li>\n<li>\n<p><a href=\"#troubleshooting-with-ttd\">Troubleshooting with TTD</a></p>\n<ul>\n<li><a href=\"#loading-the-symbol-file\">Loading the Symbol File</a></li>\n<li><a href=\"#checking-exceptions-from-the-trace-file\">Checking Exceptions from the Trace File</a></li>\n<li><a href=\"#listing-events-in-the-ttd-trace\">Listing Events in the TTD Trace</a></li>\n<li><a href=\"#retrieving-exception-details\">Retrieving Exception Details</a></li>\n<li><a href=\"#jumping-to-the-point-where-the-exception-occurred\">Jumping to the Point Where the Exception Occurred</a></li>\n<li><a href=\"#step-into-back\">Step Into Back!!!</a></li>\n<li><a href=\"#inspecting-the-memory-data-at-the-address-pointed-to-by-bsp\">Inspecting the Memory Data at the Address Pointed to by BSP</a></li>\n<li><a href=\"#supplementary-note-about-esp-and-ebp\">Supplementary Note: About ESP and EBP</a></li>\n<li><a href=\"#identifying-the-root-cause\">Identifying the Root Cause</a></li>\n<li><a href=\"#debugging-the-getcppcongreetingpwy-function\">Debugging the GetCppConGreetingPwy Function</a></li>\n</ul>\n</li>\n<li><a href=\"#wrap-up\">Wrap-up</a></li>\n</ul>\n<h2 id=\"what-is-time-travel-debugging\" style=\"position:relative;\"><a href=\"#what-is-time-travel-debugging\" aria-label=\"what is time travel debugging permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What Is Time Travel Debugging?</h2>\n<p>The Time Travel Debugging (TTD) feature allows users to record the behavior of a running process and replay it <strong>forward and backward</strong> afterward.</p>\n<p>Reference: <a href=\"https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/time-travel-debugging-overview\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Time Travel Debugging - Overview - Windows drivers | Microsoft Docs</a></p>\n<p>Using TTD provides the following advantages:</p>\n<ul>\n<li>Unlike live debugging, you can “rewind” to the point where a problem occurred and analyze it there.</li>\n<li>Sharing a TTD trace file makes it easy to share the state of a problem reproduction.</li>\n<li>Unlike crash dumps, it includes the execution context at the time the problematic code ran.</li>\n<li>You can run queries against the trace using Integrated Language Query (LINQ).</li>\n</ul>\n<p>On the other hand, recording a TTD trace requires significant overhead — even a few minutes of recording can consume gigabytes of storage.</p>\n<p>TTD is available in WinDbg Preview, but it can also be used in Visual Studio.</p>\n<p>Reference: <a href=\"https://devblogs.microsoft.com/visualstudio/introducing-time-travel-debugging-for-visual-studio-enterprise-2019/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Introducing Time Travel Debugging for Visual Studio Enterprise 2019 - Visual Studio Blog</a></p>\n<h3 id=\"files-created-by-ttd\" style=\"position:relative;\"><a href=\"#files-created-by-ttd\" aria-label=\"files created by ttd permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Files Created by TTD</h3>\n<p>During a trace, the following three files are typically created:</p>\n<ul>\n<li><code class=\"language-text\">.idx</code> file: an index for accessing the trace data</li>\n<li><code class=\"language-text\">.run</code> file: the file where the recorded code execution is stored</li>\n<li><code class=\"language-text\">.out</code> file: a file containing output from the TTD recording session</li>\n</ul>\n<p>The <code class=\"language-text\">.idx</code> and <code class=\"language-text\">.run</code> files in particular can become very large depending on how long the trace runs.</p>\n<h3 id=\"what-ttd-cannot-do\" style=\"position:relative;\"><a href=\"#what-ttd-cannot-do\" aria-label=\"what ttd cannot do permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What TTD Cannot Do</h3>\n<p>As of WinDbg Preview at the time of writing (October 17, 2021), the following three things are not supported by TTD:</p>\n<ul>\n<li>Tracing kernel-mode processes</li>\n<li>Writing to memory during TTD playback</li>\n<li>Tracing processes protected by Protected Process Light (PPL)</li>\n</ul>\n<p>In particular, because TTD traces are read-only, techniques common in live debugging — such as setting a breakpoint at a conditional branch and modifying a register to redirect execution to an arbitrary address — are not available in TTD.</p>\n<h2 id=\"tutorial-preparing-the-sample-program\" style=\"position:relative;\"><a href=\"#tutorial-preparing-the-sample-program\" aria-label=\"tutorial preparing the sample program permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Tutorial: Preparing the Sample Program</h2>\n<p>Let’s start working through the official TTD tutorial.</p>\n<p>Reference: <a href=\"https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/time-travel-debugging-walkthrough\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Time Travel Debugging - Sample App Walkthrough - Windows drivers | Microsoft Docs</a></p>\n<p>The environment used for this tutorial:</p>\n<ul>\n<li>Windows 10 Pro 20H2</li>\n<li>WinDbg Preview 1.2106.26002.0 (launched with administrator privileges)</li>\n</ul>\n<p>For the sample program, I used a version cross-compiled with llvm-mingw rather than Visual Studio.</p>\n<p>The sample program source code and compilation environment are described in the following article:</p>\n<p>Reference: <a href=\"/windows-windbg-006-symbol-en\">How to Generate Symbol Files (.pdb) in a Linux Environment Using llvm-mingw</a></p>\n<p>The sample program I used looks like this:</p>\n<div class=\"gatsby-highlight\" data-language=\"cpp\"><pre class=\"language-cpp\"><code class=\"language-cpp\"><span class=\"token macro property\"><span class=\"token directive-hash\">#</span><span class=\"token directive keyword\">include</span> <span class=\"token string\">&lt;array></span></span>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#</span><span class=\"token directive keyword\">include</span> <span class=\"token string\">&lt;cstring></span> </span>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#</span><span class=\"token directive keyword\">include</span> <span class=\"token string\">&lt;stdio.h></span></span>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#</span><span class=\"token directive keyword\">include</span> <span class=\"token string\">&lt;string.h></span></span>\n\n<span class=\"token keyword\">void</span> <span class=\"token function\">GetCppConGreeting</span><span class=\"token punctuation\">(</span><span class=\"token keyword\">wchar_t</span> <span class=\"token operator\">*</span>buffer<span class=\"token punctuation\">,</span> size_t size<span class=\"token punctuation\">)</span>\n<span class=\"token punctuation\">{</span>\n    <span class=\"token keyword\">wchar_t</span> <span class=\"token keyword\">const</span> <span class=\"token operator\">*</span><span class=\"token keyword\">const</span> message <span class=\"token operator\">=</span> L<span class=\"token string\">\"HELLO FROM THE WINDBG TEAM. GOOD LUCK IN ALL OF YOUR TIME TRAVEL DEBUGGING!\"</span><span class=\"token punctuation\">;</span>\n\n    <span class=\"token function\">wcscpy_s</span><span class=\"token punctuation\">(</span>buffer<span class=\"token punctuation\">,</span> size<span class=\"token punctuation\">,</span> message<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span>\n\n<span class=\"token keyword\">int</span> <span class=\"token function\">main</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span>\n<span class=\"token punctuation\">{</span>\n    std<span class=\"token double-colon punctuation\">::</span>array<span class=\"token operator\">&lt;</span><span class=\"token keyword\">wchar_t</span><span class=\"token punctuation\">,</span> <span class=\"token number\">50</span><span class=\"token operator\">></span> greeting<span class=\"token punctuation\">{</span><span class=\"token punctuation\">}</span><span class=\"token punctuation\">;</span>\n    <span class=\"token function\">GetCppConGreeting</span><span class=\"token punctuation\">(</span>greeting<span class=\"token punctuation\">.</span><span class=\"token function\">data</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span> <span class=\"token keyword\">sizeof</span><span class=\"token punctuation\">(</span>greeting<span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n    <span class=\"token function\">wprintf</span><span class=\"token punctuation\">(</span>L<span class=\"token string\">\"%ls\\n\"</span><span class=\"token punctuation\">,</span> greeting<span class=\"token punctuation\">.</span><span class=\"token function\">data</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n    <span class=\"token keyword\">return</span> <span class=\"token number\">0</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<p>Running the executable (<code class=\"language-text\">ttd_sample.exe</code>) — created based on the official tutorial source code — from PowerShell causes the program to crash abnormally for some reason.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/a67b31f412fbc8448faa3c68f717a457/0b533/image-28.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 83.75%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAARCAYAAADdRIy+AAAACXBIWXMAARlAAAEZQAGA43XUAAADQUlEQVQ4y4WUW2yTZRjH366OnUC2MWVAt7Gta8vafS3tECMsw61lhe5b23U9jIUyDsNkJgaHazw1mRAWTBYTJMELiN6YKImJN0YIN94ZQ4zRO6PRRIyJso2DFg9E8/Pp1+rqhnDxy/vm+573//3f5/Cpx5NZfP4U24JpvLvH0PqSuPvjQoKt8tzrH8UbGMUX2IenP4W2K2nQ1ZvE1Zug68kUrp1Rnth/msCJqyj73gzrtBQbto3T2J2m3j1KgydGnRZlrStGtSNBzZY4a5wpyjuiqNYQqm1wifYwytKPO5IhdOpTVPPuZ1Gb5IU1LgExCRgR4gWsy+gQbIkS4pjsKVRLCKc+zdDsZxK397ioDmK2JzDZRjB1/BdVpHS/REzOiHBLEE84w+jcF/KR0HOopkHK7PF7HHgQIihGVHMQX3Sa9Gufo7bopYKxEh4sVupQ048Tnb2aF5y+r8MyydP/YaTFENyDMzRF6MTHqE79Ple2iouWiBBeRqSAdbhwZXHo1qeIzX6CcoXFoeUegiK2qjNJU88RmnsnaOk9apDfN/VMYJHnFc5kofLi0DU4xZ7sRyiP9M9yQXN+b9HZmXiRr765xpdff8+31+b57odFYYEf528xv3iTHfHnpeV0zLYodR091Nr8UuXglFRJXym4MUQgPUMu9xs/Xb/Bwo2fub5wi0VZc7k7wF/0jWWNuHJHnMr6VkwVDaj6HU9L9w9JcpeqbHYUBAfGZ+TcH9z9Pcefd3/9l5u3b/PLnRy79r1sxD3kGKGqoZ2yGgtqVVdapmJ4RWVVc5jOgWd48+JlLrxzifPCBYPLnHrjPV45+y7WvkmjSGa7CP7j0CRJzbszpqSIyq8SpNpkdh8dWEljsEBbpHhmmJr1DsprN6Mq3QelbYbk2uKyNVpci8hsl8kHDaTfllOY+zwRVm/SqGr0oLShl6jzHWL99qdoeOwo67onqPcdodZ7mLVbD/Gw5yBr3OOs1sap0Q5QLSmqdqWpcu2n0lmgQv5IG7qTWPzSgpnXr3Bs7kMmT3/A4ZPvM5a9SCzzNvqxtwhMnqdn4hzbD5zBOzZHV+JVOmOz2CInaddn2BzK0hR8gY2BDI3+DI/0Zfgbc5BcoR3iOeEAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/a67b31f412fbc8448faa3c68f717a457/8ac56/image-28.webp 240w,\n/static/a67b31f412fbc8448faa3c68f717a457/d3be9/image-28.webp 480w,\n/static/a67b31f412fbc8448faa3c68f717a457/b0a15/image-28.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/a67b31f412fbc8448faa3c68f717a457/8ff5a/image-28.png 240w,\n/static/a67b31f412fbc8448faa3c68f717a457/e85cb/image-28.png 480w,\n/static/a67b31f412fbc8448faa3c68f717a457/0b533/image-28.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/a67b31f412fbc8448faa3c68f717a457/0b533/image-28.png\"\n            alt=\"image-28.png\"\n            title=\"image-28.png\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>Identifying the cause of this crash using TTD is the scenario for this tutorial.</p>\n<h2 id=\"tracing-ttd_sampleexe-with-ttd\" style=\"position:relative;\"><a href=\"#tracing-ttd_sampleexe-with-ttd\" aria-label=\"tracing ttd_sampleexe with ttd permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Tracing ttd_sample.exe with TTD</h2>\n<p>First, launch WinDbg Preview (downloaded from the Windows Store) with administrator privileges.</p>\n<p>Then, from the top-right <strong>File</strong> menu, select <strong>Launch executable (advanced)</strong> as shown in the image below.</p>\n<p>From here you can run a binary under debugging and capture a TTD trace.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/29a630fa24b406d2131da2f51a2b8d6c/0b533/image-29.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 46.25%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAARlAAAEZQAGA43XUAAABJUlEQVQoz4WSvU7DMBSFvTLyNgwVdOEReBMQbAy8AogCK++CRBGkElFbIVHi5seOf5I4LEyndtKgFtJkOLqSdfz53ntM9i5fcfzgQ6cMdBmC0iWklCiKYkt5nneq8ZH9Kw8nj3MowZCmHFpJ5JlGnCQQQvzCjTGdclDnJeR8jOH9FNOFxJP3ibdZjDnVFi7+XCp7ZOoOycULhnc+BOeYfXyBhgxc5mCMVS+WZdnbnVPjI+RsjKPRBEZGCKNoPXIGZatWqnd3TkkS290zhKGogYObCTIeI+Fp1ZnS2hqLf8HskrZ+N41SugYeXHsI6AJBQKsg3KuZ7bJJd7NuJ7953uzw9BmD23c7nqiS1RbUBmz7Rm1fqgIejnz8fBsLqU3ZGtoF3KUVxheS6t47uDkAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/29a630fa24b406d2131da2f51a2b8d6c/8ac56/image-29.webp 240w,\n/static/29a630fa24b406d2131da2f51a2b8d6c/d3be9/image-29.webp 480w,\n/static/29a630fa24b406d2131da2f51a2b8d6c/b0a15/image-29.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/29a630fa24b406d2131da2f51a2b8d6c/8ff5a/image-29.png 240w,\n/static/29a630fa24b406d2131da2f51a2b8d6c/e85cb/image-29.png 480w,\n/static/29a630fa24b406d2131da2f51a2b8d6c/0b533/image-29.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/29a630fa24b406d2131da2f51a2b8d6c/0b533/image-29.png\"\n            alt=\"image-29.png\"\n            title=\"image-29.png\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>Enter the absolute path of the <code class=\"language-text\">ttd_sample.exe</code> binary in the <strong>Executable</strong> field.</p>\n<p>Enable the <strong>Record with Time Travel Debugging</strong> checkbox in the lower right.</p>\n<p>Leave the remaining options at their defaults and click <strong>Record</strong>.</p>\n<p>In the <strong>Configure location</strong> window, choose a destination folder for the trace file and click <strong>Record</strong>.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 527px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/19c7d77f0173fa84d4f0a31389cda00b/44385/image-30.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 54.58333333333334%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAAsTAAALEwEAmpwYAAABb0lEQVQoz6WSu0/DMBDG+//viAmJgY0ZgcTAipAYoeHROLZju3k/G9om6sc5oSWIQpEYfrqzcz5/98WTIs+R76Eoij8zPjOxSVVVKMvyx8JDjOsnNuGcw/M8aKWgPjDGIIoihGF4EFtvaweFWYaHxyk8LhAFEeI4gdFzpEmGtu2wWq2/0a5bdF2Hjr5vNhsEQQApZT/lJEkSusEQczBP0gdDN9XUMEfyQZqWyLKBPC8RBikJMBByDi4Cmk59bSilJhRmM7eHk1opJJSv4Ps+XVCiaRrU9QLL5Rvu7qc4OrnA2fkNjk+vcHl9SxbpYeQ4ick7A+ZyPDkvcF2PmnrwGO9hrqA9iozijPV7dj11XnsYqRNCjxXGpMLQokFV1igLy4Ko+tG3e9ZTrTX5a3qfE0IrTXlK5zU1FUPDNE1JEQMn/wSXNO4Qx7mNg3KXIttZY2Gk2HGePxXaue1fUqMnsw+r7jessN3Dtp3/y/ZhvwPQ6DVs85U7BgAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/19c7d77f0173fa84d4f0a31389cda00b/8ac56/image-30.webp 240w,\n/static/19c7d77f0173fa84d4f0a31389cda00b/d3be9/image-30.webp 480w,\n/static/19c7d77f0173fa84d4f0a31389cda00b/042cc/image-30.webp 527w\"\n              sizes=\"(max-width: 527px) 100vw, 527px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/19c7d77f0173fa84d4f0a31389cda00b/8ff5a/image-30.png 240w,\n/static/19c7d77f0173fa84d4f0a31389cda00b/e85cb/image-30.png 480w,\n/static/19c7d77f0173fa84d4f0a31389cda00b/44385/image-30.png 527w\"\n            sizes=\"(max-width: 527px) 100vw, 527px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/19c7d77f0173fa84d4f0a31389cda00b/44385/image-30.png\"\n            alt=\"Configure location window for TTD trace file\"\n            title=\"Configure location window for TTD trace file\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>The application runs and the fault is reproduced. The TTD trace has been captured at this point, so click <strong>Terminate process</strong> to stop the application.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/4b165877ec22631875e1dc785be8a9b9/0b533/image-31.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 75%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAYAAADkmO9VAAAACXBIWXMAARlAAAEZQAGA43XUAAACrUlEQVQ4y41SS08aURQeH6mhC3cSFxqjaSiRxFXdl/7JpsvSBbY/QJsuuqkoVoOCwMDAwAwDzDDDPEB88vh6zqXVtjHRm/lyTs6c+93vPKRvGRWO48Jsd9BqW2ibDBst00GxbkM3XXRsF07XR+D34fs9XFxcYjC4EvYPLi+v0ek4kA7SGbyNx7G5GcPW1hZisZjwo4SNSAyvIlFEIhG8jkaxvr6BePwdPW6TiACe10cQDOCTZTSbFqQf+yksLi5CkqRnIRwOQy5VUdfa0A0TDcNCl9Tz6boepGw2i+XlZZE8OzuLmZmZf8Axxvz8vMhZXV1FLneOWq2OalVFuazApDbx8fwA0unZGZaWwiKZCZ5SuLKyAlmWYRiGgKZpsDv2lNAjwnQ6fa+QVczNzQmwKrYLCy8ICwiFQvcK8/k86vU6VFVFpVJBu91+IDw8OEToZehRNW+2t3F8cor91BFy5wXs7e1hbW0NSrlM6prQdZ1Kr9F0Ow+EhUIRiUQCHxOf8HlnB8lkEjtk37//gN3dr7QSAzQtF11KZiXJ5BeUlRpqag2NRkOo7FjWw1C4qa7bxcVggH6f14DXwRcwGgYURUEuLyOTOYVclMUwstm8IOL+Valk0zSnhF0irNAFXavTGmh0uSIaLpdKUCixVCyKeKVaRbGQpxKnBBr1T9d0UmiIsm37r6GoNHqTSuFyuC9cBoN9vthsUkz4GlqtFkpyCSV6kBUyuAKO3xNWSJVldUiui17Qo40PqGwunXx/6nvUG88N6H8fFu0cD8FxHHGHbUB5o9EIJvFIrufh+uYWw+EI48kEo/FE2Kk/Jgvc3N7hbjjEWPwD6Jvit89xtj71XxrdXuPpM8Fzzs3VANL38waO9R5+asGjONZ6SKseUootcFTzROz/vJNGH6migV/NBKZqnNlXpwAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/4b165877ec22631875e1dc785be8a9b9/8ac56/image-31.webp 240w,\n/static/4b165877ec22631875e1dc785be8a9b9/d3be9/image-31.webp 480w,\n/static/4b165877ec22631875e1dc785be8a9b9/b0a15/image-31.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/4b165877ec22631875e1dc785be8a9b9/8ff5a/image-31.png 240w,\n/static/4b165877ec22631875e1dc785be8a9b9/e85cb/image-31.png 480w,\n/static/4b165877ec22631875e1dc785be8a9b9/0b533/image-31.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/4b165877ec22631875e1dc785be8a9b9/0b533/image-31.png\"\n            alt=\"image-31.png\"\n            title=\"image-31.png\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>When the application terminates, the TTD trace replay starts automatically with the Timeline positioned at the beginning.</p>\n<p>You are now ready to start troubleshooting with TTD.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/4848fb3a587368a95aca2e693ab84c50/0b533/image-32.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 66.25%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAARlAAAEZQAGA43XUAAACOElEQVQ4y41S2ZLaMBD0//9NKqmw+wd5ILA2vi+MMT7lQ+ZYKI7OjGDZ4i2q6tI16umekTb5Y8KOM+RFiSwvsd7kaNoOXS9p7tGI7glB+yhewwsShPQmWRVI0oLuetxuN+x2B2iOMYc+/4vpdArLMhEEPsyFAduyEEURijxHWZYQTQM5SIRBCN93sVqtCEQchaiqCjw+P0/QFgsTjuvCtGzYtkckMTzPI+IAOZG1oiW1PbquQ98P6j4MAyJLsV6vsVwuUdf1N6FHZHzIARuyW1U12lZASqlIGMMwEFmvzgJSGJKLJEnUuzAMlYMnYUQHLJ8v2CKDA1kdW+FgBq852f0+VurSNEUcx0+Fh8ORamg7yLJMBbBKzqzIHiS8LopCkeZ5QfULlGVOyrEBCeF7HuM4QvuYz2EYBhaLBXyqmwoKAqWY10pdzWVoH5YDROE9Lk1XSnH5aIoiNHQdOmE2m1NjLDiOC/1Dh2ma9Gil7AghVF25nvfS3JNxqVjpV5eVZZbMdjv6Y3JgDNhtR4XtKLGjrPv9HtvdnhRs4VITPddBTN1mdb7vq7Lcm0KEaUiZxB7uZoBH8HMJj8F7mh2ak4I/+gi5PZB9gaZhxZ2CEPwLJE6nM/0ECa2lzmXdDlElEddM2CIqByybEXHRq/WmGZS68+WKy/WGyw2voLMzLQ5H+jbAGd/jSjgSLngdV/zfuEL7Mcvw5ghMbIE3htMq8H7y2P82a/w0SvwivNnNI0a84J3O3q0K/wBQasHtOBOkhwAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/4848fb3a587368a95aca2e693ab84c50/8ac56/image-32.webp 240w,\n/static/4848fb3a587368a95aca2e693ab84c50/d3be9/image-32.webp 480w,\n/static/4848fb3a587368a95aca2e693ab84c50/b0a15/image-32.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/4848fb3a587368a95aca2e693ab84c50/8ff5a/image-32.png 240w,\n/static/4848fb3a587368a95aca2e693ab84c50/e85cb/image-32.png 480w,\n/static/4848fb3a587368a95aca2e693ab84c50/0b533/image-32.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/4848fb3a587368a95aca2e693ab84c50/0b533/image-32.png\"\n            alt=\"image-32.png\"\n            title=\"image-32.png\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>You can analyze the TTD trace directly from here, but let’s take the opportunity to open the saved trace file for analysis.</p>\n<p>Close WinDbg and relaunch it with administrator privileges.</p>\n<p>From the <strong>File</strong> menu, select <strong>Open trace file</strong> and open the <code class=\"language-text\">.run</code> file that was created.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/e6b8480b8b5affa1bf60a2cc654a5781/0b533/image-33.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 50%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAARlAAAEZQAGA43XUAAACFklEQVQoz5WSXU/SURjA/+uGlWhs0OJtAiLGkv68hay2Xr5Fn6SWa90gMt7a3KqLtm4s1PoONu+8MDNzuSlSICAITOpKQTd+/c9xMXXddLbfnnOe7fntOec5ysM333k0t0OtecDvX20ODtq022263S7/u05OTlCuxta5/WqTfLHMXrXC7m6ZVrPF2tpXUqkUmWyWrEY6nZbns4icIJPJMDU1xdLSEoru+RfCLzfZrrZo7Nep1ev0ej1mZ2fR6XSYLTYMBgMDAwPo9XqGhoZkHBwclIizyWTi8hU9sXgC5dKzVTwvNijVmlRKRfL5bTpHh8wvLGB3ewkFAzy4f49IJEIgECAajTIxMUFEoOXC4TBer5frZrPWaRZFefqZkfQGhfIehZ9lCqUqh8c93uXm8Y6Po6q3uHsnKgtVVSUYDBIKhfrR7/fj8XgwGo3yGRTl8QouTbier7C2VWd1q0ax1eH12xxmq4WxsTGGhx1YrVbsdrvEZrP19wKXyyWvfSp8soIz/Y2dwg9ajTpVbTDH3SPmP3zkmt3JDU3oHh3F6XTKwn/hdrulUAxICl2acHUrr025SkVDDOV9bo6RmyoupwOHwyGFFxGyv/GcUHS4Xdmn2dinVjudci6Xw2KxyIJRrUPRhRBfROR9Pp98knPCsx+70+mwvLzM5OQk09PTkng8TiwW6yP+nYjJZJKZmRkSiQSfFhf5A3Qe4rocuYGSAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/e6b8480b8b5affa1bf60a2cc654a5781/8ac56/image-33.webp 240w,\n/static/e6b8480b8b5affa1bf60a2cc654a5781/d3be9/image-33.webp 480w,\n/static/e6b8480b8b5affa1bf60a2cc654a5781/b0a15/image-33.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/e6b8480b8b5affa1bf60a2cc654a5781/8ff5a/image-33.png 240w,\n/static/e6b8480b8b5affa1bf60a2cc654a5781/e85cb/image-33.png 480w,\n/static/e6b8480b8b5affa1bf60a2cc654a5781/0b533/image-33.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/e6b8480b8b5affa1bf60a2cc654a5781/0b533/image-33.png\"\n            alt=\"image-33.png\"\n            title=\"image-33.png\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>The trace file is now loaded into WinDbg and ready for analysis.</p>\n<h2 id=\"troubleshooting-with-ttd\" style=\"position:relative;\"><a href=\"#troubleshooting-with-ttd\" aria-label=\"troubleshooting with ttd permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Troubleshooting with TTD</h2>\n<p>From here, analyze the captured trace file to perform troubleshooting.</p>\n<h3 id=\"loading-the-symbol-file\" style=\"position:relative;\"><a href=\"#loading-the-symbol-file\" aria-label=\"loading the symbol file permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Loading the Symbol File</h3>\n<p>The official tutorial starts by loading the symbol file path into WinDbg.</p>\n<p>In my environment, <code class=\"language-text\">ttd_tutorial.pdb</code> is placed on the Desktop, so I use <code class=\"language-text\">.sympath+ &lt;desktop path></code>.\nAfter adding the symbol file path, run the <code class=\"language-text\">.reload</code> command.</p>\n<div class=\"gatsby-highlight\" data-language=\"powershell\"><pre class=\"language-powershell\"><code class=\"language-powershell\"><span class=\"token punctuation\">.</span>sympath+ C:\\Users\\Tadpole01\\Desktop\n<span class=\"token punctuation\">.</span>reload</code></pre></div>\n<p>When the symbol file is loaded correctly, WinDbg can interpret and display function names and other symbols for <code class=\"language-text\">ttd_tutorial.exe</code>, as shown in the image below.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 539px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/250917af9537b4cef03305202ba42a47/10f9a/image-36.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 95.41666666666667%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAATCAYAAACQjC21AAAACXBIWXMAAAsTAAALEwEAmpwYAAADkklEQVQ4y21UiW6jWBDk//9mZ7UrRUqU7EwOx45PfHCDAZvDJxhiJz5qq18mGa1mkdpgHl3dXV3dWrEtkOc5Xl9fsVgsUNU15LpcLjifz/8x4JddLuffzsW0IAgwGAwwm81QlqUCXi6XWK3WqKoKu93up5XIsp2yPN/xvFTvfp3vlL9mTCZoNBrwPA+O42A4HKLf76HT6cK2HQS+rwLGcYjmc4nv3wvc3BTo9XcMnMAwLFiWzYTm2Gw20EajER4fHzEhcPulRYcfeHl5wdNTg8B9BXZ3e8eADlrNCn98K9EgcK+3IJBBnzZ9DSRJgu12C63b6eD6+hq6rjODZ0a/wf39PW5vb9Fut+nYw9XVFZ1NOtf46++SAUvEUYRnft/hN1JdURRYr9fQTMNAs9mCZVrMps/nJrrdHp3aDDKEPtTx8PBAJ5cAJb79ucVAL+C5FoP1VSJRFCuw1WoFbUiH+/sf5GLMMh/I5xMza+GJd5PcRMxEeE3SObN8Z3l71PUec3Lmeb7iPZyGqik1FaLN4nf4/js5OJP4EwGAeHYkySf8fh1/2v+dfVya6wRM3cAiL5Cma4JL5zyMJ56SjpThs9MbEj4e5ex+zgoyeH5BiVWYzxOl3/1+/wF4PB75ImE5Q2bnYzYPWU4AP3AwnXpwXVt1eLnKGHRDHW6RL0pqUZqwUkMh+vsQPgHlJ0sPaLUyGJMNLPuV3B3ITcUm7RBGFcKwhmkeGOxAWg6s5IDT6cAM95CEPi+ZLgW4XKwx1C2MxjZ21TskWM5sWi2dTbAp4C05XvFespotMytRkAIpVZrxCfYFKCMkIo2ikLNc4eNdgdFIV/qT7h0O+y+T8RQT3uRMnr+a8vb2hjSZMcMBSRcAi9nMyJ/P8eqydFtJynYsxZnYar1gs2iceclyzZE7nc60E7QwzChkH1G8IlgK18l5jzAeh7QYjpvwjJMR1yy5oh4rSqomUM3O18ywYlN2ao7VLAsvvpcRJKAUBDBBEMxZ/pLdTTBlQNcVFUjWc0ooZdYJfWYIpjE1GyNjpwVMjZ7nuhyzZ2qxwwaMuRC6HKcBN42pOJR3ui4j1lN8yvsh/wsNos8so5xY+leGfc7j3d0//MBU2+WRW2Yw0NVzh4tDloNsH5lvnZtHZtwwTcgenU6najTTNFU8qlmWJshWkWi2bXPwdbXfXNeh9kzVFFltnuup/67rKUcRtJgCY6mfC/ZfFrVyHSA5Wl0AAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/250917af9537b4cef03305202ba42a47/8ac56/image-36.webp 240w,\n/static/250917af9537b4cef03305202ba42a47/d3be9/image-36.webp 480w,\n/static/250917af9537b4cef03305202ba42a47/9cb26/image-36.webp 539w\"\n              sizes=\"(max-width: 539px) 100vw, 539px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/250917af9537b4cef03305202ba42a47/8ff5a/image-36.png 240w,\n/static/250917af9537b4cef03305202ba42a47/e85cb/image-36.png 480w,\n/static/250917af9537b4cef03305202ba42a47/10f9a/image-36.png 539w\"\n            sizes=\"(max-width: 539px) 100vw, 539px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/250917af9537b4cef03305202ba42a47/10f9a/image-36.png\"\n            alt=\"image-36.png\"\n            title=\"image-36.png\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>With the symbol file loaded, let’s start the analysis.</p>\n<h3 id=\"checking-exceptions-from-the-trace-file\" style=\"position:relative;\"><a href=\"#checking-exceptions-from-the-trace-file\" aria-label=\"checking exceptions from the trace file permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Checking Exceptions from the Trace File</h3>\n<p>Opening the trace file reveals that a <code class=\"language-text\">code 80000003</code> exception occurred:</p>\n<div class=\"gatsby-highlight\" data-language=\"powershell\"><pre class=\"language-powershell\"><code class=\"language-powershell\"><span class=\"token punctuation\">(</span>19e0<span class=\"token punctuation\">.</span>1f9c<span class=\"token punctuation\">)</span>: <span class=\"token keyword\">Break</span> instruction exception <span class=\"token operator\">-</span> code 80000003 <span class=\"token punctuation\">(</span>first/second chance not available<span class=\"token punctuation\">)</span>\nTime Travel Position: D:0 <span class=\"token namespace\">[Unindexed]</span> Index\n<span class=\"token operator\">!</span>index\nIndexed 2/2 keyframes\nSuccessfully created the index in 362ms<span class=\"token punctuation\">.</span></code></pre></div>\n<p>The <code class=\"language-text\">Time Travel Position</code> displayed here indicates the position within the TTD trace. (Position values may vary between execution environments.)</p>\n<p>You can jump to any trace position by running a command like <code class=\"language-text\">!ttdext.tt &lt;Time Travel Position></code>.</p>\n<p>Reference: <a href=\"https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/time-travel-debugging-extension-tt\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Time Travel Debugging Extension !tt command - Windows drivers | Microsoft Docs</a></p>\n<div class=\"gatsby-highlight\" data-language=\"powershell\"><pre class=\"language-powershell\"><code class=\"language-powershell\">0:000> <span class=\"token operator\">!</span>ttdext<span class=\"token punctuation\">.</span>tt D:0\nSetting position: D:0\n<span class=\"token punctuation\">(</span>19e0<span class=\"token punctuation\">.</span>1f9c<span class=\"token punctuation\">)</span>: <span class=\"token keyword\">Break</span> instruction exception <span class=\"token operator\">-</span> code 80000003 <span class=\"token punctuation\">(</span>first/second chance not available<span class=\"token punctuation\">)</span>\nTime Travel Position: D:0\nntdll!LdrInitializeThunk:\n00007ffd`f1944b00 4053            push    rbx</code></pre></div>\n<h3 id=\"listing-events-in-the-ttd-trace\" style=\"position:relative;\"><a href=\"#listing-events-in-the-ttd-trace\" aria-label=\"listing events in the ttd trace permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Listing Events in the TTD Trace</h3>\n<p>Next, call <code class=\"language-text\">dx -r1 @$curprocess.TTD.Events</code> to get a list of events that occurred in the TTD trace.</p>\n<p>Reference: <a href=\"https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/time-travel-debugging-event-objects\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">TTD Event Objects - Windows drivers | Microsoft Docs</a></p>\n<p>The output below shows the complete sequence: various modules were loaded, a thread was started, an exception occurred which caused the thread to terminate, then each module was unloaded, and the process exited.</p>\n<div class=\"gatsby-highlight\" data-language=\"powershell\"><pre class=\"language-powershell\"><code class=\"language-powershell\">0:000> dx <span class=\"token operator\">-</span>r1 @<span class=\"token variable\">$curprocess</span><span class=\"token punctuation\">.</span>TTD<span class=\"token punctuation\">.</span>Events\n@<span class=\"token variable\">$curprocess</span><span class=\"token punctuation\">.</span>TTD<span class=\"token punctuation\">.</span>Events                \n    <span class=\"token punctuation\">[</span>0x0<span class=\"token punctuation\">]</span>            : Module ttd_tutorial<span class=\"token punctuation\">.</span>exe Loaded at position: 2:0\n    <span class=\"token punctuation\">[</span>0x1<span class=\"token punctuation\">]</span>            : Module TTDRecordCPU<span class=\"token punctuation\">.</span>dll Loaded at position: 3:0\n    <span class=\"token punctuation\">[</span>0x2<span class=\"token punctuation\">]</span>            : Module apphelp<span class=\"token punctuation\">.</span>dll Loaded at position: 4:0\n    <span class=\"token punctuation\">[</span>0x3<span class=\"token punctuation\">]</span>            : Module KERNELBASE<span class=\"token punctuation\">.</span>dll Loaded at position: 5:0\n    <span class=\"token punctuation\">[</span>0x4<span class=\"token punctuation\">]</span>            : Module ucrtbase<span class=\"token punctuation\">.</span>dll Loaded at position: 6:0\n    <span class=\"token punctuation\">[</span>0x5<span class=\"token punctuation\">]</span>            : Module KERNEL32<span class=\"token punctuation\">.</span>DLL Loaded at position: 7:0\n    <span class=\"token punctuation\">[</span>0x6<span class=\"token punctuation\">]</span>            : Module ntdll<span class=\"token punctuation\">.</span>dll Loaded at position: 8:0\n    <span class=\"token punctuation\">[</span>0x7<span class=\"token punctuation\">]</span>            : Thread UID:   2 TID: 0x1F9C created at D:0\n    <span class=\"token punctuation\">[</span>0x8<span class=\"token punctuation\">]</span>            : Exception 0xC0000005 of <span class=\"token function\">type</span> Hardware at PC: 0X52005400200045\n    <span class=\"token punctuation\">[</span>0x9<span class=\"token punctuation\">]</span>            : Thread UID:   2 TID: 0x1F9C terminated at 96:1\n    <span class=\"token punctuation\">[</span>0xa<span class=\"token punctuation\">]</span>            : Module apphelp<span class=\"token punctuation\">.</span>dll Unloaded at position: FFFFFFFFFFFFFFFE:0\n    <span class=\"token punctuation\">[</span>0xb<span class=\"token punctuation\">]</span>            : Module TTDRecordCPU<span class=\"token punctuation\">.</span>dll Unloaded at position: FFFFFFFFFFFFFFFE:0\n    <span class=\"token punctuation\">[</span>0xc<span class=\"token punctuation\">]</span>            : Module ttd_tutorial<span class=\"token punctuation\">.</span>exe Unloaded at position: FFFFFFFFFFFFFFFE:0\n    <span class=\"token punctuation\">[</span>0xd<span class=\"token punctuation\">]</span>            : Module KERNEL32<span class=\"token punctuation\">.</span>DLL Unloaded at position: FFFFFFFFFFFFFFFE:0\n    <span class=\"token punctuation\">[</span>0xe<span class=\"token punctuation\">]</span>            : Module KERNELBASE<span class=\"token punctuation\">.</span>dll Unloaded at position: FFFFFFFFFFFFFFFE:0\n    <span class=\"token punctuation\">[</span>0xf<span class=\"token punctuation\">]</span>            : Module ntdll<span class=\"token punctuation\">.</span>dll Unloaded at position: FFFFFFFFFFFFFFFE:0\n    <span class=\"token punctuation\">[</span>0x10<span class=\"token punctuation\">]</span>           : Module ucrtbase<span class=\"token punctuation\">.</span>dll Unloaded at position: FFFFFFFFFFFFFFFE</code></pre></div>\n<h3 id=\"retrieving-exception-details\" style=\"position:relative;\"><a href=\"#retrieving-exception-details\" aria-label=\"retrieving exception details permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Retrieving Exception Details</h3>\n<p>Clicking on the exception event to view its details shows that the <code class=\"language-text\">Time Travel Position</code> when the exception occurred was <code class=\"language-text\">7C:0</code>. (Position values may differ in other environments.)</p>\n<div class=\"gatsby-highlight\" data-language=\"powershell\"><pre class=\"language-powershell\"><code class=\"language-powershell\">0:000> dx <span class=\"token operator\">-</span>r1 @<span class=\"token variable\">$curprocess</span><span class=\"token punctuation\">.</span>TTD<span class=\"token punctuation\">.</span>Events<span class=\"token punctuation\">[</span>8<span class=\"token punctuation\">]</span>\n@<span class=\"token variable\">$curprocess</span><span class=\"token punctuation\">.</span>TTD<span class=\"token punctuation\">.</span>Events<span class=\"token punctuation\">[</span>8<span class=\"token punctuation\">]</span>                 : Exception 0xC0000005 of <span class=\"token function\">type</span> Hardware at PC: 0X52005400200045\n    <span class=\"token function\">Type</span>             : Exception\n    Position         : 7C:0 <span class=\"token namespace\">[Time Travel]</span>\n    Exception        : Exception 0xC0000005 of <span class=\"token function\">type</span> Hardware at PC: 0X52005400200045</code></pre></div>\n<p>Selecting the child <strong>Exception</strong> element gives even more detail:</p>\n<div class=\"gatsby-highlight\" data-language=\"powershell\"><pre class=\"language-powershell\"><code class=\"language-powershell\">0:000> dx <span class=\"token operator\">-</span>r1 @<span class=\"token variable\">$curprocess</span><span class=\"token punctuation\">.</span>TTD<span class=\"token punctuation\">.</span>Events<span class=\"token punctuation\">[</span>8<span class=\"token punctuation\">]</span><span class=\"token punctuation\">.</span>Exception\n@<span class=\"token variable\">$curprocess</span><span class=\"token punctuation\">.</span>TTD<span class=\"token punctuation\">.</span>Events<span class=\"token punctuation\">[</span>8<span class=\"token punctuation\">]</span><span class=\"token punctuation\">.</span>Exception                 : Exception 0xC0000005 of <span class=\"token function\">type</span> Hardware at PC: 0X52005400200045\n    Position         : 7C:0 <span class=\"token namespace\">[Time Travel]</span>\n    <span class=\"token function\">Type</span>             : Hardware\n    ProgramCounter   : 0x52005400200045\n    Code             : 0xc0000005\n    Flags            : 0x0\n    RecordAddress    : 0x0</code></pre></div>\n<h3 id=\"jumping-to-the-point-where-the-exception-occurred\" style=\"position:relative;\"><a href=\"#jumping-to-the-point-where-the-exception-occurred\" aria-label=\"jumping to the point where the exception occurred permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Jumping to the Point Where the Exception Occurred</h3>\n<p>Click <code class=\"language-text\">7C:0 [Time Travel]</code> to jump to the position where the exception occurred.</p>\n<p>The cursor in the <strong>Timelines</strong> panel at the bottom of the screen advances.</p>\n<p>In TTD, you can inspect the memory and register state as they were recorded at the current <code class=\"language-text\">Time Travel Position</code>.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/8e3bc7f6f574ab989430b7790e7ea787/0b533/image-34.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 66.66666666666666%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAARlAAAEZQAGA43XUAAACEklEQVQ4y42T6Y6bQBCEef83SqLdfYD8sr0cNubwcuMZrsGcxpWesUUix5EyUqlhYD6qq4X27SeDHZxhWRY2Ox26YeGTFMYpeFkhZwV4UaHreozjiCTJIMQF1+sV8zyTrpimGctyQ0Xva/5RoKBDpqFjt9thu91A13X4nocwDFEUBdr2gtttoUMLXNqfpgmvlmgENNOskGaMHBowCGoYJkzTUI5t+wjGmHIkYRKU52eC3/6SXE3TQHPcDlF0wemUI05KVFWpIJzz1V3bduqQBDLGV8BzVUDDzMlJhu3mBNNKFYTToSzLlKQjIVrlUObmuB6GYXgJlDlrvu9QLgdq8ZMy8xHFAcLoi0AZfbFGSUELIVag55/UcF4B+2GCZh8dmuweB9snYIAgOBGUgOec2heqjYbClu1KoEvA4V/AfoQWhIwyLOB5CTnjSFKGsqpQNy3VTrUhHUpXK3D4DfxzKA+gdEVtBiHSNEYch6SYcqTs6pJUoSWghMm2j467tvy8FDD9ihDyFnZSw0kbuJlYZScN9nGNIOVq2pdLhzPjaup9P9B9Tx3c6zhOlHcNTfASUdnimNaw0wpmxHCISzhZjT1FsafrtBCYyeEo/wjqbpoXjPP9fnrUmR70FIV2N3t7aAaWjqr8E5bHHu77/7UWaN+NHG97jrdDgXfSh12q+vbQ+6HED5Ph/h5bnz9L7n9YOX4Bc+/a8n94GSYAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/8e3bc7f6f574ab989430b7790e7ea787/8ac56/image-34.webp 240w,\n/static/8e3bc7f6f574ab989430b7790e7ea787/d3be9/image-34.webp 480w,\n/static/8e3bc7f6f574ab989430b7790e7ea787/b0a15/image-34.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/8e3bc7f6f574ab989430b7790e7ea787/8ff5a/image-34.png 240w,\n/static/8e3bc7f6f574ab989430b7790e7ea787/e85cb/image-34.png 480w,\n/static/8e3bc7f6f574ab989430b7790e7ea787/0b533/image-34.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/8e3bc7f6f574ab989430b7790e7ea787/0b533/image-34.png\"\n            alt=\"image-34.png\"\n            title=\"image-34.png\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>In WinDbg, the <code class=\"language-text\">r</code> command displays register information.</p>\n<div class=\"gatsby-highlight\" data-language=\"powershell\"><pre class=\"language-powershell\"><code class=\"language-powershell\">Time Travel Position: 7C:0\n0:000> r\nrax=0000000000000000 rbx=0000000000000001 rcx=00000000ffffffff\nrdx=00007ffdef6e0980 rsi=000002b36fa33520 rdi=000000000000002c\nrip=0052005400200045 rsp=000000b936effb20 <span class=\"token function\">rbp</span>=004d004900540020\n r8=000000b936efde98  r9=000002b36fa3899c r10=0000000000000000\nr11=000000b936eff980 r12=0000000000000000 r13=0000000000000000\nr14=000002b36fa2d110 r15=0000000000000001\niopl=0         <span class=\"token function\">nv</span> up ei pl nz na pe nc\ncs=0033  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00000202\n00520054`00200045 ??              ???</code></pre></div>\n<p>When the values of <code class=\"language-text\">rsp</code> and <code class=\"language-text\">rbp</code> differ as drastically as shown above, it is possible that the stack has been corrupted for some reason.</p>\n<h3 id=\"step-into-back\" style=\"position:relative;\"><a href=\"#step-into-back\" aria-label=\"step into back permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Step Into Back!!!</h3>\n<p>To identify the point at which the stack was corrupted, we need to travel back in time.</p>\n<p>Click the <strong>Step Into Back</strong> button shown in the screenshot to step backwards through the trace one instruction at a time.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 852px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/12d497b36084dbe911d3bc61dcac5f79/47ff6/image-37-852x1024.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 120%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAYCAYAAAD6S912AAAACXBIWXMAARlAAAEZQAGA43XUAAAD3UlEQVQ4y4VU2ZLiRhDUj/vZz/4F+wP8YIftxTG7MTjwBnMxMAgY0AFCAh3oPkAtIF3VGJZd76wVkVF9qTq7KquU7290vB+pWFpraJoF/VXDjK3lQJtpWK0CrBwXI9PFfG7jaWLjlweyeoil48N2Q1i2j2CTIIpSKNt4A3OuwppbmP35AeMff4LR/huG4UCfGlivfXhrD+3+HFNjifHMwu2Thle6oMpzpHGKPMnIJnKs/PBhge9+1fBedREFdOvSheN48OhG14/hBTH8IMHKC+HTWhxniMIIMbEJwhQbshuyYZTBpTNKV9Xw7uMzPvaG0BdLPA5U9IZjjKY6XsZTdLr36Nw9IspKiCNQicNXsMe2OSKIcyj2wqSnTWDqGqzFHCN1iOfnHkzTJCYbiqED3/cgRI2mETjsG7z1bbc7KJqmwVmt6Kk2gmCDNM3oCRtkFJ9qu0VdC3lYCEHPjZEXBfaHAznfY78/QY4PexRFBWU8HkPXdXJoIQwLZJmgmypUVYXdbkfj7WVcE8u6ruUaz884z7OsgGIYBhYLC5a1oIxG9DPo1gYN3Xw8Hi84MWkurL7E4czw5eUFzHIymcC2bWK6BF9iOw5dsCbtzeU4SVL6oUBOofgaeC8h+SicgHa7jW63i8FggNvbW5r/hfv7B7nWarVwc3NDlzkU35TEG1FoQmnPCEO2IdkYypAYPj4+ot/vg9ne3d2h0+nIMbObzWYy455PAvc8yrgvk3Pt8JPjhBySTDjT/GROjue68un8cxAEkk1ZltKJQ0/ndWaaJMlnSNN/S09VVUynM4qbDnvp0+YOZfEpLtdxO4+zLPsPeJ2r6CIbxnpN5RfFcInlmR0zY0bMkuXzFlg6aUqyYUf9/gCj0VhqkRPD8dM0HRO6jBPz1OvJn/7vK8stFNM0KH6vUirWYiGd9ciBYZgyXpyQOa1zWZEcSW+Hz/R5Bn9S2PO5SfW6ImFbMuicLXaUJLFkxWLm70iOkjj+JtM8o+bgU6yCTUiyCOQNguqyqnYoyorqlmKzq6mmubxqKi8h54xaNIT9BaI5IOJ+OBlNqafliNJSWj/MLgi+mF9jExeEUtogKqh/pnDWAZTw4VkKcmBF+F310Rr5eHeF1hWu1/5QPfzcW8nxb0MXnakn5aNU1FlYlNyqkpzqMS8lUmkLaqwZ4jRHQuFIr/doviZGfCYtSkRUx9zqFG5H3OsE2UbUspHKZkqbO7GFm6yxoTjneUb7p3Pick5cGm9ZVqcGyzKQoNSfJcGZPR0W5KQ5zRtOgpD98Pr8+Z/drpZQON3nXvcmRPPtfVIGP7eqtvgHh9kNveAdOTUAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/12d497b36084dbe911d3bc61dcac5f79/8ac56/image-37-852x1024.webp 240w,\n/static/12d497b36084dbe911d3bc61dcac5f79/d3be9/image-37-852x1024.webp 480w,\n/static/12d497b36084dbe911d3bc61dcac5f79/39392/image-37-852x1024.webp 852w\"\n              sizes=\"(max-width: 852px) 100vw, 852px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/12d497b36084dbe911d3bc61dcac5f79/8ff5a/image-37-852x1024.png 240w,\n/static/12d497b36084dbe911d3bc61dcac5f79/e85cb/image-37-852x1024.png 480w,\n/static/12d497b36084dbe911d3bc61dcac5f79/47ff6/image-37-852x1024.png 852w\"\n            sizes=\"(max-width: 852px) 100vw, 852px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/12d497b36084dbe911d3bc61dcac5f79/47ff6/image-37-852x1024.png\"\n            alt=\"image-37-852x1024.png\"\n            title=\"image-37-852x1024.png\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>By comparing register values, we can infer that the <code class=\"language-text\">rbp</code> register was still healthy at <code class=\"language-text\">Time Travel Position: 7B:17</code>, but became corrupted at <code class=\"language-text\">Time Travel Position: 7B:18</code>.</p>\n<h3 id=\"inspecting-the-memory-data-at-the-address-pointed-to-by-bsp\" style=\"position:relative;\"><a href=\"#inspecting-the-memory-data-at-the-address-pointed-to-by-bsp\" aria-label=\"inspecting the memory data at the address pointed to by bsp permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Inspecting the Memory Data at the Address Pointed to by BSP</h3>\n<p>We confirmed that the address held by BSP just before the stack was corrupted is <code class=\"language-text\">0xb936effb00</code>.</p>\n<p>Let’s display the memory data at that address.</p>\n<p>Open the <strong>Memory</strong> window from WinDbg’s <strong>View</strong> menu and enter <code class=\"language-text\">0xb936effb00</code> in the address bar.</p>\n<p>Change the <strong>Text</strong> setting in the <strong>Memory</strong> tab from <code class=\"language-text\">none</code> to <code class=\"language-text\">ASCII</code> to display any strings contained in the memory data.</p>\n<p>As shown in the image below, the address pointed to by BSP appears to contain a string.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 960px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/9622b7e84612443b9124da99e3025e1e/2bef9/image-38-1024x568.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 55.41666666666667%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAARlAAAEZQAGA43XUAAACCElEQVQoz4VSy5KbMBDk/78kp+yecs05lWzs2CCEhHhJgME2mIfBXh86I3krqcolh64eGM2rZ7wv33zwRGMnNLpzj+Pxibbt0XeDw+l4cTz043/hcV9ApkdseEGBE04ncgwzpnHGV1bj03eDl02Nz9uDw+uvBi//4HXX/oEnZYa6OsHoEhVx308YxxGPxwNcxGCRRFoYpNogozcWuqqRmwpJrsk+YJgXwhXX2zu8zc89OI8RhjHiOEOWlTg0LS6XC1jAEHEOFZNPSihl30j3LYRwti4KmmbEOAy43VZ4+32IPC+RZgZaH1DXJ0zTTM47FeKQ8hmUpin5C3qbOagkcVwaQ+8nzPNEMTd4PiXUukaWGxhTo2nPuF4XN3LAOFjIqVgBGSvEKoWQijp9spAxkiRDVTcoafTLQEsRUQ5Tnqlai5aW0nULJVyxrgv8gGO3Z5RUOAQsIpYftnD+SChKeISpGpJpoi2HtJT6grLs0DQjYSLHSCPMYCyksUMaW7jRrWaW7bfVUBKsDFa7dV3xfr/De3v7Qc7I6eX7e2dvtxuMpIsQ0gUqpRxiWoblLHtqaL+11liWxenoNAwZcz8LEt5y3/euuztVC4Lgo8Nn4iiKHNui1g5D5pLb7iweDzqbiO7sfO5ozIGqXOkGJ3Le3GHzSLgulUpoyzkF/0VKsAsxpnRXYWGX+RvmiiSvmi5QuAAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/9622b7e84612443b9124da99e3025e1e/8ac56/image-38-1024x568.webp 240w,\n/static/9622b7e84612443b9124da99e3025e1e/d3be9/image-38-1024x568.webp 480w,\n/static/9622b7e84612443b9124da99e3025e1e/e46b2/image-38-1024x568.webp 960w,\n/static/9622b7e84612443b9124da99e3025e1e/a9a89/image-38-1024x568.webp 1024w\"\n              sizes=\"(max-width: 960px) 100vw, 960px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/9622b7e84612443b9124da99e3025e1e/8ff5a/image-38-1024x568.png 240w,\n/static/9622b7e84612443b9124da99e3025e1e/e85cb/image-38-1024x568.png 480w,\n/static/9622b7e84612443b9124da99e3025e1e/d9199/image-38-1024x568.png 960w,\n/static/9622b7e84612443b9124da99e3025e1e/2bef9/image-38-1024x568.png 1024w\"\n            sizes=\"(max-width: 960px) 100vw, 960px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/9622b7e84612443b9124da99e3025e1e/d9199/image-38-1024x568.png\"\n            alt=\"image-38-1024x568.png\"\n            title=\"image-38-1024x568.png\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<h3 id=\"supplementary-note-about-esp-and-ebp\" style=\"position:relative;\"><a href=\"#supplementary-note-about-esp-and-ebp\" aria-label=\"supplementary note about esp and ebp permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Supplementary Note: About ESP and EBP</h3>\n<p>Let me briefly touch on some computer architecture concepts.</p>\n<p>When a function is called on a computer running a CPU with an x64 architecture or similar, the CALL instruction is used.</p>\n<p>Simply put, the CALL instruction performs the following steps:</p>\n<ul>\n<li>Pushes the address of the instruction immediately following the CALL onto the stack (this address will be called when the function’s execution is fully complete).</li>\n<li>Jumps to the memory address of the function being called.</li>\n</ul>\n<p>Reference: <a href=\"https://qiita.com/tobira-code/articles/75d3034aed8bb9828981\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Understanding the x86-64 processor stack - Qiita</a></p>\n<p>For more details, please refer to the following article:</p>\n<p>Reference: <a href=\"/windows-windbg-007-memory-spoofing-en\">Overwriting the Memory Pointed to by the Stack Pointer in WinDbg to Execute an Arbitrary Function</a></p>\n<h3 id=\"identifying-the-root-cause\" style=\"position:relative;\"><a href=\"#identifying-the-root-cause\" aria-label=\"identifying the root cause permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Identifying the Root Cause</h3>\n<p>As confirmed earlier, the address indicated by the BSP register pointed to a string.</p>\n<p>In a program like this sample, the address stored in BSP is expected to be the address of the instruction called after <code class=\"language-text\">main</code> finishes.</p>\n<p>So where exactly did the stack get corrupted? Let’s find out.</p>\n<p>Set a breakpoint on the <code class=\"language-text\">main</code> function with the following command, then press <strong>Go Back</strong> to rewind time.</p>\n<div class=\"gatsby-highlight\" data-language=\"powershell\"><pre class=\"language-powershell\"><code class=\"language-powershell\">bu ttd_tutorial!main</code></pre></div>\n<p>Execution stops at the top of <code class=\"language-text\">main</code>. Step forward with <strong>Step Into</strong> until a memory address is pushed onto BSP.</p>\n<p>Inspecting memory immediately after the address is pushed onto BSP shows that at this point it still contains an instruction address (not yet a string) — the address of the instruction to be called after <code class=\"language-text\">main</code> finishes.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 960px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/8df57812168816d1b3f7494929bc0953/2bef9/image-47-1024x578.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 56.25%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAARlAAAEZQAGA43XUAAACB0lEQVQoz12S65KaQBBGff/3yTtkk3+uArIoslkRBOQOw/WkZ0hlk7WqS2qgznyX3lmuz4sb8e01wo0asrzlI4pJ8oK6V3TjSDuMdDJ1q7gGN7zLO8GviFv4ILynxI8nYZSRpAU7y7IIrj5DnaN/VTnQxBVLMbNWCzT6UGaAdV05Hm32+wOn0xvOycWyHdw3jzTL6bqe3eH1wPlykdvu1E1H/uyIbzFZnDG20wbqV5DHeV5wnJOMg+9fOJ/PAj7Jv0dd14ziZnc8HgmCgPs9ZBgmilwJLCFPctq8QZU93bNlaAemacKybGzbNjDP83Bdl4sIKsoSpZQGOvLiKv6fYkncic2+GkHxOatJQxRigCdR+BVYCrDvjeXv8sFPotBlGp+U+Z0yDSTTB2OdyiSMncyQ0HcpOnNt83q9mqg0UIOLohCHgyg8/ODj3SJLpJg+pSpimuIm+aUogZlpZboHbfPYgCZD36jUeRqgKBxkE3a6sfMlIAwj2m4SyyuJFJI+CirJrpI1qstOzlux1WAdrf8y3IBvlFW1KdQ3avlheGNZ9Noo4iiiLEqWXg6GlXVe/2Q4C8zB0UCx+wn05MJqa/l1v5dQfdJUbKnRtFzd5WU6Mj/nbQfVVsqyrAZoW18VeqaUvwp9XysMZZdasrQxz1EcSwmKeVykrNmoU2owdp1/Wv4EbpZ/A82gNdfb8y55AAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/8df57812168816d1b3f7494929bc0953/8ac56/image-47-1024x578.webp 240w,\n/static/8df57812168816d1b3f7494929bc0953/d3be9/image-47-1024x578.webp 480w,\n/static/8df57812168816d1b3f7494929bc0953/e46b2/image-47-1024x578.webp 960w,\n/static/8df57812168816d1b3f7494929bc0953/a9a89/image-47-1024x578.webp 1024w\"\n              sizes=\"(max-width: 960px) 100vw, 960px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/8df57812168816d1b3f7494929bc0953/8ff5a/image-47-1024x578.png 240w,\n/static/8df57812168816d1b3f7494929bc0953/e85cb/image-47-1024x578.png 480w,\n/static/8df57812168816d1b3f7494929bc0953/d9199/image-47-1024x578.png 960w,\n/static/8df57812168816d1b3f7494929bc0953/2bef9/image-47-1024x578.png 1024w\"\n            sizes=\"(max-width: 960px) 100vw, 960px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/8df57812168816d1b3f7494929bc0953/d9199/image-47-1024x578.png\"\n            alt=\"image-47-1024x578.png\"\n            title=\"image-47-1024x578.png\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>Stepping forward several times with <strong>Step Over</strong> while comparing the Disassembly and Memory windows, it becomes clear that the stack was corrupted immediately after calling the <code class=\"language-text\">GetCppConGreetingPwy</code> function.</p>\n<p> Before stack corruption</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/1e99b97d538901f0412fcb48be81cab8/0b533/image-48.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 55.00000000000001%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAARlAAAEZQAGA43XUAAACIElEQVQoz1WTaW7bQAyFff+T9BztjwZF0Bi2tWu0WiNr3z3a7FfOJGkbAQQ5EOcjHykdPD/Cm5fh22sCM2lQ1R2uaYG0qNAOd4xixXhflHV0juIUYcTBKSfLa+RFg7JqKW5QNz0OhmkiuUYoeIjH/kQ/bvQyA89TtH2HuxAYpxFimSGfi2bgdNZg2a6KbYepOMsryhM46McTLEqIXQ8FVa/SkoyjzwuMZaV8X5QYyKa6gaETxLIQBD4s8q7rwHEcDMOAbdtwOP58wYns7fsPRLqFzL0iPGm4mQydl6ALyK7v1iYcmqbBNC14nqc8Yy5cxtC2LZZlwcGilmOeIU5SLDswjEBdDVilwie+PPIogbIzz2MENJVnzPsH1M4vYM5vBN4R21KiLTl1EmAuc6xlgaUg3xTYuxK7qGhu70ApWQI/JTdNg3VdCXj5BeYeYZuvmEVBwBuqyMfAOab0hpFkjhmHqDNsov6vQw+GaRDMpqXYqkMFNAwbUZTQlkra0oq+2zENAs8F2En2Nj+xrU/sD4q3J87nM3RDp7m5ytu2pQr8lXyhBFktikLa1B0Vze+Wc+R1jm1fv87w8cDlclEgRotQQIeA9gdwJaCcQxCGahZi3tB1ApxfkWQJxnGi7jZVeZ5n5TVNhyGBH0uR92zboXvdu2Rd1+H7PuI4hqC/oq5GNHVN8icqMKtvSyZKk1BdN9QSgiAgkK227LoMfd+rnD87SDCQKCF7DgAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/1e99b97d538901f0412fcb48be81cab8/8ac56/image-48.webp 240w,\n/static/1e99b97d538901f0412fcb48be81cab8/d3be9/image-48.webp 480w,\n/static/1e99b97d538901f0412fcb48be81cab8/b0a15/image-48.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/1e99b97d538901f0412fcb48be81cab8/8ff5a/image-48.png 240w,\n/static/1e99b97d538901f0412fcb48be81cab8/e85cb/image-48.png 480w,\n/static/1e99b97d538901f0412fcb48be81cab8/0b533/image-48.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/1e99b97d538901f0412fcb48be81cab8/0b533/image-48.png\"\n            alt=\"image-48.png\"\n            title=\"image-48.png\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p> After stack corruption</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/7e9f90fc440fcfb013fd35325207dfee/0b533/image-49.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 55.833333333333336%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAARlAAAEZQAGA43XUAAACHElEQVQoz22SaZKbMBCFff+D5CxxkrEr9gAS62AwZhMg9sXjl5bsSeVHVPWqkVB96uXtvCDEwUvx7UcEI6ogqhZRkuOaFhCyg+wnyG7UsSVdohs+wgRXupPlAmkmkBc1xQqlaLBjnCG5RuiqDHgA/XBH3dQQdUWAFuM00tlAcYJapslwOr3DdjxYjIPbLkyLI7llaGSLnXE44vzzDe7ZwM0PUUYZ8kuIJknR5QW6LEerlOboCwFmMXDGEAQBHNuG67lgtO+6Ftu2Ynf69QZ+OuO03yN2A4LluBgcmRuij0sMSYm+pKgkBEzD1FDP82ET0PM9HWUjMc8zdtz2EFJfLnGCjUruOqAtRmw91TeSnpX+XaZp6Yxcj0Ccw/efYCklJgU0zt/huUd4zgHrXECKG+Q1xCZyoBF4VCUeglST5oqApgaqkm2bw3GfJdd1jWVZFHBPsCMC/zeWuSRgChldMKUpFtKU3DDmCeY6xedSwbKeQFUqp4E6jqPPmqZ5AhmzyQoJsoyykxP92NCTTe4L8LnR4O+khzaAjoZhwDCNV2YWTdvWWSug7uH7+1n3IQh8jONMqQ9kgRhxFmNavhr4+KeHpga6/wMuBGSWRbAPuuDQCxtNa6JsUxTUu3Ecsa6rLkW9rr4tmrCpgK+hfIHVUJaVSrY0MEAcU0bTiqoaIMgeDV0YyNTbdifQ9tITyF/TVT5U9lF7SaZelhV/AGhmMLpFANVVAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/7e9f90fc440fcfb013fd35325207dfee/8ac56/image-49.webp 240w,\n/static/7e9f90fc440fcfb013fd35325207dfee/d3be9/image-49.webp 480w,\n/static/7e9f90fc440fcfb013fd35325207dfee/b0a15/image-49.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/7e9f90fc440fcfb013fd35325207dfee/8ff5a/image-49.png 240w,\n/static/7e9f90fc440fcfb013fd35325207dfee/e85cb/image-49.png 480w,\n/static/7e9f90fc440fcfb013fd35325207dfee/0b533/image-49.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/7e9f90fc440fcfb013fd35325207dfee/0b533/image-49.png\"\n            alt=\"image-49.png\"\n            title=\"image-49.png\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>This identifies the <code class=\"language-text\">GetCppConGreetingPwy</code> function as the source of the stack corruption.</p>\n<h3 id=\"debugging-the-getcppcongreetingpwy-function\" style=\"position:relative;\"><a href=\"#debugging-the-getcppcongreetingpwy-function\" aria-label=\"debugging the getcppcongreetingpwy function permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Debugging the GetCppConGreetingPwy Function</h3>\n<p>I rewound the TTD trace a little and stepped through the <code class=\"language-text\">GetCppConGreetingPwy</code> function.</p>\n<p>It turns out the stack was corrupted immediately after calling <code class=\"language-text\">wcscpy_s</code>.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 960px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/4d151361fce7650a5121ec8d9bf7f8af/2bef9/image-50-1024x575.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 56.25%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAARlAAAEZQAGA43XUAAAB6ElEQVQoz3WSbZOTMBSF+///lB+ccRx1XVelQBK6QKAtS3gpaWiB0uNNqNVdx8ycuQTIk3Nys4rjBHm+g1INus44HQ4djOkxDCPGcXolme0Q8hjP8RYyf0GaFci2pVO+U1gFvg8pJS6XCXYYM2GeL/jf4FzAW/tgjEMIAUbzIAiw3xfOyMrzPNotpt1HAgFa2zq7xdfr9ZXsECJCGIYE5ogIuMwD1HVNiQashLA7cRTFHk3T0i4G4zQ4lwvkasmLaDDGyNECtA6jaEPvQlRVhdPphNV6HdDLBLZqPRDwgizb4jmVqOqWfprQ9wNpScApqoUuQO6AnOZ3YBA8IJUe4viJFhU4mgplSY5Lhrp9hj5mOHSpq0BHoJAiMmw2G2yi6B5ZKUXAMzn88h7rz++Q/PyIHX9EGfukJzSpB52HOGQ+ujxAR1VvGULfQ8h+x43AxdIU6/B8JuCPh2/wvn7H44dPkCyGkjXSdYS9kND0fMwb6BdS2cColoDBvSkWugD9P01h9CHLcyQyxTBdYPoZlapxNiNgb8+bGyTcNfkLyBdgVd2A9to465xhmmZ07UhRO8yKSDURFKl1x+fg4hbxX+Atsj3gJEndIWtt0DY96i1FLQ1O1Rmm6EkGpuwx9pMDhfcuizdnOOAXFtczjy08/3QAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/4d151361fce7650a5121ec8d9bf7f8af/8ac56/image-50-1024x575.webp 240w,\n/static/4d151361fce7650a5121ec8d9bf7f8af/d3be9/image-50-1024x575.webp 480w,\n/static/4d151361fce7650a5121ec8d9bf7f8af/e46b2/image-50-1024x575.webp 960w,\n/static/4d151361fce7650a5121ec8d9bf7f8af/a9a89/image-50-1024x575.webp 1024w\"\n              sizes=\"(max-width: 960px) 100vw, 960px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/4d151361fce7650a5121ec8d9bf7f8af/8ff5a/image-50-1024x575.png 240w,\n/static/4d151361fce7650a5121ec8d9bf7f8af/e85cb/image-50-1024x575.png 480w,\n/static/4d151361fce7650a5121ec8d9bf7f8af/d9199/image-50-1024x575.png 960w,\n/static/4d151361fce7650a5121ec8d9bf7f8af/2bef9/image-50-1024x575.png 1024w\"\n            sizes=\"(max-width: 960px) 100vw, 960px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/4d151361fce7650a5121ec8d9bf7f8af/d9199/image-50-1024x575.png\"\n            alt=\"image-50-1024x575.png\"\n            title=\"image-50-1024x575.png\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>With that identified, let’s look at the source code:</p>\n<div class=\"gatsby-highlight\" data-language=\"cpp\"><pre class=\"language-cpp\"><code class=\"language-cpp\"><span class=\"token macro property\"><span class=\"token directive-hash\">#</span><span class=\"token directive keyword\">include</span> <span class=\"token string\">&lt;array></span></span>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#</span><span class=\"token directive keyword\">include</span> <span class=\"token string\">&lt;cstring></span> </span>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#</span><span class=\"token directive keyword\">include</span> <span class=\"token string\">&lt;stdio.h></span></span>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#</span><span class=\"token directive keyword\">include</span> <span class=\"token string\">&lt;string.h></span></span>\n\n<span class=\"token keyword\">void</span> <span class=\"token function\">GetCppConGreeting</span><span class=\"token punctuation\">(</span><span class=\"token keyword\">wchar_t</span> <span class=\"token operator\">*</span>buffer<span class=\"token punctuation\">,</span> size_t size<span class=\"token punctuation\">)</span>\n<span class=\"token punctuation\">{</span>\n    <span class=\"token keyword\">wchar_t</span> <span class=\"token keyword\">const</span> <span class=\"token operator\">*</span><span class=\"token keyword\">const</span> message <span class=\"token operator\">=</span> L<span class=\"token string\">\"HELLO FROM THE WINDBG TEAM. GOOD LUCK IN ALL OF YOUR TIME TRAVEL DEBUGGING!\"</span><span class=\"token punctuation\">;</span>\n\n    <span class=\"token function\">wcscpy_s</span><span class=\"token punctuation\">(</span>buffer<span class=\"token punctuation\">,</span> size<span class=\"token punctuation\">,</span> message<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span>\n\n<span class=\"token keyword\">int</span> <span class=\"token function\">main</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span>\n<span class=\"token punctuation\">{</span>\n    std<span class=\"token double-colon punctuation\">::</span>array<span class=\"token operator\">&lt;</span><span class=\"token keyword\">wchar_t</span><span class=\"token punctuation\">,</span> <span class=\"token number\">50</span><span class=\"token operator\">></span> greeting<span class=\"token punctuation\">{</span><span class=\"token punctuation\">}</span><span class=\"token punctuation\">;</span>\n    <span class=\"token function\">GetCppConGreeting</span><span class=\"token punctuation\">(</span>greeting<span class=\"token punctuation\">.</span><span class=\"token function\">data</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span> <span class=\"token keyword\">sizeof</span><span class=\"token punctuation\">(</span>greeting<span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n    <span class=\"token function\">wprintf</span><span class=\"token punctuation\">(</span>L<span class=\"token string\">\"%ls\\n\"</span><span class=\"token punctuation\">,</span> greeting<span class=\"token punctuation\">.</span><span class=\"token function\">data</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n    <span class=\"token keyword\">return</span> <span class=\"token number\">0</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<p>It appears the <code class=\"language-text\">greeting</code> array was allocated for only 50 wide characters, but a 75-character <code class=\"language-text\">message</code> was written into it, causing a stack overflow.</p>\n<p>I fixed this by increasing the array element count to 75 in <code class=\"language-text\">ttd_tutorial_fixed.cpp</code> and rebuilding as <code class=\"language-text\">ttd_tutorial_fixed.exe</code>.</p>\n<p>The error was resolved and the program ran successfully!</p>\n<div class=\"gatsby-highlight\" data-language=\"powershell\"><pre class=\"language-powershell\"><code class=\"language-powershell\">$ ttd_tutorial_fixed<span class=\"token punctuation\">.</span>exe\nHELLO <span class=\"token keyword\">FROM</span> THE WINDBG TEAM<span class=\"token punctuation\">.</span> GOOD LUCK IN ALL OF YOUR TIME TRAVEL DEBUGGING!</code></pre></div>\n<h2 id=\"wrap-up\" style=\"position:relative;\"><a href=\"#wrap-up\" aria-label=\"wrap up permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Wrap-up</h2>\n<p>I tried out TTD-based debugging, which lets you trace execution both forward and backward in time.</p>\n<p>Being able to see the memory and register state from the past — which is not possible with memory dumps or process dumps alone — made the analysis significantly smoother.</p>\n<p>Also, unlike live debugging, the ability to step backward through execution eliminates the tedious cycle of “set a breakpoint, reproduce the problem, and start over,” which is very convenient.</p>\n<p>I plan to continue documenting debugging techniques that take advantage of TTD.</p>\n<p>For other articles on Windows debugging and dump analysis with WinDbg, see the list on the following page:</p>\n<p>Reference: <a href=\"/windows-windbg-001-index-en\">Debugging and Troubleshooting Techniques with WinDbg</a></p>","fields":{"slug":"/windows-windbg-008-time-travel-debugging-en","tagSlugs":["/tag/win-dbg-en/","/tag/kernel-en/","/tag/reversing-en/","/tag/english/"]},"frontmatter":{"date":"2021-10-18","description":"","tags":["WinDbg (en)","Kernel (en)","Reversing (en)","English"],"title":"[WinDbg Preview] A New Debugging Approach with Time Travel Debugging","socialImage":{"publicURL":"/static/f6765d3ca61ba0f6df1a4575ba7c225a/windows-windbg-008-time-travel-debugging.png"}}}},"pageContext":{"slug":"/windows-windbg-008-time-travel-debugging-en"}},"staticQueryHashes":["251939775","401334301","825871152"]}