<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
  <channel>
    <title>DavidL</title>
    <description></description>
    <link>http://davidl.javaeye.com</link>
    <language>UTF-8</language>
    <copyright>Copyright 2003-2008, JavaEye.com</copyright>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <generator>JavaEye - 做最棒的软件开发交流社区</generator>
      <item>
        <title>交行网站跨站漏洞</title>
        <author>DavidL</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://davidl.javaeye.com">DavidL</a>&nbsp;
          链接：<a href="http://davidl.javaeye.com/blog/141608" style="color:red;">http://davidl.javaeye.com/blog/141608</a>&nbsp;
          发表时间: 2007年11月19日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          <a href="http://www.bankcomm.com/jh/cn/detail.jsp?c=1121231469100&id=1168824142100&cName=%3Cscript%3Ealert('hacker')%3C/script%3E&type=CMS.STD" target="_blank">http://www.bankcomm.com/jh/cn/detail.jsp?c=1121231469100&id=1168824142100&cName=%3Cscript%3Ealert('hacker')%3C/script%3E&type=CMS.STD</a>
          <br/>
          <span style="color:red;">
            <a href="http://davidl.javaeye.com/blog/141608#comments" style="color:red;">本文的讨论也很精彩，浏览讨论>></a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/92' target='_blank'><span style="color:red;font-weight:bold;">快来参加7月17日在成都举行的SOA中国技术论坛</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/106' target='_blank'><span style="color:blue;font-weight:bold;">JavaEye问答大赛开始了！ 从6月23日 至 7月6日，奖品丰厚 ！</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Mon, 19 Nov 2007 09:20:41 +0800</pubDate>
        <link>http://davidl.javaeye.com/blog/141608</link>
        <guid>http://davidl.javaeye.com/blog/141608</guid>
      </item>
      <item>
        <title>Descent Hacking</title>
        <author>DavidL</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://davidl.javaeye.com">DavidL</a>&nbsp;
          链接：<a href="http://davidl.javaeye.com/blog/113520" style="color:red;">http://davidl.javaeye.com/blog/113520</a>&nbsp;
          发表时间: 2007年08月17日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          Descent is a great IDE plugin for eclipse (D language) which takes advantage of ddbg debugging and the powerful eclipse texteditor. <br />
<br />
And it comes to a stage nearly really usable. And I took a look at it.<br />
<br />
The main problem of the descent is debugging.&nbsp; It doesn't feed the module name to ddbg, i.e. a file in C:\dmd\project\abc.d would be directly fed to ddbg which would result the breakpoint not taking any effect. Workaround is simple. In the addBreakpoint it add a DescentLineBreakpoint. What I did was adding a parsing right before the breakpoint was added to the breakpoint manager.&nbsp; Translating the &quot;module abc.mymodule;&quot; to abc/mymodule.d and at last send it to ddbg debugger backend.<br />
<br />
This solution was the first patch I posted in the <a href="http://www.dsource.org/forums/viewtopic.php?p=16025#16025">forum</a>. In the fourm because the code was not quoted under code tag, so indentation info got lost, you can see the indentation in the HTML source anyway :) The newest patch is guarded by the code tag, so you can view it nicely :)<br />
<br />
Yet I came to another problem of reloading eclipse D project, the breakpoints were not working any more. After tracing around the eclipse.org.breakpointmanager?( I can't launch the eclipse right at the moment, cause the machine's memory is so limited , 512M, so this two patches took me&nbsp; 1 week ) , the breakpoint manager loaded the breakpoints from the IMarker info. So all extention in DescentLineBreakpoint all got lost. This is actually a design flow of the breakpoint manager. A breakpoint manager shouldn't be launched in such an early stage, and also the breakpoint manager shouldn't add all breakpoints as its own interface class LineBreakpoint, it prevents others from enhancing the breakpoint or any fancy extention points like IWorkbench. After understanding the whole bug, I can now come to fix the problem. We need to refresh all the breakpoints after the breakpoint manager got them loaded. I stupidly wanted to fix it by simply copy code from the original fix. So it required IDocumentProvider and therefore ITextEditor. At last , I found out that was not required. The code in the DescentLineBreakpoint constructor was actually need the ITextEditor-&gt; IDocumentProvider -&gt; lineStart, lineEnd, and at last those two variables are set to IMarker for further reusing(possibly the highlighting). And actually those two values I can get from IMarker by getAttributes, at last I can reuse the constructor recreate the breakpoint, also I would remove the breakpoint firstly :)<br />
<br />
I can't paste much code here :) Sorry for the poor blogging. You can get the newest patch in the following link:<br />
<br />
<a href="http://www.dsource.org/forums/viewtopic.php?p=16025#16025"> http://www.dsource.org/forums/viewtopic.php?p=16025#16025</a><br />
<br />
Setting breakpoints is correct now, though it gets issues of F8 (continue the execution of the source), you need to type something(arbitrarily) in the console to feed ddbg , and then the eclipse debugging system seems to take the control back again. <br />
<br />
Have fun with descent !
          <br/>
          <span style="color:red;">
            <a href="http://davidl.javaeye.com/blog/113520#comments" style="color:red;">本文的讨论也很精彩，浏览讨论>></a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/92' target='_blank'><span style="color:red;font-weight:bold;">快来参加7月17日在成都举行的SOA中国技术论坛</span></a></li><li><a href='/adverts/106' target='_blank'><span style="color:blue;font-weight:bold;">JavaEye问答大赛开始了！ 从6月23日 至 7月6日，奖品丰厚 ！</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Fri, 17 Aug 2007 15:23:51 +0800</pubDate>
        <link>http://davidl.javaeye.com/blog/113520</link>
        <guid>http://davidl.javaeye.com/blog/113520</guid>
      </item>
      <item>
        <title>Cleanups Done</title>
        <author>DavidL</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://davidl.javaeye.com">DavidL</a>&nbsp;
          链接：<a href="http://davidl.javaeye.com/blog/108918" style="color:red;">http://davidl.javaeye.com/blog/108918</a>&nbsp;
          发表时间: 2007年08月04日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          Clean up two old blogs, which was edited in opera (the edit box was so small). In firefox, I can review these blogs easily, and some clean up done.<br />
<br />
NASM 0.99.01 was buggy for the 32bit/16bit codegen. When an instruction which access register and mem, it would be generated with 0x67 prefix for a 16bit segment. This blocks the elf2 bootsect, which has size limitation, extra 0x67 makes the code bloated, so the compilation breaks.<br />
I did a quick hack, and posted the new compiled binary to the ReactOS Build Environment maintainer. Also I filed it as a bug, though the nasm64developer told me that this couldn't be reproduced in 0.99.02 CVS snapshot. O_O , after a try , yes, it's already fixed. ;) so my hacking over nasm is useless.<br />
<br />
Though another thing interesting is spotted about GDB. GDB itself is a nice debugger. But...<br />
<br />
<div class="code_title">c 代码</div>
<div class="dp-highlighter">
<div class="bar">&nbsp;</div>
<ol class="dp-cpp" start="1">
    <li class="alt"><span><span class="preprocessor">#include&nbsp;&quot;stdio.h&quot;</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span><span class="keyword">void</span><span>&nbsp;__stdcall&nbsp;call()&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>{&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;printf(<span class="string">&quot;hello!&quot;</span><span>);&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>}&nbsp;&nbsp;</span></li>
    <li class=""><span><span class="keyword">void</span><span>&nbsp;main()&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>{&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;call();&nbsp;&nbsp;</span></li>
    <li class="alt"><span>}&nbsp;&nbsp;</span></li>
</ol>
</div>
<br />
when you try to <br />
<div class="code_title">gdb下调试</div>
<div class="dp-highlighter">
<ol class="dp-cpp" start="1">
    <li class="alt"><span><span>b&nbsp;call&nbsp;&nbsp;</span></span></li>
</ol>
</div>
gdb fails.<br />
<br />
This is the reason why gdb couldn't get all symbols work in Kernel Debugging. <br />
<br />
Remarks:<br />
__stdcall __fastcall are calling convention in Windows, they both add @ to the mangled name, seems like gdb fail to deal with mangle name with '@'<br />
<br />
mangle name(link time symbol): <br />
c mangle convention: underscore prefix, so every C symbols in asm would be prefixed with an underscore.<br />
so a typical link with ASM files would be<br />
test.c<br />
<div class="code_title">c 代码</div>
<div class="dp-highlighter">
<div class="bar">&nbsp;</div>
<ol class="dp-cpp" start="1">
    <li class="alt"><span><span class="keyword">extern</span><span>&nbsp;</span><span class="datatypes">int</span><span>&nbsp;myasmSymbol;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li>
    <li class=""><span><span class="datatypes">int</span><span>&nbsp;main()&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>{&nbsp;&nbsp;&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;myasmSymbol;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>}&nbsp;&nbsp;&nbsp;&nbsp;</span></li>
</ol>
</div>
myasm.S<br />
<div class="code_title">asm 代码</div>
<div class="dp-highlighter">
<div class="bar">&nbsp;</div>
<ol class="dp-cpp" start="1">
    <li class="alt"><span><span>.text&nbsp;&nbsp;</span></span></li>
    <li class=""><span>.global&nbsp;_myasmSymbol&nbsp;&nbsp;</span></li>
    <li class="alt"><span>_myasmSymbol:&nbsp;.<span class="datatypes">int</span><span>&nbsp;0&nbsp;&nbsp;&nbsp; <br />
    </span></span></li>
</ol>
</div>
<br />
<br />
gcc -c myasm.S<br />
gcc -c test.c<br />
<br />
gcc test.o myasm.o -o test.exe<br />
<br />
<br />
<br />
<br />
<br />
<br />
          <br/>
          <span style="color:red;">
            <a href="http://davidl.javaeye.com/blog/108918#comments" style="color:red;">本文的讨论也很精彩，浏览讨论>></a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li><li><a href='/adverts/106' target='_blank'><span style="color:blue;font-weight:bold;">JavaEye问答大赛开始了！ 从6月23日 至 7月6日，奖品丰厚 ！</span></a></li><li><a href='/adverts/92' target='_blank'><span style="color:red;font-weight:bold;">快来参加7月17日在成都举行的SOA中国技术论坛</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Sat, 04 Aug 2007 15:30:03 +0800</pubDate>
        <link>http://davidl.javaeye.com/blog/108918</link>
        <guid>http://davidl.javaeye.com/blog/108918</guid>
      </item>
      <item>
        <title>Sadly, what I did was wrong due to MSDN</title>
        <author>DavidL</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://davidl.javaeye.com">DavidL</a>&nbsp;
          链接：<a href="http://davidl.javaeye.com/blog/104705" style="color:red;">http://davidl.javaeye.com/blog/104705</a>&nbsp;
          发表时间: 2007年07月24日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          the API is designed in a way of weirdness. People call this API sending integer value to subsystem thru randomly choosed arg by the specific SPI_GETblahblah.  Recently I posted MmGrowKernelStack patch to ReactOS. This internal func is for cut down the kernelstack memory. Cause most threads use only KERNEL_STACK_SIZE, only GUI threads require KERNEL_LARGE_STACK_SIZE, and what's been done in NT? From the comments in ReactOS code, we find out that NT actually allocates KERNEL_STACK_SIZE for GUI thread at the very beginning. So the GUI thread would have only KERNEL_STACK_SIZE stack, while it could be not enough, so every call of growing kernel stack which might exhaust kernel stack would call MmGrowKernelStack. More details could be seen in bug 2413.
          <br/>
          <span style="color:red;">
            <a href="http://davidl.javaeye.com/blog/104705#comments" style="color:red;">本文的讨论也很精彩，浏览讨论>></a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/106' target='_blank'><span style="color:blue;font-weight:bold;">JavaEye问答大赛开始了！ 从6月23日 至 7月6日，奖品丰厚 ！</span></a></li><li><a href='/adverts/92' target='_blank'><span style="color:red;font-weight:bold;">快来参加7月17日在成都举行的SOA中国技术论坛</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Tue, 24 Jul 2007 13:27:46 +0800</pubDate>
        <link>http://davidl.javaeye.com/blog/104705</link>
        <guid>http://davidl.javaeye.com/blog/104705</guid>
      </item>
      <item>
        <title>NT / Subsystem</title>
        <author>DavidL</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://davidl.javaeye.com">DavidL</a>&nbsp;
          链接：<a href="http://davidl.javaeye.com/blog/100483" style="color:red;">http://davidl.javaeye.com/blog/100483</a>&nbsp;
          发表时间: 2007年07月12日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          It's interesting to work with the subsystem. Recently I discovered a bug of CPL(Control Panel) in reactos. The original one didn't send SPI to subsystem, and also the way of sending is incorrect.   How do we get system parameter set and sent to the kernel space and also updated in registry?   It itself is complicated problem. While my understanding is , CPL itself a dll calls SystemParametersInfo, and this API is in user32.dll, the API is implemented in the user32\misc\desktop.c we get two versions there SystemParametersInfoA and SystemParametersInfoW dealing with different encoding as other APIs do. And this API establishes a call to NtUserSystemParametersInfo which switch to the kernel mode. And the kernel mode subsystem would deal with the DATA sent from CPL. At last we understand the calling chain clear. Inside the subsystem , the core func calls UserSystemParametersInfo internally. After some protection check in kernel mode being done , the kernel func calls IntSystemParametersInfo. This at last deal with the data we sent. There are two ways of sending data to this func.   <br />
<div class="code_title">c 代码</div>
<div class="dp-highlighter">
<div class="bar">&nbsp;</div>
<ol class="dp-cpp" start="1">
    <li class="alt"><span><span class="datatypes">ULONG</span><span>&nbsp;FASTCALL&nbsp;IntSystemParametersInfo(&nbsp;</span><span class="datatypes">UINT</span><span>&nbsp;uiAction,&nbsp;</span><span class="datatypes">UINT</span><span>&nbsp;uiParam,&nbsp;</span><span class="datatypes">PVOID</span><span>&nbsp;pvParam,&nbsp;</span><span class="datatypes">UINT</span><span>&nbsp;fWinIni)&nbsp;&nbsp;&nbsp;</span></span></li>
</ol>
</div>
<br />
<br />
As we can see there are uiAction which stands for our action, uiParam &amp; pvParam represents different data sent. When we are sending some int like builtin small data we use the 2nd arg uiParam, while if we want to pass more we need pvParam. And obviously pvParam points to area of user space. So it's already get probed correct in order to not result KeBugCheck.  That's how our Control Panel works. And at last I developed the software mouse acceleration for Reactos. It's also in subsystem. Subsystem is really a funny place to play with. And I hope someday POSIX subsystem gets done, and running linux binaries in Reactos. Maybe coLinux uses the similar implementation as a subsystem
          <br/>
          <span style="color:red;">
            <a href="http://davidl.javaeye.com/blog/100483#comments" style="color:red;">本文的讨论也很精彩，浏览讨论>></a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/92' target='_blank'><span style="color:red;font-weight:bold;">快来参加7月17日在成都举行的SOA中国技术论坛</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li><li><a href='/adverts/106' target='_blank'><span style="color:blue;font-weight:bold;">JavaEye问答大赛开始了！ 从6月23日 至 7月6日，奖品丰厚 ！</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Thu, 12 Jul 2007 18:47:00 +0800</pubDate>
        <link>http://davidl.javaeye.com/blog/100483</link>
        <guid>http://davidl.javaeye.com/blog/100483</guid>
      </item>
  </channel>
</rss>