<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>汉客儿安全笔记</title>
    <link>https://wechat2rss.xlab.app/feed/71f7fe130360b40edf3b22e222ca2a147912893d.xml</link>
    <description>操作系统、漏洞、逆向破解技术分享，欢迎关注交流&#xA;(wechat feed made by @ttttmr https://wechat2rss.xlab.app)</description>
    <managingEditor> (汉客儿安全笔记)</managingEditor>
    <image>
      <url>https://wx.qlogo.cn/mmhead/Q3auHgzwzM5JB2YVbYBYvpxnMhmH4HE6Z6pWNuuAnBsXo9ic1nTULYg/0</url>
      <title>汉客儿安全笔记</title>
      <link>https://wechat2rss.xlab.app/feed/71f7fe130360b40edf3b22e222ca2a147912893d.xml</link>
    </image>
    <item>
      <title>vs2005无法启动分析笔记</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzU4NjY5ODM3Nw==&amp;mid=2247483832&amp;idx=1&amp;sn=b5e983ba6ba951b580fdd6cf7d44373e</link>
      <description>老古董修修还是能用的！</description>
      <content:encoded><![CDATA[<p>
原创 <span>Anhkgg</span> <span>2022-03-19 16:12</span> <span style="display: inline-block;"></span>
</p>

<p>老古董修修还是能用的！</p>
<p></p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=46cfc855&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FqukewnktvYzPWtncxfC0RomEMGiae8HX5iaq2kCictoKjkD90PmQwp4kGtaQBkt0onMfkia66ibsTtub3lyViaI2juDQ%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<p data-line="1" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">由于工作需要，还在用<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">vs2005</code>这个老古董，虽然很不喜欢。</p><p data-line="3" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">虽然很轻，但有两个原因不喜欢：</p><ol data-line="5" class="list-paddingleft-1" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;"><li><p>调试总要加载符号，不让加非加，慢的无语</p></li><li><p>时不时总是无缘无故无法启动</p></li></ol><p data-line="8" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">无法启动这个事已经无数次出现了，重装，重启，屏蔽Assist均是无效。</p><p data-line="10" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">后来无意间点击了<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE\devenv.com</code>，可以启动了。</p><p data-line="12" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">但这次这个方法也不行了，实在是忍无可忍。</p><p data-line="14" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">决定干它。</p><p data-line="16" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">上调试器，启动<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">devenv.exe</code>。</p><p data-line="18" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">看到崩溃原因 <code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">c00000fd</code>，就是栈溢出，看来应该是函数调用无限循环了。</p><p data-line="20" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">不要问我为啥知道，因为之前遇到过。</p><p data-line="22" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">看看栈，果然如此，<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">user32-&gt;msdev!xxx-&gt;user32-&gt;msdev!xxx-&gt;...</code></p><section class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul><pre class="code-snippet__js" data-lang="properties"><code><span class="code-snippet_outer"><span class="code-snippet__attr">0</span>:<span class="code-snippet__string">000:x86&gt; kn 10</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__comment"> # ChildEBP RetAddr  </span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">00</span> <span class="code-snippet__string">000a3048 76cb9cae ntdll_77660000!RtlActivateActivationContextUnsafeFast+0x18</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">01</span> <span class="code-snippet__string">000a3118 76cb9577 USER32!UserCallWinProcCheckWow+0x14e</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">02</span> <span class="code-snippet__string">000a3150 76cb771b USER32!CallWindowProcAorW+0x7f</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">03</span> <span class="code-snippet__string">000a3168 059dea67 USER32!CallWindowProcW+0x1b //5007ea67</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">04</span> <span class="code-snippet__string">000a3188 059dea34 msenv!CAutoCompletionManagerCL::TargetSubclassProc+0x29</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">05</span> <span class="code-snippet__string">000a31a4 76cc2edb msenv!CAutoCompletionManagerCL::TargetSubclassProcSTATIC+0x2a</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">06</span> <span class="code-snippet__string">000a31d0 76cb9e9a USER32!_InternalCallWinProc+0x2b</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">07</span> <span class="code-snippet__string">000a32b4 76cb9577 USER32!UserCallWinProcCheckWow+0x33a</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">08</span> <span class="code-snippet__string">000a32ec 76cb771b USER32!CallWindowProcAorW+0x7f</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">09</span> <span class="code-snippet__string">000a3304 059dea67 USER32!CallWindowProcW+0x1b</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">0a</span> <span class="code-snippet__string">000a3324 059dea34 msenv!CAutoCompletionManagerCL::TargetSubclassProc+0x29</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">0b</span> <span class="code-snippet__string">000a3340 76cc2edb msenv!CAutoCompletionManagerCL::TargetSubclassProcSTATIC+0x2a</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">0c</span> <span class="code-snippet__string">000a336c 76cb9e9a USER32!_InternalCallWinProc+0x2b</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">0d</span> <span class="code-snippet__string">000a3450 76cb9577 USER32!UserCallWinProcCheckWow+0x33a</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">0e</span> <span class="code-snippet__string">000a3488 76cb771b USER32!CallWindowProcAorW+0x7f</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">0f</span> <span class="code-snippet__string">000a34a0 059dea67 USER32!CallWindowProcW+0x1b</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">...</span></span></code></pre></section><p data-line="46" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;"><br/></p><p data-line="46" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">打开<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">IDA</code>，简单看看<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">msdev</code>。</p><p data-line="46" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;"><br/></p><section class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul><pre class="code-snippet__js" data-lang="objectivec"><code><span class="code-snippet_outer"><span class="code-snippet__keyword">int</span> __userpurge <span class="code-snippet__built_in">CAutoCompletionManagerCL</span>::TargetSubclassProcSTATIC@&lt;eax&gt;(<span class="code-snippet__keyword">int</span> a1@&lt;esi&gt;, HWND a2, <span class="code-snippet__keyword">unsigned</span> <span class="code-snippet__keyword">int</span> a3, <span class="code-snippet__keyword">unsigned</span> <span class="code-snippet__keyword">int</span> a4, <span class="code-snippet__keyword">unsigned</span> <span class="code-snippet__keyword">int</span> a5)</span></code><code><span class="code-snippet_outer">{</span></code><code><span class="code-snippet_outer">  <span class="code-snippet__built_in">CAutoCompletionManagerCL</span> *v5; <span class="code-snippet__comment">// ecx</span></span></code><code><span class="code-snippet_outer">  <span class="code-snippet__keyword">int</span> result; <span class="code-snippet__comment">// eax</span></span></code><code><span class="code-snippet_outer"><br/></span></code><code><span class="code-snippet_outer">  <span class="code-snippet__keyword">if</span> ( GetPropW(a2, L<span class="code-snippet__string">&#34;MSENV_ACMgr&#34;</span>) )</span></code><code><span class="code-snippet_outer">    result = <span class="code-snippet__built_in">CAutoCompletionManagerCL</span>::TargetSubclassProc(v5, a2, a4, a5, a1);</span></code><code><span class="code-snippet_outer">  <span class="code-snippet__keyword">else</span></span></code><code><span class="code-snippet_outer">    result = DefWindowProcAW(a2, a3, a4, a5);</span></code><code><span class="code-snippet_outer">  <span class="code-snippet__keyword">return</span> result;</span></code><code><span class="code-snippet_outer">}</span></code><code><span class="code-snippet_outer"><br/></span></code><code><span class="code-snippet_outer">text:<span class="code-snippet__number">5007</span>EA3A <span class="code-snippet__number">000</span>                 push    ebp</span></code><code><span class="code-snippet_outer">.text:<span class="code-snippet__number">5007</span>EA3B <span class="code-snippet__number">004</span>                 mov     ebp, esp</span></code><code><span class="code-snippet_outer">.text:<span class="code-snippet__number">5007</span>EA3D <span class="code-snippet__number">004</span>                 cmp     ebx, <span class="code-snippet__number">0</span>Eh</span></code><code><span class="code-snippet_outer">.text:<span class="code-snippet__number">5007</span>EA40 <span class="code-snippet__number">004</span>                 push    edi</span></code><code><span class="code-snippet_outer">.text:<span class="code-snippet__number">5007</span>EA41 <span class="code-snippet__number">008</span>                 jnz     loc_500FEDCF</span></code><code><span class="code-snippet_outer">.text:<span class="code-snippet__number">5007</span>EA47 <span class="code-snippet__number">008</span>                 mov     dword ptr [esi+<span class="code-snippet__number">34</span>h], <span class="code-snippet__number">1</span></span></code><code><span class="code-snippet_outer">.text:<span class="code-snippet__number">5007</span>EA4E</span></code><code><span class="code-snippet_outer">.text:<span class="code-snippet__number">5007</span>EA4E     loc_5007EA4E:                           ; CODE XREF: <span class="code-snippet__built_in">CAutoCompletionManagerCL</span>::TargetSubclassProc(HWND__ *,uint,uint,<span class="code-snippet__keyword">long</span>)+<span class="code-snippet__number">803</span>C6↓j</span></code><code><span class="code-snippet_outer">.text:<span class="code-snippet__number">5007</span>EA4E                                             ; <span class="code-snippet__built_in">CAutoCompletionManagerCL</span>::TargetSubclassProc(HWND__ *,uint,uint,<span class="code-snippet__keyword">long</span>)+<span class="code-snippet__number">17</span>B9CA↓j ...</span></code><code><span class="code-snippet_outer">.text:<span class="code-snippet__number">5007</span>EA4E <span class="code-snippet__number">008</span>                 mov     eax, [esi+<span class="code-snippet__number">30</span>h] <span class="code-snippet__comment">//=0 不会再调用CallWindowProcAW</span></span></code><code><span class="code-snippet_outer">.text:<span class="code-snippet__number">5007</span>EA51 <span class="code-snippet__number">008</span>                 xor     edi, edi</span></code><code><span class="code-snippet_outer">.text:<span class="code-snippet__number">5007</span>EA53 <span class="code-snippet__number">008</span>                 test    eax, eax</span></code><code><span class="code-snippet_outer">.text:<span class="code-snippet__number">5007</span>EA55 <span class="code-snippet__number">008</span>                 jz      <span class="code-snippet__keyword">short</span> loc_5007EA69</span></code><code><span class="code-snippet_outer">.text:<span class="code-snippet__number">5007</span>EA57 <span class="code-snippet__number">008</span>                 push    [ebp+arg_8]</span></code><code><span class="code-snippet_outer">.text:<span class="code-snippet__number">5007</span>EA5A <span class="code-snippet__number">00</span>C                 push    [ebp+arg_4]</span></code><code><span class="code-snippet_outer">.text:<span class="code-snippet__number">5007</span>EA5D <span class="code-snippet__number">010</span>                 push    ebx</span></code><code><span class="code-snippet_outer">.text:<span class="code-snippet__number">5007</span>EA5E <span class="code-snippet__number">014</span>                 push    [ebp+arg_0]</span></code><code><span class="code-snippet_outer">.text:<span class="code-snippet__number">5007</span>EA61 <span class="code-snippet__number">018</span>                 push    eax <span class="code-snippet__comment">//调用原始函数</span></span></code><code><span class="code-snippet_outer">.text:<span class="code-snippet__number">5007</span>EA62 <span class="code-snippet__number">01</span>C                 call    ?CallWindowProcAW@@YGJP6GJPAUHWND__@@IIJ@Z0IIJ@Z ; CallWindowProcAW(<span class="code-snippet__keyword">long</span> (*)(HWND__ *,uint,uint,<span class="code-snippet__keyword">long</span>),HWND__ *,uint,uint,<span class="code-snippet__keyword">long</span>)</span></code><code><span class="code-snippet_outer">.text:<span class="code-snippet__number">5007</span>EA67 <span class="code-snippet__number">008</span>                 mov     edi, eax</span></code><code><span class="code-snippet_outer">.text:<span class="code-snippet__number">5007</span>EA69</span></code><code><span class="code-snippet_outer">.text:<span class="code-snippet__number">5007</span>EA69     loc_5007EA69:                           ; CODE XREF: <span class="code-snippet__built_in">CAutoCompletionManagerCL</span>::TargetSubclassProc(HWND__ *,uint,uint,<span class="code-snippet__keyword">long</span>)+<span class="code-snippet__number">1</span>B↑j</span></code><code><span class="code-snippet_outer">.text:<span class="code-snippet__number">5007</span>EA69 <span class="code-snippet__number">008</span>                 cmp     ebx, <span class="code-snippet__number">82</span>h</span></code><code><span class="code-snippet_outer">.text:<span class="code-snippet__number">5007</span>EA6F <span class="code-snippet__number">008</span>                 jz      loc_501B3877</span></code><code><span class="code-snippet_outer">.text:<span class="code-snippet__number">5007</span>EA75</span></code></pre></section><pre><br/></pre><p data-line="88" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;"><code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">CAutoCompletionManagerCL::TargetSubclassProcSTATIC</code>应该是个<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">wndproc</code>，本来逻辑应该是在内部<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">CallWindowProcAW</code>调用原始<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">wndproc</code>，但是<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">CallWindowProcAW</code>又调用了<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">CAutoCompletionManagerCL::TargetSubclassProcSTATIC</code>，这样死循环，一直到栈移除。</p><p data-line="90" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">看看<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">CAutoCompletionManagerCL::TargetSubclassProcSTATIC</code>是哪里设置的，找到了：</p><section class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul><pre class="code-snippet__js" data-lang="objectivec"><code><span class="code-snippet_outer"><span class="code-snippet__keyword">int</span> __userpurge <span class="code-snippet__built_in">CAutoCompletionManagerCL</span>::AttachToCombo@&lt;eax&gt;(<span class="code-snippet__built_in">CAutoCompletionManagerCL</span> *<span class="code-snippet__keyword">this</span>@&lt;ecx&gt;, <span class="code-snippet__keyword">int</span> a2@&lt;eax&gt;, <span class="code-snippet__keyword">struct</span> IMsoControl *a3, HWND a4)</span></code><code><span class="code-snippet_outer">{</span></code><code><span class="code-snippet_outer">  result = <span class="code-snippet__built_in">CAutoCompletionManager</span>::OnCreate(<span class="code-snippet__keyword">this</span>); <span class="code-snippet__comment">//创建控件</span></span></code><code><span class="code-snippet_outer">  <span class="code-snippet__keyword">if</span> ( result &gt;= <span class="code-snippet__number">0</span> &amp;&amp; !result )</span></code><code><span class="code-snippet_outer">  {</span></code><code><span class="code-snippet_outer">   </span></code><code><span class="code-snippet_outer">    v11 = (HWND)*((_DWORD *)<span class="code-snippet__keyword">this</span> + <span class="code-snippet__number">10</span>);</span></code><code><span class="code-snippet_outer">    <span class="code-snippet__keyword">if</span> ( v6 )</span></code><code><span class="code-snippet_outer">      v7 = SetWindowLongW(v11, <span class="code-snippet__number">-4</span>, (LONG)<span class="code-snippet__built_in">CAutoCompletionManagerCL</span>::TargetSubclassProcSTATIC);</span></code><code><span class="code-snippet_outer">    <span class="code-snippet__keyword">else</span></span></code><code><span class="code-snippet_outer">      v7 = SetWindowLongA(v11, <span class="code-snippet__number">-4</span>, (LONG)<span class="code-snippet__built_in">CAutoCompletionManagerCL</span>::TargetSubclassProcSTATIC);</span></code><code><span class="code-snippet_outer">    v13 = (HWND)*((_DWORD *)<span class="code-snippet__keyword">this</span> + <span class="code-snippet__number">10</span>);</span></code><code><span class="code-snippet_outer">    *((_DWORD *)<span class="code-snippet__keyword">this</span> + <span class="code-snippet__number">12</span>) = v7; <span class="code-snippet__comment">//+30 = 1</span></span></code></pre></section><pre>   <br/></pre><p data-line="109" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">所以问题应该基本清晰了，<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">SetWindowLongW(v11, -4, (LONG)CAutoCompletionManagerCL::TargetSubclassProcSTATIC);</code>被重复设置了，<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">*((_DWORD *)this + 12) = v7</code>，保存的值被覆盖成了<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">CAutoCompletionManagerCL::TargetSubclassProcSTATIC</code></p><p data-line="111" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">所以这样死循环，导致调用栈溢出</p><p data-line="113" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">第一次进入<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">msenv!CAutoCompletionManagerCL::AttachToCombo</code>设置<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">SetWindowLongW</code>返回就已经是<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">msenv!CAutoCompletionManagerCL::TargetSubclassProcSTATIC</code></p><p data-line="115" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">赋值之前看到原始地址：</p><section class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"><li></li><li></li></ul><pre class="code-snippet__js" data-lang="cpp"><code><span class="code-snippet_outer">msenv!CAutoCompletionManagerCL::AttachToCombo+<span class="code-snippet__number">0x60</span>:</span></code><code><span class="code-snippet_outer"><span class="code-snippet__number">05910</span>cb5 <span class="code-snippet__number">894330</span>          mov     dword ptr [ebx+<span class="code-snippet__number">30</span>h],eax ds:<span class="code-snippet__number">002b</span>:<span class="code-snippet__number">06e03228</span>={msenv!_FakeEditProc (<span class="code-snippet__number">0596</span>eab8)}</span></code></pre></section><pre><br/></pre><p data-line="122" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">猜测<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">CAutoCompletionManager::OnCreate</code>中就已经调用<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">SetWindowLongW了</code>。</p><p data-line="124" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">尝试使用条件断点看看能不能找到。</p><section class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"><li></li><li></li><li></li><li></li><li></li></ul><pre class="code-snippet__js" data-lang="ruby"><code><span class="code-snippet_outer"><span class="code-snippet__number">0</span><span class="code-snippet__symbol">:</span><span class="code-snippet__number">000</span><span class="code-snippet__symbol">:x86&gt;</span> u CAutoCompletionManagerCL::TargetSubclassProcSTATIC</span></code><code><span class="code-snippet_outer">msenv!CAutoCompletionManagerCL::<span class="code-snippet__symbol">TargetSubclassProcSTATIC:</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__number">05</span>aeea06 <span class="code-snippet__number">55</span>              push    ebp</span></code><code><span class="code-snippet_outer"><span class="code-snippet__number">0</span><span class="code-snippet__symbol">:</span><span class="code-snippet__number">000</span><span class="code-snippet__symbol">:x86&gt;</span> bc <span class="code-snippet__number">1</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__number">0</span><span class="code-snippet__symbol">:</span><span class="code-snippet__number">000</span><span class="code-snippet__symbol">:x86&gt;</span> bp USER32!SetWindowLongW <span class="code-snippet__string">&#34;.if(poi(esp+c)==05aeea06 ){}.else{g};&#34;</span></span></code></pre></section><pre><br/></pre><p data-line="135" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">断下后，确认函数没问题，看看调用栈。</p><p data-line="137" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">可以看到<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">msenv!CAutoCompletionManagerCL::VerifyAttachment</code>在<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">OnCreate</code>内部设置了一次。</p><section class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul><pre class="code-snippet__js" data-lang="properties"><code><span class="code-snippet_outer"><span class="code-snippet__meta">USER32!SetWindowLongW</span>:<span class="code-snippet__string"></span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">76cb7730</span> <span class="code-snippet__string">8bff            mov     edi,edi</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">0</span>:<span class="code-snippet__string">000:x86&gt; dd esp</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">00194a2c</span>  <span class="code-snippet__string">05c6a3cc 00093096 fffffffc 05aeea06</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">00194a3c</span>  <span class="code-snippet__string">07747120 00000000 05aeec46 00000000</span></span></code><code><span class="code-snippet_outer"><br/></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">0</span>:<span class="code-snippet__string">000:x86&gt; kn</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__comment"> # ChildEBP RetAddr  </span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">00</span> <span class="code-snippet__string">00194a28 05c6a3cc USER32!SetWindowLongW</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">01</span> <span class="code-snippet__string">00194a40 05aeec46 msenv!CAutoCompletionManagerCL::VerifyAttachment+0x69</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">02</span> <span class="code-snippet__string">00194a50 05aee7ca msenv!CAutoCompletionManagerCL::VerifyAllAttachments+0x31</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">03</span> <span class="code-snippet__string">00194a70 05ae2021 msenv!CAutoCompletionManagerCL::UseAutocompletion+0x3f</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">04</span> <span class="code-snippet__string">00194abc 05ae1ceb msenv!CMsoDropdownUser::GetText+0x12f</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">...</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">18</span> <span class="code-snippet__string">001961b0 76cc2edb msenv!TBWndWindowProc+0x65</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">19</span> <span class="code-snippet__string">001961dc 76cb9e9a USER32!_InternalCallWinProc+0x2b</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">1a</span> <span class="code-snippet__string">001962c0 76cb9a9a USER32!UserCallWinProcCheckWow+0x33a</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">...</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">49</span> <span class="code-snippet__string">00198424 05a90d54 msenv!CVsAutoCompletion::InitUI+0x251</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">4a</span> <span class="code-snippet__string">00198440 05a90c6b msenv!CAutoCompletionManager::OnCreate+0x58 //这里是创建</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">4b</span> <span class="code-snippet__string">00198448 05a90ae1 msenv!CAutoCompletionManagerCL::AttachToCombo+0x12</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">4c</span> <span class="code-snippet__string">00198468 05ae2021 msenv!CAutoCompletionManagerCL::UseAutocompletion+0x95 </span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">4d</span> <span class="code-snippet__string">001984b0 05a90a72 msenv!CMsoDropdownUser::GetText+0x12f</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">4e</span> <span class="code-snippet__string">001984c8 05a9096b msenv!TBCDD::ResetEditText+0x12</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">4f</span> <span class="code-snippet__string">0019c6d8 05b018aa msenv!TBCDD::FDraw+0x684</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">50</span> <span class="code-snippet__string">0019c84c 05b013cc msenv!TB::FDraw+0xbb7</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">51</span> <span class="code-snippet__string">0019c8c8 76cc2edb msenv!TBWndProc+0xfa</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">52</span> <span class="code-snippet__string">0019c8f4 76cb9e9a USER32!_InternalCallWinProc+0x2b</span></span></code><code><span class="code-snippet_outer"><br/></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">int</span> <span class="code-snippet__string">__usercall CAutoCompletionManagerCL::VerifyAttachment@&lt;eax&gt;(int a1@&lt;esi&gt;)</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">{</span></span></code><code><span class="code-snippet_outer"><br/></span></code><code><span class="code-snippet_outer">      <span class="code-snippet__attr">v7</span> = <span class="code-snippet__string">*(HWND *)(a1 + 40);</span></span></code><code><span class="code-snippet_outer">      <span class="code-snippet__attr">if</span> <span class="code-snippet__string">( v4 )</span></span></code><code><span class="code-snippet_outer">        <span class="code-snippet__attr">v5</span> = <span class="code-snippet__string">SetWindowLongW(v7, -4, (LONG)CAutoCompletionManagerCL::TargetSubclassProcSTATIC);</span></span></code><code><span class="code-snippet_outer">      <span class="code-snippet__attr">else</span></span></code><code><span class="code-snippet_outer">        <span class="code-snippet__attr">v5</span> = <span class="code-snippet__string">SetWindowLongA(v7, -4, (LONG)CAutoCompletionManagerCL::TargetSubclassProcSTATIC);</span></span></code><code><span class="code-snippet_outer">      <span class="code-snippet__meta">*(_DWORD</span> <span class="code-snippet__string">*)(a1 + 48) = v5;</span></span></code><code><span class="code-snippet_outer">    <span class="code-snippet__attr">}</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">}</span></span></code></pre></section><pre><br/></pre><p data-line="182" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">所以应该是<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">msevn</code>逻辑出现了问题，应该加上控件创建成功后，才能<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">SetWindowsLong</code>，或者直接在<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">SetWindowLong</code>之前判断是否已经设置过。</p><p data-line="184" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">我可以给他改改代码，但是挺麻烦的。</p><p data-line="186" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">再看看是不是有什么可以控制的条件，有更简单的修改方法。</p><p data-line="188" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">看看<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">CAutoCompletionManagerCL::AttachToCombo</code>被谁调用了：</p><section class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul><pre class="code-snippet__js" data-lang="properties"><code><span class="code-snippet_outer"><span class="code-snippet__attr">Breakpoint</span> <span class="code-snippet__string">0 hit</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__meta">msenv!CAutoCompletionManagerCL</span>:<span class="code-snippet__string">:AttachToCombo:</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">03a10c59</span> <span class="code-snippet__string">53              push    ebx</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">0</span>:<span class="code-snippet__string">000:x86&gt; kn</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__comment"> # ChildEBP RetAddr  </span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">00</span> <span class="code-snippet__string">00198448 03a10ae1 msenv!CAutoCompletionManagerCL::AttachToCombo</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">01</span> <span class="code-snippet__string">00198468 03a62021 msenv!CAutoCompletionManagerCL::UseAutocompletion+0x95</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">02</span> <span class="code-snippet__string">001984b0 03a10a72 msenv!CMsoDropdownUser::GetText+0x12f</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">03</span> <span class="code-snippet__string">001984c8 03a1096b msenv!TBCDD::ResetEditText+0x12</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">04</span> <span class="code-snippet__string">0019c6d8 03a818aa msenv!TBCDD::FDraw+0x684</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">05</span> <span class="code-snippet__string">0019c84c 03a813cc msenv!TB::FDraw+0xbb7</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">06</span> <span class="code-snippet__string">0019c8c8 76cc2edb msenv!TBWndProc+0xfa</span></span></code></pre></section><pre><br/></pre><p data-line="205" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">看看<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">CAutoCompletionManagerCL::UseAutocompletion</code>的逻辑：</p><section class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul><pre class="code-snippet__js" data-lang="objectivec"><code><span class="code-snippet_outer"><span class="code-snippet__keyword">int</span> __userpurge <span class="code-snippet__built_in">CAutoCompletionManagerCL</span>::UseAutocompletion@&lt;eax&gt;(CVSShellMenu *a1@&lt;ecx&gt;, <span class="code-snippet__keyword">struct</span> IMsoControl *a2@&lt;edi&gt;, <span class="code-snippet__keyword">struct</span> IMsoControl *a3)</span></code><code><span class="code-snippet_outer">{</span></code><code><span class="code-snippet_outer">  v6 = <span class="code-snippet__number">0</span>;</span></code><code><span class="code-snippet_outer">  <span class="code-snippet__keyword">if</span> ( !<span class="code-snippet__built_in">CAutoCompletionManagerCL</span>::ms_picLastUsed )</span></code><code><span class="code-snippet_outer">    <span class="code-snippet__built_in">CAutoCompletionManagerCL</span>::ms_picLastUsed = a3;</span></code><code><span class="code-snippet_outer">  <span class="code-snippet__keyword">if</span> ( CCmdWindow::ms_fEnableAutocompletion ) <span class="code-snippet__comment">//这个状态为0，应该就不会出现了</span></span></code><code><span class="code-snippet_outer">  {</span></code><code><span class="code-snippet_outer">    v7 = CVSShellMenu::GetHwndByPic(a1, a2);</span></code><code><span class="code-snippet_outer">    v10 = (<span class="code-snippet__keyword">struct</span> IMsoControl *)v7;</span></code><code><span class="code-snippet_outer">    <span class="code-snippet__keyword">if</span> ( !v7 )</span></code><code><span class="code-snippet_outer">      <span class="code-snippet__keyword">return</span> <span class="code-snippet__number">1</span>;</span></code><code><span class="code-snippet_outer">    <span class="code-snippet__built_in">CAutoCompletionManagerCL</span>::VerifyAllAttachments(a3); <span class="code-snippet__comment">//重复设置的点</span></span></code><code><span class="code-snippet_outer">    <span class="code-snippet__keyword">if</span> ( <span class="code-snippet__built_in">CAutoCompletionManagerCL</span>::GetManager(a3, v7) )</span></code><code><span class="code-snippet_outer">      <span class="code-snippet__keyword">return</span> v6;</span></code><code><span class="code-snippet_outer">    <span class="code-snippet__keyword">if</span> ( <span class="code-snippet__built_in">CAutoCompletionManagerCL</span>::GetManagerByTargetHwnd(v7) )</span></code><code><span class="code-snippet_outer">      <span class="code-snippet__keyword">return</span> <span class="code-snippet__number">1</span>;</span></code><code><span class="code-snippet_outer">    v6 = ATL::CComObject&lt;<span class="code-snippet__built_in">CAutoCompletionManagerCL</span>&gt;::CreateInstance(&amp;hData);</span></code><code><span class="code-snippet_outer">    <span class="code-snippet__keyword">if</span> ( v6 &gt;= <span class="code-snippet__number">0</span> )</span></code><code><span class="code-snippet_outer">    {</span></code><code><span class="code-snippet_outer">      x = hData;</span></code><code><span class="code-snippet_outer">      (*(<span class="code-snippet__keyword">void</span> (__stdcall **)(HANDLE))(*(_DWORD *)hData + <span class="code-snippet__number">4</span>))(hData);</span></code><code><span class="code-snippet_outer">      v4 = dword_5074D4FC;</span></code><code><span class="code-snippet_outer">      <span class="code-snippet__keyword">if</span> ( safe::CEnvArray&lt;<span class="code-snippet__built_in">CAutoCompletionManagerCL</span> *,<span class="code-snippet__built_in">CAutoCompletionManagerCL</span> *&gt;::SetSize() )</span></code><code><span class="code-snippet_outer">      {</span></code><code><span class="code-snippet_outer">        *((_DWORD *)<span class="code-snippet__built_in">CAutoCompletionManagerCL</span>::ms_rgManagers + v4) = x;</span></code><code><span class="code-snippet_outer">        v6 = <span class="code-snippet__built_in">CAutoCompletionManagerCL</span>::AttachToCombo(x, (<span class="code-snippet__keyword">int</span>)a3, v10, v9); <span class="code-snippet__comment">//初始化</span></span></code><code><span class="code-snippet_outer">        <span class="code-snippet__keyword">if</span> ( v6 )</span></code><code><span class="code-snippet_outer">          <span class="code-snippet__built_in">CAutoCompletionManagerCL</span>::OnDestroy(v5);</span></code><code><span class="code-snippet_outer">      }</span></code><code><span class="code-snippet_outer">      <span class="code-snippet__keyword">else</span></span></code><code><span class="code-snippet_outer">      {</span></code><code><span class="code-snippet_outer">        v6 = <span class="code-snippet__number">-2147024882</span>;</span></code><code><span class="code-snippet_outer">      }</span></code><code><span class="code-snippet_outer">    }</span></code><code><span class="code-snippet_outer">  }</span></code><code><span class="code-snippet_outer">  <span class="code-snippet__keyword">return</span> v6;</span></code><code><span class="code-snippet_outer">}</span></code></pre></section><pre><br/></pre><p data-line="247" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">猜测跟代码自动完成有关，这个<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">CCmdWindow::ms_fEnableAutocompletion</code>变量好像可以弄弄，如果设置为假，就完全不会进入后面的逻辑。</p><p data-line="249" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">现在看看<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">CCmdWindow::ms_fEnableAutocompletion</code>在哪里设置的。</p><section class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul><pre class="code-snippet__js" data-lang="cpp"><code><span class="code-snippet_outer"><span class="code-snippet__keyword">void</span> __<span class="code-snippet__function">stdcall <span class="code-snippet__title">PrefInitPart2</span><span class="code-snippet__params">()</span></span></span></code><code><span class="code-snippet_outer">{</span></code><code><span class="code-snippet_outer">   <span class="code-snippet__keyword">if</span> ( GetUserOption(<span class="code-snippet__number">0</span>, <span class="code-snippet__string">L&#34;CommandWindowAutocompletion&#34;</span>, Data, <span class="code-snippet__number">4u</span>, (<span class="code-snippet__keyword">unsigned</span> <span class="code-snippet__keyword">int</span>)v72) &lt; <span class="code-snippet__number">0</span> )</span></code><code><span class="code-snippet_outer">    *(_DWORD *)Data = <span class="code-snippet__number">1</span>; <span class="code-snippet__comment">//没配置默认为1</span></span></code><code><span class="code-snippet_outer">  v32 = <span class="code-snippet__number">0</span>;</span></code><code><span class="code-snippet_outer">  hKey = *(HKEY *)Data;</span></code><code><span class="code-snippet_outer">  CCmdWindow::ms_fEnableAutocompletion = *(_DWORD *)Data; <span class="code-snippet__comment">//设置状态</span></span></code></pre></section><pre><br/></pre><p data-line="261" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">好像有戏，<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">CommandWindowAutocompletion</code>是用户配置相关的。<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">CommandWindowAutocompletion</code>未配置默认开启<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">ms_fEnableAutocompletion</code>。</p><section class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul><pre class="code-snippet__js" data-lang="properties"><code><span class="code-snippet_outer"><span class="code-snippet__attr">int</span> <span class="code-snippet__string">__userpurge GetUserOption@&lt;eax&gt;(int a1@&lt;eax&gt;, LPCWSTR lpValueName, LPBYTE lpData, DWORD cbData, unsigned int a5)</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">{</span></span></code><code><span class="code-snippet_outer"><br/></span></code><code><span class="code-snippet_outer">  <span class="code-snippet__attr">hKey</span> = <span class="code-snippet__string">0;</span></span></code><code><span class="code-snippet_outer">  <span class="code-snippet__attr">if</span> <span class="code-snippet__string">( a1 )</span></span></code><code><span class="code-snippet_outer">    <span class="code-snippet__attr">VBRegOpenTwoKeysFromRoot(</span></span></code><code><span class="code-snippet_outer">      <span class="code-snippet__attr">HKEY_CURRENT_USER,</span></span></code><code><span class="code-snippet_outer">      <span class="code-snippet__meta">(const</span> <span class="code-snippet__string">unsigned __int16 *)a1,</span></span></code><code><span class="code-snippet_outer">      <span class="code-snippet__attr">L&#34;General&#34;,</span></span></code><code><span class="code-snippet_outer">      <span class="code-snippet__attr">(HKEY)&amp;hKey,</span></span></code><code><span class="code-snippet_outer">      <span class="code-snippet__attr">v7,</span></span></code><code><span class="code-snippet_outer">      <span class="code-snippet__attr">v10,</span></span></code><code><span class="code-snippet_outer">      <span class="code-snippet__meta">(unsigned</span> <span class="code-snippet__string">int)v11,</span></span></code><code><span class="code-snippet_outer">      <span class="code-snippet__meta">(HKEY</span> <span class="code-snippet__string">*)hKey);</span></span></code><code><span class="code-snippet_outer">  <span class="code-snippet__attr">else</span></span></code><code><span class="code-snippet_outer">    <span class="code-snippet__meta">VBRegOpenKeyFromRoot(&amp;hKey,</span> <span class="code-snippet__string">HKEY_CURRENT_USER, L&#34;General&#34;, (HKEY)0x20019, v7, (unsigned int)v10, v11);//a1=0</span></span></code><code><span class="code-snippet_outer">  <span class="code-snippet__attr">v5</span> = <span class="code-snippet__string">HrFromRegError(v8);</span></span></code><code><span class="code-snippet_outer">  <span class="code-snippet__attr">if</span> <span class="code-snippet__string">( v5 &gt;= 0 )</span></span></code><code><span class="code-snippet_outer">  <span class="code-snippet__attr">{</span></span></code><code><span class="code-snippet_outer">    <span class="code-snippet__meta">RegQueryValueExW(hKey,</span> <span class="code-snippet__string">lpValueName, 0, 0, lpData, &amp;cbData);</span></span></code><code><span class="code-snippet_outer">    <span class="code-snippet__attr">v5</span> = <span class="code-snippet__string">HrFromRegError(v9);</span></span></code><code><span class="code-snippet_outer">    <span class="code-snippet__attr">if</span> <span class="code-snippet__string">( hKey )</span></span></code><code><span class="code-snippet_outer">      <span class="code-snippet__attr">RegCloseKey(hKey);</span></span></code><code><span class="code-snippet_outer">  <span class="code-snippet__attr">}</span></span></code><code><span class="code-snippet_outer">  <span class="code-snippet__attr">return</span> <span class="code-snippet__string">v5;</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">}</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">int</span> <span class="code-snippet__string">__userpurge VBRegOpenTwoKeysFromRoot@&lt;eax&gt;(HKEY a1@&lt;ebx&gt;, const unsigned __int16 *a2@&lt;edi&gt;, const unsigned __int16 *a3@&lt;esi&gt;, HKEY a4, const unsigned __int16 *a5, const unsigned __int16 *a6, unsigned int a7, HKEY *a8)</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">{</span></span></code><code><span class="code-snippet_outer"><br/></span></code><code><span class="code-snippet_outer">  <span class="code-snippet__attr">if</span> <span class="code-snippet__string">( !g_pMainParam || (v7 = (const wchar_t *)*((_DWORD *)g_pMainParam + 31)) == 0 || !*v7 )</span></span></code><code><span class="code-snippet_outer">    <span class="code-snippet__attr">v7</span> = <span class="code-snippet__string">L&#34;Software\\Microsoft\\VisualStudio\\8.0&#34;;</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">}</span></span></code><code><span class="code-snippet_outer"><br/></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">0</span>:<span class="code-snippet__string">000:x86&gt; p</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__meta">msenv!VBRegOpenKeyFromRoot+0xed</span>:<span class="code-snippet__string"></span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">05a54d9d</span> <span class="code-snippet__string">ff1550109205    call    dword ptr [msenv!_imp__RegOpenKeyExW (05921050)] ds:002b:05921050={AcLayers!NS_VirtualRegistry::APIHook_RegOpenKeyExW (68d83ce0)}</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">0</span>:<span class="code-snippet__string">000:x86&gt; dd esp</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">0019d300</span>  <span class="code-snippet__string">80000001 0019d31c 00000000 00020019</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">0019d310</span>  <span class="code-snippet__string">0019d314 0019d364 000001e4 006f0053</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">0019d320</span>  <span class="code-snippet__string">00740066 00610077 00650072 004d005c</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">0019d330</span>  <span class="code-snippet__string">00630069 006f0072 006f0073 00740066</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">0019d340</span>  <span class="code-snippet__string">0056005c 00730069 00610075 0053006c</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">0019d350</span>  <span class="code-snippet__string">00750074 00690064 005c006f 002e0038</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">0019d360</span>  <span class="code-snippet__string">005c0030 00650047 0065006e 00610072</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">0019d370</span>  <span class="code-snippet__string">0000006c 007c0cf0 baadf00d 007ed3e0</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">0</span>:<span class="code-snippet__string">000:x86&gt; du 0019d31c </span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">0019d31c</span>  <span class="code-snippet__string">&#34;Software\Microsoft\VisualStudio\&#34;</span></span></code><code><span class="code-snippet_outer"><span class="code-snippet__attr">0019d35c</span>  <span class="code-snippet__string">&#34;8.0\General&#34;</span></span></code></pre></section><p data-line="314" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;"><br/></p><p data-line="314" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">通过调试确认，最终找到配置位置：</p><p data-line="314" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;"><br/></p><section class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"><li></li><li></li></ul><pre class="code-snippet__js" data-lang="makefile"><code><span class="code-snippet_outer">计算机\HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio\8.0\General</span></code><code><span class="code-snippet_outer">CommandWindowAutocompletion = 0;REG_DWORD</span></code></pre></section><pre><br/></pre><p data-line="321" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">增加注册表<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">CommandWindowAutocompletion</code>，设置为0，这样<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">ms_fEnableAutocompletion</code>就是0，问题解决。</p><p data-line="323" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">看名字这个有点像代码自动完成功能的，但不知道<code style="color: var(--vscode-textPreformat-foreground);font-family: var(--vscode-editor-font-family, &#34;SF Mono&#34;, Monaco, Menlo, Consolas, &#34;Ubuntu Mono&#34;, &#34;Liberation Mono&#34;, &#34;DejaVu Sans Mono&#34;, &#34;Courier New&#34;, monospace);font-size: 1em;line-height: 1.357em;">ms_fEnableAutocompletion</code>配置为0之后会不会影响该功能。</p><p data-line="325" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">哈哈，经过验证没有影响，终于又可以正常使用这个老古董了。</p><p data-line="327" dir="auto" style="margin-bottom: 0.7em;color: rgb(0, 0, 0);font-family: -apple-system, BlinkMacSystemFont, &#34;Segoe WPC&#34;, &#34;Segoe UI&#34;, system-ui, Ubuntu, &#34;Droid Sans&#34;, sans-serif;font-size: 14px;text-align: start;white-space: normal;">（完）</p><p><br/></p>



<p><a href="2247483832">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=48b18db8&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzU4NjY5ODM3Nw%3D%3D%26mid%3D2247483832%26idx%3D1%26sn%3Db5e983ba6ba951b580fdd6cf7d44373e%26subscene%3D0">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Sat, 19 Mar 2022 16:12:00 +0800</pubDate>
    </item>
    <item>
      <title>LordPE在win10无法工作折腾笔记-死而复生</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzU4NjY5ODM3Nw==&amp;mid=2247483827&amp;idx=1&amp;sn=a7959b60716092f2242d2dc7cdebb665</link>
      <description>程序员就是折腾~</description>
      <content:encoded><![CDATA[<p>
原创 <span>Anhkgg</span> <span>2021-06-19 20:02</span> <span style="display: inline-block;"></span>
</p>

<p>程序员就是折腾~</p>
<p></p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=cf121763&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FqukewnktvYwz0d00ndM1Nhdr4BmFAjnay4Zmz16V3A4Y0BjrnibGSRLvia40o5J4WrNBMHPfGJXVKc6icBDdOa56A%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;"><br/></p><pre style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;font-size: 1em;line-height: 1.2em;font-size: 0.75em;margin: 1.2em 0px;"><code style="white-space:pre-wrap;font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;background-color: rgb(248, 248, 248);overflow: auto;border-radius: 3px;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 0.5em 0.7em;display: block !important;">author: anhkgg<br/>date: 2021年6月19日</code></pre><h2 style="margin: 1.3em 0px 1em;padding: 0px;font-weight: bold;color: rgb(10, 87, 187);font-size: 1.3em;text-align: center;border-bottom: 1px solid rgb(238, 238, 238);">前情提要</h2><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">最近在分析某个软件时，提示错误。赶紧挂上windbg看看调用栈，看能不能找到问题。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">一看应该能够解决，需要结合IDA静态分析。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">通过任务管理器进程转到文件，发现文件已经不存在了，咋办？</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">还好，进程还在，可以把主程序dump下来，就可以静态分析了。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">如何dump呢？简单的可以通过windbg的.writemem把内存写入文件，但是文件不是合法（可运行）的PE，虽然此时文件和内存中数据完全相同（IDA可以将就分析）。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">PE文件的文件结构和内存结构是不完全相同的，最重要的原因是文件对齐和内存对齐不同。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">所以windbg的.writemem是不支持把内存dump生成合法的PE文件，除非自己再进行文件修复。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">此时，不知道有没有人想起来逆向中脱壳，是不是也有类似操作，我这里不是脱壳，但需要做的确和脱壳类似。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">所以我想到了LordPE（没用OD），它可以把内存dump之后生成正确的PE文件，然后再ImportREC修复输入表即可。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">这活脱脱的就是脱壳啊，哈哈，无所谓啦。</p><h2 style="margin: 1.3em 0px 1em;padding: 0px;font-weight: bold;color: rgb(10, 87, 187);font-size: 1.3em;text-align: center;border-bottom: 1px solid rgb(238, 238, 238);">分析</h2><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">好久不使LordPE，赶紧找出来，运行之后，发现不行。咋回事？该版本不支持枚举高权限进程？不至于啊。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">连着换了多个版本，还是不行，LordPE枚举到的进程中没有我的目标进程，而且很多进程名都是[System Process]。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">LordPE不至于这么弱吧？！算了，祭出windbg分析一下吧。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">windbg启动LordPE，对枚举进程API下断，bp kernel32!ProcessNext，居然没断下来。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">WTF？</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">那断ntdll的API总行了吧，bp ntdll!NtQuerySystemInformation。可以，发现用的是kernel32!EnumProcess。</p><pre style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;font-size: 1em;line-height: 1.2em;font-size: 0.75em;margin: 1.2em 0px;"><code style="white-space:pre-wrap;font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;background-color: rgb(248, 248, 248);overflow: auto;border-radius: 3px;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 0.5em 0.7em;display: block !important;">0:000&gt; kv<br/> # ChildEBP RetAddr  Args to Child              <br/>00 0019f5e0 200013fc 004a0010 00000400 0019f600 KERNELBASE!K32EnumProcesses (FPO: [Non-Fpo])<br/>01 0019f74c 00405fb6 004a0010 00000400 69970c70 procs!GetProcessIDList+0x13c<br/>02 0019f7a0 6992b4f2 ffffffff 00001003 00000001 LordPE+0x5fb6<br/>03 0019f7c4 69929edb 00040426 00001003 00000001 COMCTL32!FlatSB_SubclassWndProc+0x22 (FPO: [6,0,0])<br/>04 0019f820 fffffffe 0019f874 69929e20 00040426 COMCTL32!CallNextSubclassProc+0x69 (FPO: [Non-Fpo])<br/>05 0019f844 7789c79c 00000000 00559420 00000000 0xfffffffe<br/>06 0019f920 766760bf 00000000 00000000 004911c8 ntdll!RtlDeactivateActivationContextUnsafeFast+0x9c (FPO: [Non-Fpo])</code></pre><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">然后发现procs!GetProcessIDList，看名字明显就是获取所有进程PID。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">IDA打开procs.dll一看，这个DLL提供了所有进程和模块管理的接口。</p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-backh="239" data-backw="578" data-ratio="0.41396933560477" data-s="300,640" style="width: 100%;height: auto;" data-type="png" data-w="587" src="https://wechat2rss.xlab.app/img-proxy/?k=32bc09b2&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FqukewnktvYwz0d00ndM1Nhdr4BmFAjnaIk25pvVwHuBibiaibd6U9vay6al0zU8xcH6lb8NCvTL7Lr39nNk7iawh5A%2F640%3Fwx_fmt%3Dpng"/></p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">可以看到，他根据Is_xxx_200024FC（系统版本）分两类API来获取信息，第二种才是我前面没成功下断的ProcessNext。</p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-backh="480" data-backw="578" data-ratio="0.8311036789297659" data-s="300,640" style="width: 100%;height: auto;" data-type="png" data-w="598" src="https://wechat2rss.xlab.app/img-proxy/?k=d44c215e&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FqukewnktvYwz0d00ndM1Nhdr4BmFAjna3qNKpWLGgia1YXWDteElvfYvYGUwvhibfnEO6cpZJXP1XL3MKpCDgbKQ%2F640%3Fwx_fmt%3Dpng"/></p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">这不是重点，上面的枚举代码没什么问题，不过我没怎么用过EnumProcess接口，不确定是否有问题，所以我把Is_xxx_200024FC强制改为0，然后所有接口都通过tlhelp32接口来获取进程和模块信息。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">再往上层回溯，进入LordPE，发现神奇的东西。</p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-backh="58" data-backw="541" data-ratio="0.10720887245841035" data-s="300,640" style="width: 100%;height: auto;" data-type="png" data-w="541" src="https://wechat2rss.xlab.app/img-proxy/?k=51f32cb6&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FqukewnktvYwz0d00ndM1Nhdr4BmFAjna873Wpy7ibxIGXAzok4j2FHZRzATZ0iamSm7M75lMTLwkjnvRdMouibxPw%2F640%3Fwx_fmt%3Dpng"/></p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">长度传的0xF0，也就是240 / 4 = 60，也就是说LordPE只能获取60个进程。</p><pre style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;font-size: 1em;line-height: 1.2em;font-size: 0.75em;margin: 1.2em 0px;"><code style="white-space:pre-wrap;font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;background-color: rgb(248, 248, 248);overflow: auto;border-radius: 3px;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 0.5em 0.7em;display: block !important;">DWORD dwProcessId[60];</code></pre><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">而在win10上，动不动就是上百个进程，所以没有枚举到我要看的目标进程太正常了。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">只想吐槽，LordPE作者怎么会写出这样的代码，这就算在xp、win7，进程超过60个也歇菜了。</p><h2 style="margin: 1.3em 0px 1em;padding: 0px;font-weight: bold;color: rgb(10, 87, 187);font-size: 1.3em;text-align: center;border-bottom: 1px solid rgb(238, 238, 238);">修改</h2><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">问题找到了，现在该想想如何修改让LordPE能够正常用起来。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">首先想到的是，既然枚举进程不全，我可以自己枚举进程插入到进程列表中。</p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-backh="148" data-backw="505" data-ratio="0.29306930693069305" data-s="300,640" style="width: 100%;height: auto;" data-type="png" data-w="505" src="https://wechat2rss.xlab.app/img-proxy/?k=f8a56d5a&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FqukewnktvYwz0d00ndM1Nhdr4BmFAjnaKQqsLbVaqGcsVZkzsnMKia2xWB0grzDSdSXiajk0PbavQP1BvesajhZA%2F640%3Fwx_fmt%3Dpng"/></p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">但需要确认点击某个进程选dump是怎么处理的？<br/></p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-backh="108" data-backw="442" data-ratio="0.24434389140271492" data-s="300,640" style="width: 100%;height: auto;" data-type="png" data-w="442" src="https://wechat2rss.xlab.app/img-proxy/?k=f9528168&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FqukewnktvYwz0d00ndM1Nhdr4BmFAjnaic2HwTEiciaQBPMkLxKq7vgS4ib2Q1ZRUuOfoCicul8yicOFFhVjzibpUftkA%2F640%3Fwx_fmt%3Dpng"/></p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">获取到选择的进程行，让后dwProcessId[index]拿到进程PID，然后调用dump函数。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">这，index超了60，dwProcessId[index]就不行了啊，这个PID不合法啊。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">此路不通。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">那把dwProcessId扩大呢？</p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-backh="161" data-backw="522" data-ratio="0.30842911877394635" data-s="300,640" style="width: 100%;height: auto;" data-type="png" data-w="522" src="https://wechat2rss.xlab.app/img-proxy/?k=43078e06&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FqukewnktvYwz0d00ndM1Nhdr4BmFAjnaniaWMIe9rxmgYXQibJtWoqicyjeY9lxjOpJbDUwuVZutibWZicuVbohkAWg%2F640%3Fwx_fmt%3Dpng"/></p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">dwProcessId大小60个，后面马上接着其他变量，连对齐空间都没有。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">不可行。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">可以看到，引用dwProcessId的位置还不只一个。</p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-backh="253" data-backw="454" data-ratio="0.5572687224669604" data-s="300,640" style="width: 100%;height: auto;" data-type="png" data-w="454" src="https://wechat2rss.xlab.app/img-proxy/?k=f0c92879&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FqukewnktvYwz0d00ndM1Nhdr4BmFAjnaC0RbFia9tdmprThscrpaWiazpFRXjeqhXd8Q0ZfVWaYuU61LRHicJMALA%2F640%3Fwx_fmt%3Dpng"/></p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">更多想法：</p><ol style="font-size: 0.75em;margin: 1.2em 0px;padding-left: 2em;" class="list-paddingleft-2"><li style="font-size: 0.875em;margin: 0.5em 0px;"><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;font-size: 0.875em;color: rgb(82, 82, 82);word-break: break-all;margin: 0.5em 0px !important;">dwProcessId通过malloc分配，但得修改所有引用位置的代码，从dwProcessId[index]换成(*dwProcess)[index]</p></li><li style="font-size: 0.875em;margin: 0.5em 0px;"><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;font-size: 0.875em;color: rgb(82, 82, 82);word-break: break-all;margin: 0.5em 0px !important;">劫持所有procs.dll接口，把参数PID换成我需要dump的进程，同样也需要替换模块地址。</p></li><li style="font-size: 0.875em;margin: 0.5em 0px;"><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;font-size: 0.875em;color: rgb(82, 82, 82);word-break: break-all;margin: 0.5em 0px !important;">或者重写一个…(额)</p></li></ol><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">觉得都挺麻烦的。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">此时，去百度搜索了一下，发现已经有前人做过相关工作了。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">LordPE只显示60个进程 fix</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">他是在PE中找到空白位置，用做新的dwProcessId地址，然后把所有引用dwProcessId的位置换成这个新地址，还挺简单，不过最多只能存256个进程PID，将就可以用了。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">然后procs.dll接口也存在问题，居然还有硬编码F0来EnumProcess获取进程（几乎所有接口）。</p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-backh="498" data-backw="573" data-ratio="0.8691099476439791" data-s="300,640" style="width: 100%;height: auto;" data-type="png" data-w="573" src="https://wechat2rss.xlab.app/img-proxy/?k=cbef8019&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FqukewnktvYwz0d00ndM1Nhdr4BmFAjna2Bc6UNjjucfAUQicVDLlv6icg7MI2tic5xpTDzZ3wFVwnOP2wQSZGzNng%2F640%3Fwx_fmt%3Dpng"/></p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">不过我前面已经修改了Is_xxx_200024FC，所以不会用enumprocess，全部使用的tlhelp32的ProcessNext接口，不会存在这个问题。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">所以暂时确定方案：</p><ol style="font-size: 0.75em;margin: 1.2em 0px;padding-left: 2em;" class="list-paddingleft-2"><li style="font-size: 0.875em;margin: 0.5em 0px;"><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;font-size: 0.875em;color: rgb(82, 82, 82);word-break: break-all;margin: 0.5em 0px !important;">找到新位置用作dwProcessId，并修改引用位置</p></li><li style="font-size: 0.875em;margin: 0.5em 0px;"><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;font-size: 0.875em;color: rgb(82, 82, 82);word-break: break-all;margin: 0.5em 0px !important;">修改procs.dll的Is_xxx_200024FC为0</p></li></ol><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">在结尾看到800h的对齐位置。</p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-backh="95" data-backw="522" data-ratio="0.18199233716475097" data-s="300,640" style="width: 100%;height: auto;" data-type="png" data-w="522" src="https://wechat2rss.xlab.app/img-proxy/?k=b1e3a8a8&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FqukewnktvYwz0d00ndM1Nhdr4BmFAjnahiau4CePOh0MUXy82ZPEYcmxUyLOYoblwLdq0lOKeL0RO7EUNzxFJhg%2F640%3Fwx_fmt%3Dpng"/></p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">0x800/4=0x200=512字节，那么可以枚举到512个进程。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">把所有dwProcessId换成41EA88，大小F0换成800h。</p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-backh="350" data-backw="578" data-ratio="0.6063651591289783" data-s="300,640" style="width: 100%;height: auto;" data-type="png" data-w="597" src="https://wechat2rss.xlab.app/img-proxy/?k=aaefda05&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FqukewnktvYwz0d00ndM1Nhdr4BmFAjnaCyfqh7GicKauVPfib1e6X79WusZ5ZSEgehGa9Wozp1bTibOxbibbt1cH0A%2F640%3Fwx_fmt%3Dpng"/></p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">现在可以正常枚举到进程。</p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-backh="230" data-backw="547" data-ratio="0.42047531992687387" data-s="300,640" style="width: 100%;height: auto;" data-type="png" data-w="547" src="https://wechat2rss.xlab.app/img-proxy/?k=23191576&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FqukewnktvYwz0d00ndM1Nhdr4BmFAjnaVzetkYkuETj9BGkkooWYcydib4OAB8hBGTdw5icg3aOLhMnmNXF7A1lQ%2F640%3Fwx_fmt%3Dpng"/></p><h2 style="margin: 1.3em 0px 1em;padding: 0px;font-weight: bold;color: rgb(10, 87, 187);font-size: 1.3em;text-align: center;border-bottom: 1px solid rgb(238, 238, 238);">总结</h2><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">经过一番折腾，目前满足我当前需求，可以正常dump出错的软件，但是LordPE不支持64进程，所有可能某些情况下还是鸡肋。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">很少这么手工修改软件，思路还是挺重要的，要不是搜到那篇帖子，我可能就会采用勾上procs.dll的导出接口和dump函数，但随便几点某个进程，选择dump时，会弹出一个我的界面选择真实的目标进程，然后返回调用dump函数，也同样是可以同样的功能。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">最后立个flag，有时间还是想写个支持64进程的增强版LordPE。或者我孤陋寡闻，目前已经有类似程序，有知情大佬，请不吝告知。</p>



<p><a href="2247483827">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=41b06f90&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzU4NjY5ODM3Nw%3D%3D%26mid%3D2247483827%26idx%3D1%26sn%3Da7959b60716092f2242d2dc7cdebb665%26subscene%3D0">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Sat, 19 Jun 2021 20:02:00 +0800</pubDate>
    </item>
    <item>
      <title>笔记：“锟斤拷”究竟是怎么回事？</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzU4NjY5ODM3Nw==&amp;mid=2247483811&amp;idx=1&amp;sn=16f28b12ab4c9da75858476867f8ccb8</link>
      <description>手持两把锟斤拷,口中疾呼烫烫烫。脚踏千朵屯屯屯,笑看万物锘锘锘</description>
      <content:encoded><![CDATA[<p>
原创 <span>Anhkgg</span> <span>2021-03-17 13:10</span> <span style="display: inline-block;"></span>
</p>

<p>手持两把锟斤拷,口中疾呼烫烫烫。脚踏千朵屯屯屯,笑看万物锘锘锘</p>
<p></p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=2ba62d1a&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FqukewnktvYxno3kHw7AICfWTJwcL0mYpWB1ggMT5grZhMIYhI4CkRuU63sTmq92qmqTttchFHnVcRbhl1FkG8A%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">最近用vscode编辑代码，中文总是变成乱码“锟斤拷”，无法恢复。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">思考了一下，按理说就算别识别成另一种编码，我换成正确编码应该是能够正常显示的，但结果是不能。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">所以究竟发生了什么？</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">这次终于认真研究了一下，用010editor对比二进制数据，终于发现…</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">数据已经改变了，还有一些特征。</p><pre style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;font-size: 1em;line-height: 1.2em;font-size: 0.75em;margin: 1.2em 0px;"><code style="white-space:pre-wrap;font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;background-color: rgb(248, 248, 248);overflow: auto;border-radius: 3px;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 0.5em 0.7em;display: block !important;">//内存基址<br/>//锟节达拷锟街?</code></pre><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;"><span style="color: rgb(0, 82, 255);">C4</span><span style="color: rgb(255, 0, 0);"> DA | B4 </span><span style="color: rgb(0, 82, 255);">E6</span><span style="color: rgb(255, 0, 0);"> | </span><span style="color: rgb(0, 82, 255);">BB F9</span><span style="color: rgb(255, 0, 0);"> | D6 B7</span><br/><span style="color: rgb(0, 82, 255);">EF BF BD</span> <span style="color: rgb(255, 0, 0);">DA</span> | <span style="color: rgb(255, 0, 0);">B4</span> <span style="color: rgb(0, 82, 255);">EF BF BD</span> | <span style="color: rgb(0, 82, 255);">EF BF BD</span> |<span style="color: rgb(255, 0, 0);"> D6 B7</span></p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">对比之后发现，某些字节还是原始的，某些字节替换成了EF BF BD。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">百度一搜EF BF BD，发现原来是这样的。</p><pre style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;font-size: 1em;line-height: 1.2em;font-size: 0.75em;margin: 1.2em 0px;"><code style="white-space:pre-wrap;font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;background-color: rgb(248, 248, 248);overflow: auto;border-radius: 3px;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 0.5em 0.7em;display: block !important;">在众多的utf-8码点值中，除了ascii，你还应该记住「EF BF BD」，因为它是很多编程语言以及库中的备胎，即无效的码点值在编码的时候会默认用这个码点值进行替换，即utf-8中的超级「备胎」(REPLACEMENT CHARACTER)。utf-8 神秘符号 efbf bdef bfbd<br/>很多时候我们在打开utf-8的时候会有 � 等很多像问号的编码出现这时候我们打开这个文件的二进制就会发现 问号对应的十六进制编码就是efbf bdef bfbd。这个编码到底是什么呢？为什么会有这种编码呢。这就要从各种编码格式的转换说起。而且大部分出现这种问题的就是用gbk编码的文件用utf-8编码格式打开。当编码格式中出现utf-8无法解析的字节，那么这个字节就会被替换成 efbf bdef bfbd 这时我们会发现文件大小也发生了改变，因为未知字节全部变成三个未知字节。而这时候再将其转换为gbk锟 (0xEFBF)，斤（0xBDEF），拷（0xBFBD） 这就是 锟斤拷 那么我是在什么时候发现这个问题：python 的 print 我们一般都会把python代码设置成全局utf-8编码。这时候如果你收到的是一个gbk的编码，但是直接打出来。就会发现出现很多问号。这个时候直接复制粘贴再看二进制就不是真正接受的数据。因为print自动将收到的数据进行了utf-8解码。这样无法解析的编码就变成efbf bdef bfbd。所以在遇到乱码的时候就需要在数据的原始接受处，及第一次转码发生之前将数据用二进制写入文件留存</code></pre><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">所以，本来代码使用的gbk（其实是ansi）编码保存的，用vscode打开时，自动识别成了utf8，也没注意到乱码了，只要此时一保存，完了。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">已经被换成了锟斤拷（重新用gbk打开看到是锟斤拷）。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">so，使用vscode的时候要注意打开编码是否正确，如果遇到此种情况，如法恢复。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">因为替换成了EF BF BD，没法知道原始数据是什么。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">最后就是吐槽，vscode识别编码（Auto Guess Encoding并不好用，经常会被识别成Windows 1252）不准确，相比来说<span style="text-decoration: line-through;">notepad++</span>这方面做的不错。</p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.45183714001986097" data-s="300,640" style="" data-type="png" data-w="1007" src="https://wechat2rss.xlab.app/img-proxy/?k=0d10d0f0&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FqukewnktvYxno3kHw7AICfWTJwcL0mYp1b1jbWEZzgBxD1f2qfKibeUo1EwTt9F7e2oRNsmodYJWA2iah8PTDgBw%2F640%3Fwx_fmt%3Dpng"/></p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;"><br/></p>



<p><a href="2247483811">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=c3072cd1&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzU4NjY5ODM3Nw%3D%3D%26mid%3D2247483811%26idx%3D1%26sn%3D16f28b12ab4c9da75858476867f8ccb8%26subscene%3D0">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Wed, 17 Mar 2021 13:10:00 +0800</pubDate>
    </item>
    <item>
      <title>Chrome导致Win10蓝屏简略分析</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzU4NjY5ODM3Nw==&amp;mid=2247483806&amp;idx=1&amp;sn=24f3e3f230e4c48c72bfeff11339eafe</link>
      <description>chrome导致win10蓝屏？&#xA;chrome：不是我的锅！</description>
      <content:encoded><![CDATA[<p>
原创 <span>Anhkgg</span> <span>2021-01-19 11:47</span> <span style="display: inline-block;"></span>
</p>

<p>chrome导致win10蓝屏？</p>
<p>chrome：不是我的锅！</p>
<p></p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=d5b6cd1c&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FqukewnktvYxNiatBsOoAanOn0Udic2Yx6ZPaevRvCNa6M99icwjDOBSWnsAszIthQOeSeWGzsF2TpoicpzLdulYwUQ%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">今天看到有人说chrome访问一个设备路径导致win10蓝屏，一搜帖子还挺多的。</p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-backh="429" data-backw="578" data-ratio="0.7419354838709677" data-s="300,640" style="width: 100%;height: auto;" data-type="png" data-w="837" src="https://wechat2rss.xlab.app/img-proxy/?k=36a362ee&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FqukewnktvYxNiatBsOoAanOn0Udic2Yx6Z22FXShich4yDI1FBFs3kjSibcMVzd9lORHepXAYWEDYg4QpicXIq14jVw%2F640%3Fwx_fmt%3Dpng"/></p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">作为win内核研究人员，对此非常感兴趣。赶紧打开虚拟机，装上chrome，测试一把。</p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.20927152317880796" data-s="300,640" style="" data-type="png" data-w="755" src="https://wechat2rss.xlab.app/img-proxy/?k=831afb02&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FqukewnktvYxNiatBsOoAanOn0Udic2Yx6ZtBuK8HySutfktoECVSgEMslhibmyH5g54q0oUAybjY9aRkVcFQwCTVA%2F640%3Fwx_fmt%3Dpng"/></p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">果然蓝了。</p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.17547806524184478" data-s="300,640" style="" data-type="png" data-w="889" src="https://wechat2rss.xlab.app/img-proxy/?k=e9376240&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FqukewnktvYxNiatBsOoAanOn0Udic2Yx6ZU3OxGVXbIHpeHPn5ATWNHgG8IbibKvBzRyfDCodF3932tT9Hia6goseQ%2F640%3Fwx_fmt%3Dpng"/></p><h2 style="margin: 1.3em 0px 1em;padding: 0px;font-weight: bold;color: rgb(10, 87, 187);font-size: 1.3em;text-align: center;border-bottom: 1px solid rgb(238, 238, 238);">分析</h2><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">挂上Windbg调试器，很容易就发现问题在哪里了。</p><pre style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;font-size: 1em;line-height: 1.2em;font-size: 0.75em;margin: 1.2em 0px;"><code style="white-space:pre-wrap;font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;background-color: rgb(248, 248, 248);overflow: auto;border-radius: 3px;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 0.5em 0.7em;display: block !important;">eax=9d35e390 ebx=00000012 ecx=00000000 edx=9d35e390 esi=b7cb5798 edi=9d35e390<br/>eip=b8fd693a esp=abc7f78c ebp=abc7f790 iopl=0         nv up ei ng nz na po nc<br/>cs=0008  ss=0010  ds=0023  es=0023  fs=0030  gs=0000             efl=00010282<br/>condrv!CdpDispatchCleanup+0x1a:<br/>b8fd693a 8b11            mov     edx,dword ptr [ecx]  ds:0023:00000000=????????<br/>Resetting default scope<br/>LAST_CONTROL_TRANSFER:  from 82a4f2a6 to 829959e4<br/>STACK_TEXT:  <br/>abc7ec84 82a4f2a6 00000003 417ab436 0000001e nt!RtlpBreakWithStatusInstruction<br/>abc7ecd8 82a4ecb4 896dc340 abc7f0c0 abc7f0f4 nt!KiBugCheckDebugBreak+0x1f<br/>abc7f094 8299439a 0000001e c0000005 b8fd693a nt!KeBugCheck2+0x7ad<br/>abc7f0b8 829942d1 0000001e c0000005 b8fd693a nt!KiBugCheck2+0xc6<br/>abc7f0d8 82a50f6b 0000001e c0000005 b8fd693a nt!KeBugCheckEx+0x19<br/>abc7f0f4 829d5b52 abc7f638 82b59960 abc7f1f0 nt!KiFatalExceptionHandler+0x1a<br/>abc7f118 829d5b24 abc7f638 82b59960 abc7f1f0 nt!ExecuteHandler2+0x26<br/>abc7f1e0 8292e595 abc7f638 abc7f1f0 00010037 nt!ExecuteHandler+0x24<br/>abc7f61c 829ce781 abc7f638 00000000 abc7f718 nt!KiDispatchException+0x1b5<br/>abc7f688 829d3062 ffffffff ffffffff ffffffff nt!KiDispatchTrapException+0x51<br/>abc7f688 b8fd693a ffffffff ffffffff ffffffff nt!KiTrap0E+0x382<br/>abc7f790 828b0368 b7cb5798 9d35e390 a9d2c220 condrv!CdpDispatchCleanup+0x1a<br/>abc7f7a8 82bd9e04 abc7fa74 b7cb5798 a9d2c220 nt!IofCallDriver+0x48<br/>abc7f7e8 82bd49aa 00000000 a9d2c220 00000001 nt!IopCloseFile+0x184<br/>abc7f8ac 82bb53b3 b7cb5798 45ff2480 00000000 nt!IopParseDevice+0xa6a<br/>abc7f99c 82bb7cb7 00000040 87ff2480 6c600001 nt!ObpLookupObjectName+0xea3<br/>abc7fa3c 82beecb7 098cf240 87ff2480 6c600001 nt!ObOpenObjectByNameEx+0x1c7<br/>abc7fc04 829cce6b 098cf240 098cf270 098cf2ac nt!NtQueryFullAttributesFile+0x15f<br/>abc7fc04 77cd5ef0 098cf240 098cf270 098cf2ac nt!KiSystemServicePostCall<br/>098cf220 77cd352a 75ff982e 098cf240 098cf270 ntdll!KiFastSystemCallRet<br/>098cf224 75ff982e 098cf240 098cf270 098cf2d0 ntdll!NtQueryFullAttributesFile+0xa<br/>098cf2ac 0fcb8f87 085375a8 00000000 098cf2d0 KERNELBASE!GetFileAttributesExW+0x7e<br/>WARNING: Stack unwind information not available. Following frames may be wrong.<br/>098cf350 10ec66a9 098cf54c 098cf520 00a90000 chrome!ChromeMain+0x34a47</code></pre><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;"><code style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;padding: 0px 0.3em;white-space: pre-wrap;border-width: 1px;border-style: solid;border-color: rgb(234, 234, 234);background-color: rgb(248, 248, 248);border-radius: 3px;display: inline;">mov     edx,dword ptr [ecx]</code>读0地址导致内存访问异常，蓝屏。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">具体原因就是微软condrv.sys处理cleanup例程的时候对访问指针判断不够严谨，FileObject-&gt;FsContext未空，未作判断直接读取内容导致蓝屏。</p><pre style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;font-size: 1em;line-height: 1.2em;font-size: 0.75em;margin: 1.2em 0px;"><code style="white-space:pre-wrap;font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;background-color: rgb(248, 248, 248);overflow: auto;border-radius: 3px;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 0.5em 0.7em;display: block !important;">condrv!CdpDispatchCleanup<br/>PAGE:00016925                 mov     eax, [ebp+Irp]<br/>PAGE:00016928                 mov     ecx, [eax+60h] //Irp-&gt;Tail.Overlay.CurrentStackLocation<br/>PAGE:0001692B                 mov     ecx, [ecx+18h] //IoStack-&gt;FileObject<br/>PAGE:0001692E                 test    ecx, ecx<br/>PAGE:00016930                 jz      loc_181F9<br/>PAGE:00016936                 mov     ecx, [ecx+0Ch] //FileObject-&gt;FsContext<br/>PAGE:00016939                 push    esi<br/>PAGE:0001693A                 mov     edx, [ecx] //ecx=0，读取违例</code></pre><h2 style="margin: 1.3em 0px 1em;padding: 0px;font-weight: bold;color: rgb(10, 87, 187);font-size: 1.3em;text-align: center;border-bottom: 1px solid rgb(238, 238, 238);">影响</h2><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">我也往回看了几个老版本win10系统，condrv.sys同样存在一样的问题，说明这个已经存在很久了，只是最近刚被发现了。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">粗略分析来看，FsContext一般来说并不能被攻击者控制，并且此处只是一个读内存问题，一般不能得到一个有效的漏洞攻击利用。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;"><strong>所以大家并不用特别担心，如果有人拿来恶作剧，最多就是让你电脑蓝屏重启一下，危害并不大。</strong></p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">但是，注意别在写文档、写代码等等情况下，还未保存数据的时候，中招了。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">那么，节哀，刚刚辛辛苦苦写的东西肯定没了！</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">最后，等待微软修复吧。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">最后的最后：</p><ol style="font-size: 0.75em;margin: 1.2em 0px;padding-left: 2em;" class="list-paddingleft-2"><li style="font-size: 0.875em;margin: 0.5em 0px;"><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;font-size: 0.875em;color: rgb(82, 82, 82);word-break: break-all;margin: 0.5em 0px !important;">并不是只有chrome访问这个设备路径才有问题，所有使用chrome内核的浏览器都会中招</p></li><li style="font-size: 0.875em;margin: 0.5em 0px;"><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;font-size: 0.875em;color: rgb(82, 82, 82);word-break: break-all;margin: 0.5em 0px !important;">朋友发你一个看起来像txt文本的批处理文件，也会导致windows蓝屏。</p></li><li style="font-size: 0.875em;margin: 0.5em 0px;"><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;font-size: 0.875em;color: rgb(82, 82, 82);word-break: break-all;margin: 0.5em 0px !important;">以及其他各种脚本文件，点开之前都看看内容是不是存在设备路径<code style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;padding: 0px 0.3em;white-space: pre-wrap;border-width: 1px;border-style: solid;border-color: rgb(234, 234, 234);background-color: rgb(248, 248, 248);border-radius: 3px;display: inline;">\\.\globalroot\device\condrv\kernelconnect</code></p></li><li style="font-size: 0.875em;margin: 0.5em 0px;"><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;font-size: 0.875em;color: rgb(82, 82, 82);word-break: break-all;margin: 0.5em 0px !important;"><code style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;padding: 0px 0.3em;white-space: pre-wrap;border-width: 1px;border-style: solid;border-color: rgb(234, 234, 234);background-color: rgb(248, 248, 248);border-radius: 3px;display: inline;">...</code></p></li></ol><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">（完）<br/></p>



<p><a href="2247483806">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=9a4c35ef&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzU4NjY5ODM3Nw%3D%3D%26mid%3D2247483806%26idx%3D1%26sn%3D24f3e3f230e4c48c72bfeff11339eafe%26subscene%3D0">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Tue, 19 Jan 2021 11:47:00 +0800</pubDate>
    </item>
    <item>
      <title>QQ后台读取历史记录？有点冤枉企鹅了!</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzU4NjY5ODM3Nw==&amp;mid=2247483799&amp;idx=1&amp;sn=3f0ac080c28ad498bde44b7059f5f1bc</link>
      <description>我觉得，有些事情还是别潜意思觉得~~</description>
      <content:encoded><![CDATA[<p>
原创 <span>Anhkgg</span> <span>2021-01-17 17:41</span> <span style="display: inline-block;"></span>
</p>

<p>我觉得，有些事情还是别潜意思觉得~~</p>
<p></p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=3715c5bf&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FqukewnktvYwEqOpcaeVWXdf6F3OGJsaBaGHKlr5l0yUAoAlkAXgbHdkUcBSDC7U2iaOvDBswAnjShcHCfNrjc3g%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<h2 style="margin: 1.3em 0px 1em;padding: 0px;font-weight: bold;color: rgb(10, 87, 187);font-size: 1.3em;text-align: center;border-bottom: 1px solid rgb(238, 238, 238);">起因</h2><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">今天关注到看雪一篇帖子《关于QQ读取Chrome历史记录的澄清》访问量突然爆发，貌似引起了很大的震动。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">帖子内容大致是，作者看到v2ex一篇帖子《QQ 正在尝试读取你的浏览记录》说QQ后台尝试读取你的浏览器历史记录。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">然后本着探索的精神，作者去简单抓取了一下QQ的文件访问行为，和简单的逆向分析。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">然后得出结论是，QQ并不是针对Chrome，而是会遍历读取所有浏览器历史记录，确认会中招的浏览器包括但不限于如Chrome、Chromium、360极速、360安全、猎豹、2345等浏览器（看出了吗，就是所有使用chrome内核的浏览器）。</p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.13828125" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=aab98ad5&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FqukewnktvYwEqOpcaeVWXdf6F3OGJsaBrtTNzxU1piaCVxIoibIhBAiaCCLcPAsu4wcc52X9Vop436x5MuJNKlxEg%2F640%3Fwx_fmt%3Dpng"/></p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">这个…我有点…震惊！不敢置信。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">所以，根据作者帖子提供的线索，我也去看了看QQ相关位置的代码，究竟是做什么功能，一探究竟。</p><h2 style="margin: 1.3em 0px 1em;padding: 0px;font-weight: bold;color: rgb(10, 87, 187);font-size: 1.3em;text-align: center;border-bottom: 1px solid rgb(238, 238, 238);">分析</h2><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">原帖作者通过history搜索到关键代码，我也照着做了，然后发现了不同的事情。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">可能有点先入为主，原帖作者并没有怎么仔细看相关代码的逻辑和功能，认为QQ读取了chrome历史记录文件并进行了sqlite数据操作。</p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.09921875" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=5c5f0a37&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FqukewnktvYwEqOpcaeVWXdf6F3OGJsaBq869xOYZkrwoHumh8ulAerCicialrUtynATrNTviaMZGianfKGr8fJOBJg%2F640%3Fwx_fmt%3Dpng"/></p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">其实呢？如果仔细一点，就会发现下面的代码。</p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.09210526315789473" data-s="300,640" style="" data-type="png" data-w="1140" src="https://wechat2rss.xlab.app/img-proxy/?k=4a3eaf32&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FqukewnktvYwEqOpcaeVWXdf6F3OGJsaBEtmQzZ472MgjjBiaziaanQibaeQALFicic4O1kkyBnmroVtJahErp39GkicQ%2F640%3Fwx_fmt%3Dpng"/></p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">很明显，QQ仅仅暂时拷贝了chrome历史记录文件到临时文件temphis.db，然后刷选了url进行了一些检测，log信息中看到关键字<code style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;padding: 0px 0.3em;white-space: pre-wrap;border-width: 1px;border-style: solid;border-color: rgb(234, 234, 234);background-color: rgb(248, 248, 248);border-radius: 3px;display: inline;">ptjcur Detect2</code>。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">然后通过DeleteFile删除了临时文件temphis.dbg，中间代码也并没有发现什么上传服务器的代码。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;"><span style="color: rgb(255, 76, 65);"><strong>所以我觉得原帖作者得到QQ后台读取浏览器历史记录，并臆测可能会对用户做什么危害的行为，有上升到了用户隐私上，这个结论确实是有点不妥的。</strong></span></p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;"><span style="color: rgb(255, 76, 65);"><strong>因为读取历史记录和删除临时文件中间并没有什么上传服务器之类的操作，所有都是本地完成的。</strong></span></p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">这个结论对企鹅有点不公平，对一个如日冲天的互联网公司不公平。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">不能因为某些xx历史行为，就无脑接受坏人设定，不清楚细节就轻易下结论，当然我并不否认那些历史xx行为。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">为了搞清楚真相，我进行了更深入的分析，发现一些新的东西。</p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.69296875" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=148eda03&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FqukewnktvYwEqOpcaeVWXdf6F3OGJsaBQichPoaq6nCTViaOicDZqWEd7bGxnddQkIa2P28TKa2nhd8mv9B4k7tWA%2F640%3Fwx_fmt%3Dpng"/></p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">读取历史记录相关逻辑是在一个线程中，线程首先会判断dns domain是tencent.com或者存在SNGPERF，则bint为1，那么后面的读取历史记录也就不会做了（这是不针对企鹅内部环境？）。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">如果bint是0，则开始detect。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">首先通过urlcache（后面再读取chrome历史记录）读取url信息（ptjcur Detect1）。</p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.17421875" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=c53c4ca4&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FqukewnktvYwEqOpcaeVWXdf6F3OGJsaBX0o6YHT9SVlSCFGJwWdFqZKrEOruQrzEqQX3lTsn4Uhias2OMaNe8xg%2F640%3Fwx_fmt%3Dpng"/></p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">然后计算url的md5，比几个固定的md5值比较。</p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-ratio="0.53203125" data-s="300,640" style="" data-type="png" data-w="1280" src="https://wechat2rss.xlab.app/img-proxy/?k=3b1d02e2&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FqukewnktvYwEqOpcaeVWXdf6F3OGJsaBr3ghgqxXb7VYnhVaxLI6BstmfG0aCnRU3Il1icYafrbbfTgavQOB4Kg%2F640%3Fwx_fmt%3Dpng"/></p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">如果md5匹配，会解析url分析&amp;后面的参数，然后继续把这个参数做md5计算，和一些md5比较，匹配存入一块内存。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">具体后续有什么动作，经过这些简单的分析还不能确认，所以也不能轻易对其下结论。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">需要比较url的md5如下，有条件的朋友可以去跑跑看结果是什么，然后企鹅究竟要作什么就一目了然了。</p><pre style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;font-size: 1em;line-height: 1.2em;font-size: 0.75em;margin: 1.2em 0px;"><code style="white-space:pre-wrap;font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;background-color: rgb(248, 248, 248);overflow: auto;border-radius: 3px;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 0.5em 0.7em;display: block !important;">0x1C6389BA, 0xF2FA5666, 0xF2A2E0D3, 0xC892E7BA<br/>0xB829484C, 0x520F7CC3, 0x94EC8A73, 0xD808E79<br/>0xDDA1029, 0x9E67F3BB, 0xB18ACC45, 0x597CF438<br/>0x2564591C, 0x5B11347B, 0x846A0F72, 0xEF704A8</code></pre><h2 style="margin: 1.3em 0px 1em;padding: 0px;font-weight: bold;color: rgb(10, 87, 187);font-size: 1.3em;text-align: center;border-bottom: 1px solid rgb(238, 238, 238);">结论</h2><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">最后总结，经过上面的分析，我们并不能对QQ的行为下结论，并不能因为临时读取和计算了一下url，就判定是对用户隐私的侵害（有可能真的如某些人说的，这可能是对某些不雅网站的检查呢）。<br/>当然，在这件事情中，QQ并不完全是无辜者，读取用户浏览器历史记录是一个非常敏感的行为，应该必须让用户清楚得知道，你并没用用此信息做什么伤害用户利益的事情。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">最后的最后呢，我想到一个非常有意思的点，说不定这件事情就是因为开发人员一个不小心搞出来的乌龙呢？</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">哈哈，知道我说的什么吗？就是前面我提到的，判断dns域名是不是tencent.com，bint为0，才会有后面一系列行为，所以我当时很迷惑的猜测，对企鹅内部环境并不检测。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">而可能因为开发人员<span style="color: rgb(255, 76, 65);">手误把if(bint)写错成了if(!bint)</span>导致检测了非企鹅内部环境，而其实这个功能只是针对企鹅内部环境做的。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">当然，这只是我的猜测，具体还得看看企鹅自己的解释。</p><p style="font-size: 0.875em;word-break: break-all;font-family: 微软雅黑, 宋体, Consolas, Inconsolata, Courier, monospace;margin: 0px 0px 1.2em !important;">(完)</p>



<p><a href="2247483799">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=6ce47894&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzU4NjY5ODM3Nw%3D%3D%26mid%3D2247483799%26idx%3D1%26sn%3D3f0ac080c28ad498bde44b7059f5f1bc%26subscene%3D0">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Sun, 17 Jan 2021 17:41:00 +0800</pubDate>
    </item>
    <item>
      <title>深度探索：解除文件占用那些坑</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzU4NjY5ODM3Nw==&amp;mid=2247483789&amp;idx=1&amp;sn=eb22cffe84ba7f33f6ff36eef85f8cea</link>
      <description>网上的资料很多坑~</description>
      <content:encoded><![CDATA[<p>
原创 <span>Anhkgg</span> <span>2021-01-14 01:59</span> <span style="display: inline-block;"></span>
</p>

<p>网上的资料很多坑~</p>
<p></p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=bbc74ab4&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FqukewnktvYyMRq0zbYibzVPiaqOeO0IkZLJu4NJ5p4JYBwFp9pMr0ficR3JZnfrlS1kjf5mzt7pOoouiaNYI2TsG7Q%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">了解一点操作系统知识的同学们应该都知道，文件占用无法删除，是因为某些进程正在使用该文件。</p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-backh="263" data-backw="452" data-ratio="0.581858407079646" data-s="300,640" style="width: 100%;height: auto;" data-type="png" data-w="452" src="https://wechat2rss.xlab.app/img-proxy/?k=94db63d4&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FqukewnktvYyMRq0zbYibzVPiaqOeO0IkZLiaPSia7hIgkAaNc8JIVGD0qUoqlwdIQEQBe38eLhGUGEsmQRUicr5Gefw%2F640%3Fwx_fmt%3Dpng"/></p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">要删除这样的文件，就需要让那些进程关闭文件，然后自然可以删除。<br/>一句话的事，那究竟要怎么用代码来实现这个功能呢？</p><h1 style="margin: 1.3em 0px 1em;padding: 0px;font-weight: bold;font-size: 1.4em;border-bottom: 1px solid rgb(221, 221, 221);">打开和关闭文件</h1><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">还记得上大学第一门语言课-C语言，迄今为止还依然活跃并被一直使用的语言。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">比汇编容易理解，又更接近底层，所以Windows操作系统内核大部分代码都是用C语言来编写的。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">在C的课程里，我们学过通过FILE来操作使用文件，比如：</p><pre style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;font-size: 1em;line-height: 1.2em;font-size: 0.75em;margin: 1.2em 0px;"><code style="white-space:pre-wrap;font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;background-color: rgb(248, 248, 248);overflow: auto;border-radius: 3px;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 0.5em 0.7em;display: block !important;">FILE *fp;<br/>fp = fopen(&#34;c:\\temp\\test.txt&#34;, &#34;r&#34;)</code></pre><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">通过读的方式打开一个文件，使用非常简单，后续通过fp这个结构体指针操作文件即可。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">其实fopen并不接近操作系统，他是对win32 API CreateFile的封装。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">也就是前者是标准库接口，在Windows、linux、unix等都是通用接口。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">而后者才是和操作系统关联紧密，由微软自己提供的API。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">要更好的理解进程如何使用文件的，我们还得看看CreateFile这个API接口。</p><pre style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;font-size: 1em;line-height: 1.2em;font-size: 0.75em;margin: 1.2em 0px;"><code style="white-space:pre-wrap;font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;background-color: rgb(248, 248, 248);overflow: auto;border-radius: 3px;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 0.5em 0.7em;display: block !important;">HANDLE CreateFileA(<br/>  LPCSTR                lpFileName,<br/>  DWORD                 dwDesiredAccess,<br/>  DWORD                 dwShareMode,<br/>  LPSECURITY_ATTRIBUTES lpSecurityAttributes,<br/>  DWORD                 dwCreationDisposition,<br/>  DWORD                 dwFlagsAndAttributes,<br/>  HANDLE                hTemplateFile<br/>);</code></pre><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">这是msdn对CreateFile的定义，简单来看我们可以只关注lpFileName和返回值，lpFileName传递你要打开的文件，返回值是操作系统给你的一个代表文件的句柄（handle）。</p><pre style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;font-size: 1em;line-height: 1.2em;font-size: 0.75em;margin: 1.2em 0px;"><code style="white-space:pre-wrap;font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;background-color: rgb(248, 248, 248);overflow: auto;border-radius: 3px;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 0.5em 0.7em;display: block !important;">HANDLE hFile = CreateFileA(&#34;c:\\temp\\test.txt&#34;, ...);</code></pre><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">要对文件进行读、写等操作都需要这个句柄，也就是说这个句柄至关重要，它表示文件正在被使用。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">然后什么时候结束使用呢，我们需要看另一个API CloseHandle.</p><pre style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;font-size: 1em;line-height: 1.2em;font-size: 0.75em;margin: 1.2em 0px;"><code style="white-space:pre-wrap;font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;background-color: rgb(248, 248, 248);overflow: auto;border-radius: 3px;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 0.5em 0.7em;display: block !important;">BOOL CloseHandle(<br/>  HANDLE hObject<br/>);</code></pre><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">CloseHandle用于关闭一个正在被使用的文件，通过句柄来关闭。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">现在明白过来了吗，只要我们让进程调用CloseHandle这个API，关闭被占用的文件句柄，那么该文件也就被解除占用了。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">哈哈，是不是很简单。</p><h1 style="margin: 1.3em 0px 1em;padding: 0px;font-weight: bold;font-size: 1.4em;border-bottom: 1px solid rgb(221, 221, 221);">枚举占用文件的进程</h1><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">那么我就想问同学们一个问题，怎么知道哪些进程在使用我们想删除的文件呢？怎么去查找？</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">带着这个问题，我们继续往下看。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">我们来想一个问题，操作系统给调用CreateFile的用户返回了一个句柄，然后通过句柄来操作文件，那操作系统是如何知道句柄代表哪个文件呢？</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">我们简单思考一下，我们要达到这个目的有没有什么方法，比如我用一个数组来存用户打开的文件路径，而数组序号就返回给用户，下次用户就只需要把序号给我，我就知道要操作什么问题了。</p><pre style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;font-size: 1em;line-height: 1.2em;font-size: 0.75em;margin: 1.2em 0px;"><code style="white-space:pre-wrap;font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;background-color: rgb(248, 248, 248);overflow: auto;border-radius: 3px;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 0.5em 0.7em;display: block !important;">演示代码，忽略细节<br/>LPWSTR FileTable[100] = {0};<br/>HANDLE CreateFileA(<br/>  LPCSTR                lpFileName,<br/>  ...)<br/>  {<br/>      for(int i = 0; i &lt; 100; i ++) {<br/>          if(FileTable[i] == NULL) { //还有空位<br/>              FileTable[i] = lpFileName; //保存路径<br/>              return (HANDLE)i; //返回句柄<br/>          }<br/>      }<br/>      return NULL;<br/>  }<br/>BOOL CloseHandle(<br/>  HANDLE hObject<br/>) {<br/>    if((int)hObject &lt; 100) {<br/>        if(FileTable[hObject]) {<br/>            FileTable[hObject] = NULL;//找到文件路径<br/>            return TRUE;<br/>        }<br/>    }<br/>    return FALSE;<br/>}</code></pre><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">上面简单的代码演示了一下我们粗略考略的文件和句柄的关系以及句柄的管理，那操作系统是不是这么做的呢？其实也差不多。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">任意进程，只要每打开一个对象（包括文件、进程、线程等等），就会获得一个句柄。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">这个句柄用来标志对某个对象的一次打开，通过句柄，可以直接找到对应的内核对象。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">每个进程都有一个句柄表，用来记录本进程打开的所有内核对象。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">句柄表可以简单看做为一个一维数组，每个表项就是一个句柄，一个结构体，一个句柄描述符。</p><pre style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;font-size: 1em;line-height: 1.2em;font-size: 0.75em;margin: 1.2em 0px;"><code style="white-space:pre-wrap;font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;background-color: rgb(248, 248, 248);overflow: auto;border-radius: 3px;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 0.5em 0.7em;display: block !important;"> struct _HANDLE_TABLE_ENTRY  //句柄描述符<br/> struct _HANDLE_TABLE    //句柄表描述符</code></pre><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">好，更加细节的句柄表的原理我们不用再深究，我们只需要知道每个进程都有一个句柄表，通过句柄表就可以找到打开的文件。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">这就是我们的目的，我们需要查到进程是不是打开了我们要删除的文件，我们需要查句柄表。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">那怎么查呢？</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">操作系统给用户提供了一个接口ZwQuerySystemInformation。</p><pre style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;font-size: 1em;line-height: 1.2em;font-size: 0.75em;margin: 1.2em 0px;"><code style="white-space:pre-wrap;font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;background-color: rgb(248, 248, 248);overflow: auto;border-radius: 3px;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 0.5em 0.7em;display: block !important;">NTSTATUS WINAPI ZwQuerySystemInformation(<br/>  _In_      SYSTEM_INFORMATION_CLASS SystemInformationClass,<br/>  _Inout_   PVOID                    SystemInformation,<br/>  _In_      ULONG                    SystemInformationLength,<br/>  _Out_opt_ PULONG                   ReturnLength<br/>);</code></pre><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">它可以获取系统非常多的信息，包括进程、模块、处理器、内存等等各种信息。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">而SystemHandleInformation = 16就能获取到系统所有的句柄信息。</p><pre style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;font-size: 1em;line-height: 1.2em;font-size: 0.75em;margin: 1.2em 0px;"><code style="white-space:pre-wrap;font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;background-color: rgb(248, 248, 248);overflow: auto;border-radius: 3px;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 0.5em 0.7em;display: block !important;">typedef struct _SYSTEM_HANDLE_TABLE_ENTRY_INFO<br/>{<br/>    USHORT UniqueProcessId;//所属进程<br/>    USHORT CreatorBackTraceIndex;<br/>    UCHAR ObjectTypeIndex;<br/>    UCHAR HandleAttributes;<br/>    USHORT HandleValue; //句柄<br/>    PVOID Object;<br/>    ULONG GrantedAccess;<br/>} SYSTEM_HANDLE_TABLE_ENTRY_INFO, *PSYSTEM_HANDLE_TABLE_ENTRY_INFO;<br/>typedef struct _SYSTEM_HANDLE_INFORMATION<br/>{<br/>    ULONG NumberOfHandles;<br/>    SYSTEM_HANDLE_TABLE_ENTRY_INFO Handles[1];<br/>} SYSTEM_HANDLE_INFORMATION, *PSYSTEM_HANDLE_INFORMATION;</code></pre><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">既然知道了方法，下面就开始枚举所有句柄，找到我们被占用的文件的进程信息。</p><pre style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;font-size: 1em;line-height: 1.2em;font-size: 0.75em;margin: 1.2em 0px;"><code style="white-space:pre-wrap;font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;background-color: rgb(248, 248, 248);overflow: auto;border-radius: 3px;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 0.5em 0.7em;display: block !important;">Status = ZwQuerySystemInformation(SystemHandleInformation,<br/>            Information,<br/>            Length,<br/>            &amp;ReturnLength);<br/>for (i = 0; i &lt; Information-&gt;NumberOfHandles; i++) {<br/>    if (Information-&gt;Handles[i].UniqueProcessId != CurrentProcessId) {//不是当前进程<br/>        Status = ZwQueryObject(TargetHandle, ObjectTypeInformation, &amp;TypeInfo, sizeof(TypeInfo), NULL);<br/>        RtlInitUnicodeString(&amp;TargetType, L&#34;File&#34;);<br/>        if (!RtlEqualUnicodeString(&amp;TypeInfo.Info.TypeName, &amp;TargetType, FALSE)) {<br/>            goto __next;<br/>        }<br/>        Status = ZwQueryObject(TargetHandle, ObjectNameInformation, &amp;NameInfo, sizeof(NameInfo), NULL);<br/>        if (RtlEqualUnicodeString(&amp;NameInfo.Info.Name, &amp;FileName, FALSE)) {<br/>            printf(&#34;在进程(%d)发现文件占用：(%x) %wZ\n&#34;,<br/>                    ProcessId,<br/>                    Information-&gt;Handles[i].HandleValue,<br/>                    &amp;NameInfo.Info.Name);<br/>        }<br/>    }<br/>}</code></pre><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">ZwQuerySystemInformation获取到所有句柄信息，通过循环枚举Information-&gt;Handles，找到句柄类型属于File，路径是目标文件的进程。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">ZwQueryObject传入ObjectTypeInformation可以获取句柄类型，ZwQueryObject传入ObjectNameInformation可以获取文件路径。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">如此两个条件的对比，就能让我们找到占用文件的进程了。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">是不是感觉还挺简单，不复杂嘛。</p><h1 style="margin: 1.3em 0px 1em;padding: 0px;font-weight: bold;font-size: 1.4em;border-bottom: 1px solid rgb(221, 221, 221);">坑一：ZwQueryObject</h1><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">前面提到，每个进程都有自己的句柄表，所以ZwQuerySystemInformation枚举拿到的句柄并不能直接使用，还需要复制一份到本进程才有效。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">系统也提供了API叫做DuplicateHandle:</p><pre style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;font-size: 1em;line-height: 1.2em;font-size: 0.75em;margin: 1.2em 0px;"><code style="white-space:pre-wrap;font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;background-color: rgb(248, 248, 248);overflow: auto;border-radius: 3px;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 0.5em 0.7em;display: block !important;">BOOL DuplicateHandle(<br/>  HANDLE   hSourceProcessHandle,<br/>  HANDLE   hSourceHandle,<br/>  HANDLE   hTargetProcessHandle,<br/>  LPHANDLE lpTargetHandle,<br/>  DWORD    dwDesiredAccess,<br/>  BOOL     bInheritHandle,<br/>  DWORD    dwOptions<br/>);<br/>DuplicateHandle(hSrcProc, Information-&gt;Handles[i].HandleValue, hCurProc, TargetHandle, ...);</code></pre><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">上面我们使用的TargetHandle就是通过复制获取的。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">这个地方并不是坑，而是在通过ZwQueryObject获取句柄对应的文件路径时，会发生阻塞，导致程序卡死无法继续运行。</p><pre style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;font-size: 1em;line-height: 1.2em;font-size: 0.75em;margin: 1.2em 0px;"><code style="white-space:pre-wrap;font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;background-color: rgb(248, 248, 248);overflow: auto;border-radius: 3px;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 0.5em 0.7em;display: block !important;">0: kd&gt; kv<br/> # ChildEBP RetAddr  Args to Child<br/>00 d7fdb7cc 828aacda 00000000 00000000 a7d73040 nt!KiSwapContext+0x19 (FPO: [Uses EBP] [1,0,4])<br/>01 d7fdb86c 828aa358 d7fdb930 a7d73120 a7d73040 nt!KiSwapThread+0x4aa (FPO: [Non-Fpo])<br/>02 d7fdb8c8 828a9d67 00000000 00000000 00000000 nt!KiCommitThreadWait+0x128 (FPO: [Non-Fpo])<br/>03 d7fdb978 829298a3 8ff18afc 00000000 a7d73300 nt!KeWaitForSingleObject+0x1f7 (FPO: [Non-Fpo])<br/>04 d7fdb9a4 82c0759f 88c0e801 d7fdba18 8ff18ab0 nt!IopWaitForLockAlertable+0x3f (FPO: [Non-Fpo])<br/>05 d7fdb9cc 82d3f75c 88c0e800 a7d733f8 d7fdb9ef nt!IopWaitAndAcquireFileObjectLock+0x41 (FPO: [Non-Fpo])<br/>06 d7fdba1c 82bed31a 000001ee d7fdbb01 9a651dc0 nt!IopQueryXxxInformation+0x150f3e<br/>07 d7fdba9c 82becf65 00000000 007af7a4 00000210 nt!IopQueryNameInternal+0x31a (FPO: [Non-Fpo])<br/>08 d7fdbab8 82bece25 8ff18ab0 87ff2400 007af7a4 nt!IopQueryName+0x1b (FPO: [Non-Fpo])<br/>09 d7fdbb40 82bec6a6 00000210 d7fdbc04 d7fdbb01 nt!ObQueryNameStringMode+0x495 (FPO: [Non-Fpo])<br/>0a d7fdbbf8 829cce6b 8ff18ab0 00000000 007af7a4 nt!NtQueryObject+0x186 (FPO: [SEH])<br/>0b d7fdbbf8 77cd5ef0 8ff18ab0 00000000 007af7a4 nt!KiSystemServicePostCall (FPO: [0,3] TrapFrame @ d7fdbc14)</code></pre><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">经过一些简单的分析，如果文件被是同步（SYNCHRONIZE）打开的，内核会等待一下锁，等其他线程操作完成，本线程才能拿到所有权。</p><pre style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;font-size: 1em;line-height: 1.2em;font-size: 0.75em;margin: 1.2em 0px;"><code style="white-space:pre-wrap;font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;background-color: rgb(248, 248, 248);overflow: auto;border-radius: 3px;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 0.5em 0.7em;display: block !important;">//<br/>    // Make a special check here to determine whether this is a synchronous<br/>    // I/O operation.  If it is, then wait here until the file is owned by<br/>    // the current thread.  If this is not a (serialized) synchronous I/O<br/>    // operation, then initialize the local event.<br/>    //<br/>    if (FileObject-&gt;Flags &amp; FO_SYNCHRONOUS_IO) {<br/>        BOOLEAN interrupted;<br/>        if (!IopAcquireFastLock( FileObject )) {<br/>            status = IopAcquireFileObjectLock( FileObject,<br/>                                               Mode,<br/>                                               (BOOLEAN) ((FileObject-&gt;Flags &amp; FO_ALERTABLE_IO) != 0),<br/>                                               &amp;interrupted );<br/>            if (interrupted) {<br/>                ObDereferenceObject( FileObject );<br/>                return status;<br/>            }<br/>        }<br/>        KeClearEvent( &amp;FileObject-&gt;Event );<br/>        synchronousIo = TRUE;<br/>    }</code></pre><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">所以这里我们就需要通过线程和超时的方式来调用ZwQueryObject，让程序可以不阻塞正常运行。</p><pre style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;font-size: 1em;line-height: 1.2em;font-size: 0.75em;margin: 1.2em 0px;"><code style="white-space:pre-wrap;font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;background-color: rgb(248, 248, 248);overflow: auto;border-radius: 3px;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 0.5em 0.7em;display: block !important;">void<br/>QueryThread(<br/>    IN PQUERY_CONTEXT Context<br/>) {<br/>    Status = ZwQueryObject(TargetHandle, ObjectNameInformation, &amp;NameInfo, sizeof(NameInfo), NULL);<br/>}<br/>ThreadHandle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)QueryThread, Context, 0, NULL);<br/>Result = WaitForSingleObject(ThreadHandle, 1000); //等待1秒超时，线程退出<br/>TerminateThread(ThreadHandle, 0);<br/>CloseHandle(ThreadHandle);</code></pre><h1 style="margin: 1.3em 0px 1em;padding: 0px;font-weight: bold;font-size: 1.4em;border-bottom: 1px solid rgb(221, 221, 221);">坑二：文件Map</h1><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">解决上面的问题之后，我们基本就解决了文件占用的问题，大部分情况下，我们可以正常删除文件了。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">可是…</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">某些时候，我们要删除的文件并不是普通文件，可能是一个DLL、或者其他特殊文件。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">关闭所有占用的句柄后，依然无法删除文件，还是提示占用。</p><p style="text-align: center;"><img class="rich_pages js_insertlocalimg" data-backh="262" data-backw="448" data-ratio="0.5848214285714286" data-s="300,640" style="width: 100%;height: auto;" data-type="png" data-w="448" src="https://wechat2rss.xlab.app/img-proxy/?k=9bdd6aa4&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_png%2FqukewnktvYyMRq0zbYibzVPiaqOeO0IkZLXaFObTvV5OP5Iaic8WMzChIwfdG0HevPZHwZ9ufErIUhIPqiatt1ibYrA%2F640%3Fwx_fmt%3Dpng"/></p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">这可怎么办？</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">类似于DLL这种文件，进程在使用中，操作系统会映射一份内存到进程空间，此时并没有句柄与之对应。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">但是它却关联了文件的内核对象，专业术语说增加了一次文件对象的引用。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">我们要知道，为了能够安全删除一个文件，操作系统需要保证该文件的内核对象在两种引用计数上清零。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">一个是句柄引用计数，一个是对象引用计数。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">前面我们通过枚举句柄，将句柄引用计数清零。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">但是因为共享内存的原因，对象引用计数仍未清零，所以无法删除文件。</p><pre style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;font-size: 1em;line-height: 1.2em;font-size: 0.75em;margin: 1.2em 0px;"><code style="white-space:pre-wrap;font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;background-color: rgb(248, 248, 248);overflow: auto;border-radius: 3px;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 0.5em 0.7em;display: block !important;">0: kd&gt; !handle 48<br/>PROCESS fffffa801b7c6060<br/>    SessionId: 1  Cid: 0b70    Peb: 7efdf000  ParentCid: 0588<br/>    DirBase: 1bfea000  ObjectTable: fffff8a0029f27e0  HandleCount: 157.<br/>    Image: procexp.exe<br/>Handle table at fffff8a0029f27e0 with 157 entries in use<br/>0004: Object: fffffa801bdcca10  GrantedAccess: 00000003 Entry: fffff8a0020cc010<br/>Object: fffffa801bdcca10  Type: (fffffa8018dcfa30) File<br/>    ObjectHeader: fffffa801bdcc9e0 (new version)<br/>        HandleCount: 0//句柄引用计数  PointerCount: 1 //对象引用计数</code></pre><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">我们通过!vad俩看看内存map。</p><pre style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;font-size: 1em;line-height: 1.2em;font-size: 0.75em;margin: 1.2em 0px;"><code style="white-space:pre-wrap;font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;background-color: rgb(248, 248, 248);overflow: auto;border-radius: 3px;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 0.5em 0.7em;display: block !important;">0: kd&gt; !vad fffffa8019d34e00<br/>VAD           Level     Start       End Commit<br/>fffffa8019d34e00  0      1000      12ce      0 Mapped       READONLY           \Windows\Globalization\Sorting\SortDefault.nls<br/>0: kd&gt; dt _mmvad fffffa8019d34e00<br/>nt!_MMVAD<br/>   +0x000 u1               : &lt;unnamed-tag&gt;<br/>   +0x008 LeftChild        : (null) <br/>   +0x010 RightChild       : (null) <br/>   +0x018 StartingVpn      : 0x1000<br/>   +0x020 EndingVpn        : 0x12ce<br/>   +0x028 u                : &lt;unnamed-tag&gt;<br/>   +0x030 PushLock         : _EX_PUSH_LOCK<br/>   +0x038 u5               : &lt;unnamed-tag&gt;<br/>   +0x040 u2               : &lt;unnamed-tag&gt;<br/>   +0x048 Subsection       : 0xfffffa80`1b56ef90 _SUBSECTION<br/>   +0x048 MappedSubsection : 0xfffffa80`1b56ef90 _MSUBSECTION<br/>   +0x050 FirstPrototypePte : 0xfffff8a0`00b02000 _MMPTE<br/>   +0x058 LastContiguousPte : 0xfffff8a0`00b03670 _MMPTE<br/>   +0x060 ViewLinks        : _LIST_ENTRY [ 0xfffffa80`18ec81c0 - 0xfffffa80`18fcd190 ]<br/>   +0x070 VadsProcess      : 0xfffffa80`1b7c6061 _EPROCESS<br/>0: kd&gt; dt 0xfffffa80`1b56ef90 _SUBSECTION<br/>nt!_SUBSECTION<br/>   +0x000 ControlArea      : 0xfffffa80`1b56ef10 _CONTROL_AREA<br/>   +0x008 SubsectionBase   : 0xfffff8a0`00b02000 _MMPTE<br/>   +0x010 NextSubsection   : 0xfffffa80`193a0a60 _SUBSECTION<br/>   +0x018 PtesInSubsection : 0x2cf<br/>   +0x020 UnusedPtes       : 0<br/>   +0x020 GlobalPerSessionHead : (null) <br/>   +0x028 u                : &lt;unnamed-tag&gt;<br/>   +0x02c StartingSector   : 0<br/>   +0x030 NumberOfFullSectors : 0x2cf<br/>0: kd&gt; dt 0xfffffa80`1b56ef10 _CONTROL_AREA<br/>nt!_CONTROL_AREA<br/>   +0x000 Segment          : 0xfffff8a0`03b31fd0 _SEGMENT<br/>   +0x008 DereferenceList  : _LIST_ENTRY [ 0x00000000`00000000 - 0x00000000`00000000 ]<br/>   +0x018 NumberOfSectionReferences : 0<br/>   +0x020 NumberOfPfnReferences : 0x101<br/>   +0x028 NumberOfMappedViews : 0x2a<br/>   +0x030 NumberOfUserReferences : 0x2a<br/>   +0x038 u                : &lt;unnamed-tag&gt;<br/>   +0x03c FlushInProgressCount : 0<br/>   +0x040 FilePointer      : _EX_FAST_REF<br/>   +0x048 ControlAreaLock  : 0n0<br/>   +0x04c ModifiedWriteCount : 0<br/>   +0x04c StartingFrame    : 0<br/>   +0x050 WaitList         : (null) <br/>   +0x058 u2               : &lt;unnamed-tag&gt;<br/>   +0x068 LockedPages      : 1<br/>   +0x070 ViewList         : _LIST_ENTRY [ 0xfffffa80`1be91570 - 0xfffffa80`1abbe690 ]<br/>0: kd&gt; dx -id 0,0,fffffa801b7c6060 -r1 (*((ntkrnlmp!_EX_FAST_REF *)0xfffffa801b56ef50))<br/>(*((ntkrnlmp!_EX_FAST_REF *)0xfffffa801b56ef50))                 [Type: _EX_FAST_REF]<br/>    [+0x000] Object           : 0xfffffa801b61fa14 [Type: void *]<br/>    [+0x000 ( 3: 0)] RefCnt           : 0x4 [Type: unsigned __int64]<br/>    [+0x000] Value            : 0xfffffa801b61fa14 [Type: unsigned __int64]<br/>0: kd&gt; !object 0xfffffa801b61fa10<br/>Object: fffffa801b61fa10  Type: (fffffa8018dcfa30) File<br/>    ObjectHeader: fffffa801b61f9e0 (new version)<br/>    HandleCount: 0  PointerCount: 5<br/>    Directory Object: 00000000  Name: \Windows\Globalization\Sorting\SortDefault.nls {HarddiskVolume2}<br/>0: kd&gt; dt _file_object 0xfffffa801b61fa10<br/>nt!_FILE_OBJECT<br/>   +0x000 Type             : 0n5<br/>   +0x002 Size             : 0n216<br/>   +0x008 DeviceObject     : 0xfffffa80`19e9d530 _DEVICE_OBJECT<br/>   +0x010 Vpb              : 0xfffffa80`19eca270 _VPB<br/>   +0x018 FsContext        : 0xfffff8a0`00ad0140 Void<br/>   +0x020 FsContext2       : 0xfffff8a0`00ad0330 Void<br/>   +0x028 SectionObjectPointer : 0xfffffa80`1b61f808 _SECTION_OBJECT_POINTERS<br/>0: kd&gt; dx -id 0,0,fffffa801b7c6060 -r1 ((ntkrnlmp!_SECTION_OBJECT_POINTERS *)0xfffffa801b61f808)<br/>((ntkrnlmp!_SECTION_OBJECT_POINTERS *)0xfffffa801b61f808)                 : 0xfffffa801b61f808 [Type: _SECTION_OBJECT_POINTERS *]<br/>    [+0x000] DataSectionObject : 0xfffffa801b56ef10 [Type: void *] //其实就是前面的_mmvad-&gt;Subsection-&gt;ControlArea<br/>    [+0x008] SharedCacheMap   : 0x0 [Type: void *]<br/>    [+0x010] ImageSectionObject : 0x0 [Type: void *]</code></pre><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">SortDefault.nls是被映射到了进程中，通过_mmvad-&gt;Subsection-&gt;ControlArea-&gt;FilePointer我们可以一步步定位到它引用的文件对象。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;"><code style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;padding: 0px 0.3em;white-space: pre-wrap;border-width: 1px;border-style: solid;border-color: rgb(234, 234, 234);background-color: rgb(248, 248, 248);border-radius: 3px;display: inline;">!object 0xfffffa801b61fa10</code>看到确实是该文件，也可以通过fileobject-&gt;SectionObjectPointer-&gt;DataSectionObject找到对应的映射内存。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">如此我们初步理解了文件map导致文件占用无法删除文件的原理。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">下面我们就需要找到方法怎么解决这个问题。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">首先，需要枚举进程的虚拟内存，找到是否有我们需要查找的文件的map，然后对该进程有两种操作：</p><ol style="font-size: 0.75em;margin: 1.2em 0px;padding-left: 2em;" class="list-paddingleft-2"><li style="font-size: 0.875em;margin: 0.5em 0px;"><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;font-size: 0.875em;margin: 0.5em 0px !important;">非常暴力但是简单的方法，那就是直接关闭进程</p></li><li style="font-size: 0.875em;margin: 0.5em 0px;"><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;font-size: 0.875em;margin: 0.5em 0px !important;">或者unmap这块内存，解除对象引用计数（经过测试，未成功）</p></li></ol><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">如何枚举虚拟内存呢，使用ZwQueryVirtualMemory.</p><pre style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;font-size: 1em;line-height: 1.2em;font-size: 0.75em;margin: 1.2em 0px;"><code style="white-space:pre-wrap;font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;background-color: rgb(248, 248, 248);overflow: auto;border-radius: 3px;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 0.5em 0.7em;display: block !important;">NTSTATUS ZwQueryVirtualMemory(<br/>  _In_      HANDLE                   ProcessHandle,<br/>  _In_opt_  PVOID                    BaseAddress,<br/>  _In_      MEMORY_INFORMATION_CLASS MemoryInformationClass,<br/>  _Out_     PVOID                    MemoryInformation,<br/>  _In_      SIZE_T                   MemoryInformationLength,<br/>  _Out_opt_ PSIZE_T                  ReturnLength<br/>);<br/>//MemoryBasicInformation<br/>typedef struct _MEMORY_BASIC_INFORMATION {<br/>  PVOID  BaseAddress;<br/>  PVOID  AllocationBase;<br/>  ULONG  AllocationProtect;<br/>  USHORT PartitionId;<br/>  SIZE_T RegionSize;<br/>  ULONG  State;<br/>  ULONG  Protect;<br/>  ULONG  Type;<br/>} MEMORY_BASIC_INFORMATION, *PMEMORY_BASIC_INFORMATION;<br/>Type<br/>The type of pages in the region. The following types are defined.<br/>MEM_IMAGE 0x1000000 Indicates that the memory pages within the region are mapped into the view of an image section.<br/>MEM_MAPPED 0x40000  Indicates that the memory pages within the region are mapped into the view of a section.<br/>MEM_PRIVATE 0x20000 Indicates that the memory pages within the region are private (that is, not shared by other processes).</code></pre><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">从0地址开始，每次加一个页，获取内存信息，如果内存的type是MEM_IMAGE或者MEM_MAPPED，那么就是文件map，然后获取虚拟内存对应名字，判断是不是目标文件。</p><pre style="font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;font-size: 1em;line-height: 1.2em;font-size: 0.75em;margin: 1.2em 0px;"><code style="white-space:pre-wrap;font-size: 0.8em;font-family: Consolas, Inconsolata, Courier, monospace;margin: 0px 0.15em;background-color: rgb(248, 248, 248);overflow: auto;border-radius: 3px;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);padding: 0.5em 0.7em;display: block !important;">for (;;) {<br/>    Status = ZwQueryVirtualMemory(ProcessHandle, BaseAddress, MemoryBasicInformation,<br/>        &amp;MemoryInfo, sizeof(MemoryInfo), NULL);<br/>    if (MemoryInfo.Type == MEM_IMAGE ||  //image<br/>        MemoryInfo.Type == MEM_MAPPED) { //data<br/>            Status = ZwQueryVirtualMemory(ProcessHandle, BaseAddress, MemoryMappedFilenameInformation, &amp;Name, sizeof(Name), NULL);<br/>            if (RtlEqualUnicodeString(&amp;Name.u, &amp;TargetName, TRUE)) {<br/>                //找到目标文件<br/>                break;<br/>            }<br/>        }<br/>    }<br/>}</code></pre><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">找到目标进程后，关闭进程，轻松删除文件。</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;">（完）</p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;"><span style="font-size: 12px;"><strong><span style="font-size: 12px;color: rgb(178, 178, 178);">如果觉得内容还不错，请不吝点赞或在看，谢谢。</span></strong></span><br/></p><p style="font-size: 0.875em;margin: 0px 0px 1.2em !important;"><span style="font-size: 12px;">欢迎关注公众号：<strong>Anhkgg日记本</strong></span><br/></p>



<p><a href="2247483789">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=866abf8f&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzU4NjY5ODM3Nw%3D%3D%26mid%3D2247483789%26idx%3D1%26sn%3Deb22cffe84ba7f33f6ff36eef85f8cea%26subscene%3D0">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Thu, 14 Jan 2021 01:59:00 +0800</pubDate>
    </item>
    <item>
      <title>「日记」CMakeLists使用笔记</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzU4NjY5ODM3Nw==&amp;mid=2247483782&amp;idx=1&amp;sn=6c4a1edd0cfe9c8d69366cca29295864</link>
      <description>cmake</description>
      <content:encoded><![CDATA[<p>
<span></span> <span>2019-03-03 15:16</span> <span style="display: inline-block;"></span>
</p>

<p>cmake</p>
<p></p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=de7e1269&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FqukewnktvYwEyW9cFDbicVvrk9A5u5M2fPsqwlbggHGKicAlTAS9ibZY7fn5utgHYaYFDw69FrBFys6yrv77Zkibxw%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<blockquote style="background: var(--vscode-textBlockQuote-background);" helvetica="helvetica" initial="initial" px="px" normal="normal" none="none" start="start" sans-serif="sans-serif" freesans="freesans" arial="arial" ui="ui" segoe="segoe" neue="neue"><p style="margin-top: 0px;margin-bottom: 0px;">「日记」CMakeLists使用笔记<br/>by anhkgg<br/>2019年3月3日</p></blockquote><p style="margin-top: 0px;margin-bottom: 16px;color: rgb(51, 51, 51);" helvetica="helvetica" initial="initial" px="px" normal="normal" none="none" start="start" sans-serif="sans-serif" freesans="freesans" arial="arial" ui="ui" segoe="segoe" neue="neue" rgb="rgb"><br/></p><p style="margin-top: 0px;margin-bottom: 16px;color: rgb(51, 51, 51);" helvetica="helvetica" initial="initial" px="px" normal="normal" none="none" start="start" sans-serif="sans-serif" freesans="freesans" arial="arial" ui="ui" segoe="segoe" neue="neue" rgb="rgb">最近用了一下cmake，虽然还不熟练，但是感觉比Makefile更简单，并且是跨平台的。</p><p style="margin-top: 0px;margin-bottom: 16px;color: rgb(51, 51, 51);" helvetica="helvetica" initial="initial" px="px" normal="normal" none="none" start="start" sans-serif="sans-serif" freesans="freesans" arial="arial" ui="ui" segoe="segoe" neue="neue" rgb="rgb">这里大概总结一下常用语法。</p><p style="margin-top: 0px;margin-bottom: 16px;color: rgb(51, 51, 51);" helvetica="helvetica" initial="initial" px="px" normal="normal" none="none" start="start" sans-serif="sans-serif" freesans="freesans" arial="arial" ui="ui" segoe="segoe" neue="neue" rgb="rgb">首先，<code style="color: rgb(0, 0, 0);" courier="courier" px="px" rgb="rgb" important="important" em="em" monospace="monospace" new="new">cmake</code>命令可以全大写或者全小写。</p><p class="sync-line" style="margin: 0px;color: rgb(51, 51, 51);" data-line="10" helvetica="helvetica" initial="initial" px="px" normal="normal" none="none" start="start" sans-serif="sans-serif" freesans="freesans" arial="arial" ui="ui" segoe="segoe" neue="neue" rgb="rgb"><br/></p><h3 class="mume-header" style="line-height: 1.2;margin-top: 1em;margin-bottom: 16px;color: rgb(0, 0, 0);font-size: 1.5em;font-weight: 600;" helvetica="helvetica" initial="initial" px="px" normal="normal" none="none" start="start" sans-serif="sans-serif" freesans="freesans" arial="arial" ui="ui" segoe="segoe" neue="neue" rgb="rgb">最简单的</h3><p class="sync-line" style="margin: 0px;color: rgb(51, 51, 51);" data-line="12" helvetica="helvetica" initial="initial" px="px" normal="normal" none="none" start="start" sans-serif="sans-serif" freesans="freesans" arial="arial" ui="ui" segoe="segoe" neue="neue" rgb="rgb"><br/></p><pre class="language-" style="background: rgb(245, 245, 245);padding: 0.8em;border-radius: 3px;border: rgb(214, 214, 214);text-align: left;color: rgb(51, 51, 51);text-transform: none;line-height: 1.4;text-indent: 0px;letter-spacing: normal;overflow: auto;" data-info="" data-role="codeBlock" liberation="liberation" px="px" normal="normal" important="important" em="em" pre="pre" mono="mono"><code style="background: none;margin: 0px;padding: 0px;border-radius: 3px;border: 0px;color: rgb(0, 0, 0);line-height: inherit;overflow: initial;" courier="courier" initial="initial" normal="normal" important="important" em="em" new="new" pre="pre" inline="inline">//test.cpp<br/>#include &lt;stdio.h&gt;<br/>int main()<br/>{<br/>    printf(&#34;hello CMakeLists\n&#34;);<br/>    return 0;<br/>}<br/></code></pre><p style="margin-top: 0px;margin-bottom: 16px;color: rgb(51, 51, 51);" helvetica="helvetica" initial="initial" px="px" normal="normal" none="none" start="start" sans-serif="sans-serif" freesans="freesans" arial="arial" ui="ui" segoe="segoe" neue="neue" rgb="rgb">编写<code style="color: rgb(0, 0, 0);" courier="courier" px="px" rgb="rgb" important="important" em="em" monospace="monospace" new="new">CMakeLists.txt</code></p><p class="sync-line" style="margin: 0px;color: rgb(51, 51, 51);" data-line="24" helvetica="helvetica" initial="initial" px="px" normal="normal" none="none" start="start" sans-serif="sans-serif" freesans="freesans" arial="arial" ui="ui" segoe="segoe" neue="neue" rgb="rgb"><br/></p><pre class="language-" style="background: rgb(245, 245, 245);padding: 0.8em;border-radius: 3px;border: rgb(214, 214, 214);text-align: left;color: rgb(51, 51, 51);text-transform: none;line-height: 1.4;text-indent: 0px;letter-spacing: normal;overflow: auto;" data-info="" data-role="codeBlock" liberation="liberation" px="px" normal="normal" important="important" em="em" pre="pre" mono="mono"><code style="background: none;margin: 0px;padding: 0px;border-radius: 3px;border: 0px;color: rgb(0, 0, 0);line-height: inherit;overflow: initial;" courier="courier" initial="initial" normal="normal" important="important" em="em" new="new" pre="pre" inline="inline"># CMake 最低版本号要求<br/>cmake_minimum_required (VERSION 2.8)<br/># 项目信息<br/>project (test)<br/># 查找当前目录下的所有源文件<br/># 并将名称保存到 DIR_SRCS 变量<br/>aux_source_directory(. DIR_SRCS)<br/># 指定生成目标<br/>add_executable(test ${DIR_SRCS})<br/></code></pre><p style="margin-top: 0px;margin-bottom: 16px;color: rgb(51, 51, 51);" helvetica="helvetica" initial="initial" px="px" normal="normal" none="none" start="start" sans-serif="sans-serif" freesans="freesans" arial="arial" ui="ui" segoe="segoe" neue="neue" rgb="rgb">编译</p><p class="sync-line" style="margin: 0px;color: rgb(51, 51, 51);" data-line="41" helvetica="helvetica" initial="initial" px="px" normal="normal" none="none" start="start" sans-serif="sans-serif" freesans="freesans" arial="arial" ui="ui" segoe="segoe" neue="neue" rgb="rgb"><br/></p><pre class="language-" style="background: rgb(245, 245, 245);padding: 0.8em;border-radius: 3px;border: rgb(214, 214, 214);text-align: left;color: rgb(51, 51, 51);text-transform: none;line-height: 1.4;text-indent: 0px;letter-spacing: normal;overflow: auto;" data-info="" data-role="codeBlock" liberation="liberation" px="px" normal="normal" important="important" em="em" pre="pre" mono="mono"><code style="background: none;margin: 0px;padding: 0px;border-radius: 3px;border: 0px;color: rgb(0, 0, 0);line-height: inherit;overflow: initial;" courier="courier" initial="initial" normal="normal" important="important" em="em" new="new" pre="pre" inline="inline">mkdir build<br/>cd build<br/>cmake ..<br/>make<br/></code></pre><p class="sync-line" style="margin: 0px;color: rgb(51, 51, 51);text-transform: none;text-indent: 0px;letter-spacing: normal;" data-line="48" helvetica="helvetica" px="px" normal="normal" ui="ui" neue="neue" rgb="rgb"><br/></p><h3 class="mume-header" style="line-height: 1.2;margin-top: 1em;margin-bottom: 16px;color: rgb(0, 0, 0);font-size: 1.5em;font-weight: 600;" helvetica="helvetica" initial="initial" px="px" normal="normal" none="none" start="start" sans-serif="sans-serif" freesans="freesans" arial="arial" ui="ui" segoe="segoe" neue="neue" rgb="rgb">静态库</h3><p class="sync-line" style="margin: 0px;color: rgb(51, 51, 51);" data-line="50" helvetica="helvetica" initial="initial" px="px" normal="normal" none="none" start="start" sans-serif="sans-serif" freesans="freesans" arial="arial" ui="ui" segoe="segoe" neue="neue" rgb="rgb"><br/></p><pre class="language-" style="background: rgb(245, 245, 245);padding: 0.8em;border-radius: 3px;border: rgb(214, 214, 214);text-align: left;color: rgb(51, 51, 51);text-transform: none;line-height: 1.4;text-indent: 0px;letter-spacing: normal;overflow: auto;" data-info="" data-role="codeBlock" liberation="liberation" px="px" normal="normal" important="important" em="em" pre="pre" mono="mono"><code style="background: none;margin: 0px;padding: 0px;border-radius: 3px;border: 0px;color: rgb(0, 0, 0);line-height: inherit;overflow: initial;" courier="courier" initial="initial" normal="normal" important="important" em="em" new="new" pre="pre" inline="inline">//testlib.cpp<br/>int add(int a, int b)<br/>{<br/>    return a+b;<br/>}<br/></code></pre><p class="sync-line" style="margin: 0px;color: rgb(51, 51, 51);text-transform: none;text-indent: 0px;letter-spacing: normal;" data-line="59" helvetica="helvetica" px="px" normal="normal" ui="ui" neue="neue" rgb="rgb"><br/></p><pre class="language-" style="background: rgb(245, 245, 245);padding: 0.8em;border-radius: 3px;border: rgb(214, 214, 214);text-align: left;color: rgb(51, 51, 51);text-transform: none;line-height: 1.4;text-indent: 0px;letter-spacing: normal;overflow: auto;" data-info="" data-role="codeBlock" liberation="liberation" px="px" normal="normal" important="important" em="em" pre="pre" mono="mono"><code style="background: none;margin: 0px;padding: 0px;border-radius: 3px;border: 0px;color: rgb(0, 0, 0);line-height: inherit;overflow: initial;" courier="courier" initial="initial" normal="normal" important="important" em="em" new="new" pre="pre" inline="inline"># CMake 最低版本号要求<br/>cmake_minimum_required (VERSION 2.8)<br/># 项目信息<br/>project (testlib)<br/># 查找当前目录下的所有源文件<br/># 并将名称保存到 DIR_SRCS 变量<br/>aux_source_directory(. DIR_SRCS)<br/># 指定生成目标<br/>add_library(testlib STATIC ${DIR_SRCS})</code></pre><pre class="language-" style="background: rgb(245, 245, 245);padding: 0.8em;border-radius: 3px;border: rgb(214, 214, 214);text-align: left;color: rgb(51, 51, 51);text-transform: none;line-height: 1.4;text-indent: 0px;letter-spacing: normal;overflow: auto;" data-info="" data-role="codeBlock" liberation="liberation" px="px" normal="normal" important="important" em="em" pre="pre" mono="mono"><code style="background: none;margin: 0px;padding: 0px;border-radius: 3px;border: 0px;color: rgb(0, 0, 0);line-height: inherit;overflow: initial;" courier="courier" initial="initial" normal="normal" important="important" em="em" new="new" pre="pre" inline="inline">➜  build make<br/>Scanning dependencies of target testlib<br/>[ 50%] Building CXX object CMakeFiles/testlib.dir/testlib.cpp.o<br/>[100%] Linking CXX static library libtestlib.a<br/>[100%] Built target testlib</code></pre><p style="margin-top: 0px;margin-bottom: 16px;color: rgb(51, 51, 51);" helvetica="helvetica" initial="initial" px="px" normal="normal" none="none" start="start" sans-serif="sans-serif" freesans="freesans" arial="arial" ui="ui" segoe="segoe" neue="neue" rgb="rgb">链接静态库</p><p class="sync-line" style="margin: 0px;color: rgb(51, 51, 51);" data-line="84" helvetica="helvetica" initial="initial" px="px" normal="normal" none="none" start="start" sans-serif="sans-serif" freesans="freesans" arial="arial" ui="ui" segoe="segoe" neue="neue" rgb="rgb"><br/></p><pre class="language-" style="background: rgb(245, 245, 245);padding: 0.8em;border-radius: 3px;border: rgb(214, 214, 214);text-align: left;color: rgb(51, 51, 51);text-transform: none;line-height: 1.4;text-indent: 0px;letter-spacing: normal;overflow: auto;" data-info="" data-role="codeBlock" liberation="liberation" px="px" normal="normal" important="important" em="em" pre="pre" mono="mono"><code style="background: none;margin: 0px;padding: 0px;border-radius: 3px;border: 0px;color: rgb(0, 0, 0);line-height: inherit;overflow: initial;" courier="courier" initial="initial" normal="normal" important="important" em="em" new="new" pre="pre" inline="inline">//test.cpp<br/>#include &lt;stdio.h&gt;<br/>int add(int a, int b);<br/>int main()<br/>{<br/>    printf(&#34;1 + 2 = %d\n&#34;, add(1, 2));<br/>    return 0;<br/>}<br/></code></pre><p class="sync-line" style="margin: 0px;color: rgb(51, 51, 51);text-transform: none;text-indent: 0px;letter-spacing: normal;" data-line="95" helvetica="helvetica" px="px" normal="normal" ui="ui" neue="neue" rgb="rgb"><br/></p><pre class="language-" style="background: rgb(245, 245, 245);padding: 0.8em;border-radius: 3px;border: rgb(214, 214, 214);text-align: left;color: rgb(51, 51, 51);text-transform: none;line-height: 1.4;text-indent: 0px;letter-spacing: normal;overflow: auto;" data-info="" data-role="codeBlock" liberation="liberation" px="px" normal="normal" important="important" em="em" pre="pre" mono="mono"><code style="background: none;margin: 0px;padding: 0px;border-radius: 3px;border: 0px;color: rgb(0, 0, 0);line-height: inherit;overflow: initial;" courier="courier" initial="initial" normal="normal" important="important" em="em" new="new" pre="pre" inline="inline"># CMake 最低版本号要求<br/>cmake_minimum_required (VERSION 2.8)<br/># 项目信息<br/>project (test)<br/># 查找当前目录下的所有源文件<br/># 并将名称保存到 DIR_SRCS 变量<br/>aux_source_directory(. DIR_SRCS)<br/># 指定生成目标<br/>add_executable(test ${DIR_SRCS})<br/>find_library(<br/>    TESTLIB testlib<br/>    PATHS ./build)<br/>message(${TESTLIB})<br/>target_link_libraries (test ${TESTLIB})</code></pre><pre class="language-" style="background: rgb(245, 245, 245);padding: 0.8em;border-radius: 3px;border: rgb(214, 214, 214);text-align: left;color: rgb(51, 51, 51);text-transform: none;line-height: 1.4;text-indent: 0px;letter-spacing: normal;overflow: auto;" data-info="" data-role="codeBlock" liberation="liberation" px="px" normal="normal" pre="pre" mono="mono"><p><br/></p></pre><p class="sync-line" style="margin: 0px;color: rgb(51, 51, 51);text-transform: none;text-indent: 0px;letter-spacing: normal;" data-line="118" helvetica="helvetica" px="px" normal="normal" ui="ui" neue="neue" rgb="rgb"><br/></p><h3 class="mume-header" style="line-height: 1.2;margin-top: 1em;margin-bottom: 16px;color: rgb(0, 0, 0);font-size: 1.5em;font-weight: 600;" helvetica="helvetica" initial="initial" px="px" normal="normal" none="none" start="start" sans-serif="sans-serif" freesans="freesans" arial="arial" ui="ui" segoe="segoe" neue="neue" rgb="rgb">动态库</h3><p class="sync-line" style="margin: 0px;color: rgb(51, 51, 51);" data-line="120" helvetica="helvetica" initial="initial" px="px" normal="normal" none="none" start="start" sans-serif="sans-serif" freesans="freesans" arial="arial" ui="ui" segoe="segoe" neue="neue" rgb="rgb"><br/></p><pre class="language-" style="background: rgb(245, 245, 245);padding: 0.8em;border-radius: 3px;border: rgb(214, 214, 214);text-align: left;color: rgb(51, 51, 51);text-transform: none;line-height: 1.4;text-indent: 0px;letter-spacing: normal;overflow: auto;" data-info="" data-role="codeBlock" liberation="liberation" px="px" normal="normal" important="important" em="em" pre="pre" mono="mono"><code style="background: none;margin: 0px;padding: 0px;border-radius: 3px;border: 0px;color: rgb(0, 0, 0);line-height: inherit;overflow: initial;" courier="courier" initial="initial" normal="normal" important="important" em="em" new="new" pre="pre" inline="inline"># CMake 最低版本号要求<br/>cmake_minimum_required (VERSION 2.8)<br/># 项目信息<br/>project (testlib)<br/># 查找当前目录下的所有源文件<br/># 并将名称保存到 DIR_SRCS 变量<br/>aux_source_directory(. DIR_SRCS)<br/># 指定生成目标<br/>add_library(testlib SHARED ${DIR_SRCS})<br/></code></pre><p class="sync-line" style="margin: 0px;color: rgb(51, 51, 51);text-transform: none;text-indent: 0px;letter-spacing: normal;" data-line="135" helvetica="helvetica" px="px" normal="normal" ui="ui" neue="neue" rgb="rgb"><br/></p><pre class="language-" style="background: rgb(245, 245, 245);padding: 0.8em;border-radius: 3px;border: rgb(214, 214, 214);text-align: left;color: rgb(51, 51, 51);text-transform: none;line-height: 1.4;text-indent: 0px;letter-spacing: normal;overflow: auto;" data-info="" data-role="codeBlock" liberation="liberation" px="px" normal="normal" pre="pre" mono="mono"><code style="background: none;margin: 0px;padding: 0px;border-radius: 3px;border: 0px;color: rgb(0, 0, 0);line-height: inherit;overflow: initial;" courier="courier" initial="initial" normal="normal" new="new" pre="pre" inline="inline"><span style="font-size:2px;"></span></code></pre><pre class="language-" style="background: rgb(245, 245, 245);padding: 0.8em;border-radius: 3px;border: rgb(214, 214, 214);text-align: left;color: rgb(51, 51, 51);text-transform: none;line-height: 1.4;text-indent: 0px;letter-spacing: normal;overflow: auto;" data-info="" data-role="codeBlock" liberation="liberation" px="px" normal="normal" important="important" em="em" pre="pre" mono="mono"><code style="background: none;margin: 0px;padding: 0px;border-radius: 3px;border: 0px;color: rgb(0, 0, 0);line-height: inherit;overflow: initial;" courier="courier" initial="initial" normal="normal" important="important" em="em" new="new" pre="pre" inline="inline">[ 33%] Building CXX object CMakeFiles/testlib.dir/test.cpp.o<br/>[ 66%] Building CXX object CMakeFiles/testlib.dir/testlib.cpp.o<br/>[100%] Linking CXX shared library libtestlib.so<br/>[100%] Built target testlib</code></pre><h3 class="mume-header" style="line-height: 1.2;margin-top: 1em;margin-bottom: 16px;color: rgb(0, 0, 0);font-size: 1.5em;font-weight: 600;" helvetica="helvetica" initial="initial" px="px" normal="normal" none="none" start="start" sans-serif="sans-serif" freesans="freesans" arial="arial" ui="ui" segoe="segoe" neue="neue" rgb="rgb">安装</h3><p class="sync-line" style="margin: 0px;color: rgb(51, 51, 51);" data-line="144" helvetica="helvetica" initial="initial" px="px" normal="normal" none="none" start="start" sans-serif="sans-serif" freesans="freesans" arial="arial" ui="ui" segoe="segoe" neue="neue" rgb="rgb"><br/></p><pre class="language-" style="background: rgb(245, 245, 245);padding: 0.8em;border-radius: 3px;border: rgb(214, 214, 214);text-align: left;color: rgb(51, 51, 51);text-transform: none;line-height: 1.4;text-indent: 0px;letter-spacing: normal;overflow: auto;" data-info="" data-role="codeBlock" liberation="liberation" px="px" normal="normal" important="important" em="em" pre="pre" mono="mono"><code style="background: none;margin: 0px;padding: 0px;border-radius: 3px;border: 0px;color: rgb(0, 0, 0);line-height: inherit;overflow: initial;" courier="courier" initial="initial" normal="normal" important="important" em="em" new="new" pre="pre" inline="inline"># 指定 编译目标 的安装路径<br/>install (TARGETS test DESTINATION bin)<br/></code></pre><p class="sync-line" style="margin: 0px;color: rgb(51, 51, 51);text-transform: none;text-indent: 0px;letter-spacing: normal;" data-line="149" helvetica="helvetica" px="px" normal="normal" ui="ui" neue="neue" rgb="rgb"><br/></p><pre class="language-" style="background: rgb(245, 245, 245);padding: 0.8em;border-radius: 3px;border: rgb(214, 214, 214);text-align: left;color: rgb(51, 51, 51);text-transform: none;line-height: 1.4;text-indent: 0px;letter-spacing: normal;overflow: auto;" data-info="" data-role="codeBlock" liberation="liberation" px="px" normal="normal" important="important" em="em" pre="pre" mono="mono"><code style="background: none;margin: 0px;padding: 0px;border-radius: 3px;border: 0px;color: rgb(0, 0, 0);line-height: inherit;overflow: initial;" courier="courier" initial="initial" normal="normal" important="important" em="em" new="new" pre="pre" inline="inline">make install</code></pre><h3 class="mume-header" style="line-height: 1.2;margin-top: 1em;margin-bottom: 16px;color: rgb(0, 0, 0);font-size: 1.5em;font-weight: 600;" helvetica="helvetica" initial="initial" px="px" normal="normal" none="none" start="start" sans-serif="sans-serif" freesans="freesans" arial="arial" ui="ui" segoe="segoe" neue="neue" rgb="rgb">其他命令</h3><p class="sync-line" style="margin: 0px;color: rgb(51, 51, 51);" data-line="156" helvetica="helvetica" initial="initial" px="px" normal="normal" none="none" start="start" sans-serif="sans-serif" freesans="freesans" arial="arial" ui="ui" segoe="segoe" neue="neue" rgb="rgb"><br/></p><pre class="language-" style="background: rgb(245, 245, 245);padding: 0.8em;border-radius: 3px;border: rgb(214, 214, 214);text-align: left;color: rgb(51, 51, 51);text-transform: none;line-height: 1.4;text-indent: 0px;letter-spacing: normal;overflow: auto;" data-info="" data-role="codeBlock" liberation="liberation" px="px" normal="normal" important="important" em="em" pre="pre" mono="mono"><code style="background: none;margin: 0px;padding: 0px;border-radius: 3px;border: 0px;color: rgb(0, 0, 0);line-height: inherit;overflow: initial;" courier="courier" initial="initial" normal="normal" important="important" em="em" new="new" pre="pre" inline="inline">include_directories：指定头文件的搜索路径，相当于指定gcc的-I参数<br/>&gt;&gt; include_directories (${HELLO_SOURCE_DIR}/Hello)  #增加Hello为include目录<br/>link_directories：动态链接库或静态链接库的搜索路径，相当于gcc的-L参数<br/>       &gt;&gt; link_directories (${HELLO_BINARY_DIR}/Hello)     #增加Hello为link目录<br/>add_subdirectory：包含子目录<br/>       &gt;&gt; add_subdirectory (Hello)<br/>add_executable：编译可执行程序，指定编译，好像也可以添加.o文件<br/>       &gt;&gt; add_executable (helloDemo demo.cxx demo_b.cxx)   #将cxx编译成可执行文件——<br/>add_custom_target:<br/>message( status|fatal_error, “message”):<br/>set_target_properties( ... ): lots of properties... OUTPUT_NAME, VERSION, ....<br/>link_libraries( lib1 lib2 ...): All targets link with the same set of libs<br/>set environment variable，设置环境变量，编译用到的源文件全部都要放到这里，否则编译能够通过，但是执行的时候会出现各种问题，比如&#34;symbol lookup error xxxxx , undefined symbol&#34;<br/>SET(TEST_MATH<br/> ${DIR_SRCS}<br/>)<br/></code></pre><p style="margin-top: 0px;margin-bottom: 16px;color: rgb(51, 51, 51);" helvetica="helvetica" initial="initial" px="px" normal="normal" none="none" start="start" sans-serif="sans-serif" freesans="freesans" arial="arial" ui="ui" segoe="segoe" neue="neue" rgb="rgb"><br/></p><p style="margin-top: 0px;margin-bottom: 16px;color: rgb(51, 51, 51);" helvetica="helvetica" initial="initial" px="px" normal="normal" none="none" start="start" sans-serif="sans-serif" freesans="freesans" arial="arial" ui="ui" segoe="segoe" neue="neue" rgb="rgb"><a href="https://www.jianshu.com/p/5a63414f0691" target="_blank">https://www.jianshu.com/p/5a63414f0691</a><br/><a href="https://www.cnblogs.com/cv-pr/p/6206921.html" target="_blank">https://www.cnblogs.com/cv-pr/p/6206921.html</a><br/><a href="https://www.cnblogs.com/lidabo/p/7359422.html" target="_blank">https://www.cnblogs.com/lidabo/p/7359422.html</a><br/><a href="https://www.hahack.com/codes/cmake/" target="_blank">https://www.hahack.com/codes/cmake/</a></p><p><br/></p>



<p><a href="2247483782">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=286898ab&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzU4NjY5ODM3Nw%3D%3D%26mid%3D2247483782%26idx%3D1%26sn%3D6c4a1edd0cfe9c8d69366cca29295864%26subscene%3D0">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Sun, 03 Mar 2019 15:16:00 +0800</pubDate>
    </item>
    <item>
      <title>「日记」迅雷界面库一览</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzU4NjY5ODM3Nw==&amp;mid=2247483774&amp;idx=1&amp;sn=6ff8c3438c319a0ab46d1c46fb723b1e</link>
      <description>看bolt，破thunder</description>
      <content:encoded><![CDATA[<p>
原创 <span>Anhkgg</span> <span>2018-12-26 00:00</span> <span style="display: inline-block;"></span>
</p>

<p>看bolt，破thunder</p>
<p></p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=7a3bfaa5&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FqukewnktvYxibhSD33QUJQsNuRWfjun5T6CswmFfwZERmVgpbjdmW7iaecR6cNYia7AyVEA4TpXhr3iadxf4hFJbiaw%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<p><span style="background-color: transparent;color: rgb(255, 104, 39);">by <span style="color: rgb(255, 104, 39);font-size: 14px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;margin-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;padding-top: 0px;"><strong style="margin-bottom: 0px;margin-left: 0px;margin-right: 0px;margin-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;padding-top: 0px;">Anhkgg</strong> | 2018年12月16日</span></span><span style="background-color: transparent;color: rgb(0, 0, 0);"> | </span><span style="background-color: rgb(178, 178, 178);color: rgb(0, 0, 0);"><strong style="margin-bottom: 0px;margin-left: 0px;margin-right: 0px;margin-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;padding-top: 0px;">078/100</strong></span></p><p><br/></p><p><span style="font-size: 14px;">这篇其实应该几天前就写了的，不过耽搁了，现在补上。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">已经忘了那天怎么突然想起去搜索了一下&#34;迅雷API&#34;，然后看到了&#34;迅雷7应用开发在线文档&#34;。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">地址是：<a href="http://xldoc.xl7.xunlei.com/" target="_blank">http://xldoc.xl7.xunlei.com/</a></span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">其中&#34;BOLT界面引擎&#34;真的是让我对迅雷的技术人员刮目相看，虽然我第一次听说这个界面库。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">虽然我好像要找到的是&#34;迅雷下载开放引擎&#34;，确实有，但是好像过时，并未更新开放，现在已经不能使用。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">我对bolt前前后后大致了解了一下，对原理、如何使用有了一定的印象。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">为什么我会突然对此感兴趣呢？因为我其实一直像破一下迅雷，比如去广告、去浏览器窗口页、高速（离线）下载等等。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">但确实比较难，一直没下手，这次看到bolt真的是眼睛一亮。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">因为最新的迅雷依然是bolt开发，虽然内部使用的bolt已经更新，但有迹可循了。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">blot大致来说（我的粗略理解）：</span></p><p><span style="font-size: 14px;"><br/>1. 通过ui树来组织界面，提供常用的ui元对象。<br/>2. 使用xml来定义界面元素，lua来完成界面逻辑。<br/>3. 更多功能通过lua调用c接口来完成。<br/>4. xml和lua通过打包加密发布为xar文件<br/>5. bolt sdk提供了几个dll，XLFSIO.dll去解密xar<br/>6. bolt还有字节的绘图引擎（位图、文本、矢量），据说比gdi好</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">更多细节还需要继续看文档学习，目前大致了解这些。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">bolt究竟如何不好说，不过确实已经有很多产品在使用，并且迅雷自己的产品也在使用，应该是比较完善成熟的一套东西了。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">另外一个很有名的界面库duilib，也有很多公司再使用，比如360、腾讯、百度等等，并且开源，其实有时间是很有研究的价值的。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">不管如何，我都是非常佩服写界面的同志的，更何况是自己开发界面引擎的牛牛。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">不过我此时的重点不过使用bolt，而在于破迅雷，希望再后面的研究中能够有大大的帮助。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">（完）</span></p><p><br/></p>



<p><a href="2247483774">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=2f67c0ce&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzU4NjY5ODM3Nw%3D%3D%26mid%3D2247483774%26idx%3D1%26sn%3D6ff8c3438c319a0ab46d1c46fb723b1e%26subscene%3D0">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Wed, 26 Dec 2018 00:00:00 +0800</pubDate>
    </item>
    <item>
      <title>「日记」一次产品代码审计</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzU4NjY5ODM3Nw==&amp;mid=2247483770&amp;idx=1&amp;sn=6346797f7754ac829fc393ceb41f499b</link>
      <description>有针对性的熟悉东西审计就是快</description>
      <content:encoded><![CDATA[<p>
原创 <span>Anhkgg</span> <span>2018-12-25 22:57</span> <span style="display: inline-block;"></span>
</p>

<p>有针对性的熟悉东西审计就是快</p>
<p></p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=6e86219c&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FqukewnktvYxibhSD33QUJQsNuRWfjun5TBouYciat978zh80oduAHZrI7VcoDhmj0aULn5rYYdgeoCvR0TIFEssQ%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<p><span style="background-color: transparent;color: rgb(255, 104, 39);">by <span style="color: rgb(255, 104, 39);font-size: 14px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;margin-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;padding-top: 0px;"><strong style="margin-bottom: 0px;margin-left: 0px;margin-right: 0px;margin-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;padding-top: 0px;">Anhkgg</strong> | 2018年12月25日</span></span><span style="background-color: transparent;color: rgb(0, 0, 0);"> | </span><span style="background-color: rgb(178, 178, 178);color: rgb(0, 0, 0);"><strong style="margin-bottom: 0px;margin-left: 0px;margin-right: 0px;margin-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;padding-top: 0px;">080/100</strong></span></p><p><span style="background-color: rgb(178, 178, 178);color: rgb(0, 0, 0);"><strong style="margin-bottom: 0px;margin-left: 0px;margin-right: 0px;margin-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;padding-top: 0px;"><br/></strong></span></p><p style="text-align: center;"><br/></p><p><span style="font-size: 14px;">因为之前一段时间有尝试挖过内核漏洞，对于该类型漏洞各种触发原因确实比较熟悉了。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">无非就那么几类：</span></p><p><span style="color: rgb(178, 178, 178);font-size: 14px;">0. 初级的，没有校验输入null，或者长度<br/>1. 长度校验不够，导致溢出<br/>2. 无符号、有符号混用，造成数据截断，溢出<br/>3. 输入中有offset，控制可溢出<br/>4. 输入中有指针，控制任意地址读写<br/>5. 字符串非0结尾，可溢出<br/>6. 内存是否合法，可读写缺乏校验，或者校验不够，可绕过<br/>7. 某些内容分内存和长度两个字段表示，相互校验不够严谨，长度可控溢出</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">总结来说，输入结构越复杂漏洞可能越多。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">所以在此处产品代码审计中，很快就找到多个漏洞，大多会忽略字符串的处理，然后是长度的校验。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">某些漏洞在fuzz时没有跑出来，一个是因为当时协议分析不够，为绕过协议检查，还有缺少某些payload，如绕过不严谨的内存检查。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">后面根据这些情况对fuzz进行了增强，后续验证是否有效。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">另外也负责这些漏洞的修复，发现其实都是些非常小的问题，但危害却是不小。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">以前的产品都缺乏这方面的教育，虽然是安全产品，也却真的不安全。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">还是tx、数字之类的更加有战斗经验，自保护确实都非常不错。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">对接口调用的防护使用了非常多的手段<br/></span><span style="color: rgb(178, 178, 178);font-size: 14px;">1. 文件签名校验<br/>2. 白名单进程<br/>3. 路径检查、dll劫持防护、dll签名检查等等</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">总的来说，这次活挺有意义，下次有时间再详细总结一下。</span><br/></p><p><br/></p>



<p><a href="2247483770">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=0e84b685&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzU4NjY5ODM3Nw%3D%3D%26mid%3D2247483770%26idx%3D1%26sn%3D6346797f7754ac829fc393ceb41f499b%26subscene%3D0">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Tue, 25 Dec 2018 22:57:00 +0800</pubDate>
    </item>
    <item>
      <title>「日记」单元测试</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzU4NjY5ODM3Nw==&amp;mid=2247483761&amp;idx=1&amp;sn=5da0840fd262cc3756e0ddff528060bc</link>
      <description>Google 牛！</description>
      <content:encoded><![CDATA[<p>
原创 <span>Anhkgg</span> <span>2018-12-15 23:50</span> <span style="display: inline-block;"></span>
</p>

<p>Google 牛！</p>
<p></p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=f76ea64a&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FqukewnktvYzDp5uxTw3LbvOUCaOefiavZ5hZZn6V4Qb2l5M3vywssTic3UDeKOkUfrf1UAlYLRQG26D14pGTghAg%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<p><span style="background-color: transparent;color: rgb(255, 104, 39);">by <span style="color: rgb(255, 104, 39);font-size: 14px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;margin-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;padding-top: 0px;"><strong style="margin-bottom: 0px;margin-left: 0px;margin-right: 0px;margin-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;padding-top: 0px;">Anhkgg</strong> | 2018年12月14日</span></span><span style="background-color: transparent;color: rgb(0, 0, 0);"> | </span><span style="background-color: rgb(178, 178, 178);color: rgb(0, 0, 0);"><strong style="margin-bottom: 0px;margin-left: 0px;margin-right: 0px;margin-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;padding-top: 0px;">075/100</strong></span></p><p><br/></p><p style="margin: 0px 0px 1.2em !important;padding: 0px;clear: both;color: rgb(0, 0, 0);" hiragino="hiragino" microsoft="microsoft" arial="arial" sans-serif="sans-serif" start="start" initial="initial" em="em" helvetica="helvetica" neue="neue" sans="sans" gb="gb" yahei="yahei" normal="normal" none="none" px="px"><span style="font-size: 14px;">写代码这么久，还真是第一次正儿八经写单元测试。以前一直认为编码和测试是两个行当，叫做RD和QA。</span></p><p style="margin: 0px 0px 1.2em !important;padding: 0px;clear: both;color: rgb(0, 0, 0);" hiragino="hiragino" microsoft="microsoft" arial="arial" sans-serif="sans-serif" start="start" initial="initial" em="em" helvetica="helvetica" neue="neue" sans="sans" gb="gb" yahei="yahei" normal="normal" none="none" px="px"><span style="font-size: 14px;">最近学了「单元测试」的部分内容之后，才知道测试也分级别，最基本的单元测试是RD自己的事情。其实RD确认也一直做了这件事情，只是我没有意识到而已。</span></p><p style="margin: 0px 0px 1.2em !important;padding: 0px;clear: both;color: rgb(0, 0, 0);" hiragino="hiragino" microsoft="microsoft" arial="arial" sans-serif="sans-serif" start="start" initial="initial" em="em" helvetica="helvetica" neue="neue" sans="sans" gb="gb" yahei="yahei" normal="normal" none="none" px="px"><span style="font-size: 14px;">单元测试就是测试写出的函数或类的功能的正确性，保证代码质量，避免出现某些黑盒测试无法覆盖的功能点，把bug消灭在开发阶段，提高效率。</span></p><p style="margin: 0px 0px 1.2em !important;padding: 0px;clear: both;color: rgb(0, 0, 0);" hiragino="hiragino" microsoft="microsoft" arial="arial" sans-serif="sans-serif" start="start" initial="initial" em="em" helvetica="helvetica" neue="neue" sans="sans" gb="gb" yahei="yahei" normal="normal" none="none" px="px"><span style="font-size: 14px;">理解之后，其实就知道，平实写代码，进行功能验证的时候，就是在做单元测试。</span></p><p style="margin: 0px 0px 1.2em !important;padding: 0px;clear: both;color: rgb(0, 0, 0);" hiragino="hiragino" microsoft="microsoft" arial="arial" sans-serif="sans-serif" start="start" initial="initial" em="em" helvetica="helvetica" neue="neue" sans="sans" gb="gb" yahei="yahei" normal="normal" none="none" px="px"><span style="font-size: 14px;">但是确认没有做到那么规范和完美。</span></p><p style="margin: 0px 0px 1.2em !important;padding: 0px;clear: both;color: rgb(0, 0, 0);" hiragino="hiragino" microsoft="microsoft" arial="arial" sans-serif="sans-serif" start="start" initial="initial" em="em" helvetica="helvetica" neue="neue" sans="sans" gb="gb" yahei="yahei" normal="normal" none="none" px="px"><span style="font-size: 14px;">单元测试常用的工具是GTest和BTest，顾名思义，前者叫做google test。</span></p><p style="margin: 0px 0px 1.2em !important;padding: 0px;clear: both;color: rgb(0, 0, 0);" hiragino="hiragino" microsoft="microsoft" arial="arial" sans-serif="sans-serif" start="start" initial="initial" em="em" helvetica="helvetica" neue="neue" sans="sans" gb="gb" yahei="yahei" normal="normal" none="none" px="px"><span style="font-size: 14px;">这次我使用的就是GTest，从<a href="https://github.com/google/googletest下载代码之后，进入googletest\msvc\2010，打开gtest.sln，然后编译出lib文件。" target="_blank">https://github.com/google/googletest下载代码之后，进入googletest\msvc\2010，打开gtest.sln，然后编译出lib文件。</a></span></p><p style="margin: 0px 0px 1.2em !important;padding: 0px;clear: both;color: rgb(0, 0, 0);" hiragino="hiragino" microsoft="microsoft" arial="arial" sans-serif="sans-serif" start="start" initial="initial" em="em" helvetica="helvetica" neue="neue" sans="sans" gb="gb" yahei="yahei" normal="normal" none="none" px="px"><span style="font-size: 14px;">创建单元测试工程，设置include目录\googletest\include，和lib目录。</span></p><p style="margin: 0px 0px 1.2em !important;padding: 0px;clear: both;color: rgb(0, 0, 0);" hiragino="hiragino" microsoft="microsoft" arial="arial" sans-serif="sans-serif" start="start" initial="initial" em="em" helvetica="helvetica" neue="neue" sans="sans" gb="gb" yahei="yahei" normal="normal" none="none" px="px"><span style="font-size: 14px;">基本代码结构就是如此，通过TEST宏来定义单侧函数，尽量做到一个TEST测试一个独立功能，或者相关功能。</span></p><pre style="margin: 1.2em 0px;padding: 0.4em 0.6em;border-radius: 8px;background: rgb(248, 248, 248);color: rgb(0, 0, 0);font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;font-family: Consolas, Inconsolata, Courier, monospace;line-height: 1.2em;font-size: 0.75em;"><code style="margin: 0px 0.15em;padding: 0.5em 0.7em;border-radius: 3px;border: 1px solid rgb(204, 204, 204);overflow: auto;font-family: Consolas,Inconsolata,Courier,monospace;font-size: 0.8em;display: block !important;white-space: pre;background-color: rgb(248, 248, 248);">#include &#34;gtest/gtest.h&#34;

TEST(ProjectTest, TestName)
{
}

int main(int argc, char** argv)
{
    testing::InitGoogleTest(&amp;argc, argv);
    return RUN_ALL_TESTS();
}</code></pre><p style="margin: 0px 0px 1.2em !important;padding: 0px;clear: both;color: rgb(0, 0, 0);" hiragino="hiragino" microsoft="microsoft" arial="arial" sans-serif="sans-serif" start="start" initial="initial" em="em" helvetica="helvetica" neue="neue" sans="sans" gb="gb" yahei="yahei" normal="normal" none="none" px="px"><span style="font-size: 14px;">然后使用EXPECT_EQ来判断函数结果是否符合预期，比如：</span></p><pre style="margin: 1.2em 0px;padding: 0.4em 0.6em;border-radius: 8px;background: rgb(248, 248, 248);color: rgb(0, 0, 0);font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;font-family: Consolas, Inconsolata, Courier, monospace;line-height: 1.2em;font-size: 0.75em;"><code style="margin: 0px 0.15em;padding: 0.5em 0.7em;border-radius: 3px;border: 1px solid rgb(204, 204, 204);overflow: auto;font-family: Consolas,Inconsolata,Courier,monospace;font-size: 0.8em;display: block !important;white-space: pre;background-color: rgb(248, 248, 248);">EXPECT_EQ(true, GetColumnCount(count));
EXPECT_EQ(5, count);
EXPECT_EQ(0, _stricmp(&#34;hijklm&#34;, data));</code></pre><p style="margin: 0px 0px 1.2em !important;padding: 0px;clear: both;color: rgb(0, 0, 0);" hiragino="hiragino" microsoft="microsoft" arial="arial" sans-serif="sans-serif" start="start" initial="initial" em="em" helvetica="helvetica" neue="neue" sans="sans" gb="gb" yahei="yahei" normal="normal" none="none" px="px"><span style="font-size: 14px;">GTesth还有其他高级的功能，Moch，Hook之类，暂时并没有涉及到。</span></p><p style="margin: 0px 0px 1.2em !important;padding: 0px;clear: both;color: rgb(0, 0, 0);" hiragino="hiragino" microsoft="microsoft" arial="arial" sans-serif="sans-serif" start="start" initial="initial" em="em" helvetica="helvetica" neue="neue" sans="sans" gb="gb" yahei="yahei" normal="normal" none="none" px="px"><span style="font-size: 14px;">最后如果所有测试用例通过，显示如下：</span></p><pre style="margin: 1.2em 0px;padding: 0.4em 0.6em;border-radius: 8px;background: rgb(248, 248, 248);color: rgb(0, 0, 0);font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-weight: 400;letter-spacing: normal;orphans: 2;text-align: start;text-indent: 0px;text-transform: none;widows: 2;word-spacing: 0px;-webkit-text-stroke-width: 0px;text-decoration-style: initial;text-decoration-color: initial;font-family: Consolas, Inconsolata, Courier, monospace;line-height: 1.2em;font-size: 0.75em;"><code style="margin: 0px 0.15em;padding: 0.5em 0.7em;border-radius: 3px;border: 1px solid rgb(204, 204, 204);overflow: auto;font-family: Consolas,Inconsolata,Courier,monospace;font-size: 0.8em;display: block !important;white-space: pre;background-color: rgb(248, 248, 248);">[==========] Running 2 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 2 tests from WordTableTest
[ RUN      ] WordTableTest.BuildIn
[       OK ] WordTableTest.BuildIn (0 ms)
[ RUN      ] WordTableTest.UserType
[       OK ] WordTableTest.UserType (0 ms)
[----------] 2 tests from WordTableTest (2 ms total)

[----------] Global test environment tear-down
[==========] 2 tests from 1 test case ran. (3 ms total)
[  PASSED  ] 2 tests.</code></pre><p><br/></p>



<p><a href="2247483761">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=62c566d1&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzU4NjY5ODM3Nw%3D%3D%26mid%3D2247483761%26idx%3D1%26sn%3D5da0840fd262cc3756e0ddff528060bc%26subscene%3D0">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Sat, 15 Dec 2018 23:50:00 +0800</pubDate>
    </item>
    <item>
      <title>「日记」代码规范</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzU4NjY5ODM3Nw==&amp;mid=2247483757&amp;idx=1&amp;sn=b929dd2b334d326bdc3b4a90ba0e017d</link>
      <description>代码即脸面</description>
      <content:encoded><![CDATA[<p>
原创 <span>Anhkgg</span> <span>2018-12-14 22:54</span> <span style="display: inline-block;"></span>
</p>

<p>代码即脸面</p>
<p></p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=34fc2331&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FqukewnktvYwLS2nwx4OzFEnghOB8ITqGOicIShTH1QpLG43OJSsWeAJ6DDgibsyiaWfz3l9kUnnDHSZfzhTvChoWA%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<p><span style="background-color: transparent;color: rgb(255, 104, 39);">by <span style="color: rgb(255, 104, 39);font-size: 14px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;margin-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;padding-top: 0px;"><strong style="margin-bottom: 0px;margin-left: 0px;margin-right: 0px;margin-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;padding-top: 0px;">Anhkgg</strong> | 2018年12月13日</span></span><span style="background-color: transparent;color: rgb(0, 0, 0);"> | </span><span style="background-color: rgb(178, 178, 178);color: rgb(0, 0, 0);"><strong style="margin-bottom: 0px;margin-left: 0px;margin-right: 0px;margin-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;padding-top: 0px;">074/100</strong></span></p><p><br/></p><p><span style="font-size: 14px;">代码规范就像人的脸面一样，要好看，要能给人看。别人看的越喜欢说明代码写的越好。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">代码规范涉及内容其实非常之多，不同语言还有不同的规范。这里就说说命名的规则，什么驼峰（大驼峰、小驼峰）、匈牙利之类的。名字这么优雅，说到底名字的单词写法，第一个字母大小还是小写，或者所有字母小写。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">具体如下：</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;"><strong>大驼峰</strong>式命名规则：FirstName, CamelCase</span></p><p><br/></p><p><span style="font-size: 14px;"><strong>小驼峰</strong>式命名规则：firstName, camelCase</span></p><p><br/></p><p><span style="font-size: 14px;"><strong>匈牙利</strong>命名法：通过在变量名前面加上相应的小写字母的符号标识作为前缀，标识出变量的作用域，类型等这些符号可以多个同时使用，顺序是先m_（成员变量）， 再指针，再简单数据类型，再其它。例如：m_lpszStr, 表示指向一个以0字符结尾的字符串的长指针成员变量。</span></p><p><br/></p><p><span style="font-size: 14px;">//<a href="https://www.cnblogs.com/Offie/p/5021368.html" target="_blank">https://www.cnblogs.com/Offie/p/5021368.html</a></span></p><p><span style="font-size: 14px;">属性+类型+描述<br/>属性一般是小写字母+_:<br/>g_:全局变量 m_:类成员变量 s_:静态变量 c_:常量<br/>类型就多了：<br/>b:bool sz:以零结束的字符串 p:指针 n:整整<br/>dw:双字 l:长整型 无符号:u 函数:fn<br/></span></p><p><span style="font-size: 14px;">还有个特别的linux中最常用的<strong>下划线命名法</strong>，全小写单词加下划线，如print_employee_paychecks。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">当然代码规范不仅仅就这点内容，比如还有其他的if后面括号的空格位置，变量初始化，大括号怎么放等等。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">Windows代码和linux代码的规范大相径庭，所以如果没有特殊要求，根据个人爱好，习惯一种代码规范，代码会越写越好看，真的就像艺术品一样。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">另外好不好看，其实跟使用的字体有非常大的关系，有些字体能够所有字符相同大小，样式规整，代码一罗列起来给人一种铺面而来的美感。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">我特别羡慕同事调好的字体，但是我死活调不出跟他一样的效果，只能羡慕、羡慕、羡慕。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">最后在总结一点，本次考试代码重构的一点心得。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">因为处理的数据，包括不同的类型，比如int，char*，float等等，为了使接口统一，使用方便，就比较适合使用模板来完成，如模板函数。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">在数据解析中，不同数据解析方法不同，但为了解析接口统一以及可扩展新的数据类型支持，将解析接口抽象出来，做成了模板接口类。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">如此抽象之后，代码结构非常清晰，扩展方便，使用简单，自我感觉是很好的一次代码重构。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">最后感觉稍微更喜欢C++那么一点点！</span></p><p><br/></p>



<p><a href="2247483757">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=707ae0af&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzU4NjY5ODM3Nw%3D%3D%26mid%3D2247483757%26idx%3D1%26sn%3Db929dd2b334d326bdc3b4a90ba0e017d%26subscene%3D0">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Fri, 14 Dec 2018 22:54:00 +0800</pubDate>
    </item>
    <item>
      <title>「日记」一个调试小工具的完善</title>
      <link>https://mp.weixin.qq.com/s?__biz=MzU4NjY5ODM3Nw==&amp;mid=2247483745&amp;idx=1&amp;sn=36ca41f734d6dc1be7b35daefd21b3c0</link>
      <description>晚</description>
      <content:encoded><![CDATA[<p>
原创 <span>Anhkgg</span> <span>2018-12-11 17:08</span> <span style="display: inline-block;"></span>
</p>

<p>晚</p>
<p></p>



<p>
<img src="https://wechat2rss.xlab.app/img-proxy/?k=f800e6a7&amp;u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2FqukewnktvYy67ey4BgEzLvvVVYP3ZE7IwMxCmPUnniaC511fqicEagRpmxEmCIV5qnBe4rha4Vxhb36MmZOsqQhA%2F0%3Fwx_fmt%3Djpeg"/>
</p>


<p><span style="background-color: transparent;color: rgb(255, 104, 39);">by <span style="color: rgb(255, 104, 39);font-size: 14px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;margin-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;padding-top: 0px;"><strong style="margin-bottom: 0px;margin-left: 0px;margin-right: 0px;margin-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;padding-top: 0px;">Anhkgg</strong> | 2018年12月10日</span></span><span style="background-color: transparent;color: rgb(0, 0, 0);"> | </span><span style="background-color: rgb(178, 178, 178);color: rgb(0, 0, 0);"><strong style="margin-bottom: 0px;margin-left: 0px;margin-right: 0px;margin-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;padding-top: 0px;">071/100</strong></span></p><p><span style="background-color: rgb(178, 178, 178);color: rgb(0, 0, 0);"><strong style="margin-bottom: 0px;margin-left: 0px;margin-right: 0px;margin-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;padding-top: 0px;"><br/></strong></span></p><p style="text-align: center;"><span style="margin: 0px;padding: 0px;text-align: left;color: rgb(0, 0, 0);text-transform: none;text-indent: 0px;letter-spacing: normal;font-size: 14px;font-style: normal;font-variant: normal;font-weight: 400;text-decoration: none;word-spacing: 0px;orphans: 2;-webkit-text-stroke-width: 0px;"><strong style="margin-bottom: 0px;margin-left: 0px;margin-right: 0px;margin-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;padding-top: 0px;"><span style="text-align: center;color: rgb(255, 76, 65);text-transform: none;text-indent: 0px;letter-spacing: normal;" px="px" none="none" important="important" inline="inline" normal="normal" yahei="yahei" gb="gb" sans="sans" neue="neue" helvetica="helvetica">01 闲聊</span></strong></span></p><p style="background-color: transparent;clear: both;color: rgb(0, 0, 0);"><br/></p><p style="background-color: transparent;clear: both;color: rgb(0, 0, 0);"><span style="font-size: 14px;">休假之后得第一天上班，遇上堵车，折腾了近两小时，一上午都没了。</span></p><p style="background-color: transparent;clear: both;color: rgb(0, 0, 0);"><span style="font-size: 14px;"><br/></span></p><p style="background-color: transparent;clear: both;color: rgb(0, 0, 0);"><span style="font-size: 14px;">好不容易进了办公楼，电梯里遇到了公司大老板，蒙了，错过了一次要合影的机会，惨！</span><span style="margin: 0px;padding: 0px;text-align: left;color: rgb(0, 0, 0);text-transform: none;text-indent: 0px;letter-spacing: normal;font-size: 14px;font-style: normal;font-variant: normal;font-weight: 400;text-decoration: none;word-spacing: 0px;orphans: 2;-webkit-text-stroke-width: 0px;"><strong style="margin-bottom: 0px;margin-left: 0px;margin-right: 0px;margin-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;padding-top: 0px;"><span style="text-align: center;color: rgb(255, 76, 65);text-transform: none;text-indent: 0px;letter-spacing: normal;" px="px" none="none" important="important" inline="inline" normal="normal" yahei="yahei" gb="gb" sans="sans" neue="neue" helvetica="helvetica"><br/></span></strong></span></p><p style="text-align: center;"><br/></p><p style="text-align: center;"><span style="margin: 0px;padding: 0px;text-align: left;color: rgb(0, 0, 0);text-transform: none;text-indent: 0px;letter-spacing: normal;font-size: 14px;font-style: normal;font-variant: normal;font-weight: 400;text-decoration: none;word-spacing: 0px;orphans: 2;-webkit-text-stroke-width: 0px;"><strong style="margin-bottom: 0px;margin-left: 0px;margin-right: 0px;margin-top: 0px;padding-bottom: 0px;padding-left: 0px;padding-right: 0px;padding-top: 0px;"><span style="text-align: center;color: rgb(255, 76, 65);text-transform: none;text-indent: 0px;letter-spacing: normal;display: inline !important;float: none;background-color: transparent;" px="px" none="none" important="important" inline="inline" normal="normal" yahei="yahei" gb="gb" sans="sans" neue="neue" helvetica="helvetica">02 总结</span></strong></span><br/></p><p><br/></p><p><span style="font-size: 14px;">白天（其实只有下午时间了）主要完成工作上的事情，开了两次会，验证了某个遗留问题。</span></p><p><br/></p><p><span style="font-size: 14px;">晚上寻思把前面写的小工具完善了，分享出去。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">工具叫做IDARvaTool，其实是用于逆向分析中增加效率的小工具。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">因为做逆向调试经常遇到过这种问题：在同时使用两大神器OD(或Windbg)和IDA逆向某程序时，调试中模块基址经常变化，而在IDA中默认为0x400000（或0x10000000），所以在调试到某个点想到IDA整体对比分析一下的时候，发现计算地址真的好麻烦，特别时在经常需要计算的时候，这个问题尤为明显。</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">所以对于我个人来说，这个工具非常棒！也希望别人能够觉得非常棒！</span></p><p><span style="font-size: 14px;"><br/></span></p><p><span style="font-size: 14px;">工具具体见：<a href="http://mp.weixin.qq.com/s?__biz=MzI1NTUzMjUzMQ==&amp;mid=2247483851&amp;idx=1&amp;sn=62a5a585c91f760d30c593a64b8c998d&amp;chksm=ea35cd57dd4244419922e421d7f2e90ff00bea8de63e7c5c0feb7015cde99c0684f29fd28db2&amp;scene=21#wechat_redirect" target="_blank">「神器」不容错过！逆向调试好帮手：神算子偏移计算工具。</a></span></p><p><br/></p>



<p><a href="2247483745">阅读原文</a></p>
<p><a href="https://wechat2rss.xlab.app/link-proxy/?k=5918a817&amp;r=1&amp;u=https%3A%2F%2Fmp.weixin.qq.com%2Fs%3F__biz%3DMzU4NjY5ODM3Nw%3D%3D%26mid%3D2247483745%26idx%3D1%26sn%3D36ca41f734d6dc1be7b35daefd21b3c0%26subscene%3D0">跳转微信打开</a></p>
]]></content:encoded>
      <pubDate>Tue, 11 Dec 2018 17:08:00 +0800</pubDate>
    </item>
  </channel>
</rss>