processi

processi
Adesso cerco di fare qualche variazione...

Cerco di trovare i punti dove posso variare i valori per studiare cosa causano le variazioni.

.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include	\masm32\include\user32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
WinMain	PROTO :HINSTANCE,:LPSTR,:DWORD

.DATA
ClassName BYTE "Nome della Classe",0
AppName	BYTE "Nome della Finestra",0

.DATA?
hInstance HINSTANCE ?
CommandLine LPSTR ?

.CODE
Start:
	invoke	GetModuleHandle,NULL
	mov	hInstance,eax
	invoke	GetCommandLine
	mov	CommandLine,eax
	
	invoke	WinMain,hInstance,CommandLine,SW_SHOWDEFAULT
	invoke	ExitProcess,eax
	
WinMain	proc hInst:HINSTANCE,cmdLine:LPSTR,cmdShow:DWORD

	LOCAL	wc:WNDCLASSEX
	LOCAL	msg:MSG
	LOCAL	hWnd:HWND
	
	mov	wc.cbSize,SIZEOF WNDCLASSEX
	mov	wc.style,CS_HREDRAW or CS_VREDRAW
	mov	wc.lpfnWndProc,OFFSET WndProc
	mov	wc.cbClsExtra,NULL
	mov	wc.cbWndExtra,NULL
	push	hInst
	pop	wc.hInstance
	invoke	LoadIcon,NULL,IDI_APPLICATION
	mov	wc.hIcon,eax
	mov	wc.hIconSm,eax
	invoke	LoadCursor,NULL,IDC_ARROW
	mov	wc.hCursor,eax
	mov	wc.hbrBackground,COLOR_WINDOW+1
	mov	wc.lpszMenuName,NULL
	mov	wc.lpszClassName,OFFSET ClassName
	
	invoke	RegisterClassEx,ADDR wc
	
	invoke	CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,WS_OVERLAPPEDWINDOW,\
				CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,\
				NULL,NULL,hInst,NULL
				
	mov	hWnd,eax
	invoke	ShowWindow,hWnd,cmdShow
	
	invoke	UpdateWindow,hWnd
	
	.WHILE TRUE
	invoke GetMessage,ADDR msg,hWnd,0,0
	.BREAK .IF !eax
	invoke TranslateMessage,ADDR msg
	invoke DispatchMessage,ADDR msg
	.ENDW
	ret
WinMain	endp
	


WndProc proc hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
	.IF uMsg == WM_DESTROY
		invoke	PostQuitMessage,NULL
	.ELSE
		invoke	DefWindowProc,hWnd,uMsg,wParam,lParam
		ret
	.ENDIF
		
	xor	eax,eax
	ret
WndProc	endp

End Start	
Bene: cominciamo con queste... poi vedremo di sfottere i vari "NULL" eccetera...

Il mio sorgente si chiama finestra.asm.
Al prompt del DOS, dapprima io scrivo CX finestra (per assemblare e linkare con un file batch che mi sono creato io, che si chiama CX.BAT);
Quindi scrivo:finestra e appare magicamente la finestra!
C:\masm32>cx finestra
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

 Assembling: finestra.asm
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.


C:\masm32>finestra
Eccola: finestra

ACH!!! PRIMO ERRORE ISTRUTTIVO!!!

Nel tentare di apportare modifiche alla costante SW_SHOWDEFAULT, quarto parametro della procedura WinMain, ho ridigitato il CX finestra per ricompilare il programma, ma ottenevo un errore del linker che non mi permetteva di aprire finestra.exe.
Questo genere di errore si verifica, secondo la mia esperienza, quando il programma è ancora aperto, come ad esempio, quando sto usando OllyDbg con il programma aperto sul debugger.

Quindi, sono andato su Gestione Attività con Ctrl, Alt e Canc e nella scheda Processi ho trovato ancora aperto finestra.exe.
Caricato il 11/14/2009 - 05:47 in Album predefinito

Commenti (0)