FreeRDP / FreeRDP-WebConnect

A gateway for seamless access to your RDP-Sessions in any HTML5-compliant browser
513 stars 1.6k forks source link

casting issue Please advice #47

Open Joseph1977 opened 10 years ago

Joseph1977 commented 10 years ago

I see weird things which not make science:

void Primary::PatBlt(rdpContext _ctx, PATBLTORDER po) { HCLRCONV hclrconv = reinterpret_cast<wsgContext *>(ctx)->clrconv; }

If you look at wsgContext you will see that rdpContext is one of its params:

typedef struct { /* * FreeRDP's original portion. _/ rdpContext p; / * Pointer to the main RDP handler. / RDP *pRDP; / * Pointer to the corresponding Update API module. _/ Update pUpdate; / \ Pointer to the corresponding Primary API module. / Primary pPrimary; /_ * The current color space conversion parameter. */ HCLRCONV clrconv; } wsgContext;

So HOW you can cast struct A to struct B when struct B include A ???!!!!

simply cast small struct A (lets say 100 bytes) to bigger struct B (lets say 1000 bytes), mean the only first 100 bytes in struct B will have data but all the other 900 byes will be garbage or zero, correct?

this mean hclrconv will be garbage as reinterpret_cast(ctx)->clrconv is garbage, right?

alexpilotti commented 10 years ago

To help in troubleshooting, can you please add a link to the code on github where you saw the issue?

Pasting directly the code here does not help much.

Thanks!