rdpegfx: use 1-based indexing for bitmap cache

Weird but Microsoft uses 1-based indexing in the RDPGFX bitmap
cache PDU's.

This does not seem to be documented but can be deducted from the
RDP client test code in Microsoft's "Windows Protocol Test Suites"
GitHub repository and the observation that mstsc aborts with a
protocol error if the cacheSlot index value 0 is used in e.g. a
GFX surface to cache PDU.
This commit is contained in:
Norbert Federa 2020-02-27 16:43:01 +01:00
parent efde89607b
commit f4d5ec776f
1 changed files with 8 additions and 6 deletions

View File

@ -1991,14 +1991,15 @@ static UINT rdpgfx_set_cache_slot_data(RdpgfxClientContext* context, UINT16 cach
{
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)context->handle;
if (cacheSlot >= gfx->MaxCacheSlot)
/* Microsoft uses 1-based indexing for the egfx bitmap cache ! */
if (cacheSlot == 0 || cacheSlot > gfx->MaxCacheSlot)
{
WLog_ERR(TAG, "%s: invalid cache slot %" PRIu16 " maxAllowed=%" PRIu16 "", __FUNCTION__,
WLog_ERR(TAG, "%s: invalid cache slot %" PRIu16 ", must be between 1 and %" PRIu16 "", __FUNCTION__,
cacheSlot, gfx->MaxCacheSlot);
return ERROR_INVALID_INDEX;
}
gfx->CacheSlots[cacheSlot] = pData;
gfx->CacheSlots[cacheSlot - 1] = pData;
return CHANNEL_RC_OK;
}
@ -2007,14 +2008,15 @@ static void* rdpgfx_get_cache_slot_data(RdpgfxClientContext* context, UINT16 cac
void* pData = NULL;
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)context->handle;
if (cacheSlot >= gfx->MaxCacheSlot)
/* Microsoft uses 1-based indexing for the egfx bitmap cache ! */
if (cacheSlot == 0 || cacheSlot > gfx->MaxCacheSlot)
{
WLog_ERR(TAG, "%s: invalid cache slot %" PRIu16 " maxAllowed=%" PRIu16 "", __FUNCTION__,
WLog_ERR(TAG, "%s: invalid cache slot %" PRIu16 ", must be between 1 and %" PRIu16 "", __FUNCTION__,
cacheSlot, gfx->MaxCacheSlot);
return NULL;
}
pData = gfx->CacheSlots[cacheSlot];
pData = gfx->CacheSlots[cacheSlot - 1];
return pData;
}