flat assembler
Message board for the users of flat assembler.

Index > Windows > COM again ...

Author
Thread Post new topic Reply to topic
iic2



Joined: 26 Jun 2008
Posts: 122
iic2 17 Aug 2008, 05:44
There are only three threads about **FASM and IPersistFile** on this earth. It makes you feel pretty strange when you search Goggle and "everywhere else" for weeks, then the only threads to pop-up, is your own. The FASM sample (usecom) ITaskList don't have to QueryInterface i don't think. IpersistFile must be query by Ishell. FASM don't seem to be set up to do this. Can FASM do it or not?

This file is INT ready and no buttons to push. I tried to debug but I don't understand the debugger. I get "Memory is not readable."and I don't know what to do about it. The code seems ok and I tried everything I could think of.

Also, CoCreateInstance IShellLink return a value in the MessageBox but ITaskBarList
don't, but ITaskBarList works in the usecom example!!! Would anyone mind checking this code? I included the assembled file in the attachment below.


Code:
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 ITaskBarList,\
           QueryInterface,\
           AddRef,\
           Release,\
           HrInit,\
           AddTab,\
           DeleteTab,\
           ActivateTab,\
           SetActiveAlt
; ..........................
interface IPersistFile,\
           QueryInterface,\
           AddRef,\
           Release,\
           GetClassID,\
           IsDirty,\
           Load,\
           Save,\
           SaveCompleted,\
           GetCurFile
; ..........................
interface IShellLink,\
           QueryInterface,\
           AddRef,\
           Release,\
           GetPath,\
           GetIDList,\
           SetIDList,\
           GetDescription,\
           SetDescription,\
           GetWorkingDirectory,\
           SetWorkingDirectory,\
           GetArguments,\
           SetArguments,\
           GetHotkey,\
           SetHotkey,\
           GetShowCmd,\
           SetShowCmd,\
           GetIconLocation,\
           SetIconLocation,\
           SetRelativePath,\
           Resolve,\
           SetPath

CLSCTX_INPROC_SERVER = 0x1


section '.code' code readable executable

 start:

 PUSH  0
 CALL  [CoInitialize]

 PUSH    s_IShellLink
 PUSH  IID_IShellLink
 PUSH  1
 PUSH  0
 PUSH  CLSID_ShellLink
 CALL  [CoCreateInstance]

            MOV [_TEST], eax
invoke MessageBox,0,_TEST,0,0



    lea eax,  [s_IShellLink]
    mov [ppsl], eax

    lea eax,  [s_IPersist]
    mov [pppf], eax



;INT3
comcall  ppsl,IShellLink,\
         QueryInterface,\
         IID_IPersistFile,[pppf]

MOV [_TEST], eax
invoke MessageBox,0,_TEST,0,0




    cominvk s_IShellLink,Release

        invoke  ExitProcess,0

;   ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )
;   ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )
section '.data' data readable writeable

;...........................................................
 CLSID_ShellLink   GUID 00021401-0000-0000-0C00-000000000046
 IID_IShellLink    GUID 000214ee-0000-0000-0C00-000000000046
 IID_IPersistFile  GUID 0000010b-0000-0000-0C00-000000000046
;...........................................................

  s_IShellLink      IShellLink
  s_IPersist       IPersistFile


_TEST    dd  1

hHeap   dd  ?
psl     dd  ?         
ppsl    dd  ?         
ppf     dd  ?       
pppf    dd  ?       
hResult dd  ?       

;   ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )
;   ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )

section '.idata' import data readable

  library kernel,'KERNEL32.DLL',\
          user,'USER32.DLL',\
          ole,'OLE32.DLL'

  import kernel,\
         GetModuleHandle,'GetModuleHandleA',\
         ExitProcess,'ExitProcess'

  import user,\
         DialogBoxParam,'DialogBoxParamA',\
         EndDialog,'EndDialog',\
         MessageBox,'MessageBoxA'
  import ole,\
         CoInitialize,'CoInitialize',\
         CoCreateInstance,'CoCreateInstance'    


Description:
Download
Filename: zDebug.zip
Filesize: 1.65 KB
Downloaded: 328 Time(s)

Post 17 Aug 2008, 05:44
View user's profile Send private message Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel 17 Aug 2008, 08:59
Quote:
FASM don't seem to be set up to do this. Can FASM do it or not?

What can be translated to 0s and 1s can be done with FASM. It's assembly for *'s sake!


Code:
 CLSID_ShellLink   GUID 00021401-0000-0000-0C00-000000000046 
 IID_IShellLink    GUID 000214ee-0000-0000-0C00-000000000046 
 IID_IPersistFile  GUID 0000010b-0000-0000-0C00-000000000046
    

Your CLSID and IIDs are erroneous. It's 0xc000 not 0x0c00. Use valid references.


Code:
    lea eax,  [s_IShellLink] 
    mov [ppsl], eax 

    lea eax,  [s_IPersist] 
    mov [pppf], eax 



;INT3 
comcall  ppsl,IShellLink,\ 
         QueryInterface,\ 
         IID_IPersistFile,[pppf]
    

What are those 'ppsl' and 'pppf' for?
Code:
cominvk s_IShellLink,QueryInterface,IID_IPersistFile,s_IPersist    



You should also release 's_IPersist' when you're done, not just 's_IShellLink'. And don't forget to 'CoUninitialize' too. Cleaning IS important.


And why don't you use the invoke macro instead of all these pushes and calls (e.g. 'invoke CoInitialize,0')? One line of code is much more readable than half a dozen.
Post 17 Aug 2008, 08:59
View user's profile Send private message Reply with quote
iic2



Joined: 26 Jun 2008
Posts: 122
iic2 17 Aug 2008, 10:20
ManOfSteel, please do me one last favor and place all of those corrections in the code so I can see it working. I don't want to have to come back tommorow. I been through hell. 3 hours of sleep per day since. I am new to fasm syntax . I don't know C code. I went straight to masm32 and I never had to use number like this and examples were everywhere which made things easy. 0xc000 ... at this moment I don't even know how which way o squeeze it in. and I am not good at math. I really appreciate it.

Thanks you
Post 17 Aug 2008, 10:20
View user's profile Send private message Reply with quote
iic2



Joined: 26 Jun 2008
Posts: 122
iic2 17 Aug 2008, 12:43
CLSID_ShellLink GUID 00021401-0000-0000-0C00-000000000046
IID_IShellLink GUID 000214ee-0000-0000-0C00-000000000046
IID_IPersistFile GUID 0000010b-0000-0000-0C00-000000000046

TO:

CLSID_ShellLink GUID 00021401-0000-0000-0c00-000000000046
IID_IShellLink GUID 000214ee-0000-0000-0c00-000000000046
IID_IPersistFile GUID 0000010b-0000-0000-0c00-000000000046


If this is what you mean [ 0C00 should be 0c00 ] It don't work Sad Why did you not post your fix ... Anyway, I am not worry about what's left-over in this tiny code posted above or when it is time to clean up. I'm only concern about the code
working from MessageBox 1 to MessageBox 2... anything not need, should have been overlooked. It used your suggest line of code, Near one full week since posting, I tried everything but the right thing. If you don't know how to fix it either ManOfSteel, don't worry about it. As long as you know I appreciate all of your help everything is fine. We threw down. but the fact that Google turns up nothing for FASM in COM since 1999 it can't be D assembler for *'s sake! ...
: Wink

Have a great day ManOfSteel
Post 17 Aug 2008, 12:43
View user's profile Send private message Reply with quote
asmhack



Joined: 01 Feb 2008
Posts: 431
asmhack 17 Aug 2008, 13:08
ManOfSteel didn't tell you to change uppercase to lowercase, that has no point, change the guid you are using:
Code:
;from:
xxxxxxxx-xxxx-xxxx-0C00-xxxxxxxxxxxx
;to:
xxxxxxxx-xxxx-xxxx-C000-xxxxxxxxxxxx    

and secondly why breaking your head with com technology and not with something easier for the moment ? if so go to http://wasm.ru/publist.php?list=15 and read the articles.. (if you don't know russian language, use a translator)
Post 17 Aug 2008, 13:08
View user's profile Send private message Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel 17 Aug 2008, 13:13
Quote:
place all of those corrections in the code so I can see it working.

Come on! I showed you exactly where the problems are and what to replace the erroneous code with. Just follow my first reply line by line.

Quote:
3 hours of sleep per day since.

Maybe that's the problem. 8 hours of sleep in a row won't hurt.

Quote:
I am new to fasm syntax .

This might help: http://flatassembler.net/docs.php

Quote:
I don't know C code. I went straight to masm32 and I never had to use number like this

You don't have to. GUIDs have nothing to do with C, MASM or FASM. They are just sequences of hexadecimal numbers and are used as identifiers in many places, one of them being COM which is language-independent (well, almost).

Quote:
0xc000 ... at this moment I don't even know how which way o squeeze it in.

00021401-0000-0000-0C00-000000000046 --> 00021401-0000-0000-C000-000000000046
As simple as that.
'0xabcd1234' is C-syntax (used in FASM) for hexadecimal, just like MASM's '0abcd1234h'.
Post 17 Aug 2008, 13:13
View user's profile Send private message Reply with quote
Yardman



Joined: 12 Apr 2005
Posts: 244
Location: US
Yardman 17 Aug 2008, 13:26
[ Post removed by author. ]


Last edited by Yardman on 04 Apr 2012, 03:36; edited 1 time in total
Post 17 Aug 2008, 13:26
View user's profile Send private message Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel 17 Aug 2008, 13:34
Yes, that is exactly it.
Post 17 Aug 2008, 13:34
View user's profile Send private message Reply with quote
iic2



Joined: 26 Jun 2008
Posts: 122
iic2 17 Aug 2008, 20:44
I was beginning to think there was no way and that you were only guesting based on experence with other assemblers. There are 5 millions real examples for C++, 3 or 4 for masm and absolutely nothing for fasm until now. What would **ANYONE** think after learning all of this. COM was the STUFF of the 90's. Seems everybody gave up long ago or founded other methods for fasm. Who knows. I'm just glad we get it now.

Those numbers was my major translation to fasm, I knew nothing. No docs, no usecom, no interface. Only the link below and a good guest based off of C, Monlker or Basic code i saw some where. Than you introduce me to usecom. From there I just knew I had it going on.

Anyway wooooo Woopie

btw: this was the **one and only** post that I was specking of from day1. I just went back to find those numbers. Who keeps up with names in a heat of a search. So wow ... one COM guy do exsist.

$214E8, 0, 0, <$C0,0,0,0,0,0,0,$46>

http://board.flatassembler.net/topic.php?t=7380

One cool fasm example coming shortly.. invoked Smile
Post 17 Aug 2008, 20:44
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.