<?xml version="1.0"?>
<rss version="2.0">
    <channel>
        <title>OpenRCE: Blog</title>
        <link>http://www.openrce.org/rss/feeds/blog</link>
        <description>OpenRCE: The Open Reverse Code Engineering Community</description>
                <item>
            <title>Cross Your Ts and Dot Your Filenames</title>
                            <pubDate>Thu, 27 Mar 2008 02:55:00 -0500</pubDate>
                                        <link>https://www.openrce.org/blog/view/1104/Cross_Your_Ts_and_Dot_Your_Filenames</link>
                                        <author>JasonGeffner &lt;email-suppressed@example.com&gt;</author>
                                                    <description>&lt;p&gt;I was developing some automation code recently and found that a process that I was injecting code into was crashing. At first I thought it was an error in my injected code, but when I looked at the crash-dump, I was amazed to see that the issue was in MFC42.DLL:&lt;/p&gt;&lt;br /&gt;
&lt;blockquote dir=&quot;ltr&quot;&gt;&lt;br /&gt;
&lt;p&gt;&lt;span&gt;MOV EBX,104&lt;br /&gt;PUSH EBX&lt;br /&gt;LEA EAX,DWORD PTR SS:[EBP+szBuffer]&lt;br /&gt;PUSH EAX&lt;br /&gt;PUSH DWORD PTR DS:[ESI+6C]&lt;br /&gt;CALL DWORD PTR DS:[&amp;lt;&amp;amp;KERNEL32.&lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/ms683197.aspx&quot;&gt;GetModuleFileNameA&lt;/a&gt;&amp;gt;&lt;br /&gt;LEA EAX,DWORD PTR SS:[EBP+szBuffer]&lt;br /&gt;PUSH 2E&lt;br /&gt;PUSH EAX&lt;br /&gt;CALL DWORD PTR DS:[&amp;lt;&amp;amp;msvcrt.&lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/ftw0heb9(VS.80).aspx&quot;&gt;_mbsrchr&lt;/a&gt;&amp;gt;]&lt;br /&gt;POP ECX&lt;br /&gt;POP ECX&lt;br /&gt;MOV DWORD PTR SS:[EBP-80],EAX&lt;br /&gt;&lt;span&gt;MOV BYTE PTR DS:[EAX],0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;strong&gt;&amp;lt;-- Crash!&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;br /&gt;
&lt;p&gt;The code above is from MFC42.DLL, version 6.2.4131.0 from Windows XP SP2. It effectively does the following:&lt;/p&gt;&lt;br /&gt;
&lt;blockquote dir=&quot;ltr&quot;&gt;&lt;br /&gt;
&lt;p&gt;&lt;span&gt;&lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/ms683197.aspx&quot;&gt;GetModuleFileName&lt;/a&gt;(NULL, szBuffer, MAX_PATH);&lt;br /&gt;*(&lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/ftw0heb9(VS.80).aspx&quot;&gt;_mbsrchr&lt;/a&gt;(szBuffer, .)) = 0;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;br /&gt;
&lt;p&gt;The function &lt;span&gt;&lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/ftw0heb9(VS.80).aspx&quot;&gt;_mbsrchr(...)&lt;/a&gt;&lt;/span&gt; returns NULL if the character searched for is not found. This means that if there is no . in the current processs filename (which was the case for the file I was testing) then the highlighted line above will try to write the byte 0x00 to address 0x00000000, which will cause a crash.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;I figured that this was some obscure function from MFC42.DLL that most applications dont make use of, however, after a little digging it turns out that this code is in &lt;span&gt;CWinApp::SetCurrentHandles()&lt;/span&gt;, which is called by &lt;span&gt;&lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/w04bs753(vs.80).aspx&quot;&gt;AfxWinInit(...)&lt;/a&gt;&lt;/span&gt;. From &lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/w04bs753(vs.80).aspx&quot;&gt;http://msdn2.microsoft.com/en-us/library/w04bs753(vs.80).aspx&lt;/a&gt;:&lt;/p&gt;&lt;br /&gt;
&lt;blockquote dir=&quot;ltr&quot;&gt;&lt;br /&gt;
&lt;p&gt;&quot;[AfxWinInit] is called by the MFC-supplied WinMain function, as part of the CWinApp initialization of a GUI-based application, to initialize MFC.&quot;&lt;/p&gt;&lt;/blockquote&gt;&lt;br /&gt;
&lt;p&gt;In other words, almost every MFC GUI program executes the code snippet above!&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;AAs surprised as I was by this, I figured that surely this had been fixed for Vista. Believe it or not, the same issue exists! Below is the code from MFC42.DLL version 6.6.8063.0 from Windows Vista Gold:&lt;/p&gt;&lt;br /&gt;
&lt;blockquote dir=&quot;ltr&quot;&gt;&lt;br /&gt;
&lt;p&gt;&lt;span&gt;PUSH 104&lt;br /&gt;&lt;/span&gt;&lt;span&gt;LEA EDX,DWORD PTR SS:[EBP+szBuffer]&lt;br /&gt;MOV [EDI+0C],ECX&lt;br /&gt;MOV EAX,DWORD PTR DS:[ESI+6C]&lt;br /&gt;PUSH EDX&lt;br /&gt;PUSH EAX&lt;br /&gt;CALL DWORD PTR DS:[&amp;lt;&amp;amp;KERNEL32.&lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/ms683197.aspx&quot;&gt;GetModuleFileNameA&lt;/a&gt;&amp;gt;&lt;br /&gt;TEST EAX,EAX&lt;br /&gt;JZ LOC_722F1484&lt;br /&gt;CMP EAX,104&lt;br /&gt;JZ LOC_722F1484&lt;br /&gt;LEA ECX,[EBP+szBuffer]&lt;br /&gt;PUSH 2E&lt;br /&gt;PUSH ECX&lt;br /&gt;CALL &lt;span&gt;&lt;strong&gt;__mbsrchr&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;MOV EBX,EAX&lt;br /&gt;ADD ESP,8&lt;br /&gt;TEST EBX,EBX&lt;br /&gt;MOV [EBP+VAR_310],EBX&lt;br /&gt;JZ &lt;span&gt;&lt;strong&gt;LOC_7230DB7D&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
&lt;hr /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;p&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;strong&gt;__mbsrchr&lt;/strong&gt;&lt;/span&gt;:&lt;br /&gt;MOV EDI,EDI&lt;br /&gt;PUSH EBP&lt;br /&gt;MOV EBP,ESP&lt;br /&gt;POP EBP&lt;br /&gt;JMP DWORD PTR DS:[&amp;lt;&amp;amp;msvcrt.&lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/ftw0heb9(VS.80).aspx&quot;&gt;_mbsrchr&lt;/a&gt;&amp;gt;]&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;
&lt;hr /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;p&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;strong&gt;LOC_7230DB7D&lt;/strong&gt;&lt;/span&gt;:&lt;br /&gt;...&lt;br /&gt;JMP DWORD PTR DS:[&amp;lt;&amp;amp;msvcrt.CxxThrowException&amp;gt;]&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;br /&gt;
&lt;p&gt;While the code above checks for the lack of a . in the filename, it still throws an exception and causes a crash if theres no ..&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;The good news is that it doesnt seem easy to accidentally execute an executable file without a . in the filename in Vista:&lt;/p&gt;&lt;br /&gt;
&lt;blockquote dir=&quot;ltr&quot;&gt;&lt;br /&gt;
&lt;p&gt;&lt;span&gt;C:&amp;gt;copy c:windows&lt;br /&gt;
otepad.exe notepad_exe&lt;br /&gt;1 file(s) copied.&lt;br /&gt;&lt;br /&gt;C:&amp;gt;notepad_exe&lt;br /&gt;&lt;/span&gt;&lt;span&gt;notepad_exe is not recognized as an internal or external command, operable program or batch file.&lt;br /&gt;&lt;br /&gt;C:&amp;gt;start notepad_exe&lt;br /&gt;[This opens the &quot;Open With&quot; dialog box in Explorer instead of executing the file.]&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;br /&gt;
&lt;p&gt;However, it is still possible to run non-dotted-files via API functions like &lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/ms682425(VS.85).aspx&quot;&gt;CreateProcess(...)&lt;/a&gt; to cause the crash described above.&lt;/p&gt;&lt;img src=&quot;http://malwareanalysis.com/CommunityServer/aggbug.aspx?PostID=986&quot; width=&quot;1&quot; height=&quot;1&quot; /&gt;</description>
                    </item>
                <item>
            <title>Refreshing the Taskbar Notification Area</title>
                            <pubDate>Fri, 15 Feb 2008 18:06:00 -0600</pubDate>
                                        <link>https://www.openrce.org/blog/view/1067/Refreshing_the_Taskbar_Notification_Area</link>
                                        <author>JasonGeffner &lt;email-suppressed@example.com&gt;</author>
                                                    <description>&lt;p&gt;I am working on an automation system that involves forcefully terminating a process that creates an icon in the Taskbar Notification Area &lt;a href=&quot;http://blogs.msdn.com/oldnewthing/archive/2003/09/10/54831.aspx&quot;&gt;(no, not the &quot;system tray&quot;)&lt;/a&gt;. It is the responsibility of the process that creates an icon in the Taskbar Notification Area to remove the icon when the process exits, however, since I am using &lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/ms686714.aspx&quot;&gt;TerminateProcess(...)&lt;/a&gt; to remotely kill the process, the code to remove the icon never gets executed. As such, the icon remains in the Taskbar Notification Area until one moves the mouse cursor over the icon, at which point it disappears.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Since this is an automation system thats being developed, this icon-creating process will get executed many times, and if left unchecked would end up leaving hundreds of icons in the Taskbar Notification Area (one icon per execution). Thats bad.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Despite my best Googling efforts (&quot;refresh notification area&quot;, &quot;redraw system tray&quot;, etc.), I wasnt able to find elegant code to solve this problem. I found some novel solutions, though. The most common suggestion was to use &lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/ms648393(VS.85).aspx&quot;&gt;SetCursor(...)&lt;/a&gt; to drag the mouse cursor around the Taskbar Notification Area; while this works, its an ugly hack and is actually quite slow. One of my &quot;favorite&quot; suggestions was to try to associate each icon in the Taskbar Notification Area with a process, then monitoring each process for termination, then deleting the icon once the given process terminates (talk about overkill... geeze).&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;When a user moves the mouse over a &quot;dead icon&quot; in the Taskbar Notification Area, some window message must get sent to the window to cause it to say to itself, &quot;hey, the mouse is over me, so let me see if the process that created this icon is still alive.... Oh, its not? Let me remove the icon, then.&quot; I wanted to find what window message was causing that code to fire so that I could send that message to the window myself.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;I started up &lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/aa315486(VS.60).aspx&quot;&gt;Microsoft Spy++&lt;/a&gt; and saw the following information for the Taskbar Notification Area and its parent windows:&lt;/p&gt;&lt;br /&gt;
&lt;img height=&quot;128&quot; src=&quot;http://malwareanalysis.com/CommunityServer/blogs/geffner/2008_02_15_1.jpg&quot; width=&quot;373&quot; /&gt;&lt;br /&gt;
&lt;p&gt;A useful feature of Microsoft Spy++ is that it allows you to monitor window messages sent to a given window. I started monitoring the window messages getting sent to the &quot;Notification Area&quot; window without moving my mouse over the window and saw the following messages getting sent:&lt;/p&gt;&lt;br /&gt;
&lt;ul&gt;&lt;br /&gt;
&lt;li&gt;&lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/ms940419.aspx&quot;&gt;TB_BUTTONCOUNT&lt;/a&gt; &lt;br /&gt;
&lt;li&gt;&lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/ms864705.aspx&quot;&gt;TB_GETBUTTONINFOW&lt;/a&gt; &lt;br /&gt;
&lt;li&gt;&lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/bb787413(VS.85).aspx&quot;&gt;TB_SETBUTTONINFOW&lt;/a&gt; &lt;br /&gt;
&lt;li&gt;&lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/ms534901(VS.85).aspx&quot;&gt;WM_PAINT &lt;/a&gt;&lt;br /&gt;
&lt;li&gt;&lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/ms648055(VS.85).aspx&quot;&gt;WM_ERASEBKGND&lt;/a&gt; &lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;
&lt;p&gt;The messages above clearly had nothing to do with me moving my mouse (since I wasnt moving my mouse over the window), so I configured Microsoft Spy++ to filter out those messages. Then I moved my mouse over the &quot;dead icon&quot; in question and saw the following messages:&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;font size=&quot;2&quot;&gt;&amp;lt;00001&amp;gt; 00010056 S WM_NCHITTEST xPos:1491 yPos:1024&lt;br /&gt;&amp;lt;00002&amp;gt; 00010056 R WM_NCHITTEST nHittest:HTCLIENT&lt;br /&gt;&amp;lt;00003&amp;gt; 00010056 S WM_SETCURSOR hwnd:00010056 nHittest:HTCLIENT wMouseMsg:WM_MOUSEMOVE&lt;br /&gt;&amp;lt;00004&amp;gt; 00010056 R WM_SETCURSOR fHaltProcessing:False&lt;br /&gt;&amp;lt;00005&amp;gt; 00010056 P WM_MOUSEMOVE fwKeys:0000 xPos:5 yPos:0&lt;br /&gt;&amp;lt;00006&amp;gt; 00010056 S TB_HITTEST pptHitTest:022BFC18&lt;br /&gt;&amp;lt;00007&amp;gt; 00010056 R TB_HITTEST iIndex:0&lt;br /&gt;&amp;lt;00008&amp;gt; 00010056 S TB_DELETEBUTTON iButton:0&lt;br /&gt;&amp;lt;00009&amp;gt; 00010056 R TB_DELETEBUTTON fSucceeded:True&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Aha! So either &lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/ms645618(VS.85).aspx&quot;&gt;WM_NCHITTEST&lt;/a&gt;, &lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/ms648382(VS.85).aspx&quot;&gt;WM_SETCURSOR&lt;/a&gt;, &lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/ms645616(VS.85).aspx&quot;&gt;WM_MOUSEMOVE&lt;/a&gt;, or &lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/bb787360(VS.85).aspx&quot;&gt;TB_HITTEST&lt;/a&gt; leads to the &lt;a href=&quot;http://www.piclist.com/techref/os/win/api/win32/mess/src/msg16_21.htm&quot;&gt;TB_DELETEBUTTON&lt;/a&gt; getting sent. After trying to send each window message manually with &lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/ms644950(VS.85).aspx&quot;&gt;SendMessage(...)&lt;/a&gt;, I found which window message was the catalyst: WM_MOUSEMOVE.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;With this new-found knowledge, I was able to whip up the following code to refresh the Taskbar Notification Area:&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;br /&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; align=&quot;center&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;tr&gt;&lt;br /&gt;
&lt;td&gt;&lt;font size=&quot;2&quot;&gt;#define&amp;nbsp;FW(x,y)&amp;nbsp;FindWindowEx(x,&amp;nbsp;NULL,&amp;nbsp;y,&amp;nbsp;L&quot;&quot;)&lt;br /&gt;&lt;br /&gt;void&amp;nbsp;RefreshTaskbarNotificationArea()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;HWND&amp;nbsp;hNotificationArea;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;RECT&amp;nbsp;r;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;GetClientRect(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;hNotificationArea&amp;nbsp;=&amp;nbsp;FindWindowEx(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;FW(FW(FW(NULL,&amp;nbsp;L&quot;Shell_TrayWnd&quot;),&amp;nbsp;L&quot;TrayNotifyWnd&quot;),&amp;nbsp;L&quot;SysPager&quot;),&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;NULL,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;L&quot;ToolbarWindow32&quot;,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;L&quot;Notification&amp;nbsp;Area&quot;),&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;amp;r);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for&amp;nbsp;(LONG&amp;nbsp;x&amp;nbsp;=&amp;nbsp;0;&amp;nbsp;x&amp;nbsp;&amp;lt;&amp;nbsp;r.right;&amp;nbsp;x += 5)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for&amp;nbsp;(LONG&amp;nbsp;y&amp;nbsp;=&amp;nbsp;0;&amp;nbsp;y&amp;nbsp;&amp;lt;&amp;nbsp;r.bottom;&amp;nbsp;y += 5)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;SendMessage(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;hNotificationArea,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;WM_MOUSEMOVE,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(y&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;16)&amp;nbsp;+&amp;nbsp;x);&lt;br /&gt;}&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/p&gt;&lt;img src=&quot;http://malwareanalysis.com/CommunityServer/aggbug.aspx?PostID=985&quot; width=&quot;1&quot; height=&quot;1&quot; /&gt;</description>
                    </item>
                <item>
            <title>Counting Lines of Source Code</title>
                            <pubDate>Mon, 17 Sep 2007 20:51:00 -0500</pubDate>
                                        <link>https://www.openrce.org/blog/view/899/Counting_Lines_of_Source_Code</link>
                                        <author>JasonGeffner &lt;email-suppressed@example.com&gt;</author>
                                                    <description>&lt;p&gt;Im reviewing the source code for a rather large project this week and I wanted to update &lt;a href=&quot;http://www.facebook.com/profile.php?id=416180&quot;&gt;my Facebook status&lt;/a&gt; by saying something like, &quot;Jason is reviewing 100,000 lines of Java for security vulnerabilities.&quot; However, being the perfectionist that I am I wanted to give the real number of lines of code.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;I wasnt aware of any built-in functionality in Visual Studio to do this, and after&amp;nbsp;three minutes of Googling, I found a lot of Visual Studio plugins that could do this but unfortunately I didnt find any instructions on how to do this with just plain Visual Studio. And honestly, I didnt want to install a plugin (see &lt;a href=&quot;http://blogs.msdn.com/oldnewthing/archive/2006/03/22/558007.aspx&quot;&gt;http://blogs.msdn.com/oldnewthing/archive/2006/03/22/558007.aspx&lt;/a&gt;&amp;nbsp;:)&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;I figured I could whip up a short C# program to do this, but even that seemed a little over-kill for such a simple task. Then I realized I could do this from a standard console window command prompt:&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;font&gt;&lt;a href=&quot;http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cmd.mspx&quot;&gt;cmd&lt;/a&gt; /v:on&lt;br /&gt;&lt;a href=&quot;http://technet2.microsoft.com/windowsserver2008/en/library/5fdd60d6-addf-4574-8c92-8aa53fa73d761033.mspx&quot;&gt;set&lt;/a&gt;&amp;nbsp;lines = 0&lt;br /&gt;&lt;a href=&quot;http://technet2.microsoft.com/windowsserver2008/en/library/e275726c-035f-4a74-8062-013c37f5ded11033.mspx&quot;&gt;for&lt;/a&gt; /r %a in (*.java) do (&lt;a href=&quot;http://technet2.microsoft.com/windowsserver2008/en/library/2ca66b22-3b7c-4166-8503-eb75fc53ab461033.mspx&quot;&gt;find&lt;/a&gt; /v /c &quot;&quot; &quot;%a&quot; &amp;gt; %temp%	emp.txt&lt;br /&gt;&lt;a href=&quot;http://technet2.microsoft.com/windowsserver2008/en/library/e275726c-035f-4a74-8062-013c37f5ded11033.mspx&quot;&gt;for&lt;/a&gt; /f &quot;tokens=6&quot; %b in (%temp%	emp.txt) do (&lt;a href=&quot;http://technet2.microsoft.com/windowsserver2008/en/library/5fdd60d6-addf-4574-8c92-8aa53fa73d761033.mspx&quot;&gt;set&lt;/a&gt; /a&amp;nbsp;lines += %b))&lt;br /&gt;&lt;a href=&quot;http://technet2.microsoft.com/windowsserver2008/en/library/fb9fcd0f-5e73-4504-aa95-78204e1a79d31033.mspx&quot;&gt;echo&lt;/a&gt; %lines%&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;The &quot;&lt;font&gt;tokens=6&lt;/font&gt;&quot; part is specific to the source code directory structure for this particular project, and if any of the source code subdirectories contained spaces, youd have to tweak the code above a little. But hey, it worked out quite nicely, and it was a much cleaner solution than installing a plugin.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;And Im sure theres an even shorter/simpler way to do this from a standard command prompt than with what I have above. Feel free to post cleaner &quot;solutions&quot; :)&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;(BTW, the actual number of lines turned out to be 348,523... that should keep me busy for a while.)&lt;/p&gt;&lt;img src=&quot;http://malwareanalysis.com/CommunityServer/aggbug.aspx?PostID=401&quot; width=&quot;1&quot; height=&quot;1&quot; /&gt;</description>
                    </item>
                <item>
            <title>Investigating Outlooks Single-Instance Restriction (PART 2)</title>
                            <pubDate>Sat, 01 Sep 2007 00:05:00 -0500</pubDate>
                                        <link>https://www.openrce.org/blog/view/884/Investigating_Outlooks_Single-Instance_Restriction_(PART_2)</link>
                                        <author>JasonGeffner &lt;email-suppressed@example.com&gt;</author>
                                                    <description>&lt;p&gt;Please see &lt;a href=&quot;http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2007/08/10/234.aspx&quot;&gt;PART 1&lt;/a&gt;.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;While the return value of &lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/ms633499.aspx&quot;&gt;FindWindowA&lt;/a&gt; is used to determine whether or not Outlook terminates its process, theres another issues when it comes to using a separate profile.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;Outlook calls &lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/ms529409.aspx&quot;&gt;MAPILogonEx&lt;/a&gt; without the MAPI_NEW_SESSION bit set. This causes Outlook to try to use an existing MAPI session if it can find one. Because of this, Outlook doesnt present the user with the option to choose a different profile in the second instance of Outlook; it will instead just use the profile that the first instance is using. (Why I didnt hit this issue in PART 1 is not clear.)&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;As such, to fully overcome Outlooks single-instance limitation, it is necessary to spoof the return value of the FindWindowA call in PART 1 &lt;em&gt;and&lt;/em&gt; to set the MAPI_NEW_SESSION bit in the flFlags argument passed to MAPILogonEx.&lt;/p&gt;&lt;img src=&quot;http://malwareanalysis.com/CommunityServer/aggbug.aspx?PostID=359&quot; width=&quot;1&quot; height=&quot;1&quot; /&gt;</description>
                    </item>
                <item>
            <title>Stateless Bi-Directional Proxy</title>
                            <pubDate>Tue, 28 Aug 2007 20:33:00 -0500</pubDate>
                                        <link>https://www.openrce.org/blog/view/880/Stateless_Bi-Directional_Proxy</link>
                                        <author>JasonGeffner &lt;email-suppressed@example.com&gt;</author>
                                                    <description>&lt;p&gt;After submitting my first patent two years ago to the US Patent Office, it has finally been published online!&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;You can read all the juicy details &lt;a href=&quot;http://appft1.uspto.gov/netacgi/nph-Parser?Sect1=PTO2&amp;amp;Sect2=HITOFF&amp;amp;p=1&amp;amp;u=%2Fnetahtml%2FPTO%2Fsearch-bool.html&amp;amp;r=1&amp;amp;f=G&amp;amp;l=50&amp;amp;co1=AND&amp;amp;d=PG01&amp;amp;s1=20070079366.PGNR.&amp;amp;OS=DN/20070079366&amp;amp;RS=DN/20070079366&quot;&gt;here&lt;/a&gt; and you can see diagrams &lt;a href=&quot;http://aiw2.uspto.gov/.aiw?Docid=20070079366&amp;amp;homeurl=http%3A%2F%2Fappft1.uspto.gov%2Fnetacgi%2Fnph-Parser%3FSect1%3DPTO2%2526Sect2%3DHITOFF%2526p%3D1%2526u%3D%25252Fnetahtml%25252FPTO%25252Fsearch-bool.html%2526r%3D2%2526f%3DG%2526l%3D50%2526co1%3DAND%2526d%3DPG01%2526s1%3Dgeffner.IN.%2526OS%3DIN%2Fgeffner%2526RS%3DIN%2Fgeffner&amp;amp;PageNum=&amp;amp;Rtype=&amp;amp;SectionNum=&amp;amp;idkey=FEBFACCE07D8&quot;&gt;here&lt;/a&gt; if you have a TIFF-renderer browser plug-in.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;This patent was from when I was still on the Firewall team at Microsoft, so its network-related. The&amp;nbsp;other patents of mine that should get published on the web over the next two years are from when I was on the Anti-Malware team at Microsoft, so theyre related to binary analysis... in other words, even cooler than this one ;)&lt;/p&gt;&lt;img src=&quot;http://malwareanalysis.com/CommunityServer/aggbug.aspx?PostID=339&quot; width=&quot;1&quot; height=&quot;1&quot; /&gt;</description>
                    </item>
            </channel>
</rss>
