Win32 API 日本語リファレンス
ホームNetworking.WindowsWebServices › WS_CHANNEL_DECODER

WS_CHANNEL_DECODER

構造体
サイズx64: 56 バイト / x86: 28 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
createContextvoid*8/4+0+0WS_CREATE_DECODER_CALLBACK に渡されるコンテキストです。
createDecoderCallbackWS_CREATE_DECODER_CALLBACK8/4+8+4デコーダーのインスタンスを作成する WS_CREATE_DECODER_CALLBACK コールバックです。
decoderGetContentTypeCallbackWS_DECODER_GET_CONTENT_TYPE_CALLBACK8/4+16+8メッセージのコンテンツ タイプを取得するために呼び出される WS_DECODER_GET_CONTENT_TYPE_CALLBACK コールバックです。
decoderStartCallbackWS_DECODER_START_CALLBACK8/4+24+12メッセージのデコード開始時に呼び出される WS_DECODER_START_CALLBACK コールバックです。
decoderDecodeCallbackWS_DECODER_DECODE_CALLBACK8/4+32+16メッセージをデコードするために呼び出される WS_DECODER_DECODE_CALLBACK コールバックです。
decoderEndCallbackWS_DECODER_END_CALLBACK8/4+40+20メッセージのデコード終了時に呼び出される WS_DECODER_END_CALLBACK コールバックです。
freeDecoderCallbackWS_FREE_DECODER_CALLBACK8/4+48+24デコーダーのインスタンスを解放する WS_FREE_DECODER_CALLBACK コールバックです。

公式ドキュメント

受信したメッセージのコンテンツ タイプおよびエンコードされたバイト列を変換できる 一連のコールバックを指定するために使用される構造体です。

解説(Remarks)

WS_CHANNEL では、メッセージのエンコードされたバイト列を受信した時点で、 展開、変更、またはその他の変換を行いたい場合があります。WS_CHANNEL_DECODER は、 これらの変更を割り込んで実行するために必要なフックを提供します。

チャネルを作成するときは、適切な関数を指定して WS_CHANNEL_PROPERTY_DECODER を 設定します。

指定されたコールバックは、次の文法に従って呼び出されます。


decodercalls := create decoderloop* free
decoderloop  := decodestart
             |  decodestart getcontenttype
             |  decodestart getcontenttype (decode*)
             |  decodestart getcontenttype (decode*) decodeend

チャネルまたはデコーダーがメッセージの読み取り中にエラーを検出した場合、デコーダーは メッセージの完全なデコード シーケンスを認識できないことがあります。デコーダーは、呼び出された コールバックに基づいて適切な状態へ遷移できるように準備しておく必要があります。

WS_TCP_CHANNEL_BINDINGWS_CHANNEL_TYPE_SESSION と共に使用する場合、コンテンツ タイプは チャネルに対して固定されます。この場合、WS_DECODER_GET_CONTENT_TYPE_CALLBACK は、 すべてのメッセージのコンテンツ タイプに対してまったく同じ値を返さなければなりません。

WS_DECODER_END_CALLBACK は、WS_DECODER_DECODE_CALLBACK が 0 バイトを返すまで呼び出されません。

チャネルはデコーダー インスタンスの使用を終えると、 WS_FREE_DECODER_CALLBACK を介してそれを解放します。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での定義

#include <windows.h>

// WS_CHANNEL_DECODER  (x64 56 / x86 28 バイト)
typedef struct WS_CHANNEL_DECODER {
    void* createContext;
    WS_CREATE_DECODER_CALLBACK createDecoderCallback;
    WS_DECODER_GET_CONTENT_TYPE_CALLBACK decoderGetContentTypeCallback;
    WS_DECODER_START_CALLBACK decoderStartCallback;
    WS_DECODER_DECODE_CALLBACK decoderDecodeCallback;
    WS_DECODER_END_CALLBACK decoderEndCallback;
    WS_FREE_DECODER_CALLBACK freeDecoderCallback;
} WS_CHANNEL_DECODER;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WS_CHANNEL_DECODER
{
    public IntPtr createContext;
    public IntPtr createDecoderCallback;
    public IntPtr decoderGetContentTypeCallback;
    public IntPtr decoderStartCallback;
    public IntPtr decoderDecodeCallback;
    public IntPtr decoderEndCallback;
    public IntPtr freeDecoderCallback;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WS_CHANNEL_DECODER
    Public createContext As IntPtr
    Public createDecoderCallback As IntPtr
    Public decoderGetContentTypeCallback As IntPtr
    Public decoderStartCallback As IntPtr
    Public decoderDecodeCallback As IntPtr
    Public decoderEndCallback As IntPtr
    Public freeDecoderCallback As IntPtr
End Structure
import ctypes
from ctypes import wintypes

class WS_CHANNEL_DECODER(ctypes.Structure):
    _fields_ = [
        ("createContext", ctypes.c_void_p),
        ("createDecoderCallback", ctypes.c_void_p),
        ("decoderGetContentTypeCallback", ctypes.c_void_p),
        ("decoderStartCallback", ctypes.c_void_p),
        ("decoderDecodeCallback", ctypes.c_void_p),
        ("decoderEndCallback", ctypes.c_void_p),
        ("freeDecoderCallback", ctypes.c_void_p),
    ]
#[repr(C)]
pub struct WS_CHANNEL_DECODER {
    pub createContext: *mut core::ffi::c_void,
    pub createDecoderCallback: *mut core::ffi::c_void,
    pub decoderGetContentTypeCallback: *mut core::ffi::c_void,
    pub decoderStartCallback: *mut core::ffi::c_void,
    pub decoderDecodeCallback: *mut core::ffi::c_void,
    pub decoderEndCallback: *mut core::ffi::c_void,
    pub freeDecoderCallback: *mut core::ffi::c_void,
}
import "golang.org/x/sys/windows"

type WS_CHANNEL_DECODER struct {
	createContext uintptr
	createDecoderCallback uintptr
	decoderGetContentTypeCallback uintptr
	decoderStartCallback uintptr
	decoderDecodeCallback uintptr
	decoderEndCallback uintptr
	freeDecoderCallback uintptr
}
type
  WS_CHANNEL_DECODER = record
    createContext: Pointer;
    createDecoderCallback: Pointer;
    decoderGetContentTypeCallback: Pointer;
    decoderStartCallback: Pointer;
    decoderDecodeCallback: Pointer;
    decoderEndCallback: Pointer;
    freeDecoderCallback: Pointer;
  end;
const WS_CHANNEL_DECODER = extern struct {
    createContext: ?*anyopaque,
    createDecoderCallback: ?*anyopaque,
    decoderGetContentTypeCallback: ?*anyopaque,
    decoderStartCallback: ?*anyopaque,
    decoderDecodeCallback: ?*anyopaque,
    decoderEndCallback: ?*anyopaque,
    freeDecoderCallback: ?*anyopaque,
};
type
  WS_CHANNEL_DECODER {.bycopy.} = object
    createContext: pointer
    createDecoderCallback: pointer
    decoderGetContentTypeCallback: pointer
    decoderStartCallback: pointer
    decoderDecodeCallback: pointer
    decoderEndCallback: pointer
    freeDecoderCallback: pointer
struct WS_CHANNEL_DECODER
{
    void* createContext;
    void* createDecoderCallback;
    void* decoderGetContentTypeCallback;
    void* decoderStartCallback;
    void* decoderDecodeCallback;
    void* decoderEndCallback;
    void* freeDecoderCallback;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; WS_CHANNEL_DECODER サイズ: 28 バイト(x86)
dim st, 7    ; 4byte整数×7(構造体サイズ 28 / 4 切り上げ)
; createContext : void* (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; createDecoderCallback : WS_CREATE_DECODER_CALLBACK (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; decoderGetContentTypeCallback : WS_DECODER_GET_CONTENT_TYPE_CALLBACK (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; decoderStartCallback : WS_DECODER_START_CALLBACK (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; decoderDecodeCallback : WS_DECODER_DECODE_CALLBACK (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; decoderEndCallback : WS_DECODER_END_CALLBACK (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; freeDecoderCallback : WS_FREE_DECODER_CALLBACK (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; WS_CHANNEL_DECODER サイズ: 56 バイト(x64)
dim st, 14    ; 4byte整数×14(構造体サイズ 56 / 4 切り上げ)
; createContext : void* (+0, 8byte)  qpoke st,0,値 / qpeek(st,0)  ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; createDecoderCallback : WS_CREATE_DECODER_CALLBACK (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; decoderGetContentTypeCallback : WS_DECODER_GET_CONTENT_TYPE_CALLBACK (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; decoderStartCallback : WS_DECODER_START_CALLBACK (+24, 8byte)  qpoke st,24,値 / qpeek(st,24)  ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; decoderDecodeCallback : WS_DECODER_DECODE_CALLBACK (+32, 8byte)  qpoke st,32,値 / qpeek(st,32)  ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; decoderEndCallback : WS_DECODER_END_CALLBACK (+40, 8byte)  qpoke st,40,値 / qpeek(st,40)  ※IronHSPのみ。3.7/3.8は lpoke st,40,下位 : lpoke st,44,上位
; freeDecoderCallback : WS_FREE_DECODER_CALLBACK (+48, 8byte)  qpoke st,48,値 / qpeek(st,48)  ※IronHSPのみ。3.7/3.8は lpoke st,48,下位 : lpoke st,52,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global WS_CHANNEL_DECODER
    #field intptr createContext
    #field intptr createDecoderCallback
    #field intptr decoderGetContentTypeCallback
    #field intptr decoderStartCallback
    #field intptr decoderDecodeCallback
    #field intptr decoderEndCallback
    #field intptr freeDecoderCallback
#endstruct

stdim st, WS_CHANNEL_DECODER        ; NSTRUCT 変数を確保