[ ]   [ ]   [ ]   [ ]



: 0
25-02-12 07:01


igor64
: 0
16-01-12 20:13


Lil`Ga.k.a43
: 1
09-01-12 11:23



   Web -
PHP


ASP






XML



CSS

SSI





   











   Web -








   









   










/ Assembler /

COM

www.wasm.ru

, COM- , . , COM , , . , , .

COM

COM.

COM- . , . COM , - .

COM, - "", , , - . , , , , . - . - , , .

- ( , , ). , , .

COM-

COM- , ( vtable ). . , .

C++, :

interface IInterface
{
HRESULT QueryInterface( REFIID iid, void ** ppvObject );
ULONG AddRef();
ULONG Release();
Function1( INT param1, INT param2);
Function2( INT param1 );
}

// Function1
pObject->Function1( 0, 0);

:

;
; - vtable
QueryInterface equ 0h
AddRef equ 4h
Release equ 8h
Function1 equ 0Ch
Function2 equ 10h

; Function1
; , ,
; ,
;
push param2
push param1
mov eax, pObject
push eax
mov eax, [eax]
call [eax + Function1]

, . pObject . Function1 (0Ch) , .

HRESULT

OLE API HRESULT. -, 32- . HRESULT .

HRESULT - 32- .

3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+-+-+-+-+-+---------------------+-------------------------------+
|S|R|C|N|r| Facility | Code |
+-+-+-+-+-+---------------------+-------------------------------+

S - Severity Bit
, ,
.

0 -
1 -

32- ,
, ,
:

call ComFunction ;
test eax,eax ;
js error ; ,
; ( )
; ,

R - facility.

C - facility.

N - facility.

r - facility

Facility - facility

FACILITY_WINDOWS = 8
FACILITY_STORAGE = 3
FACILITY_RPC = 1
FACILITY_WIN32 = 7
FACILITY_CONTROL = 10
FACILITY_NULL = 0
FACILITY_ITF = 4
FACILITY_DISPATCH = 2

:

call ComFunction ;
shr eax, 16 ; HRESULT 16
and eax, 1FFFh ; ,
; facility
; eax HRESULT' facility

Code - facility

facility
call ComFunction ;
and eax, 0000FFFFh ; 16
; eax the HRESULT' facility

COM MASM

MASM , , COM- . invoke, COM- , .

:

IInterface_Function1Proto typedef proto :DWORD
IInterface_Function2Proto typedef proto :DWORD, :DWORD

IInterface_Function1 typedef ptr IInterface_Function1Proto
IInterface_Function2 typedef ptr IInterface_Function2Proto

IInterface struct DWORD
QueryInterface IUnknown_QueryInterface ?
AddRef IUnknown_AddRef ?
Release IUnknown_Release ?
Function1 IInterface_Function1 ?
Function2 Interface_Function2 ?
IInterface ends

COM-:

mov eax, pObject
mov eax, [eax]
invoke (IInterface [eax]).Function1, 0, 0

, , , .

- COM

, , , ( , ).

Windows Shell, . , , COM, . , shell-, ,

.386
.model flat, stdcall

include windows.inc ;
include shlobj.inc ;
; shell'

;----------------------------------------------------------
.data
wMsg MSG <?>
g_hInstance dd ?
g_pShellMalloc dd ?

pshf dd ? ; shell'
peidl dd ? ; id

lvi LV_ITEM <?>
iCount dd ?
strret STRRET <?gt;
shfi SHFILEINFO <?>
...

;----------------------------------------------------------
.code
; Entry Point
start:
push 0h
call GetModuleHandle
mov g_hInstance,eax

call InitCommonControls

; Component Object Model (COM)
push 0
call CoInitialize
test eax,eax ; , MSB = 1
; (MSB = )
js exit ; js = ,

; shell' IMalloc
;
push offset g_pShellMalloc
call SHGetMalloc
cmp eax, E_FAIL
jz shutdown
; , list view,
; ...
; ....

;
; IMalloc
mov eax, g_pShellMalloc
push eax
mov eax, [eax]
call [eax + Release] ; g_pShellMalloc->Release();

shutdown:
; COM
call CoUninitialize

exit:
push wMsg.wParam
call ExitProcess
;


;----------------------------------------------------------
FillListView proc

; , pshf
push offset pshf
call SHGetDesktopFolder

; , EnumObjects
;
push offset peidl
push SHCONTF_NONFOLDERS
push 0
mov eax, pshf
push eax
mov eax, [eax]
call [eax + EnumObjects]

xor ebx, ebx ; ebx

; id
idlist_loop:
;
push 0
push offset pidl
push 1
mov eax, peidl
push eax
mov eax, [eax]
call [eax + Next]
test eax,eax
jnz idlist_endloop

mov lvi.imask, LVIF_TEXT or LVIF_IMAGE
mov lvi.iItem, ebx

; , GetDisplayNameOf
push offset strret
push SHGDN_NORMAL
push offset pidl
mov eax, pshf
push eax
mov eax, [eax]
call [eax + GetDisplayNameOf]
; GetDisplayNameOf ,
;
cmp strret.uType, STRRET_CSTR
je strret_cstr
cmp strret.uType, STRRET_OFFSET
je strret_offset

strret_olestr:
; WideCharToMultiByte,
; , ,
jmp strret_end

strret_cstr:
lea eax, strret.cStr
jmp strret_end

strret_offset:
mov eax, pidl
add eax, strret.uOffset

strret_end:
mov lvi.pszText, eax

;
push SHGFI_PIDL or SHGFI_SYSICONINDEX or SHGFI_SMALLICON or
SHGFI_ICON
push sizeof SHFILEINFO
push offset shfi
push 0
push pidl
call SHGetFileInfo
mov eax, shfi.iIcon
mov lvi.iImage, eax

;
push offset lvi
push 0
push LVM_INSERTITEM
push hWndListView
call SendMessage

; ebx
inc ebx, ebx
jmp idlist_loop

idlist_endloop:

; id
; ,
mov eax, peidl
push eax
mov eax,[eax]
call [eax + Release]

;
mov eax, pshf
push eax
mov eax,[eax]
call [eax + Release]

ret
FillListView endp

END start

, COM . , , . , COM , , .

[C] Bill T., . Aquila


[ ]



  !



: / Assembler /

linux
23-05-2010   

, - NASM (Netwide Assembler, nasm.2y.net). , : , , .. , ...

: 0
. : - 3562 - 2

NuMega Driver Studio WDM -
17-05-2010   

WDM - DDK . : , inf - , ....

: 0
. : - 3156 - 1

DriverWorks
17-05-2010   

, - . DriverStudio , , ...

: 0
. : - 3206 - 1

device object
17-05-2010   

KDevice KPnpDevice. DriverWorks: , ...

: 0
. : - 3246 - 2

17-05-2010   

, , - /, , , . ...

: 4
. : - 3423 - 1



e-mail:
:

| ?







IT -




-




  WWW.COMPROG.RU - 2009-2012 | Designed and Powered by Zaipov Renat | Projects