flat assembler
Message board for the users of flat assembler.
Index
> Windows > COM-2-FASM |
Author |
|
ManOfSteel 12 Aug 2008, 06:12
Have you checked USECOM.ASM in your <fasm directory>\EXAMPLES\USECOM\?
|
|||
12 Aug 2008, 06:12 |
|
iic2 12 Aug 2008, 08:13
Seems like a lot less code too. I like to get the code above to working because most of the examples I have is GoAsm and masm style which I understand a little better as of today.
I have been working furiously with USECOM and is getting burn-out. I see a lot but I'm not crazy about the GUID struct marco. I like donkey style but USE.com will be the icing for the cake for FASM com. I am only one step away from my FASM code being able to run. I'm near sure this is the only problem and I just don't know how to write it ... call [edi+ITaskbarList.HrInit] Everything before that *WAS* the most important point where the return value must be good!!! But working with USECOM I can't seem to fix it. I hate to just give up and change it ALL. I did a lot of research and never asked a question until now. Some experence com person got to be able to see that small defect. Anyway, You are the Man Of Steal. The old-style USECOM and the workable-style above is going to be a great way to code COM in FASM. Less macro calls as possible. But right now, it don't matter. Thank you Very Much |
|||
12 Aug 2008, 08:13 |
|
iic2 12 Aug 2008, 09:21
I still don't have my code working yet, but the The old-style USECOM is looking better and better ever minute. It is sooooo small. Can't wait to combine the two.
|
|||
12 Aug 2008, 09:21 |
|
iic2 15 Aug 2008, 00:58
hmm, I guest I answered all of the additional questions myself in the link below. For the first time EVER I translated macros. I was force to translated both COMINVK and COMCALL. I now see the best way to learn how to use or write macros is to take one apart and that's not easy when you don't even know how to use them. It would have took months of quiting and coming back if not for these words:
Define CLSIDs and other IDs with the GUID macro: Define your interfaces with the interface macro: Define 'pointers' to your interfaces (and methods): Get a pointer to the interface you'll be using (with CoCreateInstance for example): This will fill the psl pointer from above: I'm back in school and you can bet I'll never see this in a text book until my 2nd year of classes. Than I have to read the whole book to get half of this until the next semester. Now I see. The ManOfSteel said it ALL. http://board.flatassembler.net/topic.php?t=9074 Enjoy Code: format PE GUI 4.0 entry start include '\fasm\include\win32a.inc' include '\fasm\include\macro\if.inc' include '\fasm\include\macro\com32.inc' struc GUID def { match d1-d2-d3-d4-d5, def \{ .Data1 dd 0x\#d1 .Data2 dw 0x\#d2 .Data3 dw 0x\#d3 .Data4 db 0x\#d4 shr 8,0x\#d4 and 0FFh .Data5 db 0x\#d5 shr 40,0x\#d5 shr 32 and 0FFh,\ 0x\#d5 shr 24 and 0FFh,\ 0x\#d5 shr 16 and 0FFh,\ 0x\#d5 shr 8 and 0FFh,0x\#d5 and 0FFh \} } ; .................................. ITaskBarListITaskBarList interface ITaskBarList,\ QueryInterface,\ AddRef,\ Release,\ HrInit,\ AddTab,\ DeleteTab,\ ActivateTab,\ SetActiveAlt i1 = 401 i2 = 402 i3 = 403 i4 = 404 CLSCTX_INPROC_SERVER = 0x1 section '.code' code readable executable start: invoke GetModuleHandle,0 mov [wc.hInstance],eax invoke LoadIcon,[wc.hInstance],0 mov [wc.hIcon],eax invoke LoadCursor,0,IDC_ARROW mov [wc.hCursor],eax invoke RegisterClass,wc push 0 push [wc.hInstance] push 0 push 0 PUSH 200;[WinH] PUSH 400;[WinW] PUSH 100;[WinY] PUSH 300;[WinX] push WS_OVERLAPPEDWINDOW push Title push ClassName push 4h or 00000100h or 10h ; WS_EX_NOPARENTNOTIFY ; WS_EX_WINDOWEDGE &_ACCEPTFILES CALL [CreateWindowExA] mov [hwnd],eax invoke CreateWindowEx,0,btnClass,btnText1,\ 40000000h or 10000000h or 1, 20,20,60,30,[hwnd],i1,0,0 mov [hButt1], eax invoke CreateWindowEx,0,btnClass,btnText2,\ 40000000h or 10000000h or 1, 100,20,60,30,[hwnd],i2,0,0 mov [hButt2], eax invoke CreateWindowEx,0,btnClass,btnText3,\ 40000000h or 10000000h or 1, 220,20,60,30,[hwnd],i3,0,0 mov [hButt3], eax invoke CreateWindowEx,0,btnClass,btnText4,\ 40000000h or 10000000h or 1, 300,20,60,30,[hwnd],i4,0,0 mov [hButt4], eax invoke CreateWindowEx,0,editClass,editText1,\ 40000000h or 10000000h or 800000h or 1000h or\ 10000h or 4h or 1h or 10000h,\ 20,80,340,25,[hwnd],0,0,0 mov [hEdit1], eax invoke CreateWindowExA,0,editClass,editText2,\ 40000000h or 10000000h or 800000h or 1000h or\ 10000h or 4h or 1h or 10000h,\ 20,110,340,25,[hwnd],0,0,0 mov [hEdit2], eax call GET_OLE32 PUSH 0 CALL [CoInitialize] invoke ShowWindow,[hwnd],SW_SHOWDEFAULT invoke UpdateWindow,[hwnd] ;----------------------------- MessageLoop: ;----------------------------- invoke GetMessage,msg,0,0,0 or eax,eax jz ExitProgram invoke TranslateMessage,msg invoke DispatchMessage,msg jmp MessageLoop ExitProgram: invoke ExitProcess,[msg.wParam] ; ****************************************************** ; |||||||||||||||||||||||||||||||||||||||||||||||||||||| ; ****************************************************** ; |||||||||||||||||||||||||||||||||||||||||||||||||||||| ; ****************************************************** ; |||||||||||||||||||||||||||||||||||||||||||||||||||||| ; ****************************************************** proc WindowProc uses ebx esi edi,hWnd,uMsg,wParam,lParam .if [uMsg] = WM_CLOSE cominvk s_ITaskBar, Release invoke PostQuitMessage,0 .elseif [uMsg] = WM_COMMAND ; .......................................... ; .......................................... Button 1 .if [wParam] = BN_CLICKED shl 16 + i1 mov ebx, s_ITaskBar ; Hide call CoCreate ; ..................................................... ; .......................... cominvk s_ITaskBar,HrInit ; ................. cominvk s_ITaskBar,DeleteTab,[hwnd] ; ..................................................... push s_ITaskBar mov edi, [s_ITaskBar] mov edi, [edi] call [edi+ITaskBarList.HrInit] push [hwnd] push [s_ITaskBar] call [edi+ITaskBarList.DeleteTab] ; invoke CoUninitialize .endif ; .......................................... ; .......................................... Button 2 .if [wParam] = BN_CLICKED shl 16 + i2 mov ebx, s_ITaskBar ; show call CoCreate ; .................................................... ; .................... comcall ebx,ITaskBarList,HrInit ; ............. comcall ebx,ITaskBarList,AddTab,[hwnd] ; ........ comcall ebx,ITaskBarList,ActivateTab,[hwnd] ; .................................................... push s_ITaskBar mov edi, [s_ITaskBar] mov edi, [edi] call [edi+ITaskBarList.HrInit] push [hwnd] push [s_ITaskBar] call [edi+ITaskBarList.AddTab] push [hwnd] push [s_ITaskBar] call [edi+ITaskBarList.ActivateTab] ; invoke CoUninitialize .endif ; .......................................... ; .......................................... Button 1 .if [wParam] = BN_CLICKED shl 16 + i4 .endif .else invoke DefWindowProc,[hWnd],[uMsg],[wParam],[lParam] ret .endif mov eax,0 ret endp ; ****************************************************** ; ****************************************************** section '.data' data readable writeable ;sCLSID_TaskbarList textequ <056fdf344H, 0fd6dH, 011D0H, ; {095H, 08ah, 000H, 060H, ; 097H, 0c9H, 0a0H, 090H> ;........................................................... IID_ITaskbarList GUID 56FDF342-FD6D-11D0-958A-006097C9A090 CLSID_TaskbarList GUID 56FDF344-FD6D-11D0-958A-006097C9A090 ;........................................................... s_ITaskBar ITaskBarList sz_ole32_dll db 'ole32.dll',0 sz_CoCreateInstance db 'CoCreateInstance',0 sz_CoCreateInstanceEx db 'CoCreateInstanceEx',0 sz_CoInitialize db 'CoInitialize',0 sz_CoInitializeEx db 'CoInitializeEx',0 sz_CoUninitialize db 'CoUninitialize',0 Title db 'COM 2 FASM',0 ClassName db 'ClassWindows',0 btnClass db 'button',0 editClass db 'edit',0 btnText1 db 'Hide',0 btnText2 db 'Show',0 btnText3 db 'Blank',0 btnText4 db 'Blank',0 editText1 db 'Hide or Show Icon',0 editText2 db 'from Taskbarlist',0 align 4 oleDLL dd 1 CoCreateInstance dd 1 Protect_0le1 dd 1 CoCreateInstanceEx dd 1 CoInitialize dd 1 CoInitializeEx dd 1 CoUninitialize dd 1 hButt1 dd 1 hButt2 dd 1 hButt3 dd 1 hButt4 dd 1 hEdit1 dd 1 hEdit2 dd 1 _TEST dd 1 String1 db 256 dup(?) hwnd dd ? wc WNDCLASS 0,WindowProc,0,0,\ NULL,NULL,NULL,COLOR_BTNFACE+1,NULL,ClassName ps PAINTSTRUCT msg MSG rect RECT section '.idata' import data readable writeable library kernel32,'KERNEL32.DLL',\ user32,'USER32.DLL',\ shell32,'SHELL32.DLL',\ gdi32,'GDI32.DLL' ; ------------------------------- include '\fasm\include\api\kernel32.inc' include '\fasm\include\api\user32.inc' include '\fasm\include\api\shell32.inc' include '\fasm\include\api\gdi32.inc' GET_OLE32: push sz_ole32_dll call [LoadLibrary] mov [oleDLL], eax ; .......................... Get CoCreateInstance push sz_CoCreateInstance push [oleDLL] call [GetProcAddress] mov [CoCreateInstance], eax ; .......................... Get CoCreateInstanceEx push sz_CoCreateInstanceEx push [oleDLL] call [GetProcAddress] mov [CoCreateInstanceEx], eax ; .......................... Get CoInitialize push sz_CoInitialize push [oleDLL] call [GetProcAddress] mov [CoInitialize], eax ; .......................... Get CoInitializeEx push sz_CoInitializeEx push [oleDLL] call [GetProcAddress] mov [CoInitializeEx], eax ; .......................... Get CoUninitialize push sz_CoUninitialize push [oleDLL] call [GetProcAddress] mov [CoUninitialize], eax ret ; ####################################################### ; ####################################################### CoCreate: PUSH ebx ; s_ITaskBar PUSH IID_ITaskbarList ; <56FDF342> PUSH 1 ; CLSCTX_INPROC_SERVER PUSH 0 ; NULL PUSH CLSID_TaskbarList ; <56FDF344> CALL [CoCreateInstance] ret |
|||
15 Aug 2008, 00:58 |
|
Zero 15 Aug 2008, 01:35
May I ask which school you go to, what specialization you are doing, and what class this is for?
I ask because I have no idea what COM, COMCALL, or COMINVK are....and so i'm curious to know what subjects you are studying. So far, in my school I have not seen any classes that deal with that, maybe they don't teach it over here. |
|||
15 Aug 2008, 01:35 |
|
iic2 15 Aug 2008, 04:19
Hello zero,
I was just giving an example of how long it would take to get to any good parts of any subject when going to any school or anything you want to learn about. For example; Lets say my goal is to build a Firewall. I have to study the Information Security field starting with Windows, UNIX, database, etc, etc, etc, THAN programming. I care nothing of database. By time I get to a class where they talk FireWall it be 6 - 12 month latter when they tell me Firewalls don't really provide security with-out adding this or using that. No one said some COM can crash your system badly. Reading books and doc's are great but some people learn better from words of experenced people. Example: I read the manual about COM, saw a few examples but understood only 25%. I posted what little I knew. ManOfSteel laid the whole format down in a few word that put all of those bits and piece together in a flash (a night or two). The missing 50-75% more info needed was there. In the programming game no one is going to spend forever trying to include one function. I been there and done that "Big Time"... Now I just quit and move to the next part of an project and come back next year to try again. You usually would just stmble upon it, with a better understanding of it all anyway somewhere between. If you are in school for programming the subject of FASM will come up if you taking Assembler. They still may not know much about COM, COMCALL, or COMINVK no more than yourself so you bring it up all day everyday with your questions. If you in C++ or JAVA they may kick you out because they know you know too to much. hee hee ... My school is IU. First year. School is cool. Assembler Forums and Google are great also but they can't promise a job. My asm projects are mostly for personal use. I go to school only to learn how to walk the walk and talk the talk for a better job in the computer field. Darn this quick note has gotton long. Hope I answered most of your questions. |
|||
15 Aug 2008, 04:19 |
|
iic2 18 Aug 2008, 04:57
Soluton founded here:
http://board.flatassembler.net/topic.php?t=9096 Please check this code for any leaks and post repaired\improved code or others ways of doing thing as asmhack has suggested: Shortcut Creator: COM in FASM: 2008 Code: ; ....................................... ; Shortcut Creator for FASM 08\18\2008 : ; Notepad.exe Shortcut will be created : ; Thanks to The ManOfSteel and Friends : ; ....................................... format pe gui 4.0 entry start include "\fasm\include\win32a.inc" struc GUID def { match d1-d2-d3-d4-d5, def \{ .Data1 dd 0x\#d1 .Data2 dw 0x\#d2 .Data3 dw 0x\#d3 .Data4 db 0x\#d4 shr 8,0x\#d4 and 0FFh .Data5 db 0x\#d5 shr 40,0x\#d5 shr 32 and 0FFh,\ 0x\#d5 shr 24 and 0FFh,\ 0x\#d5 shr 16 and 0FFh,\ 0x\#d5 shr 8 and 0FFh,0x\#d5 and 0FFh \} } interface IShellLink,\ QueryInterface,\ AddRef,\ Release,\ GetPath,\ GetIDList,\ SetIDList,\ GetDescription,\ SetDescription,\ GetWorkingDirectory,\ SetWorkingDirectory,\ GetArguments,\ SetArguments,\ GetHotkey,\ SetHotkey,\ GetShowCmd,\ SetShowCmd,\ GetIconLocation,\ SetIconLocation,\ SetRelativePath,\ Resolve,\ SetPath interface IPersistFile,\ QueryInterface,\ AddRef,\ Release,\ GetClassID,\ IsDirty,\ Load,\ Save,\ SaveCompleted,\ GetCurFile CLSCTX_INPROC_SERVER = 0x1 section '.code' code readable executable start: ; ............................................... ; ............................................... ; ............................................... invoke CoInitialize,NULL invoke CoCreateInstance,CLSID_ShellLink,0,1,IID_IShellLink,psl cmp eax, 0 jne L_exit ; ............................................... get ppf for ; ............................................... saving sc cominvk psl,QueryInterface, IID_IPersistFile,ppf cmp eax, 0 jne L_exit ; ............................................... sc target mov ebx, [psl] mov eax, ShortCut_Path mov [dwBuff], eax comcall ebx,IShellLink,SetPath,[dwBuff] cmp eax, 0 jne L_exit ; ............................................... Unicode invoke MultiByteToWideChar,0,0,\ szLinkName,\ -1,bBUFFER,260 cmp eax, 0 je L_exit ; ............................................... Save target mov ebx, [ppf] mov eax, bBUFFER mov [pBigBuff], eax comcall ebx,IPersistFile,Save,[pBigBuff] cmp eax, 0 je L_exit ; ............................................... All Done!!! L_exit: cominvk ppf, Release cominvk psl, Release invoke CoUninitialize invoke ExitProcess,0 section '.data' data readable writeable CLSID_ShellLink GUID 00021401-0000-0000-C000-000000000046 IID_IShellLink GUID 000214ee-0000-0000-C000-000000000046 IID_IPersistFile GUID 0000010b-0000-0000-C000-000000000046 psl IShellLink ppf IPersistFile szLinkName db "Notepad.lnk", 0 ShortCut_Path db "c:\windows\notepad.exe", 0 dwBuff dd ? pBigBuff dd ? bBUFFER db 512 dup (?) section '.idata' import data readable library kernel32,'kernel32.dll',\ user32,'user32.dll',\ ole32,'ole32.dll' include '\fasm\include\api\kernel32.inc' include '\fasm\include\api\user32.inc' import ole32,\ CoInitialize,'CoInitialize',\ CoUninitialize,'CoUninitialize',\ CoCreateInstance,'CoCreateInstance' |
|||
18 Aug 2008, 04:57 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.