News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

ownerdrawn menu

Started by evlncrn8, June 25, 2007, 05:01:01 PM

Previous topic - Next topic

jdoe

Quote from: donkey on June 26, 2007, 10:32:06 PM
I know exactly what you mean, here's my project to date. It just doesn't seem to work and I can't figure out why. Probably lost in some indirection myself :)

NOTE: GoAsm syntax

I didn't had much time to look at your code but...

Why you don't have a global reference counter for the IContextMenu.dll (which is independent from reference counter of each object). It is the global dll reference counter that must be used in DllCanUnloadNow to know if the dll can be unloaded (not the ClassFactory counter). The ClassFactory object must be freed after CreateInstance success (Windows call Release for that).

The reference counter of ClassFactoryObject and ShellExtObject start at 1 which is supposed to be 0 and increment after their creation if sucessfull).

I don't know a lot about GoAsm but what I would do is putting some messagebox here and there to track where the code is leaving or try a debugger (I had no luck personally trying a debugger with shell extensions). The registry settings seems ok but don't forget "SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved" on Windows 2000 and higher.

I can't be sure about the vTable because I don't know if the syntax is ok for GoAsm.

IShellExtInit and IContextMenu pointer to vtable must be in the same object

You should try first to put the selected path in your object and use IDataObject.GetData (IShellExtInit - Initialize) to get that path with FORMATETC / STGMEDIUM.

Look at this...

http://www.codeproject.com/shell/shellextguide1.asp
http://www.masm32.com/board/index.php?topic=7520.msg55464#msg55464

Do you reach IShellExtInit and IContextMenu method ? If not, I would concentrate on vtable and reference counters first to be sure it start well.





drizz

i had a look..

first, DllGetClassObject has three parameters
DllGetClassObject FRAME rclsid, riid, ppvOut
you compare (in one place)
invoke IsEqualGUID,[riid],[IID_IUnknown]
but it should be "offset IID_IUnknown" and "offset IID_IClassFactory"

all ppXXX parameters must be nulled as
   mov eax,[ppv]
   mov D[eax],NULL
not as "mov D[ppXXX],NULL" (you do that in some places)


the pointer to pointer to struct! :)
invoke ClassFactoryQueryInterface,offset vtIClassFactory,[riid],[ppvOut]
change to
invoke ClassFactoryQueryInterface,offset ObjClassFactory,[riid],[ppvOut]


this is not good too!
invoke [eax+IShellExtension.IUnknown.QueryInterface],eax,[riid],[ppvObj]
should be
mov edx,D[eax+ShellExtObject.lpVtbl]
invoke [edx+IShellExtension.IUnknown.QueryInterface],eax,[riid],[ppvObj]
The truth cannot be learned ... it can only be recognized.

ragdog

hi

sorry which I answer so late

here is a nice draw menu example


greets
ragdog

[attachment deleted by admin]

SeaFarer

Hi drizz, ( other guys too )

I downloaded your PeINFO iContextMenu COM server example. Very nice. One thing, about 5 seconds after opening an exe or dll, it crashes on my P1 200mhz with Win98se.

Kinda bummed about it since it seems like a great GUI based alternative to the DumpPe console app included with the MASM32 package.

Any ideas on how I can fix the problem?

Or does anyone have a basic "Hello World" MsgBx example of IContextMenu shell extensions that actually works on a 9x system using windows.inc vs. win32.inc?

It would be helpful in trying to determine for myself what part(s) of drizz's PeINFO COM server Win98se is not agreeing with, and creating other handlers.

Regards

Quote from: drizz on June 26, 2007, 02:43:03 PM
Hi donkey,

i wrote some code to handle IContextMenu. it's a real mess. see if you can find something of interest in it

Edit: forgot to add resources to the zip

SeaFarer

Acting on a hunch I verified what the problem seems to be on my win9x box.

Firstly to replicate the issue you can do one of two things.

1.) Right click a PE/DLL file and leave the context menu open for 5-10 seconds, before trying to select the new menu entrys.( as soon as mouse hovers it, POOF!)

2.) Same as above, but select the new entry without delay and just wait whilst a dialog is still open. (When the dll unloads, POOF!)

Then you would be unpleasently surprised to see the GP Fault dialog, click OK, and POOF! Explorer crashes and restarts. Darn... I really hate it when that happens!

If you don't wait and close the context menu, it will crash. If you don't wait, selected the new item, and close the dialog created, it works fine. Go figure?

Anyway... my hunch was that the dll was being unloaded before taking any action. Verified by using this code in DllMain...

.ELSEIF dwReason == DLL_PROCESS_DETACH
    INVOKE Beep,500,500

The reason being Windows reports the fault happened in Shell32.dll. Which I'm sure is true, but better info would have made it easier to track down/figure out. I'm really not into this that deep that register values on a crash mean anything to me.

Anyway.... according to what I read in the Win32 Developers Reference... the problem there in lies in implementing IClassFactory::LockServer==true... which prevents the dll from unloading until IClassFactory::LockServer==FALSE is implemented to allow the dll to unload.

I suspect it was never an issue or discovered since us coders and power users usually don't wait for stuff to happen and just click, click, click...

Can you replicate this bug on 2K and XP? If not they must have made some improvements to prevent this type of hubub.

Regards

drizz

i will look int it as soon as i have time, i know it has bugs - it was my first venture into COM
i think i will do a complete rewrite....

The truth cannot be learned ... it can only be recognized.