1

In my namespace extension, I have folders that doesn't actually exist in the file system.

Sometimes, when browsing my namespace extension, Explorer simply re-navigates the user back to the root folder.

For example, navigating to

C:\root\folder\subfolder

I'm redirected back to

C:\root

This happens in unclear scenarios, but keeps reproducing.

I'm trying to debug it and identify what messes with Explorer, but I can't find the right tool.

I've tried ProcMon and DbgView of sysinternals, but couldn't find any relevant data.

I've added traces to any explicit calls I make to ShchangeNotify, but none are executed at the relevant time.

I've also tried to add traces to my implementation of IShellFolderViewCB.MessageSFVCB(). Again, no logs printed in the relevant timestamps.

I assume no one would be able to help my case without further information, but that applies to me as well. I need some better tool to catch the explorer events and identify what goes wrong.

Any suggestions?

Mugen
  • 8,301
  • 10
  • 62
  • 140
  • Considering your previous questions about NSE I think your code has a problem with PIDL creation. Wrong PIDL structure can be a reason of such behaviour. – Denis Anisimov May 18 '15 at 07:54
  • I'm using ancient legacy code for the PIDL, though from our previous conversations I couldn't detect any problem with it. Any reference on how to build the PIDL correctly? – Mugen May 18 '15 at 08:00
  • MSDN only: https://msdn.microsoft.com/library/windows/desktop/bb773321%28v=vs.85%29.aspx/ https://msdn.microsoft.com/en-us/library/windows/desktop/cc144090%28v=vs.85%29.aspx#ID_Lists_PIDL – Denis Anisimov May 18 '15 at 08:06
  • @DenisAnisimov I would appriciate it if you could take a look at my latest comment in our previous discussion: http://stackoverflow.com/questions/29004302/refreshing-a-folder-that-doesnt-exist-in-the-file-system Thank you in advance – Mugen May 18 '15 at 10:08
  • I suggest you have a look at your IShellFolder::GetDisplayNameOf implementation. I kinda recall I had similar problems and the issues was I was messing up this handling the various values in SHGDNF – Simon Mourier May 18 '15 at 21:21
  • @SimonMourier thanks I'll check if any calls are being made to this API when a the bug reproduces. Do you perhaps recall which flags you weren't handling correctly? – Mugen May 19 '15 at 13:20
  • 1
    I've copied my old code logic (it doesn't compile...) here: http://pastebin.com/DbZ9dznN – Simon Mourier May 19 '15 at 16:34

1 Answers1

2

This is not answer. This is advice only.

In my NSE I use logging. I see EVERY call of EVERY function of my NSE in realtime. I see all in and all out parameters. Every function in my sources looks like this:

function TdecShellNamespaceFolder.IShellFolder_ParseDisplayName(AWnd: HWND; ABindCtx: Pointer; ADisplayName: POLESTR; out AEaten: ULONG; out AItemIDList: PItemIDList; var AAttributes: ULONG): HRESULT;
var
  {$IFDEF USE_LOGS}
  CurrentMethod: string;
  {$ENDIF}
  Eaten: DWORD;
  Attr: TdecFileShellAttributes;
begin
  {$IFDEF USE_LOGS}
  CurrentMethod := 'IShellFolder.ParseDisplayName';
  LogSendEnter(CurrentMethod);
  LogSendInHWND(CurrentMethod, 'AOwner', AWnd);
  LogSendInBindCtx(CurrentMethod, 'ABindCtx', IBindCtx(ABindCtx));
  LogSendInParam(CurrentMethod, 'ADisplayName', ADisplayName);
  LogSendInNil(CurrentMethod, '@AEaten', @AEaten);
  LogSendInNil(CurrentMethod, '@AItemIDList', @AItemIDList);
  if Assigned(@AAttributes) then
    LogSendInParam(CurrentMethod, 'AAttributes', SFGAOToString(AAttributes))
  else
    LogSendInNil(CurrentMethod, '@AAttributes');
  Result := E_FAIL;
  try
  {$ENDIF}
    try
      // FUNCTION BODY
    except
      on E: Exception do
        begin
          {$IFDEF USE_LOGS}
          LogSendException(CurrentMethod, E);
          {$ENDIF}
          Result := HResultFromException(E);
        end;
    end;
  {$IFDEF USE_LOGS}
  finally
    if Result = S_OK then
      begin
        if Assigned(@AEaten) then
          LogSendOutParam(CurrentMethod, 'AEaten', IntToStr(AEaten));
        LogSendOutItemIDList(CurrentMethod, 'AItemIDList', AItemIDList);
        if Assigned(@AAttributes) then
          LogSendOutParam(CurrentMethod, 'AAttributes', SFGAOToString(AAttributes));
      end;
    LogSendResult(CurrentMethod, Result);
    LogSendExit(CurrentMethod);
  end;
  {$ENDIF}
end;

And logs look like this:

Logs

And logs helped me a lot of times to find problems in my code.

Denis Anisimov
  • 3,297
  • 1
  • 10
  • 18