Site hosted by Build your free website today!

Miscellaneous Info.

Nasm compilation in VC++:

Compiled nasm 0.98.39 in MS VC++ successfully.(on jul 19 ,2005)
Had to add the lines
#define snprintf _snprintf
#define vsnprintf _vsnprintf

In order to get it compiled.

Nasm Syntax highlighting in Textpad 4.4.1

-Download the nasm syntax definition file(zipped) -

- copy the file (nasm.syn) to samples directory in the textpad installation folder.
  Say "C:\Program Files\TextPad 4\Samples"

- Restart Textpad

- In the menu goto Configure->New Document class

- Enter 'nasm' (without single quotes)as the document class name

- Enter '*.asm,*.inc' (without single quotes) as the class members

- Check the "Enable syntax highlighting" checkbox and select nasm.syn from the
  Dropdown box.

- Click Finish

Restart Textpad and open an asm source file to see the syntax
highlighting for nasm.

You can also edit the nasm.syn file to highlight "nagoa" macros.(i have already
added the most common macros.)

Ollydbg 1.10 warning for programs written using nasm.

|Entry Point Alert                                                                         X |
|   .                                                                                        |
|  / \     Module  has entry point outside the code(as specified in the PE header).          |
| /_!_\    Maybe this file is self-extracting or self-modifying.                             |
|          Please keep it in mind when setting breakpoints!                                  |
|                                _____________                                               |
|                               |     OK      |                                              |
|                               ~~~~~~~~~~~~~~~                                              |

Add "class=code" to the segment declaration.

segment .code USE32 class=code

This way Olly will find the correct entry point.

Switch off monitor:

call GetDesktopWindow

GCD Macro for nasm.

From Paul Hsieh's page.
Result will be in eax.
%macro GCD 2
	push edx
	mov eax,%1
	mov edx,%2

	neg     eax
	je      %%gcdloop3
	neg     eax
	xchg    eax,edx
	sub     eax,edx
	jg      %%gcdloop2
	jne     %%gcdloop1
	add     eax,edx
	jne     %%gcdloop4
	inc     eax
	pop edx

Count the number of 1's in the binary representation of an Integer

popcount1 will return 10 for an input of 1023 (1023 = 1111111111 in base 2)
Result will be in eax.
%macro popcount1 1
	push esi
	mov esi,%1
	mov eax,esi
	shr eax,1
	and eax,055555555h	; (n >> 1) & 0x55555555
	sub esi,eax		; n - ((n >> 1) & 0x55555555)
	mov eax,esi
	shr eax,2		; n >> 2
	and esi,033333333h	; n & 0x33333333
	and eax,033333333h	; (n >> 2)  & 0x33333333
	add esi,eax		; n = (n & 0x33333333) + ((n >> 2) & 0x33333333)
	mov eax,esi
	shr eax,4		; n >> 4
	add eax,esi		; n + (n >> 4)
	and eax,00F0F0F0Fh	; n = (n + (n >> 4) & 0x0F0F0F0F)

	imul eax,001010101h	; add by multiplying with a "magic number"
	shr eax,24		; shift result into place
	pop esi

Bitmap background for a Window

(Didnt test this.)
IDB_BITMAP           equ 2000       ; Our BITMAP as in .RC file
segment .data USE32
     hBitmap              dd  0          ; handle for bitmap
     hBrush               dd  0          ; handle for brush

segment .code USE32

; Load the bitmap from the Resource file (.RC)
         push       IDB_BITMAP       ; Our BMP file
         push       [hInst]          ; hInstance  (from GetModuleHandleA(0); )
         call       LoadBitmapA      ; load the bitmap
         mov        [hBitmap], eax   ; save handle
         push       [hBitmap]
         call       CreatePatternBrush  ; create our PatternBrush
         mov        [hBrush], eax       ; save handle

; Now when you initialize your window class, (before you register it)
         mov eax,[hBrush]
         mov        [wc+WNDCLASSEX.clsHrBackground], eax ; here we use it.
         call       RegisterClass, wc
; And when you finish your program, before you call ExitProcess,
; you have to destroy the objects.
         call       DeleteObject, [hBrush]
         call       DeleteObject, [hBitmap]	

Transparent windows. (win2k and winxp)

%define WS_EX_LAYERED	0x080000        ;not defined in
segment .data USE32
opacity dd 200  ; opacity can range from 0 to 255
segment .code USE32

;Create a window with WS_EX_LAYERED in Extended window style in the CreateWindowExA function (very important)

;When handling WM_CREATE message code the following.

call SetLayeredWindowAttributes,[@hwnd],0,[opacity],LWA_ALPHA

Softpedia Review

Got FileSplitter 1.05 reviewed by Softpedia.(Nice score).
Click here to read the review.