Skip to content

Commit

Permalink
Implement dump for ApiSetSchema v2/v4/v6.
Browse files Browse the repository at this point in the history
  • Loading branch information
ww898 committed Sep 2, 2019
1 parent 4620f0e commit d6363d5
Show file tree
Hide file tree
Showing 15 changed files with 3,042 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.vs/
obj/
bin/
_ReSharper.Caches/
*.user
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# ApiSetSchema v2/v4/v6 dumper

|ApiSetSchema version|OS|
|:-:|:-|
|[v2](data/v2.txt)|Windows 8, Windows Server 2012|
|[v4](data/v4.txt)|Windows 8.1, Windows Server 2012 R2|
|[v6](data/v6.txt)|Windows 10, Windows Server 2016|
Binary file added data/apisetschema.v2.dll
Binary file not shown.
Binary file added data/apisetschema.v4.dll
Binary file not shown.
Binary file added data/apisetschema.v6.dll
Binary file not shown.
Binary file added data/v2.apiset
Binary file not shown.
358 changes: 358 additions & 0 deletions data/v2.txt

Large diffs are not rendered by default.

Binary file added data/v4.apiset
Binary file not shown.
506 changes: 506 additions & 0 deletions data/v4.txt

Large diffs are not rendered by default.

Binary file added data/v6.apiset
Binary file not shown.
1,569 changes: 1,569 additions & 0 deletions data/v6.txt

Large diffs are not rendered by default.

156 changes: 156 additions & 0 deletions include/ww898/api_set_schema.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
/*
MIT License
Copyright (c) 2019 Mikhail Pilin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

#pragma once

#include <minwindef.h>

// References:
// https://blog.quarkslab.com/runtime-dll-name-resolution-apisetschema-part-i.html
// https://blog.quarkslab.com/runtime-dll-name-resolution-apisetschema-part-ii.html
// https://www.geoffchappell.com/studies/windows/win32/apisetschema/index.htm

#define API_SET_FLAG_SEALED 0x01
#define API_SET_FLAG_EXT 0x02

///////////////////////////////////////////////////////////////////////////////
// ApiSet v2

struct API_SET_VALUE_ENTRY_REDIRECTION_V2
{
ULONG NameOffset;
USHORT NameLength;
ULONG ValueOffset;
USHORT ValueLength;
};

struct API_SET_VALUE_ENTRY_V2
{
ULONG NumberOfRedirections;
API_SET_VALUE_ENTRY_REDIRECTION_V2 Redirections[ANYSIZE_ARRAY];
};

struct API_SET_NAMESPACE_ENTRY_V2
{
ULONG NameOffset;
ULONG NameLength;
ULONG DataOffset; // API_SET_VALUE_ENTRY_V2 offset
};

struct API_SET_NAMESPACE_V2
{
ULONG Version;
ULONG Count;
API_SET_NAMESPACE_ENTRY_V2 Array[ANYSIZE_ARRAY];
};

///////////////////////////////////////////////////////////////////////////////
// ApiSet v4

struct API_SET_VALUE_ENTRY_REDIRECTION_V4
{
ULONG Flags;
ULONG NameOffset;
ULONG NameLength;
ULONG ValueOffset;
ULONG ValueLength;
};

struct API_SET_VALUE_ENTRY_V4
{
ULONG Flags;
ULONG NumberOfRedirections;
API_SET_VALUE_ENTRY_REDIRECTION_V4 Redirections[ANYSIZE_ARRAY];
};

struct API_SET_NAMESPACE_ENTRY_V4
{
ULONG Flags;
ULONG NameOffset;
ULONG NameLength;
ULONG AliasOffset;
ULONG AliasLength;
ULONG DataOffset; // API_SET_VALUE_ENTRY_V4 offset
};

struct API_SET_NAMESPACE_V4
{
ULONG Version;
ULONG Size;
ULONG Flags;
ULONG Count;
API_SET_NAMESPACE_ENTRY_V4 Array[ANYSIZE_ARRAY];
};

///////////////////////////////////////////////////////////////////////////////
// ApiSet v6

struct API_SET_HASH_ENTRY_V6
{
ULONG Hash;
ULONG Index;
};

struct API_SET_VALUE_ENTRY_V6
{
ULONG Flags;
ULONG NameOffset;
ULONG NameLength;
ULONG ValueOffset;
ULONG ValueLength;
};

struct API_SET_NAMESPACE_ENTRY_V6
{
ULONG Flags;
ULONG NameOffset;
ULONG NameLength;
ULONG HashedLength;
ULONG ValueOffset; // API_SET_VALUE_ENTRY_V6 offset
ULONG ValueCount;
};

struct API_SET_NAMESPACE_V6
{
ULONG Version; // Should be 6
ULONG Size;
ULONG Flags;
ULONG Count;
ULONG EntryOffset; // API_SET_NAMESPACE_ENTRY_V6 offset
ULONG HashOffset; // API_SET_HASH_ENTRY_V6 offset
ULONG HashFactor;
};

///////////////////////////////////////////////////////////////////////////////

struct API_SET_NAMESPACE
{
union
{
ULONG Version;
API_SET_NAMESPACE_V2 V2;
API_SET_NAMESPACE_V4 V4;
API_SET_NAMESPACE_V6 V6;
};
};
31 changes: 31 additions & 0 deletions solution.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27428.2043
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test\test.vcxproj", "{CDD07939-D363-46F0-938C-89F6B88DA0B1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CDD07939-D363-46F0-938C-89F6B88DA0B1}.Debug|x64.ActiveCfg = Debug|x64
{CDD07939-D363-46F0-938C-89F6B88DA0B1}.Debug|x64.Build.0 = Debug|x64
{CDD07939-D363-46F0-938C-89F6B88DA0B1}.Debug|x86.ActiveCfg = Debug|Win32
{CDD07939-D363-46F0-938C-89F6B88DA0B1}.Debug|x86.Build.0 = Debug|Win32
{CDD07939-D363-46F0-938C-89F6B88DA0B1}.Release|x64.ActiveCfg = Release|x64
{CDD07939-D363-46F0-938C-89F6B88DA0B1}.Release|x64.Build.0 = Release|x64
{CDD07939-D363-46F0-938C-89F6B88DA0B1}.Release|x86.ActiveCfg = Release|Win32
{CDD07939-D363-46F0-938C-89F6B88DA0B1}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E2140CCD-70E6-4E26-9863-BCED378778A0}
EndGlobalSection
EndGlobal
Loading

0 comments on commit d6363d5

Please sign in to comment.