As pointed out banging head with explorer is not easy also access denied is
NTSTATUS so you would need to run from user land to kernel land and back
which is another hurdle
anyway ill summarize see if you can follow
C:\Documents and Settings\Admin\Desktop>md somedirondesktop
C:\Documents and Settings\Admin\Desktop>cd somedirondesktop
C:\Documents and Settings\Admin\Desktop\somedirondesktop>cd …
C:\Documents and Settings\Admin\Desktop>cacls somedirondesktop /p Admin:N
Are you sure (Y/N)?y
processed dir: C:\Documents and Settings\Admin\Desktop\somedirondesktop
C:\Documents and Settings\Admin\Desktop>cd somedirondesktop
Access is denied.
C:\Documents and Settings\Admin\Desktop>
attach windbg to explorer.exe
set a bp on one most probable api ill use SHGetFolderpathW
and once it breaks use gu to trace around userland code
it should take you to ntdll!NtOpenFile at last where it transits to
kernelland
if you can use ntsd in conjunction with kd you can set a break on
IopCreatefile Routine and follow it allthe way to fltmgr.sys
and back
somewhere along the path you should find your token
here is a paste
C:\>cd %userprofile%\desktop\acctok
Access is denied.
C:\>f:\windbg\ntsd.exe -pn explorer.exe
0:000> bd *
0:000> bp SHELL32!CFSFolder::EnumObjects
0:000> bl
0 d 7c9eed76 0001 (0001) 0:**** SHELL32!SHGetFolderPathW
1 e 7c9f3b27 0001 (0001) 0:**** SHELL32!CFSFolder::EnumObjects
0:000> k
ChildEBP RetAddr
0007f10c 7c9f2781 SHELL32!SHGetFolderPathW
0007f138 7c9ece91 SHELL32!CFSFolder::_GetPath+0x2c
0007f148 7c9fd9b3 SHELL32!CFSFolder::_GetPathForItem+0x10
0007f164 7c9fd927 SHELL32!CFSAssocEnumData::CFSAssocEnumData+0x3e
0007f1ac 7ca11a55 SHELL32!CFileSysItemString::AssocCreate+0x153
0007f42c 7ca11a05 SHELL32!CFSFolder::_CreateContextMenu+0x47
0007f448 7c9f2dc2 SHELL32!CFSFolder::_GetContextMenu+0x19
0007f47c 7ca34fca SHELL32!CFSFolder::GetUIObjectOf+0x21c
0007f4a4 7ca34f96 SHELL32!CDesktopFolder::_GetItemUIObject+0x31
0007f4d4 7ca2d3a6 SHELL32!CDesktopFolder::GetUIObjectOf+0x110
0007f510 7ca48630 SHELL32!CRegFolder::GetUIObjectOf+0x28c
0007f548 7ca05b22 SHELL32!CDefView::_GetUIObjectFromItem+0x69
0007f58c 7cb2ca32 SHELL32!CDefView::GetItemObject+0x20c
0007f5b8 7caaabb6 SHELL32!CDefView::_CreateSelectionContextMenu+0xa9
0007f5dc 7ca495e1 SHELL32!CDefView::_InvokeContextMenuVerbOnSelection+0x71
0007f85c 7c9f461b SHELL32!CDefView::_OnLVNotify+0x37a
0007f874 7c9f448b SHELL32!CDefView::_OnNotify+0x7c
0007f9e8 7c9f44ff SHELL32!CDefView::WndProc+0x860
0007fa2c 7e418734 SHELL32!CDefView::s_WndProc+0x72
0007fa58 7e418816 USER32!InternalCallWinProc+0x28
0:000> db poi(esp+18) l20
00107778 3a 00 31 00 00 00 00 00-98 3d 76 19 10 20 61 63 :.1…=v… ac
00107788 63 74 6f 6b 00 00 24 00-03 00 04 00 ef be 98 3d ctok…$…=
0:000> !dml_proc
DbgId PID Image file name
0 b2c C:\WINDOWS\explorer.exe
0:000> gu
SHELL32!CFSFolder::_GetPath+0x2c:
7c9f2781 83f801 cmp eax,1
0:000> gu
SHELL32!CFSFolder::_GetPathForItem+0x10:
7c9ece91 85c0 test eax,eax
0:000> gu
SHELL32!CFSAssocEnumData::CFSAssocEnumData+0x3e:
7c9fd9b3 837e0c00 cmp dword ptr [esi+0Ch],0
ds:0023:0011385c=00000000
0:000> gu
SHELL32!CFileSysItemString::AssocCreate+0x153:
7c9fd927 8bf0 mov esi,eax
0:000> gu
SHELL32!CFSFolder::_CreateContextMenu+0x47:
7ca11a55 8b06 mov eax,dword ptr [esi]
ds:0023:000c7ed8={SHELL32!CFSFolder::`vftable’ (7c9c71f0)}
0:000> gu
SHELL32!CFSFolder::_GetContextMenu+0x19:
7ca11a05 5d pop ebp
0:000> gu
SHELL32!CFSFolder::GetUIObjectOf+0x21c:
7c9f2dc2 ebb5 jmp SHELL32!CFSFolder::GetUIObjectOf+0x261
(7c9f2d79)
0:000> gu
SHELL32!CDesktopFolder::_GetItemUIObject+0x31:
7ca34fca 5e pop esi
0:000> gu
SHELL32!CDesktopFolder::GetUIObjectOf+0x110:
7ca34f96 e97684ffff jmp
SHELL32!CDesktopFolder::GetUIObjectOf+0x110 (7ca2d411)
0:000> gu
SHELL32!CRegFolder::GetUIObjectOf+0x28c:
7ca2d3a6 e99b8cfcff jmp SHELL32!CRegFolder::GetUIObjectOf+0x28c
(7c9f6046)
0:000> gu
SHELL32!CDefView::_GetUIObjectFromItem+0x69:
7ca48630 3bc6 cmp eax,esi
0:000> gu
SHELL32!CDefView::GetItemObject+0x20c:
7ca05b22 8bf0 mov esi,eax
0:000> gu
SHELL32!CDefView::_CreateSelectionContextMenu+0xa9:
7cb2ca32 8945fc mov dword ptr [ebp-4],eax
ss:0023:0007f5b4=8007000e
0:000> gu
SHELL32!CDefView::_InvokeContextMenuVerbOnSelection+0x71:
7caaabb6 8bf8 mov edi,eax
0:000> gu
SHELL32!CDefView::_OnLVNotify+0x37a:
7ca495e1 e917b1faff jmp SHELL32!CDefView::_OnLVNotify+0x72b
(7c9f46fd)
0:000> gu
SHELL32!CDefView::_OnNotify+0x7c:
7c9f461b 5e pop esi
0:000> gu
SHELL32!CDefView::WndProc+0x860:
7c9f448b 8bf8 mov edi,eax
0:000> gu
SHELL32!CDefView::s_WndProc+0x72:
7c9f44ff 8945e0 mov dword ptr [ebp-20h],eax
ss:0023:0007fa0c=00000000
0:000> gu
USER32!InternalCallWinProc+0x28:
7e418734 648b0d18000000 mov ecx,dword ptr fs:[18h]
fs:003b:00000018=7ffdf000
0:000> gu
USER32!UserCallWinProcCheckWow+0x150:
7e418816 8945e4 mov dword ptr [ebp-1Ch],eax
ss:0023:0007faa4=00000000
0:000> gu
USER32!SendMessageWorker+0x4a5:
7e42927b 8bc8 mov ecx,eax
0:000> gu
USER32!SendMessageW+0x7f:
7e4292e3 5e pop esi
0:000> gu
comctl32!CCSendNotify+0xc20:
773eb001 e9e1fbffff jmp comctl32!CCSendNotify+0x806 (773eabe7)
0:000> gu
comctl32!ListView_HandleMouse+0x20e:
77420711 eb13 jmp comctl32!ListView_HandleMouse+0x223
(77420726)
0:000> gu
comctl32!ListView_OnButtonDown+0x1b:
77420ab6 5d pop ebp
0:000> gu
comctl32!ListView_WndProc+0x857:
774214e9 e983f8ffff jmp comctl32!ListView_WndProc+0xdf (77420d71)
0:000> gu
USER32!InternalCallWinProc+0x28:
7e418734 648b0d18000000 mov ecx,dword ptr fs:[18h]
fs:003b:00000018=7ffdf000
0:000> gu
USER32!UserCallWinProcCheckWow+0x150:
7e418816 8945e4 mov dword ptr [ebp-1Ch],eax
ss:0023:0007fe38=00000000
0:000> gu
USER32!DispatchMessageWorker+0x306:
7e4189cd 8bc8 mov ecx,eax
0:000> gu
USER32!DispatchMessageW+0xf:
7e418a10 5d pop ebp
0:000> gu
SHELL32!CDesktopBrowser::_PeekForAMessage+0x66:
7c9f4bcf 6a02 push 2
0:000> gu
SHELL32!CDesktopBrowser::_MessageLoop+0x14:
7c9f4a64 33ff xor edi,edi
0:000> gu
Breakpoint 1 hit
SHELL32!CFSFolder::EnumObjects:
7c9f3b27 8bff mov edi,edi
0:013> bd *
0:013> bp ntdll!ZwOpenFile
0:013> gu
Breakpoint 2 hit
ntdll!NtOpenFile:
7c90d59e b874000000 mov eax,74h
0:013> dt ntdll!_OBJECT_ATTRIBUTES poi(esp+0c)
+0x000 Length : 0x18
+0x004 RootDirectory : (null)
+0x008 ObjectName : 0x029bd5a0 _UNICODE_STRING "??\C:\Documents
and Settings\Admin\Desktop\acctok"
+0x00c Attributes : 0x40
+0x010 SecurityDescriptor : (null)
+0x014 SecurityQualityOfService : (null)
0:013> gu
kernel32!FindFirstFileExW+0x1a7:
7c80ec96 3d0d0000c0 cmp eax,0C000000Dh
0:013> r eax
eax=c0000022
0:013> !error eax
Error code: (NTSTATUS) 0xc0000022 (3221225506) - {Access Denied} A process
has
requested access to an object, but has not been granted those access
rights.
0:013> .detach
Detached
NoTarget>
regards
raj
On Mon, Jan 3, 2011 at 9:45 AM, wrote:
> hi Scott,
>
> Ty for your reply. And yes !token would give you the info , but my question
> was specific to folder residing on explorer.exe.
>
> the example which i mentioned in my first post is what i am trying to do
> and want to hook windbg to analyze
>
> a) folder activity ( when i double click , i want to see the api’s being
> called , the stack etc. )
>
> b) later i want to check the access token of that folder –> because IMO
> every process / thread has the access token attached ( this access token
> gets generated when the user logs in ) , so every object ( file / folder
> etc… ) has a token attached and i want to anlayze that in windbg.
>
> i dont want to analyze the accesstoken of the explorer.exe on which the
> folder is residing , rather i want to analyze the access token of the folder
> using Windbg.
>
> —
> WINDBG is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
–
thanks and regards
raj_r