<?xml version="1.0" encoding="UTF-8" ?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">REblog</title><subtitle type="html">A Reverse Engineer's Blog</subtitle><id>http://malwareanalysis.com/CommunityServer/blogs/geffner/atom.aspx</id><link rel="alternate" type="text/html" href="http://malwareanalysis.com/CommunityServer/blogs/geffner/default.aspx" /><link rel="self" type="application/atom+xml" href="http://malwareanalysis.com/CommunityServer/blogs/geffner/atom.aspx" /><generator uri="http://communityserver.org" version="2.0.60217.2664">Community Server</generator><updated>2006-03-17T11:31:00Z</updated><entry><title>Cross Your T's and Dot Your Filenames</title><link rel="alternate" type="text/html" href="http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2008/03/26/986.aspx" /><id>http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2008/03/26/986.aspx</id><published>2008-03-27T02:55:00Z</published><updated>2008-03-27T02:55:00Z</updated><content type="html">&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;BLOCKQUOTE dir=ltr&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="http://msdn2.microsoft.com/en-us/library/ms683197.aspx"&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="http://msdn2.microsoft.com/en-us/library/ftw0heb9(VS.80).aspx"&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;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;BLOCKQUOTE dir=ltr&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/ms683197.aspx"&gt;GetModuleFileName&lt;/A&gt;(NULL, szBuffer, MAX_PATH);&lt;BR&gt;*(&lt;A href="http://msdn2.microsoft.com/en-us/library/ftw0heb9(VS.80).aspx"&gt;_mbsrchr&lt;/A&gt;(szBuffer, '.')) = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The function &lt;SPAN&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/ftw0heb9(VS.80).aspx"&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 process's 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;P&gt;I figured that this was some obscure function from MFC42.DLL that most applications don't 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="http://msdn2.microsoft.com/en-us/library/w04bs753(vs.80).aspx"&gt;AfxWinInit(...)&lt;/A&gt;&lt;/SPAN&gt;. From &lt;A href="http://msdn2.microsoft.com/en-us/library/w04bs753(vs.80).aspx"&gt;http://msdn2.microsoft.com/en-us/library/w04bs753(vs.80).aspx&lt;/A&gt;:&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr&gt;
&lt;P&gt;"[AfxWinInit] is called by the MFC-supplied WinMain function, as part of the CWinApp initialization of a GUI-based application, to initialize MFC."&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In other words, almost every MFC GUI program executes the code snippet above!&lt;/P&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;BLOCKQUOTE dir=ltr&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="http://msdn2.microsoft.com/en-us/library/ms683197.aspx"&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;HR&gt;

&lt;P&gt;&lt;/P&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="http://msdn2.microsoft.com/en-us/library/ftw0heb9(VS.80).aspx"&gt;_mbsrchr&lt;/A&gt;&amp;gt;]&lt;BR&gt;&lt;/SPAN&gt;&lt;BR&gt;
&lt;HR&gt;

&lt;P&gt;&lt;/P&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;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 there's no '.'.&lt;/P&gt;
&lt;P&gt;The good news is that it doesn't seem easy to accidentally execute an executable file without a '.' in the filename in Vista:&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr&gt;
&lt;P&gt;&lt;SPAN&gt;C:\&amp;gt;copy c:\windows\notepad.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 "Open With" dialog box in Explorer instead of executing the file.]&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;However, it is still possible to run non-dotted-files via API functions like &lt;A href="http://msdn2.microsoft.com/en-us/library/ms682425(VS.85).aspx"&gt;CreateProcess(...)&lt;/A&gt; to cause the crash described above.&lt;/P&gt;&lt;img src="http://malwareanalysis.com/CommunityServer/aggbug.aspx?PostID=986" width="1" height="1"&gt;</content><author><name>jason</name><uri>http://malwareanalysis.com/CommunityServer/members/jason.aspx</uri></author></entry><entry><title>Refreshing the Taskbar Notification Area</title><link rel="alternate" type="text/html" href="http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2008/02/15/985.aspx" /><id>http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2008/02/15/985.aspx</id><published>2008-02-15T18:06:00Z</published><updated>2008-02-15T18:06:00Z</updated><content type="html">&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="http://blogs.msdn.com/oldnewthing/archive/2003/09/10/54831.aspx"&gt;(no, not the "system tray")&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="http://msdn2.microsoft.com/en-us/library/ms686714.aspx"&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;P&gt;Since this is an automation system that's 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). That's bad.&lt;/P&gt;
&lt;P&gt;Despite my best Googling efforts ("refresh notification area", "redraw system tray", etc.), I wasn't 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="http://msdn2.microsoft.com/en-us/library/ms648393(VS.85).aspx"&gt;SetCursor(...)&lt;/A&gt; to drag the mouse cursor around the Taskbar Notification Area; while this works, it's an ugly hack and is actually quite slow. One of my "favorite" 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;P&gt;When a user moves the mouse over a "dead icon" in the Taskbar Notification Area, some window message must get sent to the window to cause it to say to itself, "hey, the mouse is over me, so let me see if the process that created this icon is still alive.... Oh, it's not? Let me remove the icon, then." 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;P&gt;I started up &lt;A href="http://msdn2.microsoft.com/en-us/library/aa315486(VS.60).aspx"&gt;Microsoft Spy++&lt;/A&gt; and saw the following information for the Taskbar Notification Area and its parent windows:&lt;/P&gt;
&lt;IMG height=128 src="/CommunityServer/blogs/geffner/2008_02_15_1.jpg" width=373&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 "Notification Area" window without moving my mouse over the window and saw the following messages getting sent:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/ms940419.aspx"&gt;TB_BUTTONCOUNT&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/ms864705.aspx"&gt;TB_GETBUTTONINFOW&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/bb787413(VS.85).aspx"&gt;TB_SETBUTTONINFOW&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/ms534901(VS.85).aspx"&gt;WM_PAINT &lt;/A&gt;
&lt;LI&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/ms648055(VS.85).aspx"&gt;WM_ERASEBKGND&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;The messages above clearly had nothing to do with me moving my mouse (since I wasn't moving my mouse over the window), so I configured Microsoft Spy++ to filter out those messages. Then I moved my mouse over the "dead icon" in question and saw the following messages:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&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;P&gt;Aha! So either &lt;A href="http://msdn2.microsoft.com/en-us/library/ms645618(VS.85).aspx"&gt;WM_NCHITTEST&lt;/A&gt;, &lt;A href="http://msdn2.microsoft.com/en-us/library/ms648382(VS.85).aspx"&gt;WM_SETCURSOR&lt;/A&gt;, &lt;A href="http://msdn2.microsoft.com/en-us/library/ms645616(VS.85).aspx"&gt;WM_MOUSEMOVE&lt;/A&gt;, or &lt;A href="http://msdn2.microsoft.com/en-us/library/bb787360(VS.85).aspx"&gt;TB_HITTEST&lt;/A&gt; leads to the &lt;A href="http://www.piclist.com/techref/os/win/api/win32/mess/src/msg16_21.htm"&gt;TB_DELETEBUTTON&lt;/A&gt; getting sent. After trying to send each window message manually with &lt;A href="http://msdn2.microsoft.com/en-us/library/ms644950(VS.85).aspx"&gt;SendMessage(...)&lt;/A&gt;, I found which window message was the catalyst: WM_MOUSEMOVE.&lt;/P&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;P&gt;
&lt;TABLE cellSpacing=0 cellPadding=0 align=center&gt;

&lt;TR&gt;
&lt;TD&gt;&lt;FONT face="Courier New" size=2&gt;#define&amp;nbsp;FW(x,y)&amp;nbsp;FindWindowEx(x,&amp;nbsp;NULL,&amp;nbsp;y,&amp;nbsp;L"")&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"Shell_TrayWnd"),&amp;nbsp;L"TrayNotifyWnd"),&amp;nbsp;L"SysPager"),&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"ToolbarWindow32",&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"Notification&amp;nbsp;Area"),&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="http://malwareanalysis.com/CommunityServer/aggbug.aspx?PostID=985" width="1" height="1"&gt;</content><author><name>jason</name><uri>http://malwareanalysis.com/CommunityServer/members/jason.aspx</uri></author></entry><entry><title>Counting Lines of Source Code</title><link rel="alternate" type="text/html" href="http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2007/09/17/401.aspx" /><id>http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2007/09/17/401.aspx</id><published>2007-09-17T20:51:00Z</published><updated>2007-09-17T20:51:00Z</updated><content type="html">&lt;P&gt;I'm reviewing the source code for a rather large project this week and I wanted to update &lt;A href="http://www.facebook.com/profile.php?id=416180"&gt;my Facebook status&lt;/A&gt; by saying something like, "Jason is reviewing 100,000 lines of Java for security vulnerabilities." However, being the perfectionist that I am I wanted to give the real number of lines of code.&lt;/P&gt;
&lt;P&gt;I wasn't 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 didn't find any instructions on how to do this with just plain Visual Studio. And honestly, I didn't want to install a plugin (see &lt;A href="http://blogs.msdn.com/oldnewthing/archive/2006/03/22/558007.aspx"&gt;http://blogs.msdn.com/oldnewthing/archive/2006/03/22/558007.aspx&lt;/A&gt;&amp;nbsp;:)&lt;/P&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;P&gt;&lt;FONT face="Courier New"&gt;&lt;A href="http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cmd.mspx"&gt;cmd&lt;/A&gt; /v:on&lt;BR&gt;&lt;A href="http://technet2.microsoft.com/windowsserver2008/en/library/5fdd60d6-addf-4574-8c92-8aa53fa73d761033.mspx"&gt;set&lt;/A&gt;&amp;nbsp;lines = 0&lt;BR&gt;&lt;A href="http://technet2.microsoft.com/windowsserver2008/en/library/e275726c-035f-4a74-8062-013c37f5ded11033.mspx"&gt;for&lt;/A&gt; /r %a in (*.java) do (&lt;A href="http://technet2.microsoft.com/windowsserver2008/en/library/2ca66b22-3b7c-4166-8503-eb75fc53ab461033.mspx"&gt;find&lt;/A&gt; /v /c "" "%a" &amp;gt; %temp%\temp.txt&lt;BR&gt;&lt;A href="http://technet2.microsoft.com/windowsserver2008/en/library/e275726c-035f-4a74-8062-013c37f5ded11033.mspx"&gt;for&lt;/A&gt; /f "tokens=6" %b in (%temp%\temp.txt) do (&lt;A href="http://technet2.microsoft.com/windowsserver2008/en/library/5fdd60d6-addf-4574-8c92-8aa53fa73d761033.mspx"&gt;set&lt;/A&gt; /a&amp;nbsp;lines += %b))&lt;BR&gt;&lt;A href="http://technet2.microsoft.com/windowsserver2008/en/library/fb9fcd0f-5e73-4504-aa95-78204e1a79d31033.mspx"&gt;echo&lt;/A&gt; %lines%&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;The "&lt;FONT face="Courier New"&gt;tokens=6&lt;/FONT&gt;" part is specific to the source code directory structure for this particular project, and if any of the source code subdirectories contained spaces, you'd 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;P&gt;And I'm sure there's an even shorter/simpler way to do this from a standard command prompt than with what I have above. Feel free to post cleaner "solutions" :)&lt;/P&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="http://malwareanalysis.com/CommunityServer/aggbug.aspx?PostID=401" width="1" height="1"&gt;</content><author><name>jason</name><uri>http://malwareanalysis.com/CommunityServer/members/jason.aspx</uri></author></entry><entry><title>Investigating Outlook's Single-Instance Restriction (PART 2)</title><link rel="alternate" type="text/html" href="http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2007/08/31/359.aspx" /><id>http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2007/08/31/359.aspx</id><published>2007-09-01T00:05:00Z</published><updated>2007-09-01T00:05:00Z</updated><content type="html">&lt;P&gt;Please see &lt;A href="/CommunityServer/blogs/geffner/archive/2007/08/10/234.aspx"&gt;PART 1&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;While the return value of &lt;A href="http://msdn2.microsoft.com/en-us/library/ms633499.aspx"&gt;FindWindowA&lt;/A&gt; is used to determine whether or not Outlook terminates its process, there's another issues when it comes to using a separate profile.&lt;/P&gt;
&lt;P&gt;Outlook calls &lt;A href="http://msdn2.microsoft.com/en-us/library/ms529409.aspx"&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 doesn't 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 didn't hit this issue in PART 1 is not clear.)&lt;/P&gt;
&lt;P&gt;As such, to fully overcome Outlook's 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="http://malwareanalysis.com/CommunityServer/aggbug.aspx?PostID=359" width="1" height="1"&gt;</content><author><name>jason</name><uri>http://malwareanalysis.com/CommunityServer/members/jason.aspx</uri></author></entry><entry><title>Stateless Bi-Directional Proxy</title><link rel="alternate" type="text/html" href="http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2007/08/28/339.aspx" /><id>http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2007/08/28/339.aspx</id><published>2007-08-28T20:33:00Z</published><updated>2007-08-28T20:33:00Z</updated><content type="html">&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;P&gt;You can read all the juicy details &lt;A href="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"&gt;here&lt;/A&gt; and you can see diagrams &lt;A href="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"&gt;here&lt;/A&gt; if you have a TIFF-renderer browser plug-in.&lt;/P&gt;
&lt;P&gt;This patent was from when I was still on the Firewall team at Microsoft, so it's 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 they're related to binary analysis... in other words, even cooler than this one ;)&lt;/P&gt;&lt;img src="http://malwareanalysis.com/CommunityServer/aggbug.aspx?PostID=339" width="1" height="1"&gt;</content><author><name>jason</name><uri>http://malwareanalysis.com/CommunityServer/members/jason.aspx</uri></author></entry><entry><title>Investigating Outlook's Single-Instance Restriction (PART 1)</title><link rel="alternate" type="text/html" href="http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2007/08/10/234.aspx" /><id>http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2007/08/10/234.aspx</id><published>2007-08-10T19:10:00Z</published><updated>2007-08-10T19:10:00Z</updated><content type="html">&lt;P&gt;If you use Outlook and have multiple e-mail account profiles, you know how frustrating it is to have Outlook restrict you to a single running instance of Outlook per interactive login. For those of you not familiar with this "feature", here's the scoop: if you have one instance of Outlook running and then launch another instance, a new Outlook window is created in the context of the original instance, but you don't have the option to load another e-mail account profile. This is a pain because it requires you to close and restart Outlook each time you want to check a different e-mail account (assuming you have a separate profile for each account).&lt;/P&gt;
&lt;P&gt;Tim Mullen, a colleague of mine, had the ingenious idea of using RunAs to launch the second Outlook process as another user, to try to circumvent whatever "feature" was restricting Outlook to a single instance. "What a great idea!" I thought, and I kicked myself for not having thought of that myself! But when we tested it out, it had the same results as running a second instance of Outlook without RunAs; an extra window popped up for the first instance and we weren't given the option to load another profile. &lt;/P&gt;
&lt;P&gt;This &lt;A href="http://nitpickyenglishteacher.blogspot.com/2007/07/blank-my-interest.html"&gt;piqued&lt;/A&gt; my interest and I wondered how Outlook was determining whether or not another instance was already running in the interactive login session.&lt;/P&gt;
&lt;P&gt;Typically when I'm trying to figure out how specific functionality works, I have an API function or string to use as my guide. For example, if I'm red-teaming a DRM solution and I get a message box saying, "Invalid license key." then I can search in the binary for that string to see what code references it, or I can set a breakpoint on the Windows API functions that display message boxes. However, for the case of Outlook here, I didn't have any strings to base my investigation on, and I didn't know which API function(s) were being used to check for the first instance.&lt;/P&gt;
&lt;P&gt;My first idea was to use an API logging tool like &lt;A href="http://www.autodebug.com"&gt;AutoDebug&lt;/A&gt;&amp;nbsp;and run it once on the first Outlook session and once on the second Outlook session. I could then compare the API call logs and see where they differed, and then begin to investigate what caused them to differ at that point. However, I quickly found that API loggers such as AutoDebug are not suited for such a heavyweight program as Outlook (which imports a few thousand DLLs and a few million API functions (yes, I'm exaggerating, but it's still a lot)).&lt;/P&gt;
&lt;P&gt;My second idea was to use a conditional-branch logger, such as &lt;A href="http://www.woodmann.com/ollystuph/Conditional_Branch_Logger_v1.0.zip"&gt;http://www.woodmann.com/ollystuph/Conditional_Branch_Logger_v1.0.zip&lt;/A&gt; and run the same comparison as described above. However, I didn't have that plugin downloaded at the time and I didn't have Internet access, so I had to make-do with what was already on my laptop.&lt;/P&gt;
&lt;P&gt;I used Process Explorer to watch what happens when the second instance of Outlook is launched. Sure enough, the process starts and then terminates. So I used OllyDbg to set a breakpoint on ExitProcess(...) to see if I could get a decent call-stack to see what code in Outlook led to the ExitProcess(...) call. The good news is that this allowed me to find the code that led to the process termination. The bad news is that it was called via _cexit(...) from ___tmainCRTStartup(...), so whatever code was detecting the first instance of Outlook was bailing out via ret's, not via a direct call to _cexit(...) or ExitProcess(...).&lt;/P&gt;
&lt;P&gt;This led me to the old trustworthy Trial-and-Error-with-F8 method. The idea is simple -- starting from the process's Entry Point, step over (F8 in OllyDbg) every function call until you see the desired results, at which point you know the code in question lies within that function call. For this case, I was watching for a new window to pop up in the context of the first Outlook instance; by that time the check would already have been made to see if another instance of Outlook was running. The great thing about this approach is that it's incredibly straight-forward. The downside is that if you're looking for functionality that doesn't happen near the beginning of the process execution, it can be very time consuming. Luckily though, this method worked like a charm for Outlook!&lt;/P&gt;
&lt;P&gt;I started the second Outlook process in OllyDbg, stepped over the first call and into a jump. No windows popped up yet, so I hadn't yet stepped over the call-in-question. I kept pressing F8 until I found that when I tried stepping over the call from address 0x2FD251C8 (this of course is specific to my computer; your addresses will differ), an Outlook window popped up in the context of the first Outlook process. So I set a breakpoint on 0x2FD251C8 and restarted my second Outlook process, this time stepping in (F7) to that call and pressing F8 again until I found the next call that opened the first Outlook window. I found that stepping over the call at address 0x2FD25228 caused the window to pop up, so I set a breakpoint on that address, restarted, stepped in, and continued this process for about two minutes until I found the following code:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;.text:30006BB7&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; push&amp;nbsp;&amp;nbsp;&amp;nbsp; offset WindowName ; "Microsoft Outlook"&lt;BR&gt;.text:30006BBC&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; push&amp;nbsp;&amp;nbsp;&amp;nbsp; offset aMspim_wnd32 ; "mspim_wnd32"&lt;BR&gt;.text:30006BC1&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; mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [ebp+var_42C], edi&lt;BR&gt;.text:30006BC7&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; call&amp;nbsp;&amp;nbsp;&amp;nbsp; ds:FindWindowA&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;This looks like the culprit! During Outlook's initialization, it checks to see if a window named "Microsoft Outlook" with class name "mspim_wnd32" exists, and if so, it assumes that another instance is already running. To test this, I set the return value of FindWindowA(...) from the call above to NULL, and Outlook opened a full second instance of itself in a separate process, and allowed me to use a different account profile.&lt;/P&gt;
&lt;P&gt;This is a great example of where a very straight-forward reverse-engineering approach (Trial-and-Error-with-F8) can yield excellent results in just a few minutes given the right conditions.&lt;/P&gt;
&lt;P&gt;As a disclaimer, I don't know the reason that the Outlook development team decided to restrict Outlook to a single instance. Perhaps multiple instances will cause massive data corruption. In other words, if you're going to patch your Outlook executable so that it does allow for multiple instances, do so at your own risk!&lt;/P&gt;
&lt;P&gt;This post continued in &lt;A HREF="/CommunityServer/blogs/geffner/archive/2007/08/31/359.aspx"&gt;Part 2&lt;/A&gt;.&lt;/P&gt;&lt;img src="http://malwareanalysis.com/CommunityServer/aggbug.aspx?PostID=234" width="1" height="1"&gt;</content><author><name>jason</name><uri>http://malwareanalysis.com/CommunityServer/members/jason.aspx</uri></author></entry><entry><title>Career Shift</title><link rel="alternate" type="text/html" href="http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2007/04/17/20.aspx" /><id>http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2007/04/17/20.aspx</id><published>2007-04-18T04:46:00Z</published><updated>2007-04-18T04:46:00Z</updated><content type="html">&lt;P&gt;Friday, April 20th will be my final day at Microsoft. I will be joining &lt;A href="http://www.ngssoftware.com/consulting/"&gt;NGS&lt;/A&gt; in the coming weeks as a Principal Security Consultant.&lt;/P&gt;
&lt;P&gt;I've copied all of my old blog posts from &lt;A href="http://blogs.msdn.com"&gt;http://blogs.msdn.com&lt;/A&gt; to &lt;A href="http://www.malwareanalysis.com"&gt;http://www.malwareanalysis.com&lt;/A&gt; though unfortunately I was not able to save the old comments.&lt;/P&gt;
&lt;P&gt;My new personal e-mail address is jasonATmalwareanalysisDOTcom.&lt;/P&gt;&lt;img src="http://malwareanalysis.com/CommunityServer/aggbug.aspx?PostID=20" width="1" height="1"&gt;</content><author><name>jason</name><uri>http://malwareanalysis.com/CommunityServer/members/jason.aspx</uri></author></entry><entry><title>Loading Drivers in OllyDbg</title><link rel="alternate" type="text/html" href="http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2007/02/15/18.aspx" /><id>http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2007/02/15/18.aspx</id><published>2007-02-15T11:37:00Z</published><updated>2007-02-15T11:37:00Z</updated><content type="html">&lt;DIV class=postcontent&gt;
&lt;P&gt;In a &lt;A class="" href="http://blogs.msdn.com/geffner/archive/2006/08/17/704412.aspx"&gt;previous post&lt;/A&gt;, I talked about changing the &lt;FONT face="Courier New"&gt;Subsystem&lt;/FONT&gt; field in the &lt;FONT face="Courier New"&gt;IMAGE_OPTIONAL_HEADER &lt;/FONT&gt;to trick OllyDbg into loading a driver for the purpose of unpacking. However, making this single change is often not enough to be able to load the driver as an EXE in OllyDbg.&lt;/P&gt;
&lt;P&gt;From my experience (in other words, I haven't verified this in the Windows source code and I'm not speaking authoritatively here), executable files need to have NTDLL.DLL in their Import Table or have another DLL in their Import Table that will eventually cause NTDLL.DLL to get loaded. I was looking at a driver today that only had NTOSKRNL.EXE and HAL.DLL in its Import Table. The former causes BOOTVID.DLL and KDCOM.DLL to get loaded as well, however nowhere in the import chain does NTDLL.DLL get loaded. Because of this, OllyDbg can't get the driver up and running after we make the &lt;FONT face="Courier New"&gt;Subsystem&lt;/FONT&gt;&amp;nbsp;change.&lt;/P&gt;
&lt;P&gt;To solve this problem, we can add NTDLL.DLL (or anything that imports NTDLL.DLL, like KERNEL32.DLL) to the Import Table of the driver and OllyDbg&amp;nbsp;will then be able to load&amp;nbsp;the driver&amp;nbsp;as a new process.&lt;/P&gt;&lt;/DIV&gt;&lt;img src="http://malwareanalysis.com/CommunityServer/aggbug.aspx?PostID=18" width="1" height="1"&gt;</content><author><name>jason</name><uri>http://malwareanalysis.com/CommunityServer/members/jason.aspx</uri></author></entry><entry><title>Function Analysis</title><link rel="alternate" type="text/html" href="http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2007/01/12/17.aspx" /><id>http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2007/01/12/17.aspx</id><published>2007-01-12T21:44:00Z</published><updated>2007-01-12T21:44:00Z</updated><content type="html">&lt;P&gt;While analyzing a malware sample today, I came across an interesting function. It uses&amp;nbsp;red-herring local variables and red-herring global variables, and even once you get rid of that code, it's still unclear as to what the function does.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Since you don't have access to the callers of this function, I'll tell you this:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The first argument is a null-terminated ASCII string. 
&lt;LI&gt;The second argument is a null-terminated ASCII string. 
&lt;LI&gt;The third argument is an integer. &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Your challenge? Tell me what the function does. Your prize? You get to choose the name of the next malware family that I name. Stipulations:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Cannot refer to the name of a person, place, or time. 
&lt;LI&gt;Cannot refer to anything obscene or offensive. 
&lt;LI&gt;Cannot be found in a dictionary or web-search. 
&lt;LI&gt;Cannot use camel-casing for compounding words -- must begin with one uppercase letter and end with all lowercase letters. 
&lt;LI&gt;Must be a "generic" name (for example, shouldn't contain the word "bot" or "worm", since I have no idea what&amp;nbsp;class of malware I'll end up&amp;nbsp;naming next). 
&lt;LI&gt;Must be humanly pronouncable. 
&lt;LI&gt;Must be between four and eight letters in length. 
&lt;LI&gt;I have final discretion over the name in case you think of something "bad" that isn't covered by one of the rules above. &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;The winner is the first person to post a comment&amp;nbsp;that correctly and fully describes in high-level English (not in code) what the function does.&lt;/P&gt;
&lt;P&gt;And to in case you think I'm "hiring cheap labor" to analyze this for me, I'll pull a &lt;A class="" href="http://blogs.msdn.com/oldnewthing/archive/2006/05/23/604743.aspx"&gt;Raymond Chen&lt;/A&gt; and say that the MD5 of &lt;EM&gt;my&lt;/EM&gt; analysis is F2F3648B9BE371B4682B728A7A3D920F. Once the correct answer is posted, I'll post my analysis which hashes to that MD5.&lt;/P&gt;
&lt;P&gt;Here's the function:&lt;/P&gt;
&lt;TABLE class=style1 cellSpacing=0 cellPadding=0 align=center bgColor=navy&gt;

&lt;TR&gt;
&lt;TD class=""&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;&lt;PRE class=style2&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt; &lt;/SPAN&gt;sub_0           proc near
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;
 &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;var_10          &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;= dword ptr &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;-10h
&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;var_C           &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;= dword ptr &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;-0Ch
&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;var_8           &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;= dword ptr &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;-8
&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;var_4           &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;= dword ptr &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;-4
&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;arg_0           &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;= dword ptr  &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;8
&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;arg_4           &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;= dword ptr  &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;0Ch
&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;arg_8           &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;= dword ptr  &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;10h
&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;
                 push    ebp&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 mov     ebp, esp&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 sub     esp, &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;10h&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 push    ebx&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 push    esi&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 push    edi&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 mov     esi, [ebp+&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;arg_4&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 mov     [ebp+&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;var_8&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;], &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;697A259Dh&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 xor     [ebp+&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;var_8&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;], &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;182Ch&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 inc     dword ptr ds:&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;42C094h&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 and     [ebp+&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;var_C&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;], &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 and     [ebp+&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;var_4&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;], &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 jmp     short loc_94&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt; ; ---------------------------------------------------------------------------

 loc_2A:                                 &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;; CODE XREF: sub_0+A6j
&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 xor     ebx, ebx&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 add     [ebp+&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;var_8&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;], &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;3AA5h&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 inc     dword ptr ds:&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;42C094h&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 xor     edi, edi&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 jmp     short loc_81&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt; ; ---------------------------------------------------------------------------

 loc_3D:                                 &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;; CODE XREF: sub_0+8Fj
&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 mov     eax, [ebp+&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;var_4&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 add     eax, edi&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 mov     edx, [ebp+&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;arg_0&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 movsx   eax, byte ptr [edx+eax]&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 movsx   edx, byte ptr [esi+edi]&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 cmp     eax, edx&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 jnz     short loc_52&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 inc     ebx&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;
 loc_52:                                 &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;; CODE XREF: sub_0+4Fj
&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 mov     ecx, esi&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 or      eax, &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;0FFFFFFFFh&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;
 loc_57:                                 &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;; CODE XREF: sub_0+5Cj
&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 inc     eax&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 cmp     byte ptr [ecx+eax], &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 jnz     short loc_57&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 cmp     ebx, eax&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 jnz     short loc_72&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 inc     [ebp+&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;var_C&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 mov     eax, [ebp+&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;arg_8&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 cmp     [ebp+&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;var_C&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;], eax&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 jnz     short loc_72&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 mov     eax, [ebp+&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;var_4&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 jmp     short loc_C0&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt; ; ---------------------------------------------------------------------------

 loc_72:                                 &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;; CODE XREF: sub_0+60j
&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                                         &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;; sub_0+6Bj
&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 mov     eax, &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;43C9h&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 mul     [ebp+&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;var_8&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 mov     [ebp+&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;var_10&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;], eax&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 mov     [ebp+&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;var_8&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;], eax&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 inc     edi&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;
 loc_81:                                 &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;; CODE XREF: sub_0+3Bj
&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 mov     ecx, esi&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 or      eax, &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;0FFFFFFFFh&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;
 loc_86:                                 &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;; CODE XREF: sub_0+8Bj
&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 inc     eax&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 cmp     byte ptr [ecx+eax], &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 jnz     short loc_86&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 cmp     edi, eax&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 jb      short loc_3D&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 inc     [ebp+&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;var_4&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;
 loc_94:                                 &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;; CODE XREF: sub_0+28j
&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 mov     eax, [ebp+&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;arg_0&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 mov     ecx, eax&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 or      eax, &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;0FFFFFFFFh&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;
 loc_9C:                                 &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;; CODE XREF: sub_0+A1j
&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 inc     eax&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 cmp     byte ptr [ecx+eax], &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 jnz     short loc_9C&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 cmp     [ebp+&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;var_4&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;], eax&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 jb      short loc_2A&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 mov     eax, &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;0FFFFh&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 jmp     short loc_C0&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt; ; ---------------------------------------------------------------------------
                 mov     eax, &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;514Ah&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 mul     dword ptr [ebp-&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;8&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 mov     [ebp-&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;10h&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;], eax&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 mov     eax, [ebp-&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;10h&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 mov     [ebp-&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;8&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;], eax&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;
 loc_C0:                                 &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;; CODE XREF: sub_0+70j
&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                                         &lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;; sub_0+ADj
&lt;/SPAN&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 pop     edi&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 pop     esi&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 pop     ebx&lt;/SPAN&gt;
&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;                 leave
                 retn
 &lt;/SPAN&gt;sub_0           endp
&lt;/PRE&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD class=""&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;
&lt;P&gt;And here's the raw byte-code for the function above:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;5589E583EC105356578B750CC745F89D257A698175F82C180000FF0594C04200&lt;BR&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;8365F4008365FC00EB6A31DB8145F8A53A0000FF0594C0420031FFEB448B45FC&lt;BR&gt;01F88B55080FBE04020FBE143E39D075014389F183C8FF40803C010075F939C3&lt;BR&gt;7510FF45F48B45103945F475058B45FCEB4EB8C9430000F765F88945F08945F8&lt;BR&gt;4789F183C8FF40803C010075F939C772ACFF45FC8B450889C183C8FF40803C01&lt;BR&gt;0075F93945FC7282B8FFFF0000EB11B84A510000F765F88945F08B45F08945F8&lt;BR&gt;5F5E5BC9C3&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;img src="http://malwareanalysis.com/CommunityServer/aggbug.aspx?PostID=17" width="1" height="1"&gt;</content><author><name>jason</name><uri>http://malwareanalysis.com/CommunityServer/members/jason.aspx</uri></author></entry><entry><title>Virus Bulletin 2006</title><link rel="alternate" type="text/html" href="http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2006/09/14/16.aspx" /><id>http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2006/09/14/16.aspx</id><published>2006-09-14T21:36:00Z</published><updated>2006-09-14T21:36:00Z</updated><content type="html">&lt;P&gt;I bought my plane ticket a few hours ago for &lt;A href="http://www.virusbtn.com/conference/vb2006/index"&gt;Virus Bulletin 2006&lt;/A&gt;. I'm looking forward to rubbing elbows with other virus analysts and discussing the latest and greatest reverse engineering tools and methods.&lt;/P&gt;
&lt;P&gt;If you're going to VB'06 as well, send me an e-mail or find me in person and mention my blog and I'll buy you a beer (which shouldn't be too hard seeing as how the conference will be in Montreal)!&lt;/P&gt;&lt;img src="http://malwareanalysis.com/CommunityServer/aggbug.aspx?PostID=16" width="1" height="1"&gt;</content><author><name>jason</name><uri>http://malwareanalysis.com/CommunityServer/members/jason.aspx</uri></author></entry><entry><title>When the Red Pill is Hard to Swallow</title><link rel="alternate" type="text/html" href="http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2006/08/21/15.aspx" /><id>http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2006/08/21/15.aspx</id><published>2006-08-21T06:55:00Z</published><updated>2006-08-21T06:55:00Z</updated><content type="html">&lt;DIV class=postcontent&gt;
&lt;P&gt;I was looking at a malware sample last week that used a variation of Joanna Rutkowska's infamous Red Pill (&lt;A href="http://invisiblethings.org/papers/redpill.html"&gt;http://invisiblethings.org/papers/redpill.html&lt;/A&gt;) to determine whether or not&amp;nbsp;the malware&amp;nbsp;was being run from inside a Virtual Machine. Based on the Red Pill concept, the guest OS's &lt;FONT face="Courier New"&gt;IDTR&lt;/FONT&gt; should be different from the host OS's &lt;FONT face="Courier New"&gt;IDTR&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;I was using Virtual PC to step through&amp;nbsp;the malware sample&amp;nbsp;in OllyDbg, with the goal of skipping the conditional-jump after &lt;FONT face="Courier New"&gt;SIDT&lt;/FONT&gt; led to the detection of my VM (see &lt;A href="http://download.intel.com/design/Pentium4/manuals/25366720.pdf#page=275"&gt;http://download.intel.com/design/Pentium4/manuals/25366720.pdf#page=275&lt;/A&gt;&amp;nbsp;for details on the &lt;FONT face="Courier New"&gt;SIDT&lt;/FONT&gt; instruction). You can imagine my surprise when &lt;FONT face="Courier New"&gt;SIDT&lt;/FONT&gt; returned &lt;FONT face="Courier New"&gt;0x8003F400&lt;/FONT&gt; as the&amp;nbsp;base address&amp;nbsp;of the &lt;FONT face="Courier New"&gt;IDT&lt;/FONT&gt;, which is the&amp;nbsp;same base address&amp;nbsp;of the &lt;FONT face="Courier New"&gt;IDT&lt;/FONT&gt; for my host Windows XP system!&lt;/P&gt;
&lt;P&gt;My first thought was that maybe the Virtual PC team figured out some ingenious way to make this happen via the Virtual Machine Additions add-on (see &lt;A href="http://www.microsoft.com/technet/prodtechnol/virtualserver/2005/proddocs/vs_tr_components_additions.mspx?mfr=true"&gt;http://www.microsoft.com/technet/prodtechnol/virtualserver/2005/proddocs/vs_tr_components_additions.mspx?mfr=true&lt;/A&gt;). So I uninstalled Virtual Machine Additions, rebooted, and tried again. To my continued surprise, OllyDbg was still showing the host OS's &lt;FONT face="Courier New"&gt;IDTR&lt;/FONT&gt; when stepping through the &lt;FONT face="Courier New"&gt;SIDT&lt;/FONT&gt; instruction on my guest OS.&lt;/P&gt;
&lt;P&gt;After some more thinking, I thought, "maybe it has something to do with the fact that I'm single-stepping through &lt;FONT face="Courier New"&gt;SIDT&lt;/FONT&gt; in OllyDbg." To&amp;nbsp;test this hypothesis, I set a breakpoint after the &lt;FONT face="Courier New"&gt;SIDT&lt;/FONT&gt; instruction, and ran the program from the start. Sure enough, &lt;FONT face="Courier New"&gt;SIDT&lt;/FONT&gt; returned &lt;FONT face="Courier New"&gt;0xF9CB6440&lt;/FONT&gt; as the base address of the &lt;FONT face="Courier New"&gt;IDT&lt;/FONT&gt; that time.&lt;/P&gt;
&lt;P&gt;The whole trick behind the Red Pill is that VMs don't typically have the opportunity to intercept &lt;FONT face="Courier New"&gt;SIDT&lt;/FONT&gt; since it's not a privileged instruction. However, when the &lt;FONT face="Courier New"&gt;Trap Flag&lt;/FONT&gt; is set (due to single-stepping), Virtual PC&amp;nbsp;intercepts&amp;nbsp;the&amp;nbsp;&lt;FONT face="Courier New"&gt;int 1&lt;/FONT&gt; interrupt and&amp;nbsp;can execute the current instruction however it pleases; when it has the opportunity, it will use the host's &lt;FONT face="Courier New"&gt;IDTR&lt;/FONT&gt; for the &lt;FONT face="Courier New"&gt;SIDT&lt;/FONT&gt; instruction.&lt;/P&gt;
&lt;P&gt;Hopefully this knowledge will make the Red Pill a little easier for you to swallow (or spit-out if&amp;nbsp;the &lt;FONT face="Courier New"&gt;Trap Flag&lt;/FONT&gt; is set).&lt;/P&gt;&lt;/DIV&gt;&lt;img src="http://malwareanalysis.com/CommunityServer/aggbug.aspx?PostID=15" width="1" height="1"&gt;</content><author><name>jason</name><uri>http://malwareanalysis.com/CommunityServer/members/jason.aspx</uri></author></entry><entry><title>Unpacking DLLs and Drivers with OllyDbg</title><link rel="alternate" type="text/html" href="http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2006/08/17/14.aspx" /><id>http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2006/08/17/14.aspx</id><published>2006-08-17T07:27:00Z</published><updated>2006-08-17T07:27:00Z</updated><content type="html">&lt;DIV class=postcontent&gt;
&lt;P&gt;People often ask me how to unpack DLLs and drivers. A common assumption is that it is&amp;nbsp;necessary to use OllyDbg's LOADDLL for unpacking DLLs and that a ring-0 debugger such as SoftICE or WinDbg is necessary for unpacking drivers. With a little tweaking, we can use regular OllyDbg to unpack packed DLLs and even&amp;nbsp;many packed&amp;nbsp;drivers.&lt;/P&gt;
&lt;P&gt;I don't know about you, but I've always had problems with LOADDLL. Even though it's well documented in OllyDbg's help file (the source is even included in the help file), I'd rather not use it if I don't have to. So how can we load a DLL into OllyDbg so that we can unpack it like we would a normal EXE?&lt;/P&gt;
&lt;P&gt;All that you need to do is&amp;nbsp;set the &lt;FONT face="Courier New"&gt;IMAGE_FILE_DLL&lt;/FONT&gt; bit to zero in the &lt;FONT face="Courier New"&gt;Characteristics&lt;/FONT&gt; field of the PE's &lt;FONT face="Courier New"&gt;IMAGE_FILE_HEADER&lt;/FONT&gt; structure. You could use a hex editor to make this change, but it's easier with a PE editor like LordPE. Once this flag is zeroed out, you can load the "DLL" into OllyDbg and OllyDbg and the OS will interpret it as an EXE. You can then unpack it as you would an EXE (trace to the OEP, dump, fix the imports, etc.), and then set the &lt;FONT face="Courier New"&gt;IMAGE_FILE_DLL&lt;/FONT&gt; bit back to one in the unpacked file.&lt;/P&gt;
&lt;P&gt;The only catch is that&amp;nbsp;many unpacking stubs check to see if &lt;FONT face="Courier New"&gt;[EBP+0x0C] == 1&lt;/FONT&gt; (does the &lt;FONT face="Courier New"&gt;fdwReason&lt;/FONT&gt; argument to &lt;FONT face="Courier New"&gt;DllMain&lt;/FONT&gt; equal &lt;FONT face="Courier New"&gt;DLL_PROCESS_ATTACH&lt;/FONT&gt;), and if it doesn't equal &lt;FONT face="Courier New"&gt;1&lt;/FONT&gt; then it won't continue to unpack itself. You can fix this problem by looking for this comparison and forcing a jump/no-jump or by manually pushing three &lt;FONT face="Courier New"&gt;DWORD&lt;/FONT&gt;s onto the stack (before executing the first instruction at the EP), the second of which should be &lt;FONT face="Courier New"&gt;1&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;We can use the same PE header patching trick for loading drivers into OllyDbg for unpacking purposes. By setting the &lt;FONT face="Courier New"&gt;Subsystem&lt;/FONT&gt; field to &lt;FONT face="Courier New"&gt;2&lt;/FONT&gt; (&lt;FONT face="Courier New"&gt;IMAGE_SUBSYSTEM_WINDOWS_GUI&lt;/FONT&gt;) in the PE's &lt;FONT face="Courier New"&gt;IMAGE_OPTIONAL_HEADER&lt;/FONT&gt;, OllyDbg and the OS will interpret the file as an EXE instead of as a driver. This allows us to trace through the unpacking stub until the code and data are unpacked, and we can dump the&amp;nbsp;process when we find the OEP. Of course if the unpacking stub is trying to execute instructions/functions that need to be executed from ring-0 then we won't be able to unpack it like this. However, if the unpacking stub is just doing a lot of simple XORing to unpack the original code and data, then we should be able to use this trick to successfully unpack the driver with OllyDbg.&lt;/P&gt;&lt;/DIV&gt;&lt;img src="http://malwareanalysis.com/CommunityServer/aggbug.aspx?PostID=14" width="1" height="1"&gt;</content><author><name>jason</name><uri>http://malwareanalysis.com/CommunityServer/members/jason.aspx</uri></author></entry><entry><title>Terms of the Trade</title><link rel="alternate" type="text/html" href="http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2006/06/05/13.aspx" /><id>http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2006/06/05/13.aspx</id><published>2006-06-05T10:40:00Z</published><updated>2006-06-05T10:40:00Z</updated><content type="html">&lt;P class=MsoNormal&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN&gt;It is common to hear reverse engineers throw around the phrase, “forty-thousand hex”. To someone unfamiliar with reverse engineering or debugging in Windows, this phrase would probably be interpreted to mean the value &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN&gt;0x00040000&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN&gt;. However, when reverse engineers say, “forty-thousand hex”, they are actually referring to the value &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN&gt;0x00400000&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN&gt;The value &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN&gt;0x00400000&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN&gt; is commonly seen when doing low-level work in Windows because this is the default base address of EXE files compiled by Microsoft’s C++ compiler.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN&gt;So why say “forty-thousand hex” instead of “four-hundred-thousand hex”? For starters, the former is easier to say (one less syllable) than the latter. But more importantly, hexadecimal numbers are usually grouped in sets of 2-digits (bytes) instead of in groups of 3-digits as in base 10. As such, a reverse engineer could read &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN&gt;0x00400000&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN&gt; as &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN&gt;0x00,40,00,00&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN&gt;. Going from right-to-left, we have &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN&gt;00&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN&gt; in the “tens” place, &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN&gt;00&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN&gt; in the “hundreds” place, and &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;SPAN&gt;40&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Verdana size=2&gt;&lt;SPAN&gt; in the “thousands” place.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://malwareanalysis.com/CommunityServer/aggbug.aspx?PostID=13" width="1" height="1"&gt;</content><author><name>jason</name><uri>http://malwareanalysis.com/CommunityServer/members/jason.aspx</uri></author></entry><entry><title>Circumventing custom SEH</title><link rel="alternate" type="text/html" href="http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2006/05/07/12.aspx" /><id>http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2006/05/07/12.aspx</id><published>2006-05-07T05:47:00Z</published><updated>2006-05-07T05:47:00Z</updated><content type="html">&lt;DIV class=postcontent&gt;
&lt;P&gt;I do most of my malware analysis statically, which is to say that I typically analyze malware by looking at a static disassembly of it as opposed to stepping through it in a debugger. However, sometimes I come across&amp;nbsp;complicated or confusing&amp;nbsp;code&amp;nbsp;that would be easier to understand by&amp;nbsp;walking through it in a debugger.&lt;/P&gt;
&lt;P&gt;I came across such an example the other day. An important branch decision was being made based on the result of a function that used a stack variable that IDA Pro couldn't represent in a simple way. Here's a snippet&amp;nbsp;from the function:&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; edx, [ebp+arg_0]&lt;BR&gt;add&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; edx, 108h&lt;BR&gt;push&amp;nbsp;&amp;nbsp;&amp;nbsp; edx&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I could have traced back in the disassembly to figure out what &lt;FONT face="Courier New"&gt;arg_0&lt;/FONT&gt; + &lt;FONT face="Courier New"&gt;108h&lt;/FONT&gt; was really pointing to (it turned out to be a global variable and &lt;FONT face="Courier New"&gt;arg_0&lt;/FONT&gt; was set by the caller of the caller of this function), but I thought that I could save time by loading the target into a debugger and setting a breakpoint on the code above in order to determine what was actually being pushed.&lt;/P&gt;
&lt;P&gt;There was a problem, though. This malware launced other instances of itself,&amp;nbsp;and setting a breakpoint on the code above in a debugger didn't work since the&amp;nbsp;parent process never executed that code, only the&amp;nbsp;child instances did. I could have set a breakpoint on &lt;FONT face="Courier New"&gt;CreateProcessA(...)&lt;/FONT&gt;, forced it to load the child processes in a suspended state, attached a debugger to the children, then resumed them, but this was more trouble than it was worth. Instead, I opted for another method of attack.&lt;/P&gt;
&lt;P&gt;I configured my debugger for Just-In-Time (JIT) debugging (see &lt;A href="http://support.microsoft.com/default.aspx?scid=kb;en-us;103861"&gt;http://support.microsoft.com/default.aspx?scid=kb;en-us;103861&lt;/A&gt;) so that I could attach to a crashed process via the Microsoft Application Error Reporting dialog box (also known as "Dr. Watson" -- see &lt;A href="http://blogs.msdn.com/oldnewthing/archive/2005/08/10/449866.aspx"&gt;http://blogs.msdn.com/oldnewthing/archive/2005/08/10/449866.aspx&lt;/A&gt;). I then overwrote the code above with an &lt;FONT face="Courier New"&gt;int 3&lt;/FONT&gt; and patched the file, with the expectation that after running the parent program that this would crash the child process, cause the Microsoft Application Error Reporting dialog box to pop up, and allow me to attach to the crashed child process. (It should be noted that this was done on an isolated network in a &lt;EM&gt;very&lt;/EM&gt; controlled environment, and with all of&amp;nbsp;our safeguards in place it was practically impossible for the modified malware to get out of our secure lab.)&lt;/P&gt;
&lt;P&gt;I saved the patched file and ran it, waiting eagerly for the Microsoft Application Error Reporting dialog box to appear. To my surprise, nothing happened. As it turned out, the program was using custom Structured Exception Handling (SEH) routines and because of this the &lt;FONT face="Courier New"&gt;int 3&lt;/FONT&gt; exception was never passed to the operating system so the Microsoft Application Error Reporting dialog box never popped up. To remediate this, I changed my &lt;FONT face="Courier New"&gt;int 3&lt;/FONT&gt; patch to the following:&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; eax, fs:[0]&lt;BR&gt;mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [eax+4], 7c8399f3h&lt;BR&gt;int&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This effectively overwrote the first exception handler in the SEH chain (see &lt;A href="http://www.microsoft.com/msj/0197/exception/exception.aspx"&gt;http://www.microsoft.com/msj/0197/exception/exception.aspx&lt;/A&gt;) with the default exception handler from kernel32.dll. The address of this handler is of course version-specific; in my case kernel32.dll was US English version 5.1.2600.2180.&lt;/P&gt;
&lt;P&gt;With this patch in place,&amp;nbsp;the Microsoft Application Error Reporting dialog box popped up for the child process and I was able to attach my debugger and determine the value of &lt;FONT face="Courier New"&gt;arg_0&lt;/FONT&gt; + &lt;FONT face="Courier New"&gt;108h&lt;/FONT&gt; from the original code above.&lt;/P&gt;&lt;/DIV&gt;&lt;img src="http://malwareanalysis.com/CommunityServer/aggbug.aspx?PostID=12" width="1" height="1"&gt;</content><author><name>jason</name><uri>http://malwareanalysis.com/CommunityServer/members/jason.aspx</uri></author></entry><entry><title>Using Structure Offsets as Symbolic Constants in IDA</title><link rel="alternate" type="text/html" href="http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2006/03/17/11.aspx" /><id>http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2006/03/17/11.aspx</id><published>2006-03-17T18:31:00Z</published><updated>2006-03-17T18:31:00Z</updated><content type="html">&lt;DIV class=postcontent&gt;
&lt;P&gt;I was analyzing Win32/Valla.2048 today, a file infector written in x86 Assembly. It keeps almost all of its variables (file handles, API function addresses, etc.) at the end of its section and it references these variables relative to EDI:&lt;/P&gt;
&lt;DIV align=center&gt;
&lt;TABLE id=table2 cellSpacing=0 cellPadding=8 bgColor=#000080&gt;

&lt;TR&gt;
&lt;TD&gt;
&lt;P align=left&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;&lt;SPAN&gt;XOR:0040619A&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; push&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;2&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN&gt;XOR:0040619C&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; push&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN&gt;XOR:0040619E&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; push&amp;nbsp;&amp;nbsp;&amp;nbsp; dword ptr [edi+&lt;/SPAN&gt;&lt;SPAN&gt;6EBh&lt;/SPAN&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN&gt;XOR:004061A4&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; call&amp;nbsp;&amp;nbsp;&amp;nbsp; dword ptr [edi+&lt;/SPAN&gt;&lt;SPAN&gt;602h&lt;/SPAN&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN&gt;XOR:004061AA&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; mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [edi+&lt;/SPAN&gt;&lt;SPAN&gt;6EFh&lt;/SPAN&gt;&lt;SPAN&gt;], eax&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN&gt;XOR:004061B0&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; push&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN&gt;XOR:004061B2&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; push&amp;nbsp;&amp;nbsp;&amp;nbsp; dword ptr [edi+&lt;/SPAN&gt;&lt;SPAN&gt;6F7h&lt;/SPAN&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN&gt;XOR:004061B8&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; push&amp;nbsp;&amp;nbsp;&amp;nbsp; dword ptr [edi+&lt;/SPAN&gt;&lt;SPAN&gt;6EBh&lt;/SPAN&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN&gt;XOR:004061BE&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; call&amp;nbsp;&amp;nbsp;&amp;nbsp; dword ptr [edi+&lt;/SPAN&gt;&lt;SPAN&gt;602h&lt;/SPAN&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would have liked to be able to create symbolic constants for these values, but there's no "New", "Add", etc. button in IDA's "Use standard symbolic constant" window:&lt;/P&gt;
&lt;P align=center&gt;&lt;IMG height=162 src="/CommunityServer/blogs/geffner/2006_03_17_1.gif" width=600 border=0&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I probably could have created a Type Library for IDA, but this would have been more trouble than it was worth. So instead, I created a structure (named "v" for "Valla"):&lt;/P&gt;
&lt;DIV align=center&gt;
&lt;TABLE id=table3 cellSpacing=0 cellPadding=8 bgColor=#000080&gt;

&lt;TR&gt;
&lt;TD&gt;
&lt;P align=left&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;00000000 &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;v&lt;/SPAN&gt;&lt;FONT color=#c0c0c0&gt;&lt;SPAN&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; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN&gt;struc &lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;; (sizeof=0x704)&lt;BR&gt;00000000 &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;code&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT face=Fixedsys color=#00ff00&gt;db 1476 dup(?)&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; string(C)&lt;BR&gt;000005C4 &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;moduleAddressOfKernel32&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt; dd ?&lt;BR&gt;000005C8 &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;virtualAddressOfKernel32ExportTable&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt; dd ?&lt;BR&gt;000005CC &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;pOriginalEntrypointMinusInfectorsEntrypoint&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt; dd ?&lt;BR&gt;000005D0 &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;originalEntrypointMinusInfectorsEntrypoint&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt; dd ?&lt;BR&gt;000005D4 &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;_lopen&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dd ?&lt;BR&gt;000005D8 field_5D8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT face=Fixedsys color=#00ff00&gt;db 7 dup(?)&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&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; ; string(C)&lt;BR&gt;000005DF &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;_lread&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dd ?&lt;BR&gt;000005E3 field_5E3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT face=Fixedsys color=#00ff00&gt;db 7 dup(?)&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&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; ; string(C)&lt;BR&gt;000005EA &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;_lwrite&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dd ?&lt;BR&gt;000005EE field_5EE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT face=Fixedsys color=#00ff00&gt;db 8 dup(?)&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&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; ; string(C)&lt;BR&gt;000005F6 &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;_lclose&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dd ?&lt;BR&gt;000005FA field_5FA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT face=Fixedsys color=#00ff00&gt;db 8 dup(?)&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&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; ; string(C)&lt;BR&gt;00000602 &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;_llseek&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dd ?&lt;BR&gt;00000606 field_606&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT face=Fixedsys color=#00ff00&gt;db 8 dup(?)&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&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; ; string(C)&lt;BR&gt;0000060E &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;FindFirstFileA&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp; dd ?&lt;BR&gt;00000612 field_612&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT face=Fixedsys color=#00ff00&gt;db 15 dup(?)&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; string(C)&lt;BR&gt;00000621 &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;FindNextFileA&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp; dd ?&lt;BR&gt;00000625 field_625&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT face=Fixedsys color=#00ff00&gt;db 14 dup(?)&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; string(C)&lt;BR&gt;00000633 &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;FindClose&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dd ?&lt;BR&gt;00000637 field_637&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT face=Fixedsys color=#00ff00&gt;db 10 dup(?)&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; string(C)&lt;BR&gt;00000641 &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;GlobalAlloc&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dd ?&lt;BR&gt;00000645 field_645&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT face=Fixedsys color=#00ff00&gt;db 12 dup(?)&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; string(C)&lt;BR&gt;00000651 &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;GlobalLock&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dd ?&lt;BR&gt;00000655 field_655&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT face=Fixedsys color=#00ff00&gt;db 11 dup(?)&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; string(C)&lt;BR&gt;00000660 &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;GlobalFree&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dd ?&lt;BR&gt;00000664 field_664&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT face=Fixedsys color=#00ff00&gt;db 11 dup(?)&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; string(C)&lt;BR&gt;0000066F &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;GetTickCount&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dd ?&lt;BR&gt;00000673 field_673&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT face=Fixedsys color=#00ff00&gt;db 13 dup(?)&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; string(C)&lt;BR&gt;00000680 &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;GetWindowsDirectoryA&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt; dd ?&lt;BR&gt;00000684 field_684&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT face=Fixedsys color=#00ff00&gt;db 21 dup(?)&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; string(C)&lt;BR&gt;00000699 &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;GetSystemDirectoryA&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt; dd ?&lt;BR&gt;0000069D field_69D&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT face=Fixedsys color=#00ff00&gt;db 20 dup(?)&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; string(C)&lt;BR&gt;000006B1 &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;GetFileAttributesA&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt; dd ?&lt;BR&gt;000006B5 field_6B5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT face=Fixedsys color=#00ff00&gt;db 19 dup(?)&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; string(C)&lt;BR&gt;000006C8 &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;SetFileAttributesA&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt; dd ?&lt;BR&gt;000006CC field_6CC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT face=Fixedsys color=#00ff00&gt;db 19 dup(?)&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; string(C)&lt;BR&gt;000006DF &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;tickCount&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dd ?&lt;BR&gt;000006E3 field_6E3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; db ?&lt;BR&gt;000006E4 &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;dotdot&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT face=Fixedsys color=#00ff00&gt;db 3 dup(?)&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&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; ; string(C)&lt;BR&gt;000006E7 &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;starDotStar&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT face=Fixedsys color=#00ff00&gt;db 4 dup(?)&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&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; ; string(C)&lt;BR&gt;000006EB &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;hFile&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dd ?&lt;BR&gt;000006EF &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;fileSize&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dd ?&lt;BR&gt;000006F3 &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;rvaOfNewSection&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt; dd ?&lt;BR&gt;000006F7 &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;offsetOfPEHeader&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt; dd ?&lt;BR&gt;000006FB &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;pAllocatedMemory64K&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt; dd ?&lt;BR&gt;000006FF &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;hMem&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dd ?&lt;BR&gt;&lt;SPAN&gt;00000703&lt;/SPAN&gt; &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;banner&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; db ?&lt;BR&gt;&lt;SPAN&gt;00000704&lt;/SPAN&gt; &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;v&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face=Fixedsys color=#c0c0c0&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; &lt;/FONT&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;ends&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This allowed me to then tell IDA to interpret the EDI offsets as structure offsets, making it much easier to analyze the virus:&lt;/P&gt;
&lt;DIV align=center&gt;
&lt;TABLE id=table1 cellSpacing=0 cellPadding=8 bgColor=#000080&gt;

&lt;TR&gt;
&lt;TD&gt;
&lt;P align=left&gt;&lt;FONT face=Fixedsys&gt;&lt;SPAN&gt;XOR:0040619A&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; push&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;2&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR&gt;&lt;SPAN&gt;XOR:0040619C&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; push&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN&gt;XOR:0040619E&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; push&amp;nbsp;&amp;nbsp;&amp;nbsp; [edi+&lt;/SPAN&gt;v.hFile&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN&gt;XOR:004061A4&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; call&amp;nbsp;&amp;nbsp;&amp;nbsp; [edi+&lt;/SPAN&gt;v._llseek&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;SPAN&gt;XOR:004061AA&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; mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [edi+&lt;/SPAN&gt;v.fileSize&lt;SPAN&gt;], eax&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN&gt;XOR:004061B0&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; push&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR&gt;&lt;SPAN&gt;XOR:004061B2&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; push&amp;nbsp;&amp;nbsp;&amp;nbsp; [edi+&lt;/SPAN&gt;v.offsetOfPEHeader&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN&gt;XOR:004061B8&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; push&amp;nbsp;&amp;nbsp;&amp;nbsp; [edi+&lt;/SPAN&gt;v.hFile&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;BR&gt;&lt;SPAN&gt;XOR:004061BE&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; call&amp;nbsp;&amp;nbsp;&amp;nbsp; [edi+&lt;/SPAN&gt;v._llseek&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;img src="http://malwareanalysis.com/CommunityServer/aggbug.aspx?PostID=11" width="1" height="1"&gt;</content><author><name>jason</name><uri>http://malwareanalysis.com/CommunityServer/members/jason.aspx</uri></author></entry></feed>