Merge pull request #11277 from akallabeth/implement-stuff

Implement stuff
This commit is contained in:
akallabeth
2025-03-04 13:26:03 +01:00
committed by GitHub
13 changed files with 150 additions and 58 deletions

View File

@@ -104,10 +104,10 @@ static UINT encomsp_recv_change_participant_control_level_pdu(EncomspServerConte
static UINT encomsp_server_receive_pdu(EncomspServerContext* context, wStream* s)
{
UINT error = CHANNEL_RC_OK;
ENCOMSP_ORDER_HEADER header;
while (Stream_GetRemainingLength(s) > 0)
{
ENCOMSP_ORDER_HEADER header = { 0 };
if ((error = encomsp_read_header(s, &header)))
{
WLog_ERR(TAG, "encomsp_read_header failed with error %" PRIu32 "!", error);

View File

@@ -992,3 +992,13 @@ BOOL ndr_treat_deferred_write(NdrContext* context, wStream* s)
return TRUE;
}
BOOL ndr_write_data(NdrContext* context, wStream* s, const void* data, size_t sz)
{
if (!Stream_EnsureRemainingCapacity(s, sz))
return FALSE;
Stream_Write(s, data, sz);
ndr_context_bytes_written(context, sz);
return TRUE;
}

View File

@@ -153,6 +153,7 @@ extern "C"
BOOL ndr_skip_bytes(NdrContext* context, wStream* s, size_t nbytes);
BOOL ndr_read_align(NdrContext* context, wStream* s, size_t sz);
BOOL ndr_write_align(NdrContext* context, wStream* s, size_t sz);
BOOL ndr_write_data(NdrContext* context, wStream* s, const void* data, size_t sz);
BOOL ndr_read_pickle(NdrContext* context, wStream* s);
BOOL ndr_write_pickle(NdrContext* context, wStream* s);

View File

@@ -204,16 +204,26 @@ static BOOL ndr_descr_read_RPC_UNICODE_STRING(NdrContext* context, wStream* s, c
return ndr_read_RPC_UNICODE_STRING(context, s, hints, res);
}
#if 0
BOOL ndr_write_RPC_UNICODE_STRING(NdrContext* context, wStream* s, const void* hints,
BOOL ndr_write_RPC_UNICODE_STRING(NdrContext* context, wStream* s,
WINPR_ATTR_UNUSED const void* hints,
const RPC_UNICODE_STRING* res)
{
return ndr_write_uint32(context, s, res->lenHints.length) &&
ndr_write_uint32(context, s, res->lenHints.maxLength) /*&&
ndr_write_BYTE_ptr(context, s, (BYTE*)res->Buffer, res->Length)*/
;
WINPR_ASSERT(res);
if (!ndr_write_uint32(context, s, res->lenHints.length))
return FALSE;
if (!ndr_write_uint32(context, s, res->lenHints.maxLength))
return FALSE;
return ndr_write_data(context, s, res->Buffer, res->strLength);
}
static BOOL ndr_write_RPC_UNICODE_STRING_(NdrContext* context, wStream* s, const void* hints,
const void* pvres)
{
const RPC_UNICODE_STRING* res = pvres;
return ndr_write_RPC_UNICODE_STRING(context, s, hints, res);
}
#endif
void ndr_dump_RPC_UNICODE_STRING(wLog* logger, UINT32 lvl, size_t indentLevel,
const RPC_UNICODE_STRING* obj)
@@ -248,7 +258,7 @@ static void ndr_descr_destroy_RPC_UNICODE_STRING(NdrContext* context, const void
static const NdrMessageDescr RPC_UNICODE_STRING_descr_s = { NDR_ARITY_SIMPLE,
sizeof(RPC_UNICODE_STRING),
ndr_descr_read_RPC_UNICODE_STRING,
/*ndr_write_RPC_UNICODE_STRING*/ NULL,
ndr_write_RPC_UNICODE_STRING_,
ndr_descr_destroy_RPC_UNICODE_STRING,
ndr_descr_dump_RPC_UNICODE_STRING };

View File

@@ -785,15 +785,13 @@ static UINT rdpei_recv_sc_ready_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream*
if (rdpei->version > protocolVersion)
rdpei->version = protocolVersion;
rdpei->features = features;
#if 0
if (protocolVersion != RDPINPUT_PROTOCOL_V10)
if (protocolVersion > RDPINPUT_PROTOCOL_V300)
{
WLog_Print(rdpei->base.log, WLOG_ERROR, "Unknown [MS-RDPEI] protocolVersion: 0x%08"PRIX32"", protocolVersion);
return -1;
WLog_Print(rdpei->base.log, WLOG_WARN,
"Unknown [MS-RDPEI] protocolVersion: 0x%08" PRIX32 "", protocolVersion);
}
#endif
return CHANNEL_RC_OK;
}

View File

@@ -24,6 +24,7 @@
#include "sdl_freerdp.hpp"
#include "sdl_utils.hpp"
#include "sdl_prefs.hpp"
#include "sdl_touch.hpp"
#include <map>
@@ -329,20 +330,24 @@ BOOL sdlInput::keyboard_focus_in()
freerdp_input_send_focus_in_event(input, WINPR_ASSERTING_INT_CAST(UINT16, syncFlags));
/* finish with a mouse pointer position like mstsc.exe if required */
#if 0
if (xfc->remote_app)
return;
if (XQueryPointer(xfc->display, xfc->window->handle, &w, &w, &d, &d, &x, &y, &state))
{
if ((x >= 0) && (x < xfc->window->width) && (y >= 0) && (y < xfc->window->height))
{
xf_event_adjust_coordinates(xfc, &x, &y);
freerdp_client_send_button_event(&xfc->common, FALSE, PTR_FLAGS_MOVE, x, y);
}
}
#endif
return TRUE;
// TODO: fullscreen/remote app
int x = 0;
int y = 0;
if (_sdl->fullscreen)
{
SDL_GetGlobalMouseState(&x, &y);
}
else
{
SDL_GetMouseState(&x, &y);
}
auto w = SDL_GetMouseFocus();
if (w)
{
auto id = SDL_GetWindowID(w);
sdl_scale_coordinates(_sdl, id, &x, &y, TRUE, TRUE);
}
return freerdp_client_send_button_event(_sdl->common(), FALSE, PTR_FLAGS_MOVE, x, y);
}
/* This function is called to update the keyboard indicator LED */

View File

@@ -22,6 +22,7 @@
#include "sdl_freerdp.hpp"
#include "sdl_utils.hpp"
#include "sdl_prefs.hpp"
#include "sdl_touch.hpp"
#include <SDL3/SDL_oldnames.h>
@@ -313,20 +314,26 @@ BOOL sdlInput::keyboard_focus_in()
freerdp_input_send_focus_in_event(input, WINPR_ASSERTING_INT_CAST(uint16_t, syncFlags));
/* finish with a mouse pointer position like mstsc.exe if required */
#if 0
if (xfc->remote_app)
return;
if (XQueryPointer(xfc->display, xfc->window->handle, &w, &w, &d, &d, &x, &y, &state))
{
if ((x >= 0) && (x < xfc->window->width) && (y >= 0) && (y < xfc->window->height))
{
xf_event_adjust_coordinates(xfc, &x, &y);
freerdp_client_send_button_event(&xfc->common, FALSE, PTR_FLAGS_MOVE, x, y);
}
}
#endif
return TRUE;
// TODO: fullscreen/remote app
float fx = 0.0f;
float fy = 0.0f;
if (_sdl->fullscreen)
{
SDL_GetGlobalMouseState(&fx, &fy);
}
else
{
SDL_GetMouseState(&fx, &fy);
}
auto x = static_cast<int32_t>(fx);
auto y = static_cast<int32_t>(fy);
auto w = SDL_GetMouseFocus();
if (w)
{
auto id = SDL_GetWindowID(w);
sdl_scale_coordinates(_sdl, id, &x, &y, TRUE, TRUE);
}
return freerdp_client_send_button_event(_sdl->common(), FALSE, PTR_FLAGS_MOVE, x, y);
}
/* This function is called to update the keyboard indicator LED */

View File

@@ -90,13 +90,14 @@
WLog_VRB("com.freerdp.api", "IFCALLRET(" #_cb ") == NULL"); \
} while (0)
#if 0 // defined(__GNUC__)
#if defined(__GNUC__) || defined(__clang__)
#define IFCALLRESULT(_default_return, _cb, ...) \
({ \
(_cb != NULL) ? _cb(__VA_ARGS__) : ({ \
__extension__({ \
if (_cb == NULL) \
{ \
WLog_VRB("com.freerdp.api", "IFCALLRESULT(" #_cb ") == NULL"); \
(_default_return); \
}); \
} \
((_cb != NULL) ? _cb(__VA_ARGS__) : (_default_return)); \
})
#else
#define IFCALLRESULT(_default_return, _cb, ...) \

View File

@@ -432,7 +432,7 @@ typedef struct gdi_palette gdiPalette;
UINT32 nSrcStep, UINT32 nXSrc, UINT32 nYSrc,
UINT32 nSrcWidth, UINT32 nSrcHeight);
/***
/** @brief fill an area with the color provided.
*
* @param pDstData destination buffer
* @param DstFormat destination buffer format
@@ -450,6 +450,31 @@ typedef struct gdi_palette gdiPalette;
UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst, UINT32 nWidth,
UINT32 nHeight, UINT32 color);
#define FREERDP_IMAGE_FILL_IGNORE_ALPHA 1 /** @since version 3.13.0 */
/** @brief fill an area with the color provided. If flag \b FREERDP_IMAGE_FILL_IGNORE_ALPHA is
* set the destination alpha value will be kept.
*
* @param pDstData destination buffer
* @param DstFormat destination buffer format
* @param nDstStep destination buffer stride (line in bytes) 0 for default
* @param nXDst destination buffer offset x
* @param nYDst destination buffer offset y
* @param nWidth width to copy in pixels
* @param nHeight height to copy in pixels
* @param color Pixel color in DstFormat (internal representation format,
* use FreeRDPGetColor to create)
* @param flags \b FREERDP_IMAGE_FILL_* flags
*
* @return TRUE if success, FALSE otherwise
*
* @since version 3.13.0
*/
FREERDP_API BOOL freerdp_image_fill_ex(BYTE* WINPR_RESTRICT pDstData, DWORD DstFormat,
UINT32 nDstStep, UINT32 nXDst, UINT32 nYDst,
UINT32 nWidth, UINT32 nHeight, UINT32 color,
UINT32 flags);
#ifdef __cplusplus
}
#endif

View File

@@ -1127,6 +1127,37 @@ BOOL freerdp_image_fill(BYTE* WINPR_RESTRICT pDstData, DWORD DstFormat, UINT32 n
return TRUE;
}
BOOL freerdp_image_fill_ex(BYTE* pDstData, DWORD DstFormat, UINT32 nDstStep, UINT32 nXDst,
UINT32 nYDst, UINT32 nWidth, UINT32 nHeight, UINT32 color, UINT32 flags)
{
if (FreeRDPColorHasAlpha(DstFormat) && ((flags & FREERDP_IMAGE_FILL_IGNORE_ALPHA) != 0))
{
const UINT32 bpp = FreeRDPGetBytesPerPixel(DstFormat);
BYTE r = 0;
BYTE g = 0;
BYTE b = 0;
FreeRDPSplitColor(color, DstFormat, &r, &g, &b, NULL, NULL);
for (size_t y = 0; y < nHeight; y++)
{
BYTE* WINPR_RESTRICT line = &pDstData[(y + nYDst) * nDstStep];
for (size_t x = 0; x < nWidth; x++)
{
BYTE* WINPR_RESTRICT dst = &line[x * bpp];
const UINT32 dcolor = FreeRDPReadColor_int(dst, DstFormat);
BYTE a = 0;
FreeRDPSplitColor(dcolor, DstFormat, NULL, NULL, NULL, &a, NULL);
const UINT32 scolor = FreeRDPGetColor(DstFormat, r, g, b, a);
if (!FreeRDPWriteColor_int(dst, DstFormat, scolor))
return FALSE;
}
}
return TRUE;
}
return freerdp_image_fill(pDstData, DstFormat, nDstStep, nXDst, nYDst, nWidth, nHeight, color);
}
#if defined(WITH_SWSCALE)
static int av_format_for_buffer(UINT32 format)
{

View File

@@ -192,11 +192,9 @@ BOOL pcap_get_next_record(rdpPcap* pcap, pcap_record* record)
rdpPcap* pcap_open(const char* name, BOOL write)
{
rdpPcap* pcap = NULL;
WINPR_ASSERT(name);
pcap = (rdpPcap*)calloc(1, sizeof(rdpPcap));
rdpPcap* pcap = (rdpPcap*)calloc(1, sizeof(rdpPcap));
if (!pcap)
goto fail;
@@ -242,7 +240,7 @@ void pcap_flush(rdpPcap* pcap)
while (pcap->record != NULL)
{
pcap_write_record(pcap, pcap->record);
(void)pcap_write_record(pcap, pcap->record);
pcap->record = pcap->record->next;
}

View File

@@ -23,6 +23,8 @@
#include <winpr/crt.h>
#include <winpr/nt.h>
#define HAVE_SORTED_STRUCT 1
struct ntstatus_map
{
DWORD code;
@@ -4616,7 +4618,7 @@ static int ntstatus_compare(const void* pKey, const void* pValue)
const char* NtStatus2Tag(NTSTATUS ntstatus)
{
#if 1 /* Requires sorted struct */
#if defined(HAVE_SORTED_STRUCT) /* Requires sorted struct */
size_t count = ARRAYSIZE(ntstatusmap);
size_t base = sizeof(ntstatusmap[0]);
const struct ntstatus_map* found =
@@ -4638,7 +4640,7 @@ const char* NtStatus2Tag(NTSTATUS ntstatus)
const char* Win32ErrorCode2Tag(UINT16 code)
{
#if 1 /* Requires sorted struct */
#if defined(HAVE_SORTED_STRUCT) /* Requires sorted struct */
DWORD ntstatus = code;
size_t count = ARRAYSIZE(win32errmap);
size_t base = sizeof(win32errmap[0]);

View File

@@ -35,15 +35,19 @@ int TestWtsApiEnumerateProcesses(int argc, char* argv[])
return -1;
}
#if 0
int rc = 0;
{
printf("WTSEnumerateProcesses enumerated %"PRIu32" process:\n", count);
for (DWORD i = 0; i < count; i++)
printf("\t[%"PRIu32"]: %s (%"PRIu32")\n", i, pProcessInfo[i].pProcessName, pProcessInfo[i].ProcessId);
{
const WTS_PROCESS_INFOA* cur = &pProcessInfo[i];
if (!cur->pProcessName)
rc = -1;
printf("\t[%" PRIu32 "]: %s (%" PRIu32 ")\n", i, cur->pProcessName, cur->ProcessId);
}
}
#endif
WTSFreeMemory(pProcessInfo);
return 0;
return rc;
}