├── .gitattributes ├── .gitignore ├── ObjDir.sln ├── ObjDir ├── NtDll.h ├── ObjDir.cpp ├── ObjDir.vcxproj ├── ObjDir.vcxproj.filters ├── ObjectManager.cpp ├── ObjectManager.h ├── pch.cpp ├── pch.h └── targetver.h └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | 259 | # Python Tools for Visual Studio (PTVS) 260 | __pycache__/ 261 | *.pyc -------------------------------------------------------------------------------- /ObjDir.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27004.2002 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ObjDir", "ObjDir\ObjDir.vcxproj", "{EE0D2993-2EB8-4189-837E-D038DFB9AAF3}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {EE0D2993-2EB8-4189-837E-D038DFB9AAF3}.Debug|x64.ActiveCfg = Debug|x64 17 | {EE0D2993-2EB8-4189-837E-D038DFB9AAF3}.Debug|x64.Build.0 = Debug|x64 18 | {EE0D2993-2EB8-4189-837E-D038DFB9AAF3}.Debug|x86.ActiveCfg = Debug|Win32 19 | {EE0D2993-2EB8-4189-837E-D038DFB9AAF3}.Debug|x86.Build.0 = Debug|Win32 20 | {EE0D2993-2EB8-4189-837E-D038DFB9AAF3}.Release|x64.ActiveCfg = Release|x64 21 | {EE0D2993-2EB8-4189-837E-D038DFB9AAF3}.Release|x64.Build.0 = Release|x64 22 | {EE0D2993-2EB8-4189-837E-D038DFB9AAF3}.Release|x86.ActiveCfg = Release|Win32 23 | {EE0D2993-2EB8-4189-837E-D038DFB9AAF3}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {775CD7D3-AE07-467B-A71C-3E253F3E32AC} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /ObjDir/NtDll.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | extern "C" { 4 | namespace NT { 5 | typedef struct _UNICODE_STRING { 6 | USHORT Length; 7 | USHORT MaximumLength; 8 | #ifdef MIDL_PASS 9 | [size_is(MaximumLength / 2), length_is((Length) / 2)] USHORT* Buffer; 10 | #else // MIDL_PASS 11 | _Field_size_bytes_part_(MaximumLength, Length) PWCH Buffer; 12 | #endif // MIDL_PASS 13 | } UNICODE_STRING; 14 | typedef UNICODE_STRING* PUNICODE_STRING; 15 | typedef const UNICODE_STRING* PCUNICODE_STRING; 16 | 17 | typedef long NTSTATUS; 18 | 19 | typedef struct QueryDirectoryObjectBuffer_t { 20 | UNICODE_STRING DirectoryEntry; 21 | UNICODE_STRING DirectoryEntryType; 22 | char Buffer[1000]; 23 | } QUERYDIRECTORYOBJECTBUFFER, * PQUERYDIRECTORYOBJECTBUFFER; 24 | 25 | typedef struct _OBJECT_ATTRIBUTES { 26 | ULONG Length; 27 | HANDLE RootDirectory; 28 | PUNICODE_STRING ObjectName; 29 | ULONG Attributes; 30 | PVOID SecurityDescriptor; // Points to type SECURITY_DESCRIPTOR 31 | PVOID SecurityQualityOfService; // Points to type SECURITY_QUALITY_OF_SERVICE 32 | } OBJECT_ATTRIBUTES; 33 | typedef OBJECT_ATTRIBUTES* POBJECT_ATTRIBUTES; 34 | typedef CONST OBJECT_ATTRIBUTES* PCOBJECT_ATTRIBUTES; 35 | 36 | typedef ULONG ACCESS_MASK; 37 | typedef ACCESS_MASK* PACCESS_MASK; 38 | 39 | #define InitializeObjectAttributes( p, n, a, r, s ) { \ 40 | (p)->Length = sizeof( OBJECT_ATTRIBUTES ); \ 41 | (p)->RootDirectory = r; \ 42 | (p)->Attributes = a; \ 43 | (p)->ObjectName = n; \ 44 | (p)->SecurityDescriptor = s; \ 45 | (p)->SecurityQualityOfService = NULL; \ 46 | } 47 | 48 | #define DIRECTORY_QUERY (0x0001) 49 | #define DIRECTORY_TRAVERSE (0x0002) 50 | #define DIRECTORY_CREATE_OBJECT (0x0004) 51 | #define DIRECTORY_CREATE_SUBDIRECTORY (0x0008) 52 | 53 | #define DIRECTORY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0xF) 54 | 55 | #define EVENT_QUERY_STATE 0x0001 56 | #define EVENT_MODIFY_STATE 0x0002 57 | #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3) 58 | 59 | typedef struct _OBJECT_DIRECTORY_INFORMATION { 60 | UNICODE_STRING Name; 61 | UNICODE_STRING TypeName; 62 | } OBJECT_DIRECTORY_INFORMATION, * POBJECT_DIRECTORY_INFORMATION; 63 | 64 | typedef enum _OBJECT_INFORMATION_CLASS { 65 | ObjectBasicInformation, 66 | ObjectNameInformation, 67 | ObjectTypeInformation, 68 | ObjectAllInformation, 69 | ObjectDataInformation 70 | } OBJECT_INFORMATION_CLASS; 71 | 72 | NTSTATUS NTAPI NtOpenDirectoryObject( 73 | OUT PHANDLE hDirectory, 74 | IN ACCESS_MASK AccessMask, 75 | IN POBJECT_ATTRIBUTES ObjectAttributes 76 | ); 77 | 78 | NTSTATUS 79 | NTAPI 80 | NtQueryDirectoryObject( 81 | IN HANDLE hDirectory, 82 | OUT POBJECT_DIRECTORY_INFORMATION DirectoryEntryBuffer, 83 | IN ULONG DirectoryEntryBufferSize, 84 | IN BOOLEAN bOnlyFirstEntry, 85 | IN BOOLEAN bFirstEntry, 86 | IN PULONG EntryIndex, 87 | OUT PULONG BytesReturned 88 | ); 89 | 90 | VOID 91 | NTAPI 92 | RtlInitUnicodeString( 93 | _Out_ PUNICODE_STRING DestinationString, 94 | _In_opt_z_ __drv_aliasesMem PCWSTR SourceString 95 | ); 96 | 97 | NTSTATUS NTAPI NtOpenSymbolicLinkObject( 98 | _Out_ PHANDLE LinkHandle, 99 | _In_ ACCESS_MASK DesiredAccess, 100 | _In_ POBJECT_ATTRIBUTES ObjectAttributes 101 | ); 102 | 103 | 104 | NTSTATUS NTAPI NtQuerySymbolicLinkObject( 105 | _In_ HANDLE LinkHandle, 106 | _Inout_ PUNICODE_STRING LinkTarget, 107 | _Out_opt_ PULONG ReturnedLength 108 | ); 109 | 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /ObjDir/ObjDir.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/ObjDir/3e41be807c7d3f6e52a01404d50e02ddda048bcb/ObjDir/ObjDir.cpp -------------------------------------------------------------------------------- /ObjDir/ObjDir.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 15.0 23 | {EE0D2993-2EB8-4189-837E-D038DFB9AAF3} 24 | Win32Proj 25 | ObjDir 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | 76 | 77 | true 78 | 79 | 80 | false 81 | 82 | 83 | false 84 | 85 | 86 | 87 | Use 88 | Level3 89 | Disabled 90 | true 91 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 92 | stdcpplatest 93 | pch.h 94 | 95 | 96 | Console 97 | true 98 | 99 | 100 | 101 | 102 | Use 103 | Level3 104 | Disabled 105 | true 106 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 107 | stdcpplatest 108 | pch.h 109 | 110 | 111 | Console 112 | true 113 | 114 | 115 | 116 | 117 | Use 118 | Level3 119 | MaxSpeed 120 | true 121 | true 122 | true 123 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 124 | stdcpplatest 125 | MultiThreaded 126 | pch.h 127 | 128 | 129 | Console 130 | true 131 | true 132 | true 133 | 134 | 135 | 136 | 137 | Use 138 | Level3 139 | MaxSpeed 140 | true 141 | true 142 | true 143 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 144 | stdcpplatest 145 | MultiThreaded 146 | pch.h 147 | 148 | 149 | Console 150 | true 151 | true 152 | true 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | Create 165 | Create 166 | Create 167 | Create 168 | 169 | 170 | 171 | 172 | 173 | -------------------------------------------------------------------------------- /ObjDir/ObjDir.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | -------------------------------------------------------------------------------- /ObjDir/ObjectManager.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "ObjectManager.h" 3 | 4 | #pragma comment(lib, "ntdll.lib") 5 | 6 | using namespace NT; 7 | using namespace std; 8 | 9 | ObjectManager::ObjectManager() : m_Size(1 << 17) { 10 | m_Bytes = std::make_unique(m_Size); 11 | m_Buffer = reinterpret_cast(m_Bytes.get()); 12 | } 13 | 14 | vector> ObjectManager::GetObjects(const CString& root, NTSTATUS& status) { 15 | HANDLE hDirectory; 16 | OBJECT_ATTRIBUTES attr; 17 | UNICODE_STRING name; 18 | RtlInitUnicodeString(&name, root); 19 | InitializeObjectAttributes(&attr, &name, 0, nullptr, nullptr); 20 | vector> list; 21 | status = NtOpenDirectoryObject(&hDirectory, DIRECTORY_QUERY | DIRECTORY_TRAVERSE, &attr); 22 | if(status < 0) 23 | return list; 24 | 25 | ULONG index = 0, bytes; 26 | BOOLEAN firstEntry = TRUE; 27 | int start = 0; 28 | do { 29 | status = NtQueryDirectoryObject(hDirectory, m_Buffer, m_Size, FALSE, firstEntry, &index, &bytes); 30 | if(status < 0) 31 | break; 32 | for(ULONG i = 0; i < index - start; i++) 33 | list.emplace_back(make_pair( 34 | CString(m_Buffer[i].Name.Buffer, m_Buffer[i].Name.Length / sizeof(WCHAR)), 35 | CString(m_Buffer[i].TypeName.Buffer, m_Buffer[i].TypeName.Length / sizeof(WCHAR)))); 36 | if(status == 0) 37 | break; 38 | // more entries (STATUS_NEED_MORE_ENTRIES) 39 | start = index; 40 | if(firstEntry) 41 | firstEntry = FALSE; 42 | } while(true); 43 | CloseHandle(hDirectory); 44 | return list; 45 | } 46 | 47 | CString ObjectManager::GetSymbolicLinkFromName(const CString& directory, const CString& name) const { 48 | HANDLE hLink; 49 | OBJECT_ATTRIBUTES attr, attrDir; 50 | UNICODE_STRING str, strDir; 51 | HANDLE hRoot; 52 | RtlInitUnicodeString(&strDir, directory); 53 | InitializeObjectAttributes(&attrDir, &strDir, 0, nullptr, nullptr); 54 | NtOpenDirectoryObject(&hRoot, GENERIC_READ, &attrDir); 55 | ATLASSERT(hRoot != nullptr); 56 | RtlInitUnicodeString(&str, name); 57 | InitializeObjectAttributes(&attr, &str, 0, hRoot, nullptr); 58 | NtOpenSymbolicLinkObject(&hLink, GENERIC_READ, &attr); 59 | WCHAR buffer[512] = { 0 }; 60 | UNICODE_STRING target; 61 | RtlInitUnicodeString(&target, buffer); 62 | target.MaximumLength = sizeof(buffer); 63 | ULONG len; 64 | NtQuerySymbolicLinkObject(hLink, &target, &len); 65 | CloseHandle(hLink); 66 | CloseHandle(hRoot); 67 | return CString(target.Buffer, target.Length / sizeof(WCHAR)); 68 | } 69 | 70 | -------------------------------------------------------------------------------- /ObjDir/ObjectManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "NtDll.h" 4 | 5 | class ObjectManager { 6 | public: 7 | ObjectManager(); 8 | 9 | std::vector> GetObjects(const CString& root, NTSTATUS&); 10 | CString GetSymbolicLinkFromName(const CString& directory, const CString& name) const; 11 | 12 | HANDLE OpenObject(const CString& name, ULONG access, const CString& type, NT::NTSTATUS* pStatus = nullptr); 13 | 14 | private: 15 | unsigned m_Size; 16 | std::unique_ptr m_Bytes; 17 | NT::POBJECT_DIRECTORY_INFORMATION m_Buffer; 18 | }; 19 | 20 | -------------------------------------------------------------------------------- /ObjDir/pch.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/ObjDir/3e41be807c7d3f6e52a01404d50e02ddda048bcb/ObjDir/pch.cpp -------------------------------------------------------------------------------- /ObjDir/pch.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/ObjDir/3e41be807c7d3f6e52a01404d50e02ddda048bcb/ObjDir/pch.h -------------------------------------------------------------------------------- /ObjDir/targetver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zodiacon/ObjDir/3e41be807c7d3f6e52a01404d50e02ddda048bcb/ObjDir/targetver.h -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ObjDir 2 | 3 | Simple command line version of Sysinternals WinObj. Currently just lists object names and types given an object manager directory. 4 | 5 | --------------------------------------------------------------------------------