home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Iczelion / w32_00.txt < prev    next >
Text File  |  2000-05-25  |  5KB  |  176 lines

  1.                            -          
  2.               -----=========-----
  3.       -------==========================================----------
  4. --------=====_masta_'s Tutorial on Win95 ASM Coding Part 0=====---------
  5.       -------==========================================----------
  6.  
  7.                  --==INTRO==--
  8.  
  9.  
  10. Hi, after unsuccessfully searching the for an assembly tutorial on
  11. Win95 I decided to contribute a little one of my own and I hope this
  12. is just one of many to come.
  13.  
  14.  
  15.                 --==WHAT IS NEEDED?==--
  16.  
  17.  
  18.     1. Brain ;)
  19.     2. A(n Intel compatible) Computer with Win95
  20.     3. TASM 5.0 (with Tlink, libfiles, etc ...)
  21.     4. An API-Reference (Win32.HLP)
  22.  
  23.         ---> most of it can be found on 
  24.          l⌡RD ╟┼L∩G°'$ fΓ╤t├$t∩⌐ w°RL╨ °F óRAcK∩±G 
  25.          [>Cracking.home.ml.org<]
  26.  
  27.  
  28.  
  29.                     --==PRE-KNOWLEDGE==--
  30.     
  31.  
  32. I assume that you posses at least basic knowledge of Assembly 
  33. language, which every Cracker, Coder (Speedfreak!) should have.
  34.  
  35.  
  36.  
  37. -==WHAT IS SPECIAL ABOUT ASSEMBLY LANGUAGE AND WIN95?==--
  38.  
  39.  
  40. The main different is the use of API-functions as well as you 
  41. aren't able to use interrupts. The API-parameter are PUSHed
  42. into the stack before the function is called. It runs similar
  43. to C (The last parameter first, then the second-last ...) ...
  44. aditionally upper- and lowercase characters MUST be used in
  45. a certain way:
  46.  
  47. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  48. Always: "MessageBoxA" <-------------> NEVER!!!: "messageboxa"
  49. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  50.  
  51.  
  52.  
  53.      --==WHAT WILL WE LEARN IN THIS TUT?==--
  54.  
  55.  
  56. Simple!: The popular "Hello World" - Demo :-).
  57.  
  58.  
  59.  
  60.         --==HELLO WORLD !!==--
  61.  
  62.  
  63. These are two words, that every coder has already seen ...
  64.  
  65. So first we should think about, how we want to show it on the 
  66. screen. So what I do, is just use a MessageBox and since we
  67. work in Win95 and we want to use FULL 32bit Power, the command
  68. will be "MessageBoxA".
  69. So we switch over to our Api-Reference (Win32.hlp) and search
  70. for "MessageBoxA". This is what we should find:
  71.  
  72. ---------------------------------------------------------------------
  73.    int MessageBox(
  74.  
  75.        HWND  hWnd,       // handle of owner window
  76.        LPCTSTR  lpText,       // address of text in message box
  77.        LPCTSTR  lpCaption, // address of title of message box  
  78.        UINT  uType        // style of message box
  79.       );
  80. ---------------------------------------------------------------------
  81.  
  82. -  Since we don't ahve a window, that calles our MessageBox we set
  83.    "hWnd" to zero.
  84.  
  85. -  "lpText" will be the offset of our text (where it is stored)
  86.  
  87. -  "lpCaption" ---> offset of the Caption
  88.  
  89. -  "uType" we set to "0" also, which corresponds to a "normal" 
  90.    MessageBox with a nice OK-button (Type mb_ok)
  91.  
  92.  
  93. So now let's get started and see the source in ASM ...
  94.  
  95. ;-------------------------------START--------------------------tut.asm
  96.  
  97.                   ; set some options for the assembler
  98. .386P            
  99. Locals
  100. jumps        
  101.  
  102. .Model Flat ,StdCall
  103. mb_ok     equ 0               ;mb_ok gets the value "0"
  104. hWnd      equ 0   
  105. lpText    equ offset text     ;set a pointer to the text
  106. lpCaption equ offset caption  ;set a pointer to the caption
  107.  
  108.  
  109. ; declaration of all used API-functions
  110.  
  111. extrn     ExitProcess     : PROC     ;procedure to shut down a process
  112. extrn     MessageBoxA     : PROC     ;procedure to show a MessageBox
  113.  
  114. ; here begins our Data
  115.  
  116. .Data                                        
  117. text     db "Hello World",13,10 ; first row of the text(with word-wrap)
  118.          db "_masta_ greets everybody who reads this tut",0
  119.                                 ; second row, terminated with "0"
  120.  
  121. caption  db "Hello",0 ;Captionstring, 0-terminated
  122.  
  123.  
  124. ; and here we start with our code
  125.  
  126. .Code                                  
  127. Main:
  128.                 ; lets greet the world   :))
  129.  
  130.         push mb_ok              ;PUSH value for uType
  131.         push lpCaption          ;PUSH Pointer to Caption
  132.         push lpText             ;PUSH Pointer to Text
  133.         push hWnd               ;PUSH Masterhandle
  134.         call MessageBoxA        ;CALL MessageBoxA
  135.         CALL    ExitProcess     ;End (exit) program
  136.  
  137. End Main                        ;End of code, Main is the entrypoint
  138.  
  139. ;-----------------------------------END------------------------tut.asm
  140.  
  141. ;----------------------------------START-----------------------make.bat
  142.  
  143. tasm32 /mx /m3 /z /q tut
  144. tlink32 -x /Tpe /aa /c tut,tut,, import32.lib
  145.  
  146. ;-----------------------------------END------------------------make.bat
  147.  
  148.  
  149. Well as you see, it is not much, but I hope it it can be a good start to
  150. Windows-coding in ASM for you.
  151.  
  152.  
  153.                --==FINAL WORDS==--
  154.  
  155.  
  156. This is my first, but surely not my last Tutorial on Assembly-coding for
  157. windows ...
  158.  
  159. Ok, hope to CyA all at the next one ....
  160.  
  161.  
  162.                 --==GREETINX==--
  163.  
  164.  
  165. VucoeT (Translator [ :) ]), |Caligo| (kewl Page), fravia (best on the web),
  166. stone (for the inspiration), not4you, fungus, |Quest|, 
  167. Silvio (where are you ?), Vantmas and every Cracker on this planet ...
  168.  
  169.  
  170.   -------=====================================================--------
  171. ------======everybody was a lamer, before they become ELITE======-------
  172.   -------=====================================================--------
  173.                           -----=========-----
  174.                    -
  175.  
  176.