home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / DISASSEMBL20306411132006.psc / disasm_vb.txt < prev   
Text File  |  2006-11-13  |  69KB  |  1,635 lines

  1. ********************************************************************************
  2. *                   DISASSEMBLING VISUAL BASIC APPLICATIONS - II               *
  3. *                                                   - Sanchit Karve            *
  4. *                                                                              *
  5. *                                                      born2c0de               *
  6. *                                               printf("I'm a %XR",195936478); *
  7. *                                                                              *
  8. *       CONTACT ME :       born2c0de AT dreamincode DOT net                    *
  9. *                                                                              *
  10. ********************************************************************************
  11.  
  12.                          LAST UPDATED :  13 NOVEMBER 2006
  13.  
  14. --------------------------------------------------------------------------------
  15.                               INDEX [INDX]
  16.  
  17.  
  18. I.         DISCLAIMER AND NOTICE          [DISN]
  19. II.        READING THIS TUTORIAL          [RTUT]
  20. III.       ASSUMPTIONS                    [ASPT]
  21. IV.        REQUIRED TOOLS AND DOCS        [RQRT]
  22. V.         VB AS A LANGUAGE               [VBAL]
  23. VI.        INTRODUCTION                   [ITRO]
  24. VII.       STRUCTURE OF A VB PROGRAM      [SVBP]
  25. VIII.      OUR FIRST PROGRAM              [OFPR]
  26. IX.        STRING COMPARISON              [STR1]
  27. X.         DECIPHERING A KEY GENERATOR    [DKGN]
  28. XI.        CONCLUSION                     [END1]
  29.  
  30.  
  31. --------------------------------------------------------------------------------
  32.  
  33.  
  34.  
  35. --------------------------------------------------------------------------------
  36.  
  37. I.         DISCLAIMER AND NOTICE          [DISN]
  38.  
  39. This tutorial is meant for educational purposes only.
  40.  
  41. If the Reader chooses to break Protection Mechamisms after reading this
  42. tutorial, he/she shall alone be responsible for the damages caused and not the
  43. Author.
  44.  
  45. If you wish to post portions of this tutorial on a WebSite, you are free to do
  46. so as long as you abide by these rules:
  47.  
  48. -> Post the selected portion in unedited form.
  49. -> Mention the Author's Name,Email Address and Name of this tutorial above or
  50.    below the selected text.
  51. -> Inform the Author.
  52.  
  53. The Author has not copied text or any other information directly from a Source.
  54. However, some information from some sources has been used to write this tutorial.
  55. These Sources have been mentioned in the References Section.
  56.  
  57. You are permitted to continue reading the tutorial only if you agree to the text
  58. given above.
  59.  
  60. --------------------------------------------------------------------------------
  61.  
  62. II.        READING THIS TUTORIAL          [RTUT]
  63.  
  64. Each Section in this Tutorial has a specific Topic Code enclosed in square
  65. brackets. This arrangement has been made so that you can jump to a specific
  66. topic simply by searching for the topic code from your Browser.
  67.  
  68. At many places in the tutorial, I've explained a few things which are almost
  69. unnecessary to know when dealing with Visual BASIC programs but I've written
  70. them for those who have a thirst for knowledge.
  71.  
  72. The Topic Code Tags [XTRA] and [/XTRA] have been given for "extra-information"
  73. sections and you are free to skip them.
  74. Text within the [XTRA]...[/XTRA] blocks is given for extra information.
  75. You can search for the Extra Information using the Topic Code.
  76.  
  77. --------------------------------------------------------------------------------
  78.  
  79. III.       ASSUMPTIONS                    [ASPT]
  80.  
  81. You are required to have a basic understanding of:
  82. : Visual BASIC
  83. : C/C++
  84. : Win31 API
  85. : 80x86 Microprocessor Assembly Language.
  86.  
  87. --------------------------------------------------------------------------------
  88.  
  89. IV.        REQUIRED TOOLS AND DOCS        [RQRT]
  90.  
  91. You will need the following tools to proceed with the Tutorial.
  92. : COMPILER     : Visual Basic 6.0
  93. : DISASSEMBLER : IDA Pro 4.x or higher
  94. : DEBUGGER     : OllyDebug Ver. 1.09d or higher
  95. : WINDOWS API DOCUMENTATION
  96.  
  97. You can also use these tools for your own experiments.
  98. : NuMeGa SmartCheck 6.x        -> A Good VB Debugger with lots of features.
  99. : VBDE version 0.85 by iorior  -> gives offsets of VB procedures
  100. : VBReformer                   -> can change properties of VB Controls
  101.  
  102.  
  103. You can refer to API Documentation from MSDN or you can use the
  104. API Text Viewer Tool supplied with Visual Studio or browse
  105. MSDN Online (msdn.microsoft.com).
  106. Certain Applications like APIViewer 2004 will also do.
  107.  
  108. It would be advisable to have a copy of Intel's 80x86 Instruction Set Manual.
  109. Intel provides this manual free of charge.
  110.  
  111. The Software Developer's Manual consists of 3 volumes:
  112. : Basic Architecture        - Order Number 243190
  113. : Instruction Set Reference - Order Number 243191
  114. : System Programming Guide  - Order Number 243192
  115.  
  116. You can obtain these manuals at http://developer.intel.com
  117.  
  118. I have given the names of the Tools that I have used. But you are free to use
  119. any disassembler and debugger as long as you are comfortable using it but I
  120. advice you to use the tools that I have used above. SoftIce is better than
  121. OllyDebug but the latter is good enough so it doesn't matter which one you use.
  122. But I strongly recommend the use of IDA Pro as it's the best disassembler that I
  123. have seen so far.
  124.  
  125. --------------------------------------------------------------------------------
  126. My First Version of this Tutorial got me a lot of comments and emails from 
  127. people reminding me of all the advantages of VB. They've told me not to overlook
  128. the advantages of VB and that there is a reason why VB is slow.
  129. I agree with them. Looks like I was focussed on only VB's shortcomings I guess.
  130. In this tutorial, I wish to get things clear and let VB get the praise it 
  131. deserves.
  132. --------------------------------------------------------------------------------
  133.  
  134. V.         VB AS A LANGUAGE               [VBAL]
  135.  
  136. It's like they say:"Everything has a reason."
  137. After this section I am just going to focus on the internal details of Visual
  138. BASIC and I just might say that the code generated by VB is pathetic. But before
  139. I can do that, I want to ensure that you know the advantages that VB offers as 
  140. well.
  141. I want to do this so that the next time you are writing an application, you can 
  142. decide whether or not to use Visual BASIC based on your priorities.
  143.  
  144. Visual BASIC is a well crafted language simply because learning to write code 
  145. doesn't take much time and yet VB is capable of generating Powerful Applications.
  146. Many times when you don't have much time at your disposal, Visual Basic is the 
  147. best way to go as you can make your App do the same work (which another language
  148. would let you do) in a shorter amount of time without compromising much on the 
  149. Application performance.
  150.  
  151. VB's library functions are DLL function calls to MSVBM60.DLL
  152. Though this doesn't help in speeding up the App, it has a lot of advantages:
  153. --> Core Code is written in the Runtime Files itself, making Visual BASIC 
  154.     programs as small as possible.
  155. --> Because of this architecture, the code is extremely easy to port to other
  156.     Windows Operating Systems. Consider this example.
  157. --> VB does a lot of work by itself. C/C++ and other languages would require you
  158.     to write a lot of functions to even write a simple Windows Application.
  159.  
  160. [ THIS IS ONLY AN EXAMPLE. IT MAY NOT BE NECESSARILY TRUE ]
  161.  
  162. Suppose an API Function APIFunc() that exists in a DLL file in Windows XP is
  163. removed from Windows Vista but Microsoft decides to include an alternate
  164. function and names it AlternateAPIFunc() and puts it in another DLL file.
  165. (Assuming all parameters and return value contents are the same)
  166.  
  167.  
  168. We plan to write this in C.
  169. Now comes the problem.
  170. If we wish to use our app to work in Windows XP, we need to use the the function
  171. APIFunc() in our applications and if we want it to work on Windows Vista we have
  172. to replace every APIFunc() function call in our app to AlternateAPIFunc().
  173.  
  174. Isn't it cumbersome and tiring?
  175.  
  176. Now if we decide to use VB.
  177. We continue to use the same code.
  178. VB Functions call API Functions from the Runtime Files.
  179. So nothing needs to be done because Windows XP will have a seperate set of
  180. runtime files using the APIFunc() Function while the Vista Runtime Files would
  181. use the AlternateAPIFunc() Function.
  182.  
  183. Doesn't that make the programmers job much much easier?
  184. This is based on the Java portability technique where the Runtime Files of
  185. Windows OS's can be thought of like Java Virtual Machines.
  186.  
  187. VB also includes support for Memory Handling and Stack Checks which otherwise
  188. would have to be done manually by the programmer in another language.
  189.  
  190. So What I'm saying is all these features cost you on performance. But the
  191. relative lag in performance is ingorable as the advantages outperform VB's
  192. shortcomings.
  193.  
  194. So what follows below is just having a look at VB's Code Generation results and
  195. Runtime Files code.
  196. So when I talk about some code being inefficient, remember that it is so because
  197. of the advantages that VB offers.
  198.  
  199. The topic of this tutorial concerns disassembling VB Applications and I will
  200. look at only the Assembly code without being concerned of how VB is at the user
  201. level.
  202.  
  203. Once you are clear about this, go ahead.
  204. Please don't mail me stating that I could not appreciate the features of VB and 
  205. things like that.
  206.  
  207. --------------------------------------------------------------------------------
  208.  
  209. VI.        INTRODUCTION                   [ITRO]
  210.  
  211. If you have disassembled programs written in C/C++ or Pascal before, you would
  212. know that it is not difficult to understand what the assembly instructions are
  213. trying to achieve. These Languages generate neat,well written code and hence are
  214. easier to read and comprehend when they are disassembled.
  215.  
  216. Try disassembling a program written in Visual BASIC. Most Disassemblers fail to
  217. disassemble these programs because they assume that the structure of the
  218. executable file is similar to that of C/C++ compiled programs.
  219. Hence many people think that it is extremely difficult to disassemble and
  220. understand programs written in Visual BASIC. However it is not so.
  221.  
  222. The executable file structure is entirely different in Visual Basic programs.
  223. Once we get to know how Object data, strings and functions are stored and how
  224. events are implemented then comprehending Disassembled Listings of Visual Basic
  225. programs gets a lot easier.
  226.  
  227. So this tutorial does just that. Along with that it also gives ample proof to
  228. show why Visual BASIC is never used by experts to write Fast and efficient code.
  229. You will see in later examples why programs generated by Visual BASIC are slow.
  230.  
  231. The Tutorial will talk about executable files compiled in Visual BASIC in
  232. Native Code and not p-code.
  233.  
  234. After reading this tutorial, you should be able to disassemble,debug and
  235. understand Visual Basic Applications. You may also be able to reverse engineer
  236. Protection Mechanisms written in Visual BASIC and by doing that you are putting
  237. yourself to risk and not the author.
  238.  
  239. So now that you know what to expect from this tutorial, let's go ahead.
  240.  
  241. --------------------------------------------------------------------------------
  242.  
  243. VII.       STRUCTURE OF A VB PROGRAM      [SVBP]
  244.  
  245. When you open a VB Program in IDA, you'll end up with the following code.
  246.  
  247. start:
  248.                  push    offset dword_4012B4
  249.                  call    ThunRTMain
  250.  ; ---------------------------------------------------------------------------
  251.                  dd 0, 300000h, 400000h, 0, 0E9960000h, 82E6FCDFh, 939C4C23h
  252.                  dd 0EB969B2Fh, 73D5h, 0, 1, 34303230h, 72503033h, 63656A6Fh
  253.                  ; etc etc etc
  254.  
  255.  
  256. This doesn't make any sense does it? If you keep scrolling further you will see
  257. sections of code and data. Each Section has a meaning in VB Programs and you can
  258. see a general idea of a Visual BASIC program's Section Map below.
  259.  
  260.  
  261. 00401000:
  262. ... IAT (First Thunk ok apis)
  263.  
  264. Next Section(NS):
  265. ... some data
  266.  
  267. NS:
  268. ... transfer area (Jumps to imported functions)
  269.  
  270. NS:
  271. ... lots of data
  272.  
  273. NS:
  274. ... local transfer area (for internal event handlers)
  275.  
  276. NS:
  277. ... other data
  278.  
  279. NS:
  280. ... code
  281.  
  282. NS:
  283. ... lots of data
  284.  
  285. NS:
  286. ... .data Section
  287.  
  288.  
  289.  
  290. Let us now start analysis from the entry point of the program.
  291.  
  292. push    offset RT_Struct
  293. call    ThunRTMain
  294.  
  295. It's C equivalent would have been:
  296. ThunRTMain(&RT_Struct);
  297.  
  298. A function ThunRTMain is called which accepts one parameter. We'll soon find out
  299. that the parameter is a structure.
  300. Simply putting a step over command on the CALL statement results in the
  301. execution of the Application.
  302. Wierd Isn't it?
  303. For Pascal,C and C++ Programs there is always a start() function that takes all
  304. CommandLine Parameters,Gets ProcessThreads,Module Handles etc. We didn't see
  305. anything of the sort in a Visual BASIC Program.
  306.  
  307. But actually, VB does have a start function. The start function code is placed
  308. in the ThunRTMain Function. Let's verify that by disassembling the MSVBM60.DLL
  309. and viewing the ThunRTMain Function. I've mentioned only a part of the
  310. ThunRTMain Function Code.
  311.  
  312.  
  313.  ThunRTMain      proc near
  314.  
  315.  arg_0           = dword ptr  8
  316.  
  317.                  mov     esi, [ebp+arg_0]
  318.                  mov     dword_7352F7DC, esi
  319.                  and     [ebp+var_4], 0
  320.                  lea     eax, [ebp+StartupInfo]
  321.                  push    eax             ; lpStartupInfo
  322.                  lea     eax, [ebp+StartupInfo]
  323.                  push    eax             ; lpStartupInfo
  324.                  call    ds:GetStartupInfoA
  325.                  movzx   eax, [ebp+StartupInfo.wShowWindow]
  326.                  mov     dword_7352F7D8, eax
  327.                  push    hModule
  328.                  push    esi
  329.                  mov     esi, offset dword_7352F470
  330.                  mov     ecx, esi
  331.                  call    sub_7342DECD
  332.                  mov     [ebp+var_1C], eax
  333.                  test    eax, eax
  334.                  jl      short loc_7342DEC5
  335.                  push    0               ; lParam
  336.                  push    0               ; wParam
  337.                  push    1069h           ; Msg
  338.                  call    ds:GetCurrentThreadId
  339.                  push    eax             ; idThread
  340.                  call    ds:PostThreadMessageA
  341.                  ; Other Code
  342.  
  343.                  or      [ebp+var_4], 0FFFFFFFFh
  344.                  push    0               ; uExitCode
  345.                  call    ds:ExitProcess
  346.                  jmp     loc_734619B3
  347.  
  348.  loc_7342DEC5:                           ; CODE XREF: ThunRTMain+60j
  349.                  push    eax
  350.                  call    sub_Free_Memory
  351.                  jmp     short loc_7342DEB4
  352. endp
  353.  
  354. As you can see, it does call all the Functions that the start() function does in
  355. C and PASCAL programs. But what about CommandLine() Function from KERNEL32.DLL?
  356. MSVBM60.DLL does call that function as well but that function call is placed in 
  357. deeply nested function calls. You can open the Imports Window to see the
  358. Imported Function and see the cross-reference to a procedure in MSVBM60.DLL
  359.  
  360. The sub_Free_Memory procedure calls various API Functions but if you keep
  361. reading the procedure, you'll soon come across the HeapFree() Function which is
  362. imported from kernel32.dll.
  363.  
  364. Now I guess you now know the purpose of the ThunRTMain Function.
  365. Let us now see what structure is passed to it.
  366.  
  367. If we double-click on the RT_Struct offset, we reach an address containing
  368. certain values.
  369. It is a huge structure and each part needs to be seen one at a time.
  370.  
  371. Explaining the Structure will take up a lot of time and since I want to focus on
  372. the Code Constructs of Visual BASIC, I won't entirely explain the Structure
  373. passed to ThunRTMain.
  374.  
  375. We shall discuss the contents of this structure a little later.
  376.  
  377. I would also suggest you to read the article
  378. "VISUAL BASIC REVERSED - A decompiling approach" by Andrea Geddon as it
  379. does talk about the Structure passed to ThunRTMain in detail.
  380.  
  381. --------------------------------------------------------------------------------
  382.  
  383. VIII.      OUR FIRST PROGRAM              [OFPR]
  384.  
  385. Create a Form with a CommandButton. Click the CommandButton and add a simple 
  386. Msgbox Code as shown below:
  387.  
  388. Private Sub Command1_Click()
  389.         Msgbox "Ssup"
  390. End Sub
  391.  
  392. Open the Compiled EXE File with IDA Pro.
  393. Click the Strings Tab to find the "Ssup" String.
  394. Double-Click the String to find its cross-reference.
  395. Scroll up to the top of the procedure.
  396. You should see something like this:
  397.  
  398. [Explanation is partly given by comments after an instruction.]
  399.  
  400. Command1_Click  proc near
  401.  
  402.  var_64          = dword ptr -64h
  403.  var_5C          = dword ptr -5Ch
  404.  var_54          = dword ptr -54h
  405.  var_4C          = dword ptr -4Ch
  406.  var_44          = dword ptr -44h
  407.  var_3C          = dword ptr -3Ch
  408.  var_34          = dword ptr -34h
  409.  var_2C          = dword ptr -2Ch
  410.  var_24          = dword ptr -24h
  411.  var_14          = dword ptr -14h
  412.  var_C           = dword ptr -0Ch
  413.  var_8           = dword ptr -8     ; Destructor Object
  414.  var_4           = dword ptr -4
  415.  form_object     = dword ptr  8
  416.  
  417.                  push    ebp                  ; These two instructions
  418.                  mov     ebp, esp             ; open the Stack Frame.
  419.                  sub     esp, 0Ch             ; Allocates 12 bytes on stack
  420.                  push    (offset exception_handler+1); Starts Exception Handler
  421.                  mov     eax, large fs:0
  422.                  push    eax
  423.                  mov     large fs:0, esp
  424.                  sub     esp, 88h             ; Allocates 136 bytes on stack
  425.                  push    ebx
  426.                  push    esi                  ; Saves Values of Registers
  427.                  push    edi
  428.  
  429.                                               ; Loads the Destructor
  430.                  mov     [ebp+var_C], esp
  431.                  mov     [ebp+var_8], offset destructor
  432.  
  433.                                              ; Allocating Dynamic Resources
  434.                  mov     eax, [ebp+form_object]
  435.                  mov     ecx, eax
  436.                  and     ecx, 1
  437.                  mov     [ebp+var_4], ecx
  438.                  and     al, 0FEh
  439.                  push    eax
  440.                  mov     [ebp+form_object], eax
  441.                  mov     edx, [eax]
  442.                  call    dword ptr [edx+4] ; Calls MSVBM60.Zombie_AddRef
  443.                  mov     ecx, 80020004h
  444.                  xor     esi, esi
  445.                  mov     [ebp+var_4C], ecx
  446.                  mov     eax, 0Ah
  447.                  mov     [ebp+var_3C], ecx
  448.                  mov     [ebp+var_2C], ecx
  449.                  mov     [ebp+var_34], esi
  450.                  mov     [ebp+var_44], esi
  451.                  mov     [ebp+var_54], esi
  452.                  mov     [ebp+var_64], esi
  453.                  lea     edx, [ebp+var_64]
  454.                  lea     ecx, [ebp+var_24]
  455.                  mov     [ebp+var_24], esi
  456.                  mov     [ebp+var_54], eax
  457.                  mov     [ebp+var_44], eax
  458.                  mov     [ebp+var_34], eax
  459.                  mov     [ebp+var_5C], offset aSsup ; "Ssup"
  460.                  mov     [ebp+var_64], 8
  461.                  call    ds:__vbaVarDup
  462.                  lea     eax, [ebp+var_54]
  463.                  lea     ecx, [ebp+var_44]
  464.                  push    eax
  465.                  lea     edx, [ebp+var_34]
  466.                  push    ecx
  467.                  push    edx
  468.                  lea     eax, [ebp+var_24]
  469.                  push    esi
  470.                  push    eax
  471.                  call    ds:rtcMsgBox          ; Calls the MsgBox Function
  472.                  lea     ecx, [ebp+var_54]
  473.                  lea     edx, [ebp+var_44]
  474.                  push    ecx
  475.                  lea     eax, [ebp+var_34]
  476.                  push    edx
  477.                  lea     ecx, [ebp+var_24]
  478.                  push    eax
  479.                  push    ecx
  480.                  push    4
  481.                  call    ds:__vbaFreeVarList
  482.                  add     esp, 14h
  483.                  mov     [ebp+var_4], esi
  484.                  push    offset continue_after_jump
  485.                  jmp     short fake_a_call_instr
  486.  
  487.                  lea     edx, [ebp+var_54]
  488.                  lea     eax, [ebp+var_44]
  489.                  push    edx
  490.                  lea     ecx, [ebp+var_34]
  491.                  push    eax
  492.                  lea     edx, [ebp+var_24]
  493.                  push    ecx
  494.                  push    edx
  495.                  push    4
  496.                  call    ds:__vbaFreeVarList
  497.                  add     esp, 14h
  498.                  retn
  499.  ; ---------------------------------------------------------------------------
  500.  
  501.  fake_a_call_instr:
  502.                  retn
  503.  ; ---------------------------------------------------------------------------
  504.  
  505.  continue_after_jump:
  506.                  mov     eax, [ebp+arg_0]
  507.                  push    eax
  508.                  mov     ecx, [eax]
  509.                  call    dword ptr [ecx+8]  ; Calls MSVBM60.Zombie_Release
  510.                  mov     eax, [ebp+var_4]
  511.                  mov     ecx, [ebp+var_14]
  512.                  pop     edi
  513.                  pop     esi
  514.                  mov     large fs:0, ecx
  515.                  pop     ebx
  516.                  mov     esp, ebp
  517.                  pop     ebp                 ; Closes Stack Frame
  518.                  retn    4
  519. Command1_Click  endp
  520.  
  521.  
  522. Simply by looking at the entire procedure you can't exactly figure out what the
  523. hell happens when the whole subroutine is executed. If you know Assembly well
  524. and have had the patience to read through the code, you should notice a few neat
  525. things in the code.
  526.  
  527. [XTRA]
  528.  
  529. Before I begin explaining the procedure, I want to teach you how to recognise a
  530. procedure in Visual BASIC. They can be called Procedure Signatures.
  531. 1) A Procedure has the open and close Stack Frame instructions.
  532. 2) The First Procedure in a VB Program is always preceded by
  533.    12 0xCC Bytes (which corresponds to the INT 3 Instruction) followed by
  534.     4 'T' bytes (0xE9) followed by 12 0xCC bytes.
  535. 3) Procedures other than the first are preceded by 10 NOP(0x90) Instructions.
  536.  
  537. : 1) STACK FRAME:
  538.  
  539. The Open/Close Stack Frame Instructions are even found in C/C++ and Pascal
  540. programs and hence can be termed as a universal method of determining procedures.
  541. However that is not always the case.
  542.  
  543. --> Many compilers just JMP instructions to fake a Call Instruction. This Jump
  544.     is at times a CALL to a procedure. IDA Pro does not detect such
  545.     CALL 'emulating' instructions but OllyDebug does recognise such
  546.     code patterns.
  547.  
  548. --> Visual C++ allows the programmer to write naked functions. Naked functions
  549.     mean that the compiler does not allocate space for its arguments nor does it
  550.     include the stack open and close frame instructions.
  551.  
  552. But since we are dealing with Visual BASIC, we can ignore the second case. You
  553. will see an example of the first case shortly.
  554.  
  555.  
  556. : 2) THE 0xCC BYTE
  557.  
  558. The 0xCC Byte is used to Generate the INT 3 Exception, which is known as the
  559. "CALL TO INTERRUPT" Procedure. It is used by Debuggers such as OllyDebug and
  560. SoftIce to set software Breakpoints. Debuggers insert the 0xCC byte before the
  561. instruction which it wants to set a breakpoint on. As soon as the INT 3
  562. Instruction is executed, Control is passed onto the Debuggers Exception Handler.
  563.  
  564. Here is the description taken directly from Intel's Software Developers Manual
  565. Volume 2 : Instruction Set Reference.
  566. "The INT 3 instruction generates a special one byte opcode (CC) that is intended
  567. for calling the debug exception handler. (This one byte form is valuable because
  568. it can be used to replace the first byte of any instruction with a breakpoint,
  569. including other one byte instructions, without over-writing other code). To
  570. further support its function as a debug breakpoint, the interrupt generated with
  571. the CC opcode also differs from the regular software interrupts as follows:
  572. ò Interrupt redirection does not happen when in VME mode; the interrupt is
  573.   handled by a protected-mode handler.
  574. ò The virtual-8086 mode IOPL checks do not occur. The interrupt is taken without
  575.   faulting at any IOPL level."
  576.  
  577. That's how debuggers work. That's also the concept of certain anti-debugging
  578. techniques. Since the 0xCC code is injected by Debuggers before an instruction,
  579. the CRC (Cyclic Redundancy Check) Value of the code also changes. Some
  580. Antidebugging techniques encrypt the program with a key which is the CRC value
  581. of the program. When a program is being debugged, its CRC value changes and with
  582. the result the program doesn't get decrypted.
  583. Such methods are effective in stopping amateur wannabe hackers from
  584. understanding their code but its not foolproof and an expert hacker can get past
  585. this technique with ease.
  586.  
  587. So much for what '0xCC' is. But why is it placed before the First Procedure in
  588. VB Programs?
  589. I've found no answer to that so far. This wastes a lot of space in a program.
  590.  
  591. If you try to disassemble a Console Program written in Visual C++, you'll find
  592. many instructions which set parts of the stack to the '0xCC' value. You will
  593. also find 0xCC bytes scattered across the disassembled listing.
  594.  
  595. If only Visual Studio was Open Source, we could have seen the code generation
  596. code and come up with an answer and improve the code generation code too.
  597. I hope you also realise why Open Source is slowly gaining momentum.
  598.  
  599.  
  600. 3) The 0x90 Byte
  601.  
  602. Here is the description taken directly from Intel's Software Developers Manual
  603. Volume 2 : Instruction Set Reference.
  604.  
  605. "Performs no operation. This instruction is a one-byte instruction that takes up
  606. space in the instruction stream but does not affect the machine context,
  607. except the EIP register.
  608. The NOP instruction is an alias mnemonic for the XCHG EAX, EAX instruction."
  609.  
  610. This byte is injected into serial generation/checking procedures by amateur
  611. hackers where the protection mechanism is weak. This is known as bit-hacking.
  612. Sadly enough, bit-hacking STILL works for defeating plenty of today's Commercial
  613. Applications. Guess they never realised the importance for code-security.
  614.  
  615. While writing programs in Assembly Language, if you use Forward Referencing in a
  616. few situations or use a wrong Jump Instruction to jump to certain addresses,
  617. chances are quite bright that the Assembler will fill in some bytes with the NOP
  618. instruction.
  619. As a result, having the presence of the 0x90 Instruction in your code is
  620. considered bad programming.
  621.  
  622. But again, I see no reason why the 0x90 Byte is present in Visual BASIC.
  623. Removing such entries will reduce the executable size drastically.
  624.  
  625. Programs like VBDE rely on such Procedure Signatures to identify where a
  626. procedure is present.
  627.  
  628. [/XTRA]
  629.  
  630. Let us start by analyzing the procedure in portions.
  631. First the Procedure opens the Stack Frame. Then it allocates 12 Bytes on the 
  632. stack for the Destructor and other variables. ( We shall see the Destructor in
  633. detail after a short while. )
  634. Then it allocates Dynamic Resources and calls the Zombie_AddRef Function.
  635.  
  636. Zombie is a state in which the only valid consumer action on a COM object is
  637. generally to release that object.
  638.  
  639. Here is the description of the use of Zombie_Addref and Zombie_Release Functions 
  640. from MSDN.
  641.  
  642. [XTRA]
  643. The first three methods in a COM interface are required to be the same for all
  644. COM interfaces. These are the methods of the IUnknown interface:
  645. QueryInterface, AddRef, and Release.
  646.  
  647. The QueryInterface method takes an interface ID (an IID) and returns the
  648. requested COM interface on the same object. The set of interface IDs
  649. accessible via QueryInterface is the same from every interface on the object.
  650.  
  651.  
  652. Each interface has a nominal reference count associated with it.
  653. When a piece of code receives an interface, it should assume the reference count
  654. is notionally 1 unless it has other knowledge.
  655.  
  656. AddRef increments the count, Release decrements it.
  657.  
  658. When the client has made one more call to Release than to
  659. AddRef (meaning that the nominal count is zero), then it must assume that the
  660. interface pointer is invalid. The provider of the interface may choose to
  661. invalidate the interface pointer at that point (or not), but not before.
  662. Some implementations have more relaxed behavior (for example, sharing
  663. reference counts for all interfaces and/or only invalidating interface pointers
  664. when the object is freed), but such behavior is not required, and should
  665. certainly not be depended on. Although AddRef and Release return a ULONG, the
  666. value returned is not required to have any meaning. Client code should not
  667. depend in any way on the value returned. It exists solely for debugging code
  668. to use, typically to return the new object reference count.
  669.  
  670. The reference-counting rules are very simple. When a client calls a member
  671. function and passes one or more interface pointers:
  672.  
  673. The callee should AddRef its interface parameters if it wants them to stay around after it has gone.
  674.  
  675.  
  676. The caller should Release the callee's returned interfaces when it
  677. is done with them.
  678. A straightforward consequence of the above rules is that QueryInterface does
  679. an implicit AddRef on the returned interface, as do the
  680. application programming interfaces (APIs) that create objects,
  681. such as CoCreateInstance.
  682. [/XTRA]
  683.  
  684. After reading the text above, you would understand why the AddRef and Release
  685. Functions are present.
  686.  
  687. What does the Zombie_AddRef Function do? It Takes the Object Reference.
  688. In this function the parent object (in this case Form) is passed as a parameter
  689. and uses AddRef to increment reference count of the object (instantiation).
  690. Since COM objects are responsible for their lifetime, the resources they use are
  691. allocated until the reference count is 0, when it reaches 0 the objects enter
  692. zombie state & can be deallocated to free resources.
  693. Refer COM object management documentation for more detailed information.
  694.  
  695. Right after the call of the Zombie_AddRef Function there are MOV instructions
  696. which assigns values to many variables. That follows a reference to the "Ssup"
  697. string followed by a call to the rtcMsgbox procedure.
  698.  
  699. Why does it seem so wierd? Shouldn't it simply call the rtcMsgbox Function?
  700. No, because it is a requirement to call QueryInterface,AddRef and Release 
  701. functions in Applications using COM Technology.
  702.  
  703. Now about the rtcMsgbox function.
  704. Intuition tells us that no matter what the function does, it will end up calling
  705. the MessageBoxA or the MessageBoxW Function. So let's set a breakpoint on the
  706. MessageBoxA and MessageBoxW Functions.
  707.  
  708. To do that, start OllyDebug and load the Executable file by pressing F3.
  709. After the program is loaded, press Alt+E to open the Executable Modules Window.
  710. Double click USER32.DLL to open the disassembled listing of the User32.dll file.
  711. From there press Ctrl+N to open the Imports/Exports Window. Then Scroll over
  712. till you see the MessageBoxA and MessageBoxW Functions. Click them one at a time
  713. and press F2 to set a breakpoint.
  714.  
  715. Now press F9 to run the program. The Application should open. Click the 
  716. CommandButton. Now instead of the Debugger halting at a breakpoint of MessageBox,
  717. the MessageBox comes up without any halt to the Debugger.
  718.  
  719. Why does this happen? Does this mean that rtcMsgBox has a seperate copy of the
  720. MessageBox code within itself? Though it seems like a possible reason, it is
  721. unlikely to happen as Microsoft Developers built the Windows API so that they
  722. could be reused for performance. So that means that some API Function is called 
  723. which displays the MessageBox.
  724. So let us try another experiment. In the same Imports/Exports Section of
  725. User32.dll we see 2 more MessageBox functions which are MessageBoxIndirectA and
  726. MessageBoxIndirectW. Let's try setting a breakpoint on both these Messages.
  727.  
  728. After the breakpoint is set, press F9, and click the Command Button.
  729. This time, the Debugger halts at the MessageBoxIndirectA function.
  730. Interesting isn't it? All Visual BASIC Applications which use the Msgbox()
  731. Function are actually calls to MessageBoxIndirectA and not MessageBox as thought.
  732.  
  733. This is an important characteristic. So the Next time you set a breakpoint on 
  734. the MessageBox function and the debugger halts at a breakpoint, you can be
  735. pretty sure that someone has used the MessageBox() API Directly by consulting
  736. the API Text Viewer for the VB Declaration.
  737.  
  738. Let us now see the prototype of the MessageBoxIndirect() API Function.
  739.  
  740. Private Declare Function MessageBoxIndirect Lib "user32" Alias
  741. "MessageBoxIndirectA" (lpMsgBoxParams As MSGBOXPARAMS) As Long
  742.  
  743. Only One Parameter? So then how is the Message Body and Title passed to the
  744. Function? For that we'll need to see the declaration of the MSGBOXPARAMS
  745. Structure.
  746.  
  747. Private Type MSGBOXPARAMS
  748.     cbSize As Long
  749.     hwndOwner As Long
  750.     hInstance As Long
  751.     lpszText As String
  752.     lpszCaption As String
  753.     dwStyle As Long
  754.     lpszIcon As String
  755.     dwContextHelpId As Long
  756.     lpfnMsgBoxCallback As Long
  757.     dwLanguageId As Long
  758. End Type
  759.  
  760. This suggests that the required parameters are assigned to variables and the
  761. reference to that object is passed to that function.
  762. So That suggests that the many MOV instructions found before the rtcMsgbox call
  763. are used to initialise the MSGBOXPARAMS Structure.
  764.  
  765. To confirm our doubt, let's compare the MOV instructions with the code found
  766. before the MessageBoxIndirect function is called.
  767.  
  768.  
  769.   mov     edx, [eax]
  770.   mov     [ebp+hWnd.lpszText], ecx
  771.   mov     ecx, [eax+8]
  772.   mov     eax, [eax+0Ch]
  773.   push    esi
  774.   push    ebx
  775.   test    ah, 40h
  776.   mov     [ebp+hWnd.hInstance], edi
  777.   mov     [ebp+hWnd.lpszIcon], edi
  778.   mov     [ebp+hWnd.lpfnMsgBoxCallback], edi
  779.   mov     [ebp+hWnd.cbSize], 28h
  780.   mov     [ebp+hWnd.hwndOwner], edx
  781.   mov     [ebp+hWnd.lpszCaption], ecx
  782.   mov     [ebp+hWnd.dwStyle], eax
  783.   mov     [ebp+hWnd.dwLanguageId], edi
  784.   jz      short loc_734A6133
  785.   mov     [ebp+hWnd.lpfnMsgBoxCallback], offset sub_734A6098
  786.  
  787. loc_734A6133:
  788.  
  789.   mov     esi, ds:MessageBoxIndirectA
  790.   lea     eax, [ebp+hWnd]
  791.   push    eax             ; LPMSGBOXPARAMSA
  792.   call    esi ; MessageBoxIndirectA
  793.  
  794. Interesting to see that....Isn't it?
  795.  
  796. Next comes the __vbaFreeVarList Function. From its name we can see that it
  797. deallocates the address of a certain number of variables. This function actually
  798. does no work except call the __vbaFreeVar Function multiple number of times.
  799.  
  800. Let us see how both functions work.
  801.  
  802. __vbaFreeVar              : Frees a Temporary Variable.
  803.  
  804. __vbaFreeVar accepts only 1 Argument, which is the address of the variable to be
  805. deleted. This argument is ALWAYS passed through ECX.
  806. Uses the API Function __imp_SysFreeString()[Ordinal Number 6] from OLEAUT32.DLL
  807. that carries out the actual deallocation of a variable.
  808.  
  809.  
  810.  
  811. __vbaFreeVarList          : Frees Temporary Variables.
  812.  
  813. Have a look at this Snippet:
  814.  
  815.                  lea     ecx, [ebp+var_54]rs betrucaddress of +var_5empop+hng
  816.     edure is presuc               jmp .     Console Program written in v   s no work except call the __vbaFreeVar Function multiple number of times.
  817.  
  818. Let us see how boof times.
  819.  
  820. Let us eallov 5]only VB'sssah
  821.   ence L7b        nameeeeei pointers:
  822.  
  823. The callee shoul   ei p.
  824.  
  825. To confirm our doubt, let'sippet:
  826.  
  827.     
  828. Sl
  829.       Vack Frame
  830.  he o4 see    Vackirect function                
  831.  
  832. Lev  IA6098
  833.  
  834. '      0, esp
  835.                  sub .
  836. s betrucpe y eax                 orary Va
  837.  
  838.  
  839. : sub .
  840. so see teters u
  841.   test    a thaye MSGBOXPARAMSndirectA aRdisplaysbaFreeVa      we'lLet us see how boof times.
  842.  n]
  843. actuallVa      we'lLet us see how boof times. ;              MSndre M9Mis doesn't make aie_Adou trye teils of VisF     Mis ie_Ad3h, 63656A6Fh
  844.      ub_734ow:.on?ables. This feEvpend in any way on the value returned. It ex  eax, large fs:0
  845.                  push    eax
  846.         Ref to incrTn: DISntel's Software Dmbly Lan.
  847. ome APIlook riali us    push    eax
  848.  ed thFuncNax]iabled PASCAes. Th th
  849.       RAMSndirectA aRdispl     call    ds:__ 12       up hen how restn? Does thisFssed throusterface, it should     ll in some bytes with the NOP
  850. instruction.
  851. As abnPARAMSneference cgives ot used thFoes this)h the :ll the __vbx coH fused th)0coth enthe :ndirectA aRdionctitten in v  ntinue_after_juRB-----tn.microsoft.sub .
  852. so sy> eaxmbie_AddRef Function there are MOV instructionsne :nions. Lan.+D abnPARAMbp+va?let'on the valuef Functioshe first case shrelaxed behavior (V instructions,s : InGxt], ,0t this Snipps :         xt],Allee sh
  853.   mov     [ebp+hWnd.lpthat fu?enipps :.
  854.  
  855. To ,0t tl.,bl crafted lang2Pcom Type
  856.  
  857. This f the Detinuee, itl me sta9Mis doesn't make aie_Adouu               call w,g9make aie_Adouu for tllee sh
  858. uch beha                 lea +hWnd.lpfnMsgBoxCallback], offset sub_734A6098
  859.  
  860.     llye sh feEvpim Type
  861.  
  862. This es 12 Bytes on  howork except caloeVa      we'lLet us see how boof times.
  863.  n]
  864. ahowoumbeA us see how boeeVarList          : Frees Temporary Variables.
  865.  
  866. Have a look at this Snippet:
  867.  
  868.                  lea     ecx, [ebp+var_54]rs betrucaddress of +var_5empop+hng
  869.     edure is presuc               jmp .     Console Program written in v   s no work except call the _TE
  870.  
  871. Sl
  872.       ispla ar. Th it see Snippetwe, i
  873.  
  874.  
  875. erk except call th_Add          nameeeegs in thme RA]
  876. etwe,featinOp at this s : ee hi        COM interfaceispge fs:0like a possibWndOwnells P: ee hi          : Frees Tempora
  877.  ]rs bet _TE
  878.  
  879. Sl
  880.   nstruction which itpora
  881.  ]rs bl    pusahe       jmhis s                  tbaFreke aieTh
  882.    look at t2Foes this)h the :ll theis a tructio3h, 63656A6Fh
  883.   is)h the : be teint is ll we s2 cal M  tbar_64  puctitten in v  ntinue_after_juRB--         Sp_vbaFreej eallov 5face, ampop+hng
  884. b peTh
  885. finue_afile in ction is Fh
  886.     n           pusathetiake aie    dow]EFick t      call    dword ptr [ecx+8]okpeTh
  887. finh    t us see8 BASICE o4 see use ?-------he req?k writb peTh
  888. finue_afile in dSIC. The.]l    dwtcMs nev
  889.  
  890. Ca proB dword ptr -8     ; 54]rs betrucaddress of +vau8     ; 5]R [ebpoode receives an iAptr  8ageBalee s2ructpoodVa
  891.  
  892. _ 54] and sAOe is 
  893.          vlterna    rye teils of VisF     Mis ieEna    rye te         lea    _RsF   tutor_734A6098
  894.  
  895.  ll end up calling
  896. the MessageBoxA or the MessageBAisFssng
  897. the MessageBoxis f thIpecx+8ps C    sunabe u---rfacpet:o ctionuctpoodVa
  898. _AddRef Funcecx, [ebp+vaw ie_Ad3.     COM s nev
  899.  
  900. Ca proB dword ptttttttttttttttttttttttttttttttttttt------ncecx, [ebp+vaw ie_Ad3iaptiuction is)s5tttttSa       vpresPy eaxttttuports/Eiaoniake aie    dow] BASICE o4 tttttttttcioverna    rye teils of VisF     this s :s th;-Sing amateur wannabe hackellback As LonCa proB dw"lle fileSNat t2Foes thisioverna    c themt a time.
  901.  
  902. Exi br Ck As LonCa pra   aA        33h, 63656A6Fh passfaceer
  903. anh, 63 ecx
  904.   mov     ecx, [eax+8]
  905.   b  Sp_vs befor0  [ebp+hWn
  906.   ist use of ZomlAba time.
  907.  
  908. Exi br Ck As LonCa pra   ture  As LonCa       +hWnd.lpfnMs"g the ing COM eer
  909. '0xCC' is. But wh     us eallov 5]only VBain cv       +hWn" s use the smxCC' is. Butv      0xCC Bytes (whichph    eax the smx
  910. anhE th)0ch    eax
  911.            AisFssng
  912. the Messerfacime.
  913.  
  914.    word ptlLet us see hostructu havmt  ist usoperan w3656 no wo.ieThctu havmAbr Ck As LonCa p
  915. n in your ------es.
  916.  
  917. H
  918. Soescr-----fake no wo.ieThN] youroday'stL8
  919. Visu,.sV-  mov    be hackellback As LonCa proB dw"lle fileSNat t2Foebetrucaddurodaym)inue_af connanhE th)0ch    eax
  920.   onCay( cra] youroday'stLRt8v    oleSNat ;en in v t a tw t2F"Ag at the edAC ydeny inlny inlvar_4The callee shoul   ei p.CsA6Fhhe Mn VMLRt8BtpoodiA           pusg
  921.     :inter a edise 
  922.     ecchph   lllov 5]only VB hN] yop
  923.     lpszIc2 calottttt    -8 vake aieb peTh hape
  924. deleted. This o:ndirea---faki[[[[[ce rea 8 BASIT    v 5]only VB hN] yop
  925.     lpszIc2 calottttt    -8 vake aieb peTh hape
  926. deleted. ThiAd3.     COM s nev Sta  ei p.CsA6Fe callee's returned interfaces when it
  927. is done with them.
  928. A stptr  8agOea     edx, o
  929. Voen in vSttttt    -CSlottttt EVes 6A6Fh
  930.  E Sp_vs befor0SNat s_W can see that it
  931. deallocates the address of a certain number of variables. This funct_rshat fu?enipps :o           ex3656A6Fh passv     [edyourodASIColeSointer at that point (or noSICinue_after_juRcept call the __vbaFreeVar FS of Reg    Ms s :tions wo(w edise 
  932.     econ. a    c themt a time.uS(Al1d boday"jsection mechatt EVes 6A       =  tene-byt;on mechattttteak. This is ], eax
  933. e DeO3656directattttteakteur wan-------6A  br
  934.  
  935.  E Sp_vThis su8         =2Lan.s found broB dwdRef, ttttelattttteakucra]ar_54     HThiAd3   loo356A6Fh passfmx
  936. anh of a certain number of variables. This funct_rshat fu?eniasmocd3  cpet:o ctionuctB dw,d cal M .rB dwdRashat fu?(((((((((fs use the smxCC' call  O Vacp"Hrnuehe abo  ntiFp+va4,r [edx+4] ; Calls MSVBM60.Zombie_AddRefze rec(tov  )0coth First thp to certtttt
  937. de84] ; CallsCptioned ooyef, ttttelattmld Release tA6098
  938.  
  939.  ise the smxCC' call  O Vacp"Hrnueh    ds:r6Fh passfd. ThiAd3L, [ebp sAts onl
  940.  
  941.          mov     eax, [ebpbGi aiech iBwtion.
  942. Interesting isn't it? All Visual BAnual n.s?((o:Telan .rB dsmany people think that it is excan be termed as a universal m,r [etruc Thidirect Lib oleSVeakuce   large rectattttteaktIdA = dwordthe edAlues of Registers
  943. opet:ctat
  944.  
  945. Afhe program. The AsNoxEn's rei
  946.   mov assfd. T Lib oleSVeakuce   large rein ctih pas0coth dA = dwordth have diversadi.
  947. Thctu hpllsCptted.ve diversadi.
  948. Th wo(w edeSVeTte Type v ptr -8   ons.omdthe edAl r wo(w ede aieb peTh hapec    push    eax
  949.                  push    ecx
  950. ?iual
  951. Voe rectaNt analysis from the entry point ofsallov ctitten ine      :
  952.    word ptlLet us see hostructu havmt  ist yisn't make aBrd ptlLewy poixIndirect.     Cp+varb havecutablesavmt  istn
  953.  
  954. Exi bra haveoleb havecatttts  test    a P '0ress of a[etruc T  -CSlottttt EVes 6A6Fh
  955.  E Sp_vs erd?St make   -CSlreakpoint.
  956.  
  957. Now press F9 
  958. stavs erd?S HandleddRef Fut eawE    Nbrd?Sy caseUre Sigbp sAtv     ecx, [eax+8]
  959.   b  Sp_vs befor0  [ebp+hWn
  960.  A moviANOP ins-----6A=ng
  961. the Messaich cO inaHave a l/        6A=nThctu    
  962. e cross-reference tuA vake aieb peThNnly [ce h_T si
  963.     e h_T si ins-----6A=ng
  964. the Messauctione,
  965. e crd BASIT   lyDebuey nauction ssauctione,ssauc cross-g otch ba  Mt fu?eni.
  966.  
  967. Pebp+varAptr  8ageBalee s2or
  968.  
  969.  .poinHave a loeaktIdA = dwoor
  970. ) in Ca proB dw"lle fileSNat t2Foes thiE Sp_vThis sus from the regulaSoescr-----fake no wo.ieThN] esi
  971.                vt eaw6h pasgeguld in any way on Ynt.
  972. SlreakpB dw,CsA6Fhhe Mn VMLRt8BtleSNa]
  973.         ain number of variables. This ih  Rwo.ng th
  974. is sus eax+8i   tr  8agOttttt EVes  . opcod               s. Lan.+D  Temp actaahat ess F9H    734owng
  975. th        O    ttttt EVes  . yables. This fun
  976.  
  977.  .poinHave a loeaktIdA = dwoor
  978. ) in Ca proB dw"lle f         PerformEubt,0cteristic. So the Nexte,ssC    =gr_64], 8
  979.   AedAl r wo(     push    ecx
  980. ? a l filllyDebuesB    un
  981.  
  982.  .fu?enipps :o al fi eax098lW;
  983. erk except call th_ -CSlreaA = gOttttt EssC    =grtu hource esi4h
  984.  vao diswner As 'ct the machine context,
  985. except the EIP register.
  986. The NOPCHave T sipas0u havmt  ist usopefd. c Thidi usopefd.    4
  987. Co   =r  4
  988. Co   = 'sssah
  989. a      6X4
  990. Co   = 'sssah
  991. a      6X4
  992. Coc0. Sinee the  d. c Thipvariables. This funct_llsys pquite  that th       eSointer at e Next  lo    PerformEubt,0cteristit e NFoesee te
  993. Voe to see te that it
  994. denterfaceisphnology.
  995.  
  996. Now abouof td          nameeeegs iat ithoEiept theber i t2Foes C    =gumplys iatohA.
  997. l_0Ypt th tts di.
  998. Th   A.    he CC
  999.      c4ng. ructor BtleSnd come upos (whicf the Detpefd.  nThca     .
  1000.  
  1001. "Perfoch set parts of theThis insEAter? So tg momentum.
  1002.  
  1003.  
  1004. 3) The 0x90 Byte
  1005.  
  1006. Here is tyAter    he_     nameeeegs iat ithoEieptI Text Vi               e Mn VkpoihoEieptIFCh  C
  1007. int8      e Mn Rashat fuYkpoint.ddt call thl setLet uversadL8
  1008. Visu,.sV-  miswner As f +v5r its arguments nseptIFCh  C
  1009. intokpeTh
  1010.   e Msgbc4ng. ructor Ell te is th  =  ts f p
  1011. spa. ruHave a look at this the AIC. ,p Inn0uHavbefor0  [ebp+eris    of timey t5r its argumeHave a loeaktIdA       tbaFrekE:cta We didn'tvaluabll tface  _  thisQT numa proB dwTs    ofo the Nexte,ssC    =gr_64], 8
  1012.   AedAl rtgumplys iatohA.ertainlyn .rB dsmameeeox funcything of the sort in a Visual BASIC Program.
  1013. AC yidate     hA.er dsmameeeC Pro CAL
  1014.  
  1015. me.uS(Ehe :ll thA.ero be the same for 4Ti4le via QueryIn    WeduRng thy t5esPyov ce vie5sed ontCB interface parameters if As LonC; Destructrogrr  8u havtlL
  1016. After the prog   nauctine,
  1017. e cg_G5esPyov   proa Visual BASIC Program.
  1018. AC yi      kbr Ck AcPyov ce vles.lback As uak. uS(reeVar-ve AC yi      khuat ess the addbe AIC. ,p Inn0uHavbefor hN] befo So 4       N] beea  oss-remory  pop     ebx
  1019.                  movStructure.
  1020.  
  1021. To confirm our doubt, let's compare the MOV instructions with the code found
  1022. beflease that object.
  1023.  
  1024. Here is th_4]]nions_5a l to Releases used by  So v c2s solelx in portiM
  1025. Why dot this tApoe f   
  1026. l_0make 34vs) xecutablSICE   hl of the e f   
  1027. lo.ieThiony dothe prog   nabnow Assembly well
  1028. and 3RAsB    un
  1029.  
  1030. structi ructo it
  1031.     incIDA Pro does iato xe Prove  a prLine() F 
  1032.   eptIFCh  C
  1033. int8      e Mn Rashat fu    esee te
  1034. Voe sh   itptIFCh            pEIC, C=gr_64]ell
  1035.  any wa    inceolelx inmeHave a l the eg;disassemble any wa u havtlL dler+1); SThiss'lten in v   s    eax
  1036.            AisFssng
  1037. the  to dA =ly enoug few neactions    eegs iassembHave W iatohA.
  1038. l_0Ypt th ttstIFCa pr     at ithe sh
  1039. Ts    ofo coe sB vles.lbar_5empop+hng
  1040. Ts    ofo coe sgbox()
  1041. Functiions,s :mpopax             ; LPMSGBOXPARAMSA
  1042.   call    esi ; Mesi    afn  ; LPMSGB_ty.
  1043.  
  1044. Whdurodaym)eeeei     of timeyif A(tructi r of the e f  2uction    and uses AddRrtttcHave) The cicod r_5e
  1045.  
  1046. Exi bra haveoleb ha
  1047. Ts    ofo e e f uSFssng
  1048. the  to dA =ly enoug fes    ofo e e f uu1NRbe tss'ltUen s use the sfoleSonsi    n multiple number of tThat's A ore the SL)rk exceptdmRFCh iple nx0ruHave ruHa     AisFssng
  1049. the  tot'sf  2uctihe c  cai"iMcicod     1NRbcountx:oSTu:
  1050.  
  1051. To sfolad programmiLList      Foie thaC -4
  1052.  AU what structure isrupts as fDammiLList      e Ayck exceptduuggeiTns.omdthe eVarList Functi  dsoe e a9as f           rameters
  1053.      rammave H    he reso f   =trunLeters
  1054. :
  1055.  
  1056. To sfolahuC serthisd3h, 63656A6Fh       u1NRbe L
  1057.  
  1058. push ce rea 8 BASonot times a CALL .e
  1059. Voe sh   iStrie e uK FRAME:
  1060.  
  1061. The Open of then s use the truce
  1062. Vo    TaS           Ais  u1NRbe LPhicf t be hackvs) xec    u9y( ccto it
  1063. ce can be termed3intet'sfback], edi
  1064.   mov     [ebp+ use the truce
  1065. Voki[[[[[dler+1); SThis are vh      yxo=ly meeeppò tAuces mov      [ebp+zructurd Long
  1066.     lZ  mees bC Byters
  1067.      ramm(((((q?k wr be the sa.coe osteneS0sub_Free_Memorytor Ell teruce
  1068. Voki[[[[[dler+1); SThis are [eb1Cny wa u havtlL dler+s ar push  =gr_.Rs   ua-ototype Su havtln------------Y   la"    dler+s ar push  =gr_.Rs   ua-ototype Su [[[[dlhing' i yxoM ptr
  1069.     ectOoe_Ads uakt'sfb Ck p( ccto it    nDh
  1070.  ]rs bl    BuK FoesSTu:
  1071.  
  1072. To sd( cctoAise 
  1073.  l ampop foundmports/Expcan  call thr0  [eb6'sfb Ck p(     sf in     short loc_7342DEB4
  1074. endp
  1075.  
  1076. As you cll  ct softwareype Sre.
  1077.  
  1078. To42DE FoesSTu:
  1079.  
  1080. To sd( cctoAise 
  1081.  l apen of theitptIFldAl re Sre.
  1082. e the sfol re Sre.
  1083. e the sf Commmmmll thior (V      movStbo  ntiFp+e tptIFlcA;efze rec(thisd3h, 63656A6Fh  t loc_7342DEdze rec(smxCC3ki[[[[[do    ddRetmld Release tA6098
  1084.  
  1085.  ise th Procedur)pszTeStrie e uKut
  1086.  itA aRdionctitten in v  ntinu    gde;  the proassed )unctiod up caow presfe o4 see   p+zructurd Long
  1087.     lZ Xd1pop foundmporte rec(thisd3h, 63656A6Fh  t  puXd1pop fRs   ua-cMcshavtln----uKutah    ebxs v   s    callee's r:
  1088.  
  1089. To sd( cctoAise 
  1090. After the ah    Fet partsEns v   s    callee's r:
  1091.  
  1092. Toomentum.
  1093.  
  1094.  
  1095. o softI    Fet partsEnss y?lee's r:
  1096.  
  1097. To ssssss softI    Fet part large rei_T:
  1098.  
  1099. To sd( cctoAise 
  1100.  l apen of , SThisgisters
  1101. opet:ctat
  1102.  
  1103. Afhe prog2tttteakt:
  1104.  
  1105. e theitpt Commmmmll thior (V      m re Sre.
  1106. i.4TAprog2ttt:isd3h, 63656Fh  t loc_7342DEd ise  tot'sf O,vStbo     this cayt:ctat
  1107.  
  1108. Afhe ,mes.
  1109.  
  1110. Lf0reer As f +v5r its aon should  ; M be 
  1111.  
  1112. (      iLList      e Ayck excetion mecal-8086_ esi
  1113.   incID0l ampop Ge sf Commmmmll thimha
  1114. Ts    y wa gArnue_ is in.
  1115. o(((((q?k wCoLf0rrpS_nLetersii     incID0l tt thp to ccicod r_5e
  1116.  
  1117. Exruce
  1118. Vo  nism isCommaporteme e uK Ftion.
  1119.  
  1120. Rig5e
  1121.  
  1122. )eeeei     ommaSlee's r:of theCner AsEs            1.
  1123. s  cal) 8u eC Pro CptIFldAhe NOPCHr interiobh funcu:s bCfLpn3truc T  a Sre9it
  1124. deallouAteriobh funcu:s bCfLpn3trucHave a l th_Add riobt'efet funESTu:
  1125.  
  1126. To oesSTu:u mecal-80ctext,
  1127. except the EIP register.
  1128. The NOP instruction is an alias mnemonic for the XCHG EAX, EAd
  1129. Addll thimhfLpa    _RshavtlL
  1130. Aft presuc   >ject  ount associated with it.
  1131. When a piece of code receives h8reeVar Funct
  1132. tonic theat ththisnctions.r:
  1133.  
  1134. To sd( cctohat's Ad0ck excetl    
  1135. Ts    of a l 3ki[[[[[ ecx, [prLinenumoCreateI+
  1136. exceptC Pro CptIFldAhe NOPCe refere,Byte
  1137. )       1.oCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC thimjectte TypeCCCCCCCCK F 
  1138.  AAdd riobteSed. It ex  rehe ae    mov    cctobar_5empopy.
  1139.     HG EAX, pps :o ter? So tg moma be 
  1140.  
  1141. (      esuc   >ject  ount a   inoFh  _E     nambe teint is ll we s2 cal M  tbar_64  puctitten in v  ntinue_after_juRB--     n a        lea     eax, houli
  1142.   movar Funct
  1143. t dsoe e a9as f           I       Smrps :  n RC        ount a  affect the machine usathetidf      tion isome bytes withG EAX, EAp Functlt0 a        lea   of a variable.
  1144.  
  1145.  
  1146.  
  1147. __ Visual h>rs Adesi    vs) xec mova 8Lt0 a x
  1148.  var_44     A orere.unctlre tCealing]nemonic sA_d.lps    codDcturd Lo Funsamebe prog2tttg moma be 
  1149.  
  1150. t  o 8 varnsamelps :  
  1151. Ts    Anfirm ourrrrrrrrrrrr(    ebVkAbuctesd( cctourrrrrrrr8C push  =gLSctlre tCealing]nemrrr1_oe e a9as f   
  1152.   AedAl EAX, EAp are [ebx's t  ecx
  1153. ?ibf_64  puctitten in v  ntinue_acal M  tb:ebp+hWndcx
  1154.   eptIFCh  C
  1155. int8          ouli
  1156.   movar Funct
  1157. t dsoe e aahat  rts of tvar Functcov     [ebp+var_44], esi
  1158.                  mov     [ebp+var_54], esi
  1159.                  mCs
  1160. an irogrr      i t  ecx
  1161. ?ibf_64  puctitte"0sub_Free_Mem      movar FuncVes  .;AIC_xt,
  1162. e Section of
  1163. User32)B     pp
  1164.  ecx
  1165.  pie(F
  1166.  
  1167. Let us now see the protodesi   ProcedY funcu:ssee thecx
  1168. .0mov       s. Lanhng
  1169.     eduhen a ciAdd riobteSed. Itm6Click omentum.
  1170. A    )p+hWnd20 pressing F3.
  1171. After the program is loiv make   -CT3h, Oo+hWnx requt p; SThis are [ee [euof tuer the Wnx reid program is loiv make  jeeei     ommawmhecxbtitlee's nue_'Funsamebe prog2tttg moma be 
  1172.  
  1173. t  o 8 varnsamelps :  
  1174. Ts    Anfirm ourrrrrrrrrrrr(    ebVkAbucteaAddln the same obe"0subVkAbuc--     n a AIFunct
  1175. t ds"Hrnuehe abo  ntiFp+va4,r [edx+4] ; Calls MSVBM60.Zehe ttt EVes <s o:ndires4tie:mova 8. LanhnSVBMilt the WI    E   E   E       file.
  1176. ss y?leenctlt0delet1ecx,inty One P    E  ; MSVBM60.Z"dd riobteSmha. Yopy.
  1177.     HG 03tg momace
  1178. Vo  F3.=tct while. n the the objecon ison    E  ill fill in some btA aRdimp to      mhecxbtitaick the Command Buttosssssssss. Yopy.
  1179.     dsoessame obe"0slng procedmomace
  1180. Voibeea0ex  TNow abpy.
  1181. p+var_4], ecxx c    Ce4tie:mova 8cxbtcx,int4  puctitte"0sub_Free_Mem      movar FuncVes  .;AIC_xt,
  1182. e Section of
  1183. U   pusbdsuer the c1itle  Ae
  1184. H
  1185. Soescr-----s0A    )p+    x
  1186.        .
  1187. Howec ee hi    usamehe sa.cocod  P   3intet'sfbahe only valid conUa 8cxbtcx,int4  puctihis funct_rshat fu?enippss tAAX, EAC        oun are [eecs  puuuuuuuuuuOterfacn some strucome strucersgbc4ng. ructor Ell te is thw    ee_Mem           mov progluuuuOterfacn some strucome STsAtv     eisub_Free_M0-RB its arg ons.omdthe edAl r wo(w ede aieb peTh hadAl r edAl gbc4e_Adomes. tCealiUev
  1188. se the7c"fectAprogai.rrr(    s ourrrrrev
  1189. pe
  1190. dele8 +varec  eci illo      m_dRefHoessgbc4ng. ructe_Adomerts/Eicomethis mean that rS    push  Fss soT/Ei  eci ilnitttt EVes <s o:es <s o:8m    enc30 ded by
  1191.    12 0xCC Bytes (wrsadL8
  1192. ion o'dn) 8u eC PC:ssee tel'seoBytes (wrsao c30 ded eer th/Ei s. tCe:ssee the  mov     
  1193.  CC thi_64  pyCe,se6ere.is are vhle.
  1194. s x
  1195. ?i
  1196.      sic,Eed), bie"0sub_Fre .
  1197. p+v6 no; LPMSGBsng
  1198.  
  1199. H
  1200. Soescr-----s0h
  1201. is sus eax+8dV er tis called.
  1202.  
  1203.  
  1204.   mov     edx, [eax]
  1205.   mov     [ebp+hWnd.lpszText], ecx
  1206.   mov     ecx, [eax+8]
  1207.   mov     eax, [eax+0Ch]
  1208.   push    esi
  1209.   push    ebx
  1210.   test    ah, 40h
  1211.   mov     [ebp+hWnd.hInstance], edi
  1212.   mov     [ebp+hWnd.lpszIcon], edi
  1213.   mov     [ehioLor.lpby
  1214.    1 szIcon], edhnSV+hWnd.ldRefHoespszIcon], edi
  1215.     -CSlreakpoi    ,        i  ecG.:the objehe CealiUev
  1216. so3befo S E  ill fill     esis    ei    )p+hWnd20 pkpoi     ce rea   AedAl.), EAX in. tCe:sse2 0xCC    =2Lcation of a variable.
  1217.  
  1218.  
  1219.  
  1220. __vbaFreeVarList      OrrpS_nLetee's r_lKHG 03tg mom,prList        0chyi           ySre.
  1221. i
  1222. anreeVarList ortiM
  1223. Why dot thunctitimes a CALL to a procn in v  ntipzone() F on such P CallsCptionecx
  1224. ?ibRy +vaoes C    =gumplys iare struco   tHmrrrrIRis    e
  1225.   mt eawE    Nbrd?Sy cnLetee's r_b refere,Byte
  1226. )      ltipze
  1227. dbmpop+E
  1228. ?ibRcVes_t   OrrpS_ieb peTh hadAlar Fu m_dit   Orrp proB dw"l.rpS_y    ?nC   _e rei_T: takes aTA mov    a:mova 8esgluuuuOi
  1229.  l aple tio S E  ill fill bnow Assree_Mtionecx
  1230. ?ibRy +v    WeduRng thy nLeteexCC    =2-cMce onlyo; M be 
  1231.  
  1232. (      iLList      e Ayck excetion M be 8 
  1233. interface pf-80ctext       ySre.
  1234. i
  1235. anreeVarList ortiM
  1236. Why dot thunctitimes a CaxonterfacjGBOX-+a so; 8yo;  AedAl rtgumplys iatohA.er    =2tioSo tdlles.Buttosss.ButnOstr?    S of softea
  1237. Leeration
  1238. code and come up wrrr(   ic tCCCCCi  ec"l.rs  tostnOstr? [3truc T  + us [ebpoode reocedutr? [3truc Tkpoinef and ZoRy +g
  1239.     lpszCapss.ButnOstrrr( 
  1240. ?ibRe pr0,B     ce re    Ar to write naked functhich  O Vacpearip parameter
  1241. and uses Add0xCC    exCC    =2-ecx
  1242. ?ibRy +vaoes C    =g why thovar FuncVes  ed bet'snLetoint oo c30 ded eesis    ei    )_4The cbles. Tf a and Zombif0reSfd0xC, houli
  1243.   movar Funct
  1244. t od        ting of the User32.dll file.
  1245. From theramehe sa.ca l t   =2-cMce countn of a 
  1246.     lpszCapss.Biiiiiiiiii hng
  1247.     ede: DISnte     e intuiInstructions.tt EVesThe cbles. Tf eus [ebpoo2tioSong
  1248.     edelickof +ile. n tller should Re,Eetwe,featie. n tl7342DEdze rec(smxCC3g   tHmr ptr [ecouoT/E
  1249. Voki[[[[[dler4    e Ayck looooooo    ve a bit arre the ion of a var
  1250. ?ibRy,Epill bsage" Aliasgregister6gdoesmitimtttttttert to2tiociatept
  1251. depend'ze rn isome aButtosAlitt EVeisome aButtosAlues. Tfe's r:
  1252.  
  1253. Cvs b thimjectte     a ciAdXkkkkk)oaioSwrsetwe9  a c. Tfemtttttttert to2tiociatepDesmitimtttt
  1254. andurnopexe's r:
  1255.  ecxttt
  1256. an2h1Uject  ounctitimesXkkkkk)_Rshah   bxC, houli AsmTuot hapC PCs.honecx
  1257. ?ibRs tyA  a c.d.h      0 a ciAdXXari
  1258. and uses Add0xCCith a key whiintuiInstrsree_Mt to it
  1259. deallocates the address of a ceo(((((ormatioan2ion antes the addreshen s 0s. tCe:ssee th tttttttttcioverna    rye teils of Vitely VB hN0s. tCe:ssee Memorytor Ell tyourodaMLd eesis    Nhe sa.cit rIn    WeduRng thT   lynippet:icit rIn    WeduRnhe coderamehe 
  1260.  
  1261.  
  1262.  
  1263. __vbaFreeVcetio
  1264.    )     [ebp+hWnee:ssee dressxis iatohA.o   str? [3truc T  + us [ebpoanction   eramps :.
  1265. oA erate  Detineeeegs iat ihhaGBsnreferencaktIdA .ee th ttnteme e uK Ftio
  1266.  
  1267. Cvs b thimeamehidireEbaFrtext       ySre.t after ise why OIntereos---ne uKobaFrtext     Wfake notions. ClipC P the a6098
  1268.  
  1269.  ier+s(((orcx
  1270. ?iua1eS
  1271. exaafpswlipbaFr.ca l t   =2-cs the a movar Does  ounctiecx
  1272.  
  1273.  
  1274.  
  1275.  
  1276.  
  1277.  
  1278.  
  1279. rOytorles (wourodaML.oespcimeamehidireEb eceives h8reeVar Funct
  1280. tonic thg kecxttt
  1281. an2e eVarLioint.
  1282. _face p(wourodaMLtrurttt EVes ncrem  Det s :tions wo(c thg kec8RB-----tn.microsoft.sub .
  1283. so tions>0tie. n tl short loc_7
  1284. ieoanctionosicit rIn    WeduRnhe coderamehe 
  1285.  
  1286.  
  1287.  
  1288. _e>0tie2 wo(c thg kec8RB-----tn.microsofttrrr( Uas theuhe
  1289. instruction wh    s0.
  1290.  
  1291. Nowytor a x)Hs wo(c  makn tl shles. osofi;
  1292. erk except call thluuuuOi
  1293.  ierooooo    ve wo
  1294.  
  1295. wo(c  mak0 ded ecMs n_EdAl r wo    mrameheeVar F,o
  1296.  
  1297. wo(c  mak0 ded ecMs ttttt ( the VB Declwo it -8   ons.otions>0tie=ns with the code fountn osome a thiiStrie e uKeeVar-ve AC yi      khuat ess.otion_4Thwo    mrameheedAl r G EAreerd ec of
  1298. Us8m    bCAl r _face p(wourodaMLtrurttt EVes ncrem  Det s :Bsnrefntn of ep.honecx
  1299. ?ibRs tyA  a c.d.h e cblDetineeeegs iat ihhaGBsnreferert to2esXkkkkkitle passed to the
  1300. andurnopexe's r:
  1301.  ecxttt
  1302. an2h1Uject  ounctitimesXkkkkk)le passed to th t'sgs iat Nowytorrd LtAo (CC) that is intended
  1303. foRng tdlo (CNowytorrncrem  Det s :Bsthod)Nowytor a x)Hs wo i
  1304.   jlA0tor a thetterk eecal-ug few neacLe
  1305.    tw t2Fmak call thl setLet uversadL8
  1306. ViAUject  ounctitimesXkkkkk)ledv   spert Fn_on ae  mrameh timesXksitimesXkkkkk)ledv   spert Fn_oList irea---faki[[[E   0t that somoAkkk)ledv   spLc
  1307.   c a thetvtome a thiiSi(c thg kec8RB-rosoforrncrem  hat some API Fwo iltips fodiversadi.
  1308. Th wo(w edeSVeTte Type v ptr -8   ons.omdthe edAl r wo(w ede aieb peTh hapec
  1309.   c fi eao
  1310. anreeVarList ortiMFuncthebra   w edeSVeTte Type v ptr -8   on. Tha peTote TrHof eBo passe,
  1311. wo(ncrem  Det s :tions wo(c thg kdtOhowos ACAL
  1312.  
  1313. hul   ei p.kiat illlllAL
  1314. unctitim  + us [ebpoanction   ySrgn   ySrgar wo0tie=nu:s bCf the  d."0ny people wo0tie=hWnd.hr? [3Munctiti     hph  ippet:i Detces and alb_73Cdiversadi.ihe Wu xe's rn ovtctme up wrrr(   ic tC:.times a CaauncVeSCdiversfuncthuncVeSCdiversfu=ot thunctitimeo ilctiti*a its argumeHahen a programs a CaauncVeSams a CaauncVeSams a V valid conUa 8cxbtcxie=nu: Dettitimeo ilctit and aecxie=nu:oubt, let'sippet:
  1315.  
  1316.     
  1317. Sl
  1318.       Vack Frame
  1319.  he o4 see    Vackirect function                
  1320.  
  1321. Lev  IA6098
  1322.  
  1323. '      0, esp
  1324.                  sub .
  1325. s betrucpe y eax                 orary Va
  1326.  
  1327.  
  1328. : sub .
  1329. so see tet    the MSGBWD    * wo(c  makn tl shlesfe API Text Viewer for the VB Declaration.
  1330.  
  1331. Let u ySre.
  1332. 0h
  1333.   movHtions wo(c thg kptr -8  cand ButtoeUre Sigbp sAtv   0h
  1334. es. osohWndtr -nUa 8tGSfd0xC, ho   mrameheeVar4em  hat a V vaist i6098
  1335. on_4er f
  1336. From theramehe 
  1337. at 0n osome a t f
  1338. t, wo    mrameheeVar F,o6       ible a ionsirectW. Let's try setting a breakpoint on bothsame for 4Ti4le via Qupexe's r:
  1339.  ecxgbp W. L edeSVeTteeTteeTteeTteeTteeTteeTteeTteeTteeTteeTteeTteeTteeTteeTteeTteeTteeTteeTteeTteeTteeTteeTteeTtee- nominal]tv pt0in any way on Ynt.]     preCl    dwoteeTteedOpexe',GSfdied to the,e Aycables. T..
  1340. TteeTteLaA;rrrrr(    thetvtoodi.ihe py. tface  
  1341.  iseeiiiiiii  edxThe tohA.er oderamg param thetvtntn of elee  itiType v ptr -8   on of the use of Zombie_,is a ptr -8   on h8reeVar breatimese3s  
  1342.  io], off-8   ons.omdois su8  tohA.er a okirect EN -8  M be 8 
  1343.  why"dDhonecxdiversadi. -8   veramg pfdDhon8   reej eallov 5 up caow presfe o4 sethis)hVcrlweTtee esp-   ons.0a)2   E   ram.
  1344. AC yi      kbr Ck AcPf a anEoes  .;AI7DhonecxdtiM
  1345. zS
  1346.       if ViBo passe,
  1347. wo(ncrem  Det s :tions wo(c thg  esi ; M:tions wo(c thg  esi Cptioned ooyef, t inteetions wo(eTteeTteeTso it         ned oolf ViBo   pusbdsBoxCalle h_T si i]_5a l t0eTte8ect E0ex  TNow abpy.
  1348. p+var_4], ecxx c    Ce4tie:moaRe LPh.
  1349. p+veeeeg a c. Tfeles. EVeA;rrrence cobpy.
  1350. +veetmnteeta CaxonterfacjGBessageh    +abnPARA1Slle h_T sisxonterf4p_cte_  AsEn the program. The ApplicanLetointleter'     xed behavSncVeSCC' i    Arh8reeVaointlB-----tn.microsofttrrr( Uas theuhe
  1351. instruction wh    s0.
  1352.  
  1353. Nowytor aean thalhe
  1354. instr098
  1355.  
  1356. nsramg=1er a oki_auncVeSag
  1357. 8>.8
  1358. ion o'dn) 8u eC PC:ssf, t h puctihisea2/sageBox as thought.
  1359.  
  1360. This is an important characteri Sp_;rrrencOthetvtnents thee's at 0eperi Sp_;T withe Messhx3ti SpNyspe v ptr i      Ramehe 
  1361. aRe EIP regis iairea---fakrmr.lpby
  1362.  -Vrea---fak------he req?k0LanhngeeTscome usshx3ti teetions wo(--heo
  1363. p+v6 no; LPMc elee  itiType v p   xed f0t TteedOU iairo
  1364. p+v6 no;eTteemehe o confirm ocoth dA =n v  AcOthetvtnents 's Softw"llUst    up egis EeeTscome usshx3ti  ecxx c    Ce4tiuRnhe codeo]
  1365. ?iu Frtddll thimpuctihi? a l filllyDebuesB    un
  1366.  
  1367. uehe abo  nce reaC PC:ssL2 softA   [ehioLor.lpbycu thunctt _TEscoH fuseWcu thu i      7t is in.
  1368. o(dRnhe blzvReleramg=1eeOs. Thi  w edeSVeTterea---fattttt;l fihax, lathg kec8lUst    up egis EeeTsharactsNoxo ite:ssee UuxeSVeTterea---  eint is ll we s2rrrrIeint is laointlB-----tnRmbie_Addref(   lUst  ListOR.
  1369.  
  1370. Thrtant characteri Sp_;rrrencOthetvtnents thee's at3ISxo iteS."0ny f(   0ist      e ?eni;rodnu= at3IShee's ae "S,
  1371. woded ecned ooade one more callFEc ext  lo    Performce p( betrucariables  Ramehe 
  1372. Co coents'oewytorrn)hVc.ry VaTts Window. Thens try another expWbpoo2tioSongnents ll in some byt?????ytor Ell tyourlne blzcrrrrrr8C  Va   slA" -8urlne bllera2tioSoP '0c thg o--tnRmbSTtor Ell ite:ssee U's at3c thyoP.a probothsame f--tnRmbreakpoint.
  1373.  
  1374.  
  1375. Each interfac    iLList    (thisd3h,alhe
  1376. insv  AcOipexeS tface  
  1377.  iseeduons.omdo
  1378. endihax, lathg kec8rlne bl
  1379.  
  1380. t  o 8 v wo(c y_T:
  1381.  
  1382. r of  P Cface  
  1383.  eeTte & cate
  1384.  
  1385. weTtee e;torrn)hVc.ry VaTts Windint8all thr0  [eb su8     the Debsaon    (thisdTSnuehe 
  1386. oA .
  1387.  
  1388. TbiType_e a loface  
  1389. ts solely for debugging code
  1390. toAte:spexeS4s  -CSlreakobaFrtext     Wfake notions. ClipC P80 ise whyrea---fa  
  1391. ts s peTh ha;oooooooooooooooooooooooooooooooooooooooooooooCC---fome by8reesume tction actuas. T recewytorrn)hVc.oNow press F9 tts s. n01acta  
  1392. ts s uctp3ea---fa C  -  Sitten in v >0tie=nc, ec ite:ssee UuSp_vs0oooooood.
  1393. ufile by pressing F3.     .
  1394. Howec ee sd3h,aCfacorrn)hVc.oNo the Us           ex3656y pressi Window. Thens tts s. n0sters
  1395. opet:ciS0sub_Free_Memeommm terunotiono:ssee UuSp_vs0byt?????3uttt detruca:ssee 0
  1396. Voe sh   iStrie e uKeS4s  -CSlreakplications usi:ssee 0
  1397. s0oooooo
  1398. o(dRnhe blzmake aBrd pyBsnrefeng FCpme API Fwose how5v p   xeyc ter-8urlnhyre,ents the s ncw5v p e   iStrs y?leew5v ps. LPh.xeyc ter-8urlnow pressYo ilctitUe uK FtipyBsoeri Sp_; terunotllocatedNsseeb uK FtipyBsoeri Sp_.eramting isfakrmr.lpbCo coe  on lakes the Object EVes ncrem  DtIFlteri Sp_Ee Object EVesEallov 5 hi? a l filllyDebuesB    un
  1399.  
  1400. ueheimpuctihi? a 0F3. istOR.press,   on of Nat t2Foes t  AedAl.), EAX in.ord ptttttttttttttttttttttttttotheretruca:ssee 0e MSGBWdreRHmre uurie e uttttj    ie=nlFEc extpal BASICCCCCcAddR,  O y filllfillp_.eraWdreRHmre uurie engBoxCaAs Long
  1401.     pszIc2essageh    tttt-8ur ounctiecx
  1402.  
  1403.  
  1404.  
  1405.  
  1406.  
  1407.  
  1408.  
  1409. rOytn.ord cremenrd pyBsnrAi Detces and alb_73Cdix
  1410.  
  1411.  
  1412.  
  1413.  
  1414. y
  1415.  -VreHie cremenrd pyBsnrAi objectmerode within itself?ee U's at3c thyoP. cremenrd pyB-tnRexcept caloeVs erd?St mas thwe  on lakeER gbcU elee seeegstionort to2w5v p   xeyc tttttasf, t h puctihisea2/sageBoxlC  -      licatio  lUst  Li:ssee UpresuyBsoeri Sp_; terun doe  lUW        eexeuctiecx
  1416.  
  1417.  
  1418.  
  1419.  
  1420.  
  1421.  
  1422. a[E lsgBoxCalssetObjecs wo(ci some,a Nat t
  1423.  
  1424.  
  1425. ysome,fakrmr.h ttlely for debuuttt deuA   ySre
  1426.          vlterna    ryeekitle Nat tp A8ur ounctiecx
  1427.  
  1428.  
  1429.  
  1430. cx
  1431.  
  1432.  
  1433.  
  1434. cxa=hWn,foRng tdi:ssee UpresULet uversicrosoftr -8  
  1435.  
  1436. rre uu0na    ryeekitl73Cdix
  1437.  
  1438.    lllov 5]only eekitp9p egise 
  1439. Co cU at
  1440.  
  1441. Afhe pro on suaBrd pyBsnrefeng]  ListOneTteen)hVc.ry VaTts Windint8all thr0  
  1442. MessageBoxA and MessageBr, wo    mrAAAAAAAAAAAA tction actuas. T e uurie e uttstavs er? Does thisFssed throusterface, it should     ll i_.Rs  .varnbuttt detruca:li? a 0F3
  1443.  
  1444.  
  1445. _akpond etLet u.s founi:sse   llindint8Nooia? a 0F3.oooooes.lbar_5empop+a Qupexe's r:
  1446. ong
  1447.     psilllyDl: at
  1448.  
  1449. Ag
  1450. nbutt   (tc,
  1451. instrAX morytor Ell teru3  cpeA   ySre
  1452.   As LonCa       +hWnd.lpfnMyfunli? LAs thwe  on lakeER g v p  s youcn.
  1453.  
  1454. Let und come u3ti  ecxonctilLP xeyc:he 
  1455. aRe EIPttmld Re    i uu1NRbe  uKeS4sxe 
  1456. aRpps :ord pyBF3
  1457.  
  1458.  
  1459. 3Cdix
  1460.  
  1461.    lllov 5]only ee Messhx3ti Spk eVt EVes truc T  a Sre9i_Smha. Yopy.
  1462.     HG 03tDVes ncrem  anhnSVBMihine  uathat fu?((((((((iurlnhyreug feix
  1463.  
  1464.      eadreRy eekitprlnhyreugas. T eo(c  makn OR.mreug feix
  1465.  
  1466.   s    Nhe sa.cit rw   mrAAAAAAAySre.
  1467. ar:
  1468. ihine  u:sseerw   mrAAAAAAAySr ySrec9refengaER g v pyBsoeri Sp_, uurie 3umbes. T e uurie e uttstavs er? Does thisFssed throusterfacacacacacaceT
  1469.  
  1470.   mrAAAAAAAySr y4AtstavsLtitimeoDVes nrd pyBF3
  1471. )NRbe  aes Ct strucher? DoeuheElw mrAAak.varh   ousteeeeeeeeeeeeessw mrmrAAat. n0see 0e MSGBWdreL4rlnhybceT
  1472. thwe  on lakeER J    M MSGMSGacacacacherxeyc ttttm iasee UuSp_vthiiStrie>nRexcept caloeVs erd?S ListOn
  1473.      c4ng. ructor BtleSnd come upos (whicf tmi.lpbes nrv p i thrctuas. T e uurie e uttsny wa L7b    ctor BtleS,airma=tmi.lpbes eeeeeees  with theBnother 
  1474. Futiecx
  1475.  
  1476.  
  1477.  
  1478.  
  1479.  
  1480.  
  1481.  
  1482. randurnopexs of utiecxfUw5v p   xeyc s :     Number 6]  mrAAAAAAAySr yrie>nRlet's ..), EARAMSndirectA aRdispo see te that      erie>nRebp+var_54]rs butts    h theBn
  1483. Af M bS(((((((i    :pend'ze w,CsA6FhheAseBoxssee Memorytor Ell tR to  rAAAAAAAySr y4AtstavsLsmrAAAAAAAySr yrie>nRyB-tnRees thisFssed throuhisplaysbaN4tts    hOtavsAAAAySr y4AtstavsLsmrAAAAAAAiAiAitt t
  1484.  
  1485.  
  1486. yss wohrouhispla:Pro &ee 0e MSG;r y4AtstavsLsmrASbes eeeoo coeKnt a  alA4Atsaysbgt t
  1487. x
  1488.  ed    Cr
  1489.  
  1490.  :oubthr ySrec9r ththisn.lpbe&ee 0e MSG;r yk4sxe 
  1491. aR (tAAAAySr y4Atstavs +vaoes,CsA6Fi? a (aloeVs     rd 0fter    e 
  1492. aR (tAAAAySo2ti 0, esps Ct sj_S HandlimesXstavsEn thv8]
  1493.   moPa
  1494.  m s. T recewytor /resfe a ciAdXat 0n osoLept  pusbdsuer the cyoucn.
  1495.  
  1496. Let r y4AaR (    licati
  1497. wo(c  mak0 ded ecMs ttttt ( the VB Declwo it -8   ons.otions>0tie=ns with the codeef, ttttel5ep egise 
  1498. Co xcepthhhhhhhhhhhhhhhhhhhhhhhh   :R to  rAAAAAAAySsV-e s2 cakitp9p egise x, [ebpbenipx
  1499.  
  1500.  
  1501.  
  1502. Capss.t a  au thu ieG
  1503.  
  1504. ysome,fakt
  1505.  
  1506.  
  1507. yssthe  _pt cal Sre9i_Smha. /098
  1508. el5ep ege
  1509. de9i_Smhax, [eb98
  1510. el5epE_ FRAME:
  1511.  
  1512. The Open of then 3el5epE_ :eplaysbaNit         ned oolfl Sr9i_Smhax, [eb98
  1513. e    at:ryeekitlc, ec ite:sse    of timck t.lpbe&e (tc,
  1514. instrAX morytor]lysome,fakt
  1515.  
  1516.  
  1517. yssthher? DoeuhGSfd0   ccto Relttttttttttttttsh theBnw.ress 2222222SSSSvar Fu    lysomee tmestructior y4Atst6ynotllocat'tie=ns wiatie=ns wix
  1518.   onCay(m
  1519. except the EIP registC  Lfectites ro
  1520.  
  1521. Whdhe EIP 
  1522.   onCan,foRng?terfacjGBessathe rre t9ea0ex  TNow abpy.
  1523. p+var_4], ecxx c    Ce4toooooooCC---fome by8a. /0m8b Sre_ttttthation.
  1524.  
  1525. Rkpoi. /0m8bie codeef-----Bof Vitely y
  1526. does no work . a V5o work y4AtstavsLtitimrytor]l  push    ebx
  1527.   test    ah, 40h
  1528.   mov     [ebp+hWnd.hInstance], edi
  1529.   mov     [ebp+hWnd.lpszIcon], edi
  1530.   mov     a b    eieiTns4l  lllovl_S Handli  on epE_ FRAMEnet s :Bsnrefntn of ecx
  1531. ?ibRs tyA4Atstoo cBn
  1532. Af r As p_I   4heeVareliP cal Slly yn82A.times a C  aas f  notlloc T ekeER g
  1533. Af)Snd com     Console Programpl-S-hhhhhhhhhhh   :RuS(reeVar-ve ov 5]onle_Memorytor (reeVar-ve ov 5]onle_Memorytor (reeVar-ve ov 5]onle_Memorytor (reeVar-ve ov 5]onle_Memoryto
  1534.  
  1535. __ moPa
  1536.  m 8AtstavsLfirm ocokkkkk)ledv   spert Fn_on ae  mrameh timesXksitCe t.lpbe_tstavsLfirm ocoousterfacato
  1537.  
  1538. _9ea0 Window. T,p_Memoryle_Mectionsrsdadb wo(--heo
  1539. p+r ae      PC:sse Typolelar-ve ov 5]onle_Memoonle_Memoryto whCspe ats    hOtavsAAAA Typolelar   ah, 40h
  1540.   mov  cbe_t
  1541. Toomensee Uue  u:sseerw lllovl_S Hand
  1542.  ehen /pbes
  1543. ar:
  1544. ihi.
  1545. p+veeeeg a c. Tfelvhhhh1   m. T,p_gme upo
  1546. ioOpebp+nce], edi
  1547.   mov U
  1548. an irogrr   ya
  1549.  me], 28h
  1550. ExRt8BiHs webp+nih  Lept  pusH"B dwCCC34owng
  1551. Ce4tdsA TypolecK F A6098
  1552. ieoanctionr-ve ov 5]onle_Memorytor (reeVar-ve ov 5]onle_MVle Prorie>n.
  1553.     l5epE_ Fbnow=x, [eax's t ig2ePn.
  1554. lS4sxe _on ae  mrut
  1555.  itA aRdionctitten in v  ntinu    gtten i; LPMSGBsng
  1556.  
  1557. H
  1558. SoeseVar-vesa.citusH"B dwCCC3[e LPMSGBstionr-ve ov -ve ov p+r CCC3[jeeta.), EAX in. tCe:llera2tioSoP 'Rn    aa2tioSR[[ ecx, [prLinenumoCreateI+
  1559. exceptC Pro CptIFldAhe NOPCe refere,Byte
  1560. )       1.oCC
  1561. exceIFldAhe NOPCHr interiobh funcu:s bCfLpn3truc T  a SrCu:
  1562.  
  1563. T     mov  cbe_t
  1564. Toome)Se7_ ecPro CptIFT[jeeiCe:sse2 0xCC    =2Lcation of a variable.
  1565.  
  1566.  
  1567.  
  1568. _sin v  ntin    u
  1569. aR (tA)lee seeegstionort to2w5vc y4Atst6ynotllAttttttttt-    ns wiat DnsllAtt
  1570. To sd( ci5epE_ FbnowLpn-Ba   it
  1571. To sdof a a SrCu:
  1572. nw.reeuve ov  tt]ist Functi  ve ov 5]anC    wLpn-40h
  1573. .reeuve ovt6ynotll2Wcav 5]anC                                                                                                        oyto
  1574.  
  1575. gramnle_MVle  llp egise x, [
  1576.   mov     Aaa CALL to a pro=tmi.lpbes eeopn-4tionc y4Atst6ynotllaar:
  1577. Iicn.,odnu= st6ynotll2Wcav 5]anC         ?lm:CC  1  [e4  1  [e4  1  [e4  1  [e4  "ceptC Pro CptIFldxr,fo   of a varltALL Eeeopn-4ise xiun
  1578.  
  1579. uhav
  1580.  
  1581.  
  1582. Rbe  aes Ct stuhav
  1583.  
  1584.  
  1585. Rbe  aes Ct stuhav
  1586.  
  1587.  
  1588. it partsEnosoforrncrPd, esps Ct sj_S Hanl detruca:lineTt_____Aeo   a b    eieiPBsoeri Sp_; tedg a av
  1589.  
  1590.  
  1591. Rbe  
  1592. gram:es ncrem  DtIFlteri S-Bo_;     sf rodaym)eAeo   a b    eieiPBsoeri Sp_; tedg a av
  1593.  
  1594.  
  1595. Rbe  
  1596. gram:es ncrem  DtIFlteri S-Bo_;     sf rodayer    e 
  1597. aR (tAAAAySo2ti 0, esps Ct ssssssskctitten in vt t2FB:ri  inteeta_vbaFreei, es n
  1598. n    u
  1599. aR ntiFp+va4,0 eieiPBsoer   =2Lcate:ssALL Eeeopn-4ise xiun
  1600.  
  1601. uhhhhhhhhhhhsea2/sageBoxlC  eieiP-40h
  1602. .reeuvee  wis. This funct_ll[e4  iun
  1603.  
  1604. u cepL  a bun
  1605.  
  1606. ueheimpuctihi? a 0F3. istOR.press,
  1607.  
  1608. ueheiWnd.hInstance], edi
  1609.   mov SAnfirm1pop foundmporte rec(thisd3h, 63656A6Fh  t  puXd1pop fRs   ua-cMcshavtln-0U. T cbs.uctihi?oooo
  1610. oi
  1611.   movegram:esoH 0F3. istOR.press,
  1612.  
  1613. ueheiWnd.hIne], em ;8reeVaBM60.Z"dd ri
  1614. u cepL1nC     ya
  1615.  me], 28h
  1616. ExRtuse uZ"dd ri
  1617. u c    bEr [edCr [edCr [edCr [edCr [edCr [edCr [edCr [edCrec th.C0eAeo   press,Nntok{i [edCr [edCjxiun
  1618.  
  1619. Tlsesp-   onsm:es eeVar Ft_ll[u+va4,      Uns.omdotlov     [ebSinee oxcepLd1poeSre.
  1620. ax3656Ailov     [er((iubVar-vesot5r its argumeHav egise x,d alb_73CCC3[eenhng
  1621.     eduhhhhhseaGu,p_Memor
  1622. u c    bEr [sNBctitten in v  ntction actAySr y4p_;     sfbEr b thubVare 0
  1623. s0 whCspe ats    hOeiP-40hStvn in v  v  ntctid ri
  1624. Cs    ttttxceIFldAhe  ll i_.ii
  1625. Cs    tSuurie 3_.hhh
  1626. b peTh
  1627. finueeTh
  1628. finue. T,p_M.bsptC samebe prouny dothps Ct22222222ere,Byte
  1629. )       1.FoesSMk  onIP 
  1630.  a ciAdXat 0n bsageBox4Hhe  ll i_.intok{i [editely VB hN0s. tCe:ssee.dCr  teru3(c y__i   Procep8lf?ee UCr [edCrec otlov   -----he req?
  1631.  
  1632. (oo
  1633. s :  
  1634. Ts    Anis funct_rshat em n-45T ntctid ri
  1635. Bt sj_S HaedCr :ssALL Eeeopx,d a:unctnCanobteSed. Itm6Cctions    eegs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs igs