Share via


ESCAPE_GET_CAPABILITIES Code Example (Compact 7)

3/12/2014

The ESCAPE_GET_CAPABILITIES escape sequence allows the RDC client to query the capabilities of the hardware. Currently, only the RemoteFX hardware tile size is used. Some bytes are reserved for future use. The following code example shows the structure declaration that is required for the escape_get_capabilities function.

Important

For readability, the following code examples do not contain security or error handling. Do not use the following code examples in a production environment.

#define DRAW_ESCAPE_CODE_BEGIN         0x20000
#define ESCAPE_MAGIN_IN                0xBEEFABCE
#define ESCAPE_CODE_BEGIN              (DRAW_ESCAPE_CODE_BEGIN+0x100)

struct _hdr
{
    ULONG magic; 
// const: 0xBEEFABCE
    ULONG size;
    ULONG code;
};

#define ESCAPE_GET_CAPABILITIES             (ESCAPE_CODE_BEGIN+3)
struct esc_get_capabilities_in
{
    struct _hdr hdr;
};
struct esc_get_capabilities_out
{
   ULONG tile_size;
   ULONG reserved[2];
};

The following code example shows how ESCAPE_GET_CAPABILITIES should be implemented in a display driver. The function validates the escape parameters that the escape header received from the RDC client to ensure that the input buffer is from a trusted source.

BOOL esc_get_capabilities(
                     SURFOBJ*    pso,
                     ULONG       iEsc,
                     ULONG       cjIn,
                     PVOID       pvIn,
                     ULONG       cjOut,
                     PVOID       pvOut
                     )
{
    struct esc_get_capabilities_in*  p_in  = NULL;
    struct esc_get_capabilities_out* p_out = NULL;
    BOOL status  = FALSE;
    int tileSize  = 64;
    do {

        if (!pso)
        {
            break;
        }
        if (
            (!pvIn)
            ||
            (cjIn != sizeof(*p_in)))
        {
            break;
        }
        p_in = (struct esc_get_capabilities_in*)pvIn;

        if (
            (p_in->hdr.code  != iEsc)
            ||
            (p_in->hdr.magic != ESCAPE_MAGIN_IN)
            ||
            (p_in->hdr.size != sizeof(*p_in)))
        {
            break;
        }

        if (
            (!pvOut)
            ||
            (cjOut != sizeof(*p_out)))
        {
            break;
        }
        p_out = (struct esc_get_capabilities_out*)pvOut;
        p_out->tile_size =  tileSize; 
        //setting tile size to 64
        status = TRUE;

    } while (0);
    return status;
}

The pvIn parameter is a pointer to the input data for this escape call and consists of escape header information, which is defined in the esc_get_capabilities_in structure. The pvOut parameter is a pointer to the output buffer for this escape call and consists of the tile size and reserved bytes, which are defined in the esc_get_capabilities_out structure.

The tile_size member variable is set to 64 and passed back to the RDC client through the ExtEscape function.

Warning

The RDC client sets the tile size internally during decoder initialization. The RemoteFX codec algorithm currently supports 64 x 64 tile sizes. Setting an unsupported tile size in the display driver may cause the RemoteFX session to not work correctly.

See Also

Concepts

Implement a RemoteFX Display Driver