ReactOS 0.4.15-dev-7131-ge4d03f4
anonymous_namespace{activex.cpp} Namespace Reference

Functions

HMODULE GetCurrentModule ()
 
void lockServer ()
 
void unlockServer ()
 
bool canUnloadServer ()
 
void FreeLpsz (LPSTR lpsz)
 
LPSTR AllocLpsz (const CHAR *lpsz, size_t cb)
 
LPSTR AllocLpsz (const WCHAR *lpwsz, int cchIn)
 
LPSTR BstrToLpsz (BSTR bstr)
 
BSTR LpszToBstr (LPSTR lpsz)
 
template<class T , class U >
T aligndown (const T &X, const U &align)
 
template<class T , class U >
T alignup (const T &X, const U &align)
 
uint8win32_convert_scanlines (int width, int height, int bitcount, int fromalign, int toalign, const uint8 *data, uint8 **buffer)
 
HBITMAP win32_create_dib (LONG width, LONG height, WORD bitcount, const BYTE *data)
 
HBRUSH win32_create_brush (BRUSH *brush, COLORREF fgcolour)
 

Variables

LONG g_moduleRefCount = 0
 

Function Documentation

◆ aligndown()

template<class T , class U >
T anonymous_namespace{activex.cpp}::aligndown ( const T X,
const U align 
)

Definition at line 130 of file activex.cpp.

131{
132 return X & ~(T(align) - 1);
133}
int align(int length, int align)
Definition: dsound8.c:36
#define T
Definition: mbstring.h:31

Referenced by alignup().

◆ alignup()

template<class T , class U >
T anonymous_namespace{activex.cpp}::alignup ( const T X,
const U align 
)

Definition at line 135 of file activex.cpp.

136{
137 return aligndown(X + (align - 1), align);
138}
T aligndown(const T &X, const U &align)
Definition: activex.cpp:130

Referenced by RdpClientUI::Display_PaintBitmap(), ui_create_glyph(), and win32_convert_scanlines().

◆ AllocLpsz() [1/2]

LPSTR anonymous_namespace{activex.cpp}::AllocLpsz ( const CHAR lpsz,
size_t  cb 
)

Definition at line 61 of file activex.cpp.

62{
63 LPSTR lpszNew = new CHAR[cb + 1];
64
65 if(lpszNew == NULL)
66 return NULL;
67
68 CopyMemory(lpszNew, lpsz, cb);
69 lpszNew[cb] = 0;
70
71 return lpszNew;
72}
#define NULL
Definition: types.h:112
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
#define CopyMemory
Definition: winbase.h:1710
char * LPSTR
Definition: xmlstorage.h:182
char CHAR
Definition: xmlstorage.h:175

Referenced by BstrToLpsz(), and SEALED_::HandleEvent().

◆ AllocLpsz() [2/2]

LPSTR anonymous_namespace{activex.cpp}::AllocLpsz ( const WCHAR lpwsz,
int  cchIn 
)

Definition at line 74 of file activex.cpp.

75{
76 int cch = WideCharToMultiByte(CP_ACP, 0, lpwsz, cchIn, NULL, 0, NULL, NULL);
77
78 if(cch <= 0)
79 return NULL;
80
81 LPSTR lpsz = new CHAR[cch];
82
83 if(lpsz == NULL)
84 return NULL;
85
86 cch = WideCharToMultiByte(CP_ACP, 0, lpwsz, cchIn, lpsz, cch, NULL, NULL);
87
88 if(cch <= 0)
89 {
90 FreeLpsz(lpsz);
91 return NULL;
92 }
93
94 return lpsz;
95}
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202

◆ BstrToLpsz()

LPSTR anonymous_namespace{activex.cpp}::BstrToLpsz ( BSTR  bstr)

Definition at line 97 of file activex.cpp.

98{
99 return AllocLpsz(bstr, SysStringLen(bstr));
100}
LPSTR AllocLpsz(const CHAR *lpsz, size_t cb)
Definition: activex.cpp:61
UINT WINAPI SysStringLen(BSTR str)
Definition: oleaut.c:196

Referenced by SEALED_::IMsTscAx::Connect(), and SEALED_::SetProperty().

◆ canUnloadServer()

bool anonymous_namespace{activex.cpp}::canUnloadServer ( )

Definition at line 45 of file activex.cpp.

46{
47 return g_moduleRefCount == 0;
48}

Referenced by DllCanUnloadNow().

◆ FreeLpsz()

void anonymous_namespace{activex.cpp}::FreeLpsz ( LPSTR  lpsz)

Definition at line 55 of file activex.cpp.

56{
57 if(lpsz)
58 delete[] lpsz;
59}

Referenced by AllocLpsz(), SEALED_::HandleEvent(), and SEALED_::~RdpClient().

◆ GetCurrentModule()

HMODULE anonymous_namespace{activex.cpp}::GetCurrentModule ( )

Definition at line 23 of file activex.cpp.

24{
25 return reinterpret_cast<HMODULE>(&__ImageBase);
26}
#define __ImageBase
Definition: crt_handler.c:22

Referenced by SEALED_::CreateControlWindow(), DllMain(), SEALED_::LoadTypeLibrary(), SEALED_::Shutdown(), RdpClientUI::Startup(), and SEALED_::Startup().

◆ lockServer()

void anonymous_namespace{activex.cpp}::lockServer ( )

Definition at line 35 of file activex.cpp.

36{
38}
#define InterlockedIncrement
Definition: armddk.h:53

Referenced by ClassFactory::ClassFactory(), and ClassFactory::LockServer().

◆ LpszToBstr()

BSTR anonymous_namespace{activex.cpp}::LpszToBstr ( LPSTR  lpsz)

Definition at line 102 of file activex.cpp.

103{
104 int cch = MultiByteToWideChar(CP_ACP, 0, lpsz, -1, NULL, 0);
105
106 if(cch <= 0)
107 return NULL;
108
110
111 if(bstr == NULL)
112 return NULL;
113
114 cch = MultiByteToWideChar(CP_ACP, 0, lpsz, -1, bstr, cch);
115
116 if(cch <= 0)
117 {
118 SysFreeString(bstr);
119 return NULL;
120 }
121
122 return bstr;
123}
OLECHAR * BSTR
Definition: compat.h:2293
#define MultiByteToWideChar
Definition: compat.h:110
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:339

Referenced by SEALED_::GetProperty().

◆ unlockServer()

void anonymous_namespace{activex.cpp}::unlockServer ( )

Definition at line 40 of file activex.cpp.

41{
43}
#define InterlockedDecrement
Definition: armddk.h:52

Referenced by ClassFactory::LockServer(), ClassFactory::~ClassFactory(), and SEALED_::~RdpClient().

◆ win32_convert_scanlines()

uint8 * anonymous_namespace{activex.cpp}::win32_convert_scanlines ( int  width,
int  height,
int  bitcount,
int  fromalign,
int  toalign,
const uint8 data,
uint8 **  buffer 
)

Definition at line 141 of file activex.cpp.

142{
143 // TBD: profile & optimize the most common cases
144 assert(width > 0);
145 assert(height);
146 assert(bitcount && bitcount <= 32);
147 assert(fromalign <= toalign);
148 assert(data);
149 assert(buffer);
150
151 bool flipped = height < 0;
152
153 if(flipped)
154 height = - height;
155
156 int bytesperrow = alignup(width * bitcount, 8) / 8;
157 int fromstride = alignup(bytesperrow, fromalign);
158 int tostride = alignup(bytesperrow, toalign);
159 assert(fromstride <= tostride);
160
161 int datasize = tostride * height;
162
163 uint8 * dibits = new uint8[datasize];
164
165 const uint8 * src = data;
166 uint8 * dest = dibits;
167
168 const int pad = tostride - fromstride;
169
170 assert(pad < 4);
171 __assume(pad < 4);
172
173 if(flipped)
174 {
175 dest += (height - 1) * tostride;
176 tostride = - tostride;
177 }
178
179 for(int i = 0; i < height; ++ i)
180 {
181 memcpy(dest, src, fromstride);
182 memset(dest + fromstride, 0, pad);
183 src += fromstride;
184 dest += tostride;
185 }
186
187 *buffer = dibits;
188 return dibits;
189}
unsigned char uint8
Definition: types.h:28
static SIZE_T datasize
Definition: asm.c:30
#define assert(x)
Definition: debug.h:53
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
GLenum src
Definition: glext.h:6340
GLuint buffer
Definition: glext.h:5915
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define __assume(x)
Definition: intrin.h:108
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static char * dest
Definition: rtl.c:135
T alignup(const T &X, const U &align)
Definition: activex.cpp:135
BYTE * dibits
Definition: pal.c:27
#define memset(x, y, z)
Definition: compat.h:39

Referenced by ui_create_cursor(), and ui_create_glyph().

◆ win32_create_brush()

HBRUSH anonymous_namespace{activex.cpp}::win32_create_brush ( BRUSH brush,
COLORREF  fgcolour 
)

Definition at line 240 of file activex.cpp.

241{
242 if(brush == NULL)
243 return (HBRUSH)GetStockObject(NULL_BRUSH);
244
245 switch(brush->style)
246 {
247 case BS_SOLID:
248 case BS_NULL:
249 case BS_HATCHED:
250 case BS_PATTERN:
251 case BS_PATTERN8X8:
252 break;
253
254 default:
255 return NULL;
256 }
257
258 switch(brush->style)
259 {
260 case BS_SOLID:
261 return CreateSolidBrush(fgcolour);
262
263 case BS_HATCHED:
264 return CreateHatchBrush(brush->pattern[0], fgcolour);
265
266 case BS_NULL:
267 return (HBRUSH)GetStockObject(NULL_BRUSH);
268
269 case BS_PATTERN:
270 case BS_PATTERN8X8:
271 {
272 uint16 pattern[8];
273
274 for(size_t i = 0; i < 8; ++ i)
275 pattern[i] = brush->pattern[i];
276
277 HBITMAP hpattern = CreateBitmap(8, 8, 1, 1, pattern);
278 HBRUSH hbr = CreatePatternBrush(hpattern);
279 DeleteObject(hpattern);
280 return hbr;
281 }
282
284 }
285}
unsigned short uint16
Definition: types.h:30
pKey DeleteObject()
GLubyte * pattern
Definition: glext.h:7787
static HBITMAP
Definition: button.c:44
#define DEFAULT_UNREACHABLE
HGDIOBJ WINAPI GetStockObject(_In_ int)
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
#define BS_PATTERN8X8
Definition: wingdi.h:1094
#define BS_HATCHED
Definition: wingdi.h:1089
HBRUSH WINAPI CreateHatchBrush(_In_ int, _In_ COLORREF)
#define BS_PATTERN
Definition: wingdi.h:1090
#define NULL_BRUSH
Definition: wingdi.h:901
#define BS_NULL
Definition: wingdi.h:1087
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define BS_SOLID
Definition: wingdi.h:1086
HBRUSH WINAPI CreatePatternBrush(_In_ HBITMAP)

Referenced by RdpClientUI::Display_PatBlt(), and RdpClientUI::Display_Polygon().

◆ win32_create_dib()

HBITMAP anonymous_namespace{activex.cpp}::win32_create_dib ( LONG  width,
LONG  height,
WORD  bitcount,
const BYTE data 
)

Definition at line 192 of file activex.cpp.

193{
194 struct b_
195 {
196 BITMAPINFO bmi;
197 RGBQUAD colormap[256 - ARRAYSIZE(RTL_FIELD_TYPE(BITMAPINFO, bmiColors))];
198 }
199 b;
200
201 b.bmi.bmiHeader.biSize = sizeof(b.bmi.bmiHeader);
202 b.bmi.bmiHeader.biWidth = width;
203 b.bmi.bmiHeader.biHeight = height;
204 b.bmi.bmiHeader.biPlanes = 1;
205 b.bmi.bmiHeader.biBitCount = bitcount;
206 b.bmi.bmiHeader.biCompression = BI_RGB;
207 b.bmi.bmiHeader.biSizeImage = 0;
208 b.bmi.bmiHeader.biXPelsPerMeter = 0;
209 b.bmi.bmiHeader.biYPelsPerMeter = 0;
210
211 if(bitcount > 8)
212 {
213 b.bmi.bmiHeader.biClrUsed = 0;
214 b.bmi.bmiHeader.biClrImportant = 0;
215 }
216 else
217 {
218 b.bmi.bmiHeader.biClrUsed = 2 << bitcount;
219 b.bmi.bmiHeader.biClrImportant = 2 << bitcount;
220
221 // TODO: palette
222 }
223
224 // FIXME: beyond ugly
226
227 if(hdc == NULL)
228 return NULL;
229
230 HBITMAP hbm = CreateDIBitmap(hdc, &b.bmi.bmiHeader, CBM_INIT, data, &b.bmi, DIB_RGB_COLORS);
231
232 if(hbm == NULL)
233 error("CreateDIBitmap %dx%dx%d failed\n", width, height, bitcount);
234
235 DeleteDC(hdc);
236 return hbm;
237}
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define BI_RGB
Definition: precomp.h:47
ULONG RGBQUAD
Definition: precomp.h:50
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define b
Definition: ke_i.h:79
#define error(str)
Definition: mkdosfs.c:1605
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
#define RTL_FIELD_TYPE(type, field)
Definition: ntbasedef.h:667
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
#define DIB_RGB_COLORS
Definition: wingdi.h:367
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define CBM_INIT
Definition: wingdi.h:365
BOOL WINAPI DeleteDC(_In_ HDC)
HBITMAP WINAPI CreateDIBitmap(_In_ HDC hdc, _In_opt_ const BITMAPINFOHEADER *pbmih, _In_ DWORD fdwInit, _In_opt_ const VOID *pvInit, _In_opt_ const BITMAPINFO *pbmi, _In_ UINT uUsage)

Referenced by ui_create_bitmap(), and ui_create_cursor().

Variable Documentation

◆ g_moduleRefCount

LONG anonymous_namespace{activex.cpp}::g_moduleRefCount = 0

Definition at line 33 of file activex.cpp.

Referenced by canUnloadServer(), lockServer(), and unlockServer().