Skip to content

ks.h #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft

ks.h #98

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions TH-NETII Windows API.sln
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "THNETII.WinApi.Headers.WinS
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "THNETII.WinApi.Headers.DevPropDef", "src\THNETII.WinApi.Headers.DevPropDef\THNETII.WinApi.Headers.DevPropDef.csproj", "{E4A4DA91-3696-40A6-9834-E5FAACEF682E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "THNETII.WinApi.Headers.Ks", "src\THNETII.WinApi.Headers.Ks\THNETII.WinApi.Headers.Ks.csproj", "{27DD8683-2AF2-4753-BF69-2AD2C5B9790E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "THNETII.WinApi.Headers.ApDevPKey", "src\THNETII.WinApi.Headers.ApDevPKey\THNETII.WinApi.Headers.ApDevPKey.csproj", "{C0B32983-2879-4DAD-B834-8A40570A35CA}"
EndProject
Global
Expand Down Expand Up @@ -489,6 +491,18 @@ Global
{E4A4DA91-3696-40A6-9834-E5FAACEF682E}.Release|x64.Build.0 = Release|Any CPU
{E4A4DA91-3696-40A6-9834-E5FAACEF682E}.Release|x86.ActiveCfg = Release|Any CPU
{E4A4DA91-3696-40A6-9834-E5FAACEF682E}.Release|x86.Build.0 = Release|Any CPU
{27DD8683-2AF2-4753-BF69-2AD2C5B9790E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{27DD8683-2AF2-4753-BF69-2AD2C5B9790E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{27DD8683-2AF2-4753-BF69-2AD2C5B9790E}.Debug|x64.ActiveCfg = Debug|Any CPU
{27DD8683-2AF2-4753-BF69-2AD2C5B9790E}.Debug|x64.Build.0 = Debug|Any CPU
{27DD8683-2AF2-4753-BF69-2AD2C5B9790E}.Debug|x86.ActiveCfg = Debug|Any CPU
{27DD8683-2AF2-4753-BF69-2AD2C5B9790E}.Debug|x86.Build.0 = Debug|Any CPU
{27DD8683-2AF2-4753-BF69-2AD2C5B9790E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{27DD8683-2AF2-4753-BF69-2AD2C5B9790E}.Release|Any CPU.Build.0 = Release|Any CPU
{27DD8683-2AF2-4753-BF69-2AD2C5B9790E}.Release|x64.ActiveCfg = Release|Any CPU
{27DD8683-2AF2-4753-BF69-2AD2C5B9790E}.Release|x64.Build.0 = Release|Any CPU
{27DD8683-2AF2-4753-BF69-2AD2C5B9790E}.Release|x86.ActiveCfg = Release|Any CPU
{27DD8683-2AF2-4753-BF69-2AD2C5B9790E}.Release|x86.Build.0 = Release|Any CPU
{C0B32983-2879-4DAD-B834-8A40570A35CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C0B32983-2879-4DAD-B834-8A40570A35CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C0B32983-2879-4DAD-B834-8A40570A35CA}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -539,6 +553,7 @@ Global
{25A891EB-9BF0-45D1-89EE-B24E80DE259E} = {9689DB3E-1ED7-478C-AC14-C734B0397619}
{56348771-2C99-4C0A-B63A-C7F0736621DA} = {9689DB3E-1ED7-478C-AC14-C734B0397619}
{E4A4DA91-3696-40A6-9834-E5FAACEF682E} = {9689DB3E-1ED7-478C-AC14-C734B0397619}
{27DD8683-2AF2-4753-BF69-2AD2C5B9790E} = {9689DB3E-1ED7-478C-AC14-C734B0397619}
{C0B32983-2879-4DAD-B834-8A40570A35CA} = {9689DB3E-1ED7-478C-AC14-C734B0397619}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Expand Down
10 changes: 7 additions & 3 deletions src-native-c/THNETII.WinApi.Sample.Native/main.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#include <Windows.h>
#include <apdevpkey.h>
#include <ks.h>
#include <ksmedia.h>
#include <bdatypes.h>
#include <bdamedia.h>
#include <atsmedia.h>

int main(int argc, char* argv[])
{
DEVPROPTYPE instance;
KSRESET instance;
const int size = sizeof(instance);
const int value = DEVPROP_TYPE_EMPTY;
const int value = IOCTL_KS_PROPERTY;

const void* ptr = NULL;

Expand Down
14 changes: 14 additions & 0 deletions src/THNETII.WinApi.Headers.Ks/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.

using System.Diagnostics.CodeAnalysis;

[assembly: SuppressMessage("Documentation", "CS1591: Missing XML comment for publicly visible type or member")]
[assembly: SuppressMessage("Design", "CA1028: Enum Storage should be Int32")]
[assembly: SuppressMessage("Naming", "CA1714: Flags enums should have plural names")]
[assembly: SuppressMessage("Naming", "CA1707: Identifiers should not contain underscores")]
[assembly: SuppressMessage("Design", "CA1051: Do not declare visible instance fields")]
[assembly: SuppressMessage("Performance", "CA1815: Override equals and operator equals on value types")]
[assembly: SuppressMessage("Naming", "CA1712: Do not prefix enum values with type name")]
71 changes: 71 additions & 0 deletions src/THNETII.WinApi.Headers.Ks/KSIDENTIFIER.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using System;
using System.Runtime.InteropServices;

using THNETII.WinApi.Native.NTStatus;

namespace THNETII.WinApi.Native.Ks
{
using static NTStatusConstants;
using static KsConstants;

// C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\shared\ks.h, line 106
/// <summary>
/// The <see cref="KSIDENTIFIER"/> structure specifies a <see cref="Guid"/> that uniquely identifies a related set of <see cref="Guid"/>s, and an index value to refer to a specific member within that set.
/// </summary>
/// <remarks>
/// <para>The <strong>KSEVENT</strong>, <strong>KSMETHOD</strong>, and <strong>KSPROPERTY</strong> structures are aliases for the <see cref="KSIDENTIFIER"/> structure. As such, their definitions are identical.</para>
/// <para>The use of an ID within the set allows one to perform a single large compare for a set identifier, then smaller quick compares (for example, by using a switch statement for identifiers within a set). For example, a <em>property set</em> is referred to by a unique GUID identifier, and properties within that set are referred to by the short ID.</para>
/// <para><em>Method</em>, <em>Event</em>, <em>Interface</em>, and <em>medium sets</em> can be thought of as "classes" of sets.</para>
/// <para>The size of the output buffer passed determines what data is returned from a <see cref="KSPROPERTY_TYPE_BASICSUPPORT"/> request. If the output buffer is the size of a <see cref="int"/>, only the access flags are returned. If the output buffer is the size of the <see cref="KSPROPERTY_DESCRIPTION"/> structure, the structure is filled with the access flags, the inclusive size of the entire values information, the property value type information, and the number of member lists that correspond to the structure.</para>
/// <para>For a <see cref="KSPROPERTY_TYPE_RELATIONS"/> request, data returned also depends on the size of the output buffer. If the output buffer size is zero, the size required to return the related properties is returned in <see cref="KSPROPERTY_TYPE_RELATIONS.BytesReturned"/> with a warning status of <see cref="STATUS_BUFFER_OVERFLOW"/>. If the buffer is the size of a <see cref="KSMULTIPLE_ITEM"/> structure, both the byte size and count of relations is returned. Otherwise, the buffer is expected to be long enough to return the <see cref="KSMULTIPLE_ITEM"/> structure and all related property identifiers, which is returned as a list of <see cref="KSIDENTIFIER"/> structures.</para>
/// <para><see cref="KSPROPERTY_TYPE_SERIALIZESET"/> and <see cref="KSPROPERTY_TYPE_UNSERIALIZESET"/> requests allow interaction with multiple properties with a single call from the client. If the kernel streaming handler is being used to process property requests, these are broken up into multiple calls by the <see cref="KsPropertyHandler"/> function. When using this handler, the property set definition controls which properties are to be serialized.</para>
/// <para>For serialization requests, the <see cref="KSPROPERTY_ITEM.SerializedSize"/> member of the relevant <see cref="KSPROPERTY_ITEM"/> structure is checked for a nonzero value that indicates the size, in bytes, of the property. If the value of the <see cref="KSPROPERTY_ITEM.SerializedSize"/> member is <c>1</c>, it is unknown and must be queried (all unknown properties begin with a <see cref="KSMULTIPLE_ITEM"/> structure that can be queried separately). To query for the total size a serialization would take, the client passes a zero length buffer in the call to <see cref="DeviceIoControl"/>. <see cref="KSMULTIPLE_ITEM.BytesReturned"/> then returns the size, in bytes, that the buffer must be to serialize the set, and a warning status of <see cref="STATUS_BUFFER_OVERFLOW"/>. A buffer allocated that size can then be filled with the serialized data.</para>
/// <para>The format of the serialization buffer is a <see cref="KSPROPERTY_SERIALHDR"/>, followed by serialized properties. Each property that follows contains a header (<see cref="KSPROPERTY_SERIAL"/>), followed by the property data, with the start of each property on <see cref="FILE_LONG_ALIGNMENT"/>. Note that the serial header structure is defined to be on <see cref="FILE_LONG_ALIGNMENT"/>.</para>
/// <para><see cref="KSPROPERTY_TYPE_SERIALIZERAW"/> and <see cref="KSPROPERTY_TYPE_UNSERIALIZERAW"/> are supported if a property item handler exists. The <see cref="KsPropertyHandler"/> function invokes the handler provided by the minidriver. The buffer size required for serialization can also be queried by passing a zero-length buffer to a serialize raw request. Because handlers are attached to property items rather than the property set, a specific item within the property set must be specified in the <em>Property</em> parameter. This handler may deal with multiple properties within the set.</para>
/// <para>Microsoft provides several system-defined property set GUIDs. Minidrivers specify one of these GUIDs in the <see cref="Set"/> member. Kernel streaming property sets typically begin with either a <strong>KSPROPSETID</strong> or a <strong>PROPSETID</strong> prefix. Kernel streaming property sets are defined in <em>ks.h</em>, <em>ksmedia.h</em>, <em>bdamedia.h</em>, and possibly other header files.</para>
/// <para>For more information about kernel streaming properties, see <a href="https://docs.microsoft.com/windows-hardware/drivers/stream/ks-properties--events--and-methods">KS Properties, Events, and Methods</a>.</para>
/// <para>A client can use the <see cref="IOCTL_KS_METHOD"/> request along with the <see cref="KSIDENTIFIER"/> structure to execute methods on a kernel streaming object that the minidriver handles. For more information, see <a href="https://docs.microsoft.com/windows-hardware/drivers/stream/ks-methods">KS Methods</a>.</para>
/// <para>The <see cref="KSPIN_MEDIUM"/> structure identifies a medium, with a unique medium GUID and instance identifier, which is generated in a bus-specific manner. There is a reserved identifier value <see cref="KSMEDIUM_TYPE_ANYINSTANCE"/> that is used when bus instances are not of concern. For example, the <see cref="KSMEDIUMSETID_Standard"/> refers to the system bus, of which there should only be one. So this instance identifier is always used just as a convenience.</para>
/// <para>A pin may support multiple mediums and interfaces on those mediums. The way in which a pin is described implies that the list of interfaces is supported on all mediums enumerated for a pin. If there is a case in which this is not true, another pin may be used to describe each subset of interfaces for the specific mediums.</para>
/// <para>The medium is also cached by kernel streaming to speed up the search for a possible connection.</para>
/// <para>An example of use of this structure can be found in a tuner sample, in which <see cref="KSPIN_MEDIUM"/> represents unique connections between tuners, crossbars, and other tuner components.</para>
/// <para>The <see cref="Flags"/> member can contain different values based on the type of signal degradation that the client employs. See <a href="https://docs.microsoft.com/windows-hardware/drivers/stream/quality-management">Quality Management</a> for more details on different strategies for solving QM problems by reducing signal quality.</para>
/// <para>Because <see cref="Flags"/> contains in integer value, multiple Skip requests may be needed to remedy the QM issue.</para>
/// <para>Microsoft Docs page: <a href="https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/ks/ns-ks-ksidentifier">KSIDENTIFIER structure</a></para>
/// </remarks>
[StructLayout(LayoutKind.Explicit)]
public struct KSIDENTIFIER
{
[FieldOffset(0)]
internal KSIDENTIFIER_CONTENT Content;

public Guid Set
{
get => Content.Set;
set => Content.Set = value;
}

public int Id
{
get => Content.Id;
set => Content.Id = value;
}

public int Flags
{
get => Content.Flags;
set => Content.Flags = value;
}

[FieldOffset(0)]
public long Alignment;
}

[StructLayout(LayoutKind.Sequential)]
internal struct KSIDENTIFIER_CONTENT
{
public Guid Set;
public int Id;
public int Flags;
}
}
31 changes: 31 additions & 0 deletions src/THNETII.WinApi.Headers.Ks/KSPRIORITY.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Runtime.InteropServices;

namespace THNETII.WinApi.Native.Ks
{
using static KSPRIORITY_CLASS;

// C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\shared\ks.h, line 101
/// <summary>
/// The <see cref="KSPRIORITY"/> structure is used to specify priority and is used with the <see cref="KSPROPERTY_CONNECTION_PRIORITY"/> property.
/// </summary>
/// <remarks>
/// <para>The <see cref="PrioritySubClass"/> member allows a client to set exclusive use of resources consumed by a pin and also to prioritize the use of those resources by the client's pins within that exclusive class. The initial priority of a pin is set by the connection request typically performed through <see cref="KsCreatePin"/>, and is usually <see cref="KSPRIORITY_NORMAL"/>, with a subclass priority of <c>1</c>. A pin uses these priorities as parameters when allocating shared resources from any component managing resources. Resource allocation occurs when formats are set on pins.</para>
/// <para>If the removal of resources by a higher priority client causes the filter pin to fail, the client must be notified through the <see cref="KSEVENT_CONNECTION_PRIORITY"/> event (assuming that the client had registered for event notification of this type).</para>
/// <para>Microsoft Docs page: <a href="https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/ks/ns-ks-kspriority">KSPRIORITY structure</a></para>
/// </remarks>
/// <seealso cref="KSPROPERTY_CONNECTION_PRIORITY"/>
/// <seealso cref="KsCreatePin"/>
[StructLayout(LayoutKind.Sequential)]
public struct KSPRIORITY
{
/// <summary>
/// Specifies a number ranging from 1 to 0xFFFFFFFF, where 1 is least priority and 0xFFFFFFFF is the highest priority. Zero is reserved for future use. When setting a class value, 0xFFFFFFFF is used to indicate exclusive access to the resources consumed by the pin.
/// </summary>
[MarshalAs(UnmanagedType.U4)]
public KSPRIORITY_CLASS PriorityClass;
/// <summary>
/// Specifies a number ranging from 1 to 0xFFFFFFFF, where 1 is the least priority within the class and 0xFFFFFFFF is the most priority. Zero is reserved for future use.
/// </summary>
public int PrioritySubClass;
}
}
15 changes: 15 additions & 0 deletions src/THNETII.WinApi.Headers.Ks/KSPRIORITY_CLASS.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace THNETII.WinApi.Native.Ks
{
// C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\shared\ks.h, line 96
public enum KSPRIORITY_CLASS
{
/// <summary>Specifies the lowest priority. </summary>
KSPRIORITY_LOW = KsConstants.KSPRIORITY_LOW,
/// <summary>Specifies normal priority. </summary>
KSPRIORITY_NORMAL = KsConstants.KSPRIORITY_NORMAL,
/// <summary>Specifies an elevated priority. </summary>
KSPRIORITY_HIGH = KsConstants.KSPRIORITY_HIGH,
/// <summary>Specifies the highest priority, which implies exclusive access to resources. </summary>
KSPRIORITY_EXCLUSIVE = KsConstants.KSPRIORITY_EXCLUSIVE,
}
}
12 changes: 12 additions & 0 deletions src/THNETII.WinApi.Headers.Ks/KSRESET.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace THNETII.WinApi.Native.Ks
{
// C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\shared\ks.h, line 84
/// <remarks>
/// <para>Microsoft Docs page: <a href="https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/ks/ne-ks-ksreset">KSRESET enumeration</a></para>
/// </remarks>
public enum KSRESET
{
KSRESET_BEGIN,
KSRESET_END
}
}
21 changes: 21 additions & 0 deletions src/THNETII.WinApi.Headers.Ks/KSSTATE.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace THNETII.WinApi.Native.Ks
{
// C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\shared\ks.h, line 89
/// <summary>
/// The <see cref="KSSTATE"/> enumeration lists possible states of a kernel streaming object.
/// </summary>
/// <remarks>
/// <para>Microsoft Docs page: <a href="https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/ks/ne-ks-ksstate">KSSTATE enumeration</a></para>
/// </remarks>
public enum KSSTATE
{
/// <summary>Indicates that the object is in minimum resource consumption mode.</summary>
KSSTATE_STOP,
/// <summary>Indicates that the object is acquiring resources.</summary>
KSSTATE_ACQUIRE,
/// <summary>Indicates that the object is preparing to make instant transition to Run state.</summary>
KSSTATE_PAUSE,
/// <summary>Indicates that the object is actively streaming.</summary>
KSSTATE_RUN
}
}
Loading